Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Port x/wasm module #92

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions proto/wasm/v1/authz.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
syntax = "proto3";
package cosmwasm.wasm.v1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/cerc-io/laconicd/x/wasm/types";
option (gogoproto.goproto_getters_all) = false;

// ContractExecutionAuthorization defines authorization for wasm execute.
// Since: wasmd 0.30
message ContractExecutionAuthorization {
option (cosmos_proto.implements_interface) = "Authorization";

// Grants for contract executions
repeated ContractGrant grants = 1 [ (gogoproto.nullable) = false ];
}

// ContractMigrationAuthorization defines authorization for wasm contract
// migration. Since: wasmd 0.30
message ContractMigrationAuthorization {
option (cosmos_proto.implements_interface) = "Authorization";

// Grants for contract migrations
repeated ContractGrant grants = 1 [ (gogoproto.nullable) = false ];
}

// ContractGrant a granted permission for a single contract
// Since: wasmd 0.30
message ContractGrant {
// Contract is the bech32 address of the smart contract
string contract = 1;

// Limit defines execution limits that are enforced and updated when the grant
// is applied. When the limit lapsed the grant is removed.
google.protobuf.Any limit = 2
[ (cosmos_proto.accepts_interface) = "ContractAuthzLimitX" ];

// Filter define more fine-grained control on the message payload passed
// to the contract in the operation. When no filter applies on execution, the
// operation is prohibited.
google.protobuf.Any filter = 3
[ (cosmos_proto.accepts_interface) = "ContractAuthzFilterX" ];
}

// MaxCallsLimit limited number of calls to the contract. No funds transferable.
// Since: wasmd 0.30
message MaxCallsLimit {
option (cosmos_proto.implements_interface) = "ContractAuthzLimitX";

// Remaining number that is decremented on each execution
uint64 remaining = 1;
}

// MaxFundsLimit defines the maximal amounts that can be sent to the contract.
// Since: wasmd 0.30
message MaxFundsLimit {
option (cosmos_proto.implements_interface) = "ContractAuthzLimitX";

// Amounts is the maximal amount of tokens transferable to the contract.
repeated cosmos.base.v1beta1.Coin amounts = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// CombinedLimit defines the maximal amounts that can be sent to a contract and
// the maximal number of calls executable. Both need to remain >0 to be valid.
// Since: wasmd 0.30
message CombinedLimit {
option (cosmos_proto.implements_interface) = "ContractAuthzLimitX";

// Remaining number that is decremented on each execution
uint64 calls_remaining = 1;
// Amounts is the maximal amount of tokens transferable to the contract.
repeated cosmos.base.v1beta1.Coin amounts = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// AllowAllMessagesFilter is a wildcard to allow any type of contract payload
// message.
// Since: wasmd 0.30
message AllowAllMessagesFilter {
option (cosmos_proto.implements_interface) = "ContractAuthzFilterX";
}

// AcceptedMessageKeysFilter accept only the specific contract message keys in
// the json object to be executed.
// Since: wasmd 0.30
message AcceptedMessageKeysFilter {
option (cosmos_proto.implements_interface) = "ContractAuthzFilterX";

// Messages is the list of unique keys
repeated string keys = 1;
}

// AcceptedMessagesFilter accept only the specific raw contract messages to be
// executed.
// Since: wasmd 0.30
message AcceptedMessagesFilter {
option (cosmos_proto.implements_interface) = "ContractAuthzFilterX";

// Messages is the list of raw contract messages
repeated bytes messages = 1 [ (gogoproto.casttype) = "RawContractMessage" ];
}
46 changes: 46 additions & 0 deletions proto/wasm/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
syntax = "proto3";
package cosmwasm.wasm.v1;

import "gogoproto/gogo.proto";
import "wasm/v1/types.proto";

option go_package = "github.com/cerc-io/laconicd/x/wasm/types";

// GenesisState - genesis state of x/wasm
message GenesisState {
Params params = 1 [ (gogoproto.nullable) = false ];
repeated Code codes = 2
[ (gogoproto.nullable) = false, (gogoproto.jsontag) = "codes,omitempty" ];
repeated Contract contracts = 3 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "contracts,omitempty"
];
repeated Sequence sequences = 4 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "sequences,omitempty"
];
}

// Code struct encompasses CodeInfo and CodeBytes
message Code {
uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ];
CodeInfo code_info = 2 [ (gogoproto.nullable) = false ];
bytes code_bytes = 3;
// Pinned to wasmvm cache
bool pinned = 4;
}

// Contract struct encompasses ContractAddress, ContractInfo, and ContractState
message Contract {
string contract_address = 1;
ContractInfo contract_info = 2 [ (gogoproto.nullable) = false ];
repeated Model contract_state = 3 [ (gogoproto.nullable) = false ];
repeated ContractCodeHistoryEntry contract_code_history = 4
[ (gogoproto.nullable) = false ];
}

// Sequence key and value of an id generation counter
message Sequence {
bytes id_key = 1 [ (gogoproto.customname) = "IDKey" ];
uint64 value = 2;
}
31 changes: 31 additions & 0 deletions proto/wasm/v1/ibc.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
syntax = "proto3";
package cosmwasm.wasm.v1;

import "gogoproto/gogo.proto";

option go_package = "github.com/cerc-io/laconicd/x/wasm/types";
option (gogoproto.goproto_getters_all) = false;

// MsgIBCSend
message MsgIBCSend {
// the channel by which the packet will be sent
string channel = 2 [ (gogoproto.moretags) = "yaml:\"source_channel\"" ];

// Timeout height relative to the current block height.
// The timeout is disabled when set to 0.
uint64 timeout_height = 4
[ (gogoproto.moretags) = "yaml:\"timeout_height\"" ];
// Timeout timestamp (in nanoseconds) relative to the current block timestamp.
// The timeout is disabled when set to 0.
uint64 timeout_timestamp = 5
[ (gogoproto.moretags) = "yaml:\"timeout_timestamp\"" ];

// Data is the payload to transfer. We must not make assumption what format or
// content is in here.
bytes data = 6;
}

// MsgIBCCloseChannel port and channel need to be owned by the contract
message MsgIBCCloseChannel {
string channel = 2 [ (gogoproto.moretags) = "yaml:\"source_channel\"" ];
}
Loading