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

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

option go_package = "github.com/CosmWasm/wasmd/x/wasm/types";
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
message StoreCodeProposal {
  // Title is a short summary
  string title = 1;
  // Description is a human readable text
  string description = 2;
  // RunAs is the address that is passed to the contract's environment as sender
  string run_as = 3;
  // WASMByteCode can be raw or gzip compressed
  bytes wasm_byte_code = 4 [ (gogoproto.customname) = "WASMByteCode" ];
  // Used in v1beta1
  reserved 5, 6;
  // InstantiatePermission to apply on contract creation, optional
  AccessConfig instantiate_permission = 7;
}

// InstantiateContractProposal gov proposal content type to instantiate a
// contract.
message InstantiateContractProposal {
  // Title is a short summary
  string title = 1;
  // Description is a human readable text
  string description = 2;
  // RunAs is the address that is passed to the contract's environment as sender
  string run_as = 3;
  // Admin is an optional address that can execute migrations
  string admin = 4;
  // CodeID is the reference to the stored WASM code
  uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ];
  // Label is optional metadata to be stored with a constract instance.
  string label = 6;
  // Msg json encoded message to be passed to the contract on instantiation
  bytes msg = 7 [ (gogoproto.casttype) = "RawContractMessage" ];
  // Funds coins that are transferred to the contract on instantiation
  repeated cosmos.base.v1beta1.Coin funds = 8 [
    (gogoproto.nullable) = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
  ];
}

// MigrateContractProposal gov proposal content type to migrate a contract.
message MigrateContractProposal {
  // Title is a short summary
  string title = 1;
  // Description is a human readable text
  string description = 2;
  // Note: skipping 3 as this was previously used for unneeded run_as

  // Contract is the address of the smart contract
  string contract = 4;
  // CodeID references the new WASM codesudo
  uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ];
  // Msg json encoded message to be passed to the contract on migration
  bytes msg = 6 [ (gogoproto.casttype) = "RawContractMessage" ];
}

// SudoContractProposal gov proposal content type to call sudo on a contract.
message SudoContractProposal {
  // Title is a short summary
  string title = 1;
  // Description is a human readable text
  string description = 2;
  // Contract is the address of the smart contract
  string contract = 3;
  // Msg json encoded message to be passed to the contract as sudo
  bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ];
}

// ExecuteContractProposal gov proposal content type to call execute on a
// contract.
message ExecuteContractProposal {
  // Title is a short summary
  string title = 1;
  // Description is a human readable text
  string description = 2;
  // RunAs is the address that is passed to the contract's environment as sender
  string run_as = 3;
  // Contract is the address of the smart contract
  string contract = 4;
  // Msg json encoded message to be passed to the contract as execute
  bytes msg = 5 [ (gogoproto.casttype) = "RawContractMessage" ];
  // Funds coins that are transferred to the contract on instantiation
  repeated cosmos.base.v1beta1.Coin funds = 6 [
    (gogoproto.nullable) = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
  ];
}

// UpdateAdminProposal gov proposal content type to set an admin for a contract.
message UpdateAdminProposal {
  // Title is a short summary
  string title = 1;
  // Description is a human readable text
  string description = 2;
  // NewAdmin address to be set
  string new_admin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ];
  // Contract is the address of the smart contract
  string contract = 4;
}

// ClearAdminProposal gov proposal content type to clear the admin of a
// contract.
message ClearAdminProposal {
  // Title is a short summary
  string title = 1;
  // Description is a human readable text
  string description = 2;
  // Contract is the address of the smart contract
  string contract = 3;
}

// PinCodesProposal gov proposal content type to pin a set of code ids in the
// wasmvm cache.
message PinCodesProposal {
  // Title is a short summary
  string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ];
  // Description is a human readable text
  string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ];
  // CodeIDs references the new WASM codes
  repeated uint64 code_ids = 3 [
    (gogoproto.customname) = "CodeIDs",
    (gogoproto.moretags) = "yaml:\"code_ids\""
  ];
}

// UnpinCodesProposal gov proposal content type to unpin a set of code ids in
// the wasmvm cache.
message UnpinCodesProposal {
  // Title is a short summary
  string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ];
  // Description is a human readable text
  string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ];
  // CodeIDs references the WASM codes
  repeated uint64 code_ids = 3 [
    (gogoproto.customname) = "CodeIDs",
    (gogoproto.moretags) = "yaml:\"code_ids\""
  ];
}
