eth_getTransactionCount implementation (#91)

* Implemented eth_getTransactionCount endpoint

* Linting fixes
This commit is contained in:
Austin Abell
2019-09-06 10:46:26 -04:00
committed by GitHub
parent 0e942527da
commit 1e48e2b115
3 changed files with 43 additions and 4 deletions
+10 -2
View File
@@ -102,8 +102,16 @@ func (e *PublicEthAPI) GetStorageAt(address common.Address, key string, blockNum
}
// GetTransactionCount returns the number of transactions at the given address up to the given block number.
func (e *PublicEthAPI) GetTransactionCount(address common.Address, blockNum rpc.BlockNumber) hexutil.Uint64 {
return 0
func (e *PublicEthAPI) GetTransactionCount(address common.Address, blockNum rpc.BlockNumber) (hexutil.Uint64, error) {
ctx := e.cliCtx.WithHeight(blockNum.Int64())
res, _, err := ctx.QueryWithData(fmt.Sprintf("custom/%s/nonce/%s", types.ModuleName, address), nil)
if err != nil {
return 0, err
}
var out types.QueryResNonce
e.cliCtx.Codec.MustUnmarshalJSON(res, &out)
return hexutil.Uint64(out.Nonce), nil
}
// GetBlockTransactionCountByHash returns the number of transactions in the block identified by hash.