diff --git a/runtime/common/src/handlers.rs b/runtime/common/src/handlers.rs index 54eec5cb471806d5ef1ec1a136296063d34e52e8..c12f6d3d5759e12bf465168263a0bb16a5c47973 100644 --- a/runtime/common/src/handlers.rs +++ b/runtime/common/src/handlers.rs @@ -33,6 +33,37 @@ where } } +/// Runtime handler for OnNewIdty, calling all implementations of +/// OnNewIdty and implementing logic at the runtime level. +pub struct OnNewIdtyHandler<Runtime>(core::marker::PhantomData<Runtime>); +impl<Runtime: pallet_duniter_wot::Config + pallet_quota::Config> + pallet_identity::traits::OnNewIdty<Runtime> for OnNewIdtyHandler<Runtime> +{ + fn on_created(idty_index: &IdtyIndex, creator: &IdtyIndex) { + pallet_duniter_wot::Pallet::<Runtime>::on_created(idty_index, creator); + pallet_quota::Pallet::<Runtime>::on_created(idty_index, creator); + } +} + +/// Runtime handler for OnRemoveIdty, calling all implementations of +/// OnRemoveIdty and implementing logic at the runtime level. +pub struct OnRemoveIdtyHandler<Runtime>(core::marker::PhantomData<Runtime>); +impl<Runtime: pallet_duniter_wot::Config + pallet_quota::Config> + pallet_identity::traits::OnRemoveIdty<Runtime> for OnRemoveIdtyHandler<Runtime> +{ + fn on_removed(idty_index: &IdtyIndex) -> Weight { + let mut weight = pallet_duniter_wot::Pallet::<Runtime>::on_removed(idty_index); + weight += pallet_quota::Pallet::<Runtime>::on_removed(idty_index); + weight + } + + fn on_revoked(idty_index: &IdtyIndex) -> Weight { + let mut weight = pallet_duniter_wot::Pallet::<Runtime>::on_revoked(idty_index); + weight += pallet_quota::Pallet::<Runtime>::on_revoked(idty_index); + weight + } +} + /// Runtime handler for OnNewMembership, calling all implementations of /// OnNewMembership and implementing logic at the runtime level. pub struct OnNewMembershipHandler<Runtime>(core::marker::PhantomData<Runtime>); diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 4ab3570806ac8867dbde6b69fd00f8aed39b301f..1c9d1e0c5a5f0cc72948bb7f1338c0f62cc8ae4b 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -481,8 +481,8 @@ type RuntimeFreezeReason = (); type IdtyNameValidator = IdtyNameValidatorImpl; type Signer = <Signature as sp_runtime::traits::Verify>::Signer; type Signature = Signature; - type OnNewIdty = (Wot, Quota); - type OnRemoveIdty = (Wot, Quota); + type OnNewIdty = OnNewIdtyHandler<Runtime>; + type OnRemoveIdty = OnRemoveIdtyHandler<Runtime>; type RuntimeEvent = RuntimeEvent; type WeightInfo = common_runtime::weights::pallet_identity::WeightInfo<Runtime>; }