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

Update contracts to v2.4.0 with audit veto fix #778

Merged
merged 2 commits into from
Dec 13, 2023
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
156 changes: 78 additions & 78 deletions Cargo.lock

Large diffs are not rendered by default.

92 changes: 46 additions & 46 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ members = [
edition = "2021"
license = "BSD-3-Clause"
repository = "https://github.com/DA0-DA0/dao-contracts"
version = "2.3.0"
version = "2.4.0"

[profile.release]
codegen-units = 1
Expand All @@ -32,17 +32,17 @@ rpath = false
overflow-checks = true

[workspace.dependencies]
anyhow = {version = "1.0"}
anyhow = { version = "1.0" }
assert_matches = "1.5"
cosm-orc = {version = "4.0"}
cosm-orc = { version = "4.0" }
cosm-tome = "0.2"
cosmos-sdk-proto = "0.19"
cosmwasm-schema = {version = "1.2"}
cosmwasm-std = {version = "1.5.0", features = ["ibc3"]}
cosmwasm-storage = {version = "1.2"}
cosmwasm-schema = { version = "1.2" }
cosmwasm-std = { version = "1.5.0", features = ["ibc3"] }
cosmwasm-storage = { version = "1.2" }
cw-controllers = "1.1"
cw-multi-test = "0.18"
cw-storage-plus = {version = "1.1"}
cw-storage-plus = { version = "1.1" }
cw-utils = "1.0"
cw2 = "1.1"
cw20 = "1.1"
Expand All @@ -61,59 +61,59 @@ prost = "0.11"
quote = "1.0"
rand = "0.8"
schemars = "0.8"
serde = {version = "1.0", default-features = false, features = ["derive"]}
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
sg-multi-test = "3.1.0"
sg-std = "3.1.0"
sg721 = "3.1.0"
sg721-base = "3.1.0"
syn = {version = "1.0", features = ["derive"]}
syn = { version = "1.0", features = ["derive"] }
test-context = "0.1"
thiserror = {version = "1.0"}
thiserror = { version = "1.0" }
token-bindings = "0.11.0"
wynd-utils = "0.4"

# One commit ahead of version 0.3.0. Allows initialization with an
# optional owner.
cw-ownable = "0.5"

cw-admin-factory = {path = "./contracts/external/cw-admin-factory", version = "2.3.0"}
cw-denom = {path = "./packages/cw-denom", version = "2.3.0"}
cw-hooks = {path = "./packages/cw-hooks", version = "2.3.0"}
cw-paginate-storage = {path = "./packages/cw-paginate-storage", version = "2.3.0"}
cw-payroll-factory = {path = "./contracts/external/cw-payroll-factory", version = "2.3.0"}
cw-stake-tracker = {path = "./packages/cw-stake-tracker", version = "2.3.0"}
cw-tokenfactory-issuer = {path = "./contracts/external/cw-tokenfactory-issuer", version = "2.3.0"}
cw-vesting = {path = "./contracts/external/cw-vesting", version = "2.3.0"}
cw-wormhole = {path = "./packages/cw-wormhole", version = "2.3.0"}
cw20-stake = {path = "./contracts/staking/cw20-stake", version = "2.3.0"}
cw721-controllers = {path = "./packages/cw721-controllers", version = "2.3.0"}
cw721-roles = {path = "./contracts/external/cw721-roles", version = "2.3.0"}
dao-cw721-extensions = {path = "./packages/dao-cw721-extensions", version = "2.3.0"}
dao-dao-core = {path = "./contracts/dao-dao-core", version = "2.3.0"}
dao-dao-macros = {path = "./packages/dao-dao-macros", version = "2.3.0"}
dao-hooks = {path = "./packages/dao-hooks", version = "2.3.0"}
dao-interface = {path = "./packages/dao-interface", version = "2.3.0"}
dao-pre-propose-approval-single = {path = "./contracts/pre-propose/dao-pre-propose-approval-single", version = "2.3.0"}
dao-pre-propose-approver = {path = "./contracts/pre-propose/dao-pre-propose-approver", version = "2.3.0"}
dao-pre-propose-base = {path = "./packages/dao-pre-propose-base", version = "2.3.0"}
dao-pre-propose-multiple = {path = "./contracts/pre-propose/dao-pre-propose-multiple", version = "2.3.0"}
dao-pre-propose-single = {path = "./contracts/pre-propose/dao-pre-propose-single", version = "2.3.0"}
dao-proposal-condorcet = {path = "./contracts/proposal/dao-proposal-condorcet", version = "2.3.0"}
dao-proposal-hook-counter = {path = "./contracts/test/dao-proposal-hook-counter", version = "2.3.0"}
dao-proposal-multiple = {path = "./contracts/proposal/dao-proposal-multiple", version = "2.3.0"}
dao-proposal-single = {path = "./contracts/proposal/dao-proposal-single", version = "2.3.0"}
dao-proposal-sudo = {path = "./contracts/test/dao-proposal-sudo", version = "2.3.0"}
dao-test-custom-factory = {path = "./contracts/test/dao-test-custom-factory", version = "2.3.0"}
dao-testing = {path = "./packages/dao-testing", version = "2.3.0"}
dao-voting = {path = "./packages/dao-voting", version = "2.3.0"}
dao-voting-cw20-balance = {path = "./contracts/test/dao-voting-cw20-balance", version = "2.3.0"}
dao-voting-cw20-staked = {path = "./contracts/voting/dao-voting-cw20-staked", version = "2.3.0"}
dao-voting-cw4 = {path = "./contracts/voting/dao-voting-cw4", version = "2.3.0"}
dao-voting-cw721-roles = {path = "./contracts/voting/dao-voting-cw721-roles", version = "2.3.0"}
dao-voting-cw721-staked = {path = "./contracts/voting/dao-voting-cw721-staked", version = "2.3.0"}
dao-voting-token-staked = {path = "./contracts/voting/dao-voting-token-staked", version = "2.3.0"}
cw-admin-factory = { path = "./contracts/external/cw-admin-factory", version = "2.4.0" }
cw-denom = { path = "./packages/cw-denom", version = "2.4.0" }
cw-hooks = { path = "./packages/cw-hooks", version = "2.4.0" }
cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.4.0" }
cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.4.0" }
cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.4.0" }
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.4.0" }
cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.4.0" }
cw-wormhole = { path = "./packages/cw-wormhole", version = "2.4.0" }
cw20-stake = { path = "./contracts/staking/cw20-stake", version = "2.4.0" }
cw721-controllers = { path = "./packages/cw721-controllers", version = "2.4.0" }
cw721-roles = { path = "./contracts/external/cw721-roles", version = "2.4.0" }
dao-cw721-extensions = { path = "./packages/dao-cw721-extensions", version = "2.4.0" }
dao-dao-core = { path = "./contracts/dao-dao-core", version = "2.4.0" }
dao-dao-macros = { path = "./packages/dao-dao-macros", version = "2.4.0" }
dao-hooks = { path = "./packages/dao-hooks", version = "2.4.0" }
dao-interface = { path = "./packages/dao-interface", version = "2.4.0" }
dao-pre-propose-approval-single = { path = "./contracts/pre-propose/dao-pre-propose-approval-single", version = "2.4.0" }
dao-pre-propose-approver = { path = "./contracts/pre-propose/dao-pre-propose-approver", version = "2.4.0" }
dao-pre-propose-base = { path = "./packages/dao-pre-propose-base", version = "2.4.0" }
dao-pre-propose-multiple = { path = "./contracts/pre-propose/dao-pre-propose-multiple", version = "2.4.0" }
dao-pre-propose-single = { path = "./contracts/pre-propose/dao-pre-propose-single", version = "2.4.0" }
dao-proposal-condorcet = { path = "./contracts/proposal/dao-proposal-condorcet", version = "2.4.0" }
dao-proposal-hook-counter = { path = "./contracts/test/dao-proposal-hook-counter", version = "2.4.0" }
dao-proposal-multiple = { path = "./contracts/proposal/dao-proposal-multiple", version = "2.4.0" }
dao-proposal-single = { path = "./contracts/proposal/dao-proposal-single", version = "2.4.0" }
dao-proposal-sudo = { path = "./contracts/test/dao-proposal-sudo", version = "2.4.0" }
dao-test-custom-factory = { path = "./contracts/test/dao-test-custom-factory", version = "2.4.0" }
dao-testing = { path = "./packages/dao-testing", version = "2.4.0" }
dao-voting = { path = "./packages/dao-voting", version = "2.4.0" }
dao-voting-cw20-balance = { path = "./contracts/test/dao-voting-cw20-balance", version = "2.4.0" }
dao-voting-cw20-staked = { path = "./contracts/voting/dao-voting-cw20-staked", version = "2.4.0" }
dao-voting-cw4 = { path = "./contracts/voting/dao-voting-cw4", version = "2.4.0" }
dao-voting-cw721-roles = { path = "./contracts/voting/dao-voting-cw721-roles", version = "2.4.0" }
dao-voting-cw721-staked = { path = "./contracts/voting/dao-voting-cw721-staked", version = "2.4.0" }
dao-voting-token-staked = { path = "./contracts/voting/dao-voting-token-staked", version = "2.4.0" }

# v1 dependencies. used for state migrations.
cw-core-v1 = { package = "cw-core", version = "0.1.0" }
Expand Down
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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.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.3.0",
"contract_version": "2.4.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
46 changes: 22 additions & 24 deletions contracts/proposal/dao-proposal-multiple/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ pub fn execute_execute(
.ok_or(ContractError::NoSuchProposal { id: proposal_id })?;

let config = CONFIG.load(deps.storage)?;

// determine if this sender can execute
let mut sender_can_execute = true;
if config.only_members_execute {
let power = get_voting_power(
deps.as_ref(),
Expand All @@ -461,16 +464,7 @@ pub fn execute_execute(
Some(prop.start_height),
)?;

// if there is no veto config, then caller is not the vetoer
// if there is, we validate the caller addr
let vetoer_call = prop
.veto
.as_ref()
.map_or(false, |veto_config| veto_config.vetoer == info.sender);

if power.is_zero() && !vetoer_call {
return Err(ContractError::Unauthorized {});
}
sender_can_execute = !power.is_zero();
}

// Check here that the proposal is passed or timelocked.
Expand All @@ -481,27 +475,31 @@ pub fn execute_execute(
prop.update_status(&env.block)?;
let old_status = prop.status;
match &prop.status {
Status::Passed => (),
Status::VetoTimelock { expiration } => {
Status::Passed => {
// if passed, verify sender can execute
if !sender_can_execute {
return Err(ContractError::Unauthorized {});
}
}
Status::VetoTimelock { .. } => {
let veto_config = prop
.veto
.as_ref()
.ok_or(VetoError::NoVetoConfiguration {})?;

// Check if the sender is the vetoer
match veto_config.vetoer == info.sender {
// if sender is the vetoer we validate the early exec flag
true => veto_config.check_early_execute_enabled()?,
// otherwise timelock must be expired in order to execute
false => {
// it should never be expired here since the status updates
// to passed after the timelock expires, but let's check
// anyway. i.e. this error should always be returned.
if !expiration.is_expired(&env.block) {
return Err(ContractError::VetoError(VetoError::Timelocked {}));
}
// check that the sender is the vetoer
if veto_config.vetoer != info.sender {
// if the sender can normally execute, but is not the vetoer,
// return timelocked error. otherwise return unauthorized.
if sender_can_execute {
return Err(ContractError::VetoError(VetoError::Timelocked {}));
} else {
return Err(ContractError::Unauthorized {});
}
}

// if veto timelocked, only allow execution if early_execute enabled
veto_config.check_early_execute_enabled()?;
}
_ => {
return Err(ContractError::NotPassed {});
Expand Down
Loading
Loading