diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md
index dedd98bd21..ef464a9f38 100644
--- a/docs/proto/proto-docs.md
+++ b/docs/proto/proto-docs.md
@@ -64,6 +64,7 @@
- [InstantiateContractProposal](#cosmwasm.wasm.v1.InstantiateContractProposal)
- [MigrateContractProposal](#cosmwasm.wasm.v1.MigrateContractProposal)
- [PinCodesProposal](#cosmwasm.wasm.v1.PinCodesProposal)
+ - [StoreAndInstantiateContractProposal](#cosmwasm.wasm.v1.StoreAndInstantiateContractProposal)
- [StoreCodeProposal](#cosmwasm.wasm.v1.StoreCodeProposal)
- [SudoContractProposal](#cosmwasm.wasm.v1.SudoContractProposal)
- [UnpinCodesProposal](#cosmwasm.wasm.v1.UnpinCodesProposal)
@@ -984,6 +985,31 @@ wasmvm cache.
+
+
+### StoreAndInstantiateContractProposal
+StoreAndInstantiateContractProposal gov proposal content type to store
+and instantiate the contract.
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| `title` | [string](#string) | | Title is a short summary |
+| `description` | [string](#string) | | Description is a human readable text |
+| `run_as` | [string](#string) | | RunAs is the address that is passed to the contract's environment as sender |
+| `wasm_byte_code` | [bytes](#bytes) | | WASMByteCode can be raw or gzip compressed |
+| `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | InstantiatePermission to apply on contract creation, optional |
+| `unpin_code` | [bool](#bool) | | UnpinCode code on upload, optional |
+| `admin` | [string](#string) | | Admin is an optional address that can execute migrations |
+| `label` | [string](#string) | | Label is optional metadata to be stored with a constract instance. |
+| `msg` | [bytes](#bytes) | | Msg json encoded message to be passed to the contract on instantiation |
+| `funds` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Funds coins that are transferred to the contract on instantiation |
+
+
+
+
+
+
### StoreCodeProposal
diff --git a/proto/cosmwasm/wasm/v1/proposal.proto b/proto/cosmwasm/wasm/v1/proposal.proto
index 25bf2700b1..a4e57b7dd9 100644
--- a/proto/cosmwasm/wasm/v1/proposal.proto
+++ b/proto/cosmwasm/wasm/v1/proposal.proto
@@ -172,3 +172,31 @@ message UpdateInstantiateConfigProposal {
repeated AccessConfigUpdate access_config_updates = 3
[ (gogoproto.nullable) = false ];
}
+
+// StoreAndInstantiateContractProposal gov proposal content type to store
+// and instantiate the contract.
+message StoreAndInstantiateContractProposal {
+ // Title is a short summary
+ string title = 1;
+ // Description is a human readable text
+ string description = 2;
+ // RunAs is the address that is passed to the contract's environment as sender
+ string run_as = 3;
+ // WASMByteCode can be raw or gzip compressed
+ bytes wasm_byte_code = 4 [ (gogoproto.customname) = "WASMByteCode" ];
+ // InstantiatePermission to apply on contract creation, optional
+ AccessConfig instantiate_permission = 5;
+ // UnpinCode code on upload, optional
+ bool unpin_code = 6;
+ // Admin is an optional address that can execute migrations
+ string admin = 7;
+ // Label is optional metadata to be stored with a constract instance.
+ string label = 8;
+ // Msg json encoded message to be passed to the contract on instantiation
+ bytes msg = 9 [ (gogoproto.casttype) = "RawContractMessage" ];
+ // Funds coins that are transferred to the contract on instantiation
+ repeated cosmos.base.v1beta1.Coin funds = 10 [
+ (gogoproto.nullable) = false,
+ (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
+ ];
+}
diff --git a/x/wasm/Governance.md b/x/wasm/Governance.md
index cd7d0ae2cb..da47240c14 100644
--- a/x/wasm/Governance.md
+++ b/x/wasm/Governance.md
@@ -17,7 +17,8 @@ We have added 9 new wasm specific proposal types that cover the contract's live
* `ClearAdminProposal` - clear admin for a contract to prevent further migrations
* `PinCodes` - pin the given code ids in cache. This trades memory for reduced startup time and lowers gas cost
* `UnpinCodes` - unpin the given code ids from the cache. This frees up memory and returns to standard speed and gas cost
-* `UpdateInstantiateConfigProposal` - update instantiate permissions to a list of given code ids.
+* `UpdateInstantiateConfigProposal` - update instantiate permissions to a list of given code ids.
+* `StoreAndInstantiateContractProposal` - upload and instantiate a wasm contract.
For details see the proposal type [implementation](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/types/proposal.go)
diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go
index 01f7aaf80e..131ccda57d 100644
--- a/x/wasm/client/cli/gov_tx.go
+++ b/x/wasm/client/cli/gov_tx.go
@@ -23,7 +23,7 @@ func ProposalStoreCodeCmd() *cobra.Command {
Short: "Submit a wasm binary proposal",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
@@ -39,22 +39,6 @@ func ProposalStoreCodeCmd() *cobra.Command {
if len(runAs) == 0 {
return errors.New("run-as address is required")
}
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
- if err != nil {
- return fmt.Errorf("proposal title: %s", err)
- }
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
- if err != nil {
- return fmt.Errorf("proposal description: %s", err)
- }
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
- if err != nil {
- return err
- }
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
- if err != nil {
- return err
- }
unpinCode, err := cmd.Flags().GetBool(flagUnpinCode)
if err != nil {
@@ -103,7 +87,7 @@ func ProposalInstantiateContractCmd() *cobra.Command {
Short: "Submit an instantiate wasm contract proposal",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
@@ -120,22 +104,6 @@ func ProposalInstantiateContractCmd() *cobra.Command {
if len(runAs) == 0 {
return errors.New("run-as address is required")
}
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
- if err != nil {
- return fmt.Errorf("proposal title: %s", err)
- }
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
- if err != nil {
- return fmt.Errorf("proposal description: %s", err)
- }
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
- if err != nil {
- return err
- }
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
- if err != nil {
- return err
- }
content := types.InstantiateContractProposal{
Title: proposalTitle,
@@ -173,35 +141,122 @@ func ProposalInstantiateContractCmd() *cobra.Command {
return cmd
}
-func ProposalMigrateContractCmd() *cobra.Command {
+func ProposalStoreAndInstantiateContractCmd() *cobra.Command {
cmd := &cobra.Command{
- Use: "migrate-contract [contract_addr_bech32] [new_code_id_int64] [json_encoded_migration_args]",
- Short: "Submit a migrate wasm contract to a new code version proposal",
- Args: cobra.ExactArgs(3),
+ Use: "store-instantiate [wasm file] [json_encoded_init_args] --label [text] --title [text] --description [text] --run-as [address] --admin [address,optional] --amount [coins,optional]",
+ Short: "Submit and instantiate a wasm contract proposal",
+ Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
- src, err := parseMigrateContractArgs(args, clientCtx)
+ src, err := parseStoreCodeArgs(args[0], clientCtx.FromAddress, cmd.Flags())
+ if err != nil {
+ return err
+ }
+ runAs, err := cmd.Flags().GetString(flagRunAs)
+ if err != nil {
+ return fmt.Errorf("run-as: %s", err)
+ }
+ if len(runAs) == 0 {
+ return errors.New("run-as address is required")
+ }
+
+ unpinCode, err := cmd.Flags().GetBool(flagUnpinCode)
if err != nil {
return err
}
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
+ amountStr, err := cmd.Flags().GetString(flagAmount)
+ if err != nil {
+ return fmt.Errorf("amount: %s", err)
+ }
+ amount, err := sdk.ParseCoinsNormalized(amountStr)
+ if err != nil {
+ return fmt.Errorf("amount: %s", err)
+ }
+ label, err := cmd.Flags().GetString(flagLabel)
+ if err != nil {
+ return fmt.Errorf("label: %s", err)
+ }
+ if label == "" {
+ return errors.New("label is required on all contracts")
+ }
+ adminStr, err := cmd.Flags().GetString(flagAdmin)
if err != nil {
- return fmt.Errorf("proposal title: %s", err)
+ return fmt.Errorf("admin: %s", err)
}
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
+ noAdmin, err := cmd.Flags().GetBool(flagNoAdmin)
if err != nil {
- return fmt.Errorf("proposal description: %s", err)
+ return fmt.Errorf("no-admin: %s", err)
+ }
+
+ // ensure sensible admin is set (or explicitly immutable)
+ if adminStr == "" && !noAdmin {
+ return fmt.Errorf("you must set an admin or explicitly pass --no-admin to make it immutible (wasmd issue #719)")
+ }
+ if adminStr != "" && noAdmin {
+ return fmt.Errorf("you set an admin and passed --no-admin, those cannot both be true")
+ }
+
+ content := types.StoreAndInstantiateContractProposal{
+ Title: proposalTitle,
+ Description: proposalDescr,
+ RunAs: runAs,
+ WASMByteCode: src.WASMByteCode,
+ InstantiatePermission: src.InstantiatePermission,
+ UnpinCode: unpinCode,
+ Admin: adminStr,
+ Label: label,
+ Msg: []byte(args[1]),
+ Funds: amount,
+ }
+
+ msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
+ if err != nil {
+ return err
+ }
+ if err = msg.ValidateBasic(); err != nil {
+ return err
}
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
+
+ return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
+ },
+ SilenceUsage: true,
+ }
+
+ cmd.Flags().String(flagRunAs, "", "The address that is stored as code creator. It is the creator of the contract and passed to the contract as sender on proposal execution")
+ 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().Bool(flagUnpinCode, false, "Unpin code on upload, optional")
+ cmd.Flags().StringSlice(flagInstantiateByAnyOfAddress, []string{}, "Any of the addresses can instantiate a contract from the code, optional")
+ cmd.Flags().String(flagAmount, "", "Coins to send to the contract during instantiation")
+ cmd.Flags().String(flagLabel, "", "A human-readable name for this contract in lists")
+ cmd.Flags().String(flagAdmin, "", "Address of an admin")
+ cmd.Flags().Bool(flagNoAdmin, false, "You must set this explicitly if you don't want an admin")
+
+ // proposal flags
+ cmd.Flags().String(cli.FlagTitle, "", "Title of proposal")
+ cmd.Flags().String(cli.FlagDescription, "", "Description of proposal")
+ cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal")
+ return cmd
+}
+
+func ProposalMigrateContractCmd() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "migrate-contract [contract_addr_bech32] [new_code_id_int64] [json_encoded_migration_args]",
+ Short: "Submit a migrate wasm contract to a new code version proposal",
+ Args: cobra.ExactArgs(3),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
+
+ src, err := parseMigrateContractArgs(args, clientCtx)
if err != nil {
return err
}
@@ -240,7 +295,7 @@ func ProposalExecuteContractCmd() *cobra.Command {
Short: "Submit a execute wasm contract proposal (run by any address)",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
@@ -263,22 +318,6 @@ func ProposalExecuteContractCmd() *cobra.Command {
if len(runAs) == 0 {
return errors.New("run-as address is required")
}
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
- if err != nil {
- return fmt.Errorf("proposal title: %s", err)
- }
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
- if err != nil {
- return fmt.Errorf("proposal description: %s", err)
- }
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
- if err != nil {
- return err
- }
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
- if err != nil {
- return err
- }
content := types.ExecuteContractProposal{
Title: proposalTitle,
@@ -317,7 +356,7 @@ func ProposalSudoContractCmd() *cobra.Command {
Short: "Submit a sudo wasm contract proposal (to call privileged commands)",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
@@ -325,23 +364,6 @@ func ProposalSudoContractCmd() *cobra.Command {
contract := args[0]
sudoMsg := []byte(args[1])
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
- if err != nil {
- return fmt.Errorf("proposal title: %s", err)
- }
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
- if err != nil {
- return fmt.Errorf("proposal description: %s", err)
- }
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
- if err != nil {
- return err
- }
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
- if err != nil {
- return err
- }
-
content := types.SudoContractProposal{
Title: proposalTitle,
Description: proposalDescr,
@@ -375,7 +397,7 @@ func ProposalUpdateContractAdminCmd() *cobra.Command {
Short: "Submit a new admin for a contract proposal",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
@@ -385,23 +407,6 @@ func ProposalUpdateContractAdminCmd() *cobra.Command {
return err
}
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
- if err != nil {
- return fmt.Errorf("proposal title: %s", err)
- }
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
- if err != nil {
- return fmt.Errorf("proposal description: %s", err)
- }
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
- if err != nil {
- return fmt.Errorf("deposit: %s", err)
- }
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
- if err != nil {
- return err
- }
-
content := types.UpdateAdminProposal{
Title: proposalTitle,
Description: proposalDescr,
@@ -434,24 +439,7 @@ func ProposalClearContractAdminCmd() *cobra.Command {
Short: "Submit a clear admin for a contract to prevent further migrations proposal",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
- if err != nil {
- return fmt.Errorf("proposal title: %s", err)
- }
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
- if err != nil {
- return fmt.Errorf("proposal description: %s", err)
- }
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
- if err != nil {
- return fmt.Errorf("deposit: %s", err)
- }
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
@@ -487,27 +475,11 @@ func ProposalPinCodesCmd() *cobra.Command {
Short: "Submit a pin code proposal for pinning a code to cache",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
- if err != nil {
- return fmt.Errorf("proposal title: %s", err)
- }
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
- if err != nil {
- return fmt.Errorf("proposal description: %s", err)
- }
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
- if err != nil {
- return fmt.Errorf("deposit: %s", err)
- }
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
- if err != nil {
- return err
- }
codeIds, err := parsePinCodesArgs(args)
if err != nil {
return err
@@ -556,27 +528,11 @@ func ProposalUnpinCodesCmd() *cobra.Command {
Short: "Submit a unpin code proposal for unpinning a code to cache",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
- if err != nil {
- return fmt.Errorf("proposal title: %s", err)
- }
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
- if err != nil {
- return fmt.Errorf("proposal description: %s", err)
- }
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
- if err != nil {
- return fmt.Errorf("deposit: %s", err)
- }
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
- if err != nil {
- return err
- }
codeIds, err := parsePinCodesArgs(args)
if err != nil {
return err
@@ -673,24 +629,7 @@ Example:
$ %s tx gov submit-proposal update-instantiate-config 1:nobody 2:everybody 3:%s1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm,%s1vx8knpllrj7n963p9ttd80w47kpacrhuts497x
`, version.AppName, bech32Prefix, bech32Prefix)),
RunE: func(cmd *cobra.Command, args []string) error {
- clientCtx, err := client.GetClientTxContext(cmd)
- if err != nil {
- return err
- }
-
- proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
- if err != nil {
- return fmt.Errorf("proposal title: %s", err)
- }
- proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
- if err != nil {
- return fmt.Errorf("proposal description: %s", err)
- }
- depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
- if err != nil {
- return fmt.Errorf("deposit: %s", err)
- }
- deposit, err := sdk.ParseCoinsNormalized(depositArg)
+ clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd)
if err != nil {
return err
}
@@ -722,3 +661,32 @@ $ %s tx gov submit-proposal update-instantiate-config 1:nobody 2:everybody 3:%s1
cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal")
return cmd
}
+
+func getProposalInfo(cmd *cobra.Command) (client.Context, string, string, sdk.Coins, error) {
+ clientCtx, err := client.GetClientTxContext(cmd)
+ if err != nil {
+ return client.Context{}, "", "", nil, err
+ }
+
+ proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
+ if err != nil {
+ return clientCtx, proposalTitle, "", nil, err
+ }
+
+ proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription)
+ if err != nil {
+ return client.Context{}, proposalTitle, proposalDescr, nil, err
+ }
+
+ depositArg, err := cmd.Flags().GetString(cli.FlagDeposit)
+ if err != nil {
+ return client.Context{}, proposalTitle, proposalDescr, nil, err
+ }
+
+ deposit, err := sdk.ParseCoinsNormalized(depositArg)
+ if err != nil {
+ return client.Context{}, proposalTitle, proposalDescr, deposit, err
+ }
+
+ return clientCtx, proposalTitle, proposalDescr, deposit, nil
+}
diff --git a/x/wasm/client/proposal_handler.go b/x/wasm/client/proposal_handler.go
index 9d90d48df8..db51f7b3ac 100644
--- a/x/wasm/client/proposal_handler.go
+++ b/x/wasm/client/proposal_handler.go
@@ -20,4 +20,5 @@ var ProposalHandlers = []govclient.ProposalHandler{
govclient.NewProposalHandler(cli.ProposalPinCodesCmd, rest.PinCodeProposalHandler),
govclient.NewProposalHandler(cli.ProposalUnpinCodesCmd, rest.UnpinCodeProposalHandler),
govclient.NewProposalHandler(cli.ProposalUpdateInstantiateConfigCmd, rest.UpdateInstantiateConfigProposalHandler),
+ govclient.NewProposalHandler(cli.ProposalStoreAndInstantiateContractCmd, rest.EmptyRestHandler),
}
diff --git a/x/wasm/client/rest/gov.go b/x/wasm/client/rest/gov.go
index f730cb4696..3a27d2f0d7 100644
--- a/x/wasm/client/rest/gov.go
+++ b/x/wasm/client/rest/gov.go
@@ -525,3 +525,12 @@ func toStdTxResponse(cliCtx client.Context, w http.ResponseWriter, data wasmProp
}
tx.WriteGeneratedTxResponse(cliCtx, w, baseReq, msg)
}
+
+func EmptyRestHandler(cliCtx client.Context) govrest.ProposalRESTHandler {
+ return govrest.ProposalRESTHandler{
+ SubRoute: "unsupported",
+ Handler: func(w http.ResponseWriter, r *http.Request) {
+ rest.WriteErrorResponse(w, http.StatusBadRequest, "Legacy REST Routes are not supported for gov proposals")
+ },
+ }
+}
diff --git a/x/wasm/keeper/proposal_handler.go b/x/wasm/keeper/proposal_handler.go
index 29b736b00b..b39a8c4238 100644
--- a/x/wasm/keeper/proposal_handler.go
+++ b/x/wasm/keeper/proposal_handler.go
@@ -49,6 +49,8 @@ func NewWasmProposalHandlerX(k types.ContractOpsKeeper, enabledProposalTypes []t
return handleUnpinCodesProposal(ctx, k, *c)
case *types.UpdateInstantiateConfigProposal:
return handleUpdateInstantiateConfigProposal(ctx, k, *c)
+ case *types.StoreAndInstantiateContractProposal:
+ return handleStoreAndInstantiateContractProposal(ctx, k, *c)
default:
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized wasm proposal content type: %T", c)
}
@@ -103,6 +105,44 @@ func handleInstantiateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p typ
return nil
}
+func handleStoreAndInstantiateContractProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.StoreAndInstantiateContractProposal) error {
+ if err := p.ValidateBasic(); err != nil {
+ return err
+ }
+ runAsAddr, err := sdk.AccAddressFromBech32(p.RunAs)
+ if err != nil {
+ return sdkerrors.Wrap(err, "run as address")
+ }
+ var adminAddr sdk.AccAddress
+ if p.Admin != "" {
+ if adminAddr, err = sdk.AccAddressFromBech32(p.Admin); err != nil {
+ return sdkerrors.Wrap(err, "admin")
+ }
+ }
+
+ codeID, _, err := k.Create(ctx, runAsAddr, p.WASMByteCode, p.InstantiatePermission)
+ if err != nil {
+ return err
+ }
+
+ if !p.UnpinCode {
+ if err := k.PinCode(ctx, codeID); err != nil {
+ return err
+ }
+ }
+
+ _, data, err := k.Instantiate(ctx, codeID, runAsAddr, adminAddr, p.Msg, p.Label, p.Funds)
+ if err != nil {
+ return err
+ }
+
+ ctx.EventManager().EmitEvent(sdk.NewEvent(
+ types.EventTypeGovContractResult,
+ sdk.NewAttribute(types.AttributeKeyResultDataHex, hex.EncodeToString(data)),
+ ))
+ return nil
+}
+
func handleMigrateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.MigrateContractProposal) error {
if err := p.ValidateBasic(); err != nil {
return err
diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go
index 1327ba88e3..8055ca385a 100644
--- a/x/wasm/keeper/proposal_integration_test.go
+++ b/x/wasm/keeper/proposal_integration_test.go
@@ -210,6 +210,66 @@ func TestInstantiateProposal_NoAdmin(t *testing.T) {
require.NotEmpty(t, em.Events()[2].Attributes[0])
}
+func TestStoreAndInstantiateContractProposal(t *testing.T) {
+ ctx, keepers := CreateTestInput(t, false, "staking")
+ govKeeper, wasmKeeper := keepers.GovKeeper, keepers.WasmKeeper
+ wasmKeeper.SetParams(ctx, types.Params{
+ CodeUploadAccess: types.AllowNobody,
+ InstantiateDefaultPermission: types.AccessTypeNobody,
+ })
+
+ wasmCode, err := os.ReadFile("./testdata/hackatom.wasm")
+ require.NoError(t, err)
+
+ var (
+ oneAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, types.ContractAddrLen)
+ otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen)
+ )
+
+ src := types.StoreAndInstantiateContractProposalFixture(func(p *types.StoreAndInstantiateContractProposal) {
+ p.WASMByteCode = wasmCode
+ p.RunAs = oneAddress.String()
+ p.Admin = otherAddress.String()
+ p.Label = "testing"
+ })
+ em := sdk.NewEventManager()
+
+ // when stored
+ storedProposal, err := govKeeper.SubmitProposal(ctx, src)
+ require.NoError(t, err)
+
+ // and proposal execute
+ handler := govKeeper.Router().GetRoute(storedProposal.ProposalRoute())
+ err = handler(ctx.WithEventManager(em), storedProposal.GetContent())
+ require.NoError(t, err)
+
+ // then
+ contractAddr, err := sdk.AccAddressFromBech32("cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr")
+ require.NoError(t, err)
+
+ cInfo := wasmKeeper.GetContractInfo(ctx, contractAddr)
+ require.NotNil(t, cInfo)
+ assert.Equal(t, oneAddress.String(), cInfo.Creator)
+ assert.Equal(t, otherAddress.String(), cInfo.Admin)
+ assert.Equal(t, "testing", cInfo.Label)
+ expHistory := []types.ContractCodeHistoryEntry{{
+ Operation: types.ContractCodeHistoryOperationTypeInit,
+ CodeID: cInfo.CodeID,
+ Updated: types.NewAbsoluteTxPosition(ctx),
+ Msg: src.Msg,
+ }}
+ assert.Equal(t, expHistory, wasmKeeper.GetContractHistory(ctx, contractAddr))
+ // and event
+ require.Len(t, em.Events(), 5, "%#v", em.Events())
+ require.Equal(t, types.EventTypeStoreCode, em.Events()[0].Type)
+ require.Equal(t, types.EventTypePinCode, em.Events()[1].Type)
+ require.Equal(t, types.EventTypeInstantiate, em.Events()[2].Type)
+ require.Equal(t, types.WasmModuleEventType, em.Events()[3].Type)
+ require.Equal(t, types.EventTypeGovContractResult, em.Events()[4].Type)
+ require.Len(t, em.Events()[4].Attributes, 1)
+ require.NotEmpty(t, em.Events()[4].Attributes[0])
+}
+
func TestMigrateProposal(t *testing.T) {
ctx, keepers := CreateTestInput(t, false, "staking")
govKeeper, wasmKeeper := keepers.GovKeeper, keepers.WasmKeeper
diff --git a/x/wasm/types/codec.go b/x/wasm/types/codec.go
index 5148da1346..64b4f28e41 100644
--- a/x/wasm/types/codec.go
+++ b/x/wasm/types/codec.go
@@ -45,6 +45,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { //nolint:staticcheck
cdc.RegisterConcrete(&ContractExecutionAuthorization{}, "wasm/ContractExecutionAuthorization", nil)
cdc.RegisterConcrete(&ContractMigrationAuthorization{}, "wasm/ContractMigrationAuthorization", nil)
+ cdc.RegisterConcrete(&StoreAndInstantiateContractProposal{}, "wasm/StoreAndInstantiateContractProposal", nil)
}
func RegisterInterfaces(registry types.InterfaceRegistry) {
@@ -72,6 +73,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
&PinCodesProposal{},
&UnpinCodesProposal{},
&UpdateInstantiateConfigProposal{},
+ &StoreAndInstantiateContractProposal{},
)
registry.RegisterInterface("ContractInfoExtension", (*ContractInfoExtension)(nil))
diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go
index bb2ba16d6b..0b8f943264 100644
--- a/x/wasm/types/proposal.go
+++ b/x/wasm/types/proposal.go
@@ -13,16 +13,17 @@ import (
type ProposalType string
const (
- ProposalTypeStoreCode ProposalType = "StoreCode"
- ProposalTypeInstantiateContract ProposalType = "InstantiateContract"
- ProposalTypeMigrateContract ProposalType = "MigrateContract"
- ProposalTypeSudoContract ProposalType = "SudoContract"
- ProposalTypeExecuteContract ProposalType = "ExecuteContract"
- ProposalTypeUpdateAdmin ProposalType = "UpdateAdmin"
- ProposalTypeClearAdmin ProposalType = "ClearAdmin"
- ProposalTypePinCodes ProposalType = "PinCodes"
- ProposalTypeUnpinCodes ProposalType = "UnpinCodes"
- ProposalTypeUpdateInstantiateConfig ProposalType = "UpdateInstantiateConfig"
+ ProposalTypeStoreCode ProposalType = "StoreCode"
+ ProposalTypeInstantiateContract ProposalType = "InstantiateContract"
+ ProposalTypeMigrateContract ProposalType = "MigrateContract"
+ ProposalTypeSudoContract ProposalType = "SudoContract"
+ ProposalTypeExecuteContract ProposalType = "ExecuteContract"
+ ProposalTypeUpdateAdmin ProposalType = "UpdateAdmin"
+ ProposalTypeClearAdmin ProposalType = "ClearAdmin"
+ ProposalTypePinCodes ProposalType = "PinCodes"
+ ProposalTypeUnpinCodes ProposalType = "UnpinCodes"
+ ProposalTypeUpdateInstantiateConfig ProposalType = "UpdateInstantiateConfig"
+ ProposalTypeStoreAndInstantiateContractProposal ProposalType = "StoreAndInstantiateContract"
)
// DisableAllProposals contains no wasm gov types.
@@ -40,6 +41,7 @@ var EnableAllProposals = []ProposalType{
ProposalTypePinCodes,
ProposalTypeUnpinCodes,
ProposalTypeUpdateInstantiateConfig,
+ ProposalTypeStoreAndInstantiateContractProposal,
}
// ConvertToProposals maps each key to a ProposalType and returns a typed list.
@@ -71,6 +73,7 @@ func init() { // register new content types with the sdk
govtypes.RegisterProposalType(string(ProposalTypePinCodes))
govtypes.RegisterProposalType(string(ProposalTypeUnpinCodes))
govtypes.RegisterProposalType(string(ProposalTypeUpdateInstantiateConfig))
+ govtypes.RegisterProposalType(string(ProposalTypeStoreAndInstantiateContractProposal))
govtypes.RegisterProposalTypeCodec(&StoreCodeProposal{}, "wasm/StoreCodeProposal")
govtypes.RegisterProposalTypeCodec(&InstantiateContractProposal{}, "wasm/InstantiateContractProposal")
govtypes.RegisterProposalTypeCodec(&MigrateContractProposal{}, "wasm/MigrateContractProposal")
@@ -81,6 +84,7 @@ func init() { // register new content types with the sdk
govtypes.RegisterProposalTypeCodec(&PinCodesProposal{}, "wasm/PinCodesProposal")
govtypes.RegisterProposalTypeCodec(&UnpinCodesProposal{}, "wasm/UnpinCodesProposal")
govtypes.RegisterProposalTypeCodec(&UpdateInstantiateConfigProposal{}, "wasm/UpdateInstantiateConfigProposal")
+ govtypes.RegisterProposalTypeCodec(&StoreAndInstantiateContractProposal{}, "wasm/StoreAndInstantiateContractProposal")
}
func NewStoreCodeProposal(
@@ -250,6 +254,127 @@ func (p InstantiateContractProposal) MarshalYAML() (interface{}, error) {
}, nil
}
+func NewStoreAndInstantiateContractProposal(
+ title string,
+ description string,
+ runAs string,
+ wasmBz []byte,
+ permission *AccessConfig,
+ unpinCode bool,
+ admin string,
+ label string,
+ msg RawContractMessage,
+ funds sdk.Coins,
+) *StoreAndInstantiateContractProposal {
+ return &StoreAndInstantiateContractProposal{
+ Title: title,
+ Description: description,
+ RunAs: runAs,
+ WASMByteCode: wasmBz,
+ InstantiatePermission: permission,
+ UnpinCode: unpinCode,
+ Admin: admin,
+ Label: label,
+ Msg: msg,
+ Funds: funds,
+ }
+}
+
+// ProposalRoute returns the routing key of a parameter change proposal.
+func (p StoreAndInstantiateContractProposal) ProposalRoute() string { return RouterKey }
+
+// GetTitle returns the title of the proposal
+func (p *StoreAndInstantiateContractProposal) GetTitle() string { return p.Title }
+
+// GetDescription returns the human readable description of the proposal
+func (p StoreAndInstantiateContractProposal) GetDescription() string { return p.Description }
+
+// ProposalType returns the type
+func (p StoreAndInstantiateContractProposal) ProposalType() string {
+ return string(ProposalTypeStoreAndInstantiateContractProposal)
+}
+
+// ValidateBasic validates the proposal
+func (p StoreAndInstantiateContractProposal) ValidateBasic() error {
+ if err := validateProposalCommons(p.Title, p.Description); err != nil {
+ return err
+ }
+ if _, err := sdk.AccAddressFromBech32(p.RunAs); err != nil {
+ return sdkerrors.Wrap(err, "run as")
+ }
+
+ if err := validateWasmCode(p.WASMByteCode); err != nil {
+ return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "code bytes %s", err.Error())
+ }
+
+ if p.InstantiatePermission != nil {
+ if err := p.InstantiatePermission.ValidateBasic(); err != nil {
+ return sdkerrors.Wrap(err, "instantiate permission")
+ }
+ }
+
+ if err := ValidateLabel(p.Label); err != nil {
+ return err
+ }
+
+ if !p.Funds.IsValid() {
+ return sdkerrors.ErrInvalidCoins
+ }
+
+ if len(p.Admin) != 0 {
+ if _, err := sdk.AccAddressFromBech32(p.Admin); err != nil {
+ return err
+ }
+ }
+ if err := p.Msg.ValidateBasic(); err != nil {
+ return sdkerrors.Wrap(err, "payload msg")
+ }
+ return nil
+}
+
+// String implements the Stringer interface.
+func (p StoreAndInstantiateContractProposal) String() string {
+ return fmt.Sprintf(`Store And Instantiate Coontract Proposal:
+ Title: %s
+ Description: %s
+ Run as: %s
+ WasmCode: %X
+ Instantiate permission: %s
+ Unpin code: %t
+ Admin: %s
+ Label: %s
+ Msg: %q
+ Funds: %s
+`, p.Title, p.Description, p.RunAs, p.WASMByteCode, p.InstantiatePermission, p.UnpinCode, p.Admin, p.Label, p.Msg, p.Funds)
+}
+
+// MarshalYAML pretty prints the wasm byte code and the init message
+func (p StoreAndInstantiateContractProposal) MarshalYAML() (interface{}, error) {
+ return struct {
+ Title string `yaml:"title"`
+ Description string `yaml:"description"`
+ RunAs string `yaml:"run_as"`
+ WASMByteCode string `yaml:"wasm_byte_code"`
+ InstantiatePermission *AccessConfig `yaml:"instantiate_permission"`
+ UnpinCode bool `yaml:"unpin_code"`
+ Admin string `yaml:"admin"`
+ Label string `yaml:"label"`
+ Msg string `yaml:"msg"`
+ Funds sdk.Coins `yaml:"funds"`
+ }{
+ Title: p.Title,
+ Description: p.Description,
+ RunAs: p.RunAs,
+ WASMByteCode: base64.StdEncoding.EncodeToString(p.WASMByteCode),
+ InstantiatePermission: p.InstantiatePermission,
+ UnpinCode: p.UnpinCode,
+ Admin: p.Admin,
+ Label: p.Label,
+ Msg: string(p.Msg),
+ Funds: p.Funds,
+ }, nil
+}
+
// ProposalRoute returns the routing key of a parameter change proposal.
func (p MigrateContractProposal) ProposalRoute() string { return RouterKey }
diff --git a/x/wasm/types/proposal.pb.go b/x/wasm/types/proposal.pb.go
index 0e87ce5fca..27a9ed0b9f 100644
--- a/x/wasm/types/proposal.pb.go
+++ b/x/wasm/types/proposal.pb.go
@@ -583,6 +583,68 @@ func (m *UpdateInstantiateConfigProposal) XXX_DiscardUnknown() {
var xxx_messageInfo_UpdateInstantiateConfigProposal proto.InternalMessageInfo
+// StoreAndInstantiateContractProposal gov proposal content type to store
+// and instantiate the contract.
+type StoreAndInstantiateContractProposal struct {
+ // Title is a short summary
+ Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
+ // Description is a human readable text
+ Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
+ // RunAs is the address that is passed to the contract's environment as sender
+ RunAs string `protobuf:"bytes,3,opt,name=run_as,json=runAs,proto3" json:"run_as,omitempty"`
+ // WASMByteCode can be raw or gzip compressed
+ WASMByteCode []byte `protobuf:"bytes,4,opt,name=wasm_byte_code,json=wasmByteCode,proto3" json:"wasm_byte_code,omitempty"`
+ // InstantiatePermission to apply on contract creation, optional
+ InstantiatePermission *AccessConfig `protobuf:"bytes,5,opt,name=instantiate_permission,json=instantiatePermission,proto3" json:"instantiate_permission,omitempty"`
+ // UnpinCode code on upload, optional
+ UnpinCode bool `protobuf:"varint,6,opt,name=unpin_code,json=unpinCode,proto3" json:"unpin_code,omitempty"`
+ // Admin is an optional address that can execute migrations
+ Admin string `protobuf:"bytes,7,opt,name=admin,proto3" json:"admin,omitempty"`
+ // Label is optional metadata to be stored with a constract instance.
+ Label string `protobuf:"bytes,8,opt,name=label,proto3" json:"label,omitempty"`
+ // Msg json encoded message to be passed to the contract on instantiation
+ Msg RawContractMessage `protobuf:"bytes,9,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"`
+ // Funds coins that are transferred to the contract on instantiation
+ Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,10,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"`
+}
+
+func (m *StoreAndInstantiateContractProposal) Reset() { *m = StoreAndInstantiateContractProposal{} }
+func (*StoreAndInstantiateContractProposal) ProtoMessage() {}
+func (*StoreAndInstantiateContractProposal) Descriptor() ([]byte, []int) {
+ return fileDescriptor_be6422d717c730cb, []int{11}
+}
+
+func (m *StoreAndInstantiateContractProposal) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+
+func (m *StoreAndInstantiateContractProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_StoreAndInstantiateContractProposal.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+
+func (m *StoreAndInstantiateContractProposal) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_StoreAndInstantiateContractProposal.Merge(m, src)
+}
+
+func (m *StoreAndInstantiateContractProposal) XXX_Size() int {
+ return m.Size()
+}
+
+func (m *StoreAndInstantiateContractProposal) XXX_DiscardUnknown() {
+ xxx_messageInfo_StoreAndInstantiateContractProposal.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_StoreAndInstantiateContractProposal proto.InternalMessageInfo
+
func init() {
proto.RegisterType((*StoreCodeProposal)(nil), "cosmwasm.wasm.v1.StoreCodeProposal")
proto.RegisterType((*InstantiateContractProposal)(nil), "cosmwasm.wasm.v1.InstantiateContractProposal")
@@ -595,65 +657,68 @@ func init() {
proto.RegisterType((*UnpinCodesProposal)(nil), "cosmwasm.wasm.v1.UnpinCodesProposal")
proto.RegisterType((*AccessConfigUpdate)(nil), "cosmwasm.wasm.v1.AccessConfigUpdate")
proto.RegisterType((*UpdateInstantiateConfigProposal)(nil), "cosmwasm.wasm.v1.UpdateInstantiateConfigProposal")
+ proto.RegisterType((*StoreAndInstantiateContractProposal)(nil), "cosmwasm.wasm.v1.StoreAndInstantiateContractProposal")
}
func init() { proto.RegisterFile("cosmwasm/wasm/v1/proposal.proto", fileDescriptor_be6422d717c730cb) }
var fileDescriptor_be6422d717c730cb = []byte{
- // 834 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4f, 0x8f, 0xdb, 0x44,
- 0x14, 0xcf, 0xe4, 0x8f, 0x93, 0x9d, 0x8d, 0x20, 0xb8, 0xd9, 0x6d, 0x58, 0xc0, 0x8e, 0x0c, 0xaa,
- 0x7c, 0xc1, 0x26, 0x8b, 0x84, 0x80, 0xdb, 0x3a, 0x70, 0xd8, 0x8a, 0x95, 0x56, 0x5e, 0xad, 0x2a,
- 0x81, 0x84, 0x35, 0xb1, 0x67, 0x5d, 0x8b, 0xd8, 0x63, 0x79, 0xc6, 0x9b, 0xe6, 0x5b, 0x80, 0x84,
- 0x38, 0xf5, 0x03, 0x20, 0x2e, 0x88, 0x3b, 0x1f, 0x60, 0xc5, 0xa9, 0xc7, 0x9e, 0x0c, 0x4d, 0xbe,
- 0x41, 0x8e, 0x9c, 0xd0, 0xcc, 0x38, 0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0x24, 0x0a, 0xec, 0x07, 0xf2, 0x69, 0x24, 0x1a, 0xc9, 0x48,
- 0x11, 0x0f, 0xa3, 0x0f, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x4f, 0xac, 0x4a, 0xb0, 0xa1, 0x09,
- 0x00, 0x00,
+ // 877 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0xe3, 0x44,
+ 0x1c, 0xcf, 0xe4, 0xc3, 0x49, 0xa6, 0x11, 0x04, 0x6f, 0xda, 0x0d, 0x05, 0xec, 0xc8, 0x8b, 0x56,
+ 0xbe, 0xe0, 0x90, 0x22, 0x21, 0xe0, 0x16, 0x07, 0x0e, 0x5d, 0x51, 0xa9, 0x72, 0x55, 0xad, 0x04,
+ 0x12, 0xd1, 0xc4, 0x9e, 0x7a, 0x2d, 0xe2, 0x19, 0xcb, 0x33, 0x6e, 0xb7, 0x6f, 0x01, 0x12, 0xe2,
+ 0xb4, 0x0f, 0x80, 0xb8, 0x20, 0xee, 0x3c, 0x40, 0xc5, 0x69, 0x8f, 0x2b, 0x21, 0x19, 0x36, 0x7d,
+ 0x83, 0x1e, 0x39, 0xa1, 0x99, 0x71, 0xb2, 0x69, 0x77, 0xdb, 0xdd, 0x15, 0x4d, 0xa5, 0xbd, 0x38,
+ 0x99, 0xf9, 0x7f, 0xfd, 0xe6, 0xa7, 0xff, 0x17, 0x34, 0x7d, 0xca, 0xe2, 0x23, 0xc4, 0xe2, 0xbe,
+ 0xfc, 0x1c, 0x0e, 0xfa, 0x49, 0x4a, 0x13, 0xca, 0xd0, 0xd4, 0x49, 0x52, 0xca, 0xa9, 0xde, 0x9e,
+ 0x2b, 0x38, 0xf2, 0x73, 0x38, 0xd8, 0xec, 0x84, 0x34, 0xa4, 0x52, 0xd8, 0x17, 0xff, 0x94, 0xde,
+ 0xa6, 0x21, 0xf4, 0x28,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x93, 0xff,
+ 0x02, 0x00, 0x00, 0xff, 0xff, 0x50, 0x71, 0x76, 0x67, 0x7f, 0x0b, 0x00, 0x00,
}
func (this *StoreCodeProposal) Equal(that interface{}) bool {
@@ -1064,6 +1129,63 @@ func (this *UpdateInstantiateConfigProposal) Equal(that interface{}) bool {
return true
}
+func (this *StoreAndInstantiateContractProposal) Equal(that interface{}) bool {
+ if that == nil {
+ return this == nil
+ }
+
+ that1, ok := that.(*StoreAndInstantiateContractProposal)
+ if !ok {
+ that2, ok := that.(StoreAndInstantiateContractProposal)
+ if ok {
+ that1 = &that2
+ } else {
+ return false
+ }
+ }
+ if that1 == nil {
+ return this == nil
+ } else if this == nil {
+ return false
+ }
+ if this.Title != that1.Title {
+ return false
+ }
+ if this.Description != that1.Description {
+ return false
+ }
+ if this.RunAs != that1.RunAs {
+ return false
+ }
+ if !bytes.Equal(this.WASMByteCode, that1.WASMByteCode) {
+ return false
+ }
+ if !this.InstantiatePermission.Equal(that1.InstantiatePermission) {
+ return false
+ }
+ if this.UnpinCode != that1.UnpinCode {
+ return false
+ }
+ if this.Admin != that1.Admin {
+ return false
+ }
+ if this.Label != that1.Label {
+ return false
+ }
+ if !bytes.Equal(this.Msg, that1.Msg) {
+ return false
+ }
+ if len(this.Funds) != len(that1.Funds) {
+ return false
+ }
+ for i := range this.Funds {
+ if !this.Funds[i].Equal(&that1.Funds[i]) {
+ return false
+ }
+ }
+ return true
+}
+
func (m *StoreCodeProposal) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@@ -1694,6 +1816,114 @@ func (m *UpdateInstantiateConfigProposal) MarshalToSizedBuffer(dAtA []byte) (int
return len(dAtA) - i, nil
}
+func (m *StoreAndInstantiateContractProposal) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *StoreAndInstantiateContractProposal) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *StoreAndInstantiateContractProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if len(m.Funds) > 0 {
+ for iNdEx := len(m.Funds) - 1; iNdEx >= 0; iNdEx-- {
+ {
+ size, err := m.Funds[iNdEx].MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintProposal(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x52
+ }
+ }
+ if len(m.Msg) > 0 {
+ i -= len(m.Msg)
+ copy(dAtA[i:], m.Msg)
+ i = encodeVarintProposal(dAtA, i, uint64(len(m.Msg)))
+ i--
+ dAtA[i] = 0x4a
+ }
+ if len(m.Label) > 0 {
+ i -= len(m.Label)
+ copy(dAtA[i:], m.Label)
+ i = encodeVarintProposal(dAtA, i, uint64(len(m.Label)))
+ i--
+ dAtA[i] = 0x42
+ }
+ if len(m.Admin) > 0 {
+ i -= len(m.Admin)
+ copy(dAtA[i:], m.Admin)
+ i = encodeVarintProposal(dAtA, i, uint64(len(m.Admin)))
+ i--
+ dAtA[i] = 0x3a
+ }
+ if m.UnpinCode {
+ i--
+ if m.UnpinCode {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i--
+ dAtA[i] = 0x30
+ }
+ if m.InstantiatePermission != nil {
+ {
+ size, err := m.InstantiatePermission.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintProposal(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x2a
+ }
+ if len(m.WASMByteCode) > 0 {
+ i -= len(m.WASMByteCode)
+ copy(dAtA[i:], m.WASMByteCode)
+ i = encodeVarintProposal(dAtA, i, uint64(len(m.WASMByteCode)))
+ i--
+ dAtA[i] = 0x22
+ }
+ if len(m.RunAs) > 0 {
+ i -= len(m.RunAs)
+ copy(dAtA[i:], m.RunAs)
+ i = encodeVarintProposal(dAtA, i, uint64(len(m.RunAs)))
+ i--
+ dAtA[i] = 0x1a
+ }
+ if len(m.Description) > 0 {
+ i -= len(m.Description)
+ copy(dAtA[i:], m.Description)
+ i = encodeVarintProposal(dAtA, i, uint64(len(m.Description)))
+ i--
+ dAtA[i] = 0x12
+ }
+ if len(m.Title) > 0 {
+ i -= len(m.Title)
+ copy(dAtA[i:], m.Title)
+ i = encodeVarintProposal(dAtA, i, uint64(len(m.Title)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
func encodeVarintProposal(dAtA []byte, offset int, v uint64) int {
offset -= sovProposal(v)
base := offset
@@ -1999,6 +2229,56 @@ func (m *UpdateInstantiateConfigProposal) Size() (n int) {
return n
}
+func (m *StoreAndInstantiateContractProposal) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.Title)
+ if l > 0 {
+ n += 1 + l + sovProposal(uint64(l))
+ }
+ l = len(m.Description)
+ if l > 0 {
+ n += 1 + l + sovProposal(uint64(l))
+ }
+ l = len(m.RunAs)
+ if l > 0 {
+ n += 1 + l + sovProposal(uint64(l))
+ }
+ l = len(m.WASMByteCode)
+ if l > 0 {
+ n += 1 + l + sovProposal(uint64(l))
+ }
+ if m.InstantiatePermission != nil {
+ l = m.InstantiatePermission.Size()
+ n += 1 + l + sovProposal(uint64(l))
+ }
+ if m.UnpinCode {
+ n += 2
+ }
+ l = len(m.Admin)
+ if l > 0 {
+ n += 1 + l + sovProposal(uint64(l))
+ }
+ l = len(m.Label)
+ if l > 0 {
+ n += 1 + l + sovProposal(uint64(l))
+ }
+ l = len(m.Msg)
+ if l > 0 {
+ n += 1 + l + sovProposal(uint64(l))
+ }
+ if len(m.Funds) > 0 {
+ for _, e := range m.Funds {
+ l = e.Size()
+ n += 1 + l + sovProposal(uint64(l))
+ }
+ }
+ return n
+}
+
func sovProposal(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@@ -4130,6 +4410,375 @@ func (m *UpdateInstantiateConfigProposal) Unmarshal(dAtA []byte) error {
return nil
}
+func (m *StoreAndInstantiateContractProposal) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: StoreAndInstantiateContractProposal: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: StoreAndInstantiateContractProposal: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthProposal
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Title = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthProposal
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Description = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field RunAs", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthProposal
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.RunAs = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field WASMByteCode", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthProposal
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.WASMByteCode = append(m.WASMByteCode[:0], dAtA[iNdEx:postIndex]...)
+ if m.WASMByteCode == nil {
+ m.WASMByteCode = []byte{}
+ }
+ iNdEx = postIndex
+ case 5:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field InstantiatePermission", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthProposal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.InstantiatePermission == nil {
+ m.InstantiatePermission = &AccessConfig{}
+ }
+ if err := m.InstantiatePermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 6:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field UnpinCode", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.UnpinCode = bool(v != 0)
+ case 7:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthProposal
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Admin = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 8:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Label", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthProposal
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Label = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 9:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthProposal
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Msg = append(m.Msg[:0], dAtA[iNdEx:postIndex]...)
+ if m.Msg == nil {
+ m.Msg = []byte{}
+ }
+ iNdEx = postIndex
+ case 10:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Funds", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowProposal
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthProposal
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Funds = append(m.Funds, types.Coin{})
+ if err := m.Funds[len(m.Funds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipProposal(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
+ return ErrInvalidLengthProposal
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+
func skipProposal(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
diff --git a/x/wasm/types/proposal_test.go b/x/wasm/types/proposal_test.go
index fcc378d390..6657d11412 100644
--- a/x/wasm/types/proposal_test.go
+++ b/x/wasm/types/proposal_test.go
@@ -254,6 +254,120 @@ func TestValidateInstantiateContractProposal(t *testing.T) {
}
}
+func TestValidateStoreAndInstantiateContractProposal(t *testing.T) {
+ var (
+ anyAddress sdk.AccAddress = bytes.Repeat([]byte{0x0}, ContractAddrLen)
+ invalidAddress = "invalid address"
+ )
+
+ specs := map[string]struct {
+ src *StoreAndInstantiateContractProposal
+ expErr bool
+ }{
+ "all good": {
+ src: StoreAndInstantiateContractProposalFixture(),
+ },
+ "with instantiate permission": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ accessConfig := AccessTypeOnlyAddress.With(anyAddress)
+ p.InstantiatePermission = &accessConfig
+ }),
+ },
+ "base data missing": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.Title = ""
+ }),
+ expErr: true,
+ },
+ "run_as missing": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.RunAs = ""
+ }),
+ expErr: true,
+ },
+ "run_as invalid": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.RunAs = invalidAddress
+ }),
+ expErr: true,
+ },
+ "wasm code missing": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.WASMByteCode = nil
+ }),
+ expErr: true,
+ },
+ "wasm code invalid": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.WASMByteCode = bytes.Repeat([]byte{0x0}, MaxWasmSize+1)
+ }),
+ expErr: true,
+ },
+ "with invalid instantiate permission": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.InstantiatePermission = &AccessConfig{}
+ }),
+ expErr: true,
+ },
+ "without admin": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.Admin = ""
+ }),
+ },
+ "without init msg": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.Msg = nil
+ }),
+ expErr: true,
+ },
+ "with invalid init msg": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.Msg = []byte("not a json string")
+ }),
+ expErr: true,
+ },
+ "without init funds": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.Funds = nil
+ }),
+ },
+ "admin invalid": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.Admin = invalidAddress
+ }),
+ expErr: true,
+ },
+ "label empty": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.Label = ""
+ }),
+ expErr: true,
+ },
+ "init funds negative": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(-1)}}
+ }),
+ expErr: true,
+ },
+ "init funds with duplicates": {
+ src: StoreAndInstantiateContractProposalFixture(func(p *StoreAndInstantiateContractProposal) {
+ p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(1)}, {Denom: "foo", Amount: sdk.NewInt(2)}}
+ }),
+ expErr: true,
+ },
+ }
+ for msg, spec := range specs {
+ t.Run(msg, func(t *testing.T) {
+ err := spec.src.ValidateBasic()
+ if spec.expErr {
+ require.Error(t, err)
+ } else {
+ require.NoError(t, err)
+ }
+ })
+ }
+}
+
func TestValidateMigrateContractProposal(t *testing.T) {
invalidAddress := "invalid address2"
diff --git a/x/wasm/types/test_fixtures.go b/x/wasm/types/test_fixtures.go
index 22da3520d6..c37b6d9ddf 100644
--- a/x/wasm/types/test_fixtures.go
+++ b/x/wasm/types/test_fixtures.go
@@ -247,6 +247,41 @@ func InstantiateContractProposalFixture(mutators ...func(p *InstantiateContractP
return p
}
+func StoreAndInstantiateContractProposalFixture(mutators ...func(p *StoreAndInstantiateContractProposal)) *StoreAndInstantiateContractProposal {
+ var (
+ anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, ContractAddrLen)
+
+ initMsg = struct {
+ Verifier sdk.AccAddress `json:"verifier"`
+ Beneficiary sdk.AccAddress `json:"beneficiary"`
+ }{
+ Verifier: anyValidAddress,
+ Beneficiary: anyValidAddress,
+ }
+ )
+ const anyAddress = "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs2m6sx4"
+
+ initMsgBz, err := json.Marshal(initMsg)
+ if err != nil {
+ panic(err)
+ }
+ p := &StoreAndInstantiateContractProposal{
+ Title: "Foo",
+ Description: "Bar",
+ RunAs: anyAddress,
+ WASMByteCode: []byte{0x0},
+ Admin: anyAddress,
+ Label: "testing",
+ Msg: initMsgBz,
+ Funds: nil,
+ }
+
+ for _, m := range mutators {
+ m(p)
+ }
+ return p
+}
+
func MigrateContractProposalFixture(mutators ...func(p *MigrateContractProposal)) *MigrateContractProposal {
var (
anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, ContractAddrLen)