hermez-node/api/config.go
api/config.goRaw
1package api
2
3import (
4 "math/big"
5 "net/http"
6
7 ethCommon "github.com/ethereum/go-ethereum/common"
8 "github.com/gin-gonic/gin"
9 "github.com/hermeznetwork/hermez-node/common"
10)
11
12type rollupConstants struct {
13 PublicConstants common.RollupConstants `json:"publicConstants"`
14 MaxFeeIdxCoordinator int `json:"maxFeeIdxCoordinator"`
15 ReservedIdx int `json:"reservedIdx"`
16 ExitIdx int `json:"exitIdx"`
17 LimitDepositAmount *big.Int `json:"limitDepositAmount"`
18 LimitL2TransferAmount *big.Int `json:"limitL2TransferAmount"`
19 LimitTokens int `json:"limitTokens"`
20 L1CoordinatorTotalBytes int `json:"l1CoordinatorTotalBytes"`
21 L1UserTotalBytes int `json:"l1UserTotalBytes"`
22 MaxL1UserTx int `json:"maxL1UserTx"`
23 MaxL1Tx int `json:"maxL1Tx"`
24 InputSHAConstantBytes int `json:"inputSHAConstantBytes"`
25 NumBuckets int `json:"numBuckets"`
26 MaxWithdrawalDelay int `json:"maxWithdrawalDelay"`
27 ExchangeMultiplier int `json:"exchangeMultiplier"`
28}
29
30func newRollupConstants(publicConstants common.RollupConstants) *rollupConstants {
31 return &rollupConstants{
32 PublicConstants: publicConstants,
33 MaxFeeIdxCoordinator: common.RollupConstMaxFeeIdxCoordinator,
34 ReservedIdx: common.RollupConstReservedIDx,
35 ExitIdx: common.RollupConstExitIDx,
36 LimitDepositAmount: common.RollupConstLimitDepositAmount,
37 LimitL2TransferAmount: common.RollupConstLimitL2TransferAmount,
38 LimitTokens: common.RollupConstLimitTokens,
39 L1CoordinatorTotalBytes: common.RollupConstL1CoordinatorTotalBytes,
40 L1UserTotalBytes: common.RollupConstL1UserTotalBytes,
41 MaxL1UserTx: common.RollupConstMaxL1UserTx,
42 MaxL1Tx: common.RollupConstMaxL1Tx,
43 InputSHAConstantBytes: common.RollupConstInputSHAConstantBytes,
44 NumBuckets: common.RollupConstNumBuckets,
45 MaxWithdrawalDelay: common.RollupConstMaxWithdrawalDelay,
46 ExchangeMultiplier: common.RollupConstExchangeMultiplier,
47 }
48}
49
50// Config of the API
51type Config struct {
52 RollupConstants common.RollupConstants
53 AuctionConstants common.AuctionConstants
54 WDelayerConstants common.WDelayerConstants
55 ChainID uint16
56 HermezAddress ethCommon.Address
57}
58
59type configAPI struct {
60 ChainID uint16 `json:"chainId"`
61 RollupConstants rollupConstants `json:"hermez"`
62 AuctionConstants common.AuctionConstants `json:"auction"`
63 WDelayerConstants common.WDelayerConstants `json:"withdrawalDelayer"`
64}
65
66func (a *API) getConfig(c *gin.Context) {
67 c.JSON(http.StatusOK, a.cg)
68}