Merge pull request #476 from hermeznetwork/feature/api-big-ints-removal

Remove bigints from API
This commit is contained in:
a_bennassar
2021-01-12 15:35:16 +01:00
committed by GitHub
6 changed files with 88 additions and 28 deletions

View File

@@ -1380,8 +1380,8 @@ func (hdb *HistoryDB) GetAllBucketUpdates() ([]common.BucketUpdate, error) {
}
// GetBucketUpdates retrieves latest values for each bucket
func (hdb *HistoryDB) GetBucketUpdates() ([]common.BucketUpdate, error) {
var bucketUpdates []*common.BucketUpdate
func (hdb *HistoryDB) GetBucketUpdates() ([]BucketUpdateAPI, error) {
var bucketUpdates []*BucketUpdateAPI
err := meddler.QueryAll(
hdb.db, &bucketUpdates,
`SELECT num_bucket, withdrawals FROM bucket_update
@@ -1389,7 +1389,7 @@ func (hdb *HistoryDB) GetBucketUpdates() ([]common.BucketUpdate, error) {
group by num_bucket)
ORDER BY num_bucket ASC;`,
)
return db.SlicePtrsToSlice(bucketUpdates).([]common.BucketUpdate), tracerr.Wrap(err)
return db.SlicePtrsToSlice(bucketUpdates).([]BucketUpdateAPI), tracerr.Wrap(err)
}
func (hdb *HistoryDB) addTokenExchanges(d meddler.DB, tokenExchanges []common.TokenExchange) error {

View File

@@ -343,3 +343,31 @@ type MinBidInfo struct {
DefaultSlotSetBid [6]*big.Int `json:"defaultSlotSetBid" meddler:"default_slot_set_bid,json" validate:"required"`
DefaultSlotSetBidSlotNum int64 `json:"-" meddler:"default_slot_set_bid_slot_num"`
}
// BucketUpdateAPI are the bucket updates (tracking the withdrawals value changes)
// in Rollup Smart Contract
type BucketUpdateAPI struct {
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
NumBucket int `json:"numBucket" meddler:"num_bucket"`
BlockStamp int64 `json:"blockStamp" meddler:"block_stamp"`
Withdrawals *apitypes.BigIntStr `json:"withdrawals" meddler:"withdrawals"`
}
// BucketParamsAPI are the parameter variables of each Bucket of Rollup Smart
// Contract
type BucketParamsAPI struct {
CeilUSD *apitypes.BigIntStr `json:"ceilUSD"`
Withdrawals *apitypes.BigIntStr `json:"withdrawals"`
BlockWithdrawalRate *apitypes.BigIntStr `json:"blockWithdrawalRate"`
MaxWithdrawals *apitypes.BigIntStr `json:"maxWithdrawals"`
}
// RollupVariablesAPI are the variables of the Rollup Smart Contract
type RollupVariablesAPI struct {
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
FeeAddToken *apitypes.BigIntStr `json:"feeAddToken" meddler:"fee_add_token" validate:"required"`
ForgeL1L2BatchTimeout int64 `json:"forgeL1L2BatchTimeout" meddler:"forge_l1_timeout" validate:"required"`
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay" validate:"required"`
Buckets [common.RollupConstNumBuckets]BucketParamsAPI `json:"buckets" meddler:"buckets,json"`
SafeMode bool `json:"safeMode" meddler:"safe_mode"`
}