-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.rs
45 lines (39 loc) · 1.38 KB
/
interface.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use cosmwasm_std::Empty;
use cw_orch::interface;
use cw_orch::prelude::*;
#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty, id = "buyable-counter")]
pub struct BuyableCounterI;
impl<Chain: CwEnv> Uploadable for BuyableCounterI<Chain> {
/// Return the path to the wasm file corresponding to the contract
fn wasm(_info: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("buyable_counter")
.unwrap()
}
/// Returns a CosmWasm contract wrapper
fn wrapper() -> Box<dyn MockContract<Empty>> {
Box::new(ContractWrapper::new_with_empty(
crate::contract::execute,
crate::contract::instantiate,
crate::contract::query,
))
}
}
impl<Chain: CwEnv> BuyableCounterI<Chain> {
/// Instantiate the contract in any CosmWasm environment
pub fn deploy(
chain: Chain,
instantiate_msg: InstantiateMsg,
admin: Addr,
) -> cw_orch::anyhow::Result<BuyableCounterI<Chain>> {
// Construct the interface
let contract = BuyableCounterI::new(chain.clone());
// Upload the contract
contract.upload()?;
// Instantiate the contract
contract.instantiate(&instantiate_msg, Some(&admin), &[])?;
// Return the interface
Ok(contract)
}
}