From 16021564fa8d8c429ed5fde9cb6186af6d1a4058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kuras?= Date: Fri, 22 Oct 2021 11:53:10 +0200 Subject: [PATCH 1/4] cw1-subkeys-ng: Additional follow up improvements --- contracts/cw1-whitelist-ng/Cargo.toml | 1 + contracts/cw1-whitelist-ng/src/lib.rs | 5 +++-- contracts/cw1-whitelist-ng/src/multitest.rs | 4 ++-- contracts/cw1-whitelist-ng/src/multitest/contract.rs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index f3dfbcdf6..175f8d22d 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -17,6 +17,7 @@ backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] test-utils = [] +querier = ["library"] # generate multitest interfaces multitest = ["cw-multi-test", "anyhow"] diff --git a/contracts/cw1-whitelist-ng/src/lib.rs b/contracts/cw1-whitelist-ng/src/lib.rs index 9e035cdc4..71d9e13a2 100644 --- a/contracts/cw1-whitelist-ng/src/lib.rs +++ b/contracts/cw1-whitelist-ng/src/lib.rs @@ -3,11 +3,12 @@ pub mod error; pub mod interfaces; pub mod msg; pub mod multitest; +#[cfg(feature = "querier")] pub mod query; pub mod state; #[cfg(not(feature = "library"))] -mod binary { +mod entry_points { use crate::error::ContractError; use crate::state::Cw1WhitelistContract; use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response}; @@ -41,4 +42,4 @@ mod binary { } #[cfg(not(feature = "library"))] -pub use binary::*; +pub use entry_points::*; diff --git a/contracts/cw1-whitelist-ng/src/multitest.rs b/contracts/cw1-whitelist-ng/src/multitest.rs index 718c0e1ab..9ade2a89d 100644 --- a/contracts/cw1-whitelist-ng/src/multitest.rs +++ b/contracts/cw1-whitelist-ng/src/multitest.rs @@ -19,12 +19,12 @@ mod test { let proxy = Cw1WhitelistProxy::instantiate(&mut app, contract_id, &owner, &[]) .with_label("Proxy") - .with(vec![owner.to_string()], true) + .with_args(vec![owner.to_string()], true) .unwrap(); let remote = Cw1WhitelistProxy::instantiate(&mut app, contract_id, &owner, &[]) .with_label("Remote") - .with(vec![proxy.addr().into()], true) + .with_args(vec![proxy.addr().into()], true) .unwrap(); assert_ne!(proxy, remote); diff --git a/contracts/cw1-whitelist-ng/src/multitest/contract.rs b/contracts/cw1-whitelist-ng/src/multitest/contract.rs index 2ec012684..6d660eb2b 100644 --- a/contracts/cw1-whitelist-ng/src/multitest/contract.rs +++ b/contracts/cw1-whitelist-ng/src/multitest/contract.rs @@ -166,7 +166,7 @@ impl<'a, App> Instantiator<'a, App> { self } - pub fn with(self, admins: Vec, mutable: bool) -> AnyResult + pub fn with_args(self, admins: Vec, mutable: bool) -> AnyResult where C: Clone + std::fmt::Debug + PartialEq + JsonSchema + 'static, App: Executor, From 1de1d94bd133478268c3b4705b96243fc2a42adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kuras?= Date: Fri, 22 Oct 2021 11:59:58 +0200 Subject: [PATCH 2/4] cw1-subkeys-ng: Simplified some bounds to CustomMsg --- contracts/cw1-whitelist-ng/src/multitest/contract.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/cw1-whitelist-ng/src/multitest/contract.rs b/contracts/cw1-whitelist-ng/src/multitest/contract.rs index 6d660eb2b..c1fec65b3 100644 --- a/contracts/cw1-whitelist-ng/src/multitest/contract.rs +++ b/contracts/cw1-whitelist-ng/src/multitest/contract.rs @@ -2,6 +2,7 @@ use crate::msg::*; use crate::query::*; use crate::state::Cw1WhitelistContract; use anyhow::{bail, Result as AnyResult}; +use cosmwasm_std::CustomMsg; use cosmwasm_std::{ Addr, Binary, Coin, CosmosMsg, CustomQuery, DepsMut, Env, MessageInfo, QuerierWrapper, Reply, Response, @@ -75,7 +76,7 @@ impl<'a, App> Cw1Executor<'a, App> { pub fn execute(self, msgs: Vec>) -> AnyResult where - C: Clone + std::fmt::Debug + PartialEq + JsonSchema + Serialize + 'static, + C: CustomMsg, App: Executor, { self.app.execute_contract( @@ -108,7 +109,7 @@ impl<'a, App> WhitelistExecutor<'a, App> { pub fn freeze(self) -> AnyResult where - C: Clone + std::fmt::Debug + PartialEq + JsonSchema + Serialize + 'static, + C: CustomMsg, App: Executor, { self.app.execute_contract( @@ -121,7 +122,7 @@ impl<'a, App> WhitelistExecutor<'a, App> { pub fn update_admins(self, admins: Vec) -> AnyResult where - C: Clone + std::fmt::Debug + PartialEq + JsonSchema + 'static + Serialize, + C: CustomMsg, App: Executor, { self.app.execute_contract( @@ -168,7 +169,7 @@ impl<'a, App> Instantiator<'a, App> { pub fn with_args(self, admins: Vec, mutable: bool) -> AnyResult where - C: Clone + std::fmt::Debug + PartialEq + JsonSchema + 'static, + C: CustomMsg, App: Executor, { let addr = self.app.instantiate_contract( From de1d0ab463a8b6f79cfd24503b0f22a903ba19b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kuras?= Date: Fri, 22 Oct 2021 12:12:38 +0200 Subject: [PATCH 3/4] cw1-subkeys-ng: Fix mistakes --- contracts/cw1-whitelist-ng/src/lib.rs | 2 +- contracts/cw1-whitelist-ng/src/multitest/contract.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/contracts/cw1-whitelist-ng/src/lib.rs b/contracts/cw1-whitelist-ng/src/lib.rs index 71d9e13a2..5c3c3237e 100644 --- a/contracts/cw1-whitelist-ng/src/lib.rs +++ b/contracts/cw1-whitelist-ng/src/lib.rs @@ -3,7 +3,7 @@ pub mod error; pub mod interfaces; pub mod msg; pub mod multitest; -#[cfg(feature = "querier")] +#[cfg(any(test, feature = "querier"))] pub mod query; pub mod state; diff --git a/contracts/cw1-whitelist-ng/src/multitest/contract.rs b/contracts/cw1-whitelist-ng/src/multitest/contract.rs index c1fec65b3..59a2063de 100644 --- a/contracts/cw1-whitelist-ng/src/multitest/contract.rs +++ b/contracts/cw1-whitelist-ng/src/multitest/contract.rs @@ -10,7 +10,6 @@ use cosmwasm_std::{ use cw_multi_test::{AppResponse, Contract, Executor}; use schemars::JsonSchema; use serde::de::DeserializeOwned; -use serde::Serialize; impl Contract for Cw1WhitelistContract where @@ -76,7 +75,7 @@ impl<'a, App> Cw1Executor<'a, App> { pub fn execute(self, msgs: Vec>) -> AnyResult where - C: CustomMsg, + C: CustomMsg + 'static, App: Executor, { self.app.execute_contract( @@ -109,7 +108,7 @@ impl<'a, App> WhitelistExecutor<'a, App> { pub fn freeze(self) -> AnyResult where - C: CustomMsg, + C: CustomMsg + 'static, App: Executor, { self.app.execute_contract( @@ -122,7 +121,7 @@ impl<'a, App> WhitelistExecutor<'a, App> { pub fn update_admins(self, admins: Vec) -> AnyResult where - C: CustomMsg, + C: CustomMsg + 'static, App: Executor, { self.app.execute_contract( @@ -169,7 +168,7 @@ impl<'a, App> Instantiator<'a, App> { pub fn with_args(self, admins: Vec, mutable: bool) -> AnyResult where - C: CustomMsg, + C: CustomMsg + 'static, App: Executor, { let addr = self.app.instantiate_contract( From f44b912c4970d1b34fd0a7fa50d6a4f072ff2b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kuras?= Date: Mon, 25 Oct 2021 10:57:46 +0200 Subject: [PATCH 4/4] cw1-subkeys-ng: Removed obsolete feature flag --- contracts/cw1-whitelist-ng/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/cw1-whitelist-ng/src/lib.rs b/contracts/cw1-whitelist-ng/src/lib.rs index 5c3c3237e..bdb81526c 100644 --- a/contracts/cw1-whitelist-ng/src/lib.rs +++ b/contracts/cw1-whitelist-ng/src/lib.rs @@ -3,7 +3,6 @@ pub mod error; pub mod interfaces; pub mod msg; pub mod multitest; -#[cfg(any(test, feature = "querier"))] pub mod query; pub mod state;