ai_ora/
helpers.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, WasmMsg};
5
6use crate::msg::ExecuteMsg;
7
8/// CwTemplateContract is a wrapper around Addr that provides a lot of helpers
9/// for working with this.
10#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
11pub struct CwTemplateContract(pub Addr);
12
13impl CwTemplateContract {
14    pub fn addr(&self) -> Addr {
15        self.0.clone()
16    }
17
18    pub fn call<T: Into<ExecuteMsg>>(&self, msg: T) -> StdResult<CosmosMsg> {
19        let msg = to_binary(&msg.into())?;
20        Ok(WasmMsg::Execute {
21            contract_addr: self.addr().into(),
22            msg,
23            funds: vec![],
24        }
25        .into())
26    }
27}