Skip to content

Commit

Permalink
Two-step ownership transfer for staking contracts (#597)
Browse files Browse the repository at this point in the history
* cw20-stake-external-rewards two-step ownership transfer.

* Remove manager from cw20-stake-external-rewards.

* Update to latest cw-ownable version.

* Add v1 -> v2 migration for cw20-stake-reward-distributor.

* Two-step ownership transfers for cw20-stake-external-rewards

* v1 -> v2 migration for cw20-stake-external-rewards.

* Remove manager from cw20-stake.

* Two-step ownership transfer for cw20-stake

* Add v1->v2 migration for stake-cw20.

* Move v2 config to new storage key in staking contracts.
  • Loading branch information
0xekez authored Jan 2, 2023
1 parent b46a494 commit 1673241
Show file tree
Hide file tree
Showing 36 changed files with 2,125 additions and 1,322 deletions.
291 changes: 207 additions & 84 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ cw2 = "0.16"
cw20 = "0.16"
cw721 = "0.16"
cw20-base = "0.16"
cw-core-v1 = { package = "cw-core", version = "0.1.0", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
cw-multi-test = "0.16"
cw721-base = "0.16"
cw-controllers = "0.16"
Expand All @@ -49,15 +48,18 @@ cw4-group = "0.16"
rand = "0.8"
cw4 = "0.16"
cw3 = "0.16"
indexmap = "1.9"
serde = "1.0"
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features = ["derive"] }

# One commit ahead of version 0.3.0. Allows initialization with an
# optional owner.
cw-ownable = { git = "https://github.com/steak-enjoyers/cw-plus-plus", rev = "50d4d9333305894457e5028072a0465f4635b15b" }


cw-admin-factory = { path = "./contracts/external/cw-admin-factory" }
dao-core = { path = "./contracts/dao-core" }

dao-proposal-single = { path = "./contracts/proposal/dao-proposal-single" }
dao-proposal-multiple = { path = "./contracts/proposal/dao-proposal-multiple" }
dao-pre-propose-single = { path = "./contracts/pre-propose/dao-pre-propose-single" }
Expand All @@ -82,6 +84,12 @@ dao-vote-hooks = { path = "./packages/dao-vote-hooks" }
cw-paginate = { path = "./packages/cw-paginate" }
dao-interface = { path = "./packages/dao-interface" }
dao-voting = { path = "./packages/dao-voting" }

# v1 dependencies. used for state migrations.
cw-core-v1 = { package = "cw-core", version = "0.1.0", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
cw-proposal-single-v1 = { package = "cw-proposal-single", version = "0.1.0", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
voting-v1 = { package = "voting", version = "0.1.0", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
cw-utils-v1 = {package = "cw-utils", version = "0.13"}
cw20-stake-reward-distributor-v1 = { package = "stake-cw20-reward-distributor", version = "0.1.0", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
cw20-stake-external-rewards-v1 = { package = "stake-cw20-external-rewards", version = "0.2.6", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
cw20-stake-v1 = { package = "cw20-stake", version = "0.2.6", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
20 changes: 15 additions & 5 deletions ci/integration-tests/src/tests/cw_core_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,23 @@ fn instantiate_with_admin(chain: &mut Chain) {
.query("cw20_stake", &cw20_stake::msg::QueryMsg::GetConfig {})
.unwrap();
let config_res: cw20_stake::state::Config = res.data().unwrap();
assert_eq!(config_res.unstaking_duration, Some(Duration::Time(1209600)));

let res = chain
.orc
.query("cw20_stake", &cw20_stake::msg::QueryMsg::Ownership {})
.unwrap();
let ownership: cw20_stake::msg::Ownership<Addr> = res.data().unwrap();
assert_eq!(
config_res.owner,
Some(Addr::unchecked(
chain.orc.contract_map.address("dao_core").unwrap()
))
ownership,
cw20_stake::msg::Ownership::<Addr> {
owner: Some(Addr::unchecked(
chain.orc.contract_map.address("dao_core").unwrap()
)),
pending_owner: None,
pending_expiry: None
}
);
assert_eq!(config_res.manager, None);

let res = &chain
.orc
Expand Down
1 change: 0 additions & 1 deletion contracts/dao-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ library = []

[dependencies]
cosmwasm-std = { workspace = true, features = ["ibc3"] }
cosmwasm-storage = { workspace = true }
cosmwasm-schema = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
Expand Down
12 changes: 6 additions & 6 deletions contracts/staking/cw20-stake-external-rewards/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
[package]
name = "stake-cw20-external-rewards"
name = "cw20-stake-external-rewards"
version = "2.0.0-beta"
authors = ["Ben2x4 <[email protected]>"]
authors = ["Ben2x4 <[email protected]>", "ekez <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
repository = "https://github.com/DA0-DA0/cw-dao/contracts/cw20-stakeable"
description = "CW20 token that can be staked and staked balance can be queried at any height"

[lib]
crate-type = ["cdylib", "rlib"]
Expand All @@ -25,9 +22,12 @@ cw20 = { workspace = true }
cw-utils = { workspace = true }
cw20-base = { workspace = true, features = ["library"] }
cw2 = { workspace = true }

thiserror = { workspace = true }
cw20-stake = { workspace = true, features = ["library"]}
cw-ownable = { workspace = true }

cw20-stake-external-rewards-v1 = { workspace = true }
cw20-013 = { package = "cw20", version = "0.13" }

[dev-dependencies]
cw-multi-test = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::write_api;
use stake_cw20_external_rewards::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use cw20_stake_external_rewards::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
Expand Down
Loading

0 comments on commit 1673241

Please sign in to comment.