Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose module account setter #284

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading