Crates.io | cw82 |
lib.rs | cw82 |
version | 1.3.0 |
source | src |
created_at | 2024-10-06 06:22:24.225057 |
updated_at | 2024-12-03 16:44:24.02004 |
description | Definition and types for the CosmWasm-82 interface |
homepage | |
repository | https://github.com/MegaRockLabs/cw-extra |
max_upload_size | |
id | 1398828 |
size | 10,254 |
The standard defining minimal interface for interacting with a smart contract based on CosmWasm. Contract implementing the standard might be both fully fledged accounts serving as a replacement for externally owned accounts (EOAs) or accounts of ephemeral nature and/or limited set of features meant to be used for the needs of an individual application.
The standard doesn't introduce any new primitives and achieved through a combination of multiple existing standards, mainly:
Standard | Description |
---|---|
cw-1 |
Proxy Contracts |
cw-2 |
Contract Info |
cw-81 |
Signature Verification |
cw-22 |
Supported Interface (in-review) |
A final query message looks in the following manner
pub enum QueryMsg {
...
// cw1
#[returns(CanExecuteResponse)]
CanExecute { sender: String, msg: CosmosMsg<T> },
// cw81
#[returns(ValidSignatureResponse)]
ValidSignature {
data: Binary,
signature: Binary,
payload: Option<Binary>
},
// cw81
#[returns(ValidSignaturesResponse)]
ValidSignatures {
data: Vec<Binary>,
signatures: Vec<Binary>,
payload: Option<Binary>
}
...
}
cw2
and cw22
operate on storage level and use raw queries and do not enforce any variants
The package expose #[smart_account_query]
macro attribute that injects the variants into a custom query message enum and also exposes a Cw82QueryMsg<T = Empty>
that can be extended to to check an executional validity of any custom CosmosMsg
The only execution message the standard enforces is
enum ExecuteMsg<T = Empty>
...
Execute { msgs: Vec<CosmosMsg<T>> },
. ...
}
coming from cw1
standard. Keep in mind that
T: Clone + fmt::Debug + PartialEq + JsonSchema
The package provides an Cw82ExecuteMsg
alias and no macro attributes
Example contracts can be found in this repository and are prefixed with cw81-
Contract | Description |
---|---|
cw82-key-account |
Signatures are verified against secp256k1 public key and all executable cosmos message must be signed by corresponding private key |
cw82-token-account |
Only an NFT owner can execute some cosmos messages. Signature are checked against the stored public key through direct sign |
cw82-sn-sym |
Secret Network specifc contract that only allow cosmos messages that were encrypted by a secret key provided to the contract by instantiator. Signatures must be coming from a separate key generated inside the contract |