macro_rules! cw_orch_interface {
($adapter_const:expr, $adapter_type:ty, $init_msg:ty, $interface_name: ident) => { ... };
($adapter_const:expr, $adapter_type:ty, $init_msg:ty, $interface_name: ident, $custom_exec: ty) => { ... };
}Expand description
Creates the interface for working with the adapter with cw-orch. This generates all the necessary code used to interact with the adapter in an cw-orch environment
§Usage
The macro takes three arguments:
- The adapter’s constant, declared in
contract.rs. - The adapter’s type, declared in
contract.rs. - The name of the interface struct to be generated.
ⓘ
cw_orch_interface!(ADAPTER, Adapter, AdapterInterface);This will generate :
ⓘ
pub mod interface{
#[cw_orch::interface(Adapter::InstantiateMsg, Adapter::ExecuteMsg, Adapter::QueryMsg, Adapter::MigrateMsg)]
pub struct AdapterInterface;
impl <Chain: cw_orch::prelude::CwEnv> cw_orch::prelude::Uploadable for AdapterInterface<Chain> {
// Looks for the wasm file in the app's artifacts directory
// The name of the wasm file should contain the app crate name (snake_cased)
fn wasm(&self) -> cw_orch::prelude::WasmPath {
let wasm_name = env!("CARGO_CRATE_NAME").replace('-', "_");
cw_orch::prelude::ArtifactsDir::auto(Some(env!("CARGO_MANIFEST_DIR").to_string()))
.find_wasm_path(&wasm_name).unwrap()
}
fn wrapper(
&self,
) -> Box<dyn cw_orch::prelude::MockContract<cosmwasm_std::Empty, cosmwasm_std::Empty>> {
Box::new(
cw_orch::prelude::ContractWrapper::new_with_empty(
ADAPTER::execute, // This notation, doesn't actually work like so, but we use that to illustrate
ADAPTER::instantiate,
ADAPTER::query,
)
.with_reply(ADAPTER::reply)
.with_migrate(ADAPTER::migrate)
.with_sudo(ADAPTER::sudo),
)
}
}
impl<Chain: ::cw_orch::prelude::CwEnv> $crate::abstract_app::abstract_interface::AdapterDeployer<Chain> for AdapterInterface<Chain> {}
}