Skip to content
Snippets Groups Projects
Commit 1f18c5bc authored by Pascal Engélibert's avatar Pascal Engélibert :bicyclist:
Browse files

Fix UD eligibility at genesis

parent 3f3990d9
No related branches found
No related tags found
1 merge request!304Disable UD for non-members at genesis
...@@ -198,7 +198,12 @@ fn genesis_data_to_g1_genesis_conf( ...@@ -198,7 +198,12 @@ fn genesis_data_to_g1_genesis_conf(
index: idty_index, index: idty_index,
name: common_runtime::IdtyName::from(name.as_str()), name: common_runtime::IdtyName::from(name.as_str()),
value: common_runtime::IdtyValue { value: common_runtime::IdtyValue {
data: IdtyData::new(), data: IdtyData {
first_eligible_ud: match status {
common_runtime::IdtyStatus::Member => 1_u16.into(),
_ => g1_runtime::pallet_universal_dividend::FirstEligibleUd(None),
}
},
next_creatable_identity_on: 0, next_creatable_identity_on: 0,
old_owner_key: None, old_owner_key: None,
owner_key, owner_key,
......
...@@ -286,7 +286,12 @@ fn genesis_data_to_gdev_genesis_conf( ...@@ -286,7 +286,12 @@ fn genesis_data_to_gdev_genesis_conf(
index: idty_index, index: idty_index,
name: common_runtime::IdtyName::from(name.as_str()), name: common_runtime::IdtyName::from(name.as_str()),
value: common_runtime::IdtyValue { value: common_runtime::IdtyValue {
data: IdtyData::new(), data: IdtyData {
first_eligible_ud: match status {
common_runtime::IdtyStatus::Member => 1_u16.into(),
_ => gdev_runtime::pallet_universal_dividend::FirstEligibleUd(None),
}
},
next_creatable_identity_on: 0, next_creatable_identity_on: 0,
old_owner_key: None, old_owner_key: None,
owner_key, owner_key,
......
...@@ -291,7 +291,12 @@ fn genesis_data_to_gtest_genesis_conf( ...@@ -291,7 +291,12 @@ fn genesis_data_to_gtest_genesis_conf(
index: idty_index, index: idty_index,
name: common_runtime::IdtyName::from(name.as_str()), name: common_runtime::IdtyName::from(name.as_str()),
value: common_runtime::IdtyValue { value: common_runtime::IdtyValue {
data: IdtyData::new(), data: IdtyData {
first_eligible_ud: match status {
common_runtime::IdtyStatus::Member => 1_u16.into(),
_ => gtest_runtime::pallet_universal_dividend::FirstEligibleUd(None),
}
},
next_creatable_identity_on: 0, next_creatable_identity_on: 0,
old_owner_key: None, old_owner_key: None,
owner_key, owner_key,
......
...@@ -22,10 +22,18 @@ use sp_runtime::RuntimeDebug; ...@@ -22,10 +22,18 @@ use sp_runtime::RuntimeDebug;
pub type UdIndex = u16; pub type UdIndex = u16;
/// Represents the first eligible Universal Dividend. /// Represents the first eligible Universal Dividend.
#[derive(Clone, Default, Eq, PartialEq, RuntimeDebug, serde::Deserialize, serde::Serialize)] #[derive(Clone, Eq, PartialEq, RuntimeDebug, serde::Deserialize, serde::Serialize)]
pub struct FirstEligibleUd(pub Option<NonZeroU16>); pub struct FirstEligibleUd(pub Option<NonZeroU16>);
/// Default is not eligible
impl Default for FirstEligibleUd {
fn default() -> Self {
FirstEligibleUd(None)
}
}
impl FirstEligibleUd { impl FirstEligibleUd {
/// Eligible at the first UD index
pub fn min() -> Self { pub fn min() -> Self {
Self(Some(NonZeroU16::new(1).expect("unreachable"))) Self(Some(NonZeroU16::new(1).expect("unreachable")))
} }
......
...@@ -53,15 +53,6 @@ pub struct IdtyData { ...@@ -53,15 +53,6 @@ pub struct IdtyData {
pub first_eligible_ud: pallet_universal_dividend::FirstEligibleUd, pub first_eligible_ud: pallet_universal_dividend::FirstEligibleUd,
} }
#[cfg(feature = "std")]
impl IdtyData {
pub fn new() -> Self {
Self {
first_eligible_ud: pallet_universal_dividend::FirstEligibleUd::min(),
}
}
}
impl From<IdtyData> for pallet_universal_dividend::FirstEligibleUd { impl From<IdtyData> for pallet_universal_dividend::FirstEligibleUd {
fn from(idty_data: IdtyData) -> Self { fn from(idty_data: IdtyData) -> Self {
idty_data.first_eligible_ud idty_data.first_eligible_ud
......
...@@ -223,7 +223,9 @@ impl ExtBuilder { ...@@ -223,7 +223,9 @@ impl ExtBuilder {
index: i as u32 + 1, index: i as u32 + 1,
name: name.clone(), name: name.clone(),
value: IdtyValue { value: IdtyValue {
data: IdtyData::new(), data: IdtyData {
first_eligible_ud: 1_u16.into(),
},
next_creatable_identity_on: Default::default(), next_creatable_identity_on: Default::default(),
owner_key: owner_key.clone(), owner_key: owner_key.clone(),
old_owner_key: None, old_owner_key: None,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment