Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sontrinh16 committed Jun 3, 2024
1 parent 5da3500 commit 35c522e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion testutil/mock/logger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions x/accounts/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ func (k Keeper) NextAccountNumber(
return accNum, nil
}

// InitAccountNumberSeq use to set accounts account number tracking.
// InitAccountNumberSeqUnsafe use to set accounts account number tracking.
// Only use for account number migration.
func (k Keeper) InitAccountNumberSeq(ctx context.Context, accNum uint64) error {
func (k Keeper) InitAccountNumberSeqUnsafe(ctx context.Context, accNum uint64) error {
currentNum, err := k.AccountNumber.Peek(ctx)
if err != nil {
return err
Expand Down
15 changes: 15 additions & 0 deletions x/auth/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ type AccountKeeperI interface {
// Fetch the sequence of an account at a specified address.
GetSequence(context.Context, sdk.AccAddress) (uint64, error)

// Fetch the next account number, and increment the internal counter.
NextAccountNumber(context.Context) uint64

// GetModulePermissions fetches per-module account permissions
GetModulePermissions() map[string]types.PermissionsForAddress

Expand Down Expand Up @@ -175,6 +178,18 @@ func (ak AccountKeeper) GetSequence(ctx context.Context, addr sdk.AccAddress) (u
return acc.GetSequence(), nil
}

// NextAccountNumber returns and increments the global account number counter.
// If the global account number is not set, it initializes it with value 0.
//
// Depricated: keep this to avoid break api
func (ak AccountKeeper) NextAccountNumber(ctx context.Context) uint64 {
n, err := ak.AccountsModKeeper.NextAccountNumber(ctx)
if err != nil {
panic(err)
}
return n
}

// GetModulePermissions fetches per-module account permissions.
func (ak AccountKeeper) GetModulePermissions() map[string]types.PermissionsForAddress {
return ak.permAddrs
Expand Down
2 changes: 1 addition & 1 deletion x/auth/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (m Migrator) Migrate5To6(ctx context.Context) error {
return err
}

return m.keeper.AccountsModKeeper.InitAccountNumberSeq(ctx, currentAccNum)
return m.keeper.AccountsModKeeper.InitAccountNumberSeqUnsafe(ctx, currentAccNum)
}

// V45SetAccount implements V45_SetAccount
Expand Down
12 changes: 6 additions & 6 deletions x/auth/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions x/auth/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type AccountsModKeeper interface {
IsAccountsModuleAccount(ctx context.Context, accountAddr []byte) bool
NextAccountNumber(ctx context.Context) (accNum uint64, err error)

// InitAccountNumberSeq is use to set accounts module account number with value
// InitAccountNumberSeqUnsafe is use to set accounts module account number with value
// of auth module current account number
InitAccountNumberSeq(ctx context.Context, currentAccNum uint64) error
InitAccountNumberSeqUnsafe(ctx context.Context, currentAccNum uint64) error
}
12 changes: 6 additions & 6 deletions x/auth/vesting/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 35c522e

Please sign in to comment.