syntax = "proto3";
package cosmwasm.wasm.v1;

import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "gogoproto/gogo.proto";
import "cosmwasm/wasm/v1/types.proto";
import "cosmos_proto/cosmos.proto";
import "amino/amino.proto";

option go_package = "github.com/CosmWasm/wasmd/x/wasm/types";
option (gogoproto.goproto_getters_all) = false;

// Msg defines the wasm Msg service.
service Msg {
  option (cosmos.msg.v1.service) = true;

  // StoreCode to submit Wasm code to the system
  rpc StoreCode(MsgStoreCode) returns (MsgStoreCodeResponse);
  //  InstantiateContract creates a new smart contract instance for the given
  //  code id.
  rpc InstantiateContract(MsgInstantiateContract)
      returns (MsgInstantiateContractResponse);
  //  InstantiateContract2 creates a new smart contract instance for the given
  //  code id with a predictable address
  rpc InstantiateContract2(MsgInstantiateContract2)
      returns (MsgInstantiateContract2Response);
  // Execute submits the given message data to a smart contract
  rpc ExecuteContract(MsgExecuteContract) returns (MsgExecuteContractResponse);
  // Migrate runs a code upgrade/ downgrade for a smart contract
  rpc MigrateContract(MsgMigrateContract) returns (MsgMigrateContractResponse);
  // UpdateAdmin sets a new admin for a smart contract
  rpc UpdateAdmin(MsgUpdateAdmin) returns (MsgUpdateAdminResponse);
  // ClearAdmin removes any admin stored for a smart contract
  rpc ClearAdmin(MsgClearAdmin) returns (MsgClearAdminResponse);
  // UpdateInstantiateConfig updates instantiate config for a smart contract
  rpc UpdateInstantiateConfig(MsgUpdateInstantiateConfig)
      returns (MsgUpdateInstantiateConfigResponse);
  // UpdateParams defines a governance operation for updating the x/wasm
  // module parameters. The authority is defined in the keeper.
  //
  // 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);
  // RemoveCodeUploadParamsAddresses defines a governance operation for
  // removing addresses from code upload params.
  // The authority is defined in the keeper.
  rpc RemoveCodeUploadParamsAddresses(MsgRemoveCodeUploadParamsAddresses)
      returns (MsgRemoveCodeUploadParamsAddressesResponse);
  // AddCodeUploadParamsAddresses defines a governance operation for
  // adding addresses to code upload params.
  // The authority is defined in the keeper.
  rpc AddCodeUploadParamsAddresses(MsgAddCodeUploadParamsAddresses)
      returns (MsgAddCodeUploadParamsAddressesResponse);
  // StoreAndMigrateContract defines a governance operation for storing
  // and migrating the contract. The authority is defined in the keeper.
  //
  // Since: 0.42
  rpc StoreAndMigrateContract(MsgStoreAndMigrateContract)
      returns (MsgStoreAndMigrateContractResponse);
  // UpdateContractLabel sets a new label for a smart contract
  //
  // Since: 0.43
  rpc UpdateContractLabel(MsgUpdateContractLabel)
      returns (MsgUpdateContractLabelResponse);
}

// MsgStoreCode submit Wasm code to the system
message MsgStoreCode {
  option (amino.name) = "wasm/MsgStoreCode";
  option (cosmos.msg.v1.signer) = "sender";

  // Sender is the actor that signed the messages
  string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // WASMByteCode can be raw or gzip compressed
  bytes wasm_byte_code = 2 [ (gogoproto.customname) = "WASMByteCode" ];
  // Used in v1beta1
  reserved 3, 4;
  // InstantiatePermission access control to apply on contract creation,
  // optional
  AccessConfig instantiate_permission = 5;
}
// MsgStoreCodeResponse returns store result data.
message MsgStoreCodeResponse {
  // CodeID is the reference to the stored WASM code
  uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ];
  // Checksum is the sha256 hash of the stored code
  bytes checksum = 2;
}

// MsgInstantiateContract create a new smart contract instance for the given
// code id.
message MsgInstantiateContract {
  option (amino.name) = "wasm/MsgInstantiateContract";
  option (cosmos.msg.v1.signer) = "sender";

  // Sender is the that actor that signed the messages
  string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Admin is an optional address that can execute migrations
  string admin = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // CodeID is the reference to the stored WASM code
  uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ];
  // Label is optional metadata to be stored with a contract instance.
  string label = 4;
  // Msg json encoded message to be passed to the contract on instantiation
  bytes msg = 5 [
    (gogoproto.casttype) = "RawContractMessage",
    (amino.encoding) = "inline_json"
  ];
  // Funds coins that are transferred to the contract on instantiation
  repeated cosmos.base.v1beta1.Coin funds = 6 [
    (gogoproto.nullable) = false,
    (amino.dont_omitempty) = true,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.encoding) = "legacy_coins"
  ];
}

// MsgInstantiateContractResponse return instantiation result data
message MsgInstantiateContractResponse {
  // Address is the bech32 address of the new contract instance.
  string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Data contains bytes to returned from the contract
  bytes data = 2;
}

// MsgInstantiateContract2 create a new smart contract instance for the given
// code id with a predictable address.
message MsgInstantiateContract2 {
  option (amino.name) = "wasm/MsgInstantiateContract2";
  option (cosmos.msg.v1.signer) = "sender";

  // Sender is the that actor that signed the messages
  string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Admin is an optional address that can execute migrations
  string admin = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // CodeID is the reference to the stored WASM code
  uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ];
  // Label is optional metadata to be stored with a contract instance.
  string label = 4;
  // Msg json encoded message to be passed to the contract on instantiation
  bytes msg = 5 [
    (gogoproto.casttype) = "RawContractMessage",
    (amino.encoding) = "inline_json"
  ];
  // Funds coins that are transferred to the contract on instantiation
  repeated cosmos.base.v1beta1.Coin funds = 6 [
    (gogoproto.nullable) = false,
    (amino.dont_omitempty) = true,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.encoding) = "legacy_coins"
  ];
  // Salt is an arbitrary value provided by the sender. Size can be 1 to 64.
  bytes salt = 7;
  // FixMsg include the msg value into the hash for the predictable address.
  // Default is false
  bool fix_msg = 8;
}

// MsgInstantiateContract2Response return instantiation result data
message MsgInstantiateContract2Response {
  // Address is the bech32 address of the new contract instance.
  string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Data contains bytes to returned from the contract
  bytes data = 2;
}

// MsgExecuteContract submits the given message data to a smart contract
message MsgExecuteContract {
  option (amino.name) = "wasm/MsgExecuteContract";
  option (cosmos.msg.v1.signer) = "sender";

  // Sender is the that actor that signed the messages
  string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Contract is the address of the smart contract
  string contract = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Msg json encoded message to be passed to the contract
  bytes msg = 3 [
    (gogoproto.casttype) = "RawContractMessage",
    (amino.encoding) = "inline_json"
  ];
  // Funds coins that are transferred to the contract on execution
  repeated cosmos.base.v1beta1.Coin funds = 5 [
    (gogoproto.nullable) = false,
    (amino.dont_omitempty) = true,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.encoding) = "legacy_coins"
  ];
}

// MsgExecuteContractResponse returns execution result data.
message MsgExecuteContractResponse {
  // Data contains bytes to returned from the contract
  bytes data = 1;
}

// MsgMigrateContract runs a code upgrade/ downgrade for a smart contract
message MsgMigrateContract {
  option (amino.name) = "wasm/MsgMigrateContract";
  option (cosmos.msg.v1.signer) = "sender";

  // Sender is the that actor that signed the messages
  string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Contract is the address of the smart contract
  string contract = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // CodeID references the new WASM code
  uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ];
  // Msg json encoded message to be passed to the contract on migration
  bytes msg = 4 [
    (gogoproto.casttype) = "RawContractMessage",
    (amino.encoding) = "inline_json"
  ];
}

// MsgMigrateContractResponse returns contract migration result data.
message MsgMigrateContractResponse {
  // Data contains same raw bytes returned as data from the wasm contract.
  // (May be empty)
  bytes data = 1;
}

// MsgUpdateAdmin sets a new admin for a smart contract
message MsgUpdateAdmin {
  option (amino.name) = "wasm/MsgUpdateAdmin";
  option (cosmos.msg.v1.signer) = "sender";

  // Sender is the that actor that signed the messages
  string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // NewAdmin address to be set
  string new_admin = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Contract is the address of the smart contract
  string contract = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// MsgUpdateAdminResponse returns empty data
message MsgUpdateAdminResponse {}

// MsgClearAdmin removes any admin stored for a smart contract
message MsgClearAdmin {
  option (amino.name) = "wasm/MsgClearAdmin";
  option (cosmos.msg.v1.signer) = "sender";

  // Sender is the actor that signed the messages
  string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Contract is the address of the smart contract
  string contract = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// MsgClearAdminResponse returns empty data
message MsgClearAdminResponse {}

// MsgUpdateInstantiateConfig updates instantiate config for a smart contract
message MsgUpdateInstantiateConfig {
  option (amino.name) = "wasm/MsgUpdateInstantiateConfig";
  option (cosmos.msg.v1.signer) = "sender";

  // Sender is the that actor that signed the messages
  string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // CodeID references the stored WASM code
  uint64 code_id = 2 [ (gogoproto.customname) = "CodeID" ];
  // NewInstantiatePermission is the new access control
  AccessConfig new_instantiate_permission = 3;
}

// MsgUpdateInstantiateConfigResponse returns empty data
message MsgUpdateInstantiateConfigResponse {}

// MsgUpdateParams is the MsgUpdateParams request type.
//
// Since: 0.40
message MsgUpdateParams {
  option (amino.name) = "wasm/MsgUpdateParams";
  option (cosmos.msg.v1.signer) = "authority";

  // Authority is the address of the governance account.
  string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

  // params defines the x/wasm parameters to update.
  //
  // NOTE: All parameters must be supplied.
  Params params = 2
      [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: 0.40
message MsgUpdateParamsResponse {}

// MsgSudoContract is the MsgSudoContract request type.
//
// Since: 0.40
message MsgSudoContract {
  option (amino.name) = "wasm/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 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // Msg json encoded message to be passed to the contract as sudo
  bytes msg = 3 [
    (gogoproto.casttype) = "RawContractMessage",
    (amino.encoding) = "inline_json"
  ];
}

// 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 (amino.name) = "wasm/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 (amino.name) = "wasm/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 (amino.name) = "wasm/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 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // 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",
    (amino.encoding) = "inline_json"
  ];
  // Funds coins that are transferred from the authority account to the contract
  // on instantiation
  repeated cosmos.base.v1beta1.Coin funds = 9 [
    (gogoproto.nullable) = false,
    (amino.dont_omitempty) = true,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.encoding) = "legacy_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 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

  // Data contains bytes to returned from the contract
  bytes data = 2;
}

// MsgAddCodeUploadParamsAddresses is the
// MsgAddCodeUploadParamsAddresses request type.
message MsgAddCodeUploadParamsAddresses {
  option (amino.name) = "wasm/MsgAddCodeUploadParamsAddresses";
  option (cosmos.msg.v1.signer) = "authority";

  // Authority is the address of the governance account.
  string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

  repeated string addresses = 2 [ (gogoproto.moretags) = "yaml:\"addresses\"" ];
}

// MsgAddCodeUploadParamsAddressesResponse defines the response
// structure for executing a MsgAddCodeUploadParamsAddresses message.
message MsgAddCodeUploadParamsAddressesResponse {}

// MsgRemoveCodeUploadParamsAddresses is the
// MsgRemoveCodeUploadParamsAddresses request type.
message MsgRemoveCodeUploadParamsAddresses {
  option (amino.name) = "wasm/MsgRemoveCodeUploadParamsAddresses";
  option (cosmos.msg.v1.signer) = "authority";

  // Authority is the address of the governance account.
  string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

  repeated string addresses = 2 [ (gogoproto.moretags) = "yaml:\"addresses\"" ];
}

// MsgRemoveCodeUploadParamsAddressesResponse defines the response
// structure for executing a MsgRemoveCodeUploadParamsAddresses message.
message MsgRemoveCodeUploadParamsAddressesResponse {}

// MsgStoreAndMigrateContract is the MsgStoreAndMigrateContract
// request type.
//
// Since: 0.42
message MsgStoreAndMigrateContract {
  option (amino.name) = "wasm/MsgStoreAndMigrateContract";
  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 = 2 [ (gogoproto.customname) = "WASMByteCode" ];
  // InstantiatePermission to apply on contract creation, optional
  AccessConfig instantiate_permission = 3;
  // Contract is the address of the smart contract
  string contract = 4;
  // Msg json encoded message to be passed to the contract on migration
  bytes msg = 5 [
    (gogoproto.casttype) = "RawContractMessage",
    (amino.encoding) = "inline_json"
  ];
}

// MsgStoreAndMigrateContractResponse defines the response structure
// for executing a MsgStoreAndMigrateContract message.
//
// Since: 0.42
message MsgStoreAndMigrateContractResponse {
  // CodeID is the reference to the stored WASM code
  uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ];
  // Checksum is the sha256 hash of the stored code
  bytes checksum = 2;
  // Data contains bytes to returned from the contract
  bytes data = 3;
}

// MsgUpdateContractLabel sets a new label for a smart contract
message MsgUpdateContractLabel {
  option (amino.name) = "wasm/MsgUpdateContractLabel";
  option (cosmos.msg.v1.signer) = "sender";

  // Sender is the that actor that signed the messages
  string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
  // NewLabel string to be set
  string new_label = 2;
  // Contract is the address of the smart contract
  string contract = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// MsgUpdateContractLabelResponse returns empty data
message MsgUpdateContractLabelResponse {}