Allow ExistentialDeposit = 0 (#6185)

* Allow ExistentialDeposit = 0

* there are better ways to check is an account exists

* fix StorageMapShim

* test account events and fix some bugs
This commit is contained in:
Xiliang Chen
2020-06-03 03:22:21 +12:00
committed by GitHub
parent 7b9add7a71
commit 6547d7a09a
6 changed files with 186 additions and 42 deletions
+12 -3
View File
@@ -742,12 +742,12 @@ decl_module! {
/// No DB Read or Write operations because caller is already in overlay
/// # </weight>
#[weight = (10_000_000, DispatchClass::Operational)]
fn suicide(origin) {
pub fn suicide(origin) {
let who = ensure_signed(origin)?;
let account = Account::<T>::get(&who);
ensure!(account.refcount == 0, Error::<T>::NonZeroRefCount);
ensure!(account.data == T::AccountData::default(), Error::<T>::NonDefaultComposite);
Account::<T>::remove(who);
Self::kill_account(&who);
}
}
}
@@ -1131,6 +1131,15 @@ impl<T: Trait> Module<T> {
AllExtrinsicsLen::put(len as u32);
}
/// Reset events. Can be used as an alternative to
/// `initialize` for tests that don't need to bother with the other environment entries.
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
pub fn reset_events() {
<Events<T>>::kill();
EventCount::kill();
<EventTopics<T>>::remove_all();
}
/// Return the chain's current runtime version.
pub fn runtime_version() -> RuntimeVersion { T::Version::get() }
@@ -1222,8 +1231,8 @@ impl<T: Trait> Module<T> {
"WARNING: Referenced account deleted. This is probably a bug."
);
}
Module::<T>::on_killed_account(who.clone());
}
Module::<T>::on_killed_account(who.clone());
}
/// Determine whether or not it is possible to update the code.