Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: Add SkipCheckIfFeeless signed extension #1264

Merged
merged 18 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions subxt/src/config/default_extrinsic_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub type DefaultExtrinsicParams<T> = signed_extensions::AnyOf<
signed_extensions::CheckGenesis<T>,
signed_extensions::CheckMortality<T>,
signed_extensions::ChargeAssetTxPayment<T>,
signed_extensions::SkipCheckIfFeeless,
signed_extensions::ChargeTransactionPayment,
),
>;
Expand Down Expand Up @@ -138,6 +139,7 @@ impl<T: Config> DefaultExtrinsicParamsBuilder<T> {
(),
check_mortality_params,
charge_asset_tx_params,
(),
charge_transaction_params,
)
}
Expand Down
26 changes: 26 additions & 0 deletions subxt/src/config/signed_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,32 @@ impl<T: Config> SignedExtension<T> for ChargeTransactionPayment {
type Decoded = Self;
}

/// The [`SkipCheckIfFeeless`] signed extension.
#[derive(Debug, DecodeAsType)]
pub struct SkipCheckIfFeeless;

impl<T: Config> ExtrinsicParams<T> for SkipCheckIfFeeless {
type OtherParams = ();
type Error = std::convert::Infallible;

fn new<Client: OfflineClientT<T>>(
_nonce: u64,
_client: Client,
_other_params: Self::OtherParams,
) -> Result<Self, Self::Error> {
Ok(SkipCheckIfFeeless)
}
}

impl ExtrinsicParamsEncoder for SkipCheckIfFeeless {
fn encode_extra_to(&self, _v: &mut Vec<u8>) {}
}

impl<T: Config> SignedExtension<T> for SkipCheckIfFeeless {
const NAME: &'static str = "SkipCheckIfFeeless";
type Decoded = Self;
}

/// This accepts a tuple of [`SignedExtension`]s, and will dynamically make use of whichever
/// ones are actually required for the chain in the correct order, ignoring the rest. This
/// is a sensible default, and allows for a single configuration to work across multiple chains.
Expand Down