Skip to content

Commit e8d1a81

Browse files
committed
EnsureExists
1 parent 5759b35 commit e8d1a81

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

rpc/backend/account_info.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
errorsmod "cosmossdk.io/errors"
2222
sdkmath "cosmossdk.io/math"
2323
"github.com/cometbft/cometbft/libs/bytes"
24-
sdk "github.com/cosmos/cosmos-sdk/types"
2524
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
2625
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
2726
"github.com/ethereum/go-ethereum/common"
@@ -206,11 +205,7 @@ func (b *Backend) GetTransactionCount(address common.Address, blockNum rpctypes.
206205
)
207206
}
208207
// Get nonce (sequence) from account
209-
from := sdk.AccAddress(address.Bytes())
210-
accRet := b.clientCtx.AccountRetriever
211-
212-
err = accRet.EnsureExists(b.clientCtx, from)
213-
if err != nil {
208+
if err := b.clientCtx.AccountRetriever.EnsureExists(b.clientCtx, address.Bytes()); err != nil {
214209
// account doesn't exist yet, return 0
215210
return &n, nil
216211
}

rpc/backend/backend_suite_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/cosmos/cosmos-sdk/crypto/keyring"
1515
"github.com/cosmos/cosmos-sdk/server"
1616
sdk "github.com/cosmos/cosmos-sdk/types"
17+
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
1718
"github.com/ethereum/go-ethereum/common"
1819
ethtypes "github.com/ethereum/go-ethereum/core/types"
1920
"github.com/stretchr/testify/suite"
@@ -76,6 +77,7 @@ func (suite *BackendTestSuite) SetupTest() {
7677
WithTxConfig(encodingConfig.TxConfig).
7778
WithKeyringDir(clientDir).
7879
WithKeyring(keyRing).
80+
WithAddressCodec(authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())).
7981
WithAccountRetriever(client.TestAccountRetriever{Accounts: accounts})
8082

8183
allowUnprotectedTxs := false

0 commit comments

Comments
 (0)