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
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,10 @@ fn test_create_idty_ok() {
events[1],
EventRecord {
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![],
}
);
......@@ -145,7 +148,7 @@ fn test_new_idty_validation() {
events[2],
EventRecord {
phase: Phase::Initialization,
event: Event::Identity(pallet_identity::Event::IdtyValidated(6,)),
event: Event::Identity(pallet_identity::Event::IdtyValidated { idty_index: 6 }),
topics: vec![],
}
);
......@@ -194,11 +197,11 @@ fn test_confirm_idty_ok() {
events[1],
EventRecord {
phase: Phase::Initialization,
event: Event::Identity(pallet_identity::Event::IdtyConfirmed(
6,
6,
IdtyName::from("Ferdie"),
)),
event: Event::Identity(pallet_identity::Event::IdtyConfirmed {
idty_index: 6,
owner_key: 6,
name: IdtyName::from("Ferdie"),
}),
topics: vec![],
}
);
......
......@@ -200,13 +200,20 @@ pub mod pallet {
pub enum Event<T: Config> {
/// A new identity has been created
/// [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
/// [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
/// [idty_index]
IdtyValidated(T::IdtyIndex),
IdtyValidated { idty_index: T::IdtyIndex },
}
// CALLS //
......@@ -266,7 +273,10 @@ pub mod pallet {
);
IdentitiesRemovableOn::<T>::append(removable_on, (idty_index, IdtyStatus::Created));
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 });
Ok(().into())
}
......@@ -302,7 +312,11 @@ pub mod pallet {
<Identities<T>>::insert(idty_index, idty_value);
<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);
Ok(().into())
}
......@@ -332,7 +346,7 @@ pub mod pallet {
idty_value.status = IdtyStatus::Validated;
<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);
Ok(().into())
......
......@@ -62,7 +62,10 @@ fn test_create_identity_ok() {
events[1],
EventRecord {
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![],
}
);
......@@ -86,7 +89,10 @@ fn test_idty_creation_period() {
events[1],
EventRecord {
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![],
}
);
......@@ -108,7 +114,10 @@ fn test_idty_creation_period() {
events[1],
EventRecord {
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![],
}
);
......
......@@ -177,11 +177,19 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A new universal dividend is created
/// [ud_amout, members_count]
NewUdCreated(BalanceOf<T>, BalanceOf<T>),
/// [amout, members_count]
NewUdCreated {
amount: BalanceOf<T>,
monetary_mass: BalanceOf<T>,
members_count: BalanceOf<T>,
},
/// The universal dividend has been re-evaluated
/// [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 //
......@@ -197,10 +205,14 @@ pub mod pallet {
Self::write_ud_history(n, account_id, ud_amount);
}
<MonetaryMassStorage<T>>::put(
monetary_mass.saturating_add(ud_amount.saturating_mul(members_count)),
);
Self::deposit_event(Event::NewUdCreated(ud_amount, members_count));
let new_monetary_mass =
monetary_mass.saturating_add(ud_amount.saturating_mul(members_count));
MonetaryMassStorage::<T>::put(new_monetary_mass);
Self::deposit_event(Event::NewUdCreated {
amount: ud_amount,
members_count,
monetary_mass: new_monetary_mass,
});
total_weight
}
......@@ -239,11 +251,11 @@ pub mod pallet {
<CurrentUdStorage<T>>::put(new_ud_amount);
Self::deposit_event(Event::UdReevalued(
Self::deposit_event(Event::UdReevalued {
new_ud_amount,
monetary_mass,
members_count,
));
});
total_weight
}
......
......@@ -47,7 +47,11 @@ fn test_ud_creation() {
events[9],
EventRecord {
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![],
}
);
......
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