diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index abd59632e5..5609e3a0af 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -61,6 +61,7 @@ - [AccessConfigUpdate](#cosmwasm.wasm.v1.AccessConfigUpdate) - [ClearAdminProposal](#cosmwasm.wasm.v1.ClearAdminProposal) - [ExecuteContractProposal](#cosmwasm.wasm.v1.ExecuteContractProposal) + - [InstantiateContract2Proposal](#cosmwasm.wasm.v1.InstantiateContract2Proposal) - [InstantiateContractProposal](#cosmwasm.wasm.v1.InstantiateContractProposal) - [MigrateContractProposal](#cosmwasm.wasm.v1.MigrateContractProposal) - [PinCodesProposal](#cosmwasm.wasm.v1.PinCodesProposal) @@ -923,6 +924,30 @@ contract. + + +### InstantiateContract2Proposal +InstantiateContract2Proposal gov proposal content type to instantiate contract 2 + + +| 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 enviroment as sender | +| `admin` | [string](#string) | | Admin is an optional address that can execute migrations | +| `code_id` | [uint64](#uint64) | | CodeID is the reference to the stored WASM code | +| `label` | [string](#string) | | Label is optional metadata to be stored with a constract instance. | +| `msg` | [bytes](#bytes) | | Msg json encode 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 | +| `salt` | [bytes](#bytes) | | Salt is an arbitrary value provided by the sender. Size can be 1 to 64. | +| `fix_msg` | [bool](#bool) | | FixMsg include the msg value into the hash for the predictable address. Default is false | + + + + + + ### InstantiateContractProposal diff --git a/proto/cosmwasm/wasm/v1/proposal.proto b/proto/cosmwasm/wasm/v1/proposal.proto index b8a143b672..a419fea7cc 100644 --- a/proto/cosmwasm/wasm/v1/proposal.proto +++ b/proto/cosmwasm/wasm/v1/proposal.proto @@ -60,6 +60,34 @@ message InstantiateContractProposal { ]; } +// InstantiateContract2Proposal gov proposal content type to instantiate contract 2 +message InstantiateContract2Proposal { + // 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 enviroment as sender + string run_as = 3; + // Admin is an optional address that can execute migrations + string admin = 4; + // CodeID is the reference to the stored WASM code + uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ]; + // Label is optional metadata to be stored with a constract instance. + string label = 6; + // Msg json encode message to be passed to the contract on instantiation + bytes msg = 7 [ (gogoproto.casttype) = "RawContractMessage" ]; + // Funds coins that are transferred to the contract on instantiation + repeated cosmos.base.v1beta1.Coin funds = 8 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + // Salt is an arbitrary value provided by the sender. Size can be 1 to 64. + bytes salt = 9; + // FixMsg include the msg value into the hash for the predictable address. + // Default is false + bool fix_msg = 10; +} + // MigrateContractProposal gov proposal content type to migrate a contract. message MigrateContractProposal { // Title is a short summary diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go index 3c8a7b9f3a..3f5ecd033f 100644 --- a/x/wasm/client/cli/gov_tx.go +++ b/x/wasm/client/cli/gov_tx.go @@ -3,6 +3,7 @@ package cli import ( "bytes" "crypto/sha256" + "encoding/hex" "fmt" "net/url" "strconv" @@ -199,6 +200,71 @@ func ProposalInstantiateContractCmd() *cobra.Command { return cmd } +func ProposalInstantiateContract2Cmd() *cobra.Command { + decoder := newArgDecoder(hex.DecodeString) + cmd := &cobra.Command{ + Use: "instantiate-contract-2 [code_id_int64] [json_encoded_init_args] [salt] --label [text] --title [text] --description [text] --run-as [address] --admin [address,optional] --amount [coins,optional] --fix-msg [bool,optional]", + Short: "Submit an instantiate wasm contract proposal with predictable address", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) + if err != nil { + return err + } + + src, err := parseInstantiateArgs(args[0], args[1], 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") + } + + salt, err := decoder.DecodeString(args[2]) + if err != nil { + return fmt.Errorf("salt: %w", err) + } + + fixMsg, err := cmd.Flags().GetBool(flagFixMsg) + if err != nil { + return fmt.Errorf("fix msg: %w", err) + } + + content := types.NewInstantiateContract2Proposal(proposalTitle, proposalDescr, runAs, src.Admin, src.CodeID, src.Label, src.Msg, src.Funds, salt, fixMsg) + + msg, err := govtypes.NewMsgSubmitProposal(content, deposit, clientCtx.GetFromAddress()) + if err != nil { + return err + } + if err = msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + SilenceUsage: true, + } + + 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().String(flagRunAs, "", "The address that pays the init funds. It is the creator of the contract and passed to the contract as sender on proposal execution") + cmd.Flags().Bool(flagNoAdmin, false, "You must set this explicitly if you don't want an admin") + cmd.Flags().Bool(flagFixMsg, false, "An optional flag to include the json_encoded_init_args for the predictable address generation mode") + decoder.RegisterFlags(cmd.PersistentFlags(), "salt") + + // 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 ProposalStoreAndInstantiateContractCmd() *cobra.Command { cmd := &cobra.Command{ Use: "store-instantiate [wasm file] [json_encoded_init_args] --label [text] --title [text] --description [text] --run-as [address]" + diff --git a/x/wasm/client/proposal_handler.go b/x/wasm/client/proposal_handler.go index db51f7b3ac..286d37d197 100644 --- a/x/wasm/client/proposal_handler.go +++ b/x/wasm/client/proposal_handler.go @@ -21,4 +21,5 @@ var ProposalHandlers = []govclient.ProposalHandler{ govclient.NewProposalHandler(cli.ProposalUnpinCodesCmd, rest.UnpinCodeProposalHandler), govclient.NewProposalHandler(cli.ProposalUpdateInstantiateConfigCmd, rest.UpdateInstantiateConfigProposalHandler), govclient.NewProposalHandler(cli.ProposalStoreAndInstantiateContractCmd, rest.EmptyRestHandler), + govclient.NewProposalHandler(cli.ProposalInstantiateContract2Cmd, rest.EmptyRestHandler), } diff --git a/x/wasm/keeper/proposal_handler.go b/x/wasm/keeper/proposal_handler.go index 08f2774f3e..efcf49c481 100644 --- a/x/wasm/keeper/proposal_handler.go +++ b/x/wasm/keeper/proposal_handler.go @@ -35,6 +35,8 @@ func NewWasmProposalHandlerX(k types.ContractOpsKeeper, enabledProposalTypes []t return handleStoreCodeProposal(ctx, k, *c) case *types.InstantiateContractProposal: return handleInstantiateProposal(ctx, k, *c) + case *types.InstantiateContract2Proposal: + return handleInstantiate2Proposal(ctx, k, *c) case *types.MigrateContractProposal: return handleMigrateProposal(ctx, k, *c) case *types.SudoContractProposal: @@ -111,6 +113,38 @@ func handleInstantiateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p typ return nil } +func handleInstantiate2Proposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.InstantiateContract2Proposal) error { + // Validatebasic with proposal + if err := p.ValidateBasic(); err != nil { + return err + } + + // Get runAsAddr as AccAddress + runAsAddr, err := sdk.AccAddressFromBech32(p.RunAs) + if err != nil { + return sdkerrors.Wrap(err, "run as address") + } + + // Get admin address + var adminAddr sdk.AccAddress + if p.Admin != "" { + if adminAddr, err = sdk.AccAddressFromBech32(p.Admin); err != nil { + return sdkerrors.Wrap(err, "admin") + } + } + + _, data, err := k.Instantiate2(ctx, p.CodeID, runAsAddr, adminAddr, p.Msg, p.Label, p.Funds, p.Salt, p.FixMsg) + if err != nil { + return err + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeGovContractResult, + sdk.NewAttribute(types.AttributeKeyResultDataHex, hex.EncodeToString(data)), + )) + return nil +} + func handleStoreAndInstantiateContractProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.StoreAndInstantiateContractProposal) 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 74ef6928b9..7ea9f657d9 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -141,6 +141,70 @@ func TestInstantiateProposal(t *testing.T) { require.NotEmpty(t, em.Events()[2].Attributes[0]) } +func TestInstantiate2Proposal(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) + + codeInfo := types.CodeInfoFixture(types.WithSHA256CodeHash(wasmCode)) + err = wasmKeeper.importCode(ctx, 1, codeInfo, wasmCode) + require.NoError(t, err) + + var ( + oneAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, types.ContractAddrLen) + otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) + label string = "label" + salt []byte = []byte("mySalt") + ) + src := types.InstantiateContract2ProposalFixture(func(p *types.InstantiateContract2Proposal) { + p.CodeID = firstCodeID + p.RunAs = oneAddress.String() + p.Admin = otherAddress.String() + p.Label = label + p.Salt = salt + }) + contractAddress := BuildContractAddressPredictable(codeInfo.CodeHash, oneAddress, salt, []byte{}) + + 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) + + cInfo := wasmKeeper.GetContractInfo(ctx, contractAddress) + require.NotNil(t, cInfo) + + assert.Equal(t, uint64(1), cInfo.CodeID) + assert.Equal(t, oneAddress.String(), cInfo.Creator) + assert.Equal(t, otherAddress.String(), cInfo.Admin) + assert.Equal(t, "label", cInfo.Label) + expHistory := []types.ContractCodeHistoryEntry{{ + Operation: types.ContractCodeHistoryOperationTypeInit, + CodeID: src.CodeID, + Updated: types.NewAbsoluteTxPosition(ctx), + Msg: src.Msg, + }} + assert.Equal(t, expHistory, wasmKeeper.GetContractHistory(ctx, contractAddress)) + // and event + require.Len(t, em.Events(), 3, "%#v", em.Events()) + require.Equal(t, types.EventTypeInstantiate, em.Events()[0].Type) + require.Equal(t, types.WasmModuleEventType, em.Events()[1].Type) + require.Equal(t, types.EventTypeGovContractResult, em.Events()[2].Type) + require.Len(t, em.Events()[2].Attributes, 1) + require.NotEmpty(t, em.Events()[2].Attributes[0]) +} + func TestInstantiateProposal_NoAdmin(t *testing.T) { ctx, keepers := CreateTestInput(t, false, "staking") govKeeper, wasmKeeper := keepers.GovKeeper, keepers.WasmKeeper diff --git a/x/wasm/types/authz.pb.go b/x/wasm/types/authz.pb.go index 549b558aa1..f98d24fa93 100644 --- a/x/wasm/types/authz.pb.go +++ b/x/wasm/types/authz.pb.go @@ -18,9 +18,8 @@ import ( ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - var ( + _ = proto.Marshal _ = fmt.Errorf _ = math.Inf ) diff --git a/x/wasm/types/codec.go b/x/wasm/types/codec.go index 64b4f28e41..d1c2b9eb92 100644 --- a/x/wasm/types/codec.go +++ b/x/wasm/types/codec.go @@ -24,6 +24,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { //nolint:staticcheck cdc.RegisterConcrete(&UnpinCodesProposal{}, "wasm/UnpinCodesProposal", nil) cdc.RegisterConcrete(&StoreCodeProposal{}, "wasm/StoreCodeProposal", nil) cdc.RegisterConcrete(&InstantiateContractProposal{}, "wasm/InstantiateContractProposal", nil) + cdc.RegisterConcrete(&InstantiateContract2Proposal{}, "wasm/InstantiateContract2Proposal", nil) cdc.RegisterConcrete(&MigrateContractProposal{}, "wasm/MigrateContractProposal", nil) cdc.RegisterConcrete(&SudoContractProposal{}, "wasm/SudoContractProposal", nil) cdc.RegisterConcrete(&ExecuteContractProposal{}, "wasm/ExecuteContractProposal", nil) @@ -65,6 +66,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { (*govtypes.Content)(nil), &StoreCodeProposal{}, &InstantiateContractProposal{}, + &InstantiateContract2Proposal{}, &MigrateContractProposal{}, &SudoContractProposal{}, &ExecuteContractProposal{}, diff --git a/x/wasm/types/genesis.pb.go b/x/wasm/types/genesis.pb.go index 3f7037985a..b080905ab4 100644 --- a/x/wasm/types/genesis.pb.go +++ b/x/wasm/types/genesis.pb.go @@ -14,9 +14,8 @@ import ( ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - var ( + _ = proto.Marshal _ = fmt.Errorf _ = math.Inf ) diff --git a/x/wasm/types/ibc.pb.go b/x/wasm/types/ibc.pb.go index bedc1954ab..370b4aef85 100644 --- a/x/wasm/types/ibc.pb.go +++ b/x/wasm/types/ibc.pb.go @@ -14,9 +14,8 @@ import ( ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - var ( + _ = proto.Marshal _ = fmt.Errorf _ = math.Inf ) diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go index 1597818597..6386f08716 100644 --- a/x/wasm/types/proposal.go +++ b/x/wasm/types/proposal.go @@ -16,6 +16,7 @@ type ProposalType string const ( ProposalTypeStoreCode ProposalType = "StoreCode" ProposalTypeInstantiateContract ProposalType = "InstantiateContract" + ProposalTypeInstantiateContract2 ProposalType = "InstantiateContract2" ProposalTypeMigrateContract ProposalType = "MigrateContract" ProposalTypeSudoContract ProposalType = "SudoContract" ProposalTypeExecuteContract ProposalType = "ExecuteContract" @@ -34,6 +35,7 @@ var DisableAllProposals []ProposalType var EnableAllProposals = []ProposalType{ ProposalTypeStoreCode, ProposalTypeInstantiateContract, + ProposalTypeInstantiateContract2, ProposalTypeMigrateContract, ProposalTypeSudoContract, ProposalTypeExecuteContract, @@ -66,6 +68,7 @@ func ConvertToProposals(keys []string) ([]ProposalType, error) { func init() { // register new content types with the sdk govtypes.RegisterProposalType(string(ProposalTypeStoreCode)) govtypes.RegisterProposalType(string(ProposalTypeInstantiateContract)) + govtypes.RegisterProposalType(string(ProposalTypeInstantiateContract2)) govtypes.RegisterProposalType(string(ProposalTypeMigrateContract)) govtypes.RegisterProposalType(string(ProposalTypeSudoContract)) govtypes.RegisterProposalType(string(ProposalTypeExecuteContract)) @@ -77,6 +80,7 @@ func init() { // register new content types with the sdk govtypes.RegisterProposalType(string(ProposalTypeStoreAndInstantiateContractProposal)) govtypes.RegisterProposalTypeCodec(&StoreCodeProposal{}, "wasm/StoreCodeProposal") govtypes.RegisterProposalTypeCodec(&InstantiateContractProposal{}, "wasm/InstantiateContractProposal") + govtypes.RegisterProposalTypeCodec(&InstantiateContract2Proposal{}, "wasm/InstantiateContract2Proposal") govtypes.RegisterProposalTypeCodec(&MigrateContractProposal{}, "wasm/MigrateContractProposal") govtypes.RegisterProposalTypeCodec(&SudoContractProposal{}, "wasm/SudoContractProposal") govtypes.RegisterProposalTypeCodec(&ExecuteContractProposal{}, "wasm/ExecuteContractProposal") @@ -271,6 +275,114 @@ func (p InstantiateContractProposal) MarshalYAML() (interface{}, error) { }, nil } +func NewInstantiateContract2Proposal( + title string, + description string, + runAs string, + admin string, + codeID uint64, + label string, + msg RawContractMessage, + funds sdk.Coins, + salt []byte, + fixMsg bool, +) *InstantiateContract2Proposal { + return &InstantiateContract2Proposal{title, description, runAs, admin, codeID, label, msg, funds, salt, fixMsg} +} + +// ProposalRoute returns the routing key of a parameter change proposal. +func (p InstantiateContract2Proposal) ProposalRoute() string { return RouterKey } + +// GetTitle returns the title of the proposal +func (p *InstantiateContract2Proposal) GetTitle() string { return p.Title } + +// GetDescription returns the human readable description of the proposal +func (p InstantiateContract2Proposal) GetDescription() string { return p.Description } + +// ProposalType returns the type +func (p InstantiateContract2Proposal) ProposalType() string { + return string(ProposalTypeInstantiateContract2) +} + +// ValidateBasic validates the proposal +func (p InstantiateContract2Proposal) ValidateBasic() error { + // Validate title and description + if err := validateProposalCommons(p.Title, p.Description); err != nil { + return err + } + // Validate run as + if _, err := sdk.AccAddressFromBech32(p.RunAs); err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "run as") + } + // Validate admin + if len(p.Admin) != 0 { + if _, err := sdk.AccAddressFromBech32(p.Admin); err != nil { + return err + } + } + // Validate codeid + if p.CodeID == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "code id is required") + } + // Validate label + if err := ValidateLabel(p.Label); err != nil { + return err + } + // Validate msg + if err := p.Msg.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "payload msg") + } + // Validate funds + if !p.Funds.IsValid() { + return sdkerrors.ErrInvalidCoins + } + // Validate salt + if len(p.Salt) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "salt is required") + } + return nil +} + +// String implements the Stringer interface. +func (p InstantiateContract2Proposal) String() string { + return fmt.Sprintf(`Instantiate Code Proposal: + Title: %s + Description: %s + Run as: %s + Admin: %s + Code id: %d + Label: %s + Msg: %q + Funds: %s + Salt: %X +`, p.Title, p.Description, p.RunAs, p.Admin, p.CodeID, p.Label, p.Msg, p.Funds, p.Salt) +} + +// MarshalYAML pretty prints the init message +func (p InstantiateContract2Proposal) MarshalYAML() (interface{}, error) { + return struct { + Title string `yaml:"title"` + Description string `yaml:"description"` + RunAs string `yaml:"run_as"` + Admin string `yaml:"admin"` + CodeID uint64 `yaml:"code_id"` + Label string `yaml:"label"` + Msg string `yaml:"msg"` + Funds sdk.Coins `yaml:"funds"` + Salt string `yaml:"salt"` + }{ + Title: p.Title, + Description: p.Description, + RunAs: p.RunAs, + Admin: p.Admin, + CodeID: p.CodeID, + Label: p.Label, + Msg: string(p.Msg), + Funds: p.Funds, + Salt: base64.StdEncoding.EncodeToString(p.Salt), + }, nil +} + func NewStoreAndInstantiateContractProposal( title string, description string, diff --git a/x/wasm/types/proposal.pb.go b/x/wasm/types/proposal.pb.go index dbce4e7172..6062ffdbfa 100644 --- a/x/wasm/types/proposal.pb.go +++ b/x/wasm/types/proposal.pb.go @@ -148,6 +148,68 @@ func (m *InstantiateContractProposal) XXX_DiscardUnknown() { var xxx_messageInfo_InstantiateContractProposal proto.InternalMessageInfo +// InstantiateContract2Proposal gov proposal content type to instantiate contract 2 +type InstantiateContract2Proposal 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"` + // Admin is an optional address that can execute migrations + Admin string `protobuf:"bytes,4,opt,name=admin,proto3" json:"admin,omitempty"` + // CodeID is the reference to the stored WASM code + CodeID uint64 `protobuf:"varint,5,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + // Label is optional metadata to be stored with a constract instance. + Label string `protobuf:"bytes,6,opt,name=label,proto3" json:"label,omitempty"` + // Msg json encode message to be passed to the contract on instantiation + Msg RawContractMessage `protobuf:"bytes,7,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,8,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` + // Salt is an arbitrary value provided by the sender. Size can be 1 to 64. + Salt []byte `protobuf:"bytes,9,opt,name=salt,proto3" json:"salt,omitempty"` + // FixMsg include the msg value into the hash for the predictable address. + // Default is false + FixMsg bool `protobuf:"varint,10,opt,name=fix_msg,json=fixMsg,proto3" json:"fix_msg,omitempty"` +} + +func (m *InstantiateContract2Proposal) Reset() { *m = InstantiateContract2Proposal{} } +func (*InstantiateContract2Proposal) ProtoMessage() {} +func (*InstantiateContract2Proposal) Descriptor() ([]byte, []int) { + return fileDescriptor_be6422d717c730cb, []int{2} +} + +func (m *InstantiateContract2Proposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *InstantiateContract2Proposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InstantiateContract2Proposal.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 *InstantiateContract2Proposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_InstantiateContract2Proposal.Merge(m, src) +} + +func (m *InstantiateContract2Proposal) XXX_Size() int { + return m.Size() +} + +func (m *InstantiateContract2Proposal) XXX_DiscardUnknown() { + xxx_messageInfo_InstantiateContract2Proposal.DiscardUnknown(m) +} + +var xxx_messageInfo_InstantiateContract2Proposal proto.InternalMessageInfo + // MigrateContractProposal gov proposal content type to migrate a contract. type MigrateContractProposal struct { // Title is a short summary @@ -165,7 +227,7 @@ type MigrateContractProposal struct { func (m *MigrateContractProposal) Reset() { *m = MigrateContractProposal{} } func (*MigrateContractProposal) ProtoMessage() {} func (*MigrateContractProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{2} + return fileDescriptor_be6422d717c730cb, []int{3} } func (m *MigrateContractProposal) XXX_Unmarshal(b []byte) error { @@ -214,7 +276,7 @@ type SudoContractProposal struct { func (m *SudoContractProposal) Reset() { *m = SudoContractProposal{} } func (*SudoContractProposal) ProtoMessage() {} func (*SudoContractProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{3} + return fileDescriptor_be6422d717c730cb, []int{4} } func (m *SudoContractProposal) XXX_Unmarshal(b []byte) error { @@ -268,7 +330,7 @@ type ExecuteContractProposal struct { func (m *ExecuteContractProposal) Reset() { *m = ExecuteContractProposal{} } func (*ExecuteContractProposal) ProtoMessage() {} func (*ExecuteContractProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{4} + return fileDescriptor_be6422d717c730cb, []int{5} } func (m *ExecuteContractProposal) XXX_Unmarshal(b []byte) error { @@ -317,7 +379,7 @@ type UpdateAdminProposal struct { func (m *UpdateAdminProposal) Reset() { *m = UpdateAdminProposal{} } func (*UpdateAdminProposal) ProtoMessage() {} func (*UpdateAdminProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{5} + return fileDescriptor_be6422d717c730cb, []int{6} } func (m *UpdateAdminProposal) XXX_Unmarshal(b []byte) error { @@ -365,7 +427,7 @@ type ClearAdminProposal struct { func (m *ClearAdminProposal) Reset() { *m = ClearAdminProposal{} } func (*ClearAdminProposal) ProtoMessage() {} func (*ClearAdminProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{6} + return fileDescriptor_be6422d717c730cb, []int{7} } func (m *ClearAdminProposal) XXX_Unmarshal(b []byte) error { @@ -413,7 +475,7 @@ type PinCodesProposal struct { func (m *PinCodesProposal) Reset() { *m = PinCodesProposal{} } func (*PinCodesProposal) ProtoMessage() {} func (*PinCodesProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{7} + return fileDescriptor_be6422d717c730cb, []int{8} } func (m *PinCodesProposal) XXX_Unmarshal(b []byte) error { @@ -461,7 +523,7 @@ type UnpinCodesProposal struct { func (m *UnpinCodesProposal) Reset() { *m = UnpinCodesProposal{} } func (*UnpinCodesProposal) ProtoMessage() {} func (*UnpinCodesProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{8} + return fileDescriptor_be6422d717c730cb, []int{9} } func (m *UnpinCodesProposal) XXX_Unmarshal(b []byte) error { @@ -507,7 +569,7 @@ type AccessConfigUpdate struct { func (m *AccessConfigUpdate) Reset() { *m = AccessConfigUpdate{} } func (*AccessConfigUpdate) ProtoMessage() {} func (*AccessConfigUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{9} + return fileDescriptor_be6422d717c730cb, []int{10} } func (m *AccessConfigUpdate) XXX_Unmarshal(b []byte) error { @@ -556,7 +618,7 @@ type UpdateInstantiateConfigProposal struct { func (m *UpdateInstantiateConfigProposal) Reset() { *m = UpdateInstantiateConfigProposal{} } func (*UpdateInstantiateConfigProposal) ProtoMessage() {} func (*UpdateInstantiateConfigProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{10} + return fileDescriptor_be6422d717c730cb, []int{11} } func (m *UpdateInstantiateConfigProposal) XXX_Unmarshal(b []byte) error { @@ -626,7 +688,7 @@ type StoreAndInstantiateContractProposal struct { func (m *StoreAndInstantiateContractProposal) Reset() { *m = StoreAndInstantiateContractProposal{} } func (*StoreAndInstantiateContractProposal) ProtoMessage() {} func (*StoreAndInstantiateContractProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_be6422d717c730cb, []int{11} + return fileDescriptor_be6422d717c730cb, []int{12} } func (m *StoreAndInstantiateContractProposal) XXX_Unmarshal(b []byte) error { @@ -663,6 +725,7 @@ var xxx_messageInfo_StoreAndInstantiateContractProposal proto.InternalMessageInf func init() { proto.RegisterType((*StoreCodeProposal)(nil), "cosmwasm.wasm.v1.StoreCodeProposal") proto.RegisterType((*InstantiateContractProposal)(nil), "cosmwasm.wasm.v1.InstantiateContractProposal") + proto.RegisterType((*InstantiateContract2Proposal)(nil), "cosmwasm.wasm.v1.InstantiateContract2Proposal") proto.RegisterType((*MigrateContractProposal)(nil), "cosmwasm.wasm.v1.MigrateContractProposal") proto.RegisterType((*SudoContractProposal)(nil), "cosmwasm.wasm.v1.SudoContractProposal") proto.RegisterType((*ExecuteContractProposal)(nil), "cosmwasm.wasm.v1.ExecuteContractProposal") @@ -678,66 +741,69 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/proposal.proto", fileDescriptor_be6422d717c730cb) } var fileDescriptor_be6422d717c730cb = []byte{ - // 936 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0xcf, 0xe4, 0x8f, 0xe3, 0xbc, 0x04, 0x08, 0xde, 0xb4, 0x6b, 0xba, 0x60, 0x47, 0x5e, 0xb4, - 0xca, 0x05, 0x87, 0x14, 0x09, 0x01, 0xb7, 0x38, 0x20, 0xd1, 0x15, 0x95, 0x2a, 0x57, 0xd5, 0x4a, - 0x20, 0x11, 0x4d, 0xec, 0x69, 0x62, 0x91, 0x78, 0x22, 0x8f, 0xdd, 0x6e, 0xbf, 0x05, 0x48, 0x88, + // 981 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x57, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0xd3, 0xc4, 0x71, 0x5e, 0x02, 0x84, 0xd9, 0xb4, 0x35, 0xdd, 0xc5, 0x8e, 0xbc, 0x68, + 0x95, 0x0b, 0x09, 0x29, 0x12, 0x02, 0x6e, 0x71, 0x40, 0xa2, 0x2b, 0x2a, 0x55, 0xae, 0xaa, 0x95, + 0x40, 0x22, 0x9a, 0xd8, 0x93, 0xc4, 0x22, 0xf1, 0x44, 0x1e, 0xbb, 0x7f, 0xbe, 0x05, 0x48, 0x88, 0x13, 0x1f, 0x00, 0xed, 0x05, 0x71, 0xe7, 0x03, 0x54, 0x9c, 0xf6, 0xb8, 0x27, 0xc3, 0xa6, 0x47, - 0x6e, 0x3d, 0x72, 0x42, 0x33, 0xe3, 0x84, 0xb4, 0xbb, 0xcd, 0xee, 0x8a, 0xa6, 0xd2, 0x5e, 0x9c, -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0x13, 0x49, 0xca, 0x65, 0x91, 0xb4, 0x90, - 0x16, 0xe5, 0x65, 0x69, 0xb1, 0x50, 0x0d, 0xea, 0x73, 0x54, 0x43, 0xe5, 0x15, 0xde, 0x72, 0x58, - 0xd7, 0x5b, 0xbe, 0xa4, 0xee, 0xaa, 0x57, 0xa9, 0xbb, 0xda, 0x0a, 0x75, 0xf7, 0xc6, 0x45, 0x75, - 0xe7, 0x7c, 0x75, 0xfa, 0xd4, 0xc8, 0x3d, 0x79, 0x6a, 0xe4, 0x7e, 0x99, 0x19, 0xe8, 0x74, 0x66, - 0xa0, 0xc7, 0x33, 0x03, 0xfd, 0x35, 0x33, 0xd0, 0xf7, 0x67, 0x46, 0xee, 0xf1, 0x99, 0x91, 0x7b, - 0x72, 0x66, 0xe4, 0xbe, 0xbe, 0xb7, 0x84, 0xb2, 0x47, 0xd9, 0xe4, 0xc1, 0x5c, 0x8e, 0xfb, 0xed, - 0x87, 0x52, 0x96, 0x0b, 0xa4, 0x03, 0x45, 0x88, 0xf2, 0x8f, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, - 0x13, 0x9e, 0x35, 0x27, 0x1d, 0x0c, 0x00, 0x00, + 0x6e, 0x3d, 0x21, 0x4e, 0x68, 0x66, 0x9c, 0x6c, 0xda, 0x6d, 0xb3, 0xbb, 0xd0, 0xac, 0x84, 0xc4, + 0x25, 0xf1, 0x9b, 0xf7, 0x66, 0xde, 0xef, 0xfd, 0xf4, 0xde, 0xf8, 0x67, 0x30, 0x5d, 0xca, 0xc6, + 0x47, 0x98, 0x8d, 0x9b, 0xe2, 0xe7, 0xb0, 0xd5, 0x9c, 0x84, 0x74, 0x42, 0x19, 0x1e, 0x35, 0x26, + 0x21, 0x8d, 0x28, 0xaa, 0xcc, 0x02, 0x1a, 0xe2, 0xe7, 0xb0, 0xb5, 0x55, 0x1d, 0xd0, 0x01, 0x15, + 0xce, 0x26, 0x7f, 0x92, 0x71, 0x5b, 0x06, 0x8f, 0xa3, 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cc, 0x25, 0x86, 0x76, 0x85, 0xc4, 0x28, 0xbe, 0xc4, 0x5d, 0x0e, 0x2b, 0x93, 0x18, 0x4f, 0x85, + 0x75, 0xe9, 0x3a, 0x61, 0x5d, 0x5e, 0x22, 0xac, 0x5f, 0xbb, 0x28, 0xac, 0xed, 0xcf, 0x4f, 0x9f, + 0x18, 0x99, 0xc7, 0x4f, 0x8c, 0xcc, 0x8f, 0x53, 0x43, 0x39, 0x9d, 0x1a, 0xca, 0xa3, 0xa9, 0xa1, + 0xfc, 0x3e, 0x35, 0x94, 0x6f, 0xce, 0x8c, 0xcc, 0xa3, 0x33, 0x23, 0xf3, 0xf8, 0xcc, 0xc8, 0x7c, + 0x71, 0x6f, 0x01, 0x65, 0x87, 0xb2, 0xf1, 0x83, 0xd9, 0x97, 0x90, 0xd7, 0x3c, 0x96, 0x5f, 0x44, + 0x02, 0x69, 0x4f, 0x15, 0xdf, 0x43, 0xef, 0xff, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x34, 0xb6, 0x6c, + 0x40, 0x98, 0x0d, 0x00, 0x00, } func (this *StoreCodeProposal) Equal(that interface{}) bool { @@ -840,6 +906,63 @@ func (this *InstantiateContractProposal) Equal(that interface{}) bool { return true } +func (this *InstantiateContract2Proposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*InstantiateContract2Proposal) + if !ok { + that2, ok := that.(InstantiateContract2Proposal) + 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 this.Admin != that1.Admin { + return false + } + if this.CodeID != that1.CodeID { + 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 + } + } + if !bytes.Equal(this.Salt, that1.Salt) { + return false + } + if this.FixMsg != that1.FixMsg { + return false + } + return true +} + func (this *MigrateContractProposal) Equal(that interface{}) bool { if that == nil { return this == nil @@ -1401,6 +1524,107 @@ func (m *InstantiateContractProposal) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } +func (m *InstantiateContract2Proposal) 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 *InstantiateContract2Proposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InstantiateContract2Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.FixMsg { + i-- + if m.FixMsg { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x50 + } + if len(m.Salt) > 0 { + i -= len(m.Salt) + copy(dAtA[i:], m.Salt) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Salt))) + i-- + dAtA[i] = 0x4a + } + 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] = 0x42 + } + } + 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] = 0x3a + } + 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] = 0x32 + } + if m.CodeID != 0 { + i = encodeVarintProposal(dAtA, i, uint64(m.CodeID)) + i-- + dAtA[i] = 0x28 + } + 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] = 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 (m *MigrateContractProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2101,6 +2325,55 @@ func (m *InstantiateContractProposal) Size() (n int) { return n } +func (m *InstantiateContract2Proposal) 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.Admin) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + if m.CodeID != 0 { + n += 1 + sovProposal(uint64(m.CodeID)) + } + 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)) + } + } + l = len(m.Salt) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + if m.FixMsg { + n += 2 + } + return n +} + func (m *MigrateContractProposal) Size() (n int) { if m == nil { return 0 @@ -3023,6 +3296,358 @@ func (m *InstantiateContractProposal) Unmarshal(dAtA []byte) error { return nil } +func (m *InstantiateContract2Proposal) 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: InstantiateContract2Proposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InstantiateContract2Proposal: 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 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 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeID", wireType) + } + m.CodeID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + 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 7: + 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 8: + 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 + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Salt", 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.Salt = append(m.Salt[:0], dAtA[iNdEx:postIndex]...) + if m.Salt == nil { + m.Salt = []byte{} + } + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FixMsg", 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.FixMsg = bool(v != 0) + 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 (m *MigrateContractProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/wasm/types/proposal_test.go b/x/wasm/types/proposal_test.go index 581ed85d80..a558744f8b 100644 --- a/x/wasm/types/proposal_test.go +++ b/x/wasm/types/proposal_test.go @@ -279,6 +279,105 @@ func TestValidateInstantiateContractProposal(t *testing.T) { } } +func TestValidateInstantiateContract2Proposal(t *testing.T) { + invalidAddress := "invalid address" + + specs := map[string]struct { + src *InstantiateContract2Proposal + expErr bool + }{ + "all good": { + src: InstantiateContract2ProposalFixture(), + }, + "without admin": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Admin = "" + }), + }, + "without init msg": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Msg = nil + }), + expErr: true, + }, + "with invalid init msg": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Msg = []byte("not a json string") + }), + expErr: true, + }, + "without init funds": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Funds = nil + }), + }, + "base data missing": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Title = "" + }), + expErr: true, + }, + "run_as missing": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.RunAs = "" + }), + expErr: true, + }, + "run_as invalid": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.RunAs = invalidAddress + }), + expErr: true, + }, + "admin invalid": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Admin = invalidAddress + }), + expErr: true, + }, + "code id empty": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.CodeID = 0 + }), + expErr: true, + }, + "label empty": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Label = "" + }), + expErr: true, + }, + "init funds negative": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(-1)}} + }), + expErr: true, + }, + "init funds with duplicates": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Funds = sdk.Coins{{Denom: "foo", Amount: sdk.NewInt(1)}, {Denom: "foo", Amount: sdk.NewInt(2)}} + }), + expErr: true, + }, + "init with empty salt": { + src: InstantiateContract2ProposalFixture(func(p *InstantiateContract2Proposal) { + p.Salt = nil + }), + 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 TestValidateStoreAndInstantiateContractProposal(t *testing.T) { var ( anyAddress sdk.AccAddress = bytes.Repeat([]byte{0x0}, ContractAddrLen) diff --git a/x/wasm/types/query.pb.go b/x/wasm/types/query.pb.go index 68b15e39fa..95175f2ae6 100644 --- a/x/wasm/types/query.pb.go +++ b/x/wasm/types/query.pb.go @@ -23,9 +23,8 @@ import ( ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - var ( + _ = proto.Marshal _ = fmt.Errorf _ = math.Inf ) diff --git a/x/wasm/types/query.pb.gw.go b/x/wasm/types/query.pb.gw.go index 4bffee3d7c..32f3fd25cd 100644 --- a/x/wasm/types/query.pb.gw.go +++ b/x/wasm/types/query.pb.gw.go @@ -25,9 +25,8 @@ import ( ) // Suppress "imported and not used" errors -var _ codes.Code - var ( + _ codes.Code _ io.Reader _ status.Status _ = runtime.String diff --git a/x/wasm/types/test_fixtures.go b/x/wasm/types/test_fixtures.go index e62399972f..1f68e4bb56 100644 --- a/x/wasm/types/test_fixtures.go +++ b/x/wasm/types/test_fixtures.go @@ -258,6 +258,46 @@ func InstantiateContractProposalFixture(mutators ...func(p *InstantiateContractP return p } +func InstantiateContract2ProposalFixture(mutators ...func(p *InstantiateContract2Proposal)) *InstantiateContract2Proposal { + 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" + mySalt = "myDefaultSalt" + ) + + initMsgBz, err := json.Marshal(initMsg) + if err != nil { + panic(err) + } + p := &InstantiateContract2Proposal{ + Title: "Foo", + Description: "Bar", + RunAs: anyAddress, + Admin: anyAddress, + CodeID: 1, + Label: "testing", + Msg: initMsgBz, + Funds: nil, + Salt: []byte(mySalt), + FixMsg: false, + } + + for _, m := range mutators { + m(p) + } + return p +} + func StoreAndInstantiateContractProposalFixture(mutators ...func(p *StoreAndInstantiateContractProposal)) *StoreAndInstantiateContractProposal { var ( anyValidAddress sdk.AccAddress = bytes.Repeat([]byte{0x1}, ContractAddrLen) diff --git a/x/wasm/types/tx.pb.go b/x/wasm/types/tx.pb.go index 4670ba2b0b..4aa9676b37 100644 --- a/x/wasm/types/tx.pb.go +++ b/x/wasm/types/tx.pb.go @@ -21,9 +21,8 @@ import ( ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - var ( + _ = proto.Marshal _ = fmt.Errorf _ = math.Inf ) diff --git a/x/wasm/types/types.pb.go b/x/wasm/types/types.pb.go index d53952253e..8914b69485 100644 --- a/x/wasm/types/types.pb.go +++ b/x/wasm/types/types.pb.go @@ -18,9 +18,8 @@ import ( ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal - var ( + _ = proto.Marshal _ = fmt.Errorf _ = math.Inf )