Add instantiate-nobody flag to cli store cmd (#827)

* add instantiate-nobody flag to cli store cmd

* add flag to genesis store cmd

* update flag description
This commit is contained in:
Jorge Hernandez
2022-05-03 01:33:46 -06:00
committed by GitHub
parent 591ff72868
commit fb2d2f2ab9
3 changed files with 19 additions and 0 deletions

View File

@@ -71,6 +71,7 @@ func GenesisStoreCodeCmd(defaultNodeHome string, genesisMutator GenesisMutator)
}
cmd.Flags().String(flagRunAs, "", "The address that is stored as code creator")
cmd.Flags().String(flagInstantiateByEverybody, "", "Everybody can instantiate a contract from the code, optional")
cmd.Flags().String(flagInstantiateNobody, "", "Nobody except the governance process can instantiate a contract from the code, optional")
cmd.Flags().String(flagInstantiateByAddress, "", "Only this address can instantiate a contract instance from the code, optional")
cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")

View File

@@ -76,6 +76,7 @@ func ProposalStoreCodeCmd() *cobra.Command {
cmd.Flags().String(flagRunAs, "", "The address that is stored as code creator")
cmd.Flags().String(flagInstantiateByEverybody, "", "Everybody can instantiate a contract from the code, optional")
cmd.Flags().String(flagInstantiateNobody, "", "Nobody except the governance process can instantiate a contract from the code, optional")
cmd.Flags().String(flagInstantiateByAddress, "", "Only this address can instantiate a contract instance from the code, optional")
// proposal flags

View File

@@ -25,6 +25,7 @@ const (
flagNoAdmin = "no-admin"
flagRunAs = "run-as"
flagInstantiateByEverybody = "instantiate-everybody"
flagInstantiateNobody = "instantiate-nobody"
flagInstantiateByAddress = "instantiate-only-address"
flagProposalType = "type"
)
@@ -73,6 +74,7 @@ func StoreCodeCmd() *cobra.Command {
}
cmd.Flags().String(flagInstantiateByEverybody, "", "Everybody can instantiate a contract from the code, optional")
cmd.Flags().String(flagInstantiateNobody, "", "Nobody except the governance process can instantiate a contract from the code, optional")
cmd.Flags().String(flagInstantiateByAddress, "", "Only this address can instantiate a contract instance from the code, optional")
flags.AddTxFlagsToCmd(cmd)
return cmd
@@ -121,6 +123,21 @@ func parseStoreCodeArgs(file string, sender sdk.AccAddress, flags *flag.FlagSet)
perm = &types.AllowEverybody
}
}
nobodyStr, err := flags.GetString(flagInstantiateNobody)
if err != nil {
return types.MsgStoreCode{}, fmt.Errorf("instantiate by nobody: %s", err)
}
if nobodyStr != "" {
ok, err := strconv.ParseBool(nobodyStr)
if err != nil {
return types.MsgStoreCode{}, fmt.Errorf("boolean value expected for instantiate by nobody: %s", err)
}
if ok {
perm = &types.AllowNobody
}
}
}
msg := types.MsgStoreCode{