mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 22:45:40 +00:00
pallet-identity: Be more paranoid ;) (#12170)
* pallet-identity: Be more paranoid ;)
Check that a registrar is providing judgement for the correct identity.
* Fixes
* Fix alliance
* 🤦
* Fixes
* ...
This commit is contained in:
@@ -79,7 +79,7 @@ mod types;
|
||||
pub mod weights;
|
||||
|
||||
use frame_support::traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency};
|
||||
use sp_runtime::traits::{AppendZerosInput, Saturating, StaticLookup, Zero};
|
||||
use sp_runtime::traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero};
|
||||
use sp_std::prelude::*;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
@@ -236,6 +236,8 @@ pub mod pallet {
|
||||
NotSub,
|
||||
/// Sub-account isn't owned by sender.
|
||||
NotOwned,
|
||||
/// The provided judgement was for a different identity.
|
||||
JudgementForDifferentIdentity,
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
@@ -746,6 +748,7 @@ pub mod pallet {
|
||||
/// - `target`: the account whose identity the judgement is upon. This must be an account
|
||||
/// with a registered identity.
|
||||
/// - `judgement`: the judgement of the registrar of index `reg_index` about `target`.
|
||||
/// - `identity`: The hash of the [`IdentityInfo`] for that the judgement is provided.
|
||||
///
|
||||
/// Emits `JudgementGiven` if successful.
|
||||
///
|
||||
@@ -765,6 +768,7 @@ pub mod pallet {
|
||||
#[pallet::compact] reg_index: RegistrarIndex,
|
||||
target: AccountIdLookupOf<T>,
|
||||
judgement: Judgement<BalanceOf<T>>,
|
||||
identity: T::Hash,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
let sender = ensure_signed(origin)?;
|
||||
let target = T::Lookup::lookup(target)?;
|
||||
@@ -772,10 +776,14 @@ pub mod pallet {
|
||||
<Registrars<T>>::get()
|
||||
.get(reg_index as usize)
|
||||
.and_then(Option::as_ref)
|
||||
.and_then(|r| if r.account == sender { Some(r) } else { None })
|
||||
.filter(|r| r.account == sender)
|
||||
.ok_or(Error::<T>::InvalidIndex)?;
|
||||
let mut id = <IdentityOf<T>>::get(&target).ok_or(Error::<T>::InvalidTarget)?;
|
||||
|
||||
if T::Hashing::hash_of(&id.info) != identity {
|
||||
return Err(Error::<T>::JudgementForDifferentIdentity.into())
|
||||
}
|
||||
|
||||
let item = (reg_index, judgement);
|
||||
match id.judgements.binary_search_by_key(®_index, |x| x.0) {
|
||||
Ok(position) => {
|
||||
|
||||
Reference in New Issue
Block a user