diff --git a/eth/api.go b/eth/api.go index c205053e75b4..776e7125883a 100644 --- a/eth/api.go +++ b/eth/api.go @@ -728,8 +728,19 @@ func (api *PublicWemixAPI) HalvingSchedule() []*HalvingInfo { return result } -func (api *PublicWemixAPI) GetBriocheBlockReward(blockNumber *hexutil.Big) *hexutil.Big { - return (*hexutil.Big)(api.getBriocheBlockReward((*big.Int)(blockNumber))) +func (api *PublicWemixAPI) GetBriocheBlockReward(blockNumber rpc.BlockNumber) *hexutil.Big { + height := new(big.Int) + if blockNumber == rpc.LatestBlockNumber { + height.Set(api.e.BlockChain().CurrentHeader().Number) + } else if blockNumber == rpc.FinalizedBlockNumber { + height.Set(api.e.BlockChain().CurrentHeader().Number) + } else if blockNumber == rpc.PendingBlockNumber { + height.Set(api.e.miner.PendingBlock().Header().Number) + } else { + height.SetInt64(blockNumber.Int64()) + } + + return (*hexutil.Big)(api.getBriocheBlockReward(height)) } func (api *PublicWemixAPI) getBriocheBlockReward(blockNumber *big.Int) *big.Int { @@ -742,13 +753,7 @@ func (api *PublicWemixAPI) getBriocheBlockReward(blockNumber *big.Int) *big.Int } wemixInfo := *wemixInfoPtr config := api.e.BlockChain().Config() - - height := new(big.Int) - if blockNumber == nil { - height.Set(api.e.BlockChain().CurrentHeader().Number) - } else { - height.Set(blockNumber) - } + height := new(big.Int).Set(blockNumber) if config.IsBrioche(height) { return config.Brioche.GetBriocheBlockReward(wemixInfo["defaultBriocheBlockReward"].(*big.Int), height) diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index b593a7850a43..64d871e5139f 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -1013,8 +1013,7 @@ web3._extend({ new web3._extend.Method({ name: 'getBriocheBlockReward', call: 'wemix_getBriocheBlockReward', - params: 1, - inputFormatter: [null] + params: 1 }) ], properties: