Skip to content

Commit

Permalink
feat: expose module account setter
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Oct 13, 2023
1 parent f1b76a2 commit 97f7d08
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions x/auth/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,21 @@ func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleNa
return maccI, perms
}

// SetModuleAccountAndPermissions the module account from the auth account store and its
// registered permissions
func (ak AccountKeeper) SetModuleAccountAndPermissions(ctx sdk.Context, moduleName string, perms ...string) types.ModuleAccountI {
// create a new empty module account
macc := types.NewEmptyModuleAccount(moduleName, perms...)
// set the account number
maccI := (ak.NewAccount(ctx, macc)).(types.ModuleAccountI)
// Add the account to the store
ak.SetModuleAccount(ctx, maccI)
// Add the permissions for the module account
ak.permAddrs[moduleName] = types.NewPermissionsForAddress(maccI.GetName(), perms)

return maccI
}

// GetModuleAccount gets the module account from the auth account store, if the account does not
// exist in the AccountKeeper, then it is created.
func (ak AccountKeeper) GetModuleAccount(ctx sdk.Context, moduleName string) types.ModuleAccountI {
Expand Down

0 comments on commit 97f7d08

Please sign in to comment.