Skip to content

Commit

Permalink
Merge pull request #12 from comdex-official/remove-target
Browse files Browse the repository at this point in the history
Removed `target` from config and InstantiateMsg
  • Loading branch information
Subham2804 authored Nov 12, 2022
2 parents d5f9c6e + f3473d4 commit 5a4d651
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Governance

**TODO:** Remove 'target' from instantiate msg an update this README.

This is a base implementation of governance contract for Harbor Protocol . The contract can be extended to be used by other protocol with relatively same proposal execution behaviour.

The contract uses the binding from package/bindings in the root directory to interact with Comdex Native Modules for Queries and Messages.
Expand All @@ -16,7 +14,6 @@ instantiate this contract.
pub struct InstantiateMsg {
pub threshold: Threshold,
pub locking_contract: Addr,
pub target: String,
}
```

Expand Down Expand Up @@ -404,4 +401,4 @@ AppGovConfig {

* `proposal_count` - Count of proposals for the application.
* `current_supply` - Total supply of the governance token.
* `active_participation_supply` - Total weight of the participated votes.
* `active_participation_supply` - Total weight of the participated votes.
11 changes: 0 additions & 11 deletions contracts/governance/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ pub fn instantiate(
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
let cfg = Config {
threshold: msg.threshold,
target: msg.target,
locking_contract: deps.api.addr_validate(msg.locking_contract.as_str())?,
};
CONFIG.save(deps.storage, &cfg)?;
Expand Down Expand Up @@ -1001,7 +1000,6 @@ mod tests {
threshold: Decimal::one(),
quorum: Decimal::one(),
},
target: String::new(),
locking_contract: Addr::unchecked(""),
};
let result =
Expand All @@ -1018,15 +1016,13 @@ mod tests {

let not_acceptable_msg1 = InstantiateMsg {
threshold: Threshold::AbsoluteCount { weight: 10 },
target: Duration::Height(3).to_string(),
locking_contract: Addr::unchecked("locking_contract"),
};

let not_acceptable_msg2 = InstantiateMsg {
threshold: Threshold::AbsolutePercentage {
percentage: Decimal::percent(50),
},
target: Duration::Height(3).to_string(),
locking_contract: Addr::unchecked("locking_contract"),
};

Expand All @@ -1035,7 +1031,6 @@ mod tests {
threshold: Decimal::percent(50),
quorum: Decimal::percent(33),
},
target: Duration::Height(3).to_string(),
locking_contract: Addr::unchecked("locking_contract"),
};

Expand Down Expand Up @@ -1425,7 +1420,6 @@ mod tests {
threshold: Decimal::percent(50),
quorum: Decimal::percent(33),
},
target: Duration::Height(3).to_string(),
locking_contract: Addr::unchecked("locking_contract"),
};
instantiate(deps.as_mut(), mock_env(), info.clone(), expected_msg).unwrap();
Expand Down Expand Up @@ -1502,7 +1496,6 @@ mod tests {
threshold: Decimal::percent(50),
quorum: Decimal::percent(33),
},
target: Duration::Height(3).to_string(),
locking_contract: Addr::unchecked("locking_contract"),
};
instantiate(deps.as_mut(), mock_env(), info.clone(), expected_msg).unwrap();
Expand Down Expand Up @@ -1630,7 +1623,6 @@ mod tests {
threshold: Decimal::percent(50),
quorum: Decimal::percent(33),
},
target: Duration::Height(3).to_string(),
locking_contract: Addr::unchecked("locking_contract"),
};
_ = CONFIG.save(&mut deps.storage, &cfg);
Expand Down Expand Up @@ -1687,7 +1679,6 @@ mod tests {
threshold: Decimal::one(),
quorum: Decimal::one(),
},
target: String::new(),
locking_contract: Addr::unchecked("locking-contract"),
};
let sender = Addr::unchecked("sender");
Expand Down Expand Up @@ -1774,7 +1765,6 @@ mod tests {
threshold: Decimal::one(),
quorum: Decimal::one(),
},
target: String::new(),
locking_contract: Addr::unchecked("locking-contract"),
};
let sender = Addr::unchecked("sender");
Expand Down Expand Up @@ -1843,7 +1833,6 @@ mod tests {
threshold: Decimal::one(),
quorum: Decimal::one(),
},
target: String::new(),
locking_contract: Addr::unchecked("locking-contract"),
};
let sender = Addr::unchecked("sender");
Expand Down
5 changes: 2 additions & 3 deletions contracts/governance/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::state::Votes;
use comdex_bindings::ComdexMessages;
use cosmwasm_std::{Addr, Decimal, Timestamp,Uint128};
use cosmwasm_std::{Addr, Decimal, Timestamp, Uint128};
use cw3::{Status, Vote};
use cw_utils::{Duration, Expiration, Threshold};
use schemars::JsonSchema;
Expand All @@ -10,10 +10,9 @@ use serde::{Deserialize, Serialize};
pub struct InstantiateMsg {
pub threshold: Threshold,
pub locking_contract: Addr,
pub target: String,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug,Eq)]
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Eq)]
pub struct Voter {
pub addr: String,
pub weight: u64,
Expand Down
7 changes: 3 additions & 4 deletions contracts/governance/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ const PRECISION_FACTOR: u128 = 1_000_000_000;
pub struct Config {
pub threshold: Threshold,
pub locking_contract: Addr,
pub target: String,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug,Eq)]
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Eq)]
pub struct AppGovConfig {
pub proposal_count: u64,

Expand All @@ -35,7 +34,7 @@ pub struct AppProposalConfig {
pub proposal: Proposal,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug,Eq)]
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Eq)]
#[serde(rename_all = "snake_case")]
pub struct TokenSupply {
// total token in the system.
Expand Down Expand Up @@ -194,7 +193,7 @@ impl Proposal {
}

// weight of votes for each option
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug,Eq)]
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Eq)]
pub struct Votes {
pub yes: u128,
pub no: u128,
Expand Down

0 comments on commit 5a4d651

Please sign in to comment.