forked from cerc-io/laconicd-deprecated
get account sequence in GetTransactionCount (#303)
* get account sequence if querying latest in GetTransactionCount * use ctx WithHeight in GetTransactionCount; remove nonce query from querier
This commit is contained in:
+9
-4
@@ -181,14 +181,19 @@ 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 BlockNumber) (*hexutil.Uint64, error) {
|
||||
ctx := e.cliCtx.WithHeight(blockNum.Int64())
|
||||
res, _, err := ctx.QueryWithData(fmt.Sprintf("custom/%s/nonce/%s", types.ModuleName, address.Hex()), nil)
|
||||
|
||||
// Get nonce (sequence) from account
|
||||
from := sdk.AccAddress(address.Bytes())
|
||||
authclient.Codec = codec.NewAppCodec(ctx.Codec)
|
||||
accRet := authtypes.NewAccountRetriever(authclient.Codec, ctx)
|
||||
|
||||
_, nonce, err := accRet.GetAccountNumberSequence(from)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var out types.QueryResNonce
|
||||
e.cliCtx.Codec.MustUnmarshalJSON(res, &out)
|
||||
return (*hexutil.Uint64)(&out.Nonce), nil
|
||||
n := hexutil.Uint64(nonce)
|
||||
return &n, nil
|
||||
}
|
||||
|
||||
// GetBlockTransactionCountByHash returns the number of transactions in the block identified by hash.
|
||||
|
||||
Reference in New Issue
Block a user