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

remove cw721 claim limit, and upgrade to v2.6.0 #893

Merged
merged 6 commits into from
Nov 1, 2024
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
488 changes: 251 additions & 237 deletions Cargo.lock

Large diffs are not rendered by default.

97 changes: 50 additions & 47 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resolver = "2"
edition = "2021"
license = "BSD-3-Clause"
repository = "https://github.com/DA0-DA0/dao-contracts"
version = "2.5.1"
version = "2.6.0"

[profile.release]
codegen-units = 1
Expand Down Expand Up @@ -85,52 +85,52 @@ wynd-utils = "0.4"
# optional owner.
cw-ownable = "0.5"

btsg-ft-factory = { path = "./contracts/external/btsg-ft-factory", version = "2.5.1" }
cw-admin-factory = { path = "./contracts/external/cw-admin-factory", version = "2.5.1" }
cw-denom = { path = "./packages/cw-denom", version = "2.5.1" }
cw-fund-distributor = { path = "./contracts/distribution/cw-fund-distributor", version = "2.5.1" }
cw-hooks = { path = "./packages/cw-hooks", version = "2.5.1" }
cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.5.1" }
cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.5.1" }
cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.5.1" }
cw-token-swap = { path = "./contracts/external/cw-token-swap", version = "2.5.1" }
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.5.1", default-features = false }
cw-tokenfactory-types = { path = "./packages/cw-tokenfactory-types", version = "2.5.1", default-features = false }
cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.5.1" }
cw-wormhole = { path = "./packages/cw-wormhole", version = "2.5.1" }
cw20-stake = { path = "./contracts/staking/cw20-stake", version = "2.5.1" }
cw20-stake-external-rewards = { path = "./contracts/staking/cw20-stake-external-rewards", version = "2.5.1" }
cw20-stake-reward-distributor = { path = "./contracts/staking/cw20-stake-reward-distributor", version = "2.5.1" }
cw721-controllers = { path = "./packages/cw721-controllers", version = "2.5.1" }
cw721-roles = { path = "./contracts/external/cw721-roles", version = "2.5.1" }
dao-cw721-extensions = { path = "./packages/dao-cw721-extensions", version = "2.5.1" }
dao-dao-core = { path = "./contracts/dao-dao-core", version = "2.5.1" }
dao-dao-macros = { path = "./packages/dao-dao-macros", version = "2.5.1" }
dao-hooks = { path = "./packages/dao-hooks", version = "2.5.1" }
dao-interface = { path = "./packages/dao-interface", version = "2.5.1" }
dao-pre-propose-approval-multiple = { path = "./contracts/pre-propose/dao-pre-propose-approval-multiple", version = "2.5.1" }
dao-migrator = { path = "./contracts/external/dao-migrator", version = "2.5.1" }
dao-pre-propose-approval-single = { path = "./contracts/pre-propose/dao-pre-propose-approval-single", version = "2.5.1" }
dao-pre-propose-approver = { path = "./contracts/pre-propose/dao-pre-propose-approver", version = "2.5.1" }
dao-pre-propose-base = { path = "./packages/dao-pre-propose-base", version = "2.5.1" }
dao-pre-propose-multiple = { path = "./contracts/pre-propose/dao-pre-propose-multiple", version = "2.5.1" }
dao-pre-propose-single = { path = "./contracts/pre-propose/dao-pre-propose-single", version = "2.5.1" }
dao-proposal-condorcet = { path = "./contracts/proposal/dao-proposal-condorcet", version = "2.5.1" }
dao-proposal-hook-counter = { path = "./contracts/test/dao-proposal-hook-counter", version = "2.5.1" }
dao-proposal-multiple = { path = "./contracts/proposal/dao-proposal-multiple", version = "2.5.1" }
dao-proposal-single = { path = "./contracts/proposal/dao-proposal-single", version = "2.5.1" }
dao-proposal-sudo = { path = "./contracts/test/dao-proposal-sudo", version = "2.5.1" }
dao-rewards-distributor = { path = "./contracts/distribution/dao-rewards-distributor", version = "2.5.1" }
dao-test-custom-factory = { path = "./contracts/test/dao-test-custom-factory", version = "2.5.1" }
dao-testing = { path = "./packages/dao-testing", version = "2.5.1" }
dao-voting = { path = "./packages/dao-voting", version = "2.5.1" }
dao-voting-cw20-balance = { path = "./contracts/test/dao-voting-cw20-balance", version = "2.5.1" }
dao-voting-cw20-staked = { path = "./contracts/voting/dao-voting-cw20-staked", version = "2.5.1" }
dao-voting-cw4 = { path = "./contracts/voting/dao-voting-cw4", version = "2.5.1" }
dao-voting-cw721-roles = { path = "./contracts/voting/dao-voting-cw721-roles", version = "2.5.1" }
dao-voting-cw721-staked = { path = "./contracts/voting/dao-voting-cw721-staked", version = "2.5.1" }
dao-voting-onft-staked = { path = "./contracts/voting/dao-voting-onft-staked", version = "2.5.1" }
dao-voting-token-staked = { path = "./contracts/voting/dao-voting-token-staked", version = "2.5.1" }
btsg-ft-factory = { path = "./contracts/external/btsg-ft-factory", version = "2.6.0" }
cw-admin-factory = { path = "./contracts/external/cw-admin-factory", version = "2.6.0" }
cw-denom = { path = "./packages/cw-denom", version = "2.6.0" }
cw-fund-distributor = { path = "./contracts/distribution/cw-fund-distributor", version = "2.6.0" }
cw-hooks = { path = "./packages/cw-hooks", version = "2.6.0" }
cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.6.0" }
cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.6.0" }
cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.6.0" }
cw-token-swap = { path = "./contracts/external/cw-token-swap", version = "2.6.0" }
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.6.0", default-features = false }
cw-tokenfactory-types = { path = "./packages/cw-tokenfactory-types", version = "2.6.0", default-features = false }
cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.6.0" }
cw-wormhole = { path = "./packages/cw-wormhole", version = "2.6.0" }
cw20-stake = { path = "./contracts/staking/cw20-stake", version = "2.6.0" }
cw20-stake-external-rewards = { path = "./contracts/staking/cw20-stake-external-rewards", version = "2.6.0" }
cw20-stake-reward-distributor = { path = "./contracts/staking/cw20-stake-reward-distributor", version = "2.6.0" }
cw721-controllers = { path = "./packages/cw721-controllers", version = "2.6.0" }
cw721-roles = { path = "./contracts/external/cw721-roles", version = "2.6.0" }
dao-cw721-extensions = { path = "./packages/dao-cw721-extensions", version = "2.6.0" }
dao-dao-core = { path = "./contracts/dao-dao-core", version = "2.6.0" }
dao-dao-macros = { path = "./packages/dao-dao-macros", version = "2.6.0" }
dao-hooks = { path = "./packages/dao-hooks", version = "2.6.0" }
dao-interface = { path = "./packages/dao-interface", version = "2.6.0" }
dao-pre-propose-approval-multiple = { path = "./contracts/pre-propose/dao-pre-propose-approval-multiple", version = "2.6.0" }
dao-migrator = { path = "./contracts/external/dao-migrator", version = "2.6.0" }
dao-pre-propose-approval-single = { path = "./contracts/pre-propose/dao-pre-propose-approval-single", version = "2.6.0" }
dao-pre-propose-approver = { path = "./contracts/pre-propose/dao-pre-propose-approver", version = "2.6.0" }
dao-pre-propose-base = { path = "./packages/dao-pre-propose-base", version = "2.6.0" }
dao-pre-propose-multiple = { path = "./contracts/pre-propose/dao-pre-propose-multiple", version = "2.6.0" }
dao-pre-propose-single = { path = "./contracts/pre-propose/dao-pre-propose-single", version = "2.6.0" }
dao-proposal-condorcet = { path = "./contracts/proposal/dao-proposal-condorcet", version = "2.6.0" }
dao-proposal-hook-counter = { path = "./contracts/test/dao-proposal-hook-counter", version = "2.6.0" }
dao-proposal-multiple = { path = "./contracts/proposal/dao-proposal-multiple", version = "2.6.0" }
dao-proposal-single = { path = "./contracts/proposal/dao-proposal-single", version = "2.6.0" }
dao-proposal-sudo = { path = "./contracts/test/dao-proposal-sudo", version = "2.6.0" }
dao-rewards-distributor = { path = "./contracts/distribution/dao-rewards-distributor", version = "2.6.0" }
dao-test-custom-factory = { path = "./contracts/test/dao-test-custom-factory", version = "2.6.0" }
dao-testing = { path = "./packages/dao-testing", version = "2.6.0" }
dao-voting = { path = "./packages/dao-voting", version = "2.6.0" }
dao-voting-cw20-balance = { path = "./contracts/test/dao-voting-cw20-balance", version = "2.6.0" }
dao-voting-cw20-staked = { path = "./contracts/voting/dao-voting-cw20-staked", version = "2.6.0" }
dao-voting-cw4 = { path = "./contracts/voting/dao-voting-cw4", version = "2.6.0" }
dao-voting-cw721-roles = { path = "./contracts/voting/dao-voting-cw721-roles", version = "2.6.0" }
dao-voting-cw721-staked = { path = "./contracts/voting/dao-voting-cw721-staked", version = "2.6.0" }
dao-voting-onft-staked = { path = "./contracts/voting/dao-voting-onft-staked", version = "2.6.0" }
dao-voting-token-staked = { path = "./contracts/voting/dao-voting-token-staked", version = "2.6.0" }

# v1 dependencies. used for state migrations.
cw-core-v1 = { package = "cw-core", version = "0.1.0" }
Expand Down Expand Up @@ -159,3 +159,6 @@ dao-proposal-multiple-v241 = { package = "dao-proposal-multiple", version = "=2.
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" }

# v2.5.0 dependencies.
cw721-controllers-v250 = { package = "cw721-controllers", version = "=2.5.0" }
82 changes: 4 additions & 78 deletions ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosm_orc::orchestrator::{ExecReq, SigningKey};
use cosm_orc::orchestrator::SigningKey;
use cosmwasm_std::{Binary, Empty, Uint128};
use cw_utils::Duration;
use test_context::test_context;
Expand Down Expand Up @@ -126,7 +126,9 @@ pub fn claim_nfts(chain: &mut Chain, sender: &SigningKey) {
.execute(
CONTRACT_NAME,
"claim_nfts",
&module::msg::ExecuteMsg::ClaimNfts {},
&module::msg::ExecuteMsg::ClaimNfts {
r#type: module::msg::ClaimType::All,
},
sender,
vec![],
)
Expand Down Expand Up @@ -189,79 +191,3 @@ fn cw721_stake_tokens(chain: &mut Chain) {
let voting_power = query_voting_power(chain, &user_addr, None);
assert_eq!(voting_power, Uint128::zero());
}

#[test_context(Chain)]
#[test]
#[ignore]
fn cw721_stake_max_claims_works(chain: &mut Chain) {
use module::state::MAX_CLAIMS;

let user_addr = chain.users["user1"].account.address.clone();
let user_key = chain.users["user1"].key.clone();

let CommonTest { module, .. } =
setup_test(chain, Some(Duration::Height(1)), &user_key, &user_addr);

// Create `MAX_CLAIMS` claims.

// batch_size * 3 = the number of msgs to be batched per tx.
// We cant batch all of the msgs under a single tx because we hit MAX_BLOCK_GAS limits.
let batch_size = 10;
let mut total_msgs = 0;

let mut reqs = vec![];
for i in 0..MAX_CLAIMS {
let token_id = i.to_string();

reqs.push(ExecReq {
contract_name: CW721_NAME.to_string(),
msg: Box::new(cw721_base::ExecuteMsg::Mint::<Empty, Empty> {
token_id: token_id.clone(),
owner: user_addr.to_string(),
token_uri: None,
extension: Empty::default(),
}),
funds: vec![],
});

reqs.push(ExecReq {
contract_name: CW721_NAME.to_string(),
msg: Box::new(cw721::Cw721ExecuteMsg::SendNft {
contract: module.to_string(),
token_id: token_id.clone(),
msg: Binary::default(),
}),
funds: vec![],
});

reqs.push(ExecReq {
contract_name: CONTRACT_NAME.to_string(),
msg: Box::new(module::msg::ExecuteMsg::Unstake {
token_ids: vec![token_id],
}),
funds: vec![],
});

if (i != 0 && i % batch_size == 0) || i == MAX_CLAIMS - 1 {
total_msgs += reqs.len();

chain
.orc
.execute_batch("batch_cw721_stake_max_claims", reqs, &user_key)
.unwrap();

reqs = vec![];
}
}

assert_eq!(total_msgs as u64, MAX_CLAIMS * 3);

chain
.orc
.poll_for_n_blocks(1, core::time::Duration::from_millis(20_000), false)
.unwrap();

// If this works, we're golden. Other tests make sure that the
// NFTs get returned as a result of this.
claim_nfts(chain, &user_key);
}
2 changes: 1 addition & 1 deletion contracts/dao-dao-core/schema/dao-dao-core.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-dao-core",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw-fund-distributor",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-rewards-distributor",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "btsg-ft-factory",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw-admin-factory",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw-payroll-factory",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
2 changes: 1 addition & 1 deletion contracts/external/cw-token-swap/schema/cw-token-swap.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw-token-swap",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw-tokenfactory-issuer",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
2 changes: 1 addition & 1 deletion contracts/external/cw-vesting/schema/cw-vesting.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw-vesting",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
2 changes: 1 addition & 1 deletion contracts/external/cw721-roles/schema/cw721-roles.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw721-roles",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
2 changes: 1 addition & 1 deletion contracts/external/dao-migrator/schema/dao-migrator.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-migrator",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-pre-propose-approval-multiple",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-pre-propose-approval-single",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-pre-propose-approver",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-pre-propose-multiple",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-pre-propose-single",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-proposal-condorcet",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-proposal-multiple",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-proposal-single",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw20-stake-external-rewards",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw20-stake-reward-distributor",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
2 changes: 1 addition & 1 deletion contracts/staking/cw20-stake/schema/cw20-stake.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw20-stake",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-voting-cw20-staked",
"contract_version": "2.5.1",
"contract_version": "2.6.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Loading
Loading