Skip to content

Commit

Permalink
revert HasAccount to its original definition in case future libraries…
Browse files Browse the repository at this point in the history
…/code uses it.

set function which checks for account with mapping condition included name to be AccountExists instead
  • Loading branch information
randy75828 committed Dec 30, 2022
1 parent 84e120b commit b45c030
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions x/auth/keeper/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc types.AccountI) types.Ac
return acc
}

// HasAccount implements AccountKeeperI.
func (ak AccountKeeper) HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool {
// AccountExists implements AccountKeeperI.
// Check if an account exists in the store, includes check for mapping.
func (ak AccountKeeper) AccountExists(ctx sdk.Context, addr sdk.AccAddress) bool {
store := ctx.KVStore(ak.key)
if !store.Has(types.AddressStoreKey(addr)) {
cosmosAddr := ak.GetCorrespondingCosmosAddressIfExists(ctx, addr)
Expand All @@ -38,10 +39,9 @@ func (ak AccountKeeper) HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool {
return true
}

// HasExactAccount implements AccountKeeperI.
// Checks if account exists based on address directly, doesn't check for mapping.
// Original cosmos implementation of HasAccount
func (ak AccountKeeper) HasExactAccount(ctx sdk.Context, addr sdk.AccAddress) bool {
// HasAccount implements AccountKeeperI.
// Check if an account exists in the store based on address directly, doesn't check for mapping.
func (ak AccountKeeper) HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool {
store := ctx.KVStore(ak.key)
return store.Has(types.AddressStoreKey(addr))
}
Expand Down
8 changes: 4 additions & 4 deletions x/auth/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ type AccountKeeperI interface {
// Return a new account with the next account number. Does not save the new account to the store.
NewAccount(sdk.Context, types.AccountI) types.AccountI

// Check if an account exists in the store.
HasAccount(sdk.Context, sdk.AccAddress) bool

// Check if an account is a module account
IsModuleAccount(sdk.Context, sdk.AccAddress) bool

// Check if an account exists in the store, includes check for mapping.
AccountExists(sdk.Context, sdk.AccAddress) bool

// Check if an account exists in the store based on address directly, doesn't check for mapping.
HasExactAccount(sdk.Context, sdk.AccAddress) bool
HasAccount(sdk.Context, sdk.AccAddress) bool

// Retrieve an account from the store.
GetAccount(sdk.Context, sdk.AccAddress) types.AccountI
Expand Down
4 changes: 2 additions & 2 deletions x/bank/keeper/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (k BaseSendKeeper) InputOutputCoins(ctx sdk.Context, inputs []types.Input,
//
// NOTE: This should ultimately be removed in favor a more flexible approach
// such as delegated fee messages.
accExists := k.ak.HasAccount(ctx, outAddress)
accExists := k.ak.AccountExists(ctx, outAddress)
if !accExists {
defer telemetry.IncrCounter(1, "new", "account")
k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, outAddress))
Expand Down Expand Up @@ -174,7 +174,7 @@ func (k BaseSendKeeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAd
//
// NOTE: This should ultimately be removed in favor a more flexible approach
// such as delegated fee messages.
accExists := k.ak.HasAccount(ctx, toAddr)
accExists := k.ak.AccountExists(ctx, toAddr)
if !accExists {
defer telemetry.IncrCounter(1, "new", "account")
k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, toAddr))
Expand Down
2 changes: 1 addition & 1 deletion x/bank/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type AccountKeeper interface {

GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI
GetAllAccounts(ctx sdk.Context) []types.AccountI
AccountExists(ctx sdk.Context, addr sdk.AccAddress) bool
HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool
HasExactAccount(ctx sdk.Context, addr sdk.AccAddress) bool
SetAccount(ctx sdk.Context, acc types.AccountI)

IterateAccounts(ctx sdk.Context, process func(types.AccountI) bool)
Expand Down

0 comments on commit b45c030

Please sign in to comment.