Skip to content

Add active threshold functionality to CW4 voting module, closes #781 - #819

Open
theghostmac wants to merge 6 commits into
DA0-DA0:developmentfrom
theghostmac:ghostmac-new
Open

theghostmac wants to merge 6 commits into
DA0-DA0:developmentfrom
theghostmac:ghostmac-new

Conversation

@theghostmac

Copy link
Copy Markdown

Changelog

  • Added new custom error message to error.rs, InvalidThreshold
  • Added the query_is_active function and corresponding Query::IsActive
  • Added the execute_update_active_threshold function and corresponding ExecuteMsg::UpdateActiveThreshold
  • Added the new optional Config and updated the instantiate function to make use of it.

Author

GhostMac

@JakeHartnell

Copy link
Copy Markdown
Member

Needs a few things:

  • Fix the build
  • Add tests for active_threshold and being able to update it
  • Make sure CI passes
  • Clean up

Comment thread contracts/voting/dao-voting-cw4/src/contract.rs Outdated
Comment on lines +13 to +19
#[cw_serde]
pub struct Config {
pub active_threshold_enabled: bool,
pub active_threshold: Option<ActiveThreshold>,
}

pub const CONFIG: Item<Config> = Item::new("config"); No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't really need this as if ACTIVE_THRESHOLD is not set, it's not enabled. There is no other config needed for this contract.

Comment thread contracts/voting/dao-voting-cw4/src/contract.rs Outdated
Comment thread contracts/voting/dao-voting-cw4/src/contract.rs Outdated
@theghostmac

Copy link
Copy Markdown
Author

Needs a few things:

  • Fix the build
  • Add tests for active_threshold and being able to update it
  • Make sure CI passes
  • Clean up

I have updated the contract with everything you pointed out. Build passes. Moving on to the tests.

Comment thread contracts/voting/dao-voting-cw4/src/contract.rs Outdated
Comment on lines +12 to +17
#[cw_serde]
pub struct Config {
pub active_threshold: Option<ActiveThreshold>,
}

pub const CONFIG: Item<Config> = Item::new("config");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the same info as ACTIVE_THRESHOLD. Delete Config struct.

Comment thread contracts/voting/dao-voting-cw4/src/contract.rs Outdated
Comment thread contracts/voting/dao-voting-cw4/src/contract.rs Outdated
@JakeHartnell

Copy link
Copy Markdown
Member

Needs a few things:

  • Fix the build
  • Add tests for active_threshold and being able to update it
  • Make sure CI passes
  • Clean up

I have updated the contract with everything you pointed out. Build passes. Moving on to the tests.

Close, but see above comments.

  • Get rid of CONFIG, it's duplicate state for no reason
  • Make sure to save ACTIVE_THRESHOLD on instantiation and validate that it's NOT ACTIVE_THRESHOLD::Percent
  • Get rid of ACTIVE_THRESHOLD::Percent in the IsActive query, it does nothing right now and we should not allow it
  • Fix linting errors and tests, CI should pass

Comment thread contracts/voting/dao-voting-cw4/src/contract.rs Outdated
Co-authored-by: Jake Hartnell <Jake.Hartnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants