mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Merge pull request #675 from hermeznetwork/feature/configChainId
added chainId to config API
This commit is contained in:
@@ -21,7 +21,7 @@ func (a *API) postAccountCreationAuth(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// API to common + verify signature
|
// API to common + verify signature
|
||||||
commonAuth := accountCreationAuthAPIToCommon(&apiAuth)
|
commonAuth := accountCreationAuthAPIToCommon(&apiAuth)
|
||||||
if !commonAuth.VerifySignature(a.chainID, a.hermezAddress) {
|
if !commonAuth.VerifySignature(a.cg.ChainID, a.hermezAddress) {
|
||||||
retBadReq(errors.New("invalid signature"), c)
|
retBadReq(errors.New("invalid signature"), c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ type API struct {
|
|||||||
h *historydb.HistoryDB
|
h *historydb.HistoryDB
|
||||||
cg *configAPI
|
cg *configAPI
|
||||||
l2 *l2db.L2DB
|
l2 *l2db.L2DB
|
||||||
chainID uint16
|
|
||||||
hermezAddress ethCommon.Address
|
hermezAddress ethCommon.Address
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,9 +67,9 @@ func NewAPI(
|
|||||||
RollupConstants: *newRollupConstants(consts.Rollup),
|
RollupConstants: *newRollupConstants(consts.Rollup),
|
||||||
AuctionConstants: consts.Auction,
|
AuctionConstants: consts.Auction,
|
||||||
WDelayerConstants: consts.WDelayer,
|
WDelayerConstants: consts.WDelayer,
|
||||||
|
ChainID: consts.ChainID,
|
||||||
},
|
},
|
||||||
l2: l2db,
|
l2: l2db,
|
||||||
chainID: consts.ChainID,
|
|
||||||
hermezAddress: consts.HermezAddress,
|
hermezAddress: consts.HermezAddress,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ func TestMain(m *testing.M) {
|
|||||||
chainID := uint16(0)
|
chainID := uint16(0)
|
||||||
_config := getConfigTest(chainID)
|
_config := getConfigTest(chainID)
|
||||||
config = configAPI{
|
config = configAPI{
|
||||||
|
ChainID: chainID,
|
||||||
RollupConstants: *newRollupConstants(_config.RollupConstants),
|
RollupConstants: *newRollupConstants(_config.RollupConstants),
|
||||||
AuctionConstants: _config.AuctionConstants,
|
AuctionConstants: _config.AuctionConstants,
|
||||||
WDelayerConstants: _config.WDelayerConstants,
|
WDelayerConstants: _config.WDelayerConstants,
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type configAPI struct {
|
type configAPI struct {
|
||||||
|
ChainID uint16 `json:"chainId"`
|
||||||
RollupConstants rollupConstants `json:"hermez"`
|
RollupConstants rollupConstants `json:"hermez"`
|
||||||
AuctionConstants common.AuctionConstants `json:"auction"`
|
AuctionConstants common.AuctionConstants `json:"auction"`
|
||||||
WDelayerConstants common.WDelayerConstants `json:"withdrawalDelayer"`
|
WDelayerConstants common.WDelayerConstants `json:"withdrawalDelayer"`
|
||||||
|
|||||||
@@ -3040,10 +3040,15 @@ components:
|
|||||||
- maxEmergencyModeTime
|
- maxEmergencyModeTime
|
||||||
- hermezRollup
|
- hermezRollup
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
chainId:
|
||||||
|
type: integer
|
||||||
|
description: Id of the chain
|
||||||
|
example: 27
|
||||||
required:
|
required:
|
||||||
- hermez
|
- hermez
|
||||||
- auction
|
- auction
|
||||||
- withdrawalDelayer
|
- withdrawalDelayer
|
||||||
|
- chainId
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
Error:
|
Error:
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ func (a *API) verifyPoolL2TxWrite(txw *l2db.PoolL2TxWrite) error {
|
|||||||
poolTx.TokenID, account.TokenID))
|
poolTx.TokenID, account.TokenID))
|
||||||
}
|
}
|
||||||
// Check signature
|
// Check signature
|
||||||
if !poolTx.VerifySignature(a.chainID, account.BJJ) {
|
if !poolTx.VerifySignature(a.cg.ChainID, account.BJJ) {
|
||||||
return tracerr.Wrap(errors.New("wrong signature"))
|
return tracerr.Wrap(errors.New("wrong signature"))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user