mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +00:00
Remove Default bound for AccountId (#10403)
* Remove Default for AccountId * More removals of default * Update frame/authorship/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/authorship/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/authorship/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/authorship/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * More work * More work * Remove old code * More work * pallet-asset-tx-payment * tips * sc-consensus-babe * sc-finality-grandpa * sc-consensus-babe-rpc * sc-cli * make npos crates accept non-default account (#10420) * minimal changes to make npos pallets all work * make this pesky reduce.rs a bit cleaner * more work * more work * Tests build * Fix imonline tests * Formatting * Fixes * Fixes * Fix bench * Fixes * Fixes * Fixes * Fixes * Fixes * Formatting * Fixes * Formatting * Fixes * Formatting * Fixes * Formatting * Fixes * Formatting * Update client/keystore/src/local.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/finality-grandpa/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/keystore/src/local.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/keystore/src/local.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/staking/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/staking/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update primitives/runtime/src/traits.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Formatting Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: kianenigma <kian@parity.io>
This commit is contained in:
@@ -851,7 +851,7 @@ pub trait SignedExtension:
|
||||
type AdditionalSigned: Encode + TypeInfo;
|
||||
|
||||
/// The type that encodes information that can be passed from pre_dispatch to post-dispatch.
|
||||
type Pre: Default;
|
||||
type Pre;
|
||||
|
||||
/// Construct any additional data that should be in the signed payload of the transaction. Can
|
||||
/// also perform any pre-signature-verification checks and return an error if needed.
|
||||
@@ -890,11 +890,7 @@ pub trait SignedExtension:
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
self.validate(who, call, info, len)
|
||||
.map(|_| Self::Pre::default())
|
||||
.map_err(Into::into)
|
||||
}
|
||||
) -> Result<Self::Pre, TransactionValidityError>;
|
||||
|
||||
/// Validate an unsigned transaction for the transaction queue.
|
||||
///
|
||||
@@ -924,14 +920,15 @@ pub trait SignedExtension:
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
Self::validate_unsigned(call, info, len)
|
||||
.map(|_| Self::Pre::default())
|
||||
.map_err(Into::into)
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
Self::validate_unsigned(call, info, len).map(|_| ()).map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Do any post-flight stuff for an extrinsic.
|
||||
///
|
||||
/// If the transaction is signed, then `_pre` will contain the output of `pre_dispatch`,
|
||||
/// and `None` otherwise.
|
||||
///
|
||||
/// This gets given the `DispatchResult` `_result` from the extrinsic and can, if desired,
|
||||
/// introduce a `TransactionValidityError`, causing the block to become invalid for including
|
||||
/// it.
|
||||
@@ -944,7 +941,7 @@ pub trait SignedExtension:
|
||||
/// introduced by the current block author; generally this implies that it is an inherent and
|
||||
/// will come from either an offchain-worker or via `InherentData`.
|
||||
fn post_dispatch(
|
||||
_pre: Self::Pre,
|
||||
_pre: Option<Self::Pre>,
|
||||
_info: &DispatchInfoOf<Self::Call>,
|
||||
_post_info: &PostDispatchInfoOf<Self::Call>,
|
||||
_len: usize,
|
||||
@@ -1029,18 +1026,26 @@ impl<AccountId, Call: Dispatchable> SignedExtension for Tuple {
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
Ok(for_tuples!( ( #( Tuple::pre_dispatch_unsigned(call, info, len)? ),* ) ))
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
for_tuples!( #( Tuple::pre_dispatch_unsigned(call, info, len)?; )* );
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn post_dispatch(
|
||||
pre: Self::Pre,
|
||||
pre: Option<Self::Pre>,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
post_info: &PostDispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
result: &DispatchResult,
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
for_tuples!( #( Tuple::post_dispatch(pre.Tuple, info, post_info, len, result)?; )* );
|
||||
match pre {
|
||||
Some(x) => {
|
||||
for_tuples!( #( Tuple::post_dispatch(Some(x.Tuple), info, post_info, len, result)?; )* );
|
||||
},
|
||||
None => {
|
||||
for_tuples!( #( Tuple::post_dispatch(None, info, post_info, len, result)?; )* );
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1062,6 +1067,15 @@ impl SignedExtension for () {
|
||||
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> {
|
||||
Ok(())
|
||||
}
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
Ok(self.validate(who, call, info, len).map(|_| ())?)
|
||||
}
|
||||
}
|
||||
|
||||
/// An "executable" piece of information, used by the standard Substrate Executive in order to
|
||||
@@ -1212,6 +1226,11 @@ impl<'a> TrailingZeroInput<'a> {
|
||||
pub fn new(data: &'a [u8]) -> Self {
|
||||
Self(data)
|
||||
}
|
||||
|
||||
/// Create a new instance which only contains zeroes as input.
|
||||
pub fn zeroes() -> Self {
|
||||
Self::new(&[][..])
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> codec::Input for TrailingZeroInput<'a> {
|
||||
@@ -1260,11 +1279,11 @@ pub trait AccountIdConversion<AccountId>: Sized {
|
||||
|
||||
/// Format is TYPE_ID ++ encode(parachain ID) ++ 00.... where 00... is indefinite trailing zeroes to
|
||||
/// fill AccountId.
|
||||
impl<T: Encode + Decode + Default, Id: Encode + Decode + TypeId> AccountIdConversion<T> for Id {
|
||||
impl<T: Encode + Decode, Id: Encode + Decode + TypeId> AccountIdConversion<T> for Id {
|
||||
fn into_sub_account<S: Encode>(&self, sub: S) -> T {
|
||||
(Id::TYPE_ID, self, sub)
|
||||
.using_encoded(|b| T::decode(&mut TrailingZeroInput(b)))
|
||||
.unwrap_or_default()
|
||||
.expect("`AccountId` type is never greater than 32 bytes; qed")
|
||||
}
|
||||
|
||||
fn try_from_sub_account<S: Decode>(x: &T) -> Option<(Self, S)> {
|
||||
@@ -1317,7 +1336,7 @@ macro_rules! impl_opaque_keys_inner {
|
||||
) => {
|
||||
$( #[ $attr ] )*
|
||||
#[derive(
|
||||
Default, Clone, PartialEq, Eq,
|
||||
Clone, PartialEq, Eq,
|
||||
$crate::codec::Encode,
|
||||
$crate::codec::Decode,
|
||||
$crate::scale_info::TypeInfo,
|
||||
@@ -1616,7 +1635,10 @@ pub trait BlockNumberProvider {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::codec::{Decode, Encode, Input};
|
||||
use sp_core::{crypto::Pair, ecdsa};
|
||||
use sp_core::{
|
||||
crypto::{Pair, UncheckedFrom},
|
||||
ecdsa,
|
||||
};
|
||||
|
||||
mod t {
|
||||
use sp_application_crypto::{app_crypto, sr25519};
|
||||
@@ -1629,8 +1651,8 @@ mod tests {
|
||||
use super::AppVerify;
|
||||
use t::*;
|
||||
|
||||
let s = Signature::default();
|
||||
let _ = s.verify(&[0u8; 100][..], &Public::default());
|
||||
let s = Signature::try_from(vec![0; 64]).unwrap();
|
||||
let _ = s.verify(&[0u8; 100][..], &Public::unchecked_from([0; 32]));
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Default, PartialEq, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user