Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit d796143

Browse files
authored
Merge pull request #168 from confio/release-0.13
Release 0.13
2 parents 35997ce + d07adfd commit d796143

File tree

21 files changed

+233
-164
lines changed

21 files changed

+233
-164
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,21 @@
22

33
## [Unreleased](https://github.com/confio/poe-contracts/tree/HEAD)
44

5-
[Full Changelog](https://github.com/confio/poe-contracts/compare/v0.12.0...HEAD)
5+
[Full Changelog](https://github.com/confio/poe-contracts/compare/v0.13.0...HEAD)
6+
7+
## [v0.13.0](https://github.com/confio/poe-contracts/tree/v0.13.0) (2022-07-26)
8+
9+
[Full Changelog](https://github.com/confio/poe-contracts/compare/v0.12.0...v0.13.0)
10+
11+
**Closed issues:**
12+
13+
- bug when defining the jailing start time [\#162](https://github.com/confio/poe-contracts/issues/162)
14+
- \[tgrade-validator-voting\] Add proposal validation during creation [\#156](https://github.com/confio/poe-contracts/issues/156)
15+
16+
**Merged pull requests:**
17+
18+
- Older version migration helper [\#164](https://github.com/confio/poe-contracts/pull/164) ([maurolacy](https://github.com/maurolacy))
19+
- Validate proposal during creation [\#163](https://github.com/confio/poe-contracts/pull/163) ([maurolacy](https://github.com/maurolacy))
620

721
## [v0.12.0](https://github.com/confio/poe-contracts/tree/v0.12.0) (2022-07-14)
822

Cargo.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/tg4-engagement/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tg4-engagement"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
authors = ["Ethan Frey <[email protected]>"]
55
edition = "2018"
66
description = "Simple TG4 implementation of group membership controlled by an admin"
@@ -25,9 +25,9 @@ cw-controllers = "0.13.4"
2525
cw-storage-plus = "0.13.4"
2626
cw-utils = "0.13.4"
2727
cw2 = "0.13.4"
28-
tg-utils = { version = "0.12.0", path = "../../packages/utils" }
29-
tg-bindings = { version = "0.12.0", path = "../../packages/bindings" }
30-
tg4 = { path = "../../packages/tg4", version = "0.12.0" }
28+
tg-utils = { version = "0.13.0", path = "../../packages/utils" }
29+
tg-bindings = { version = "0.13.0", path = "../../packages/bindings" }
30+
tg4 = { path = "../../packages/tg4", version = "0.13.0" }
3131
schemars = "0.8"
3232
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
3333
thiserror = "1.0.21"
@@ -37,4 +37,4 @@ anyhow = "1"
3737
cosmwasm-schema = "1.0.0"
3838
cw-multi-test = "0.13.4"
3939
derivative = "2"
40-
tg-bindings-test = { version = "0.12.0", path = "../../packages/bindings-test" }
40+
tg-bindings-test = { version = "0.13.0", path = "../../packages/bindings-test" }

contracts/tg4-group/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tg4-group"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
authors = ["Mauro Lacy <[email protected]>"]
55
edition = "2018"
66
description = "Simple tg4 implementation of group membership controlled by admin"
@@ -34,7 +34,7 @@ cw-controllers = "0.13.4"
3434
cw-storage-plus = "0.13.4"
3535
schemars = "0.8.1"
3636
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
37-
tg4 = { version = "0.12.0", path = "../../packages/tg4" }
37+
tg4 = { version = "0.13.0", path = "../../packages/tg4" }
3838
thiserror = { version = "1.0.23" }
3939

4040
[dev-dependencies]

contracts/tg4-mixer/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tg4-mixer"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
authors = ["Ethan Frey <[email protected]>"]
55
edition = "2018"
66
description = "TG4 implementation that combines two different groups with a merge function"
@@ -33,17 +33,17 @@ rust_decimal_macros = { version = "1.16", default-features = false }
3333
thiserror = "1.0.21"
3434
schemars = "0.8"
3535
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
36-
tg4 = { path = "../../packages/tg4", version = "0.12.0" }
37-
tg-utils = { path = "../../packages/utils", version = "0.12.0" }
38-
tg-bindings = { path = "../../packages/bindings", version = "0.12.0" }
36+
tg4 = { path = "../../packages/tg4", version = "0.13.0" }
37+
tg-utils = { path = "../../packages/utils", version = "0.13.0" }
38+
tg-bindings = { path = "../../packages/bindings", version = "0.13.0" }
3939

4040
[dev-dependencies]
4141
cosmwasm-schema = "1.0.0"
4242
# bench dependencies
4343
cosmwasm-vm = { version = "1.0.0" }
4444
cw-multi-test = "0.13.4"
45-
tg4-engagement = { path = "../tg4-engagement", version = "0.12.0", features = ["library"] }
46-
tg4-stake = { path = "../tg4-stake", version = "0.12.0", features = ["library"] }
45+
tg4-engagement = { path = "../tg4-engagement", version = "0.13.0", features = ["library"] }
46+
tg4-stake = { path = "../tg4-stake", version = "0.13.0", features = ["library"] }
4747

4848
[[bench]]
4949
name = "main"

contracts/tg4-stake/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tg4-stake"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
authors = ["Ethan Frey <[email protected]>"]
55
edition = "2018"
66
description = "TG4 implementation of group based on staked tokens"
@@ -28,11 +28,11 @@ cw-storage-plus = "0.13.4"
2828
itertools = "0.10"
2929
schemars = "0.8.1"
3030
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
31-
tg4 = { path = "../../packages/tg4", version = "0.12.0" }
32-
tg-utils = { path = "../../packages/utils", version = "0.12.0" }
33-
tg-bindings = { path = "../../packages/bindings", version = "0.12.0" }
31+
tg4 = { path = "../../packages/tg4", version = "0.13.0" }
32+
tg-utils = { path = "../../packages/utils", version = "0.13.0" }
33+
tg-bindings = { path = "../../packages/bindings", version = "0.13.0" }
3434
thiserror = "1.0.21"
3535

3636
[dev-dependencies]
3737
cosmwasm-schema = "1.0.0"
38-
tg-bindings-test = { path = "../../packages/bindings-test", version = "0.12.0" }
38+
tg-bindings-test = { path = "../../packages/bindings-test", version = "0.13.0" }

contracts/tg4-stake/src/claim.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ const DEFAULT_LIMIT: u32 = 30;
1919
pub struct Claim {
2020
/// Address owning the claim
2121
pub addr: Addr,
22-
/// Amount of tokens in claim
22+
/// Liquid amount of tokens in claim
2323
pub amount: Uint128,
24+
/// Vesting amount of tokens in claim
25+
pub vesting_amount: Option<Uint128>,
2426
/// Release time of the claim. Originally in `cw_controllers` it is an `Expiration` type, but
2527
/// here we need to query for claims via release time, and expiration is impossible to be
2628
/// properly sorted, as it is impossible to properly compare expiration by height and
@@ -43,10 +45,17 @@ impl<'a> IndexList<Claim> for ClaimIndexes<'a> {
4345
}
4446

4547
impl Claim {
46-
pub fn new(addr: Addr, amount: u128, released: Expiration, creation_height: u64) -> Self {
48+
pub fn new(
49+
addr: Addr,
50+
amount: u128,
51+
vesting_amount: u128,
52+
released: Expiration,
53+
creation_height: u64,
54+
) -> Self {
4755
Claim {
4856
addr,
4957
amount: amount.into(),
58+
vesting_amount: Some(vesting_amount.into()),
5059
release_at: released,
5160
creation_height,
5261
}
@@ -80,6 +89,7 @@ impl<'a> Claims<'a> {
8089
storage: &mut dyn Storage,
8190
addr: Addr,
8291
amount: Uint128,
92+
vesting_amount: Uint128,
8393
release_at: Expiration,
8494
creation_height: u64,
8595
) -> StdResult<()> {
@@ -92,11 +102,14 @@ impl<'a> Claims<'a> {
92102
match claim {
93103
Some(mut claim) => {
94104
claim.amount += amount;
105+
claim.vesting_amount =
106+
Some(claim.vesting_amount.unwrap_or_default() + vesting_amount);
95107
Ok(claim)
96108
}
97109
None => Ok(Claim {
98110
addr: addr.clone(),
99111
amount,
112+
vesting_amount: Some(vesting_amount),
100113
release_at,
101114
creation_height,
102115
}),
@@ -115,7 +128,7 @@ impl<'a> Claims<'a> {
115128
addr: &Addr,
116129
block: &BlockInfo,
117130
limit: impl Into<Option<u64>>,
118-
) -> StdResult<Uint128> {
131+
) -> StdResult<(Uint128, Uint128)> {
119132
let claims = self
120133
.claims
121134
.prefix(addr)
@@ -129,10 +142,14 @@ impl<'a> Claims<'a> {
129142

130143
let claims = self.collect_claims(claims, limit.into())?;
131144
let amount = claims.iter().map(|claim| claim.amount).sum();
145+
let vesting_amount = claims
146+
.iter()
147+
.map(|claim| claim.vesting_amount.unwrap_or_default())
148+
.sum();
132149

133150
self.release_claims(storage, claims)?;
134151

135-
Ok(amount)
152+
Ok((amount, vesting_amount))
136153
}
137154

138155
/// This iterates over all mature claims of any addresses, and removes them. Up to `limit`
@@ -211,7 +228,7 @@ impl<'a> Claims<'a> {
211228
storage: &mut dyn Storage,
212229
address: Addr,
213230
portion: Decimal,
214-
) -> StdResult<Uint128> {
231+
) -> StdResult<(Uint128, Uint128)> {
215232
let claims: StdResult<Vec<_>> = self
216233
.claims
217234
.prefix(&address)
@@ -220,21 +237,26 @@ impl<'a> Claims<'a> {
220237
let claims = claims?;
221238

222239
let mut total_slashed = Uint128::zero();
240+
let mut total_vesting_slashed = Uint128::zero();
223241

224242
for (release_at, claim) in claims {
225243
let key = (&address, release_at);
226244

227245
let slashed = claim.amount * portion;
246+
let vesting_slashed = claim.vesting_amount.unwrap_or_default() * portion;
228247
let mut new_claim = claim.clone();
229248
new_claim.amount -= slashed;
249+
new_claim.vesting_amount =
250+
Some(claim.vesting_amount.unwrap_or_default() - vesting_slashed);
230251

231252
self.claims
232253
.replace(storage, key, Some(&new_claim), Some(&claim))?;
233254

234255
total_slashed += slashed;
256+
total_vesting_slashed += vesting_slashed;
235257
}
236258

237-
Ok(total_slashed)
259+
Ok((total_slashed, total_vesting_slashed))
238260
}
239261

240262
pub fn query_claims<Q: CustomQuery>(

0 commit comments

Comments
 (0)