Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cw1-subkeys-ng: Additional follow up improvements #506

Merged
merged 4 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/cw1-whitelist-ng/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
5 changes: 3 additions & 2 deletions contracts/cw1-whitelist-ng/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ pub mod error;
pub mod interfaces;
pub mod msg;
pub mod multitest;
#[cfg(any(test, feature = "querier"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did this have any effect?
I assume it would have been optimised away, but curious if this affects was size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may not be it is to be chcecked. The reason why they may not be optimized is, that they are public and visible from this point, and our wasm binaries are actually wasm libraries, so I am pretty sure optimizer has no rights to cut them off. I think, that in librray builds any dispatcher would not occur in the library, because they are pub(crate), and if I don't generate neither entry points nor multitest helpers they are straightly deadcode, so cut off, but not in this case.

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};
Expand Down Expand Up @@ -41,4 +42,4 @@ mod binary {
}

#[cfg(not(feature = "library"))]
pub use binary::*;
pub use entry_points::*;
4 changes: 2 additions & 2 deletions contracts/cw1-whitelist-ng/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions contracts/cw1-whitelist-ng/src/multitest/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ 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,
};
use cw_multi_test::{AppResponse, Contract, Executor};
use schemars::JsonSchema;
use serde::de::DeserializeOwned;
use serde::Serialize;

impl<T> Contract<T> for Cw1WhitelistContract<T>
where
Expand Down Expand Up @@ -75,7 +75,7 @@ impl<'a, App> Cw1Executor<'a, App> {

pub fn execute<C>(self, msgs: Vec<CosmosMsg<C>>) -> AnyResult<AppResponse>
where
C: Clone + std::fmt::Debug + PartialEq + JsonSchema + Serialize + 'static,
C: CustomMsg + 'static,
App: Executor<C>,
{
self.app.execute_contract(
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<'a, App> WhitelistExecutor<'a, App> {

pub fn freeze<C>(self) -> AnyResult<AppResponse>
where
C: Clone + std::fmt::Debug + PartialEq + JsonSchema + Serialize + 'static,
C: CustomMsg + 'static,
App: Executor<C>,
{
self.app.execute_contract(
Expand All @@ -121,7 +121,7 @@ impl<'a, App> WhitelistExecutor<'a, App> {

pub fn update_admins<C>(self, admins: Vec<String>) -> AnyResult<AppResponse>
where
C: Clone + std::fmt::Debug + PartialEq + JsonSchema + 'static + Serialize,
C: CustomMsg + 'static,
App: Executor<C>,
{
self.app.execute_contract(
Expand Down Expand Up @@ -166,9 +166,9 @@ impl<'a, App> Instantiator<'a, App> {
self
}

pub fn with<C>(self, admins: Vec<String>, mutable: bool) -> AnyResult<Cw1WhitelistProxy>
pub fn with_args<C>(self, admins: Vec<String>, mutable: bool) -> AnyResult<Cw1WhitelistProxy>
where
C: Clone + std::fmt::Debug + PartialEq + JsonSchema + 'static,
C: CustomMsg + 'static,
App: Executor<C>,
{
let addr = self.app.instantiate_contract(
Expand Down