Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Remove some last AccountId32::default() leftovers (#10655)
Browse files Browse the repository at this point in the history
* Remove some last `AccountId32::default()` leftovers

As we removed `Default` of account id, we have overseen some last bits. This pr removes these last
bits.

* Fix
  • Loading branch information
bkchr authored and eskimor committed Jan 27, 2022
1 parent 491b5a9 commit 04de912
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 5 additions & 2 deletions frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,8 +990,8 @@ where
pub struct EnsureMember<AccountId, I: 'static>(PhantomData<(AccountId, I)>);
impl<
O: Into<Result<RawOrigin<AccountId, I>, O>> + From<RawOrigin<AccountId, I>>,
AccountId: Default,
I,
AccountId: Decode,
> EnsureOrigin<O> for EnsureMember<AccountId, I>
{
type Success = AccountId;
Expand All @@ -1004,7 +1004,10 @@ impl<

#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> O {
O::from(RawOrigin::Member(Default::default()))
let zero_account_id =
AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes())
.expect("infinite length input; no invalid inputs for type; qed");
O::from(RawOrigin::Member(zero_account_id))
}
}

Expand Down
10 changes: 4 additions & 6 deletions primitives/core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,7 @@ pub trait Public: ByteArray + Derive + CryptoType + PartialEq + Eq + Clone + Sen
}

/// An opaque 32-byte cryptographic identifier.
#[derive(
Clone, Eq, PartialEq, Ord, PartialOrd, Default, Encode, Decode, MaxEncodedLen, TypeInfo,
)]
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, TypeInfo)]
#[cfg_attr(feature = "std", derive(Hash))]
pub struct AccountId32([u8; 32]);

Expand Down Expand Up @@ -541,9 +539,9 @@ impl<'a> sp_std::convert::TryFrom<&'a [u8]> for AccountId32 {
type Error = ();
fn try_from(x: &'a [u8]) -> Result<AccountId32, ()> {
if x.len() == 32 {
let mut r = AccountId32::default();
r.0.copy_from_slice(x);
Ok(r)
let mut data = [0; 32];
data.copy_from_slice(x);
Ok(AccountId32(data))
} else {
Err(())
}
Expand Down

0 comments on commit 04de912

Please sign in to comment.