diff --git a/subxt/src/blocks/extrinsic_types.rs b/subxt/src/blocks/extrinsic_types.rs index 8cb9a9c35c..5aa19f8c5a 100644 --- a/subxt/src/blocks/extrinsic_types.rs +++ b/subxt/src/blocks/extrinsic_types.rs @@ -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>(&self) -> Option> { 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(&self) -> Result { self.decoded()?.as_type::().map_err(Into::into) } diff --git a/subxt/src/config/signed_extensions.rs b/subxt/src/config/signed_extensions.rs index 508792c491..c487ef4f8f 100644 --- a/subxt/src/config/signed_extensions.rs +++ b/subxt/src/config/signed_extensions.rs @@ -276,8 +276,10 @@ impl SignedExtension for CheckMortality { /// The [`ChargeAssetTxPayment`] signed extension. #[derive(Debug, Encode, Decode, DecodeAsType)] pub struct ChargeAssetTxPayment { - tip: Compact, - asset_id: Option, + /// Tip + pub tip: Compact, + /// Asset Id + pub asset_id: Option, } /// Parameters to configure the [`ChargeAssetTxPayment`] signed extension. @@ -347,6 +349,7 @@ impl SignedExtension for ChargeAssetTxPayment { /// The [`ChargeTransactionPayment`] signed extension. #[derive(Debug, Encode, Decode, DecodeAsType)] pub struct ChargeTransactionPayment { + /// Tip tip: Compact, } diff --git a/testing/integration-tests/src/full_client/blocks/mod.rs b/testing/integration-tests/src/full_client/blocks/mod.rs index f65678160d..b659d8d947 100644 --- a/testing/integration-tests/src/full_client/blocks/mod.rs +++ b/testing/integration-tests/src/full_client/blocks/mod.rs @@ -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::().0; + let nonce1_static = extensions1.find::().unwrap().unwrap().0; let tip1 = extensions1.tip().unwrap(); - let tip1_static: u128 = extensions1.find::().tip.0; + let tip1_static: u128 = extensions1 + .find::() + .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::().0; + let nonce2_static: u64 = extensions2.find::().unwrap().unwrap().0; let tip2 = extensions2.tip().unwrap(); - let tip2_static: u128 = extensions2.find::().tip.0; + let tip2_static: u128 = extensions2 + .find::() + .unwrap() + .unwrap() + .tip + .0; assert_eq!(nonce1, 0); assert_eq!(nonce1, nonce1_static);