diff --git a/app/app.go b/app/app.go index 55a4d0af73..037dca2009 100644 --- a/app/app.go +++ b/app/app.go @@ -122,9 +122,9 @@ import ( "github.com/spf13/cast" "github.com/CosmWasm/wasmd/x/wasm" - wasmclient "github.com/CosmWasm/wasmd/x/wasm/client" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" ) const appName = "WasmApp" @@ -194,14 +194,13 @@ var ( mint.AppModuleBasic{}, distr.AppModuleBasic{}, gov.NewAppModuleBasic( - append( - wasmclient.ProposalHandlers, + []govclient.ProposalHandler{ paramsclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler, ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler, - ), + }, ), params.AppModuleBasic{}, crisis.AppModuleBasic{}, diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index b0ad0b0445..b55424e5b9 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -92,8 +92,16 @@ - [MsgInstantiateContractResponse](#cosmwasm.wasm.v1.MsgInstantiateContractResponse) - [MsgMigrateContract](#cosmwasm.wasm.v1.MsgMigrateContract) - [MsgMigrateContractResponse](#cosmwasm.wasm.v1.MsgMigrateContractResponse) + - [MsgPinCodes](#cosmwasm.wasm.v1.MsgPinCodes) + - [MsgPinCodesResponse](#cosmwasm.wasm.v1.MsgPinCodesResponse) + - [MsgStoreAndInstantiateContract](#cosmwasm.wasm.v1.MsgStoreAndInstantiateContract) + - [MsgStoreAndInstantiateContractResponse](#cosmwasm.wasm.v1.MsgStoreAndInstantiateContractResponse) - [MsgStoreCode](#cosmwasm.wasm.v1.MsgStoreCode) - [MsgStoreCodeResponse](#cosmwasm.wasm.v1.MsgStoreCodeResponse) + - [MsgSudoContract](#cosmwasm.wasm.v1.MsgSudoContract) + - [MsgSudoContractResponse](#cosmwasm.wasm.v1.MsgSudoContractResponse) + - [MsgUnpinCodes](#cosmwasm.wasm.v1.MsgUnpinCodes) + - [MsgUnpinCodesResponse](#cosmwasm.wasm.v1.MsgUnpinCodesResponse) - [MsgUpdateAdmin](#cosmwasm.wasm.v1.MsgUpdateAdmin) - [MsgUpdateAdminResponse](#cosmwasm.wasm.v1.MsgUpdateAdminResponse) - [MsgUpdateInstantiateConfig](#cosmwasm.wasm.v1.MsgUpdateInstantiateConfig) @@ -628,8 +636,10 @@ applied. ### ClearAdminProposal -ClearAdminProposal gov proposal content type to clear the admin of a -contract. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit ClearAdminProposal. To clear the admin of a contract, +a simple MsgClearAdmin can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -646,8 +656,10 @@ contract. ### ExecuteContractProposal -ExecuteContractProposal gov proposal content type to call execute on a -contract. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit ExecuteContractProposal. To call execute on a contract, +a simple MsgExecuteContract can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -667,8 +679,10 @@ contract. ### InstantiateContract2Proposal -InstantiateContract2Proposal gov proposal content type to instantiate -contract 2 +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit InstantiateContract2Proposal. To instantiate contract 2, +a simple MsgInstantiateContract2 can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -692,8 +706,10 @@ contract 2 ### InstantiateContractProposal -InstantiateContractProposal gov proposal content type to instantiate a -contract. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit InstantiateContractProposal. To instantiate a contract, +a simple MsgInstantiateContract can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -715,7 +731,10 @@ contract. ### MigrateContractProposal -MigrateContractProposal gov proposal content type to migrate a contract. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit MigrateContractProposal. To migrate a contract, +a simple MsgMigrateContract can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -736,8 +755,10 @@ Note: skipping 3 as this was previously used for unneeded run_as | ### PinCodesProposal -PinCodesProposal gov proposal content type to pin a set of code ids in the -wasmvm cache. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit PinCodesProposal. To pin a set of code ids in the wasmvm +cache, a simple MsgPinCodes can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -754,8 +775,10 @@ wasmvm cache. ### StoreAndInstantiateContractProposal -StoreAndInstantiateContractProposal gov proposal content type to store -and instantiate the contract. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit StoreAndInstantiateContractProposal. To store and instantiate +the contract, a simple MsgStoreAndInstantiateContract can be invoked from +the x/gov module via a v1 governance proposal. | Field | Type | Label | Description | @@ -782,7 +805,10 @@ and instantiate the contract. ### StoreCodeProposal -StoreCodeProposal gov proposal content type to submit WASM code to the system +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit StoreCodeProposal. To submit WASM code to the system, +a simple MsgStoreCode can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -805,7 +831,10 @@ StoreCodeProposal gov proposal content type to submit WASM code to the system ### SudoContractProposal -SudoContractProposal gov proposal content type to call sudo on a contract. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit SudoContractProposal. To call sudo on a contract, +a simple MsgSudoContract can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -823,8 +852,10 @@ SudoContractProposal gov proposal content type to call sudo on a contract. ### UnpinCodesProposal -UnpinCodesProposal gov proposal content type to unpin a set of code ids in -the wasmvm cache. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit UnpinCodesProposal. To unpin a set of code ids in the wasmvm +cache, a simple MsgUnpinCodes can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -841,7 +872,10 @@ the wasmvm cache. ### UpdateAdminProposal -UpdateAdminProposal gov proposal content type to set an admin for a contract. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit UpdateAdminProposal. To set an admin for a contract, +a simple MsgUpdateAdmin can be invoked from the x/gov module via +a v1 governance proposal. | Field | Type | Label | Description | @@ -859,8 +893,10 @@ UpdateAdminProposal gov proposal content type to set an admin for a contract. ### UpdateInstantiateConfigProposal -UpdateInstantiateConfigProposal gov proposal content type to update -instantiate config to a set of code ids. +Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +an explicit UpdateInstantiateConfigProposal. To update instantiate config +to a set of code ids, a simple MsgUpdateInstantiateConfig can be invoked from +the x/gov module via a v1 governance proposal. | Field | Type | Label | Description | @@ -1467,6 +1503,84 @@ MsgMigrateContractResponse returns contract migration result data. + + +### MsgPinCodes +MsgPinCodes is the MsgPinCodes request type. + +Since: 0.40 + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | Authority is the address of the governance account. | +| `code_ids` | [uint64](#uint64) | repeated | CodeIDs references the new WASM codes | + + + + + + + + +### MsgPinCodesResponse +MsgPinCodesResponse defines the response structure for executing a +MsgPinCodes message. + +Since: 0.40 + + + + + + + + +### MsgStoreAndInstantiateContract +MsgStoreAndInstantiateContract is the MsgStoreAndInstantiateContract +request type. + +Since: 0.40 + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | Authority is the address of the governance account. | +| `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. As default the uploaded contract is pinned to cache. | +| `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 from the authority account to the contract on instantiation | +| `source` | [string](#string) | | Source is the URL where the code is hosted | +| `builder` | [string](#string) | | Builder is the docker image used to build the code deterministically, used for smart contract verification | +| `code_hash` | [bytes](#bytes) | | CodeHash is the SHA256 sum of the code outputted by builder, used for smart contract verification | + + + + + + + + +### MsgStoreAndInstantiateContractResponse +MsgStoreAndInstantiateContractResponse defines the response structure +for executing a MsgStoreAndInstantiateContract message. + +Since: 0.40 + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | Address is the bech32 address of the new contract instance. | +| `data` | [bytes](#bytes) | | Data contains bytes to returned from the contract | + + + + + + ### MsgStoreCode @@ -1500,6 +1614,74 @@ MsgStoreCodeResponse returns store result data. + + +### MsgSudoContract +MsgSudoContract is the MsgSudoContract request type. + +Since: 0.40 + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | Authority is the address of the governance account. | +| `contract` | [string](#string) | | Contract is the address of the smart contract | +| `msg` | [bytes](#bytes) | | Msg json encoded message to be passed to the contract as sudo | + + + + + + + + +### MsgSudoContractResponse +MsgSudoContractResponse defines the response structure for executing a +MsgSudoContract message. + +Since: 0.40 + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `data` | [bytes](#bytes) | | Data contains bytes to returned from the contract | + + + + + + + + +### MsgUnpinCodes +MsgUnpinCodes is the MsgUnpinCodes request type. + +Since: 0.40 + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | Authority is the address of the governance account. | +| `code_ids` | [uint64](#uint64) | repeated | CodeIDs references the WASM codes | + + + + + + + + +### MsgUnpinCodesResponse +MsgUnpinCodesResponse defines the response structure for executing a +MsgUnpinCodes message. + +Since: 0.40 + + + + + + ### MsgUpdateAdmin @@ -1557,14 +1739,14 @@ MsgUpdateInstantiateConfigResponse returns empty data ### MsgUpdateParams -MsgUpdateParams is the Msg/UpdateParams request type. +MsgUpdateParams is the MsgUpdateParams request type. Since: 0.40 | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | authority is the address of the governance account. | +| `authority` | [string](#string) | | Authority is the address of the governance account. | | `params` | [Params](#cosmwasm.wasm.v1.Params) | | params defines the x/wasm parameters to update. NOTE: All parameters must be supplied. | @@ -1610,6 +1792,18 @@ Msg defines the wasm Msg service. | `UpdateInstantiateConfig` | [MsgUpdateInstantiateConfig](#cosmwasm.wasm.v1.MsgUpdateInstantiateConfig) | [MsgUpdateInstantiateConfigResponse](#cosmwasm.wasm.v1.MsgUpdateInstantiateConfigResponse) | UpdateInstantiateConfig updates instantiate config for a smart contract | | | `UpdateParams` | [MsgUpdateParams](#cosmwasm.wasm.v1.MsgUpdateParams) | [MsgUpdateParamsResponse](#cosmwasm.wasm.v1.MsgUpdateParamsResponse) | UpdateParams defines a governance operation for updating the x/wasm module parameters. The authority is defined in the keeper. +Since: 0.40 | | +| `SudoContract` | [MsgSudoContract](#cosmwasm.wasm.v1.MsgSudoContract) | [MsgSudoContractResponse](#cosmwasm.wasm.v1.MsgSudoContractResponse) | SudoContract defines a governance operation for calling sudo on a contract. The authority is defined in the keeper. + +Since: 0.40 | | +| `PinCodes` | [MsgPinCodes](#cosmwasm.wasm.v1.MsgPinCodes) | [MsgPinCodesResponse](#cosmwasm.wasm.v1.MsgPinCodesResponse) | PinCodes defines a governance operation for pinning a set of code ids in the wasmvm cache. The authority is defined in the keeper. + +Since: 0.40 | | +| `UnpinCodes` | [MsgUnpinCodes](#cosmwasm.wasm.v1.MsgUnpinCodes) | [MsgUnpinCodesResponse](#cosmwasm.wasm.v1.MsgUnpinCodesResponse) | UnpinCodes defines a governance operation for unpinning a set of code ids in the wasmvm cache. The authority is defined in the keeper. + +Since: 0.40 | | +| `StoreAndInstantiateContract` | [MsgStoreAndInstantiateContract](#cosmwasm.wasm.v1.MsgStoreAndInstantiateContract) | [MsgStoreAndInstantiateContractResponse](#cosmwasm.wasm.v1.MsgStoreAndInstantiateContractResponse) | StoreAndInstantiateContract defines a governance operation for storing and instantiating the contract. The authority is defined in the keeper. + Since: 0.40 | | diff --git a/proto/cosmwasm/wasm/v1/proposal.proto b/proto/cosmwasm/wasm/v1/proposal.proto index b1c484bc9c..c171feb4af 100644 --- a/proto/cosmwasm/wasm/v1/proposal.proto +++ b/proto/cosmwasm/wasm/v1/proposal.proto @@ -11,8 +11,12 @@ option (gogoproto.goproto_stringer_all) = false; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = true; -// StoreCodeProposal gov proposal content type to submit WASM code to the system +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit StoreCodeProposal. To submit WASM code to the system, +// a simple MsgStoreCode can be invoked from the x/gov module via +// a v1 governance proposal. message StoreCodeProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -39,9 +43,12 @@ message StoreCodeProposal { bytes code_hash = 11; } -// InstantiateContractProposal gov proposal content type to instantiate a -// contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit InstantiateContractProposal. To instantiate a contract, +// a simple MsgInstantiateContract can be invoked from the x/gov module via +// a v1 governance proposal. message InstantiateContractProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -65,9 +72,12 @@ message InstantiateContractProposal { ]; } -// InstantiateContract2Proposal gov proposal content type to instantiate -// contract 2 +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit InstantiateContract2Proposal. To instantiate contract 2, +// a simple MsgInstantiateContract2 can be invoked from the x/gov module via +// a v1 governance proposal. message InstantiateContract2Proposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -96,8 +106,12 @@ message InstantiateContract2Proposal { bool fix_msg = 10; } -// MigrateContractProposal gov proposal content type to migrate a contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit MigrateContractProposal. To migrate a contract, +// a simple MsgMigrateContract can be invoked from the x/gov module via +// a v1 governance proposal. message MigrateContractProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -114,8 +128,12 @@ message MigrateContractProposal { bytes msg = 6 [ (gogoproto.casttype) = "RawContractMessage" ]; } -// SudoContractProposal gov proposal content type to call sudo on a contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit SudoContractProposal. To call sudo on a contract, +// a simple MsgSudoContract can be invoked from the x/gov module via +// a v1 governance proposal. message SudoContractProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -128,9 +146,12 @@ message SudoContractProposal { bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ]; } -// ExecuteContractProposal gov proposal content type to call execute on a -// contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit ExecuteContractProposal. To call execute on a contract, +// a simple MsgExecuteContract can be invoked from the x/gov module via +// a v1 governance proposal. message ExecuteContractProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -150,8 +171,12 @@ message ExecuteContractProposal { ]; } -// UpdateAdminProposal gov proposal content type to set an admin for a contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit UpdateAdminProposal. To set an admin for a contract, +// a simple MsgUpdateAdmin can be invoked from the x/gov module via +// a v1 governance proposal. message UpdateAdminProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -164,9 +189,12 @@ message UpdateAdminProposal { string contract = 4; } -// ClearAdminProposal gov proposal content type to clear the admin of a -// contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit ClearAdminProposal. To clear the admin of a contract, +// a simple MsgClearAdmin can be invoked from the x/gov module via +// a v1 governance proposal. message ClearAdminProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -177,9 +205,12 @@ message ClearAdminProposal { string contract = 3; } -// PinCodesProposal gov proposal content type to pin a set of code ids in the -// wasmvm cache. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit PinCodesProposal. To pin a set of code ids in the wasmvm +// cache, a simple MsgPinCodes can be invoked from the x/gov module via +// a v1 governance proposal. message PinCodesProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -193,9 +224,12 @@ message PinCodesProposal { ]; } -// UnpinCodesProposal gov proposal content type to unpin a set of code ids in -// the wasmvm cache. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit UnpinCodesProposal. To unpin a set of code ids in the wasmvm +// cache, a simple MsgUnpinCodes can be invoked from the x/gov module via +// a v1 governance proposal. message UnpinCodesProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -218,9 +252,12 @@ message AccessConfigUpdate { AccessConfig instantiate_permission = 2 [ (gogoproto.nullable) = false ]; } -// UpdateInstantiateConfigProposal gov proposal content type to update -// instantiate config to a set of code ids. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit UpdateInstantiateConfigProposal. To update instantiate config +// to a set of code ids, a simple MsgUpdateInstantiateConfig can be invoked from +// the x/gov module via a v1 governance proposal. message UpdateInstantiateConfigProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary @@ -233,9 +270,12 @@ message UpdateInstantiateConfigProposal { [ (gogoproto.nullable) = false ]; } -// StoreAndInstantiateContractProposal gov proposal content type to store -// and instantiate the contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit StoreAndInstantiateContractProposal. To store and instantiate +// the contract, a simple MsgStoreAndInstantiateContract can be invoked from +// the x/gov module via a v1 governance proposal. message StoreAndInstantiateContractProposal { + option deprecated = true; option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // Title is a short summary diff --git a/proto/cosmwasm/wasm/v1/tx.proto b/proto/cosmwasm/wasm/v1/tx.proto index 5b86535a21..3add64c029 100644 --- a/proto/cosmwasm/wasm/v1/tx.proto +++ b/proto/cosmwasm/wasm/v1/tx.proto @@ -38,6 +38,27 @@ service Msg { // // Since: 0.40 rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + // SudoContract defines a governance operation for calling sudo + // on a contract. The authority is defined in the keeper. + // + // Since: 0.40 + rpc SudoContract(MsgSudoContract) returns (MsgSudoContractResponse); + // PinCodes defines a governance operation for pinning a set of + // code ids in the wasmvm cache. The authority is defined in the keeper. + // + // Since: 0.40 + rpc PinCodes(MsgPinCodes) returns (MsgPinCodesResponse); + // UnpinCodes defines a governance operation for unpinning a set of + // code ids in the wasmvm cache. The authority is defined in the keeper. + // + // Since: 0.40 + rpc UnpinCodes(MsgUnpinCodes) returns (MsgUnpinCodesResponse); + // StoreAndInstantiateContract defines a governance operation for storing + // and instantiating the contract. The authority is defined in the keeper. + // + // Since: 0.40 + rpc StoreAndInstantiateContract(MsgStoreAndInstantiateContract) + returns (MsgStoreAndInstantiateContractResponse); } // MsgStoreCode submit Wasm code to the system @@ -214,13 +235,13 @@ message MsgUpdateInstantiateConfig { // MsgUpdateInstantiateConfigResponse returns empty data message MsgUpdateInstantiateConfigResponse {} -// MsgUpdateParams is the Msg/UpdateParams request type. +// MsgUpdateParams is the MsgUpdateParams request type. // // Since: 0.40 message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; - // authority is the address of the governance account. + // Authority is the address of the governance account. string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // params defines the x/wasm parameters to update. @@ -233,4 +254,119 @@ message MsgUpdateParams { // MsgUpdateParams message. // // Since: 0.40 -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgUpdateParamsResponse {} + +// MsgSudoContract is the MsgSudoContract request type. +// +// Since: 0.40 +message MsgSudoContract { + option (cosmos.msg.v1.signer) = "authority"; + + // Authority is the address of the governance account. + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // Contract is the address of the smart contract + string contract = 2; + // Msg json encoded message to be passed to the contract as sudo + bytes msg = 3 [ (gogoproto.casttype) = "RawContractMessage" ]; +} + +// MsgSudoContractResponse defines the response structure for executing a +// MsgSudoContract message. +// +// Since: 0.40 +message MsgSudoContractResponse { + // Data contains bytes to returned from the contract + bytes data = 1; +} + +// MsgPinCodes is the MsgPinCodes request type. +// +// Since: 0.40 +message MsgPinCodes { + option (cosmos.msg.v1.signer) = "authority"; + + // Authority is the address of the governance account. + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // CodeIDs references the new WASM codes + repeated uint64 code_ids = 2 [ + (gogoproto.customname) = "CodeIDs", + (gogoproto.moretags) = "yaml:\"code_ids\"" + ]; +} + +// MsgPinCodesResponse defines the response structure for executing a +// MsgPinCodes message. +// +// Since: 0.40 +message MsgPinCodesResponse {} + +// MsgUnpinCodes is the MsgUnpinCodes request type. +// +// Since: 0.40 +message MsgUnpinCodes { + option (cosmos.msg.v1.signer) = "authority"; + + // Authority is the address of the governance account. + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // CodeIDs references the WASM codes + repeated uint64 code_ids = 2 [ + (gogoproto.customname) = "CodeIDs", + (gogoproto.moretags) = "yaml:\"code_ids\"" + ]; +} + +// MsgUnpinCodesResponse defines the response structure for executing a +// MsgUnpinCodes message. +// +// Since: 0.40 +message MsgUnpinCodesResponse {} + +// MsgStoreAndInstantiateContract is the MsgStoreAndInstantiateContract +// request type. +// +// Since: 0.40 +message MsgStoreAndInstantiateContract { + option (cosmos.msg.v1.signer) = "authority"; + + // Authority is the address of the governance account. + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // WASMByteCode can be raw or gzip compressed + bytes wasm_byte_code = 3 [ (gogoproto.customname) = "WASMByteCode" ]; + // InstantiatePermission to apply on contract creation, optional + AccessConfig instantiate_permission = 4; + // UnpinCode code on upload, optional. As default the uploaded contract is + // pinned to cache. + bool unpin_code = 5; + // Admin is an optional address that can execute migrations + string admin = 6; + // Label is optional metadata to be stored with a constract instance. + string label = 7; + // Msg json encoded message to be passed to the contract on instantiation + bytes msg = 8 [ (gogoproto.casttype) = "RawContractMessage" ]; + // Funds coins that are transferred from the authority account to the contract + // on instantiation + repeated cosmos.base.v1beta1.Coin funds = 9 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + // Source is the URL where the code is hosted + string source = 10; + // Builder is the docker image used to build the code deterministically, used + // for smart contract verification + string builder = 11; + // CodeHash is the SHA256 sum of the code outputted by builder, used for smart + // contract verification + bytes code_hash = 12; +} + +// MsgStoreAndInstantiateContractResponse defines the response structure +// for executing a MsgStoreAndInstantiateContract message. +// +// Since: 0.40 +message MsgStoreAndInstantiateContractResponse { + // Address is the bech32 address of the new contract instance. + string address = 1; + // Data contains bytes to returned from the contract + bytes data = 2; +} \ No newline at end of file diff --git a/x/wasm/alias.go b/x/wasm/alias.go index 83480ab4dd..7b10c4198a 100644 --- a/x/wasm/alias.go +++ b/x/wasm/alias.go @@ -57,7 +57,7 @@ var ( WasmQuerier = keeper.WasmQuerier CreateTestInput = keeper.CreateTestInput TestHandler = keeper.TestHandler - NewWasmProposalHandler = keeper.NewWasmProposalHandler + NewWasmProposalHandler = keeper.NewWasmProposalHandler //nolint:staticcheck NewQuerier = keeper.Querier ContractFromPortID = keeper.ContractFromPortID WithWasmEngine = keeper.WithWasmEngine diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go deleted file mode 100644 index 035d54a1bb..0000000000 --- a/x/wasm/client/cli/gov_tx.go +++ /dev/null @@ -1,821 +0,0 @@ -package cli - -import ( - "bytes" - "crypto/sha256" - "encoding/hex" - "fmt" - "net/url" - "strconv" - "strings" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/version" - "github.com/cosmos/cosmos-sdk/x/gov/client/cli" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/docker/distribution/reference" - "github.com/pkg/errors" - "github.com/spf13/cobra" - flag "github.com/spf13/pflag" - - "github.com/CosmWasm/wasmd/x/wasm/ioutils" - "github.com/CosmWasm/wasmd/x/wasm/types" -) - -func ProposalStoreCodeCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "wasm-store [wasm file] --title [text] --description [text] --run-as [address] --unpin-code [unpin_code] --source [source] --builder [builder] --code-hash [code_hash]", - Short: "Submit a wasm binary proposal", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - 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 - } - - source, builder, codeHash, err := parseVerificationFlags(src.WASMByteCode, cmd.Flags()) - if err != nil { - return err - } - content := types.StoreCodeProposal{ - Title: proposalTitle, - Description: proposalDescr, - RunAs: runAs, - WASMByteCode: src.WASMByteCode, - InstantiatePermission: src.InstantiatePermission, - UnpinCode: unpinCode, - Source: source, - Builder: builder, - CodeHash: codeHash, - } - - msg, err := v1beta1.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(flagRunAs, "", "The address that is stored as code creator") - cmd.Flags().Bool(flagUnpinCode, false, "Unpin code on upload, optional") - cmd.Flags().String(flagSource, "", "Code Source URL is a valid absolute HTTPS URI to the contract's source code,") - cmd.Flags().String(flagBuilder, "", "Builder is a valid docker image name with tag, such as \"cosmwasm/workspace-optimizer:0.12.9\"") - cmd.Flags().BytesHex(flagCodeHash, nil, "CodeHash is the sha256 hash of the wasm code") - addInstantiatePermissionFlags(cmd) - - // proposal flags - addCommonProposalFlags(cmd) - return cmd -} - -func parseVerificationFlags(gzippedWasm []byte, flags *flag.FlagSet) (string, string, []byte, error) { - source, err := flags.GetString(flagSource) - if err != nil { - return "", "", nil, fmt.Errorf("source: %s", err) - } - builder, err := flags.GetString(flagBuilder) - if err != nil { - return "", "", nil, fmt.Errorf("builder: %s", err) - } - codeHash, err := flags.GetBytesHex(flagCodeHash) - if err != nil { - return "", "", nil, fmt.Errorf("codeHash: %s", err) - } - - // if any set require others to be set - if len(source) != 0 || len(builder) != 0 || len(codeHash) != 0 { - if source == "" { - return "", "", nil, fmt.Errorf("source is required") - } - if _, err = url.ParseRequestURI(source); err != nil { - return "", "", nil, fmt.Errorf("source: %s", err) - } - if builder == "" { - return "", "", nil, fmt.Errorf("builder is required") - } - if _, err := reference.ParseDockerRef(builder); err != nil { - return "", "", nil, fmt.Errorf("builder: %s", err) - } - if len(codeHash) == 0 { - return "", "", nil, fmt.Errorf("code hash is required") - } - // wasm is gzipped in parseStoreCodeArgs - // checksum generation will be decoupled here - // reference https://github.com/CosmWasm/wasmvm/issues/359 - raw, err := ioutils.Uncompress(gzippedWasm, uint64(types.MaxWasmSize)) - if err != nil { - return "", "", nil, fmt.Errorf("invalid zip: %w", err) - } - checksum := sha256.Sum256(raw) - if !bytes.Equal(checksum[:], codeHash) { - return "", "", nil, fmt.Errorf("code-hash mismatch: %X, checksum: %X", codeHash, checksum) - } - } - return source, builder, codeHash, nil -} - -func ProposalInstantiateContractCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "instantiate-contract [code_id_int64] [json_encoded_init_args] --label [text] --title [text] --description [text] --run-as [address] --admin [address,optional] --amount [coins,optional]", - Short: "Submit an instantiate wasm contract proposal", - Args: cobra.ExactArgs(2), - 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.Keyring, 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") - } - - content := types.InstantiateContractProposal{ - Title: proposalTitle, - Description: proposalDescr, - RunAs: runAs, - Admin: src.Admin, - CodeID: src.CodeID, - Label: src.Label, - Msg: src.Msg, - Funds: src.Funds, - } - - msg, err := v1beta1.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 or key name 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") - - // proposal flags - addCommonProposalFlags(cmd) - 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.Keyring, 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 := v1beta1.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 - addCommonProposalFlags(cmd) - 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]" + - "--unpin-code [unpin_code,optional] --source [source,optional] --builder [builder,optional] --code-hash [code_hash,optional] --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, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - 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 - } - - source, builder, codeHash, err := parseVerificationFlags(src.WASMByteCode, cmd.Flags()) - if err != nil { - return err - } - - 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("admin: %s", err) - } - noAdmin, err := cmd.Flags().GetBool(flagNoAdmin) - if err != nil { - 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") - } - - if adminStr != "" { - addr, err := sdk.AccAddressFromBech32(adminStr) - if err != nil { - info, err := clientCtx.Keyring.Key(adminStr) - if err != nil { - return fmt.Errorf("admin %s", err) - } - admin, err := info.GetAddress() - if err != nil { - return err - } - adminStr = admin.String() - } else { - adminStr = addr.String() - } - } - - content := types.StoreAndInstantiateContractProposal{ - Title: proposalTitle, - Description: proposalDescr, - RunAs: runAs, - WASMByteCode: src.WASMByteCode, - InstantiatePermission: src.InstantiatePermission, - UnpinCode: unpinCode, - Source: source, - Builder: builder, - CodeHash: codeHash, - Admin: adminStr, - Label: label, - Msg: []byte(args[1]), - Funds: amount, - } - - msg, err := v1beta1.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(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().Bool(flagUnpinCode, false, "Unpin code on upload, optional") - cmd.Flags().String(flagSource, "", "Code Source URL is a valid absolute HTTPS URI to the contract's source code,") - cmd.Flags().String(flagBuilder, "", "Builder is a valid docker image name with tag, such as \"cosmwasm/workspace-optimizer:0.12.9\"") - cmd.Flags().BytesHex(flagCodeHash, nil, "CodeHash is the sha256 hash of the wasm code") - 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 or key name of an admin") - cmd.Flags().Bool(flagNoAdmin, false, "You must set this explicitly if you don't want an admin") - addInstantiatePermissionFlags(cmd) - // proposal flags - addCommonProposalFlags(cmd) - 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 - } - - src, err := parseMigrateContractArgs(args, clientCtx) - if err != nil { - return err - } - - content := types.MigrateContractProposal{ - Title: proposalTitle, - Description: proposalDescr, - Contract: src.Contract, - CodeID: src.CodeID, - Msg: src.Msg, - } - - msg, err := v1beta1.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, - } - - // proposal flags - addCommonProposalFlags(cmd) - return cmd -} - -func ProposalExecuteContractCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "execute-contract [contract_addr_bech32] [json_encoded_migration_args]", - Short: "Submit a execute wasm contract proposal (run by any address)", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - contract := args[0] - execMsg := []byte(args[1]) - amountStr, err := cmd.Flags().GetString(flagAmount) - if err != nil { - return fmt.Errorf("amount: %s", err) - } - funds, err := sdk.ParseCoinsNormalized(amountStr) - if err != nil { - return fmt.Errorf("amount: %s", 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") - } - - content := types.ExecuteContractProposal{ - Title: proposalTitle, - Description: proposalDescr, - Contract: contract, - Msg: execMsg, - RunAs: runAs, - Funds: funds, - } - - msg, err := v1beta1.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(flagRunAs, "", "The address that is passed as sender to the contract on proposal execution") - cmd.Flags().String(flagAmount, "", "Coins to send to the contract during instantiation") - - // proposal flags - addCommonProposalFlags(cmd) - return cmd -} - -func ProposalSudoContractCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "sudo-contract [contract_addr_bech32] [json_encoded_migration_args]", - Short: "Submit a sudo wasm contract proposal (to call privileged commands)", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - contract := args[0] - sudoMsg := []byte(args[1]) - - content := types.SudoContractProposal{ - Title: proposalTitle, - Description: proposalDescr, - Contract: contract, - Msg: sudoMsg, - } - - msg, err := v1beta1.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, - } - - // proposal flagsExecute - addCommonProposalFlags(cmd) - return cmd -} - -func ProposalUpdateContractAdminCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "set-contract-admin [contract_addr_bech32] [new_admin_addr_bech32]", - Short: "Submit a new admin for a contract proposal", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - src := parseUpdateContractAdminArgs(args, clientCtx) - - content := types.UpdateAdminProposal{ - Title: proposalTitle, - Description: proposalDescr, - Contract: src.Contract, - NewAdmin: src.NewAdmin, - } - - msg, err := v1beta1.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, - } - // proposal flags - addCommonProposalFlags(cmd) - return cmd -} - -func ProposalClearContractAdminCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "clear-contract-admin [contract_addr_bech32]", - 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, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - content := types.ClearAdminProposal{ - Title: proposalTitle, - Description: proposalDescr, - Contract: args[0], - } - - msg, err := v1beta1.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, - } - // proposal flags - addCommonProposalFlags(cmd) - return cmd -} - -func ProposalPinCodesCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "pin-codes [code-ids]", - 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, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - codeIds, err := parsePinCodesArgs(args) - if err != nil { - return err - } - - content := types.PinCodesProposal{ - Title: proposalTitle, - Description: proposalDescr, - CodeIDs: codeIds, - } - - msg, err := v1beta1.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, - } - // proposal flags - addCommonProposalFlags(cmd) - return cmd -} - -func parsePinCodesArgs(args []string) ([]uint64, error) { - codeIDs := make([]uint64, len(args)) - for i, c := range args { - codeID, err := strconv.ParseUint(c, 10, 64) - if err != nil { - return codeIDs, fmt.Errorf("code IDs: %s", err) - } - codeIDs[i] = codeID - } - return codeIDs, nil -} - -func ProposalUnpinCodesCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "unpin-codes [code-ids]", - 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, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - - codeIds, err := parsePinCodesArgs(args) - if err != nil { - return err - } - - content := types.UnpinCodesProposal{ - Title: proposalTitle, - Description: proposalDescr, - CodeIDs: codeIds, - } - - msg, err := v1beta1.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, - } - // proposal flags - addCommonProposalFlags(cmd) - return cmd -} - -func parseAccessConfig(raw string) (c types.AccessConfig, err error) { - switch raw { - case "nobody": - return types.AllowNobody, nil - case "everybody": - return types.AllowEverybody, nil - default: - parts := strings.Split(raw, ",") - addrs := make([]sdk.AccAddress, len(parts)) - for i, v := range parts { - addr, err := sdk.AccAddressFromBech32(v) - if err != nil { - return types.AccessConfig{}, fmt.Errorf("unable to parse address %q: %s", v, err) - } - addrs[i] = addr - } - defer func() { // convert panic in ".With" to error for better output - if r := recover(); r != nil { - err = r.(error) - } - }() - cfg := types.AccessTypeAnyOfAddresses.With(addrs...) - return cfg, cfg.ValidateBasic() - } -} - -func parseAccessConfigUpdates(args []string) ([]types.AccessConfigUpdate, error) { - updates := make([]types.AccessConfigUpdate, len(args)) - for i, c := range args { - // format: code_id:access_config - // access_config: nobody|everybody|address(es) - parts := strings.Split(c, ":") - if len(parts) != 2 { - return nil, fmt.Errorf("invalid format") - } - - codeID, err := strconv.ParseUint(parts[0], 10, 64) - if err != nil { - return nil, fmt.Errorf("invalid code ID: %s", err) - } - - accessConfig, err := parseAccessConfig(parts[1]) - if err != nil { - return nil, err - } - updates[i] = types.AccessConfigUpdate{ - CodeID: codeID, - InstantiatePermission: accessConfig, - } - } - return updates, nil -} - -func ProposalUpdateInstantiateConfigCmd() *cobra.Command { - bech32Prefix := sdk.GetConfig().GetBech32AccountAddrPrefix() - cmd := &cobra.Command{ - Use: "update-instantiate-config [code-id:permission]...", - Short: "Submit an update instantiate config proposal.", - Args: cobra.MinimumNArgs(1), - Long: strings.TrimSpace( - fmt.Sprintf(`Submit an update instantiate config proposal for multiple code ids. - -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, proposalTitle, proposalDescr, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - updates, err := parseAccessConfigUpdates(args) - if err != nil { - return err - } - - content := types.UpdateInstantiateConfigProposal{ - Title: proposalTitle, - Description: proposalDescr, - AccessConfigUpdates: updates, - } - msg, err := v1beta1.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, - } - // proposal flags - addCommonProposalFlags(cmd) - return cmd -} - -func addCommonProposalFlags(cmd *cobra.Command) { - cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") //nolint:staticcheck - cmd.Flags().String(cli.FlagDescription, "", "Description of proposal") //nolint:staticcheck - cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") -} - -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) //nolint:staticcheck - if err != nil { - return clientCtx, proposalTitle, "", nil, err - } - - proposalDescr, err := cmd.Flags().GetString(cli.FlagDescription) //nolint:staticcheck - 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/cli/gov_tx_test.go b/x/wasm/client/cli/gov_tx_test.go deleted file mode 100644 index bc498f0fbe..0000000000 --- a/x/wasm/client/cli/gov_tx_test.go +++ /dev/null @@ -1,158 +0,0 @@ -package cli - -import ( - "os" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/CosmWasm/wasmd/x/wasm/types" -) - -func TestParseAccessConfigUpdates(t *testing.T) { - specs := map[string]struct { - src []string - exp []types.AccessConfigUpdate - expErr bool - }{ - "nobody": { - src: []string{"1:nobody"}, - exp: []types.AccessConfigUpdate{{ - CodeID: 1, - InstantiatePermission: types.AccessConfig{Permission: types.AccessTypeNobody}, - }}, - }, - "everybody": { - src: []string{"1:everybody"}, - exp: []types.AccessConfigUpdate{{ - CodeID: 1, - InstantiatePermission: types.AccessConfig{Permission: types.AccessTypeEverybody}, - }}, - }, - "any of addresses - single": { - src: []string{"1:cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x"}, - exp: []types.AccessConfigUpdate{ - { - CodeID: 1, - InstantiatePermission: types.AccessConfig{ - Permission: types.AccessTypeAnyOfAddresses, - Addresses: []string{"cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x"}, - }, - }, - }, - }, - "any of addresses - multiple": { - src: []string{"1:cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x,cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr"}, - exp: []types.AccessConfigUpdate{ - { - CodeID: 1, - InstantiatePermission: types.AccessConfig{ - Permission: types.AccessTypeAnyOfAddresses, - Addresses: []string{"cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x", "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr"}, - }, - }, - }, - }, - "multiple code ids with different permissions": { - src: []string{"1:cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x,cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", "2:nobody"}, - exp: []types.AccessConfigUpdate{ - { - CodeID: 1, - InstantiatePermission: types.AccessConfig{ - Permission: types.AccessTypeAnyOfAddresses, - Addresses: []string{"cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x", "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr"}, - }, - }, { - CodeID: 2, - InstantiatePermission: types.AccessConfig{ - Permission: types.AccessTypeNobody, - }, - }, - }, - }, - "any of addresses - empty list": { - src: []string{"1:"}, - expErr: true, - }, - "any of addresses - invalid address": { - src: []string{"1:foo"}, - expErr: true, - }, - "any of addresses - duplicate address": { - src: []string{"1:cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x,cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x"}, - expErr: true, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - got, gotErr := parseAccessConfigUpdates(spec.src) - if spec.expErr { - require.Error(t, gotErr) - return - } - require.NoError(t, gotErr) - assert.Equal(t, spec.exp, got) - }) - } -} - -func TestParseCodeInfoFlags(t *testing.T) { - correctSource := "https://github.com/CosmWasm/wasmd/blob/main/x/wasm/keeper/testdata/hackatom.wasm" - correctBuilderRef := "cosmwasm/workspace-optimizer:0.12.9" - - wasmBin, err := os.ReadFile("../../keeper/testdata/hackatom.wasm.gzip") - require.NoError(t, err) - - checksumStr := "beb3de5e9b93b52e514c74ce87ccddb594b9bcd33b7f1af1bb6da63fc883917b" - - specs := map[string]struct { - args []string - expErr bool - }{ - "source missing": { - args: []string{"--builder=" + correctBuilderRef, "--code-hash=" + checksumStr}, - expErr: true, - }, - "builder missing": { - args: []string{"--code-source-url=" + correctSource, "--code-hash=" + checksumStr}, - expErr: true, - }, - "code hash missing": { - args: []string{"--code-source-url=" + correctSource, "--builder=" + correctBuilderRef}, - expErr: true, - }, - "source format wrong": { - args: []string{"--code-source-url=" + "format_wrong", "--builder=" + correctBuilderRef, "--code-hash=" + checksumStr}, - expErr: true, - }, - "builder format wrong": { - args: []string{"--code-source-url=" + correctSource, "--builder=" + "format//", "--code-hash=" + checksumStr}, - expErr: true, - }, - "code hash wrong": { - args: []string{"--code-source-url=" + correctSource, "--builder=" + correctBuilderRef, "--code-hash=" + "AA"}, - expErr: true, - }, - "happy path, none set": { - args: []string{}, - expErr: false, - }, - "happy path all set": { - args: []string{"--code-source-url=" + correctSource, "--builder=" + correctBuilderRef, "--code-hash=" + checksumStr}, - expErr: false, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - flags := ProposalStoreCodeCmd().Flags() - require.NoError(t, flags.Parse(spec.args)) - _, _, _, gotErr := parseVerificationFlags(wasmBin, flags) - if spec.expErr { - require.Error(t, gotErr) - return - } - require.NoError(t, gotErr) - }) - } -} diff --git a/x/wasm/client/cli/new_tx.go b/x/wasm/client/cli/new_tx.go index a3d61466ac..39562248c8 100644 --- a/x/wasm/client/cli/new_tx.go +++ b/x/wasm/client/cli/new_tx.go @@ -25,7 +25,7 @@ func MigrateContractCmd() *cobra.Command { return err } - msg, err := parseMigrateContractArgs(args, clientCtx) + msg, err := parseMigrateContractArgs(args, clientCtx.GetFromAddress().String()) if err != nil { return err } @@ -40,7 +40,7 @@ func MigrateContractCmd() *cobra.Command { return cmd } -func parseMigrateContractArgs(args []string, cliCtx client.Context) (types.MsgMigrateContract, error) { +func parseMigrateContractArgs(args []string, sender string) (types.MsgMigrateContract, error) { // get the id of the code to instantiate codeID, err := strconv.ParseUint(args[1], 10, 64) if err != nil { @@ -50,7 +50,7 @@ func parseMigrateContractArgs(args []string, cliCtx client.Context) (types.MsgMi migrateMsg := args[2] msg := types.MsgMigrateContract{ - Sender: cliCtx.GetFromAddress().String(), + Sender: sender, Contract: args[0], CodeID: codeID, Msg: []byte(migrateMsg), @@ -71,8 +71,7 @@ func UpdateContractAdminCmd() *cobra.Command { return err } - msg := parseUpdateContractAdminArgs(args, clientCtx) - + msg := parseUpdateContractAdminArgs(args, clientCtx.GetFromAddress().String()) if err := msg.ValidateBasic(); err != nil { return err } @@ -84,9 +83,9 @@ func UpdateContractAdminCmd() *cobra.Command { return cmd } -func parseUpdateContractAdminArgs(args []string, cliCtx client.Context) types.MsgUpdateAdmin { +func parseUpdateContractAdminArgs(args []string, sender string) types.MsgUpdateAdmin { msg := types.MsgUpdateAdmin{ - Sender: cliCtx.GetFromAddress().String(), + Sender: sender, Contract: args[0], NewAdmin: args[1], } diff --git a/x/wasm/client/cli/tx.go b/x/wasm/client/cli/tx.go index 788cde4e84..04c229701b 100644 --- a/x/wasm/client/cli/tx.go +++ b/x/wasm/client/cli/tx.go @@ -82,7 +82,7 @@ func StoreCodeCmd() *cobra.Command { if err != nil { return err } - msg, err := parseStoreCodeArgs(args[0], clientCtx.GetFromAddress(), cmd.Flags()) + msg, err := parseStoreCodeArgs(args[0], clientCtx.GetFromAddress().String(), cmd.Flags()) if err != nil { return err } @@ -100,7 +100,7 @@ func StoreCodeCmd() *cobra.Command { } // Prepares MsgStoreCode object from flags with gzipped wasm byte code field -func parseStoreCodeArgs(file string, sender sdk.AccAddress, flags *flag.FlagSet) (types.MsgStoreCode, error) { +func parseStoreCodeArgs(file string, sender string, flags *flag.FlagSet) (types.MsgStoreCode, error) { wasm, err := os.ReadFile(file) if err != nil { return types.MsgStoreCode{}, err @@ -123,7 +123,7 @@ func parseStoreCodeArgs(file string, sender sdk.AccAddress, flags *flag.FlagSet) } msg := types.MsgStoreCode{ - Sender: sender.String(), + Sender: sender, WASMByteCode: wasm, InstantiatePermission: perm, } @@ -209,7 +209,7 @@ $ %s tx wasm instantiate 1 '{"foo":"bar"}' --admin="$(%s keys show mykey -a)" \ if err != nil { return err } - msg, err := parseInstantiateArgs(args[0], args[1], clientCtx.Keyring, clientCtx.GetFromAddress(), cmd.Flags()) + msg, err := parseInstantiateArgs(args[0], args[1], clientCtx.Keyring, clientCtx.GetFromAddress().String(), cmd.Flags()) if err != nil { return err } @@ -260,7 +260,7 @@ $ %s tx wasm instantiate2 1 '{"foo":"bar"}' $(echo -n "testing" | xxd -ps) --adm if err != nil { return fmt.Errorf("fix msg: %w", err) } - data, err := parseInstantiateArgs(args[0], args[1], clientCtx.Keyring, clientCtx.GetFromAddress(), cmd.Flags()) + data, err := parseInstantiateArgs(args[0], args[1], clientCtx.Keyring, clientCtx.GetFromAddress().String(), cmd.Flags()) if err != nil { return err } @@ -292,7 +292,7 @@ $ %s tx wasm instantiate2 1 '{"foo":"bar"}' $(echo -n "testing" | xxd -ps) --adm return cmd } -func parseInstantiateArgs(rawCodeID, initMsg string, kr keyring.Keyring, sender sdk.AccAddress, flags *flag.FlagSet) (*types.MsgInstantiateContract, error) { +func parseInstantiateArgs(rawCodeID, initMsg string, kr keyring.Keyring, sender string, flags *flag.FlagSet) (*types.MsgInstantiateContract, error) { // get the id of the code to instantiate codeID, err := strconv.ParseUint(rawCodeID, 10, 64) if err != nil { @@ -351,7 +351,7 @@ func parseInstantiateArgs(rawCodeID, initMsg string, kr keyring.Keyring, sender // build and sign the transaction, then broadcast to Tendermint msg := types.MsgInstantiateContract{ - Sender: sender.String(), + Sender: sender, CodeID: codeID, Label: label, Funds: amount, diff --git a/x/wasm/client/cli/tx_test.go b/x/wasm/client/cli/tx_test.go index 8d6dfcf840..888df2b51f 100644 --- a/x/wasm/client/cli/tx_test.go +++ b/x/wasm/client/cli/tx_test.go @@ -1,14 +1,11 @@ package cli import ( - "encoding/hex" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/CosmWasm/wasmd/x/wasm/ioutils" "github.com/CosmWasm/wasmd/x/wasm/types" ) @@ -60,65 +57,3 @@ func TestParseAccessConfigFlags(t *testing.T) { }) } } - -func TestParseVerificationFlags(t *testing.T) { - mySender := sdk.MustAccAddressFromBech32("cosmos1wyqh3n50ecatjg4vww5crmtd0nmyzusnwckw4at4gluc0m5m477q4arfek") - - specs := map[string]struct { - srcPath string - args []string - expErr bool - expSource string - expBuilder string - expCodeHash string - }{ - "gov store zipped": { - srcPath: "../../keeper/testdata/hackatom.wasm.gzip", - args: []string{ - "--instantiate-everybody=true", "--code-hash=beb3de5e9b93b52e514c74ce87ccddb594b9bcd33b7f1af1bb6da63fc883917b", - "--code-source-url=https://example.com", "--builder=cosmwasm/workspace-optimizer:0.12.11", - }, - expBuilder: "cosmwasm/workspace-optimizer:0.12.11", - expSource: "https://example.com", - expCodeHash: "beb3de5e9b93b52e514c74ce87ccddb594b9bcd33b7f1af1bb6da63fc883917b", - }, - "gov store raw": { - srcPath: "../../keeper/testdata/hackatom.wasm", - args: []string{ - "--instantiate-everybody=true", "--code-hash=beb3de5e9b93b52e514c74ce87ccddb594b9bcd33b7f1af1bb6da63fc883917b", - "--code-source-url=https://example.com", "--builder=cosmwasm/workspace-optimizer:0.12.11", - }, - expBuilder: "cosmwasm/workspace-optimizer:0.12.11", - expSource: "https://example.com", - expCodeHash: "beb3de5e9b93b52e514c74ce87ccddb594b9bcd33b7f1af1bb6da63fc883917b", - }, - "gov store checksum mismatch": { - srcPath: "../../keeper/testdata/hackatom.wasm", - args: []string{ - "--instantiate-everybody=true", "--code-hash=0000de5e9b93b52e514c74ce87ccddb594b9bcd33b7f1af1bb6da63fc883917b", - "--code-source-url=https://example.com", "--builder=cosmwasm/workspace-optimizer:0.12.11", - }, - expErr: true, - }, - } - for name, spec := range specs { - t.Run(name, func(t *testing.T) { - flagSet := ProposalStoreCodeCmd().Flags() - require.NoError(t, flagSet.Parse(spec.args)) - - gotMsg, err := parseStoreCodeArgs(spec.srcPath, mySender, flagSet) - require.NoError(t, err) - require.True(t, ioutils.IsGzip(gotMsg.WASMByteCode)) - - gotSource, gotBuilder, gotCodeHash, gotErr := parseVerificationFlags(gotMsg.WASMByteCode, flagSet) - if spec.expErr { - require.Error(t, gotErr) - return - } - require.NoError(t, gotErr) - assert.Equal(t, spec.expSource, gotSource) - assert.Equal(t, spec.expBuilder, gotBuilder) - assert.Equal(t, spec.expCodeHash, hex.EncodeToString(gotCodeHash)) - }) - } -} diff --git a/x/wasm/client/proposal_handler.go b/x/wasm/client/proposal_handler.go deleted file mode 100644 index deba8070ca..0000000000 --- a/x/wasm/client/proposal_handler.go +++ /dev/null @@ -1,23 +0,0 @@ -package client - -import ( - govclient "github.com/cosmos/cosmos-sdk/x/gov/client" - - "github.com/CosmWasm/wasmd/x/wasm/client/cli" -) - -// ProposalHandlers define the wasm cli proposal types and rest handler. -var ProposalHandlers = []govclient.ProposalHandler{ - govclient.NewProposalHandler(cli.ProposalStoreCodeCmd), - govclient.NewProposalHandler(cli.ProposalInstantiateContractCmd), - govclient.NewProposalHandler(cli.ProposalMigrateContractCmd), - govclient.NewProposalHandler(cli.ProposalExecuteContractCmd), - govclient.NewProposalHandler(cli.ProposalSudoContractCmd), - govclient.NewProposalHandler(cli.ProposalUpdateContractAdminCmd), - govclient.NewProposalHandler(cli.ProposalClearContractAdminCmd), - govclient.NewProposalHandler(cli.ProposalPinCodesCmd), - govclient.NewProposalHandler(cli.ProposalUnpinCodesCmd), - govclient.NewProposalHandler(cli.ProposalUpdateInstantiateConfigCmd), - govclient.NewProposalHandler(cli.ProposalStoreAndInstantiateContractCmd), - govclient.NewProposalHandler(cli.ProposalInstantiateContract2Cmd), -} diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index 91413b2e2a..b9addff343 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -751,7 +751,7 @@ func TestInstantiateWithContractFactoryChildQueriesParent(t *testing.T) { // overwrite wasmvm in router router := baseapp.NewMsgServiceRouter() router.SetInterfaceRegistry(keepers.EncodingConfig.InterfaceRegistry) - types.RegisterMsgServer(router, newMsgServerImpl(NewDefaultPermissionKeeper(keeper), *keeper)) + types.RegisterMsgServer(router, NewMsgServerImpl(keeper)) keeper.messenger = NewDefaultMessageHandler(router, nil, nil, nil, keepers.EncodingConfig.Marshaler, nil) // overwrite wasmvm in response handler keeper.wasmVMResponseHandler = NewDefaultWasmVMContractResponseHandler(NewMessageDispatcher(keeper.messenger, keeper)) diff --git a/x/wasm/keeper/msg_server.go b/x/wasm/keeper/msg_server.go index bfc3e8b445..3c5c3e72e8 100644 --- a/x/wasm/keeper/msg_server.go +++ b/x/wasm/keeper/msg_server.go @@ -11,26 +11,14 @@ import ( var _ types.MsgServer = msgServer{} -// abstract type -type paramStore interface { - GetAuthority() string - SetParams(ctx sdk.Context, params types.Params) error -} - // grpc message server implementation type msgServer struct { - keeper types.ContractOpsKeeper - paramStore paramStore + keeper *Keeper } // NewMsgServerImpl default constructor func NewMsgServerImpl(k *Keeper) types.MsgServer { - return newMsgServerImpl(NewDefaultPermissionKeeper(k), k) -} - -// newMsgServerImpl internal constructor to overwrite interfaces for testing -func newMsgServerImpl(k types.ContractOpsKeeper, p paramStore) types.MsgServer { - return &msgServer{keeper: k, paramStore: p} + return &msgServer{keeper: k} } // StoreCode stores a new wasm code on chain @@ -44,7 +32,9 @@ func (m msgServer) StoreCode(goCtx context.Context, msg *types.MsgStoreCode) (*t return nil, errorsmod.Wrap(err, "sender") } - codeID, checksum, err := m.keeper.Create(ctx, senderAddr, msg.WASMByteCode, msg.InstantiatePermission) + policy := m.selectAuthorizationPolicy(msg.Sender) + + codeID, checksum, err := m.keeper.create(ctx, senderAddr, msg.WASMByteCode, msg.InstantiatePermission, policy) if err != nil { return nil, err } @@ -73,7 +63,9 @@ func (m msgServer) InstantiateContract(goCtx context.Context, msg *types.MsgInst } } - contractAddr, data, err := m.keeper.Instantiate(ctx, msg.CodeID, senderAddr, adminAddr, msg.Msg, msg.Label, msg.Funds) + policy := m.selectAuthorizationPolicy(msg.Sender) + + contractAddr, data, err := m.keeper.instantiate(ctx, msg.CodeID, senderAddr, adminAddr, msg.Msg, msg.Label, msg.Funds, m.keeper.ClassicAddressGenerator(), policy) if err != nil { return nil, err } @@ -102,7 +94,11 @@ func (m msgServer) InstantiateContract2(goCtx context.Context, msg *types.MsgIns } } - contractAddr, data, err := m.keeper.Instantiate2(ctx, msg.CodeID, senderAddr, adminAddr, msg.Msg, msg.Label, msg.Funds, msg.Salt, msg.FixMsg) + policy := m.selectAuthorizationPolicy(msg.Sender) + + addrGenerator := PredicableAddressGenerator(senderAddr, msg.Salt, msg.Msg, msg.FixMsg) + + contractAddr, data, err := m.keeper.instantiate(ctx, msg.CodeID, senderAddr, adminAddr, msg.Msg, msg.Label, msg.Funds, addrGenerator, policy) if err != nil { return nil, err } @@ -128,7 +124,7 @@ func (m msgServer) ExecuteContract(goCtx context.Context, msg *types.MsgExecuteC return nil, errorsmod.Wrap(err, "contract") } - data, err := m.keeper.Execute(ctx, contractAddr, senderAddr, msg.Msg, msg.Funds) + data, err := m.keeper.execute(ctx, contractAddr, senderAddr, msg.Msg, msg.Funds) if err != nil { return nil, err } @@ -153,7 +149,9 @@ func (m msgServer) MigrateContract(goCtx context.Context, msg *types.MsgMigrateC return nil, errorsmod.Wrap(err, "contract") } - data, err := m.keeper.Migrate(ctx, contractAddr, senderAddr, msg.CodeID, msg.Msg) + policy := m.selectAuthorizationPolicy(msg.Sender) + + data, err := m.keeper.migrate(ctx, contractAddr, senderAddr, msg.CodeID, msg.Msg, policy) if err != nil { return nil, err } @@ -182,7 +180,9 @@ func (m msgServer) UpdateAdmin(goCtx context.Context, msg *types.MsgUpdateAdmin) return nil, errorsmod.Wrap(err, "new admin") } - if err := m.keeper.UpdateContractAdmin(ctx, contractAddr, senderAddr, newAdminAddr); err != nil { + policy := m.selectAuthorizationPolicy(msg.Sender) + + if err := m.keeper.setContractAdmin(ctx, contractAddr, senderAddr, newAdminAddr, policy); err != nil { return nil, err } @@ -204,7 +204,9 @@ func (m msgServer) ClearAdmin(goCtx context.Context, msg *types.MsgClearAdmin) ( return nil, errorsmod.Wrap(err, "contract") } - if err := m.keeper.ClearContractAdmin(ctx, contractAddr, senderAddr); err != nil { + policy := m.selectAuthorizationPolicy(msg.Sender) + + if err := m.keeper.setContractAdmin(ctx, contractAddr, senderAddr, nil, policy); err != nil { return nil, err } @@ -217,7 +219,13 @@ func (m msgServer) UpdateInstantiateConfig(goCtx context.Context, msg *types.Msg } ctx := sdk.UnwrapSDKContext(goCtx) - if err := m.keeper.SetAccessConfig(ctx, msg.CodeID, sdk.AccAddress(msg.Sender), *msg.NewInstantiatePermission); err != nil { + senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, errorsmod.Wrap(err, "sender") + } + policy := m.selectAuthorizationPolicy(msg.Sender) + + if err := m.keeper.setAccessConfig(ctx, msg.CodeID, senderAddr, *msg.NewInstantiatePermission, policy); err != nil { return nil, err } @@ -226,15 +234,132 @@ func (m msgServer) UpdateInstantiateConfig(goCtx context.Context, msg *types.Msg // UpdateParams updates the module parameters func (m msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - authority := m.paramStore.GetAuthority() + if err := req.ValidateBasic(); err != nil { + return nil, err + } + authority := m.keeper.GetAuthority() if authority != req.Authority { return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid authority; expected %s, got %s", authority, req.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) - if err := m.paramStore.SetParams(ctx, req.Params); err != nil { + if err := m.keeper.SetParams(ctx, req.Params); err != nil { return nil, err } return &types.MsgUpdateParamsResponse{}, nil } + +// PinCodes pins a set of code ids in the wasmvm cache. +func (m msgServer) PinCodes(goCtx context.Context, req *types.MsgPinCodes) (*types.MsgPinCodesResponse, error) { + if err := req.ValidateBasic(); err != nil { + return nil, err + } + + authority := m.keeper.GetAuthority() + if authority != req.Authority { + return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid authority; expected %s, got %s", authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + for _, codeID := range req.CodeIDs { + if err := m.keeper.pinCode(ctx, codeID); err != nil { + return nil, err + } + } + + return &types.MsgPinCodesResponse{}, nil +} + +// UnpinCodes unpins a set of code ids in the wasmvm cache. +func (m msgServer) UnpinCodes(goCtx context.Context, req *types.MsgUnpinCodes) (*types.MsgUnpinCodesResponse, error) { + if err := req.ValidateBasic(); err != nil { + return nil, err + } + + authority := m.keeper.GetAuthority() + if authority != req.Authority { + return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid authority; expected %s, got %s", authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + for _, codeID := range req.CodeIDs { + if err := m.keeper.unpinCode(ctx, codeID); err != nil { + return nil, err + } + } + + return &types.MsgUnpinCodesResponse{}, nil +} + +// SudoContract calls sudo on a contract. +func (m msgServer) SudoContract(goCtx context.Context, req *types.MsgSudoContract) (*types.MsgSudoContractResponse, error) { + if err := req.ValidateBasic(); err != nil { + return nil, err + } + authority := m.keeper.GetAuthority() + if authority != req.Authority { + return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid authority; expected %s, got %s", authority, req.Authority) + } + + contractAddr, err := sdk.AccAddressFromBech32(req.Contract) + if err != nil { + return nil, errorsmod.Wrap(err, "contract") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + data, err := m.keeper.Sudo(ctx, contractAddr, req.Msg) + if err != nil { + return nil, err + } + + return &types.MsgSudoContractResponse{Data: data}, nil +} + +// StoreAndInstantiateContract stores and instantiates the contract. +func (m msgServer) StoreAndInstantiateContract(goCtx context.Context, req *types.MsgStoreAndInstantiateContract) (*types.MsgStoreAndInstantiateContractResponse, error) { + if err := req.ValidateBasic(); err != nil { + return nil, err + } + + authorityAddr, err := sdk.AccAddressFromBech32(req.Authority) + if err != nil { + return nil, errorsmod.Wrap(err, "authority") + } + + if err = req.ValidateBasic(); err != nil { + return nil, err + } + + var adminAddr sdk.AccAddress + if req.Admin != "" { + if adminAddr, err = sdk.AccAddressFromBech32(req.Admin); err != nil { + return nil, errorsmod.Wrap(err, "admin") + } + } + + ctx := sdk.UnwrapSDKContext(goCtx) + policy := m.selectAuthorizationPolicy(req.Authority) + + codeID, _, err := m.keeper.create(ctx, authorityAddr, req.WASMByteCode, req.InstantiatePermission, policy) + if err != nil { + return nil, err + } + + contractAddr, data, err := m.keeper.instantiate(ctx, codeID, authorityAddr, adminAddr, req.Msg, req.Label, req.Funds, m.keeper.ClassicAddressGenerator(), policy) + if err != nil { + return nil, err + } + + return &types.MsgStoreAndInstantiateContractResponse{ + Address: contractAddr.String(), + Data: data, + }, nil +} + +func (m msgServer) selectAuthorizationPolicy(actor string) AuthorizationPolicy { + if actor == m.keeper.GetAuthority() { + return GovAuthorizationPolicy{} + } + return DefaultAuthorizationPolicy{} +} diff --git a/x/wasm/keeper/msg_server_integration_test.go b/x/wasm/keeper/msg_server_integration_test.go index ea426646cb..d176c77e65 100644 --- a/x/wasm/keeper/msg_server_integration_test.go +++ b/x/wasm/keeper/msg_server_integration_test.go @@ -3,23 +3,28 @@ package keeper_test import ( "crypto/sha256" _ "embed" + "encoding/json" "testing" + "time" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/CosmWasm/wasmd/app" + "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/CosmWasm/wasmd/x/wasm/types" ) //go:embed testdata/reflect.wasm var wasmContract []byte +//go:embed testdata/hackatom.wasm +var hackatomContract []byte + func TestStoreCode(t *testing.T) { wasmApp := app.Setup(t) ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{}) @@ -54,7 +59,7 @@ func TestUpdateParams(t *testing.T) { var ( myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) oneAddressAccessConfig = types.AccessTypeOnlyAddress.With(myAddress) - govAuthority = wasmApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName).String() + govAuthority = wasmApp.WasmKeeper.GetAuthority() ) specs := map[string]struct { @@ -118,8 +123,8 @@ func TestUpdateParams(t *testing.T) { expInstantiateType: types.AccessTypeEverybody, }, } - for msg, spec := range specs { - t.Run(msg, func(t *testing.T) { + for name, spec := range specs { + t.Run(name, func(t *testing.T) { err := wasmApp.WasmKeeper.SetParams(ctx, types.DefaultParams()) require.NoError(t, err) @@ -136,3 +141,717 @@ func TestUpdateParams(t *testing.T) { }) } } + +func TestPinCodes(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{}) + + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + ) + + specs := map[string]struct { + addr string + expErr bool + }{ + "authority can pin codes": { + addr: authority, + expErr: false, + }, + "other address cannot pin codes": { + addr: myAddress.String(), + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + // setup + _, _, sender := testdata.KeyTestPubAddr() + msg := types.MsgStoreCodeFixture(func(m *types.MsgStoreCode) { + m.WASMByteCode = wasmContract + m.Sender = sender.String() + }) + + //store code + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + require.NoError(t, err) + var result types.MsgStoreCodeResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &result)) + require.False(t, wasmApp.WasmKeeper.IsPinnedCode(ctx, result.CodeID)) + + // when + msgPinCodes := &types.MsgPinCodes{ + Authority: spec.addr, + CodeIDs: []uint64{result.CodeID}, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgPinCodes)(ctx, msgPinCodes) + + //then + if spec.expErr { + require.Error(t, err) + assert.False(t, wasmApp.WasmKeeper.IsPinnedCode(ctx, result.CodeID)) + } else { + require.NoError(t, err) + assert.True(t, wasmApp.WasmKeeper.IsPinnedCode(ctx, result.CodeID)) + } + }) + } +} + +func TestUnpinCodes(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{}) + + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + ) + + specs := map[string]struct { + addr string + expErr bool + }{ + "authority can unpin codes": { + addr: authority, + expErr: false, + }, + "other address cannot unpin codes": { + addr: myAddress.String(), + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + // setup + _, _, sender := testdata.KeyTestPubAddr() + msg := types.MsgStoreCodeFixture(func(m *types.MsgStoreCode) { + m.WASMByteCode = wasmContract + m.Sender = sender.String() + }) + + // store code + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + require.NoError(t, err) + var result types.MsgStoreCodeResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &result)) + + // pin code + msgPin := &types.MsgPinCodes{ + Authority: authority, + CodeIDs: []uint64{result.CodeID}, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgPin)(ctx, msgPin) + require.NoError(t, err) + assert.True(t, wasmApp.WasmKeeper.IsPinnedCode(ctx, result.CodeID)) + + // when + msgUnpinCodes := &types.MsgUnpinCodes{ + Authority: spec.addr, + CodeIDs: []uint64{result.CodeID}, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgUnpinCodes)(ctx, msgUnpinCodes) + + //then + if spec.expErr { + require.Error(t, err) + assert.True(t, wasmApp.WasmKeeper.IsPinnedCode(ctx, result.CodeID)) + } else { + require.NoError(t, err) + assert.False(t, wasmApp.WasmKeeper.IsPinnedCode(ctx, result.CodeID)) + } + }) + } +} + +func TestSudoContract(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + ) + + type StealMsg struct { + Recipient string `json:"recipient"` + Amount []sdk.Coin `json:"amount"` + } + + stealMsg := struct { + Steal StealMsg `json:"steal_funds"` + }{Steal: StealMsg{ + Recipient: myAddress.String(), + Amount: []sdk.Coin{}, + }} + + stealMsgBz, err := json.Marshal(stealMsg) + require.NoError(t, err) + + specs := map[string]struct { + addr string + expErr bool + }{ + "authority can call sudo on a contract": { + addr: authority, + expErr: false, + }, + "other address cannot call sudo on a contract": { + addr: myAddress.String(), + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + // setup + _, _, sender := testdata.KeyTestPubAddr() + msg := types.MsgStoreCodeFixture(func(m *types.MsgStoreCode) { + m.WASMByteCode = hackatomContract + m.Sender = sender.String() + }) + + //store code + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + require.NoError(t, err) + var storeCodeResponse types.MsgStoreCodeResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &storeCodeResponse)) + + // instantiate contract + initMsg := keeper.HackatomExampleInitMsg{ + Verifier: sender, + Beneficiary: myAddress, + } + initMsgBz, err := json.Marshal(initMsg) + require.NoError(t, err) + + msgInstantiate := &types.MsgInstantiateContract{ + Sender: sender.String(), + Admin: sender.String(), + CodeID: storeCodeResponse.CodeID, + Label: "test", + Msg: initMsgBz, + Funds: sdk.Coins{}, + } + rsp, err = wasmApp.MsgServiceRouter().Handler(msgInstantiate)(ctx, msgInstantiate) + require.NoError(t, err) + var instantiateResponse types.MsgInstantiateContractResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &instantiateResponse)) + + // when + msgSudoContract := &types.MsgSudoContract{ + Authority: spec.addr, + Msg: stealMsgBz, + Contract: instantiateResponse.Address, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgSudoContract)(ctx, msgSudoContract) + + //then + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestStoreAndInstantiateContract(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + ) + + specs := map[string]struct { + addr string + permission *types.AccessConfig + expErr bool + }{ + "authority can store and instantiate a contract when permission is nobody": { + addr: authority, + permission: &types.AllowNobody, + expErr: false, + }, + "other address cannot store and instantiate a contract when permission is nobody": { + addr: myAddress.String(), + permission: &types.AllowNobody, + expErr: true, + }, + "authority can store and instantiate a contract when permission is everybody": { + addr: authority, + permission: &types.AllowEverybody, + expErr: false, + }, + "other address can store and instantiate a contract when permission is everybody": { + addr: myAddress.String(), + permission: &types.AllowEverybody, + expErr: false, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + + // when + msg := &types.MsgStoreAndInstantiateContract{ + Authority: spec.addr, + WASMByteCode: wasmContract, + InstantiatePermission: spec.permission, + Admin: myAddress.String(), + UnpinCode: false, + Label: "test", + Msg: []byte(`{}`), + Funds: sdk.Coins{}, + } + _, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + + //then + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestUpdateAdmin(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + _, _, otherAddr = testdata.KeyTestPubAddr() + ) + + specs := map[string]struct { + addr string + expErr bool + }{ + "authority can update admin": { + addr: authority, + expErr: false, + }, + "admin can update admin": { + addr: myAddress.String(), + expErr: false, + }, + "other address cannot update admin": { + addr: otherAddr.String(), + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + _, _, newAdmin := testdata.KeyTestPubAddr() + + // setup + msg := &types.MsgStoreAndInstantiateContract{ + Authority: spec.addr, + WASMByteCode: wasmContract, + InstantiatePermission: &types.AllowEverybody, + Admin: myAddress.String(), + UnpinCode: false, + Label: "test", + Msg: []byte(`{}`), + Funds: sdk.Coins{}, + } + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + require.NoError(t, err) + var storeAndInstantiateResponse types.MsgStoreAndInstantiateContractResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &storeAndInstantiateResponse)) + + // when + msgUpdateAdmin := &types.MsgUpdateAdmin{ + Sender: spec.addr, + NewAdmin: newAdmin.String(), + Contract: storeAndInstantiateResponse.Address, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgUpdateAdmin)(ctx, msgUpdateAdmin) + + //then + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestClearAdmin(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + _, _, otherAddr = testdata.KeyTestPubAddr() + ) + + specs := map[string]struct { + addr string + expErr bool + }{ + "authority can clear admin": { + addr: authority, + expErr: false, + }, + "admin can clear admin": { + addr: myAddress.String(), + expErr: false, + }, + "other address cannot clear admin": { + addr: otherAddr.String(), + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + + // setup + msg := &types.MsgStoreAndInstantiateContract{ + Authority: spec.addr, + WASMByteCode: wasmContract, + InstantiatePermission: &types.AllowEverybody, + Admin: myAddress.String(), + UnpinCode: false, + Label: "test", + Msg: []byte(`{}`), + Funds: sdk.Coins{}, + } + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + require.NoError(t, err) + var storeAndInstantiateResponse types.MsgStoreAndInstantiateContractResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &storeAndInstantiateResponse)) + + // when + msgClearAdmin := &types.MsgClearAdmin{ + Sender: spec.addr, + Contract: storeAndInstantiateResponse.Address, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgClearAdmin)(ctx, msgClearAdmin) + + //then + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMigrateContract(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + _, _, otherAddr = testdata.KeyTestPubAddr() + ) + + specs := map[string]struct { + addr string + expErr bool + }{ + "authority can migrate a contract": { + addr: authority, + expErr: false, + }, + "admin can migrate a contract": { + addr: myAddress.String(), + expErr: false, + }, + "other address cannot migrate a contract": { + addr: otherAddr.String(), + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + // setup + _, _, sender := testdata.KeyTestPubAddr() + msg := types.MsgStoreCodeFixture(func(m *types.MsgStoreCode) { + m.WASMByteCode = hackatomContract + m.Sender = sender.String() + }) + + //store code + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + require.NoError(t, err) + var storeCodeResponse types.MsgStoreCodeResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &storeCodeResponse)) + + // instantiate contract + initMsg := keeper.HackatomExampleInitMsg{ + Verifier: sender, + Beneficiary: myAddress, + } + initMsgBz, err := json.Marshal(initMsg) + require.NoError(t, err) + + msgInstantiate := &types.MsgInstantiateContract{ + Sender: sender.String(), + Admin: myAddress.String(), + CodeID: storeCodeResponse.CodeID, + Label: "test", + Msg: initMsgBz, + Funds: sdk.Coins{}, + } + rsp, err = wasmApp.MsgServiceRouter().Handler(msgInstantiate)(ctx, msgInstantiate) + require.NoError(t, err) + var instantiateResponse types.MsgInstantiateContractResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &instantiateResponse)) + + // when + migMsg := struct { + Verifier sdk.AccAddress `json:"verifier"` + }{Verifier: myAddress} + migMsgBz, err := json.Marshal(migMsg) + require.NoError(t, err) + msgMigrateContract := &types.MsgMigrateContract{ + Sender: spec.addr, + Msg: migMsgBz, + Contract: instantiateResponse.Address, + CodeID: storeCodeResponse.CodeID, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgMigrateContract)(ctx, msgMigrateContract) + + //then + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestInstantiateContract(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + ) + + specs := map[string]struct { + addr string + permission *types.AccessConfig + expErr bool + }{ + "authority can instantiate a contract when permission is nobody": { + addr: authority, + permission: &types.AllowNobody, + expErr: false, + }, + "other address cannot instantiate a contract when permission is nobody": { + addr: myAddress.String(), + permission: &types.AllowNobody, + expErr: true, + }, + "authority can instantiate a contract when permission is everybody": { + addr: authority, + permission: &types.AllowEverybody, + expErr: false, + }, + "other address can instantiate a contract when permission is everybody": { + addr: myAddress.String(), + permission: &types.AllowEverybody, + expErr: false, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + // setup + _, _, sender := testdata.KeyTestPubAddr() + msg := types.MsgStoreCodeFixture(func(m *types.MsgStoreCode) { + m.WASMByteCode = wasmContract + m.Sender = sender.String() + m.InstantiatePermission = spec.permission + }) + + // store code + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + require.NoError(t, err) + var result types.MsgStoreCodeResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &result)) + + // when + msgInstantiate := &types.MsgInstantiateContract{ + Sender: spec.addr, + Admin: myAddress.String(), + CodeID: result.CodeID, + Label: "test", + Msg: []byte(`{}`), + Funds: sdk.Coins{}, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgInstantiate)(ctx, msgInstantiate) + + //then + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestInstantiateContract2(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + ) + + specs := map[string]struct { + addr string + salt string + permission *types.AccessConfig + expErr bool + }{ + "authority can instantiate a contract when permission is nobody": { + addr: authority, + permission: &types.AllowNobody, + salt: "salt1", + expErr: false, + }, + "other address cannot instantiate a contract when permission is nobody": { + addr: myAddress.String(), + permission: &types.AllowNobody, + salt: "salt2", + expErr: true, + }, + "authority can instantiate a contract when permission is everybody": { + addr: authority, + permission: &types.AllowEverybody, + salt: "salt3", + expErr: false, + }, + "other address can instantiate a contract when permission is everybody": { + addr: myAddress.String(), + permission: &types.AllowEverybody, + salt: "salt4", + expErr: false, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + // setup + _, _, sender := testdata.KeyTestPubAddr() + msg := types.MsgStoreCodeFixture(func(m *types.MsgStoreCode) { + m.WASMByteCode = wasmContract + m.Sender = sender.String() + m.InstantiatePermission = spec.permission + }) + + // store code + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + require.NoError(t, err) + var result types.MsgStoreCodeResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &result)) + + // when + msgInstantiate := &types.MsgInstantiateContract2{ + Sender: spec.addr, + Admin: myAddress.String(), + CodeID: result.CodeID, + Label: "label", + Msg: []byte(`{}`), + Funds: sdk.Coins{}, + Salt: []byte(spec.salt), + FixMsg: true, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgInstantiate)(ctx, msgInstantiate) + + //then + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestUpdateInstantiateConfig(t *testing.T) { + wasmApp := app.Setup(t) + ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + var ( + creator sdk.AccAddress = make([]byte, types.ContractAddrLen) + authority = wasmApp.WasmKeeper.GetAuthority() + ) + + specs := map[string]struct { + addr string + permission *types.AccessConfig + expErr bool + }{ + "authority can update instantiate config when permission is subset": { + addr: authority, + permission: &types.AllowNobody, + expErr: false, + }, + "creator can update instantiate config when permission is subset": { + addr: creator.String(), + permission: &types.AllowNobody, + expErr: false, + }, + "authority can update instantiate config when permission is not subset": { + addr: authority, + permission: &types.AllowEverybody, + expErr: false, + }, + "creator cannot update instantiate config when permission is not subset": { + addr: creator.String(), + permission: &types.AllowEverybody, + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + // setup + err := wasmApp.WasmKeeper.SetParams(ctx, types.Params{ + CodeUploadAccess: types.AllowEverybody, + InstantiateDefaultPermission: types.AccessTypeNobody, + }) + require.NoError(t, err) + + msg := types.MsgStoreCodeFixture(func(m *types.MsgStoreCode) { + m.WASMByteCode = wasmContract + m.Sender = creator.String() + m.InstantiatePermission = &types.AllowNobody + }) + + // store code + rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(ctx, msg) + require.NoError(t, err) + var result types.MsgStoreCodeResponse + require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &result)) + + // when + msgUpdateInstantiateConfig := &types.MsgUpdateInstantiateConfig{ + Sender: spec.addr, + CodeID: result.CodeID, + NewInstantiatePermission: spec.permission, + } + _, err = wasmApp.MsgServiceRouter().Handler(msgUpdateInstantiateConfig)(ctx, msgUpdateInstantiateConfig) + + //then + if spec.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/wasm/keeper/proposal_handler.go b/x/wasm/keeper/proposal_handler.go index e47e973983..82048ca3e8 100644 --- a/x/wasm/keeper/proposal_handler.go +++ b/x/wasm/keeper/proposal_handler.go @@ -15,11 +15,15 @@ import ( ) // NewWasmProposalHandler creates a new governance Handler for wasm proposals +// +// Deprecated: Do not use. func NewWasmProposalHandler(k decoratedKeeper, enabledProposalTypes []types.ProposalType) v1beta1.Handler { return NewWasmProposalHandlerX(NewGovPermissionKeeper(k), enabledProposalTypes) } // NewWasmProposalHandlerX creates a new governance Handler for wasm proposals +// +// Deprecated: Do not use. func NewWasmProposalHandlerX(k types.ContractOpsKeeper, enabledProposalTypes []types.ProposalType) v1beta1.Handler { enabledTypes := make(map[string]struct{}, len(enabledProposalTypes)) for i := range enabledProposalTypes { @@ -63,6 +67,7 @@ func NewWasmProposalHandlerX(k types.ContractOpsKeeper, enabledProposalTypes []t } } +//nolint:staticcheck func handleStoreCodeProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.StoreCodeProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -88,6 +93,7 @@ func handleStoreCodeProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types return k.PinCode(ctx, codeID) } +//nolint:staticcheck func handleInstantiateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.InstantiateContractProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -115,6 +121,7 @@ func handleInstantiateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p typ return nil } +//nolint:staticcheck func handleInstantiate2Proposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.InstantiateContract2Proposal) error { // Validatebasic with proposal if err := p.ValidateBasic(); err != nil { @@ -147,6 +154,7 @@ func handleInstantiate2Proposal(ctx sdk.Context, k types.ContractOpsKeeper, p ty return nil } +//nolint:staticcheck func handleStoreAndInstantiateContractProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.StoreAndInstantiateContractProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -189,6 +197,7 @@ func handleStoreAndInstantiateContractProposal(ctx sdk.Context, k types.Contract return nil } +//nolint:staticcheck func handleMigrateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.MigrateContractProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -212,6 +221,7 @@ func handleMigrateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.M return nil } +//nolint:staticcheck func handleSudoProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.SudoContractProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -233,6 +243,7 @@ func handleSudoProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.Sudo return nil } +//nolint:staticcheck func handleExecuteProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.ExecuteContractProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -258,6 +269,7 @@ func handleExecuteProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.E return nil } +//nolint:staticcheck func handleUpdateAdminProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.UpdateAdminProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -274,6 +286,7 @@ func handleUpdateAdminProposal(ctx sdk.Context, k types.ContractOpsKeeper, p typ return k.UpdateContractAdmin(ctx, contractAddr, nil, newAdminAddr) } +//nolint:staticcheck func handleClearAdminProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.ClearAdminProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -287,6 +300,7 @@ func handleClearAdminProposal(ctx sdk.Context, k types.ContractOpsKeeper, p type return err } +//nolint:staticcheck func handlePinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.PinCodesProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -299,6 +313,7 @@ func handlePinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types. return nil } +//nolint:staticcheck func handleUnpinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.UnpinCodesProposal) error { if err := p.ValidateBasic(); err != nil { return err @@ -311,6 +326,7 @@ func handleUnpinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p type return nil } +//nolint:staticcheck func handleUpdateInstantiateConfigProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.UpdateInstantiateConfigProposal) error { if err := p.ValidateBasic(); err != nil { return err diff --git a/x/wasm/keeper/test_common.go b/x/wasm/keeper/test_common.go index d67441ad67..d5cd223311 100644 --- a/x/wasm/keeper/test_common.go +++ b/x/wasm/keeper/test_common.go @@ -468,7 +468,7 @@ func createTestInput( gov.NewAppModule(appCodec, govKeeper, accountKeeper, bankKeeper, subspace(govtypes.ModuleName)), ) am.RegisterServices(module.NewConfigurator(appCodec, msgRouter, querier)) - types.RegisterMsgServer(msgRouter, newMsgServerImpl(NewDefaultPermissionKeeper(keeper), keeper)) + types.RegisterMsgServer(msgRouter, NewMsgServerImpl(&keeper)) types.RegisterQueryServer(querier, NewGrpcQuerier(appCodec, keys[types.ModuleName], keeper, keeper.queryGasLimit)) keepers := TestKeepers{ diff --git a/x/wasm/module.go b/x/wasm/module.go index 272b32d1a4..6fc956289f 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -208,9 +208,9 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } -// ProposalContents doesn't return any content functions for governance proposals. -func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return simulation.ProposalContents(am.bankKeeper, am.keeper) +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return simulation.ProposalMsgs(am.bankKeeper, am.keeper) } // RegisterStoreDecoder registers a decoder for supply module's types diff --git a/x/wasm/simulation/operations.go b/x/wasm/simulation/operations.go index 06c430eab7..ea5860b369 100644 --- a/x/wasm/simulation/operations.go +++ b/x/wasm/simulation/operations.go @@ -38,6 +38,7 @@ const ( // WasmKeeper is a subset of the wasm keeper used by simulations type WasmKeeper interface { + GetAuthority() string GetParams(ctx sdk.Context) types.Params IterateCodeInfos(ctx sdk.Context, cb func(uint64, types.CodeInfo) bool) IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, types.ContractInfo) bool) diff --git a/x/wasm/simulation/proposals.go b/x/wasm/simulation/proposals.go index 880e6cf371..aeda227b23 100644 --- a/x/wasm/simulation/proposals.go +++ b/x/wasm/simulation/proposals.go @@ -26,14 +26,9 @@ const ( WeightStoreAndInstantiateContractProposal = "weight_store_and_instantiate_contract_proposal" ) -func ProposalContents(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedProposalContent { - return []simtypes.WeightedProposalContent{ - // simulation.NewWeightedProposalContent( - // WeightStoreCodeProposal, - // params.DefaultWeightStoreCodeProposal, - // SimulateStoreCodeProposal(wasmKeeper), - // ), - simulation.NewWeightedProposalContent( +func ProposalMsgs(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( WeightInstantiateContractProposal, params.DefaultWeightInstantiateContractProposal, SimulateInstantiateContractProposal( @@ -42,7 +37,7 @@ func ProposalContents(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedP DefaultSimulationCodeIDSelector, ), ), - simulation.NewWeightedProposalContent( + simulation.NewWeightedProposalMsg( WeightUpdateAdminProposal, params.DefaultWeightUpdateAdminProposal, SimulateUpdateAdminProposal( @@ -50,7 +45,7 @@ func ProposalContents(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedP DefaultSimulateUpdateAdminProposalContractSelector, ), ), - simulation.NewWeightedProposalContent( + simulation.NewWeightedProposalMsg( WeightExeContractProposal, params.DefaultWeightExecuteContractProposal, SimulateExecuteContractProposal( @@ -61,7 +56,7 @@ func ProposalContents(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedP DefaultSimulationExecutePayloader, ), ), - simulation.NewWeightedProposalContent( + simulation.NewWeightedProposalMsg( WeightClearAdminProposal, params.DefaultWeightClearAdminProposal, SimulateClearAdminProposal( @@ -69,7 +64,7 @@ func ProposalContents(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedP DefaultSimulateContractSelector, ), ), - simulation.NewWeightedProposalContent( + simulation.NewWeightedProposalMsg( WeightMigrateContractProposal, params.DefaultWeightMigrateContractProposal, SimulateMigrateContractProposal( @@ -78,15 +73,7 @@ func ProposalContents(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedP DefaultSimulationCodeIDSelector, ), ), - // simulation.NewWeightedProposalContent( - // WeightSudoContractProposal, - // params.DefaultWeightSudoContractProposal, - // SimulateSudoContractProposal( - // wasmKeeper, - // DefaultSimulateContractSelector, - // ), - // ), - simulation.NewWeightedProposalContent( + simulation.NewWeightedProposalMsg( WeightPinCodesProposal, params.DefaultWeightPinCodesProposal, SimulatePinContractProposal( @@ -94,7 +81,7 @@ func ProposalContents(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedP DefaultSimulationCodeIDSelector, ), ), - simulation.NewWeightedProposalContent( + simulation.NewWeightedProposalMsg( WeightUnpinCodesProposal, params.DefaultWeightUnpinCodesProposal, SimulateUnpinContractProposal( @@ -102,7 +89,7 @@ func ProposalContents(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedP DefaultSimulationCodeIDSelector, ), ), - simulation.NewWeightedProposalContent( + simulation.NewWeightedProposalMsg( WeightUpdateInstantiateConfigProposal, params.DefaultWeightUpdateInstantiateConfigProposal, SimulateUpdateInstantiateConfigProposal( @@ -110,47 +97,35 @@ func ProposalContents(bk BankKeeper, wasmKeeper WasmKeeper) []simtypes.WeightedP DefaultSimulationCodeIDSelector, ), ), - // simulation.NewWeightedProposalContent( - // WeightStoreAndInstantiateContractProposal, - // params.DefaultWeightStoreAndInstantiateContractProposal, - // SimulateStoreAndInstantiateContractProposal( - // wasmKeeper, - // ), - // ), } } // simulate store code proposal (unused now) // Current problem: out of gas (defaul gaswanted config of gov SimulateMsgSubmitProposal is 10_000_000) // but this proposal may need more than it -// +func SimulateStoreCodeProposal(wasmKeeper WasmKeeper) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() -func SimulateStoreCodeProposal(wasmKeeper WasmKeeper) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { simAccount, _ := simtypes.RandomAcc(r, accs) wasmBz := testdata.ReflectContractWasm() permission := wasmKeeper.GetParams(ctx).InstantiateDefaultPermission.With(simAccount.Address) - return types.NewStoreCodeProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - simAccount.Address.String(), - wasmBz, - &permission, - false, - "", - "", - []byte{}, - ) + return &types.MsgStoreCode{ + Sender: authority, + WASMByteCode: wasmBz, + InstantiatePermission: &permission, + } } } // Simulate instantiate contract proposal -func SimulateInstantiateContractProposal(_ BankKeeper, wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { - simAccount, _ := simtypes.RandomAcc(r, accs) +func SimulateInstantiateContractProposal(bk BankKeeper, wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() + // admin adminAccount, _ := simtypes.RandomAcc(r, accs) // get codeID @@ -159,58 +134,44 @@ func SimulateInstantiateContractProposal(_ BankKeeper, wasmKeeper WasmKeeper, co return nil } - return types.NewInstantiateContractProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - simAccount.Address.String(), - adminAccount.Address.String(), - codeID, - simtypes.RandStringOfLength(r, 10), - []byte(`{}`), - sdk.Coins{}, - ) + return &types.MsgInstantiateContract{ + Sender: authority, + Admin: adminAccount.Address.String(), + CodeID: codeID, + Label: simtypes.RandStringOfLength(r, 10), + Msg: []byte(`{}`), + Funds: sdk.Coins{}, + } } } // Simulate execute contract proposal -// - func SimulateExecuteContractProposal( _ BankKeeper, wasmKeeper WasmKeeper, contractSelector MsgExecuteContractSelector, senderSelector MsgExecuteSenderSelector, payloader MsgExecutePayloader, -) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { +) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() + ctAddress := contractSelector(ctx, wasmKeeper) if ctAddress == nil { return nil } - simAccount, err := senderSelector(wasmKeeper, ctx, ctAddress, accs) - if err != nil { - return nil - } - - msg := types.MsgExecuteContract{ - Sender: simAccount.Address.String(), + msg := &types.MsgExecuteContract{ + Sender: authority, Contract: ctAddress.String(), Funds: sdk.Coins{}, } - if err := payloader(&msg); err != nil { + if err := payloader(msg); err != nil { return nil } - return types.NewExecuteContractProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - simAccount.Address.String(), - ctAddress.String(), - msg.Msg, - sdk.Coins{}, - ) + return msg } } @@ -235,22 +196,20 @@ func DefaultSimulateUpdateAdminProposalContractSelector( } // Simulate update admin contract proposal -// - -func SimulateUpdateAdminProposal(wasmKeeper WasmKeeper, contractSelector UpdateAdminContractSelector) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { +func SimulateUpdateAdminProposal(wasmKeeper WasmKeeper, contractSelector UpdateAdminContractSelector) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() simAccount, _ := simtypes.RandomAcc(r, accs) ctAddress, _ := contractSelector(ctx, wasmKeeper, simAccount.Address.String()) if ctAddress == nil { return nil } - return types.NewUpdateAdminProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - simtypes.RandomAccounts(r, 1)[0].Address.String(), - ctAddress.String(), - ) + return &types.MsgUpdateAdmin{ + Sender: authority, + NewAdmin: simtypes.RandomAccounts(r, 1)[0].Address.String(), + Contract: ctAddress.String(), + } } } @@ -269,30 +228,28 @@ func DefaultSimulateContractSelector( } // Simulate clear admin proposal -// +func SimulateClearAdminProposal(wasmKeeper WasmKeeper, contractSelector ClearAdminContractSelector) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() -func SimulateClearAdminProposal(wasmKeeper WasmKeeper, contractSelector ClearAdminContractSelector) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { ctAddress := contractSelector(ctx, wasmKeeper) if ctAddress == nil { return nil } - - return types.NewClearAdminProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - ctAddress.String(), - ) + return &types.MsgClearAdmin{ + Sender: authority, + Contract: ctAddress.String(), + } } } type MigrateContractProposalContractSelector func(sdk.Context, WasmKeeper) sdk.AccAddress // Simulate migrate contract proposal -// +func SimulateMigrateContractProposal(wasmKeeper WasmKeeper, contractSelector MigrateContractProposalContractSelector, codeSelector CodeIDSelector) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() -func SimulateMigrateContractProposal(wasmKeeper WasmKeeper, contractSelector MigrateContractProposalContractSelector, codeSelector CodeIDSelector) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { ctAddress := contractSelector(ctx, wasmKeeper) if ctAddress == nil { return nil @@ -303,78 +260,74 @@ func SimulateMigrateContractProposal(wasmKeeper WasmKeeper, contractSelector Mig return nil } - return types.NewMigrateContractProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - ctAddress.String(), - codeID, - []byte(`{}`), - ) + return &types.MsgMigrateContract{ + Sender: authority, + Contract: ctAddress.String(), + CodeID: codeID, + Msg: []byte(`{}`), + } } } type SudoContractProposalContractSelector func(sdk.Context, WasmKeeper) sdk.AccAddress // Simulate sudo contract proposal -// +func SimulateSudoContractProposal(wasmKeeper WasmKeeper, contractSelector SudoContractProposalContractSelector) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() -func SimulateSudoContractProposal(wasmKeeper WasmKeeper, contractSelector SudoContractProposalContractSelector) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { ctAddress := contractSelector(ctx, wasmKeeper) if ctAddress == nil { return nil } - return types.NewSudoContractProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - ctAddress.String(), - []byte(`{}`), - ) + return &types.MsgSudoContract{ + Authority: authority, + Contract: ctAddress.String(), + Msg: []byte(`{}`), + } } } // Simulate pin contract proposal -// +func SimulatePinContractProposal(wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() -func SimulatePinContractProposal(wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { codeID := codeSelector(ctx, wasmKeeper) if codeID == 0 { return nil } - return types.NewPinCodesProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - []uint64{codeID}, - ) + return &types.MsgPinCodes{ + Authority: authority, + CodeIDs: []uint64{codeID}, + } } } // Simulate unpin contract proposal -// +func SimulateUnpinContractProposal(wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() -func SimulateUnpinContractProposal(wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { codeID := codeSelector(ctx, wasmKeeper) if codeID == 0 { return nil } - return types.NewUnpinCodesProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - []uint64{codeID}, - ) + return &types.MsgUnpinCodes{ + Authority: authority, + CodeIDs: []uint64{codeID}, + } } } // Simulate update instantiate config proposal -// +func SimulateUpdateInstantiateConfigProposal(wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() -func SimulateUpdateInstantiateConfigProposal(wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { codeID := codeSelector(ctx, wasmKeeper) if codeID == 0 { return nil @@ -384,41 +337,33 @@ func SimulateUpdateInstantiateConfigProposal(wasmKeeper WasmKeeper, codeSelector permission := wasmKeeper.GetParams(ctx).InstantiateDefaultPermission config := permission.With(simAccount.Address) - configUpdate := types.AccessConfigUpdate{ - CodeID: codeID, - InstantiatePermission: config, + return &types.MsgUpdateInstantiateConfig{ + Sender: authority, + CodeID: codeID, + NewInstantiatePermission: &config, } - - return types.NewUpdateInstantiateConfigProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - configUpdate, - ) } } -func SimulateStoreAndInstantiateContractProposal(wasmKeeper WasmKeeper) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { +func SimulateStoreAndInstantiateContractProposal(wasmKeeper WasmKeeper) simtypes.MsgSimulatorFn { + return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + authority := wasmKeeper.GetAuthority() + simAccount, _ := simtypes.RandomAcc(r, accs) adminAccount, _ := simtypes.RandomAcc(r, accs) wasmBz := testdata.ReflectContractWasm() permission := wasmKeeper.GetParams(ctx).InstantiateDefaultPermission.With(simAccount.Address) - return types.NewStoreAndInstantiateContractProposal( - simtypes.RandStringOfLength(r, 10), - simtypes.RandStringOfLength(r, 10), - simAccount.Address.String(), - wasmBz, - "", - "", - []byte{}, - &permission, - false, - adminAccount.Address.String(), - simtypes.RandStringOfLength(r, 10), - []byte(`{}`), - sdk.Coins{}, - ) + return &types.MsgStoreAndInstantiateContract{ + Authority: authority, + WASMByteCode: wasmBz, + InstantiatePermission: &permission, + UnpinCode: false, + Admin: adminAccount.Address.String(), + Label: simtypes.RandStringOfLength(r, 10), + Msg: []byte(`{}`), + Funds: sdk.Coins{}, + } } } diff --git a/x/wasm/types/codec.go b/x/wasm/types/codec.go index d486ea60e2..c25b338e02 100644 --- a/x/wasm/types/codec.go +++ b/x/wasm/types/codec.go @@ -24,6 +24,10 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgClearAdmin{}, "wasm/MsgClearAdmin", nil) cdc.RegisterConcrete(&MsgUpdateInstantiateConfig{}, "wasm/MsgUpdateInstantiateConfig", nil) cdc.RegisterConcrete(&MsgUpdateParams{}, "wasm/MsgUpdateParams", nil) + cdc.RegisterConcrete(&MsgSudoContract{}, "wasm/MsgSudoContract", nil) + cdc.RegisterConcrete(&MsgPinCodes{}, "wasm/MsgPinCodes", nil) + cdc.RegisterConcrete(&MsgUnpinCodes{}, "wasm/MsgUnpinCodes", nil) + cdc.RegisterConcrete(&MsgStoreAndInstantiateContract{}, "wasm/MsgStoreAndInstantiateContract", nil) cdc.RegisterConcrete(&PinCodesProposal{}, "wasm/PinCodesProposal", nil) cdc.RegisterConcrete(&UnpinCodesProposal{}, "wasm/UnpinCodesProposal", nil) @@ -68,6 +72,10 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgIBCSend{}, &MsgUpdateInstantiateConfig{}, &MsgUpdateParams{}, + &MsgSudoContract{}, + &MsgPinCodes{}, + &MsgUnpinCodes{}, + &MsgStoreAndInstantiateContract{}, ) registry.RegisterImplementations( (*v1beta1.Content)(nil), diff --git a/x/wasm/types/proposal.pb.go b/x/wasm/types/proposal.pb.go index 349a1535b6..ca74cc5ae0 100644 --- a/x/wasm/types/proposal.pb.go +++ b/x/wasm/types/proposal.pb.go @@ -30,7 +30,12 @@ var ( // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// StoreCodeProposal gov proposal content type to submit WASM code to the system +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit StoreCodeProposal. To submit WASM code to the system, +// a simple MsgStoreCode can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type StoreCodeProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -91,8 +96,12 @@ func (m *StoreCodeProposal) XXX_DiscardUnknown() { var xxx_messageInfo_StoreCodeProposal proto.InternalMessageInfo -// InstantiateContractProposal gov proposal content type to instantiate a -// contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit InstantiateContractProposal. To instantiate a contract, +// a simple MsgInstantiateContract can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type InstantiateContractProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -149,8 +158,12 @@ func (m *InstantiateContractProposal) XXX_DiscardUnknown() { var xxx_messageInfo_InstantiateContractProposal proto.InternalMessageInfo -// InstantiateContract2Proposal gov proposal content type to instantiate -// contract 2 +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit InstantiateContract2Proposal. To instantiate contract 2, +// a simple MsgInstantiateContract2 can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type InstantiateContract2Proposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -212,7 +225,12 @@ func (m *InstantiateContract2Proposal) XXX_DiscardUnknown() { var xxx_messageInfo_InstantiateContract2Proposal proto.InternalMessageInfo -// MigrateContractProposal gov proposal content type to migrate a contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit MigrateContractProposal. To migrate a contract, +// a simple MsgMigrateContract can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type MigrateContractProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -263,7 +281,12 @@ func (m *MigrateContractProposal) XXX_DiscardUnknown() { var xxx_messageInfo_MigrateContractProposal proto.InternalMessageInfo -// SudoContractProposal gov proposal content type to call sudo on a contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit SudoContractProposal. To call sudo on a contract, +// a simple MsgSudoContract can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type SudoContractProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -312,8 +335,12 @@ func (m *SudoContractProposal) XXX_DiscardUnknown() { var xxx_messageInfo_SudoContractProposal proto.InternalMessageInfo -// ExecuteContractProposal gov proposal content type to call execute on a -// contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit ExecuteContractProposal. To call execute on a contract, +// a simple MsgExecuteContract can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type ExecuteContractProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -366,7 +393,12 @@ func (m *ExecuteContractProposal) XXX_DiscardUnknown() { var xxx_messageInfo_ExecuteContractProposal proto.InternalMessageInfo -// UpdateAdminProposal gov proposal content type to set an admin for a contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit UpdateAdminProposal. To set an admin for a contract, +// a simple MsgUpdateAdmin can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type UpdateAdminProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -415,8 +447,12 @@ func (m *UpdateAdminProposal) XXX_DiscardUnknown() { var xxx_messageInfo_UpdateAdminProposal proto.InternalMessageInfo -// ClearAdminProposal gov proposal content type to clear the admin of a -// contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit ClearAdminProposal. To clear the admin of a contract, +// a simple MsgClearAdmin can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type ClearAdminProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -463,8 +499,12 @@ func (m *ClearAdminProposal) XXX_DiscardUnknown() { var xxx_messageInfo_ClearAdminProposal proto.InternalMessageInfo -// PinCodesProposal gov proposal content type to pin a set of code ids in the -// wasmvm cache. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit PinCodesProposal. To pin a set of code ids in the wasmvm +// cache, a simple MsgPinCodes can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type PinCodesProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` @@ -511,8 +551,12 @@ func (m *PinCodesProposal) XXX_DiscardUnknown() { var xxx_messageInfo_PinCodesProposal proto.InternalMessageInfo -// UnpinCodesProposal gov proposal content type to unpin a set of code ids in -// the wasmvm cache. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit UnpinCodesProposal. To unpin a set of code ids in the wasmvm +// cache, a simple MsgUnpinCodes can be invoked from the x/gov module via +// a v1 governance proposal. +// +// Deprecated: Do not use. type UnpinCodesProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` @@ -605,8 +649,12 @@ func (m *AccessConfigUpdate) XXX_DiscardUnknown() { var xxx_messageInfo_AccessConfigUpdate proto.InternalMessageInfo -// UpdateInstantiateConfigProposal gov proposal content type to update -// instantiate config to a set of code ids. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit UpdateInstantiateConfigProposal. To update instantiate config +// to a set of code ids, a simple MsgUpdateInstantiateConfig can be invoked from +// the x/gov module via a v1 governance proposal. +// +// Deprecated: Do not use. type UpdateInstantiateConfigProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` @@ -654,8 +702,12 @@ func (m *UpdateInstantiateConfigProposal) XXX_DiscardUnknown() { var xxx_messageInfo_UpdateInstantiateConfigProposal proto.InternalMessageInfo -// StoreAndInstantiateContractProposal gov proposal content type to store -// and instantiate the contract. +// Deprecated: Do not use. Since wasmd v0.40, there is no longer a need for +// an explicit StoreAndInstantiateContractProposal. To store and instantiate +// the contract, a simple MsgStoreAndInstantiateContract can be invoked from +// the x/gov module via a v1 governance proposal. +// +// Deprecated: Do not use. type StoreAndInstantiateContractProposal struct { // Title is a short summary Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -743,72 +795,72 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/proposal.proto", fileDescriptor_be6422d717c730cb) } var fileDescriptor_be6422d717c730cb = []byte{ - // 1025 bytes of a gzipped FileDescriptorProto + // 1028 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x57, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0x8f, 0xf3, 0xc7, 0x71, 0x5e, 0x02, 0x84, 0xd9, 0xb4, 0xf5, 0x76, 0x17, 0x3b, 0xca, 0xa2, + 0x14, 0x8f, 0x9b, 0xc4, 0x71, 0x5e, 0x02, 0x84, 0xd9, 0xfe, 0xf1, 0x76, 0x17, 0x3b, 0xca, 0xa2, 0x55, 0x2e, 0x9b, 0x90, 0x22, 0x21, 0xd8, 0x5b, 0x1c, 0x90, 0xe8, 0x8a, 0x4a, 0x95, 0xab, 0x6a, - 0x25, 0x90, 0xb0, 0x26, 0xf6, 0xc4, 0xb5, 0x48, 0x3c, 0x91, 0xc7, 0xee, 0x9f, 0x33, 0x17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, 0xe2, 0xc7, 0x82, + 0xfc, 0xe2, 0xc6, 0x02, 0xf9, 0xfc, 0x58, 0x30, 0x69, 0xdd, 0x0a, 0xd3, 0xad, 0xdb, 0xa4, 0x2b, + 0x53, 0x2e, 0xe8, 0xca, 0x8a, 0x57, 0xf8, 0x63, 0x82, 0x6b, 0xeb, 0xca, 0x9e, 0xce, 0x33, 0xa5, + 0xcb, 0xe6, 0x99, 0xf2, 0x8c, 0x79, 0xe6, 0x95, 0xab, 0xce, 0x33, 0xc6, 0x47, 0xc7, 0x4f, 0xb4, + 0xcc, 0xe3, 0x27, 0x5a, 0xe6, 0xdb, 0x91, 0x26, 0x1d, 0x8f, 0x34, 0xe9, 0xd1, 0x48, 0x93, 0xfe, + 0x18, 0x69, 0xd2, 0x57, 0x27, 0x5a, 0xe6, 0xd1, 0x89, 0x96, 0x79, 0x7c, 0xa2, 0x65, 0x3e, 0xbe, + 0x3b, 0xe5, 0x47, 0x87, 0xb2, 0xc1, 0xc3, 0xf1, 0x88, 0xea, 0x34, 0x0f, 0xc5, 0xa8, 0xca, 0x7d, + 0xe9, 0xca, 0x7c, 0x50, 0x7d, 0xfb, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x49, 0x99, 0xc3, 0x16, + 0x4c, 0x0f, 0x00, 0x00, } func (this *StoreCodeProposal) Equal(that interface{}) bool { diff --git a/x/wasm/types/tx.go b/x/wasm/types/tx.go index 22c8f1b052..30c9c41ac7 100644 --- a/x/wasm/types/tx.go +++ b/x/wasm/types/tx.go @@ -74,11 +74,6 @@ func (msg MsgStoreCode) ValidateBasic() error { if msg.InstantiatePermission.Permission == AccessTypeOnlyAddress { return ErrInvalid.Wrap("unsupported type, use AccessTypeAnyOfAddresses instead") } - // AccessTypeOnlyAddress is still considered valid as legacy instantiation permission - // but not for new contracts - if msg.InstantiatePermission.Permission == AccessTypeOnlyAddress { - return ErrInvalid.Wrap("unsupported type, use AccessTypeAnyOfAddresses instead") - } } return nil } @@ -478,5 +473,165 @@ func (msg MsgUpdateParams) GetSignBytes() []byte { } func (msg MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "authority") + } return msg.Params.ValidateBasic() } + +func (msg MsgPinCodes) Route() string { + return RouterKey +} + +func (msg MsgPinCodes) Type() string { + return "pin-codes" +} + +func (msg MsgPinCodes) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{authority} +} + +func (msg MsgPinCodes) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgPinCodes) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "authority") + } + if len(msg.CodeIDs) == 0 { + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty code ids") + } + return nil +} + +func (msg MsgUnpinCodes) Route() string { + return RouterKey +} + +func (msg MsgUnpinCodes) Type() string { + return "unpin-codes" +} + +func (msg MsgUnpinCodes) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{authority} +} + +func (msg MsgUnpinCodes) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgUnpinCodes) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "authority") + } + if len(msg.CodeIDs) == 0 { + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "empty code ids") + } + return nil +} + +func (msg MsgSudoContract) Route() string { + return RouterKey +} + +func (msg MsgSudoContract) Type() string { + return "sudo-contract" +} + +func (msg MsgSudoContract) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{authority} +} + +func (msg MsgSudoContract) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgSudoContract) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "authority") + } + if _, err := sdk.AccAddressFromBech32(msg.Contract); err != nil { + return errorsmod.Wrap(err, "contract") + } + if err := msg.Msg.ValidateBasic(); err != nil { + return errorsmod.Wrap(err, "payload msg") + } + return nil +} + +func (msg MsgStoreAndInstantiateContract) Route() string { + return RouterKey +} + +func (msg MsgStoreAndInstantiateContract) Type() string { + return "store-and-instantiate-contract" +} + +func (msg MsgStoreAndInstantiateContract) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{authority} +} + +func (msg MsgStoreAndInstantiateContract) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgStoreAndInstantiateContract) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "authority") + } + + if err := ValidateLabel(msg.Label); err != nil { + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "label is required") + } + + if !msg.Funds.IsValid() { + return sdkerrors.ErrInvalidCoins + } + + if len(msg.Admin) != 0 { + if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { + return errorsmod.Wrap(err, "admin") + } + } + + if err := ValidateVerificationInfo(msg.Source, msg.Builder, msg.CodeHash); err != nil { + return errorsmod.Wrapf(err, "code verification info") + } + + if err := msg.Msg.ValidateBasic(); err != nil { + return errorsmod.Wrap(err, "payload msg") + } + + if err := validateWasmCode(msg.WASMByteCode, MaxWasmSize); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "code bytes %s", err.Error()) + } + + if msg.InstantiatePermission != nil { + if err := msg.InstantiatePermission.ValidateBasic(); err != nil { + return errorsmod.Wrap(err, "instantiate permission") + } + // AccessTypeOnlyAddress is still considered valid as legacy instantiation permission + // but not for new contracts + if msg.InstantiatePermission.Permission == AccessTypeOnlyAddress { + return ErrInvalid.Wrap("unsupported type, use AccessTypeAnyOfAddresses instead") + } + } + return nil +} diff --git a/x/wasm/types/tx.pb.go b/x/wasm/types/tx.pb.go index a97615f13c..d661f41c69 100644 --- a/x/wasm/types/tx.pb.go +++ b/x/wasm/types/tx.pb.go @@ -791,11 +791,11 @@ func (m *MsgUpdateInstantiateConfigResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateInstantiateConfigResponse proto.InternalMessageInfo -// MsgUpdateParams is the Msg/UpdateParams request type. +// MsgUpdateParams is the MsgUpdateParams request type. // // Since: 0.40 type MsgUpdateParams struct { - // authority is the address of the governance account. + // Authority is the address of the governance account. Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` // params defines the x/wasm parameters to update. // @@ -885,6 +885,409 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// MsgSudoContract is the MsgSudoContract request type. +// +// Since: 0.40 +type MsgSudoContract struct { + // Authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // Contract is the address of the smart contract + Contract string `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"` + // Msg json encoded message to be passed to the contract as sudo + Msg RawContractMessage `protobuf:"bytes,3,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"` +} + +func (m *MsgSudoContract) Reset() { *m = MsgSudoContract{} } +func (m *MsgSudoContract) String() string { return proto.CompactTextString(m) } +func (*MsgSudoContract) ProtoMessage() {} +func (*MsgSudoContract) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{18} +} + +func (m *MsgSudoContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *MsgSudoContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSudoContract.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 *MsgSudoContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSudoContract.Merge(m, src) +} + +func (m *MsgSudoContract) XXX_Size() int { + return m.Size() +} + +func (m *MsgSudoContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSudoContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSudoContract proto.InternalMessageInfo + +// MsgSudoContractResponse defines the response structure for executing a +// MsgSudoContract message. +// +// Since: 0.40 +type MsgSudoContractResponse struct { + // Data contains bytes to returned from the contract + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *MsgSudoContractResponse) Reset() { *m = MsgSudoContractResponse{} } +func (m *MsgSudoContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSudoContractResponse) ProtoMessage() {} +func (*MsgSudoContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{19} +} + +func (m *MsgSudoContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *MsgSudoContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSudoContractResponse.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 *MsgSudoContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSudoContractResponse.Merge(m, src) +} + +func (m *MsgSudoContractResponse) XXX_Size() int { + return m.Size() +} + +func (m *MsgSudoContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSudoContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSudoContractResponse proto.InternalMessageInfo + +// MsgPinCodes is the MsgPinCodes request type. +// +// Since: 0.40 +type MsgPinCodes struct { + // Authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // CodeIDs references the new WASM codes + CodeIDs []uint64 `protobuf:"varint,2,rep,packed,name=code_ids,json=codeIds,proto3" json:"code_ids,omitempty" yaml:"code_ids"` +} + +func (m *MsgPinCodes) Reset() { *m = MsgPinCodes{} } +func (m *MsgPinCodes) String() string { return proto.CompactTextString(m) } +func (*MsgPinCodes) ProtoMessage() {} +func (*MsgPinCodes) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{20} +} + +func (m *MsgPinCodes) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *MsgPinCodes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPinCodes.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 *MsgPinCodes) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPinCodes.Merge(m, src) +} + +func (m *MsgPinCodes) XXX_Size() int { + return m.Size() +} + +func (m *MsgPinCodes) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPinCodes.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPinCodes proto.InternalMessageInfo + +// MsgPinCodesResponse defines the response structure for executing a +// MsgPinCodes message. +// +// Since: 0.40 +type MsgPinCodesResponse struct{} + +func (m *MsgPinCodesResponse) Reset() { *m = MsgPinCodesResponse{} } +func (m *MsgPinCodesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPinCodesResponse) ProtoMessage() {} +func (*MsgPinCodesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{21} +} + +func (m *MsgPinCodesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *MsgPinCodesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPinCodesResponse.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 *MsgPinCodesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPinCodesResponse.Merge(m, src) +} + +func (m *MsgPinCodesResponse) XXX_Size() int { + return m.Size() +} + +func (m *MsgPinCodesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPinCodesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPinCodesResponse proto.InternalMessageInfo + +// MsgUnpinCodes is the MsgUnpinCodes request type. +// +// Since: 0.40 +type MsgUnpinCodes struct { + // Authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // CodeIDs references the WASM codes + CodeIDs []uint64 `protobuf:"varint,2,rep,packed,name=code_ids,json=codeIds,proto3" json:"code_ids,omitempty" yaml:"code_ids"` +} + +func (m *MsgUnpinCodes) Reset() { *m = MsgUnpinCodes{} } +func (m *MsgUnpinCodes) String() string { return proto.CompactTextString(m) } +func (*MsgUnpinCodes) ProtoMessage() {} +func (*MsgUnpinCodes) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{22} +} + +func (m *MsgUnpinCodes) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *MsgUnpinCodes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnpinCodes.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 *MsgUnpinCodes) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnpinCodes.Merge(m, src) +} + +func (m *MsgUnpinCodes) XXX_Size() int { + return m.Size() +} + +func (m *MsgUnpinCodes) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnpinCodes.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnpinCodes proto.InternalMessageInfo + +// MsgUnpinCodesResponse defines the response structure for executing a +// MsgUnpinCodes message. +// +// Since: 0.40 +type MsgUnpinCodesResponse struct{} + +func (m *MsgUnpinCodesResponse) Reset() { *m = MsgUnpinCodesResponse{} } +func (m *MsgUnpinCodesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUnpinCodesResponse) ProtoMessage() {} +func (*MsgUnpinCodesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{23} +} + +func (m *MsgUnpinCodesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *MsgUnpinCodesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnpinCodesResponse.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 *MsgUnpinCodesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnpinCodesResponse.Merge(m, src) +} + +func (m *MsgUnpinCodesResponse) XXX_Size() int { + return m.Size() +} + +func (m *MsgUnpinCodesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnpinCodesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnpinCodesResponse proto.InternalMessageInfo + +// MsgStoreAndInstantiateContract is the MsgStoreAndInstantiateContract +// request type. +// +// Since: 0.40 +type MsgStoreAndInstantiateContract struct { + // Authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // WASMByteCode can be raw or gzip compressed + WASMByteCode []byte `protobuf:"bytes,3,opt,name=wasm_byte_code,json=wasmByteCode,proto3" json:"wasm_byte_code,omitempty"` + // InstantiatePermission to apply on contract creation, optional + InstantiatePermission *AccessConfig `protobuf:"bytes,4,opt,name=instantiate_permission,json=instantiatePermission,proto3" json:"instantiate_permission,omitempty"` + // UnpinCode code on upload, optional. As default the uploaded contract is + // pinned to cache. + UnpinCode bool `protobuf:"varint,5,opt,name=unpin_code,json=unpinCode,proto3" json:"unpin_code,omitempty"` + // Admin is an optional address that can execute migrations + Admin string `protobuf:"bytes,6,opt,name=admin,proto3" json:"admin,omitempty"` + // Label is optional metadata to be stored with a constract instance. + Label string `protobuf:"bytes,7,opt,name=label,proto3" json:"label,omitempty"` + // Msg json encoded message to be passed to the contract on instantiation + Msg RawContractMessage `protobuf:"bytes,8,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"` + // Funds coins that are transferred from the authority account to the contract + // on instantiation + Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,9,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` + // Source is the URL where the code is hosted + Source string `protobuf:"bytes,10,opt,name=source,proto3" json:"source,omitempty"` + // Builder is the docker image used to build the code deterministically, used + // for smart contract verification + Builder string `protobuf:"bytes,11,opt,name=builder,proto3" json:"builder,omitempty"` + // CodeHash is the SHA256 sum of the code outputted by builder, used for smart + // contract verification + CodeHash []byte `protobuf:"bytes,12,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty"` +} + +func (m *MsgStoreAndInstantiateContract) Reset() { *m = MsgStoreAndInstantiateContract{} } +func (m *MsgStoreAndInstantiateContract) String() string { return proto.CompactTextString(m) } +func (*MsgStoreAndInstantiateContract) ProtoMessage() {} +func (*MsgStoreAndInstantiateContract) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{24} +} + +func (m *MsgStoreAndInstantiateContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *MsgStoreAndInstantiateContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgStoreAndInstantiateContract.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 *MsgStoreAndInstantiateContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgStoreAndInstantiateContract.Merge(m, src) +} + +func (m *MsgStoreAndInstantiateContract) XXX_Size() int { + return m.Size() +} + +func (m *MsgStoreAndInstantiateContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgStoreAndInstantiateContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgStoreAndInstantiateContract proto.InternalMessageInfo + +// MsgStoreAndInstantiateContractResponse defines the response structure +// for executing a MsgStoreAndInstantiateContract message. +// +// Since: 0.40 +type MsgStoreAndInstantiateContractResponse struct { + // Address is the bech32 address of the new contract instance. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // Data contains bytes to returned from the contract + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *MsgStoreAndInstantiateContractResponse) Reset() { + *m = MsgStoreAndInstantiateContractResponse{} +} +func (m *MsgStoreAndInstantiateContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgStoreAndInstantiateContractResponse) ProtoMessage() {} +func (*MsgStoreAndInstantiateContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4f74d82755520264, []int{25} +} + +func (m *MsgStoreAndInstantiateContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *MsgStoreAndInstantiateContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgStoreAndInstantiateContractResponse.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 *MsgStoreAndInstantiateContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgStoreAndInstantiateContractResponse.Merge(m, src) +} + +func (m *MsgStoreAndInstantiateContractResponse) XXX_Size() int { + return m.Size() +} + +func (m *MsgStoreAndInstantiateContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgStoreAndInstantiateContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgStoreAndInstantiateContractResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgStoreCode)(nil), "cosmwasm.wasm.v1.MsgStoreCode") proto.RegisterType((*MsgStoreCodeResponse)(nil), "cosmwasm.wasm.v1.MsgStoreCodeResponse") @@ -904,78 +1307,103 @@ func init() { proto.RegisterType((*MsgUpdateInstantiateConfigResponse)(nil), "cosmwasm.wasm.v1.MsgUpdateInstantiateConfigResponse") proto.RegisterType((*MsgUpdateParams)(nil), "cosmwasm.wasm.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmwasm.wasm.v1.MsgUpdateParamsResponse") + proto.RegisterType((*MsgSudoContract)(nil), "cosmwasm.wasm.v1.MsgSudoContract") + proto.RegisterType((*MsgSudoContractResponse)(nil), "cosmwasm.wasm.v1.MsgSudoContractResponse") + proto.RegisterType((*MsgPinCodes)(nil), "cosmwasm.wasm.v1.MsgPinCodes") + proto.RegisterType((*MsgPinCodesResponse)(nil), "cosmwasm.wasm.v1.MsgPinCodesResponse") + proto.RegisterType((*MsgUnpinCodes)(nil), "cosmwasm.wasm.v1.MsgUnpinCodes") + proto.RegisterType((*MsgUnpinCodesResponse)(nil), "cosmwasm.wasm.v1.MsgUnpinCodesResponse") + proto.RegisterType((*MsgStoreAndInstantiateContract)(nil), "cosmwasm.wasm.v1.MsgStoreAndInstantiateContract") + proto.RegisterType((*MsgStoreAndInstantiateContractResponse)(nil), "cosmwasm.wasm.v1.MsgStoreAndInstantiateContractResponse") } func init() { proto.RegisterFile("cosmwasm/wasm/v1/tx.proto", fileDescriptor_4f74d82755520264) } var fileDescriptor_4f74d82755520264 = []byte{ - // 1043 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x57, 0xcf, 0x6f, 0xe3, 0x44, - 0x14, 0xae, 0x9b, 0x1f, 0x4d, 0x5e, 0x42, 0xb7, 0x32, 0xd9, 0xc6, 0x35, 0xc8, 0x09, 0x61, 0xb5, - 0x64, 0xd1, 0x6e, 0xd2, 0x04, 0xd4, 0xc3, 0xde, 0x9a, 0x2c, 0x87, 0xae, 0x64, 0xa8, 0x5c, 0x2d, - 0x15, 0x68, 0xa5, 0x68, 0x62, 0x4f, 0x5c, 0x6b, 0x6b, 0x3b, 0x78, 0x26, 0x4d, 0x7a, 0xe0, 0xc2, - 0x5f, 0x00, 0x67, 0x4e, 0x48, 0x9c, 0x38, 0x71, 0xe0, 0x4f, 0xe0, 0x50, 0x2e, 0x68, 0xc5, 0x89, - 0x53, 0x81, 0xf4, 0xc0, 0xff, 0xc0, 0x09, 0x79, 0xfc, 0x23, 0x4e, 0x6a, 0x27, 0x59, 0x90, 0xb8, - 0x70, 0x49, 0x3c, 0x99, 0xef, 0x7d, 0xef, 0x7b, 0xdf, 0xcc, 0x9b, 0x89, 0x61, 0x4f, 0xb5, 0x89, - 0x39, 0x46, 0xc4, 0x6c, 0xb2, 0x8f, 0x8b, 0x56, 0x93, 0x4e, 0x1a, 0x43, 0xc7, 0xa6, 0x36, 0xbf, - 0x13, 0x4c, 0x35, 0xd8, 0xc7, 0x45, 0x4b, 0x94, 0xdc, 0x5f, 0x6c, 0xd2, 0xec, 0x23, 0x82, 0x9b, - 0x17, 0xad, 0x3e, 0xa6, 0xa8, 0xd5, 0x54, 0x6d, 0xc3, 0xf2, 0x22, 0xc4, 0xb2, 0x3f, 0x6f, 0x12, - 0xdd, 0x65, 0x32, 0x89, 0xee, 0x4f, 0x94, 0x74, 0x5b, 0xb7, 0xd9, 0x63, 0xd3, 0x7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xa6, 0x59, 0x3c, 0x12, 0xe3, 0xd3, 0x2c, 0xa0, 0x12, 0xd2, 0x24, 0x1d, 0x5c, - 0x9f, 0x40, 0x21, 0x7a, 0x42, 0x55, 0x63, 0x83, 0x23, 0x08, 0xb1, 0xbe, 0x0a, 0x11, 0x52, 0x7f, - 0x0c, 0x10, 0x39, 0x72, 0x2a, 0xb1, 0x71, 0x33, 0x80, 0xf8, 0xce, 0x0a, 0x40, 0xc8, 0xfb, 0x39, - 0x94, 0x93, 0x8e, 0x97, 0x87, 0x4b, 0xc4, 0xdd, 0x42, 0x8b, 0xef, 0xbf, 0x0a, 0x3a, 0x4c, 0xff, - 0x1c, 0x8a, 0x73, 0x0d, 0xff, 0xd6, 0x12, 0x16, 0x0f, 0x22, 0x3e, 0x58, 0x09, 0x09, 0xd8, 0x3b, - 0x4f, 0xae, 0xfe, 0x90, 0x36, 0xae, 0xa6, 0x12, 0xf7, 0x72, 0x2a, 0x71, 0xbf, 0x4f, 0x25, 0xee, - 0xcb, 0x1b, 0x69, 0xe3, 0xe5, 0x8d, 0xb4, 0xf1, 0xeb, 0x8d, 0xb4, 0xf1, 0xe9, 0xfd, 0xc8, 0xdd, - 0xdc, 0xb5, 0x89, 0x79, 0x1a, 0xbc, 0xbb, 0x68, 0xcd, 0x89, 0xf7, 0x0e, 0xc3, 0xee, 0xe7, 0x7e, - 0x96, 0xbd, 0xa6, 0xbc, 0xf7, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd3, 0x7b, 0x0a, 0x47, 0x5d, - 0x0d, 0x00, 0x00, + // 1319 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x58, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xc6, 0xeb, 0xaf, 0x67, 0xd3, 0x46, 0x5b, 0x37, 0xd9, 0x6c, 0xa9, 0x6d, 0x4c, 0x29, + 0x2e, 0x6a,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0x45, 0xad, 0xde, 0x87, 0x4c, 0x90, 0x43, 0x15, 0x43, 0x95, 0x03, + 0x12, 0x52, 0xf9, 0x34, 0x09, 0xdf, 0xf4, 0x23, 0x80, 0x00, 0x29, 0x2a, 0x84, 0xea, 0x8d, 0x05, + 0xa4, 0x57, 0x4f, 0x11, 0xf0, 0xed, 0x7e, 0x04, 0x6b, 0x51, 0x04, 0xe8, 0xf6, 0x1c, 0x70, 0x33, + 0xd2, 0xd2, 0x1b, 0x67, 0x91, 0xf6, 0xdd, 0x3f, 0x81, 0xec, 0x04, 0x25, 0x79, 0x69, 0x8e, 0x15, + 0x47, 0x44, 0xba, 0x75, 0xaa, 0x48, 0xd0, 0xfa, 0x04, 0x83, 0x08, 0xb7, 0x1e, 0x14, 0x89, 0xb0, + 0x1e, 0x3a, 0xe6, 0x77, 0x20, 0xe5, 0x8f, 0xf3, 0xeb, 0xa1, 0x6a, 0xde, 0xb6, 0xf4, 0xca, 0xdc, + 0xed, 0xe0, 0x21, 0x07, 0xc6, 0x6e, 0xf8, 0x21, 0x8f, 0x05, 0x22, 0x0e, 0x79, 0x76, 0x48, 0x0a, + 0x9f, 0x70, 0x70, 0x6d, 0xde, 0x84, 0xdc, 0x88, 0xbe, 0x96, 0xc2, 0x35, 0xa4, 0x37, 0xcf, 0xaa, + 0xe1, 0x61, 0xa9, 0xdf, 0x3f, 0xfe, 0x2d, 0xbf, 0x74, 0x3c, 0xca, 0x73, 0xcf, 0x47, 0x79, 0xee, + 0xd7, 0x51, 0x9e, 0x7b, 0x76, 0x92, 0x5f, 0x7a, 0x7e, 0x92, 0x5f, 0xfa, 0xf9, 0x24, 0xbf, 0xf4, + 0xc1, 0xcd, 0xc0, 0xf4, 0x68, 0x98, 0x44, 0x7f, 0xec, 0xbd, 0xf1, 0x52, 0xaa, 0x87, 0xce, 0x9b, + 0x2f, 0x36, 0x41, 0xda, 0x09, 0xf6, 0x72, 0xeb, 0xf5, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x77, + 0x6c, 0x46, 0x8e, 0x93, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1015,6 +1443,26 @@ type MsgClient interface { // // Since: 0.40 UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // SudoContract defines a governance operation for calling sudo + // on a contract. The authority is defined in the keeper. + // + // Since: 0.40 + SudoContract(ctx context.Context, in *MsgSudoContract, opts ...grpc.CallOption) (*MsgSudoContractResponse, error) + // PinCodes defines a governance operation for pinning a set of + // code ids in the wasmvm cache. The authority is defined in the keeper. + // + // Since: 0.40 + PinCodes(ctx context.Context, in *MsgPinCodes, opts ...grpc.CallOption) (*MsgPinCodesResponse, error) + // UnpinCodes defines a governance operation for unpinning a set of + // code ids in the wasmvm cache. The authority is defined in the keeper. + // + // Since: 0.40 + UnpinCodes(ctx context.Context, in *MsgUnpinCodes, opts ...grpc.CallOption) (*MsgUnpinCodesResponse, error) + // StoreAndInstantiateContract defines a governance operation for storing + // and instantiating the contract. The authority is defined in the keeper. + // + // Since: 0.40 + StoreAndInstantiateContract(ctx context.Context, in *MsgStoreAndInstantiateContract, opts ...grpc.CallOption) (*MsgStoreAndInstantiateContractResponse, error) } type msgClient struct { @@ -1106,19 +1554,55 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } -// MsgServer is the server API for Msg service. -type MsgServer interface { - // StoreCode to submit Wasm code to the system - StoreCode(context.Context, *MsgStoreCode) (*MsgStoreCodeResponse, error) - // InstantiateContract creates a new smart contract instance for the given - // code id. - InstantiateContract(context.Context, *MsgInstantiateContract) (*MsgInstantiateContractResponse, error) - // InstantiateContract2 creates a new smart contract instance for the given - // code id with a predictable address - InstantiateContract2(context.Context, *MsgInstantiateContract2) (*MsgInstantiateContract2Response, error) - // Execute submits the given message data to a smart contract - ExecuteContract(context.Context, *MsgExecuteContract) (*MsgExecuteContractResponse, error) - // Migrate runs a code upgrade/ downgrade for a smart contract +func (c *msgClient) SudoContract(ctx context.Context, in *MsgSudoContract, opts ...grpc.CallOption) (*MsgSudoContractResponse, error) { + out := new(MsgSudoContractResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1.Msg/SudoContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) PinCodes(ctx context.Context, in *MsgPinCodes, opts ...grpc.CallOption) (*MsgPinCodesResponse, error) { + out := new(MsgPinCodesResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1.Msg/PinCodes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UnpinCodes(ctx context.Context, in *MsgUnpinCodes, opts ...grpc.CallOption) (*MsgUnpinCodesResponse, error) { + out := new(MsgUnpinCodesResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1.Msg/UnpinCodes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) StoreAndInstantiateContract(ctx context.Context, in *MsgStoreAndInstantiateContract, opts ...grpc.CallOption) (*MsgStoreAndInstantiateContractResponse, error) { + out := new(MsgStoreAndInstantiateContractResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1.Msg/StoreAndInstantiateContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // StoreCode to submit Wasm code to the system + StoreCode(context.Context, *MsgStoreCode) (*MsgStoreCodeResponse, error) + // InstantiateContract creates a new smart contract instance for the given + // code id. + InstantiateContract(context.Context, *MsgInstantiateContract) (*MsgInstantiateContractResponse, error) + // InstantiateContract2 creates a new smart contract instance for the given + // code id with a predictable address + InstantiateContract2(context.Context, *MsgInstantiateContract2) (*MsgInstantiateContract2Response, error) + // Execute submits the given message data to a smart contract + ExecuteContract(context.Context, *MsgExecuteContract) (*MsgExecuteContractResponse, error) + // Migrate runs a code upgrade/ downgrade for a smart contract MigrateContract(context.Context, *MsgMigrateContract) (*MsgMigrateContractResponse, error) // UpdateAdmin sets a new admin for a smart contract UpdateAdmin(context.Context, *MsgUpdateAdmin) (*MsgUpdateAdminResponse, error) @@ -1131,6 +1615,26 @@ type MsgServer interface { // // Since: 0.40 UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // SudoContract defines a governance operation for calling sudo + // on a contract. The authority is defined in the keeper. + // + // Since: 0.40 + SudoContract(context.Context, *MsgSudoContract) (*MsgSudoContractResponse, error) + // PinCodes defines a governance operation for pinning a set of + // code ids in the wasmvm cache. The authority is defined in the keeper. + // + // Since: 0.40 + PinCodes(context.Context, *MsgPinCodes) (*MsgPinCodesResponse, error) + // UnpinCodes defines a governance operation for unpinning a set of + // code ids in the wasmvm cache. The authority is defined in the keeper. + // + // Since: 0.40 + UnpinCodes(context.Context, *MsgUnpinCodes) (*MsgUnpinCodesResponse, error) + // StoreAndInstantiateContract defines a governance operation for storing + // and instantiating the contract. The authority is defined in the keeper. + // + // Since: 0.40 + StoreAndInstantiateContract(context.Context, *MsgStoreAndInstantiateContract) (*MsgStoreAndInstantiateContractResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1172,6 +1676,22 @@ func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateP return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (*UnimplementedMsgServer) SudoContract(ctx context.Context, req *MsgSudoContract) (*MsgSudoContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SudoContract not implemented") +} + +func (*UnimplementedMsgServer) PinCodes(ctx context.Context, req *MsgPinCodes) (*MsgPinCodesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PinCodes not implemented") +} + +func (*UnimplementedMsgServer) UnpinCodes(ctx context.Context, req *MsgUnpinCodes) (*MsgUnpinCodesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnpinCodes not implemented") +} + +func (*UnimplementedMsgServer) StoreAndInstantiateContract(ctx context.Context, req *MsgStoreAndInstantiateContract) (*MsgStoreAndInstantiateContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StoreAndInstantiateContract not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } @@ -1338,6 +1858,78 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_SudoContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSudoContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SudoContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1.Msg/SudoContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SudoContract(ctx, req.(*MsgSudoContract)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_PinCodes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPinCodes) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PinCodes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1.Msg/PinCodes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PinCodes(ctx, req.(*MsgPinCodes)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UnpinCodes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUnpinCodes) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UnpinCodes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1.Msg/UnpinCodes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UnpinCodes(ctx, req.(*MsgUnpinCodes)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_StoreAndInstantiateContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgStoreAndInstantiateContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).StoreAndInstantiateContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1.Msg/StoreAndInstantiateContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).StoreAndInstantiateContract(ctx, req.(*MsgStoreAndInstantiateContract)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmwasm.wasm.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -1378,6 +1970,22 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "SudoContract", + Handler: _Msg_SudoContract_Handler, + }, + { + MethodName: "PinCodes", + Handler: _Msg_PinCodes_Handler, + }, + { + MethodName: "UnpinCodes", + Handler: _Msg_UnpinCodes_Handler, + }, + { + MethodName: "StoreAndInstantiateContract", + Handler: _Msg_StoreAndInstantiateContract_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmwasm/wasm/v1/tx.proto", @@ -2125,165 +2733,424 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgSudoContract) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *MsgStoreCode) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgSudoContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSudoContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Msg) > 0 { + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) + i = encodeVarintTx(dAtA, i, uint64(len(m.Msg))) + i-- + dAtA[i] = 0x1a } - l = len(m.WASMByteCode) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintTx(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0x12 } - if m.InstantiatePermission != nil { - l = m.InstantiatePermission.Size() - n += 1 + l + sovTx(uint64(l)) + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *MsgStoreCodeResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgSudoContractResponse) 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 *MsgSudoContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSudoContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.CodeID != 0 { - n += 1 + sovTx(uint64(m.CodeID)) - } - l = len(m.Checksum) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *MsgInstantiateContract) Size() (n int) { - if m == nil { - return 0 +func (m *MsgPinCodes) 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 *MsgPinCodes) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPinCodes) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.CodeID != 0 { - n += 1 + sovTx(uint64(m.CodeID)) - } - l = len(m.Label) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.CodeIDs) > 0 { + dAtA5 := make([]byte, len(m.CodeIDs)*10) + var j4 int + for _, num := range m.CodeIDs { + for num >= 1<<7 { + dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j4++ + } + dAtA5[j4] = uint8(num) + j4++ + } + i -= j4 + copy(dAtA[i:], dAtA5[:j4]) + i = encodeVarintTx(dAtA, i, uint64(j4)) + i-- + dAtA[i] = 0x12 } - l = len(m.Msg) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa } - if len(m.Funds) > 0 { - for _, e := range m.Funds { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } + return len(dAtA) - i, nil +} + +func (m *MsgPinCodesResponse) 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 n + return dAtA[:n], nil } -func (m *MsgInstantiateContract2) Size() (n int) { - if m == nil { - return 0 +func (m *MsgPinCodesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPinCodesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUnpinCodes) 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 *MsgUnpinCodes) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnpinCodes) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.CodeIDs) > 0 { + dAtA7 := make([]byte, len(m.CodeIDs)*10) + var j6 int + for _, num := range m.CodeIDs { + for num >= 1<<7 { + dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j6++ + } + dAtA7[j6] = uint8(num) + j6++ + } + i -= j6 + copy(dAtA[i:], dAtA7[:j6]) + i = encodeVarintTx(dAtA, i, uint64(j6)) + i-- + dAtA[i] = 0x12 } - l = len(m.Admin) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa } - if m.CodeID != 0 { - n += 1 + sovTx(uint64(m.CodeID)) + return len(dAtA) - i, nil +} + +func (m *MsgUnpinCodesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - l = len(m.Label) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + return dAtA[:n], nil +} + +func (m *MsgUnpinCodesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnpinCodesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgStoreAndInstantiateContract) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - l = len(m.Msg) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + return dAtA[:n], nil +} + +func (m *MsgStoreAndInstantiateContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgStoreAndInstantiateContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CodeHash) > 0 { + i -= len(m.CodeHash) + copy(dAtA[i:], m.CodeHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.CodeHash))) + i-- + dAtA[i] = 0x62 + } + if len(m.Builder) > 0 { + i -= len(m.Builder) + copy(dAtA[i:], m.Builder) + i = encodeVarintTx(dAtA, i, uint64(len(m.Builder))) + i-- + dAtA[i] = 0x5a + } + if len(m.Source) > 0 { + i -= len(m.Source) + copy(dAtA[i:], m.Source) + i = encodeVarintTx(dAtA, i, uint64(len(m.Source))) + i-- + dAtA[i] = 0x52 } if len(m.Funds) > 0 { - for _, e := range m.Funds { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) + 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a } } - l = len(m.Salt) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Msg) > 0 { + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) + i = encodeVarintTx(dAtA, i, uint64(len(m.Msg))) + i-- + dAtA[i] = 0x42 } - if m.FixMsg { - n += 2 + if len(m.Label) > 0 { + i -= len(m.Label) + copy(dAtA[i:], m.Label) + i = encodeVarintTx(dAtA, i, uint64(len(m.Label))) + i-- + dAtA[i] = 0x3a } - return n + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0x32 + } + if m.UnpinCode { + i-- + if m.UnpinCode { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if m.InstantiatePermission != nil { + { + size, err := m.InstantiatePermission.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.WASMByteCode) > 0 { + i -= len(m.WASMByteCode) + copy(dAtA[i:], m.WASMByteCode) + i = encodeVarintTx(dAtA, i, uint64(len(m.WASMByteCode))) + i-- + dAtA[i] = 0x1a + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *MsgInstantiateContractResponse) Size() (n int) { +func (m *MsgStoreAndInstantiateContractResponse) 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 *MsgStoreAndInstantiateContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgStoreAndInstantiateContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} + +func (m *MsgStoreCode) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Address) + l = len(m.Sender) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Data) + l = len(m.WASMByteCode) if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.InstantiatePermission != nil { + l = m.InstantiatePermission.Size() + n += 1 + l + sovTx(uint64(l)) + } return n } -func (m *MsgInstantiateContract2Response) Size() (n int) { +func (m *MsgStoreCodeResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.CodeID != 0 { + n += 1 + sovTx(uint64(m.CodeID)) } - l = len(m.Data) + l = len(m.Checksum) if l > 0 { n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgExecuteContract) Size() (n int) { +func (m *MsgInstantiateContract) Size() (n int) { if m == nil { return 0 } @@ -2293,7 +3160,14 @@ func (m *MsgExecuteContract) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Contract) + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.CodeID != 0 { + n += 1 + sovTx(uint64(m.CodeID)) + } + l = len(m.Label) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -2310,30 +3184,132 @@ func (m *MsgExecuteContract) Size() (n int) { return n } -func (m *MsgExecuteContractResponse) Size() (n int) { +func (m *MsgInstantiateContract2) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Data) + l = len(m.Sender) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - return n -} - -func (m *MsgMigrateContract) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) + l = len(m.Admin) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Contract) + if m.CodeID != 0 { + n += 1 + sovTx(uint64(m.CodeID)) + } + l = len(m.Label) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Funds) > 0 { + for _, e := range m.Funds { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Salt) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.FixMsg { + n += 2 + } + return n +} + +func (m *MsgInstantiateContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgInstantiateContract2Response) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgExecuteContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Funds) > 0 { + for _, e := range m.Funds { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgExecuteContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMigrateContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Contract) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -2433,51 +3409,1495 @@ func (m *MsgUpdateInstantiateConfig) Size() (n int) { l = m.NewInstantiatePermission.Size() n += 1 + l + sovTx(uint64(l)) } - return n -} + return n +} + +func (m *MsgUpdateInstantiateConfigResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSudoContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSudoContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgPinCodes) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.CodeIDs) > 0 { + l = 0 + for _, e := range m.CodeIDs { + l += sovTx(uint64(e)) + } + n += 1 + sovTx(uint64(l)) + l + } + return n +} + +func (m *MsgPinCodesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUnpinCodes) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.CodeIDs) > 0 { + l = 0 + for _, e := range m.CodeIDs { + l += sovTx(uint64(e)) + } + n += 1 + sovTx(uint64(l)) + l + } + return n +} + +func (m *MsgUnpinCodesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgStoreAndInstantiateContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.WASMByteCode) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.InstantiatePermission != nil { + l = m.InstantiatePermission.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.UnpinCode { + n += 2 + } + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Label) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Funds) > 0 { + for _, e := range m.Funds { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Source) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Builder) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.CodeHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgStoreAndInstantiateContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} + +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +func (m *MsgStoreCode) 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 ErrIntOverflowTx + } + 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: MsgStoreCode: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgStoreCode: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgStoreCodeResponse) 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 ErrIntOverflowTx + } + 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: MsgStoreCodeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgStoreCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Checksum", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Checksum = append(m.Checksum[:0], dAtA[iNdEx:postIndex]...) + if m.Checksum == nil { + m.Checksum = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgInstantiateContract) 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 ErrIntOverflowTx + } + 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: MsgInstantiateContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInstantiateContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Label = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 6: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgInstantiateContract2) 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 ErrIntOverflowTx + } + 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: MsgInstantiateContract2: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInstantiateContract2: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Label = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 6: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 7: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 8: + 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 ErrIntOverflowTx + } + 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 := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgInstantiateContractResponse) 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 ErrIntOverflowTx + } + 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: MsgInstantiateContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInstantiateContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgInstantiateContract2Response) 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 ErrIntOverflowTx + } + 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: MsgInstantiateContract2Response: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInstantiateContract2Response: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgExecuteContract) 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 ErrIntOverflowTx + } + 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: MsgExecuteContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 5: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func (m *MsgUpdateInstantiateConfigResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n + return nil } -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgExecuteContractResponse) 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 ErrIntOverflowTx + } + 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: MsgExecuteContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *MsgStoreCode) Unmarshal(dAtA []byte) error { +func (m *MsgMigrateContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2500,10 +4920,10 @@ func (m *MsgStoreCode) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgStoreCode: wiretype end group for non-group") + return fmt.Errorf("proto: MsgMigrateContract: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgStoreCode: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgMigrateContract: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2540,9 +4960,9 @@ func (m *MsgStoreCode) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WASMByteCode", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2552,31 +4972,48 @@ func (m *MsgStoreCode) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.WASMByteCode = append(m.WASMByteCode[:0], dAtA[iNdEx:postIndex]...) - if m.WASMByteCode == nil { - m.WASMByteCode = []byte{} - } + m.Contract = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 3: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InstantiatePermission", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2586,26 +5023,24 @@ func (m *MsgStoreCode) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } 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 + m.Msg = append(m.Msg[:0], dAtA[iNdEx:postIndex]...) + if m.Msg == nil { + m.Msg = []byte{} } iNdEx = postIndex default: @@ -2630,7 +5065,7 @@ func (m *MsgStoreCode) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgStoreCodeResponse) Unmarshal(dAtA []byte) error { +func (m *MsgMigrateContractResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2653,34 +5088,15 @@ func (m *MsgStoreCodeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgStoreCodeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgMigrateContractResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgStoreCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgMigrateContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CodeID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Checksum", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -2707,9 +5123,9 @@ func (m *MsgStoreCodeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Checksum = append(m.Checksum[:0], dAtA[iNdEx:postIndex]...) - if m.Checksum == nil { - m.Checksum = []byte{} + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} } iNdEx = postIndex default: @@ -2734,7 +5150,7 @@ func (m *MsgStoreCodeResponse) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateAdmin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2757,10 +5173,10 @@ func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgInstantiateContract: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateAdmin: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgInstantiateContract: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateAdmin: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2797,7 +5213,7 @@ func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2825,30 +5241,11 @@ func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Admin = string(dAtA[iNdEx:postIndex]) + m.NewAdmin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CodeID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Label", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2876,13 +5273,115 @@ func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Label = string(dAtA[iNdEx:postIndex]) + m.Contract = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgUpdateAdminResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgClearAdmin) 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 ErrIntOverflowTx + } + 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: MsgClearAdmin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClearAdmin: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2892,31 +5391,29 @@ func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Msg = append(m.Msg[:0], dAtA[iNdEx:postIndex]...) - if m.Msg == nil { - m.Msg = []byte{} - } + m.Sender = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Funds", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2926,26 +5423,75 @@ func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } 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 { + m.Contract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { return err } - iNdEx = postIndex + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgClearAdminResponse) 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 ErrIntOverflowTx + } + 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: MsgClearAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClearAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2968,7 +5514,7 @@ func (m *MsgInstantiateContract) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgInstantiateContract2) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateInstantiateConfig) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2991,10 +5537,10 @@ func (m *MsgInstantiateContract2) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgInstantiateContract2: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateInstantiateConfig: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgInstantiateContract2: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateInstantiateConfig: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3030,38 +5576,6 @@ func (m *MsgInstantiateContract2) Unmarshal(dAtA []byte) error { m.Sender = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - 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 ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Admin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CodeID", wireType) } @@ -3080,75 +5594,9 @@ func (m *MsgInstantiateContract2) Unmarshal(dAtA []byte) error { break } } - case 4: - 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 ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Label = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - 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 6: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Funds", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NewInstantiatePermission", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3175,65 +5623,13 @@ func (m *MsgInstantiateContract2) Unmarshal(dAtA []byte) error { 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 7: - 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF + if m.NewInstantiatePermission == nil { + m.NewInstantiatePermission = &AccessConfig{} } - m.Salt = append(m.Salt[:0], dAtA[iNdEx:postIndex]...) - if m.Salt == nil { - m.Salt = []byte{} + if err := m.NewInstantiatePermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex - case 8: - 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 ErrIntOverflowTx - } - 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 := skipTx(dAtA[iNdEx:]) @@ -3256,7 +5652,7 @@ func (m *MsgInstantiateContract2) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgInstantiateContractResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateInstantiateConfigResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3279,78 +5675,12 @@ func (m *MsgInstantiateContractResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgInstantiateContractResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateInstantiateConfigResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgInstantiateContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateInstantiateConfigResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3373,7 +5703,7 @@ func (m *MsgInstantiateContractResponse) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgInstantiateContract2Response) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3396,15 +5726,15 @@ func (m *MsgInstantiateContract2Response) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgInstantiateContract2Response: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgInstantiateContract2Response: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3432,13 +5762,13 @@ func (m *MsgInstantiateContract2Response) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3448,24 +5778,23 @@ func (m *MsgInstantiateContract2Response) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: @@ -3490,7 +5819,7 @@ func (m *MsgInstantiateContract2Response) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgExecuteContract) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3513,15 +5842,66 @@ func (m *MsgExecuteContract) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgExecuteContract: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgExecuteContract: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *MsgSudoContract) 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 ErrIntOverflowTx + } + 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: MsgSudoContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSudoContract: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3549,7 +5929,7 @@ func (m *MsgExecuteContract) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -3617,40 +5997,6 @@ func (m *MsgExecuteContract) Unmarshal(dAtA []byte) error { m.Msg = []byte{} } iNdEx = postIndex - case 5: - 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - 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 := skipTx(dAtA[iNdEx:]) @@ -3673,7 +6019,7 @@ func (m *MsgExecuteContract) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgExecuteContractResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSudoContractResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3696,10 +6042,10 @@ func (m *MsgExecuteContractResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgExecuteContractResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSudoContractResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgExecuteContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSudoContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3758,7 +6104,7 @@ func (m *MsgExecuteContractResponse) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgMigrateContract) Unmarshal(dAtA []byte) error { +func (m *MsgPinCodes) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3781,15 +6127,15 @@ func (m *MsgMigrateContract) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgMigrateContract: wiretype end group for non-group") + return fmt.Errorf("proto: MsgPinCodes: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgMigrateContract: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgPinCodes: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3817,93 +6163,84 @@ func (m *MsgMigrateContract) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Contract = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - 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 ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CodeID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - 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 ErrIntOverflowTx - } - if iNdEx >= l { + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CodeIDs = append(m.CodeIDs, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Msg = append(m.Msg[:0], dAtA[iNdEx:postIndex]...) - if m.Msg == nil { - m.Msg = []byte{} + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.CodeIDs) == 0 { + m.CodeIDs = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CodeIDs = append(m.CodeIDs, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field CodeIDs", wireType) } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3926,69 +6263,35 @@ func (m *MsgMigrateContract) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgMigrateContractResponse) Unmarshal(dAtA []byte) error { +func (m *MsgPinCodesResponse) 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 ErrIntOverflowTx - } - 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: MsgMigrateContractResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgMigrateContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx } - if postIndex > l { + if iNdEx >= l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - iNdEx = postIndex + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPinCodesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPinCodesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4011,7 +6314,7 @@ func (m *MsgMigrateContractResponse) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgUpdateAdmin) Unmarshal(dAtA []byte) error { +func (m *MsgUnpinCodes) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4034,15 +6337,15 @@ func (m *MsgUpdateAdmin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateAdmin: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUnpinCodes: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateAdmin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUnpinCodes: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4070,72 +6373,84 @@ func (m *MsgUpdateAdmin) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NewAdmin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CodeIDs = append(m.CodeIDs, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.CodeIDs) == 0 { + m.CodeIDs = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CodeIDs = append(m.CodeIDs, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field CodeIDs", wireType) } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Contract = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4158,7 +6473,7 @@ func (m *MsgUpdateAdmin) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgUpdateAdminResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUnpinCodesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4181,10 +6496,10 @@ func (m *MsgUpdateAdminResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateAdminResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUnpinCodesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUnpinCodesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -4209,7 +6524,7 @@ func (m *MsgUpdateAdminResponse) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgClearAdmin) Unmarshal(dAtA []byte) error { +func (m *MsgStoreAndInstantiateContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4232,15 +6547,15 @@ func (m *MsgClearAdmin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgClearAdmin: wiretype end group for non-group") + return fmt.Errorf("proto: MsgStoreAndInstantiateContract: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgClearAdmin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgStoreAndInstantiateContract: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4268,13 +6583,13 @@ func (m *MsgClearAdmin) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WASMByteCode", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4284,129 +6599,117 @@ func (m *MsgClearAdmin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Contract = string(dAtA[iNdEx:postIndex]) + m.WASMByteCode = append(m.WASMByteCode[:0], dAtA[iNdEx:postIndex]...) + if m.WASMByteCode == nil { + m.WASMByteCode = []byte{} + } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InstantiatePermission", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if msglen < 0 { + return ErrInvalidLengthTx } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *MsgClearAdminResponse) 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 ErrIntOverflowTx + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if m.InstantiatePermission == nil { + m.InstantiatePermission = &AccessConfig{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgClearAdminResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgClearAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { + if err := m.InstantiatePermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UnpinCode", wireType) } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *MsgUpdateInstantiateConfig) 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 ErrIntOverflowTx + m.UnpinCode = bool(v != 0) + case 6: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx } - if iNdEx >= l { + if postIndex > 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: MsgUpdateInstantiateConfig: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateInstantiateConfig: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Label", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4434,13 +6737,13 @@ func (m *MsgUpdateInstantiateConfig) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.Label = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CodeID", wireType) + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) } - m.CodeID = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4450,14 +6753,29 @@ func (m *MsgUpdateInstantiateConfig) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CodeID |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 3: + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewInstantiatePermission", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Funds", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4484,64 +6802,109 @@ func (m *MsgUpdateInstantiateConfig) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.NewInstantiatePermission == nil { - m.NewInstantiatePermission = &AccessConfig{} - } - if err := m.NewInstantiatePermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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 := skipTx(dAtA[iNdEx:]) - if err != nil { - return err + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Source", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx } - if (iNdEx + skippy) > l { + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - -func (m *MsgUpdateInstantiateConfigResponse) 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 ErrIntOverflowTx + m.Source = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Builder", wireType) } - if iNdEx >= l { + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.Builder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeHash", wireType) } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateInstantiateConfigResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateInstantiateConfigResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeHash = append(m.CodeHash[:0], dAtA[iNdEx:postIndex]...) + if m.CodeHash == nil { + m.CodeHash = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4564,7 +6927,7 @@ func (m *MsgUpdateInstantiateConfigResponse) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { +func (m *MsgStoreAndInstantiateContractResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4587,15 +6950,15 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + return fmt.Errorf("proto: MsgStoreAndInstantiateContractResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgStoreAndInstantiateContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4623,13 +6986,13 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Authority = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4639,23 +7002,24 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} } iNdEx = postIndex default: @@ -4680,57 +7044,6 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { return nil } -func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx - } - 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: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} - func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/wasm/types/tx_test.go b/x/wasm/types/tx_test.go index 628f259503..355beae1bb 100644 --- a/x/wasm/types/tx_test.go +++ b/x/wasm/types/tx_test.go @@ -748,3 +748,392 @@ func TestMsgUpdateInstantiateConfig(t *testing.T) { }) } } + +func TestMsgUpdateParamsValidation(t *testing.T) { + bad, err := sdk.AccAddressFromHexUnsafe("012345") + require.NoError(t, err) + badAddress := bad.String() + // proper address size + goodAddress := sdk.AccAddress(make([]byte, 20)).String() + + specs := map[string]struct { + src MsgUpdateParams + expErr bool + }{ + "all good": { + src: MsgUpdateParams{ + Authority: goodAddress, + Params: DefaultParams(), + }, + }, + "bad authority": { + src: MsgUpdateParams{ + Authority: badAddress, + Params: DefaultParams(), + }, + expErr: true, + }, + "empty authority": { + src: MsgUpdateParams{ + Params: DefaultParams(), + }, + 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) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgPinCodesValidation(t *testing.T) { + bad, err := sdk.AccAddressFromHexUnsafe("012345") + require.NoError(t, err) + badAddress := bad.String() + // proper address size + goodAddress := sdk.AccAddress(make([]byte, 20)).String() + + specs := map[string]struct { + src MsgPinCodes + expErr bool + }{ + "all good": { + src: MsgPinCodes{ + Authority: goodAddress, + CodeIDs: []uint64{1}, + }, + }, + "bad authority": { + src: MsgPinCodes{ + Authority: badAddress, + CodeIDs: []uint64{1}, + }, + expErr: true, + }, + "empty authority": { + src: MsgPinCodes{ + CodeIDs: []uint64{1}, + }, + expErr: true, + }, + "empty code ids": { + src: MsgPinCodes{ + Authority: goodAddress, + }, + 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) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgUnpinCodesValidation(t *testing.T) { + bad, err := sdk.AccAddressFromHexUnsafe("012345") + require.NoError(t, err) + badAddress := bad.String() + // proper address size + goodAddress := sdk.AccAddress(make([]byte, 20)).String() + + specs := map[string]struct { + src MsgUnpinCodes + expErr bool + }{ + "all good": { + src: MsgUnpinCodes{ + Authority: goodAddress, + CodeIDs: []uint64{1}, + }, + }, + "bad authority": { + src: MsgUnpinCodes{ + Authority: badAddress, + CodeIDs: []uint64{1}, + }, + expErr: true, + }, + "empty authority": { + src: MsgUnpinCodes{ + CodeIDs: []uint64{1}, + }, + expErr: true, + }, + "empty code ids": { + src: MsgUnpinCodes{ + Authority: goodAddress, + }, + 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) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgSudoContractValidation(t *testing.T) { + bad, err := sdk.AccAddressFromHexUnsafe("012345") + require.NoError(t, err) + badAddress := bad.String() + // proper address size + goodAddress := sdk.AccAddress(make([]byte, 20)).String() + anotherGoodAddress := sdk.AccAddress(bytes.Repeat([]byte{0x2}, 20)).String() + + specs := map[string]struct { + src MsgSudoContract + expErr bool + }{ + "all good": { + src: MsgSudoContract{ + Authority: goodAddress, + Contract: anotherGoodAddress, + Msg: []byte("{}"), + }, + }, + "bad authority": { + src: MsgSudoContract{ + Authority: badAddress, + Contract: anotherGoodAddress, + Msg: []byte("{}"), + }, + expErr: true, + }, + "empty authority": { + src: MsgSudoContract{ + Contract: anotherGoodAddress, + Msg: []byte("{}"), + }, + expErr: true, + }, + "bad contract addr": { + src: MsgSudoContract{ + Authority: goodAddress, + Contract: badAddress, + Msg: []byte("{}"), + }, + expErr: true, + }, + "empty contract addr": { + src: MsgSudoContract{ + Authority: goodAddress, + Msg: []byte("{}"), + }, + expErr: true, + }, + "non json sudoMsg": { + src: MsgSudoContract{ + Authority: goodAddress, + Contract: anotherGoodAddress, + Msg: []byte("invalid json"), + }, + expErr: true, + }, + "empty sudoMsg": { + src: MsgSudoContract{ + Authority: goodAddress, + Contract: anotherGoodAddress, + }, + 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) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgStoreAndInstantiateContractValidation(t *testing.T) { + bad, err := sdk.AccAddressFromHexUnsafe("012345") + require.NoError(t, err) + badAddress := bad.String() + // proper address size + goodAddress := sdk.AccAddress(make([]byte, 20)).String() + sdk.GetConfig().SetAddressVerifier(VerifyAddressLen()) + + cases := map[string]struct { + msg MsgStoreAndInstantiateContract + valid bool + }{ + "empty": { + msg: MsgStoreAndInstantiateContract{}, + valid: false, + }, + "correct minimal": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + Msg: []byte("{}"), + WASMByteCode: []byte("foo"), + }, + valid: true, + }, + "missing byte code": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + Msg: []byte("{}"), + }, + valid: false, + }, + "missing label": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Msg: []byte("{}"), + WASMByteCode: []byte("foo"), + }, + valid: false, + }, + "label too long": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: strings.Repeat("food", 33), + Msg: []byte("{}"), + WASMByteCode: []byte("foo"), + }, + valid: false, + }, + "bad sender minimal": { + msg: MsgStoreAndInstantiateContract{ + Authority: badAddress, + Label: "foo", + Msg: []byte("{}"), + WASMByteCode: []byte("foo"), + }, + valid: false, + }, + "bad admin": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + Msg: []byte("{}"), + WASMByteCode: []byte("foo"), + Admin: badAddress, + }, + valid: false, + }, + "correct maximal": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + Msg: []byte(`{"some": "data"}`), + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(200)}}, + WASMByteCode: []byte("foo"), + InstantiatePermission: &AllowEverybody, + UnpinCode: true, + Admin: goodAddress, + Source: "http://source.com", + Builder: "builder", + CodeHash: []byte("{}"), + }, + valid: true, + }, + "invalid source": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + Msg: []byte("{}"), + WASMByteCode: []byte("foo"), + Admin: goodAddress, + Source: "source", + }, + valid: false, + }, + "empty builder": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + Msg: []byte("{}"), + WASMByteCode: []byte("foo"), + Admin: goodAddress, + Source: "http://source.com", + }, + valid: false, + }, + "empty code hash": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + Msg: []byte("{}"), + WASMByteCode: []byte("foo"), + Admin: goodAddress, + Source: "http://source.com", + Builder: "builder", + }, + valid: false, + }, + "negative funds": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + Msg: []byte(`{"some": "data"}`), + // we cannot use sdk.NewCoin() constructors as they panic on creating invalid data (before we can test) + Funds: sdk.Coins{sdk.Coin{Denom: "foobar", Amount: sdk.NewInt(-200)}}, + WASMByteCode: []byte("foo"), + }, + valid: false, + }, + "non json init msg": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + Msg: []byte("invalid-json"), + WASMByteCode: []byte("foo"), + }, + valid: false, + }, + "empty init msg": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + Label: "foo", + WASMByteCode: []byte("foo"), + }, + valid: false, + }, + "invalid InstantiatePermission": { + msg: MsgStoreAndInstantiateContract{ + Authority: goodAddress, + WASMByteCode: []byte("foo"), + Label: "foo", + Msg: []byte(`{"some": "data"}`), + InstantiatePermission: &AccessConfig{Permission: AccessTypeOnlyAddress, Address: badAddress}, + }, + valid: false, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + if tc.valid { + assert.NoError(t, err) + } else { + assert.Error(t, err) + } + }) + } +}