mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 15:35:42 +00:00
adjust to merge conflicts and tests
This commit is contained in:
@@ -674,6 +674,8 @@ impl<'a, T: Config> ExtrinsicSignedExtensions<'a, T> {
|
|||||||
Some(signed_extension)
|
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>> {
|
pub fn find<S: SignedExtension<T>>(&self) -> Option<Result<S::Extra, Error>> {
|
||||||
let signed_extension = self.find_by_name(S::NAME)?;
|
let signed_extension = self.find_by_name(S::NAME)?;
|
||||||
Some(signed_extension.as_type().map_err(Into::into))
|
Some(signed_extension.as_type().map_err(Into::into))
|
||||||
@@ -734,6 +736,7 @@ impl<'a, T: Config> ExtrinsicSignedExtension<'a, T> {
|
|||||||
self.decoded()?.to_value()
|
self.decoded()?.to_value()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Decodes the Signed Extension into a static type.
|
||||||
pub fn as_type<E: DecodeAsType>(&self) -> Result<E, Error> {
|
pub fn as_type<E: DecodeAsType>(&self) -> Result<E, Error> {
|
||||||
self.decoded()?.as_type::<E>().map_err(Into::into)
|
self.decoded()?.as_type::<E>().map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,8 +276,10 @@ impl<T: Config> SignedExtension<T> for CheckMortality<T> {
|
|||||||
/// The [`ChargeAssetTxPayment`] signed extension.
|
/// The [`ChargeAssetTxPayment`] signed extension.
|
||||||
#[derive(Debug, Encode, Decode, DecodeAsType)]
|
#[derive(Debug, Encode, Decode, DecodeAsType)]
|
||||||
pub struct ChargeAssetTxPayment {
|
pub struct ChargeAssetTxPayment {
|
||||||
tip: Compact<u128>,
|
/// Tip
|
||||||
asset_id: Option<u32>,
|
pub tip: Compact<u128>,
|
||||||
|
/// Asset Id
|
||||||
|
pub asset_id: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parameters to configure the [`ChargeAssetTxPayment`] signed extension.
|
/// Parameters to configure the [`ChargeAssetTxPayment`] signed extension.
|
||||||
@@ -347,6 +349,7 @@ impl<T: Config> SignedExtension<T> for ChargeAssetTxPayment {
|
|||||||
/// The [`ChargeTransactionPayment`] signed extension.
|
/// The [`ChargeTransactionPayment`] signed extension.
|
||||||
#[derive(Debug, Encode, Decode, DecodeAsType)]
|
#[derive(Debug, Encode, Decode, DecodeAsType)]
|
||||||
pub struct ChargeTransactionPayment {
|
pub struct ChargeTransactionPayment {
|
||||||
|
/// Tip
|
||||||
tip: Compact<u128>,
|
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 transaction1 = submit_transfer_extrinsic_and_get_it_back!(1234);
|
||||||
let extensions1 = transaction1.signed_extensions().unwrap();
|
let extensions1 = transaction1.signed_extensions().unwrap();
|
||||||
let nonce1 = extensions1.nonce().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 = 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 transaction2 = submit_transfer_extrinsic_and_get_it_back!(5678);
|
||||||
let extensions2 = transaction2.signed_extensions().unwrap();
|
let extensions2 = transaction2.signed_extensions().unwrap();
|
||||||
let nonce2 = extensions2.nonce().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 = 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, 0);
|
||||||
assert_eq!(nonce1, nonce1_static);
|
assert_eq!(nonce1, nonce1_static);
|
||||||
|
|||||||
Reference in New Issue
Block a user