Composite accounts (#4820)

* Basic account composition.

* Add try_mutate_exists

* De-duplicate

* Refactor away the UpdateBalanceOutcome

* Expunge final UpdateBalanceOutcome refs

* Refactor transfer

* Refactor reservable currency stuff.

* Test with the alternative setup.

* Fixes

* Test with both setups.

* Fixes

* Fix

* Fix macros

* Make indices opt-in

* Remove CreationFee, and make indices opt-in.

* Fix construct_runtime

* Fix last few bits

* Fix tests

* Update trait impls

* Don't hardcode the system event

* Make tests build and fix some stuff.

* Pointlessly bump runtime version

* Fix benchmark

* Another fix

* Whitespace

* Make indices module economically safe

* Migrations for indices.

* Fix

* Whilespace

* Trim defunct migrations

* Remove unused storage item

* More contains_key fixes

* Docs.

* Bump runtime

* Remove unneeded code

* Fix test

* Fix test

* Update frame/balances/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Fix ED logic

* Repatriate reserved logic

* Typo

* Fix typo

* Update frame/system/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update frame/system/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Last few fixes

* Another fix

* Build fix

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Jaco Greeff <jacogr@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Gavin Wood
2020-02-14 00:47:51 +00:00
committed by GitHub
parent d3fa8c91af
commit 5b7512e2e4
79 changed files with 2459 additions and 2100 deletions
+12 -13
View File
@@ -91,7 +91,7 @@ use frame_support::{
decl_storage, decl_event, ensure, decl_module, decl_error, weights::SimpleDispatchInfo,
traits::{
Currency, Get, LockableCurrency, LockIdentifier, ReservableCurrency, WithdrawReasons,
ChangeMembers, OnUnbalanced, WithdrawReason, Contains
ChangeMembers, OnUnbalanced, WithdrawReason, Contains, BalanceStatus
}
};
use sp_phragmen::ExtendedBalance;
@@ -314,7 +314,7 @@ decl_module! {
let valid = Self::is_defunct_voter(&target);
if valid {
// reporter will get the voting bond of the target
T::Currency::repatriate_reserved(&target, &reporter, T::VotingBond::get())?;
T::Currency::repatriate_reserved(&target, &reporter, T::VotingBond::get(), BalanceStatus::Free)?;
// remove the target. They are defunct.
Self::do_remove_voter(&target, false);
} else {
@@ -814,23 +814,22 @@ mod tests {
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnReapAccount = Balances;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
pub const CreationFee: u64 = 0;
}
}
impl pallet_balances::Trait for Test {
type Balance = u64;
type OnNewAccount = ();
type OnReapAccount = System;
type Event = Event;
type TransferPayment = ();
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type CreationFee = CreationFee;
}
type AccountStore = frame_system::Module<Test>;
}
parameter_types! {
pub const CandidacyBond: u64 = 3;
@@ -937,7 +936,7 @@ mod tests {
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Module, Call, Event},
System: system::{Module, Call, Event<T>},
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>},
Elections: elections::{Module, Call, Event<T>},
}
@@ -1427,7 +1426,7 @@ mod tests {
assert_ok!(Elections::report_defunct_voter(Origin::signed(5), 3));
assert_eq!(
System::events()[1].event,
System::events()[7].event,
Event::elections(RawEvent::VoterReported(3, 5, true))
);
@@ -1456,7 +1455,7 @@ mod tests {
assert_ok!(Elections::report_defunct_voter(Origin::signed(5), 4));
assert_eq!(
System::events()[1].event,
System::events()[7].event,
Event::elections(RawEvent::VoterReported(4, 5, false))
);
@@ -1867,7 +1866,7 @@ mod tests {
assert_eq!(balances(&5), (45, 2));
assert_eq!(
System::events()[0].event,
System::events()[6].event,
Event::elections(RawEvent::NewTerm(vec![(4, 40), (5, 50)])),
);
})