From c9ec7717ed22ec32d0a66fae2a4ba40ffd94c3d8 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 23 Nov 2019 12:43:20 +0800 Subject: [PATCH 1/3] fix: get the ledger after `clear_mature_deposits` --- srml/staking/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 2ab27acae..5caa9474c 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -583,13 +583,14 @@ decl_module! { /// called by controller fn deposit_extra(origin, value: RingBalanceOf, promise_month: u32) { let controller = ensure_signed(origin)?; - let mut ledger = Self::ledger(&controller).ok_or("not a controller")?; + if Self::ledger(&controller).is_none() { return Err("not a controller"); } ensure!(promise_month >= 3 && promise_month <= 36, "months at least is 3 and at most is 36."); Self::clear_mature_deposits(&controller); let now = >::now(); + let mut ledger = Self::ledger(&controller).unwrap(); let StakingLedger { stash, active_ring, From 7795a3022b2d85858f089d708d7c990193ced9e2 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Mon, 25 Nov 2019 17:28:57 +0800 Subject: [PATCH 2/3] add: lock types fix: typo update: format --- types.json | 109 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 46 deletions(-) diff --git a/types.json b/types.json index 7eacd5184..5c6a8e7c7 100644 --- a/types.json +++ b/types.json @@ -1,48 +1,65 @@ { - "EpochDuration": "u64", - "EraIndex": "u32", - "RingBalanceOf": "u128", - "KtonBalanceOf": "u128", - "ExtendedBalance": "u128", - "ValidatorPrefs": { - "unstake_threshold": "Compact", - "validator_payment_ratio": "Perbill" - }, - "StakingBalance": { - "_enum": { - "Ring": "RingBalanceOf", - "Kton": "KtonBalanceOf" - } - }, - "TimeDepositItem": { - "value": "Compact", - "start_time": "Compact", - "expire_time": "Compact" - }, - "NormalLock": { - "amount": "u128", - "util": "Moment", - }, - "StakingLock": { - "staking_amount": "u128", - "unbondings": "Vec" - }, - "StakingLedger": { - "stash": "AccountId", - "active_ring": "Compact", - "active_deposit_ring": "Compact", - "active_kton": "Compact", - "deposit_items": "Vec", - "ring_staking_lock": "StakingLock", - "kton_staking_lock": "StakingLock" - }, - "IndividualExposure": { - "who": "AccountId", - "value": "ExtendedBalance" - }, - "Exposure": { - "total": "ExtendedBalance", - "own": "ExtendedBalance", - "others": "Vec" - } + "EpochDuration": "u64", + "EraIndex": "u32", + + "RingBalanceOf": "u128", + "KtonBalanceOf": "u128", + "ExtendedBalance": "u128", + + "StakingBalance": { + "_enum": { + "Ring": "RingBalanceOf", + "Kton": "KtonBalanceOf" + } + }, + + "IndividualExposure": { + "who": "AccountId", + "value": "ExtendedBalance" + }, + "Exposure": { + "total": "ExtendedBalance", + "own": "ExtendedBalance", + "others": "Vec" + }, + + "ValidatorPrefs": { + "unstake_threshold": "Compact", + "validator_payment_ratio": "Perbill" + }, + + "StakingLedger": { + "stash": "AccountId", + "active_ring": "Compact", + "active_deposit_ring": "Compact", + "active_kton": "Compact", + "deposit_items": "Vec", + "ring_staking_lock": "StakingLock", + "kton_staking_lock": "StakingLock" + }, + "TimeDepositItem": { + "value": "Compact", + "start_time": "Compact", + "expire_time": "Compact" + }, + + "BalanceLock": { + "id": "Vec", + "withdraw_lock": "WithdrawLock", + "reasons": "WithdrawReasons" + }, + "WithdrawLock": { + "_enum": { + "Normal": "NormalLock", + "WithStaking": "StakingLock" + } + }, + "NormalLock": { + "amount": "u128", + "until": "Moment" + }, + "StakingLock": { + "staking_amount": "u128", + "unbondings": "Vec" + } } \ No newline at end of file From 56d5cb26eebf83c733b9c040096a41e69a1a2713 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Mon, 25 Nov 2019 17:33:15 +0800 Subject: [PATCH 3/3] update: format --- types.json | 1 - 1 file changed, 1 deletion(-) diff --git a/types.json b/types.json index 5c6a8e7c7..081c517b0 100644 --- a/types.json +++ b/types.json @@ -5,7 +5,6 @@ "RingBalanceOf": "u128", "KtonBalanceOf": "u128", "ExtendedBalance": "u128", - "StakingBalance": { "_enum": { "Ring": "RingBalanceOf",