Skip to content
Snippets Groups Projects
Commit c2424828 authored by Éloïs's avatar Éloïs
Browse files

ref(duniter-wot): adapt pallet duniter wot to future smiths sub-zot

parent 060cb448
No related branches found
No related tags found
1 merge request!28Smiths sub-wot
......@@ -137,9 +137,9 @@ fn devnet_genesis(
ud_reeval_period: 20,
ud_reeval_period_in_blocks: 200,
wot_first_cert_issuable_on: 20,
wot_min_cert_for_ud_right: 2,
wot_min_cert_for_cert_right: 2,
wot_min_cert_for_create_idty_right: 2,
wot_min_cert_for_membership: 2,
},
},
authority_discovery: Default::default(),
......
......@@ -51,9 +51,9 @@ pub mod types {
pub ud_reeval_period: PeriodCount,
pub ud_reeval_period_in_blocks: BlockNumber,
pub wot_first_cert_issuable_on: BlockNumber,
pub wot_min_cert_for_ud_right: CertCount,
pub wot_min_cert_for_cert_right: CertCount,
pub wot_min_cert_for_create_idty_right: CertCount,
pub wot_min_cert_for_membership: CertCount,
}
}
......
......@@ -64,8 +64,8 @@ pub mod pallet {
+ pallet_membership::Config<I, IdtyId = IdtyIndex, MetaData = ()>
{
type FirstIssuableOn: Get<Self::BlockNumber>;
type ManageIdentitiesChanges: Get<bool>;
type MinCertForUdRight: Get<u32>;
type IsSubWot: Get<bool>;
type MinCertForMembership: Get<u32>;
type MinCertForCreateIdtyRight: Get<u32>;
}
......@@ -80,7 +80,7 @@ pub mod pallet {
);
}
pub(super) fn dispath_idty_call(idty_call: pallet_identity::Call<T>) -> bool {
if T::ManageIdentitiesChanges::get() {
if !T::IsSubWot::get() {
if let Err(e) = idty_call.dispatch_bypass_filter(RawOrigin::Root.into()) {
sp_std::if_std! {
println!("{:?}", e)
......@@ -120,10 +120,18 @@ impl<T: Config<I>, I: 'static> pallet_identity::traits::EnsureIdtyCallAllowed<T>
impl<T: Config<I>, I: 'static> sp_membership::traits::IsIdtyAllowedToClaimMembership<IdtyIndex>
for Pallet<T, I>
{
fn is_idty_allowed_to_claim_membership(_: &IdtyIndex) -> bool {
fn is_idty_allowed_to_claim_membership(idty_index: &IdtyIndex) -> bool {
if T::IsSubWot::get() {
if let Some(idty_value) = pallet_identity::Pallet::<T>::identity(idty_index) {
idty_value.status == IdtyStatus::Validated
} else {
false
}
} else {
false
}
}
}
impl<T: Config<I>, I: 'static> sp_membership::traits::IsIdtyAllowedToRenewMembership<IdtyIndex>
for Pallet<T, I>
......@@ -142,7 +150,11 @@ impl<T: Config<I>, I: 'static> sp_membership::traits::IsIdtyAllowedToRequestMemb
{
fn is_idty_allowed_to_request_membership(idty_index: &IdtyIndex) -> bool {
if let Some(idty_value) = pallet_identity::Pallet::<T>::identity(idty_index) {
if T::IsSubWot::get() {
idty_value.status == IdtyStatus::Validated
} else {
idty_value.status == IdtyStatus::Disabled
}
} else {
false
}
......@@ -190,8 +202,8 @@ impl<T: Config<I>, I: 'static> sp_membership::traits::OnEvent<IdtyIndex, ()> for
{
let received_count = idty_cert_meta.received_count;
// TODO insert `receiver` in distance queue if received_count >= MinCertForUdRight
if received_count >= T::MinCertForUdRight::get() as u32 {
// TODO insert `receiver` in distance queue if received_count >= MinCertForMembership
if received_count >= T::MinCertForMembership::get() as u32 {
// TODO insert `receiver` in distance queue
if Self::dispath_idty_call(pallet_identity::Call::validate_identity {
idty_index: *idty_index,
......@@ -247,7 +259,7 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::OnNewcert<IdtyIndex
Self::do_apply_first_issuable_on(receiver);
}
} else if pallet_membership::Pallet::<T, I>::pending_membership(receiver).is_some()
&& receiver_received_count >= T::MinCertForUdRight::get()
&& receiver_received_count >= T::MinCertForMembership::get()
{
// TODO insert `receiver` in distance queue
Self::dispath_idty_call(pallet_identity::Call::validate_identity {
......@@ -272,7 +284,7 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::OnRemovedCert<IdtyI
receiver_received_count: u32,
_expiration: bool,
) -> Weight {
if receiver_received_count < T::MinCertForUdRight::get() {
if receiver_received_count < T::MinCertForMembership::get() {
// Revoke receiver membership and disable his identity
if let Err(e) = pallet_membership::Pallet::<T, I>::revoke_membership(
RawOrigin::Root.into(),
......
......@@ -80,14 +80,14 @@ impl system::Config for Test {
// DuniterWot
parameter_types! {
pub const MinCertForUdRight: u32 = 2;
pub const MinCertForMembership: u32 = 2;
pub const MinCertForCreateIdtyRigh: u32 = 4;
pub const FirstIssuableOn: u64 = 2;
}
impl pallet_duniter_wot::Config<Instance1> for Test {
type ManageIdentitiesChanges = frame_support::traits::ConstBool<true>;
type MinCertForUdRight = MinCertForUdRight;
type IsSubWot = frame_support::traits::ConstBool<false>;
type MinCertForMembership = MinCertForMembership;
type MinCertForCreateIdtyRight = MinCertForCreateIdtyRigh;
type FirstIssuableOn = FirstIssuableOn;
}
......
......@@ -268,8 +268,8 @@ macro_rules! pallets_config {
use frame_support::instances::Instance1;
impl pallet_duniter_wot::Config<Instance1> for Runtime {
type FirstIssuableOn = WotFirstCertIssuableOn;
type ManageIdentitiesChanges = frame_support::traits::ConstBool<true>;
type MinCertForUdRight = WotMinCertForUdRight;
type IsSubWot = frame_support::traits::ConstBool<true>;
type MinCertForMembership = WotMinCertForMembership;
type MinCertForCreateIdtyRight = WotMinCertForCreateIdtyRight;
}
......
......@@ -98,7 +98,7 @@ parameter_types! {
parameter_types! {
pub WotFirstCertIssuableOn: BlockNumber = 30* DAYS;
pub WotMinCertForUdRight: u8 = 5;
pub WotMinCertForMembership: u8 = 5;
pub MinReceivedCertToBeAbleToIssueCert: u8 = 5;
pub WotMinCertForCreateIdtyRight: u8 = 5;
}
......
......@@ -167,7 +167,7 @@ common_runtime::pallets_config! {
pub type UdReevalPeriod = pallet_duniter_test_parameters::UdReevalPeriod<Runtime>;
pub type UdReevalPeriodInBlocks = pallet_duniter_test_parameters::UdReevalPeriodInBlocks<Runtime>;
pub type WotFirstCertIssuableOn = pallet_duniter_test_parameters::WotFirstCertIssuableOn<Runtime>;
pub type WotMinCertForUdRight = pallet_duniter_test_parameters::WotMinCertForUdRight<Runtime>;
pub type WotMinCertForMembership = pallet_duniter_test_parameters::WotMinCertForMembership<Runtime>;
pub type WotMinCertForCreateIdtyRight = pallet_duniter_test_parameters::WotMinCertForCreateIdtyRight<Runtime>;
impl pallet_duniter_test_parameters::Config for Runtime {
......
......@@ -97,7 +97,7 @@ parameter_types! {
parameter_types! {
pub WotFirstCertIssuableOn: BlockNumber = DAYS;
pub WotMinCertForUdRight: u8 = 5;
pub WotMinCertForMembership: u8 = 5;
pub MinReceivedCertToBeAbleToIssueCert: u8 = 5;
pub WotMinCertForCreateIdtyRight: u8 = 5;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment