diff --git a/CHANGELOG.md b/CHANGELOG.md index f2b20537a..56dfdc12b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,15 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [C] Changes is `Cere` Runtime - [D] Changes is `Cere Dev` Runtime -## [vNext] +## [5.2.2] -### Added - -- ... - -### Changed - -- ... +- [C,D] Depositing extra amount in ddc-customers pallet is fixed ## [5.2.1] diff --git a/Cargo.lock b/Cargo.lock index 2656bf05e..74e7b2129 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -685,7 +685,7 @@ dependencies = [ [[package]] name = "cere-cli" -version = "5.2.1" +version = "5.2.2" dependencies = [ "cere-client", "cere-service", @@ -702,7 +702,7 @@ dependencies = [ [[package]] name = "cere-client" -version = "5.2.1" +version = "5.2.2" dependencies = [ "cere-dev-runtime", "cere-runtime", @@ -734,7 +734,7 @@ dependencies = [ [[package]] name = "cere-dev-runtime" -version = "5.2.1" +version = "5.2.2" dependencies = [ "cere-runtime-common", "ddc-primitives", @@ -819,7 +819,7 @@ dependencies = [ [[package]] name = "cere-rpc" -version = "5.2.1" +version = "5.2.2" dependencies = [ "jsonrpsee", "node-primitives", @@ -848,7 +848,7 @@ dependencies = [ [[package]] name = "cere-runtime" -version = "5.2.1" +version = "5.2.2" dependencies = [ "cere-runtime-common", "ddc-primitives", @@ -933,7 +933,7 @@ dependencies = [ [[package]] name = "cere-runtime-common" -version = "5.2.1" +version = "5.2.2" dependencies = [ "frame-support", "frame-system", @@ -952,7 +952,7 @@ dependencies = [ [[package]] name = "cere-service" -version = "5.2.1" +version = "5.2.2" dependencies = [ "cere-client", "cere-dev-runtime", @@ -1585,7 +1585,7 @@ dependencies = [ [[package]] name = "ddc-primitives" -version = "5.2.1" +version = "5.2.2" dependencies = [ "frame-support", "frame-system", @@ -4734,7 +4734,7 @@ dependencies = [ [[package]] name = "pallet-chainbridge" -version = "5.2.1" +version = "5.2.2" dependencies = [ "frame-support", "frame-system", @@ -4837,7 +4837,7 @@ dependencies = [ [[package]] name = "pallet-ddc-clusters" -version = "5.2.1" +version = "5.2.2" dependencies = [ "ddc-primitives", "frame-benchmarking", @@ -4863,7 +4863,7 @@ dependencies = [ [[package]] name = "pallet-ddc-customers" -version = "5.2.1" +version = "5.2.2" dependencies = [ "ddc-primitives", "frame-benchmarking", @@ -4886,7 +4886,7 @@ dependencies = [ [[package]] name = "pallet-ddc-nodes" -version = "5.2.1" +version = "5.2.2" dependencies = [ "ddc-primitives", "frame-benchmarking", @@ -4907,7 +4907,7 @@ dependencies = [ [[package]] name = "pallet-ddc-payouts" -version = "5.2.1" +version = "5.2.2" dependencies = [ "byte-unit", "chrono", @@ -4931,7 +4931,7 @@ dependencies = [ [[package]] name = "pallet-ddc-staking" -version = "5.2.1" +version = "5.2.2" dependencies = [ "ddc-primitives", "frame-benchmarking", @@ -5026,7 +5026,7 @@ dependencies = [ [[package]] name = "pallet-erc20" -version = "5.2.1" +version = "5.2.2" dependencies = [ "frame-benchmarking", "frame-support", @@ -5045,7 +5045,7 @@ dependencies = [ [[package]] name = "pallet-erc721" -version = "5.2.1" +version = "5.2.2" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/Cargo.toml b/Cargo.toml index 462065269..1186edff8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "5.2.1" +version = "5.2.2" authors = ["Cerebellum-Network"] edition = "2021" homepage = "https://cere.network/" diff --git a/pallets/ddc-customers/src/lib.rs b/pallets/ddc-customers/src/lib.rs index 1a22a5905..0d6aa30fc 100644 --- a/pallets/ddc-customers/src/lib.rs +++ b/pallets/ddc-customers/src/lib.rs @@ -557,11 +557,12 @@ pub mod pallet { fn update_ledger_and_deposit( owner: &T::AccountId, ledger: &AccountsLedger, + amount: BalanceOf, ) -> DispatchResult { ::Currency::transfer( owner, &Self::account_id(), - ledger.total, + amount, ExistenceRequirement::AllowDeath, )?; >::insert(owner, ledger); @@ -693,14 +694,14 @@ pub mod pallet { let owner_balance = ::Currency::free_balance(&owner); let value = value.min(owner_balance); - let item = AccountsLedger { + let ledger = AccountsLedger { owner: owner.clone(), total: value, active: value, unlocking: Default::default(), }; - Self::update_ledger_and_deposit(&owner, &item) + Self::update_ledger_and_deposit(&owner, &ledger, value) .map_err(|_| Error::::TransferFailed)?; Self::deposit_event(Event::::Deposited { owner_id: owner, amount: value }); @@ -724,7 +725,7 @@ pub mod pallet { Error::::InsufficientDeposit ); - Self::update_ledger_and_deposit(&owner, &ledger) + Self::update_ledger_and_deposit(&owner, &ledger, extra) .map_err(|_| Error::::TransferFailed)?; Self::deposit_event(Event::::Deposited { owner_id: owner, amount: extra }); diff --git a/pallets/ddc-customers/src/tests.rs b/pallets/ddc-customers/src/tests.rs index 27cfbfbdf..7c8921200 100644 --- a/pallets/ddc-customers/src/tests.rs +++ b/pallets/ddc-customers/src/tests.rs @@ -111,7 +111,7 @@ fn deposit_and_deposit_extra_works() { Error::::TransferFailed ); - let amount1 = 10_u128; + let amount1 = 90_u128; // Deposited assert_ok!(DdcCustomers::deposit(RuntimeOrigin::signed(account_1), amount1)); @@ -141,23 +141,33 @@ fn deposit_and_deposit_extra_works() { Error::::NotOwner ); + // Deposit of an extra amount that is more than the customer's total balance fails + let extra_amount1 = 20_u128; + assert_noop!( + DdcCustomers::deposit_extra(RuntimeOrigin::signed(account_1), extra_amount1), + Error::::TransferFailed + ); + + let extra_amount2 = 5_u128; + // Deposited extra - let amount2 = 20_u128; - assert_ok!(DdcCustomers::deposit_extra(RuntimeOrigin::signed(account_1), amount2)); + assert_ok!(DdcCustomers::deposit_extra(RuntimeOrigin::signed(account_1), extra_amount2)); // Check storage assert_eq!( DdcCustomers::ledger(account_1), Some(AccountsLedger { owner: account_1, - total: amount1 + amount2, - active: amount1 + amount2, + total: amount1 + extra_amount2, + active: amount1 + extra_amount2, unlocking: Default::default(), }) ); // Checking that event was emitted - System::assert_last_event(Event::Deposited { owner_id: account_1, amount: amount2 }.into()); + System::assert_last_event( + Event::Deposited { owner_id: account_1, amount: extra_amount2 }.into(), + ); }) } diff --git a/runtime/cere-dev/src/lib.rs b/runtime/cere-dev/src/lib.rs index f8fedfeef..3f0e11cbd 100644 --- a/runtime/cere-dev/src/lib.rs +++ b/runtime/cere-dev/src/lib.rs @@ -133,7 +133,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 52100, + spec_version: 52200, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 15, diff --git a/runtime/cere/src/lib.rs b/runtime/cere/src/lib.rs index 2f0db55d7..10c40a4ff 100644 --- a/runtime/cere/src/lib.rs +++ b/runtime/cere/src/lib.rs @@ -128,7 +128,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 52100, + spec_version: 52200, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 15,