mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +00:00
Add field names to pallet Event variants (#9993)
* convert pallet-assets events to struct types * updated events of a couple pallets * updated pallet event field names * update pallet event field names * updated events in test files * cargo fmt * minorfixes * fix assertion error * minor fix * formatting fix * fmt
This commit is contained in:
@@ -153,7 +153,7 @@ benchmarks! {
|
||||
};
|
||||
}: _(RawOrigin::Signed(caller.clone()), Box::new(create_identity_info::<T>(x)))
|
||||
verify {
|
||||
assert_last_event::<T>(Event::<T>::IdentitySet(caller).into());
|
||||
assert_last_event::<T>(Event::<T>::IdentitySet { who: caller }.into());
|
||||
}
|
||||
|
||||
// We need to split `set_subs` into two benchmarks to accurately isolate the potential
|
||||
@@ -237,7 +237,7 @@ benchmarks! {
|
||||
};
|
||||
}: _(RawOrigin::Signed(caller.clone()), r - 1, 10u32.into())
|
||||
verify {
|
||||
assert_last_event::<T>(Event::<T>::JudgementRequested(caller, r-1).into());
|
||||
assert_last_event::<T>(Event::<T>::JudgementRequested { who: caller, registrar_index: r-1 }.into());
|
||||
}
|
||||
|
||||
cancel_request {
|
||||
@@ -257,7 +257,7 @@ benchmarks! {
|
||||
Identity::<T>::request_judgement(caller_origin, r - 1, 10u32.into())?;
|
||||
}: _(RawOrigin::Signed(caller.clone()), r - 1)
|
||||
verify {
|
||||
assert_last_event::<T>(Event::<T>::JudgementUnrequested(caller, r-1).into());
|
||||
assert_last_event::<T>(Event::<T>::JudgementUnrequested { who: caller, registrar_index: r-1 }.into());
|
||||
}
|
||||
|
||||
set_fee {
|
||||
@@ -328,7 +328,7 @@ benchmarks! {
|
||||
Identity::<T>::request_judgement(user_origin.clone(), r, 10u32.into())?;
|
||||
}: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable)
|
||||
verify {
|
||||
assert_last_event::<T>(Event::<T>::JudgementGiven(user, r).into())
|
||||
assert_last_event::<T>(Event::<T>::JudgementGiven { target: user, registrar_index: r }.into())
|
||||
}
|
||||
|
||||
kill_identity {
|
||||
|
||||
@@ -241,28 +241,27 @@ pub mod pallet {
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A name was set or reset (which will remove all judgements). \[who\]
|
||||
IdentitySet(T::AccountId),
|
||||
/// A name was cleared, and the given balance returned. \[who, deposit\]
|
||||
IdentityCleared(T::AccountId, BalanceOf<T>),
|
||||
/// A name was removed and the given balance slashed. \[who, deposit\]
|
||||
IdentityKilled(T::AccountId, BalanceOf<T>),
|
||||
/// A judgement was asked from a registrar. \[who, registrar_index\]
|
||||
JudgementRequested(T::AccountId, RegistrarIndex),
|
||||
/// A judgement request was retracted. \[who, registrar_index\]
|
||||
JudgementUnrequested(T::AccountId, RegistrarIndex),
|
||||
/// A judgement was given by a registrar. \[target, registrar_index\]
|
||||
JudgementGiven(T::AccountId, RegistrarIndex),
|
||||
/// A registrar was added. \[registrar_index\]
|
||||
RegistrarAdded(RegistrarIndex),
|
||||
/// A sub-identity was added to an identity and the deposit paid. \[sub, main, deposit\]
|
||||
SubIdentityAdded(T::AccountId, T::AccountId, BalanceOf<T>),
|
||||
/// A name was set or reset (which will remove all judgements).
|
||||
IdentitySet { who: T::AccountId },
|
||||
/// A name was cleared, and the given balance returned.
|
||||
IdentityCleared { who: T::AccountId, deposit: BalanceOf<T> },
|
||||
/// A name was removed and the given balance slashed.
|
||||
IdentityKilled { who: T::AccountId, deposit: BalanceOf<T> },
|
||||
/// A judgement was asked from a registrar.
|
||||
JudgementRequested { who: T::AccountId, registrar_index: RegistrarIndex },
|
||||
/// A judgement request was retracted.
|
||||
JudgementUnrequested { who: T::AccountId, registrar_index: RegistrarIndex },
|
||||
/// A judgement was given by a registrar.
|
||||
JudgementGiven { target: T::AccountId, registrar_index: RegistrarIndex },
|
||||
/// A registrar was added.
|
||||
RegistrarAdded { registrar_index: RegistrarIndex },
|
||||
/// A sub-identity was added to an identity and the deposit paid.
|
||||
SubIdentityAdded { sub: T::AccountId, main: T::AccountId, deposit: BalanceOf<T> },
|
||||
/// A sub-identity was removed from an identity and the deposit freed.
|
||||
/// \[sub, main, deposit\]
|
||||
SubIdentityRemoved(T::AccountId, T::AccountId, BalanceOf<T>),
|
||||
SubIdentityRemoved { sub: T::AccountId, main: T::AccountId, deposit: BalanceOf<T> },
|
||||
/// A sub-identity was cleared, and the given deposit repatriated from the
|
||||
/// main identity account to the sub-identity account. \[sub, main, deposit\]
|
||||
SubIdentityRevoked(T::AccountId, T::AccountId, BalanceOf<T>),
|
||||
/// main identity account to the sub-identity account.
|
||||
SubIdentityRevoked { sub: T::AccountId, main: T::AccountId, deposit: BalanceOf<T> },
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
@@ -301,7 +300,7 @@ pub mod pallet {
|
||||
},
|
||||
)?;
|
||||
|
||||
Self::deposit_event(Event::RegistrarAdded(i));
|
||||
Self::deposit_event(Event::RegistrarAdded { registrar_index: i });
|
||||
|
||||
Ok(Some(T::WeightInfo::add_registrar(registrar_count as u32)).into())
|
||||
}
|
||||
@@ -364,7 +363,7 @@ pub mod pallet {
|
||||
|
||||
let judgements = id.judgements.len();
|
||||
<IdentityOf<T>>::insert(&sender, id);
|
||||
Self::deposit_event(Event::IdentitySet(sender));
|
||||
Self::deposit_event(Event::IdentitySet { who: sender });
|
||||
|
||||
Ok(Some(T::WeightInfo::set_identity(
|
||||
judgements as u32, // R
|
||||
@@ -489,7 +488,7 @@ pub mod pallet {
|
||||
let err_amount = T::Currency::unreserve(&sender, deposit.clone());
|
||||
debug_assert!(err_amount.is_zero());
|
||||
|
||||
Self::deposit_event(Event::IdentityCleared(sender, deposit));
|
||||
Self::deposit_event(Event::IdentityCleared { who: sender, deposit });
|
||||
|
||||
Ok(Some(T::WeightInfo::clear_identity(
|
||||
id.judgements.len() as u32, // R
|
||||
@@ -558,7 +557,10 @@ pub mod pallet {
|
||||
let extra_fields = id.info.additional.len();
|
||||
<IdentityOf<T>>::insert(&sender, id);
|
||||
|
||||
Self::deposit_event(Event::JudgementRequested(sender, reg_index));
|
||||
Self::deposit_event(Event::JudgementRequested {
|
||||
who: sender,
|
||||
registrar_index: reg_index,
|
||||
});
|
||||
|
||||
Ok(Some(T::WeightInfo::request_judgement(judgements as u32, extra_fields as u32))
|
||||
.into())
|
||||
@@ -608,7 +610,10 @@ pub mod pallet {
|
||||
let extra_fields = id.info.additional.len();
|
||||
<IdentityOf<T>>::insert(&sender, id);
|
||||
|
||||
Self::deposit_event(Event::JudgementUnrequested(sender, reg_index));
|
||||
Self::deposit_event(Event::JudgementUnrequested {
|
||||
who: sender,
|
||||
registrar_index: reg_index,
|
||||
});
|
||||
|
||||
Ok(Some(T::WeightInfo::cancel_request(judgements as u32, extra_fields as u32)).into())
|
||||
}
|
||||
@@ -791,7 +796,7 @@ pub mod pallet {
|
||||
let judgements = id.judgements.len();
|
||||
let extra_fields = id.info.additional.len();
|
||||
<IdentityOf<T>>::insert(&target, id);
|
||||
Self::deposit_event(Event::JudgementGiven(target, reg_index));
|
||||
Self::deposit_event(Event::JudgementGiven { target, registrar_index: reg_index });
|
||||
|
||||
Ok(Some(T::WeightInfo::provide_judgement(judgements as u32, extra_fields as u32))
|
||||
.into())
|
||||
@@ -839,7 +844,7 @@ pub mod pallet {
|
||||
// Slash their deposit from them.
|
||||
T::Slashed::on_unbalanced(T::Currency::slash_reserved(&target, deposit).0);
|
||||
|
||||
Self::deposit_event(Event::IdentityKilled(target, deposit));
|
||||
Self::deposit_event(Event::IdentityKilled { who: target, deposit });
|
||||
|
||||
Ok(Some(T::WeightInfo::kill_identity(
|
||||
id.judgements.len() as u32, // R
|
||||
@@ -882,7 +887,7 @@ pub mod pallet {
|
||||
sub_ids.try_push(sub.clone()).expect("sub ids length checked above; qed");
|
||||
*subs_deposit = subs_deposit.saturating_add(deposit);
|
||||
|
||||
Self::deposit_event(Event::SubIdentityAdded(sub, sender.clone(), deposit));
|
||||
Self::deposit_event(Event::SubIdentityAdded { sub, main: sender.clone(), deposit });
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
@@ -929,7 +934,7 @@ pub mod pallet {
|
||||
*subs_deposit -= deposit;
|
||||
let err_amount = T::Currency::unreserve(&sender, deposit);
|
||||
debug_assert!(err_amount.is_zero());
|
||||
Self::deposit_event(Event::SubIdentityRemoved(sub, sender, deposit));
|
||||
Self::deposit_event(Event::SubIdentityRemoved { sub, main: sender, deposit });
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
@@ -954,7 +959,11 @@ pub mod pallet {
|
||||
*subs_deposit -= deposit;
|
||||
let _ =
|
||||
T::Currency::repatriate_reserved(&sup, &sender, deposit, BalanceStatus::Free);
|
||||
Self::deposit_event(Event::SubIdentityRevoked(sender, sup.clone(), deposit));
|
||||
Self::deposit_event(Event::SubIdentityRevoked {
|
||||
sub: sender,
|
||||
main: sup.clone(),
|
||||
deposit,
|
||||
});
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user