Skip to content

Commit

Permalink
Dao voting cw4 cleanup (#691)
Browse files Browse the repository at this point in the history
* Refactor cw4 voting

* Fix up tests and bugs

* Add test for using an existing group contract

* Update schema

* Fix clippy

* nightly -> stable for CI

nightly broke a bunch of linting stuff, we should probably be using stable
  • Loading branch information
JakeHartnell committed Jul 9, 2023
1 parent 7f89ad1 commit 5cfb3bf
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 318 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: coverage
'on':
"on":
- push
jobs:
test:
name: coverage
runs-on: ubuntu-latest
container:
image: 'xd009642/tarpaulin:develop-nightly'
options: '--security-opt seccomp=unconfined'
image: "xd009642/tarpaulin:develop-nightly"
options: "--security-opt seccomp=unconfined"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Generate code coverage
run: >
cargo +nightly tarpaulin --verbose --workspace --out Xml --exclude-files test-contracts/* *test*.rs packages/dao-dao-macros/* packages/dao-testing/* ci/*
cargo tarpaulin --verbose --workspace --out Xml --exclude-files test-contracts/* *test*.rs packages/dao-dao-macros/* packages/dao-testing/* ci/*
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install latest nightly toolchain
- name: Install latest stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
target: wasm32-unknown-unknown
override: true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use dao_testing::contracts::{
cw4_group_contract, dao_dao_contract, dao_voting_cw4_contract, proposal_condorcet_contract,
};
use dao_voting::threshold::PercentageThreshold;
use dao_voting_cw4::msg::GroupContract;

use crate::{
config::{Config, UncheckedConfig},
Expand Down Expand Up @@ -88,8 +89,10 @@ impl SuiteBuilder {
voting_module_instantiate_info: ModuleInstantiateInfo {
code_id: cw4_voting_id,
msg: to_binary(&dao_voting_cw4::msg::InstantiateMsg {
cw4_group_code_id: cw4_id,
initial_members,
group_contract: GroupContract::New {
cw4_group_code_id: cw4_id,
initial_members,
},
})
.unwrap(),
admin: Some(Admin::CoreModule {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use dao_voting::{
};
use dao_voting_cw20_staked::msg::ActiveThreshold;
use dao_voting_cw20_staked::msg::ActiveThreshold::AbsoluteCount;
use dao_voting_cw4::msg::GroupContract;

use crate::testing::tests::ALTERNATIVE_ADDR;
use crate::{
Expand Down Expand Up @@ -793,8 +794,10 @@ pub fn _instantiate_with_cw4_groups_governance(
voting_module_instantiate_info: ModuleInstantiateInfo {
code_id: votemod_id,
msg: to_binary(&dao_voting_cw4::msg::InstantiateMsg {
cw4_group_code_id: cw4_id,
initial_members: initial_weights,
group_contract: GroupContract::New {
cw4_group_code_id: cw4_id,
initial_members: initial_weights,
},
})
.unwrap(),
admin: Some(Admin::CoreModule {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use dao_voting::{
pre_propose::PreProposeInfo,
threshold::{PercentageThreshold, Threshold::ThresholdQuorum},
};
use dao_voting_cw4::msg::GroupContract;

use crate::msg::InstantiateMsg;

Expand Down Expand Up @@ -572,8 +573,10 @@ pub(crate) fn instantiate_with_cw4_groups_governance(
voting_module_instantiate_info: ModuleInstantiateInfo {
code_id: votemod_id,
msg: to_binary(&dao_voting_cw4::msg::InstantiateMsg {
cw4_group_code_id: cw4_id,
initial_members: initial_weights,
group_contract: GroupContract::New {
cw4_group_code_id: cw4_id,
initial_members: initial_weights,
},
})
.unwrap(),
admin: Some(Admin::CoreModule {}),
Expand Down
129 changes: 60 additions & 69 deletions contracts/voting/dao-voting-cw4/schema/dao-voting-cw4.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,70 @@
"title": "InstantiateMsg",
"type": "object",
"required": [
"cw4_group_code_id",
"initial_members"
"group_contract"
],
"properties": {
"cw4_group_code_id": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"initial_members": {
"type": "array",
"items": {
"$ref": "#/definitions/Member"
}
"group_contract": {
"$ref": "#/definitions/GroupContract"
}
},
"additionalProperties": false,
"definitions": {
"GroupContract": {
"oneOf": [
{
"type": "object",
"required": [
"existing"
],
"properties": {
"existing": {
"type": "object",
"required": [
"address"
],
"properties": {
"address": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"new"
],
"properties": {
"new": {
"type": "object",
"required": [
"cw4_group_code_id",
"initial_members"
],
"properties": {
"cw4_group_code_id": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"initial_members": {
"type": "array",
"items": {
"$ref": "#/definitions/Member"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
"Member": {
"description": "A group member has a weight associated with them. This may all be equal, or may have meaning in the app that makes use of the group (eg. voting power)",
"type": "object",
Expand All @@ -49,63 +95,8 @@
"execute": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ExecuteMsg",
"oneOf": [
{
"type": "object",
"required": [
"member_changed_hook"
],
"properties": {
"member_changed_hook": {
"type": "object",
"required": [
"diffs"
],
"properties": {
"diffs": {
"type": "array",
"items": {
"$ref": "#/definitions/MemberDiff"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
],
"definitions": {
"MemberDiff": {
"description": "MemberDiff shows the old and new states for a given cw4 member They cannot both be None. old = None, new = Some -> Insert old = Some, new = Some -> Update old = Some, new = None -> Delete",
"type": "object",
"required": [
"key"
],
"properties": {
"key": {
"type": "string"
},
"new": {
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"old": {
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false
}
}
"type": "string",
"enum": []
},
"query": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Loading

0 comments on commit 5cfb3bf

Please sign in to comment.