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(genutil): Add module account at genesis. #16046

Merged
merged 5 commits into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* (genutil) [#16046](https://github.com/cosmos/cosmos-sdk/pull/16046) Add "module-name" flag to genutil add-genesis-account to enable intializing module accounts at genesis.
* (types) [#15958](https://github.com/cosmos/cosmos-sdk/pull/15958) Add `module.NewBasicManagerFromManager` for creating a basic module manager from a module manager.
* (runtime) [#15818](https://github.com/cosmos/cosmos-sdk/pull/15818) Provide logger through `depinject` instead of appBuilder.
* (client) [#15597](https://github.com/cosmos/cosmos-sdk/pull/15597) Add status endpoint for clients.
Expand Down
3 changes: 3 additions & 0 deletions x/auth/helpers/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func AddGenesisAccount(
appendAcct bool,
genesisFileURL, amountStr, vestingAmtStr string,
vestingStart, vestingEnd int64,
moduleName string,
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
) error {
coins, err := sdk.ParseCoinsNormalized(amountStr)
if err != nil {
Expand Down Expand Up @@ -61,6 +62,8 @@ func AddGenesisAccount(
default:
return errors.New("invalid vesting parameters; must supply start and end time or end time")
}
} else if moduleName != "" {
genAccount = authtypes.NewEmptyModuleAccount(moduleName, authtypes.Burner, authtypes.Minter)
} else {
genAccount = baseAccount
}
Expand Down
5 changes: 4 additions & 1 deletion x/genutil/client/cli/genaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
flagVestingEnd = "vesting-end-time"
flagVestingAmt = "vesting-amount"
flagAppendMode = "append"
flagModuleName = "module-name"
)

// AddGenesisAccountCmd returns add-genesis-account cobra Command.
Expand Down Expand Up @@ -71,8 +72,9 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
vestingStart, _ := cmd.Flags().GetInt64(flagVestingStart)
vestingEnd, _ := cmd.Flags().GetInt64(flagVestingEnd)
vestingAmtStr, _ := cmd.Flags().GetString(flagVestingAmt)
moduleNameStr, _ := cmd.Flags().GetString(flagModuleName)

return auth.AddGenesisAccount(clientCtx.Codec, addr, appendflag, config.GenesisFile(), args[1], vestingAmtStr, vestingStart, vestingEnd)
return auth.AddGenesisAccount(clientCtx.Codec, addr, appendflag, config.GenesisFile(), args[1], vestingAmtStr, vestingStart, vestingEnd, moduleNameStr)
},
}

Expand All @@ -82,6 +84,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
cmd.Flags().Int64(flagVestingStart, 0, "schedule start time (unix epoch) for vesting accounts")
cmd.Flags().Int64(flagVestingEnd, 0, "schedule end time (unix epoch) for vesting accounts")
cmd.Flags().Bool(flagAppendMode, false, "append the coins to an account already in the genesis.json file")
cmd.Flags().String(flagModuleName, "", "module account name")
flags.AddQueryFlagsToCmd(cmd)

return cmd
Expand Down