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
This commit is part of merge request !217. Comments created here will be created in the context of that merge request.
...@@ -66,8 +66,6 @@ pub mod pallet { ...@@ -66,8 +66,6 @@ pub mod pallet {
#[pallet::constant] #[pallet::constant]
type FirstIssuableOn: Get<Self::BlockNumber>; type FirstIssuableOn: Get<Self::BlockNumber>;
#[pallet::constant] #[pallet::constant]
type IsSubWot: Get<bool>;
#[pallet::constant]
type MinCertForMembership: Get<u32>; type MinCertForMembership: Get<u32>;
#[pallet::constant] #[pallet::constant]
type MinCertForCreateIdtyRight: Get<u32>; type MinCertForCreateIdtyRight: Get<u32>;
...@@ -132,30 +130,25 @@ where ...@@ -132,30 +130,25 @@ where
{ {
// identity creation checks // identity creation checks
fn check_create_identity(creator: IdtyIndex) -> Result<(), DispatchError> { fn check_create_identity(creator: IdtyIndex) -> Result<(), DispatchError> {
// main WoT constraints let cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(creator);
if !T::IsSubWot::get() { // perform all checks
let cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(creator); // 1. check that identity has the right to create an identity
// perform all checks // identity can be member with 5 certifications and still not reach identity creation threshold which could be higher (6, 7...)
// 1. check that identity has the right to create an identity ensure!(
// identity can be member with 5 certifications and still not reach identity creation threshold which could be higher (6, 7...) cert_meta.received_count >= T::MinCertForCreateIdtyRight::get(),
ensure!( Error::<T, I>::NotEnoughReceivedCertsToCreateIdty
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)
// 2. check that issuer can emit one more certification ensure!(
// (this is only a partial check) cert_meta.issued_count < T::MaxByIssuer::get(),
ensure!( Error::<T, I>::MaxEmittedCertsReached
cert_meta.issued_count < T::MaxByIssuer::get(), );
Error::<T, I>::MaxEmittedCertsReached // 3. check that issuer respects certification creation period
); ensure!(
// 3. check that issuer respects certification creation period cert_meta.next_issuable_on <= frame_system::pallet::Pallet::<T>::block_number(),
ensure!( Error::<T, I>::IdtyCreationPeriodNotRespected
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
Ok(()) Ok(())
} }
} }
...@@ -238,17 +231,13 @@ where ...@@ -238,17 +231,13 @@ where
fn on_event(membership_event: &sp_membership::Event<IdtyIndex>) { fn on_event(membership_event: &sp_membership::Event<IdtyIndex>) {
match membership_event { match membership_event {
sp_membership::Event::<IdtyIndex>::MembershipAdded(idty_index) => { sp_membership::Event::<IdtyIndex>::MembershipAdded(idty_index) => {
if !T::IsSubWot::get() { // when main membership is acquired, tell identity
// when main membership is acquired, tell identity // (only used on first membership acquiry)
// (only used on first membership acquiry) pallet_identity::Pallet::<T>::membership_added(*idty_index);
pallet_identity::Pallet::<T>::membership_added(*idty_index);
}
} }
sp_membership::Event::<IdtyIndex>::MembershipRemoved(idty_index) => { sp_membership::Event::<IdtyIndex>::MembershipRemoved(idty_index) => {
if !T::IsSubWot::get() { // when main membership is lost, tell identity
// when main membership is lost, tell identity pallet_identity::Pallet::<T>::membership_removed(*idty_index);
pallet_identity::Pallet::<T>::membership_removed(*idty_index);
}
} }
sp_membership::Event::<IdtyIndex>::MembershipRenewed(_) => {} sp_membership::Event::<IdtyIndex>::MembershipRenewed(_) => {}
} }
......
...@@ -94,7 +94,6 @@ parameter_types! { ...@@ -94,7 +94,6 @@ parameter_types! {
} }
impl pallet_duniter_wot::Config<Instance1> for Test { impl pallet_duniter_wot::Config<Instance1> for Test {
type IsSubWot = frame_support::traits::ConstBool<false>;
type MinCertForMembership = MinCertForMembership; type MinCertForMembership = MinCertForMembership;
type MinCertForCreateIdtyRight = MinCertForCreateIdtyRight; type MinCertForCreateIdtyRight = MinCertForCreateIdtyRight;
type FirstIssuableOn = FirstIssuableOn; type FirstIssuableOn = FirstIssuableOn;
......
...@@ -458,7 +458,6 @@ macro_rules! pallets_config { ...@@ -458,7 +458,6 @@ macro_rules! pallets_config {
impl pallet_duniter_wot::Config<Instance1> for Runtime { impl pallet_duniter_wot::Config<Instance1> for Runtime {
type FirstIssuableOn = WotFirstCertIssuableOn; type FirstIssuableOn = WotFirstCertIssuableOn;
type IsDistanceOk = common_runtime::providers::MainWotIsDistanceOk<Runtime>; type IsDistanceOk = common_runtime::providers::MainWotIsDistanceOk<Runtime>;
type IsSubWot = frame_support::traits::ConstBool<false>;
type MinCertForMembership = WotMinCertForMembership; type MinCertForMembership = WotMinCertForMembership;
type MinCertForCreateIdtyRight = WotMinCertForCreateIdtyRight; 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