Improve SignedExtension matching logic and remove SkipCheckIfFeeless bits (#1283)

* First pass making matching on signed exts more general and handlng SkipCheckifFeeless

* remove unneeded derives (only exts we can decode into are handled by the user)

* No SkipCheckIfFeeless in integration tests either

* Cargo fmt

* Remove SkipCheckIfFeeless specific logic

* clippy

* matches to just return bool, not result

* remove now-invalid comment

* return error from find if .iter() errors
This commit is contained in:
James Wilson
2023-11-23 15:44:35 +00:00
committed by GitHub
parent 6855b1ffd2
commit 2c528854da
8 changed files with 138 additions and 383 deletions
@@ -5,9 +5,7 @@
use crate::{test_context, utils::node_runtime};
use codec::{Compact, Encode};
use futures::StreamExt;
use subxt::config::signed_extensions::{
ChargeAssetTxPayment, CheckMortality, CheckNonce, SkipCheckIfFeeless,
};
use subxt::config::signed_extensions::{ChargeAssetTxPayment, CheckMortality, CheckNonce};
use subxt::config::DefaultExtrinsicParamsBuilder;
use subxt::config::SubstrateConfig;
use subxt::utils::Era;
@@ -280,25 +278,23 @@ async fn decode_signed_extensions_from_blocks() {
let extensions1 = transaction1.signed_extensions().unwrap();
let nonce1 = extensions1.nonce().unwrap();
let nonce1_static = extensions1.find::<CheckNonce>().unwrap().unwrap().0;
let nonce1_static = extensions1.find::<CheckNonce>().unwrap().unwrap();
let tip1 = extensions1.tip().unwrap();
let tip1_static: u128 = extensions1
.find::<SkipCheckIfFeeless<SubstrateConfig, ChargeAssetTxPayment<SubstrateConfig>>>()
.find::<ChargeAssetTxPayment<SubstrateConfig>>()
.unwrap()
.unwrap()
.inner_signed_extension()
.tip();
let transaction2 = submit_transfer_extrinsic_and_get_it_back!(5678);
let extensions2 = transaction2.signed_extensions().unwrap();
let nonce2 = extensions2.nonce().unwrap();
let nonce2_static = extensions2.find::<CheckNonce>().unwrap().unwrap().0;
let nonce2_static = extensions2.find::<CheckNonce>().unwrap().unwrap();
let tip2 = extensions2.tip().unwrap();
let tip2_static: u128 = extensions2
.find::<SkipCheckIfFeeless<SubstrateConfig, ChargeAssetTxPayment<SubstrateConfig>>>()
.find::<ChargeAssetTxPayment<SubstrateConfig>>()
.unwrap()
.unwrap()
.inner_signed_extension()
.tip();
assert_eq!(nonce1, 0);
@@ -318,7 +314,7 @@ async fn decode_signed_extensions_from_blocks() {
"CheckMortality",
"CheckNonce",
"CheckWeight",
"SkipCheckIfFeeless",
"ChargeAssetTxPayment",
];
assert_eq!(extensions1.iter().count(), expected_signed_extensions.len());