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

cw-orch improvements #880

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
599 changes: 457 additions & 142 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ cw721-base = "0.18"
env_logger = "0.10"
once_cell = "1.18"
omniflix-std = "0.1.8"
osmosis-std = "0.20.1"
osmosis-std = "0.25.0"
osmosis-std-derive = "0.20.1"
osmosis-test-tube = "20.1.1"
osmosis-test-tube = "25.0.0"
proc-macro2 = "1.0"
prost = { version = "=0.12.3", features = ["prost-derive"] }
prost-types = { version = "=0.12.3", default-features = false }
prost-derive = "=0.12.3"
prost = { version = "0.12.3", features = ["prost-derive"] }
prost-types = { version = "0.12.3", default-features = false }
prost-derive = "0.12.3"
quote = "1.0"
rand = "0.8"
schemars = "0.8"
Expand All @@ -81,7 +81,7 @@ test-context = "0.1"
thiserror = { version = "1.0" }
wynd-utils = "0.4"
cw-orch = "0.24.1"
tokio = "=1.38.1"
tokio = "1.40.0"

# One commit ahead of version 0.3.0. Allows initialization with an
# optional owner.
Expand Down Expand Up @@ -159,4 +159,4 @@ dao-pre-propose-single-v241 = { package = "dao-pre-propose-single", version = "=
dao-proposal-multiple-v241 = { package = "dao-proposal-multiple", version = "=2.4.1" }
dao-proposal-single-v241 = { package = "dao-proposal-single", version = "=2.4.1" }
dao-voting-cw4-v241 = { package = "dao-voting-cw4", version = "=2.4.1" }
dao-voting-v241 = { package = "dao-voting", version = "=2.4.1" }
dao-voting-v241 = { package = "dao-voting", version = "=2.4.1" }
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
"type": "string"
},
"exponent": {
"description": "exponent represents power of 10 exponent that one must raise the base_denom to in order to equal the given DenomUnit's denom 1 denom = 1^exponent base_denom (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with exponent = 6, thus: 1 atom = 10^6 uatom).",
"description": "exponent represents power of 10 exponent that one must raise the base_denom to in order to equal the given DenomUnit's denom 1 denom = 10^exponent base_denom (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with exponent = 6, thus: 1 atom = 10^6 uatom).",
"type": "integer",
"format": "uint32",
"minimum": 0.0
Expand Down Expand Up @@ -483,7 +483,9 @@
"description",
"display",
"name",
"symbol"
"symbol",
"uri",
"uri_hash"
],
"properties": {
"base": {
Expand Down Expand Up @@ -511,6 +513,14 @@
"symbol": {
"description": "symbol is the token symbol usually shown on exchanges (eg: ATOM). This can be the same as the display.\n\nSince: cosmos-sdk 0.43",
"type": "string"
},
"uri": {
"description": "URI to a document (on or off-chain) that contains additional information. Optional.\n\nSince: cosmos-sdk 0.46",
"type": "string"
},
"uri_hash": {
"description": "URIHash is a sha256 hash of a document pointed by URI. It's used to verify that the document didn't change. Optional.\n\nSince: cosmos-sdk 0.46",
"type": "string"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn burn_more_than_balance_should_fail_and_not_deduct_allowance() {
assert_eq!(
err,
RunnerError::ExecuteError {
msg: format!("failed to execute message; message index: 0: dispatch: submessages: {balance}{denom} is smaller than {burn_amount}{denom}: insufficient funds")
msg: format!("failed to execute message; message index: 0: dispatch: submessages: spendable balance {balance}{denom} is smaller than {burn_amount}{denom}: insufficient funds")
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ fn set_denom_metadata_by_contract_owner_should_work() {
display: "sthb".to_string(),
name: "Stable Thai Baht".to_string(),
symbol: "STHB".to_string(),
uri: String::default(),
uri_hash: String::default(),
};
env.cw_tokenfactory_issuer
.set_denom_metadata(metadata, owner)
Expand Down Expand Up @@ -64,6 +66,8 @@ fn set_denom_metadata_by_contract_non_owner_should_fail() {
display: "sthb".to_string(),
name: "Stable Thai Baht".to_string(),
symbol: "STHB".to_string(),
uri: String::default(),
uri_hash: String::default(),
};

// Set denom metadata
Expand Down Expand Up @@ -108,6 +112,8 @@ fn set_denom_metadata_with_base_denom_unit_should_overides_default_base_denom_un
display: "sthb".to_string(),
name: "Stable Thai Baht".to_string(),
symbol: "STHB".to_string(),
uri: String::default(),
uri_hash: String::default(),
};

// Set denom metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl TokenfactoryIssuer {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("cw_tokenfactory_issuer"),
&[token_creation_fee],
signer,
)?
Expand Down
18 changes: 14 additions & 4 deletions contracts/proposal/dao-proposal-condorcet/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@ pub struct Choice {
#[cw_serde]
#[derive(cw_orch::ExecuteFns)]
pub enum ExecuteMsg {
Propose { choices: Vec<Choice> },
Vote { proposal_id: u32, vote: Vec<u32> },
Execute { proposal_id: u32 },
Close { proposal_id: u32 },
Propose {
choices: Vec<Choice>,
},
Vote {
proposal_id: u32,
vote: Vec<u32>,
},
#[cw_orch(fn_name("proposal_execute"))]
Execute {
proposal_id: u32,
},
Close {
proposal_id: u32,
},
SetConfig(UncheckedConfig),
}

Expand Down
1 change: 1 addition & 0 deletions contracts/proposal/dao-proposal-multiple/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub enum ExecuteMsg {
},
/// Causes the messages associated with a passed proposal to be
/// executed by the DAO.
#[cw_orch(fn_name("proposal_execute"))]
Execute {
/// The ID of the proposal to execute.
proposal_id: u64,
Expand Down
1 change: 1 addition & 0 deletions contracts/proposal/dao-proposal-single/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub enum ExecuteMsg {
},
/// Causes the messages associated with a passed proposal to be
/// executed by the DAO.
#[cw_orch(fn_name("proposal_execute"))]
Execute {
/// The ID of the proposal to execute.
proposal_id: u64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn test_full_integration_with_factory() {
// Error is insufficient funds as no funds were sent
assert_eq!(
RunnerError::ExecuteError {
msg: "failed to execute message; message index: 0: dispatch: submessages: 0uosmo is smaller than 1000uosmo: insufficient funds".to_string()
msg: "failed to execute message; message index: 0: dispatch: submessages: spendable balance is smaller than 1000uosmo: insufficient funds".to_string()
},
err
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"type": "string"
},
"exponent": {
"description": "exponent represents power of 10 exponent that one must raise the base_denom to in order to equal the given DenomUnit's denom 1 denom = 1^exponent base_denom (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with exponent = 6, thus: 1 atom = 10^6 uatom).",
"description": "exponent represents power of 10 exponent that one must raise the base_denom to in order to equal the given DenomUnit's denom 1 denom = 10^exponent base_denom (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with exponent = 6, thus: 1 atom = 10^6 uatom).",
"type": "integer",
"format": "uint32",
"minimum": 0.0
Expand Down
5 changes: 4 additions & 1 deletion contracts/voting/dao-voting-token-staked/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,8 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractEr
// If metadata, set it by calling the contract
#[cfg(any(
feature = "osmosis_tokenfactory",
feature = "cosmwasm_tokenfactory"
feature = "cosmwasm_tokenfactory",
feature = "kujira_tokenfactory"
))]
if let Some(metadata) = token.metadata {
// The first denom_unit must be the same as the tf and base denom.
Expand Down Expand Up @@ -663,6 +664,8 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractEr
display: metadata.display,
name: metadata.name,
symbol: metadata.symbol,
uri: String::default(),
uri_hash: String::default(),
},
})?,
funds: vec![],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl<'a> TokenVotingContract<'a> {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("token_voting"),
&[],
signer,
)?
Expand Down Expand Up @@ -398,7 +398,7 @@ impl<'a> TokenVotingContract<'a> {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("token_voting_contract"),
&[],
signer,
)?
Expand Down
17 changes: 9 additions & 8 deletions packages/cw-orch/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ use cw_orch::{
};

use crate::{
Cw20Stake, Cw20StakeExternalRewards, Cw20StakeRewardDistributor, DaoDaoCore,
DaoPreProposeApprovalSingle, DaoPreProposeApprover, DaoPreProposeMultiple, DaoPreProposeSingle,
DaoProposalCondorcet, DaoProposalHookCounter, DaoProposalMultiple, DaoProposalSingle,
DaoProposalSudo, DaoTestCustomFactory, DaoVotingCw20Balance, DaoVotingCw20Staked, DaoVotingCw4,
DaoVotingCw721Roles, DaoVotingCw721Staked, DaoVotingTokenStaked,
DaoDaoCore, DaoPreProposeApprovalSingle, DaoPreProposeApprover, DaoPreProposeMultiple,
DaoPreProposeSingle, DaoProposalCondorcet, DaoProposalHookCounter, DaoProposalMultiple,
DaoProposalSingle, DaoProposalSudo, DaoStakingCw20, DaoStakingCw20ExternalRewards,
DaoStakingCw20RewardDistributor, DaoTestCustomFactory, DaoVotingCw20Balance,
DaoVotingCw20Staked, DaoVotingCw4, DaoVotingCw721Roles, DaoVotingCw721Staked,
DaoVotingTokenStaked,
};

pub const DUMMY_CHAIN_INFO: ChainInfo = ChainInfo {
Expand Down Expand Up @@ -44,9 +45,9 @@ fn test_all_wasms_different() {
DaoProposalMultiple::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
DaoProposalSingle::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
// Stake
Cw20Stake::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
Cw20StakeExternalRewards::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
Cw20StakeRewardDistributor::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
DaoStakingCw20::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
DaoStakingCw20ExternalRewards::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
DaoStakingCw20RewardDistributor::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
// Voting
DaoVotingCw4::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
DaoVotingCw20Staked::<Mock>::wasm(&DUMMY_CHAIN_INFO.into()),
Expand Down
2 changes: 2 additions & 0 deletions packages/cw-tokenfactory-types/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ mod tokenfactory_msg {
display: metadata.display,
name: metadata.name,
symbol: metadata.symbol,
uri: metadata.uri,
uri_hash: metadata.uri_hash,
}),
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/dao-testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ pub mod suite;
#[cfg(not(target_arch = "wasm32"))]
pub use suite::*;

// Integration tests using an actual chain binary, requires
// the "test-tube" feature to be enabled
// cargo test --features test-tube
#[cfg(not(target_arch = "wasm32"))]
#[cfg(feature = "test-tube")]
pub mod test_tube;
2 changes: 1 addition & 1 deletion packages/dao-testing/src/test_tube/cw4_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> Cw4Group<'a> {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("cw4_group"),
&[],
signer,
)?
Expand Down
2 changes: 1 addition & 1 deletion packages/dao-testing/src/test_tube/cw721_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> Cw721Base<'a> {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("cw721_base"),
&[],
signer,
)?
Expand Down
2 changes: 1 addition & 1 deletion packages/dao-testing/src/test_tube/cw_admin_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> CwAdminFactory<'a> {
code_id,
&InstantiateMsg { admin },
Some(&signer.address()),
None,
Some("cw_admin_factory"),
funds,
signer,
)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'a> TokenfactoryIssuer<'a> {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("cw_tokenfactory_issuer"),
&[token_creation_fee],
signer,
)?
Expand Down
2 changes: 1 addition & 1 deletion packages/dao-testing/src/test_tube/dao_dao_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<'a> DaoCore<'a> {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("dao_dao_core"),
funds,
signer,
)?
Expand Down
2 changes: 1 addition & 1 deletion packages/dao-testing/src/test_tube/dao_proposal_single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'a> DaoProposalSingle<'a> {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("dao_proposal_single"),
&[token_creation_fee],
signer,
)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'a> CustomFactoryContract<'a> {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("dao_test_custom_factory"),
&[token_creation_fee],
signer,
)?
Expand Down
2 changes: 1 addition & 1 deletion packages/dao-testing/src/test_tube/dao_voting_cw4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> DaoVotingCw4<'a> {
code_id,
&instantiate_msg,
Some(&signer.address()),
None,
Some("dao_voting_cw4"),
funds,
signer,
)?
Expand Down
23 changes: 2 additions & 21 deletions packages/dao-testing/src/test_tube/mod.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
// Integrationg tests using an actual chain binary, requires
// the "test-tube" feature to be enabled
// cargo test --features test-tube

#[cfg(feature = "test-tube")]
pub mod cw_admin_factory;

#[cfg(feature = "test-tube")]
pub mod cw_tokenfactory_issuer;

#[cfg(feature = "test-tube")]
pub mod cw4_group;

#[cfg(feature = "test-tube")]
pub mod cw721_base;

#[cfg(feature = "test-tube")]
pub mod cw_admin_factory;
pub mod cw_tokenfactory_issuer;
pub mod dao_dao_core;

#[cfg(feature = "test-tube")]
pub mod dao_proposal_single;

#[cfg(feature = "test-tube")]
pub mod dao_test_custom_factory;

#[cfg(feature = "test-tube")]
pub mod dao_voting_cw4;
Loading