diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index 7244fd3d9bfde32e320bef9f0ed205f2ce58d9ee..7184febf0d30586df9c8f8d0bac1a74c9d95d43a 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -219,22 +219,18 @@ pub mod pallet { /// link account to identity pub fn do_link_identity( - account_id: T::AccountId, + account_id: &T::AccountId, idty_id: IdtyIdOf<T>, ) -> Result<(), DispatchError> { // Check that account exist ensure!( - (frame_system::Account::<T>::get(&account_id).providers >= 1) - || (frame_system::Account::<T>::get(&account_id).sufficients >= 1), + (frame_system::Account::<T>::get(account_id).providers >= 1) + || (frame_system::Account::<T>::get(account_id).sufficients >= 1), pallet_identity::Error::<T>::AccountNotExist ); // no-op if identity does not change - if frame_system::Account::<T>::get(&account_id) - .data - .linked_idty - != Some(idty_id) - { - frame_system::Account::<T>::mutate(&account_id, |account| { + if frame_system::Account::<T>::get(account_id).data.linked_idty != Some(idty_id) { + frame_system::Account::<T>::mutate(account_id, |account| { account.data.linked_idty = Some(idty_id); Self::deposit_event(Event::AccountLinked { who: account_id.clone(), @@ -335,7 +331,7 @@ impl<T> pallet_identity::traits::LinkIdty<T::AccountId, IdtyIdOf<T>> for Pallet< where T: Config, { - fn link_identity(account_id: T::AccountId, idty_id: IdtyIdOf<T>) -> Result<(), DispatchError> { + fn link_identity(account_id: &T::AccountId, idty_id: IdtyIdOf<T>) -> Result<(), DispatchError> { Self::do_link_identity(account_id, idty_id) } } diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index c89d77aacbcb80a845a9a1f5e96f37f63ea3d867..17c4d38450fe53ba73f5fbd54609793ca6578e3e 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -328,7 +328,7 @@ pub mod pallet { idty_index, owner_key: owner_key.clone(), }); - T::AccountLinker::link_identity(owner_key.clone(), idty_index)?; + T::AccountLinker::link_identity(&owner_key, idty_index)?; T::OnIdtyChange::on_idty_change( idty_index, &IdtyEvent::Created { @@ -455,7 +455,7 @@ pub mod pallet { frame_system::Pallet::<T>::inc_sufficients(&idty_value.owner_key); IdentityIndexOf::<T>::insert(&idty_value.owner_key, idty_index); Identities::<T>::insert(idty_index, idty_value); - T::AccountLinker::link_identity(new_key.clone(), idty_index)?; + T::AccountLinker::link_identity(&new_key, idty_index)?; Self::deposit_event(Event::IdtyChangedOwnerKey { idty_index, new_owner_key: new_key, @@ -586,7 +586,7 @@ pub mod pallet { Error::<T>::InvalidSignature ); // apply - T::AccountLinker::link_identity(account_id, idty_index)?; + T::AccountLinker::link_identity(&account_id, idty_index)?; Ok(().into()) } diff --git a/pallets/identity/src/traits.rs b/pallets/identity/src/traits.rs index ffc230aa7fdea7ab97547325a2952d23a924294b..95bd3064150772a6ed7e36f68b3e9af97c7e5536 100644 --- a/pallets/identity/src/traits.rs +++ b/pallets/identity/src/traits.rs @@ -53,10 +53,10 @@ impl<T: Config> OnIdtyChange<T> for Tuple { /// trait used to link an account to an identity pub trait LinkIdty<AccountId, IdtyIndex> { - fn link_identity(account_id: AccountId, idty_index: IdtyIndex) -> Result<(), DispatchError>; + fn link_identity(account_id: &AccountId, idty_index: IdtyIndex) -> Result<(), DispatchError>; } impl<AccountId, IdtyIndex> LinkIdty<AccountId, IdtyIndex> for () { - fn link_identity(_: AccountId, _: IdtyIndex) -> Result<(), DispatchError> { + fn link_identity(_: &AccountId, _: IdtyIndex) -> Result<(), DispatchError> { Ok(()) } }