Skip to content

Commit

Permalink
Implement orch-interface for cw-abc
Browse files Browse the repository at this point in the history
  • Loading branch information
ismellike committed Jul 19, 2024
1 parent bc6e552 commit 847550a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions contracts/external/cw-abc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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" }
3 changes: 2 additions & 1 deletion contracts/external/cw-abc/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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`]
Expand Down
1 change: 1 addition & 0 deletions packages/cw-orch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions packages/cw-orch/src/external/cw_abc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use cw_orch::interface;
#[cfg(not(target_arch = "wasm32"))]
use cw_orch::prelude::*;

use cw_abc::contract::{execute, instantiate, query};

Check warning on line 5 in packages/cw-orch/src/external/cw_abc.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused imports: `execute`, `instantiate`, `query`
use cw_abc::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

Check warning on line 6 in packages/cw-orch/src/external/cw_abc.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused imports: `ExecuteMsg`, `InstantiateMsg`, `QueryMsg`

#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty)]
pub struct CwAbc;

#[cfg(not(target_arch = "wasm32"))]
impl<Chain> Uploadable for CwAbc<Chain> {
/// 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<dyn MockContract<Empty>> {
Box::new(ContractWrapper::new_with_empty(execute, instantiate, query))
}
}
3 changes: 3 additions & 0 deletions packages/cw-orch/src/external/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod cw_abc;

pub use cw_abc::CwAbc;
2 changes: 2 additions & 0 deletions packages/cw-orch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
mod core;
mod external;
mod pre_propose;
mod proposal;
mod staking;
mod test_contracts;
mod voting;

pub use core::*;
pub use external::*;
pub use pre_propose::*;
pub use proposal::*;
pub use staking::*;
Expand Down

0 comments on commit 847550a

Please sign in to comment.