Replace T::AccountId with <T::Lookup as StaticLookup>::Source (#11670)

* initial

* update

* update

* update

* cargo fmt

* update

* update benchmarks

* AccountIdLookupOf<T>

* cargo fmt

* fix conflits

* cargo fmt

* update

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Doordashcon
2022-08-18 10:30:46 +01:00
committed by GitHub
parent 511e5c9651
commit d46f6f0d34
50 changed files with 465 additions and 309 deletions
+10 -10
View File
@@ -94,6 +94,7 @@ type BalanceOf<T> =
type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::NegativeImbalance;
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
#[frame_support::pallet]
pub mod pallet {
@@ -282,9 +283,10 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::add_registrar(T::MaxRegistrars::get()))]
pub fn add_registrar(
origin: OriginFor<T>,
account: T::AccountId,
account: AccountIdLookupOf<T>,
) -> DispatchResultWithPostInfo {
T::RegistrarOrigin::ensure_origin(origin)?;
let account = T::Lookup::lookup(account)?;
let (i, registrar_count) = <Registrars<T>>::try_mutate(
|registrars| -> Result<(RegistrarIndex, usize), DispatchError> {
@@ -672,9 +674,10 @@ pub mod pallet {
pub fn set_account_id(
origin: OriginFor<T>,
#[pallet::compact] index: RegistrarIndex,
new: T::AccountId,
new: AccountIdLookupOf<T>,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
let new = T::Lookup::lookup(new)?;
let registrars = <Registrars<T>>::mutate(|rs| -> Result<usize, DispatchError> {
rs.get_mut(index as usize)
@@ -760,7 +763,7 @@ pub mod pallet {
pub fn provide_judgement(
origin: OriginFor<T>,
#[pallet::compact] reg_index: RegistrarIndex,
target: <T::Lookup as StaticLookup>::Source,
target: AccountIdLookupOf<T>,
judgement: Judgement<BalanceOf<T>>,
) -> DispatchResultWithPostInfo {
let sender = ensure_signed(origin)?;
@@ -827,7 +830,7 @@ pub mod pallet {
))]
pub fn kill_identity(
origin: OriginFor<T>,
target: <T::Lookup as StaticLookup>::Source,
target: AccountIdLookupOf<T>,
) -> DispatchResultWithPostInfo {
T::ForceOrigin::ensure_origin(origin)?;
@@ -863,7 +866,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::add_sub(T::MaxSubAccounts::get()))]
pub fn add_sub(
origin: OriginFor<T>,
sub: <T::Lookup as StaticLookup>::Source,
sub: AccountIdLookupOf<T>,
data: Data,
) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -898,7 +901,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::rename_sub(T::MaxSubAccounts::get()))]
pub fn rename_sub(
origin: OriginFor<T>,
sub: <T::Lookup as StaticLookup>::Source,
sub: AccountIdLookupOf<T>,
data: Data,
) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -917,10 +920,7 @@ pub mod pallet {
/// The dispatch origin for this call must be _Signed_ and the sender must have a registered
/// sub identity of `sub`.
#[pallet::weight(T::WeightInfo::remove_sub(T::MaxSubAccounts::get()))]
pub fn remove_sub(
origin: OriginFor<T>,
sub: <T::Lookup as StaticLookup>::Source,
) -> DispatchResult {
pub fn remove_sub(origin: OriginFor<T>, sub: AccountIdLookupOf<T>) -> DispatchResult {
let sender = ensure_signed(origin)?;
ensure!(IdentityOf::<T>::contains_key(&sender), Error::<T>::NoIdentity);
let sub = T::Lookup::lookup(sub)?;