From 847550a2069f7f7d4c60b76120c6927d507bb278 Mon Sep 17 00:00:00 2001 From: Gabe Date: Fri, 19 Jul 2024 01:13:28 -0500 Subject: [PATCH] Implement orch-interface for cw-abc --- Cargo.lock | 3 +++ contracts/external/cw-abc/Cargo.toml | 2 ++ contracts/external/cw-abc/src/msg.rs | 3 ++- packages/cw-orch/Cargo.toml | 1 + packages/cw-orch/src/external/cw_abc.rs | 23 +++++++++++++++++++++++ packages/cw-orch/src/external/mod.rs | 3 +++ packages/cw-orch/src/lib.rs | 2 ++ 7 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 packages/cw-orch/src/external/cw_abc.rs create mode 100644 packages/cw-orch/src/external/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 5811f2478..6a4bba49e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1022,12 +1022,14 @@ dependencies = [ "cw-address-like", "cw-curves", "cw-multi-test", + "cw-orch", "cw-ownable", "cw-paginate-storage 2.5.0", "cw-storage-plus 1.2.0", "cw-tokenfactory-issuer", "cw-utils 1.0.3", "cw2 1.1.2", + "dao-cw-orch", "dao-interface", "dao-proposal-single", "dao-testing", @@ -2118,6 +2120,7 @@ name = "dao-cw-orch" version = "2.5.0" dependencies = [ "cosmwasm-std", + "cw-abc", "cw-orch", "cw20-stake 2.5.0", "cw20-stake-external-rewards", diff --git a/contracts/external/cw-abc/Cargo.toml b/contracts/external/cw-abc/Cargo.toml index b0e9d0e6b..459b99e64 100644 --- a/contracts/external/cw-abc/Cargo.toml +++ b/contracts/external/cw-abc/Cargo.toml @@ -40,6 +40,7 @@ dao-interface = { workspace = true } getrandom = { workspace = true, features = ["js"] } thiserror = { workspace = true } cw-curves = { workspace = true } +cw-orch = { workspace = true } [dev-dependencies] speculoos = { workspace = true } @@ -54,3 +55,4 @@ cw-tokenfactory-issuer = { workspace = true } dao-voting-token-staked = { workspace = true } dao-proposal-single = { workspace = true } dao-voting = { workspace = true } +dao-cw-orch = { path = "../../../packages/cw-orch" } diff --git a/contracts/external/cw-abc/src/msg.rs b/contracts/external/cw-abc/src/msg.rs index f8ee0d289..3fc5820de 100644 --- a/contracts/external/cw-abc/src/msg.rs +++ b/contracts/external/cw-abc/src/msg.rs @@ -55,6 +55,7 @@ pub enum UpdatePhaseConfigMsg { #[cw_ownable::cw_ownable_execute] #[cw_serde] +#[derive(cw_orch::ExecuteFns)] pub enum ExecuteMsg { /// Buy will attempt to purchase as many supply tokens as possible. /// You must send only reserve tokens. @@ -107,7 +108,7 @@ pub enum ExecuteMsg { #[cw_ownable::cw_ownable_query] #[cw_serde] -#[derive(QueryResponses)] +#[derive(QueryResponses, cw_orch::QueryFns)] pub enum QueryMsg { /// Returns the reserve and supply quantities, as well as the spot price to buy 1 token /// Returns [`CurveInfoResponse`] diff --git a/packages/cw-orch/Cargo.toml b/packages/cw-orch/Cargo.toml index e4d3826e2..ebff3e21e 100644 --- a/packages/cw-orch/Cargo.toml +++ b/packages/cw-orch/Cargo.toml @@ -36,4 +36,5 @@ dao-voting-cw4 = { version = "2.4.2", path = "../../contracts/voting/dao-voting- dao-voting-cw721-roles = { version = "2.4.2", path = "../../contracts/voting/dao-voting-cw721-roles" } dao-voting-cw721-staked = { version = "2.4.2", path = "../../contracts/voting/dao-voting-cw721-staked" } dao-voting-token-staked = { version = "2.4.2", path = "../../contracts/voting/dao-voting-token-staked" } +cw-abc = { path = "../../contracts/external/cw-abc" } serde.workspace = true diff --git a/packages/cw-orch/src/external/cw_abc.rs b/packages/cw-orch/src/external/cw_abc.rs new file mode 100644 index 000000000..034de60d5 --- /dev/null +++ b/packages/cw-orch/src/external/cw_abc.rs @@ -0,0 +1,23 @@ +use cw_orch::interface; +#[cfg(not(target_arch = "wasm32"))] +use cw_orch::prelude::*; + +use cw_abc::contract::{execute, instantiate, query}; +use cw_abc::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; + +#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty)] +pub struct CwAbc; + +#[cfg(not(target_arch = "wasm32"))] +impl Uploadable for CwAbc { + /// Return the path to the wasm file corresponding to the contract + fn wasm(_chain: &ChainInfoOwned) -> WasmPath { + artifacts_dir_from_workspace!() + .find_wasm_path("cw_abc") + .unwrap() + } + /// Returns a CosmWasm contract wrapper + fn wrapper() -> Box> { + Box::new(ContractWrapper::new_with_empty(execute, instantiate, query)) + } +} diff --git a/packages/cw-orch/src/external/mod.rs b/packages/cw-orch/src/external/mod.rs new file mode 100644 index 000000000..2409f5475 --- /dev/null +++ b/packages/cw-orch/src/external/mod.rs @@ -0,0 +1,3 @@ +mod cw_abc; + +pub use cw_abc::CwAbc; diff --git a/packages/cw-orch/src/lib.rs b/packages/cw-orch/src/lib.rs index 3b933d3b6..7a3794426 100644 --- a/packages/cw-orch/src/lib.rs +++ b/packages/cw-orch/src/lib.rs @@ -1,4 +1,5 @@ mod core; +mod external; mod pre_propose; mod proposal; mod staking; @@ -6,6 +7,7 @@ mod test_contracts; mod voting; pub use core::*; +pub use external::*; pub use pre_propose::*; pub use proposal::*; pub use staking::*;