mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
Asset Transaction Payment (#488)
* use new pallet name based genesis config names * use custom substrate and update polkadot * add initial asset-tx-payment pallet * update cargo.toml * add (failing) tests * dispatch Calls instead of using Pallet functions * fix fee-refund split * add test for transaction payment with tip * update cargo.lock * update cargo.lock * remove mint workaround and use Mutable trait * extract fee charging logic into OnChargeAssetTransaction trait * use asset-tx-payment in statemint runtime * make extrinsics public * make extrinsics public * use ChargeAssetIdOf type alias * update deps * move back to AssetIdOf * remove extra rpc_http_threads * use different substrate branch * Update pallets/asset-tx-payment/src/payment.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update pallets/asset-tx-payment/src/payment.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * remove overrides * override substrate deps (again) * increment spec_version and transaction_version (because we change transaction signing) * remove direct dependency on pallet-balances from asset-tx-payment * remove Assets pallet visibility workaround * add docs and comments * remove unused imports * more docs * add more debug asserts to document assumptions * add test for tx payment from account with only assets * add test for missing asset case * extend test to cover non-sufficient assets * add a test for Pays::No (refunded transaction) * add type alias comments * add more doc comments * add asset-tx-payment to statemine and westmint * improve formatting * update license headers * add default implementation of HandleCredit for () * update doc comments and format imports * adjust Cargo.toml * update cargo.lock * cargo fmt * cargo fmt * cargo fmt * cargo +nightly fmt * add type alias for OnChargeTransaction * cargo +nightly fmt * convert ChargeAssetTxPayment from tuple struct to regular struct * add more comments * formatting * adjust imports and comment * cargo +nightly fmt * reformat comment * use ChargeTransactionPayment's own get_priority + update Substrate * update Substrate and Polkadot * cargo fmt * cargo fmt * add OperationalFeeMultiplier to asset tx payment tests * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * add doc links * charge a minimum converted asset fee of 1 if the input fee is greater zero * cargo +nightly fmt * bump spec and transaction version Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -62,6 +62,7 @@ cumulus-pallet-xcmp-queue = { path = "../../pallets/xcmp-queue", default-feature
|
||||
cumulus-pallet-xcm = { path = "../../pallets/xcm", default-features = false }
|
||||
cumulus-pallet-session-benchmarking = { path = "../../pallets/session-benchmarking", default-features = false, version = "3.0.0" }
|
||||
cumulus-ping = { path = "../pallets/ping", default-features = false }
|
||||
pallet-asset-tx-payment = { path = "../../pallets/asset-tx-payment", default-features = false }
|
||||
pallet-collator-selection = { path = "../../pallets/collator-selection", default-features = false }
|
||||
parachains-common = { path = "../parachains-common", default-features = false }
|
||||
|
||||
@@ -136,6 +137,7 @@ std = [
|
||||
"pallet-utility/std",
|
||||
"parachain-info/std",
|
||||
"cumulus-pallet-aura-ext/std",
|
||||
"pallet-asset-tx-payment/std",
|
||||
"pallet-collator-selection/std",
|
||||
"cumulus-pallet-dmp-queue/std",
|
||||
"cumulus-pallet-parachain-system/std",
|
||||
|
||||
@@ -29,7 +29,7 @@ use sp_api::impl_runtime_apis;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT},
|
||||
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto},
|
||||
transaction_validity::{TransactionSource, TransactionValidity},
|
||||
ApplyExtrinsicResult,
|
||||
};
|
||||
@@ -56,7 +56,7 @@ use frame_system::{
|
||||
};
|
||||
pub use parachains_common as common;
|
||||
use parachains_common::{
|
||||
impls::{DealWithFees, NonZeroIssuance},
|
||||
impls::{AssetsToBlockAuthor, DealWithFees, NonZeroIssuance},
|
||||
opaque, AccountId, AssetId, AuraId, Balance, BlockNumber, Hash, Header, Index, Signature,
|
||||
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
|
||||
};
|
||||
@@ -90,10 +90,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("statemint"),
|
||||
impl_name: create_runtime_str!("statemint"),
|
||||
authoring_version: 1,
|
||||
spec_version: 1,
|
||||
spec_version: 2,
|
||||
impl_version: 1,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 1,
|
||||
transaction_version: 2,
|
||||
};
|
||||
|
||||
/// The version information used to identify this runtime when compiled natively.
|
||||
@@ -656,6 +656,14 @@ impl pallet_collator_selection::Config for Runtime {
|
||||
type WeightInfo = weights::pallet_collator_selection::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
impl pallet_asset_tx_payment::Config for Runtime {
|
||||
type Fungibles = Assets;
|
||||
type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter<
|
||||
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto>,
|
||||
AssetsToBlockAuthor<Runtime>,
|
||||
>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ClassDeposit: Balance = UNITS; // 1 UNIT deposit to create asset class
|
||||
pub const InstanceDeposit: Balance = UNITS / 100; // 1/100 UNIT deposit to create asset instance
|
||||
@@ -703,6 +711,7 @@ construct_runtime!(
|
||||
// Monetary stuff.
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 10,
|
||||
TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 11,
|
||||
AssetTxPayment: pallet_asset_tx_payment::{Pallet} = 12,
|
||||
|
||||
// Collator support. the order of these 4 are important and shall not change.
|
||||
Authorship: pallet_authorship::{Pallet, Call, Storage} = 20,
|
||||
@@ -744,7 +753,7 @@ pub type SignedExtra = (
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
pallet_asset_tx_payment::ChargeAssetTxPayment<Runtime>,
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
|
||||
Reference in New Issue
Block a user