Skip to content
Snippets Groups Projects
Commit 380f085c authored by Cédric Moreau's avatar Cédric Moreau
Browse files

refac(smith-members): remove IsSubWoT

parent d811c71b
No related branches found
No related tags found
No related merge requests found
......@@ -66,8 +66,6 @@ pub mod pallet {
#[pallet::constant]
type FirstIssuableOn: Get<Self::BlockNumber>;
#[pallet::constant]
type IsSubWot: Get<bool>;
#[pallet::constant]
type MinCertForMembership: Get<u32>;
#[pallet::constant]
type MinCertForCreateIdtyRight: Get<u32>;
......@@ -132,30 +130,25 @@ where
{
// identity creation checks
fn check_create_identity(creator: IdtyIndex) -> Result<(), DispatchError> {
// main WoT constraints
if !T::IsSubWot::get() {
let cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(creator);
// perform all checks
// 1. check that identity has the right to create an identity
// identity can be member with 5 certifications and still not reach identity creation threshold which could be higher (6, 7...)
ensure!(
cert_meta.received_count >= T::MinCertForCreateIdtyRight::get(),
Error::<T, I>::NotEnoughReceivedCertsToCreateIdty
);
// 2. check that issuer can emit one more certification
// (this is only a partial check)
ensure!(
cert_meta.issued_count < T::MaxByIssuer::get(),
Error::<T, I>::MaxEmittedCertsReached
);
// 3. check that issuer respects certification creation period
ensure!(
cert_meta.next_issuable_on <= frame_system::pallet::Pallet::<T>::block_number(),
Error::<T, I>::IdtyCreationPeriodNotRespected
);
}
// TODO (#136) make these trait implementation work on instances rather than static to avoid checking IsSubWot
// smith subwot can never prevent from creating identity
let cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(creator);
// perform all checks
// 1. check that identity has the right to create an identity
// identity can be member with 5 certifications and still not reach identity creation threshold which could be higher (6, 7...)
ensure!(
cert_meta.received_count >= T::MinCertForCreateIdtyRight::get(),
Error::<T, I>::NotEnoughReceivedCertsToCreateIdty
);
// 2. check that issuer can emit one more certification
// (this is only a partial check)
ensure!(
cert_meta.issued_count < T::MaxByIssuer::get(),
Error::<T, I>::MaxEmittedCertsReached
);
// 3. check that issuer respects certification creation period
ensure!(
cert_meta.next_issuable_on <= frame_system::pallet::Pallet::<T>::block_number(),
Error::<T, I>::IdtyCreationPeriodNotRespected
);
Ok(())
}
}
......@@ -238,17 +231,13 @@ where
fn on_event(membership_event: &sp_membership::Event<IdtyIndex>) {
match membership_event {
sp_membership::Event::<IdtyIndex>::MembershipAdded(idty_index) => {
if !T::IsSubWot::get() {
// when main membership is acquired, tell identity
// (only used on first membership acquiry)
pallet_identity::Pallet::<T>::membership_added(*idty_index);
}
// when main membership is acquired, tell identity
// (only used on first membership acquiry)
pallet_identity::Pallet::<T>::membership_added(*idty_index);
}
sp_membership::Event::<IdtyIndex>::MembershipRemoved(idty_index) => {
if !T::IsSubWot::get() {
// when main membership is lost, tell identity
pallet_identity::Pallet::<T>::membership_removed(*idty_index);
}
// when main membership is lost, tell identity
pallet_identity::Pallet::<T>::membership_removed(*idty_index);
}
sp_membership::Event::<IdtyIndex>::MembershipRenewed(_) => {}
}
......
......@@ -94,7 +94,6 @@ parameter_types! {
}
impl pallet_duniter_wot::Config<Instance1> for Test {
type IsSubWot = frame_support::traits::ConstBool<false>;
type MinCertForMembership = MinCertForMembership;
type MinCertForCreateIdtyRight = MinCertForCreateIdtyRight;
type FirstIssuableOn = FirstIssuableOn;
......
......@@ -458,7 +458,6 @@ macro_rules! pallets_config {
impl pallet_duniter_wot::Config<Instance1> for Runtime {
type FirstIssuableOn = WotFirstCertIssuableOn;
type IsDistanceOk = common_runtime::providers::MainWotIsDistanceOk<Runtime>;
type IsSubWot = frame_support::traits::ConstBool<false>;
type MinCertForMembership = WotMinCertForMembership;
type MinCertForCreateIdtyRight = WotMinCertForCreateIdtyRight;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment