@@ -76,31 +76,29 @@ func (e *PublicEthAPI) BlockNumber() *big.Int {
7676}
7777
7878// GetBalance returns the provided account's balance up to the provided block number.
79- func (e * PublicEthAPI ) GetBalance (address common.Address , blockNum rpc.BlockNumber ) * hexutil.Big {
79+ func (e * PublicEthAPI ) GetBalance (address common.Address , blockNum rpc.BlockNumber ) ( * hexutil.Big , error ) {
8080 ctx := e .cliCtx .WithHeight (blockNum .Int64 ())
8181 res , _ , err := ctx .QueryWithData (fmt .Sprintf ("custom/%s/balance/%s" , types .ModuleName , address ), nil )
8282 if err != nil {
83- fmt .Printf ("could not resolve: %s\n " , err )
84- return nil
83+ return nil , err
8584 }
8685
8786 var out types.QueryResBalance
8887 e .cliCtx .Codec .MustUnmarshalJSON (res , & out )
89- return (* hexutil .Big )(out .Balance )
88+ return (* hexutil .Big )(out .Balance ), nil
9089}
9190
9291// GetStorageAt returns the contract storage at the given address, block number, and key.
93- func (e * PublicEthAPI ) GetStorageAt (address common.Address , key string , blockNum rpc.BlockNumber ) hexutil.Bytes {
92+ func (e * PublicEthAPI ) GetStorageAt (address common.Address , key string , blockNum rpc.BlockNumber ) ( hexutil.Bytes , error ) {
9493 ctx := e .cliCtx .WithHeight (blockNum .Int64 ())
9594 res , _ , err := ctx .QueryWithData (fmt .Sprintf ("custom/%s/storage/%s/%s" , types .ModuleName , address , key ), nil )
9695 if err != nil {
97- fmt .Printf ("could not resolve: %s\n " , err )
98- return nil
96+ return nil , err
9997 }
10098
10199 var out types.QueryResStorage
102100 e .cliCtx .Codec .MustUnmarshalJSON (res , & out )
103- return out .Value [:]
101+ return out .Value [:], nil
104102}
105103
106104// GetTransactionCount returns the number of transactions at the given address up to the given block number.
@@ -140,17 +138,16 @@ func (e *PublicEthAPI) GetUncleCountByBlockNumber(blockNum rpc.BlockNumber) hexu
140138}
141139
142140// GetCode returns the contract code at the given address and block number.
143- func (e * PublicEthAPI ) GetCode (address common.Address , blockNumber rpc.BlockNumber ) hexutil.Bytes {
141+ func (e * PublicEthAPI ) GetCode (address common.Address , blockNumber rpc.BlockNumber ) ( hexutil.Bytes , error ) {
144142 ctx := e .cliCtx .WithHeight (blockNumber .Int64 ())
145143 res , _ , err := ctx .QueryWithData (fmt .Sprintf ("custom/%s/code/%s" , types .ModuleName , address ), nil )
146144 if err != nil {
147- fmt .Printf ("could not resolve: %s\n " , err )
148- return nil
145+ return nil , err
149146 }
150147
151148 var out types.QueryResCode
152149 e .cliCtx .Codec .MustUnmarshalJSON (res , & out )
153- return out .Code
150+ return out .Code , nil
154151}
155152
156153// Sign signs the provided data using the private key of address via Geth's signature standard.
0 commit comments