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

feat(runtime): name events fieds for pallets ud and identity

parent 46b7b2a6
Branches
Tags
No related merge requests found
...@@ -73,7 +73,10 @@ fn test_create_idty_ok() { ...@@ -73,7 +73,10 @@ fn test_create_idty_ok() {
events[1], events[1],
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::Identity(pallet_identity::Event::IdtyCreated(6, 6)), event: Event::Identity(pallet_identity::Event::IdtyCreated {
idty_index: 6,
owner_key: 6,
}),
topics: vec![], topics: vec![],
} }
); );
...@@ -145,7 +148,7 @@ fn test_new_idty_validation() { ...@@ -145,7 +148,7 @@ fn test_new_idty_validation() {
events[2], events[2],
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::Identity(pallet_identity::Event::IdtyValidated(6,)), event: Event::Identity(pallet_identity::Event::IdtyValidated { idty_index: 6 }),
topics: vec![], topics: vec![],
} }
); );
...@@ -194,11 +197,11 @@ fn test_confirm_idty_ok() { ...@@ -194,11 +197,11 @@ fn test_confirm_idty_ok() {
events[1], events[1],
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::Identity(pallet_identity::Event::IdtyConfirmed( event: Event::Identity(pallet_identity::Event::IdtyConfirmed {
6, idty_index: 6,
6, owner_key: 6,
IdtyName::from("Ferdie"), name: IdtyName::from("Ferdie"),
)), }),
topics: vec![], topics: vec![],
} }
); );
......
...@@ -200,13 +200,20 @@ pub mod pallet { ...@@ -200,13 +200,20 @@ pub mod pallet {
pub enum Event<T: Config> { pub enum Event<T: Config> {
/// A new identity has been created /// A new identity has been created
/// [idty_index, owner_key] /// [idty_index, owner_key]
IdtyCreated(T::IdtyIndex, T::AccountId), IdtyCreated {
idty_index: T::IdtyIndex,
owner_key: T::AccountId,
},
/// An identity has been confirmed by it's owner /// An identity has been confirmed by it's owner
/// [idty_index, owner_key, name] /// [idty_index, owner_key, name]
IdtyConfirmed(T::IdtyIndex, T::AccountId, IdtyName), IdtyConfirmed {
idty_index: T::IdtyIndex,
owner_key: T::AccountId,
name: IdtyName,
},
/// An identity has been validated /// An identity has been validated
/// [idty_index] /// [idty_index]
IdtyValidated(T::IdtyIndex), IdtyValidated { idty_index: T::IdtyIndex },
} }
// CALLS // // CALLS //
...@@ -266,7 +273,10 @@ pub mod pallet { ...@@ -266,7 +273,10 @@ pub mod pallet {
); );
IdentitiesRemovableOn::<T>::append(removable_on, (idty_index, IdtyStatus::Created)); IdentitiesRemovableOn::<T>::append(removable_on, (idty_index, IdtyStatus::Created));
IdentityIndexOf::<T>::insert(owner_key.clone(), idty_index); IdentityIndexOf::<T>::insert(owner_key.clone(), idty_index);
Self::deposit_event(Event::IdtyCreated(idty_index, owner_key)); Self::deposit_event(Event::IdtyCreated {
idty_index,
owner_key,
});
T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Created { creator }); T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Created { creator });
Ok(().into()) Ok(().into())
} }
...@@ -302,7 +312,11 @@ pub mod pallet { ...@@ -302,7 +312,11 @@ pub mod pallet {
<Identities<T>>::insert(idty_index, idty_value); <Identities<T>>::insert(idty_index, idty_value);
<IdentitiesNames<T>>::insert(idty_name.clone(), ()); <IdentitiesNames<T>>::insert(idty_name.clone(), ());
Self::deposit_event(Event::IdtyConfirmed(idty_index, who, idty_name)); Self::deposit_event(Event::IdtyConfirmed {
idty_index,
owner_key: who,
name: idty_name,
});
T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Confirmed); T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Confirmed);
Ok(().into()) Ok(().into())
} }
...@@ -332,7 +346,7 @@ pub mod pallet { ...@@ -332,7 +346,7 @@ pub mod pallet {
idty_value.status = IdtyStatus::Validated; idty_value.status = IdtyStatus::Validated;
<Identities<T>>::insert(idty_index, idty_value); <Identities<T>>::insert(idty_index, idty_value);
Self::deposit_event(Event::IdtyValidated(idty_index)); Self::deposit_event(Event::IdtyValidated { idty_index });
T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Validated); T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Validated);
Ok(().into()) Ok(().into())
......
...@@ -62,7 +62,10 @@ fn test_create_identity_ok() { ...@@ -62,7 +62,10 @@ fn test_create_identity_ok() {
events[1], events[1],
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::Identity(crate::Event::IdtyCreated(2, 2)), event: Event::Identity(crate::Event::IdtyCreated {
idty_index: 2,
owner_key: 2,
}),
topics: vec![], topics: vec![],
} }
); );
...@@ -86,7 +89,10 @@ fn test_idty_creation_period() { ...@@ -86,7 +89,10 @@ fn test_idty_creation_period() {
events[1], events[1],
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::Identity(crate::Event::IdtyCreated(2, 2)), event: Event::Identity(crate::Event::IdtyCreated {
idty_index: 2,
owner_key: 2,
}),
topics: vec![], topics: vec![],
} }
); );
...@@ -108,7 +114,10 @@ fn test_idty_creation_period() { ...@@ -108,7 +114,10 @@ fn test_idty_creation_period() {
events[1], events[1],
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::Identity(crate::Event::IdtyCreated(3, 3)), event: Event::Identity(crate::Event::IdtyCreated {
idty_index: 3,
owner_key: 3,
}),
topics: vec![], topics: vec![],
} }
); );
......
...@@ -177,11 +177,19 @@ pub mod pallet { ...@@ -177,11 +177,19 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> { pub enum Event<T: Config> {
/// A new universal dividend is created /// A new universal dividend is created
/// [ud_amout, members_count] /// [amout, members_count]
NewUdCreated(BalanceOf<T>, BalanceOf<T>), NewUdCreated {
amount: BalanceOf<T>,
monetary_mass: BalanceOf<T>,
members_count: BalanceOf<T>,
},
/// The universal dividend has been re-evaluated /// The universal dividend has been re-evaluated
/// [new_ud_amount, monetary_mass, members_count] /// [new_ud_amount, monetary_mass, members_count]
UdReevalued(BalanceOf<T>, BalanceOf<T>, BalanceOf<T>), UdReevalued {
new_ud_amount: BalanceOf<T>,
monetary_mass: BalanceOf<T>,
members_count: BalanceOf<T>,
},
} }
// INTERNAL FUNCTIONS // // INTERNAL FUNCTIONS //
...@@ -197,10 +205,14 @@ pub mod pallet { ...@@ -197,10 +205,14 @@ pub mod pallet {
Self::write_ud_history(n, account_id, ud_amount); Self::write_ud_history(n, account_id, ud_amount);
} }
<MonetaryMassStorage<T>>::put( let new_monetary_mass =
monetary_mass.saturating_add(ud_amount.saturating_mul(members_count)), monetary_mass.saturating_add(ud_amount.saturating_mul(members_count));
); MonetaryMassStorage::<T>::put(new_monetary_mass);
Self::deposit_event(Event::NewUdCreated(ud_amount, members_count)); Self::deposit_event(Event::NewUdCreated {
amount: ud_amount,
members_count,
monetary_mass: new_monetary_mass,
});
total_weight total_weight
} }
...@@ -239,11 +251,11 @@ pub mod pallet { ...@@ -239,11 +251,11 @@ pub mod pallet {
<CurrentUdStorage<T>>::put(new_ud_amount); <CurrentUdStorage<T>>::put(new_ud_amount);
Self::deposit_event(Event::UdReevalued( Self::deposit_event(Event::UdReevalued {
new_ud_amount, new_ud_amount,
monetary_mass, monetary_mass,
members_count, members_count,
)); });
total_weight total_weight
} }
......
...@@ -47,7 +47,11 @@ fn test_ud_creation() { ...@@ -47,7 +47,11 @@ fn test_ud_creation() {
events[9], events[9],
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::UniversalDividend(crate::Event::NewUdCreated(1000, 3)), event: Event::UniversalDividend(crate::Event::NewUdCreated {
amount: 1_000,
monetary_mass: 3_000,
members_count: 3,
}),
topics: vec![], topics: vec![],
} }
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment