From 73643fcc2d5cc3dbe2c4ece7646882417c02ccca Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Fri, 5 May 2023 13:45:59 -0400 Subject: [PATCH 1/3] module acc flag --- x/auth/helpers/genaccounts.go | 3 +++ x/genutil/client/cli/genaccount.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/x/auth/helpers/genaccounts.go b/x/auth/helpers/genaccounts.go index 817d4f71095b..9d3ec893af53 100644 --- a/x/auth/helpers/genaccounts.go +++ b/x/auth/helpers/genaccounts.go @@ -26,6 +26,7 @@ func AddGenesisAccount( appendAcct bool, genesisFileURL, amountStr, vestingAmtStr string, vestingStart, vestingEnd int64, + moduleName string, ) error { coins, err := sdk.ParseCoinsNormalized(amountStr) if err != nil { @@ -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 } diff --git a/x/genutil/client/cli/genaccount.go b/x/genutil/client/cli/genaccount.go index 043428daf5ab..d92fc2888dfe 100644 --- a/x/genutil/client/cli/genaccount.go +++ b/x/genutil/client/cli/genaccount.go @@ -19,6 +19,7 @@ const ( flagVestingEnd = "vesting-end-time" flagVestingAmt = "vesting-amount" flagAppendMode = "append" + flagModuleName = "module-name" ) // AddGenesisAccountCmd returns add-genesis-account cobra Command. @@ -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) }, } @@ -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 From 0b1b8b327ac62862d6f8ae97b077cabaace7da21 Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Fri, 5 May 2023 13:48:25 -0400 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b0a16134260..13117f77b93e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. From 50a6fc699ea1cf6e0d2977125580414423f2b717 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Sat, 3 Jun 2023 08:08:14 -0400 Subject: [PATCH 3/3] add godoc --- x/auth/helpers/genaccounts.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/auth/helpers/genaccounts.go b/x/auth/helpers/genaccounts.go index 9d3ec893af53..9ff62f17150f 100644 --- a/x/auth/helpers/genaccounts.go +++ b/x/auth/helpers/genaccounts.go @@ -19,6 +19,7 @@ import ( // `accAddr` is the address to be added to the genesis state, `amountStr` is the list of initial coins // to be added for the account, `appendAcct` updates the account if already exists. // `vestingStart, vestingEnd and vestingAmtStr` respectively are the schedule start time, end time (unix epoch) +// `moduleNameā€œ is the module name for which the account is being created // and coins to be appended to the account already in the genesis.json file. func AddGenesisAccount( cdc codec.Codec,