adjust to merge conflicts and tests

This commit is contained in:
Tadeo hepperle
2023-10-31 15:26:35 +01:00
parent 9728d0010e
commit e32065e005
3 changed files with 22 additions and 6 deletions
+3
View File
@@ -674,6 +674,8 @@ impl<'a, T: Config> ExtrinsicSignedExtensions<'a, T> {
Some(signed_extension)
}
/// Searches through all signed extensions to find a specific one.
/// If the Signed Extension is found, but decoding failed, `Some(Err(err))` is returned.
pub fn find<S: SignedExtension<T>>(&self) -> Option<Result<S::Extra, Error>> {
let signed_extension = self.find_by_name(S::NAME)?;
Some(signed_extension.as_type().map_err(Into::into))
@@ -734,6 +736,7 @@ impl<'a, T: Config> ExtrinsicSignedExtension<'a, T> {
self.decoded()?.to_value()
}
/// Decodes the Signed Extension into a static type.
pub fn as_type<E: DecodeAsType>(&self) -> Result<E, Error> {
self.decoded()?.as_type::<E>().map_err(Into::into)
}
+5 -2
View File
@@ -276,8 +276,10 @@ impl<T: Config> SignedExtension<T> for CheckMortality<T> {
/// The [`ChargeAssetTxPayment`] signed extension.
#[derive(Debug, Encode, Decode, DecodeAsType)]
pub struct ChargeAssetTxPayment {
tip: Compact<u128>,
asset_id: Option<u32>,
/// Tip
pub tip: Compact<u128>,
/// Asset Id
pub asset_id: Option<u32>,
}
/// Parameters to configure the [`ChargeAssetTxPayment`] signed extension.
@@ -347,6 +349,7 @@ impl<T: Config> SignedExtension<T> for ChargeAssetTxPayment {
/// The [`ChargeTransactionPayment`] signed extension.
#[derive(Debug, Encode, Decode, DecodeAsType)]
pub struct ChargeTransactionPayment {
/// Tip
tip: Compact<u128>,
}
@@ -287,16 +287,26 @@ async fn decode_signed_extensions_from_blocks() {
let transaction1 = submit_transfer_extrinsic_and_get_it_back!(1234);
let extensions1 = transaction1.signed_extensions().unwrap();
let nonce1 = extensions1.nonce().unwrap();
let nonce1_static = extensions1.find::<CheckNonce>().0;
let nonce1_static = extensions1.find::<CheckNonce>().unwrap().unwrap().0;
let tip1 = extensions1.tip().unwrap();
let tip1_static: u128 = extensions1.find::<ChargeAssetTxPayment>().tip.0;
let tip1_static: u128 = extensions1
.find::<ChargeAssetTxPayment>()
.unwrap()
.unwrap()
.tip
.0;
let transaction2 = submit_transfer_extrinsic_and_get_it_back!(5678);
let extensions2 = transaction2.signed_extensions().unwrap();
let nonce2 = extensions2.nonce().unwrap();
let nonce2_static: u64 = extensions2.find::<CheckNonce>().0;
let nonce2_static: u64 = extensions2.find::<CheckNonce>().unwrap().unwrap().0;
let tip2 = extensions2.tip().unwrap();
let tip2_static: u128 = extensions2.find::<ChargeAssetTxPayment>().tip.0;
let tip2_static: u128 = extensions2
.find::<ChargeAssetTxPayment>()
.unwrap()
.unwrap()
.tip
.0;
assert_eq!(nonce1, 0);
assert_eq!(nonce1, nonce1_static);