support both ChargeTransactionPayment and ChargeAssetTxPayment

This commit is contained in:
Tadeo hepperle
2023-10-24 13:50:01 +02:00
parent 0eabab9618
commit 58fd6543d6
2 changed files with 5 additions and 3 deletions
+5 -1
View File
@@ -668,7 +668,11 @@ impl<'a> ExtrinsicSignedExtensions<'a> {
/// The tip of an extrinsic, extracted from the ChargeTransactionPayment signed extension.
pub fn tip(&self) -> Option<u128> {
let tip = self.find("ChargeAssetTxPayment")?;
let tip = self
.find("ChargeTransactionPayment")
.or_else(|| self.find("ChargeAssetTxPayment"))?;
// Note: ChargeAssetTxPayment might have addition information in it (asset_id).
// But both should start with a compact encoded u128, so this decoding is fine.
let tip = Compact::<u128>::decode(&mut tip.bytes()).ok()?.0;
Some(tip)
}
@@ -2,12 +2,10 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{test_context, utils::node_runtime};
use codec::{Compact, Encode};
use futures::StreamExt;
use subxt::config::DefaultExtrinsicParamsBuilder;
use subxt_metadata::Metadata;
use subxt_signer::sr25519::dev;