Skip to content

Commit bd93ef6

Browse files
authored
Merge pull request #116 from XinFinOrg/fix-issue-with-methods-returning-num-instead-of-hex
2 parents 4d61f00 + cf8b889 commit bd93ef6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

internal/ethapi/api.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI {
8282
}
8383

8484
// GasPrice returns a suggestion for a gas price.
85-
func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*big.Int, error) {
86-
return s.b.SuggestPrice(ctx)
85+
func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) {
86+
price, err := s.b.SuggestPrice(ctx)
87+
return (*hexutil.Big)(price), err
8788
}
8889

8990
// ProtocolVersion returns the current Ethereum protocol version this node supports
@@ -512,9 +513,9 @@ func NewPublicBlockChainAPI(b Backend, chainReader consensus.ChainReader) *Publi
512513
}
513514

514515
// BlockNumber returns the block number of the chain head.
515-
func (s *PublicBlockChainAPI) BlockNumber() *big.Int {
516+
func (s *PublicBlockChainAPI) BlockNumber() hexutil.Uint64 {
516517
header, _ := s.b.HeaderByNumber(context.Background(), rpc.LatestBlockNumber) // latest header should always be available
517-
return header.Number
518+
return hexutil.Uint64(header.Number.Uint64())
518519
}
519520

520521
// BlockNumber returns the block number of the chain head.
@@ -525,13 +526,12 @@ func (s *PublicBlockChainAPI) GetRewardByHash(hash common.Hash) map[string]map[s
525526
// GetBalance returns the amount of wei for the given address in the state of the
526527
// given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta
527528
// block numbers are also allowed.
528-
func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*big.Int, error) {
529+
func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Big, error) {
529530
state, _, err := s.b.StateAndHeaderByNumber(ctx, blockNr)
530531
if state == nil || err != nil {
531532
return nil, err
532533
}
533-
b := state.GetBalance(address)
534-
return b, state.Error()
534+
return (*hexutil.Big)(state.GetBalance(address)), state.Error()
535535
}
536536

537537
// GetTransactionAndReceiptProof returns the Trie transaction and receipt proof of the given transaction hash.

0 commit comments

Comments
 (0)