6 releases (2 stable)
1.5.9 | Dec 3, 2024 |
---|---|
0.5.0 | Dec 3, 2024 |
0.4.0 | Dec 2, 2024 |
0.3.0 | Nov 30, 2024 |
0.2.0 | Oct 6, 2024 |
#202 in #contract
598 downloads per month
Used in 3 crates
11KB
124 lines
CW22 Spec: Contract Info
The standard used to declare which interface contract implements. This standard is inspired by the EIP-165 from Ethereum.
For more information on this specification, please check out the README.
Data structures
Required
All CW22-compliant contracts must store the following data:
- key:
contract_supported_interface
- data: Json-serialized
ContractSupportedInterface
pub struct ContractSupportedInterface<'a> {
/// supported_interface is the name of an interface that the contract supports.
/// This is inspired by the EIP-165 from Ethereum.
/// Interface names should follow a common standard such as <Registry Domain>:<Crate Name> in Rust crate registry.
/// e.g. "crates.io:cw2"
/// NOTE: this is just a hint for the caller to adapt on how to interact with this contract.
/// There is no guarantee that the contract actually implements the interface.
pub supported_interface: Cow<'a, str>,
/// Version on release tags of the interface package following [SemVer](https://semver.org/) guideline.
/// e.g. "0.16.0"
pub version: Cow<'a, str>,
}
Below is an example used in cw20 contract, where we declare to implement cw20 interface with version 0.16.0 at instantiate:
use cw22::{set_contract_supported_interface, ContractSupportedInterface};
pub fn instantiate(
mut deps: DepsMut,
_env: Env,
_info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
///...
let supported_interface = ContractSupportedInterface {
supported_interface: "crates.io:cw20".into(),
version: "0.16.0".into(),
};
set_contract_supported_interface(deps.storage, &[supported_interface])?;
///...
}
Dependencies
~4–6MB
~123K SLoC