macro_rules! cw_orch_interface {
($app_const:expr, $app_type:ty, $interface_name: ident) => { ... };
($app_const:expr, $app_type:ty, $interface_name: ident, $custom_exec:ty) => { ... };
}Expand description
Creates the interface for working with the app with cw-orch. This generates all the necessary code used to interact with the app in an cw-orch environment
§Usage
The macro takes three arguments:
- The app’s constant, declared in
contract.rs. - The app’s type, declared in
contract.rs. - The name of the interface struct to be generated.
ⓘ
cw_orch_interface!(APP, App, AppInterface);This will generate :
ⓘ
pub mod interface{
#[cw_orch::interface(App::InstantiateMsg, App::ExecuteMsg, App::QueryMsg, App::MigrateMsg)]
pub struct AppInterface;
impl <Chain: cw_orch::prelude::CwEnv> cw_orch::prelude::Uploadable for AppInterface<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(
APP::execute, // This notation, doesn't actually work like so, but we use that to illustrate
APP::instantiate,
APP::query,
)
.with_reply(APP::reply)
.with_migrate(APP::migrate)
.with_sudo(APP::sudo),
)
}
}
impl<Chain: ::cw_orch::prelude::CwEnv> $crate::abstract_app::abstract_interface::AppDeployer<Chain> for AppInterface<Chain> {}
}