mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
support both ChargeTransactionPayment and ChargeAssetTxPayment
This commit is contained in:
@@ -668,7 +668,11 @@ impl<'a> ExtrinsicSignedExtensions<'a> {
|
|||||||
|
|
||||||
/// The tip of an extrinsic, extracted from the ChargeTransactionPayment signed extension.
|
/// The tip of an extrinsic, extracted from the ChargeTransactionPayment signed extension.
|
||||||
pub fn tip(&self) -> Option<u128> {
|
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;
|
let tip = Compact::<u128>::decode(&mut tip.bytes()).ok()?.0;
|
||||||
Some(tip)
|
Some(tip)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,10 @@
|
|||||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||||
// see LICENSE for license details.
|
// see LICENSE for license details.
|
||||||
|
|
||||||
|
|
||||||
use crate::{test_context, utils::node_runtime};
|
use crate::{test_context, utils::node_runtime};
|
||||||
use codec::{Compact, Encode};
|
use codec::{Compact, Encode};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
|
||||||
|
|
||||||
use subxt::config::DefaultExtrinsicParamsBuilder;
|
use subxt::config::DefaultExtrinsicParamsBuilder;
|
||||||
use subxt_metadata::Metadata;
|
use subxt_metadata::Metadata;
|
||||||
use subxt_signer::sr25519::dev;
|
use subxt_signer::sr25519::dev;
|
||||||
|
|||||||
Reference in New Issue
Block a user