Attribute Macro aabb_cw_orch::interface_entry_point
source · #[interface_entry_point]
Expand description
Procedural macro to generate a cw-orchestrator interface with the kebab-case name of the crate.
Add this macro to the entry point functions of your contract to use it.
This macro can only be used in contract.rs
Example
ⓘ
// In crate "my-contract::contract.rs"
#[cfg_attr(feature="interface", interface_entry_point)]
#[cfg_attr(feature="export", entry_point)]
pub fn instantiate(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: InstantiateMsg,
-> StdResult<Response> {
// ...
}
// ... other entry points (execute, query, migrate)
Generated code
ⓘ
// This struct represents the interface to the contract.
pub struct MyContract<Chain: ::cw_orch::prelude::CwEnv>(::cw_orch::contract::Contract<Chain>);
impl <Chain: ::cw_orch::prelude::CwEnv> MyContract<Chain> {
/// Constructor for the contract interface
pub fn new(contract_id: impl ToString, chain: Chain) -> Self {
Self(
::cw_orch::contract::Contract::new(contract_id, chain)
)
}
}
// Traits for signaling cw-orchestrator with what messages to call the contract's entry points.
impl <Chain: ::cw_orch::prelude::CwEnv> ::cw_orch::prelude::InstantiableContract for MyContract<Chain> {
type InstantiateMsg = InstantiateMsg;
}
impl <Chain: ::cw_orch::prelude::CwEnv> ::cw_orch::prelude::ExecutableContract for MyContract<Chain> {
type ExecuteMsg = ExecuteMsg;
}
// ... other entry point & upload traits
// Implementation for Uploadable
impl <Chain: CwEnv> Uploadable for Cw20<Chain> {
fn wrapper(&self) -> <Mock as cw_orch::TxHandler>::ContractSource {
Box::new(
ContractWrapper::new_with_empty(
my_contract::contract::execute,
my_contract::contract::instantiate,
my_contract::contract::query,
)
.with_migrate(my_contract::contract::migrate),
)
}
fn wasm(&self) -> <Daemon as cw_orch::TxHandler>::ContractSource {
// Wasm path to the artifacts directory of the contract
// generated with CARGO_MANIFEST_DIR env variable
}
}