-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Pay tx fee with assets by using the asset conversion pallet #14340
Conversation
# Conflicts: # bin/node/runtime/src/impls.rs
frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs
Outdated
Show resolved
Hide resolved
frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is OK to go on Westend. Would like to see a few more things addressed before Kusama though. Will let @muharem and/or @kianenigma have another look before approving.
…ent.rs Co-authored-by: joe petrowski <[email protected]>
This needs to be addressed.
We don't, this is something that wallets and UIs can (and should) handle.
Look at the PR.
On Asset Hub we won't need to since everything can only pair with DOT, but this would be a nice addition (and should at least be documented in the README). |
// If successful returns the amount in native tokens. | ||
/// Trait for providing methods to swap between the chain's native token and other asset classes. | ||
pub trait SwapNative<Origin, AccountId, Balance, AssetBalance, AssetId> { | ||
/// Take an `asset_id` and swap some amount for `amount_out` of the chain's native asset. If an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you actually need all of this to be generics, instead of associated types? You can probably save a bunch of boilerplate if you revise.
From what I can seem we want the asset-related stuff to be generic, but everything else to be associated types, because a chain might have multiple asset classes, but almost always has just one native currency. So something like
impl SawpNative<AssetType1> for PalletA {...}
impl SawpNative<AssetType2> for PalletB {...}
is reasonable but I don't think we ever want to customize the origin per implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would invite @gilescope to answer your question :) It was his idea to create this generic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions for follow-ups, looks good otherwise.
* Dedup raising swap event * use expect rather than unwrap * Additional checks for future defence. * cargo fmt * Update frame/asset-conversion/src/lib.rs Co-authored-by: Jegor Sidorenko <[email protected]> --------- Co-authored-by: Jegor Sidorenko <[email protected]>
bot merge |
+ From<ChargeAssetLiquidityOf<T>>, | ||
ChargeAssetIdOf<T>: Send + Sync, | ||
{ | ||
const IDENTIFIER: &'static str = "ChargeAssetTxPayment"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name should be unique per signed extension. But as I already said on element, we should just make asset-tx-payment generic to support the use case here.
…ch#14340) * Pay tx by swapping the assets * Change liquidity structure * Uncomment the event * Update frame/transaction-payment/asset-tx-payment/src/payment.rs Co-authored-by: Squirrel <[email protected]> * New approach * Fix bounds * Clearer version * Change IsType with Into and From * Enable event * Check ED + fix the logic * Add temp comments * Rework the refund * Clean up * Improve readability * Getting closer * fix * Use fungible instead of Currency * Test account without ed * Final push * Fixed * Rename to pallet-asset-conversion-tx-payment * Bring back the old pallet * Update versions * Update docs * Update readme * Wrong readme updated * Revert back doc change * Fix import * Fix kitchensink * Fix * One more time.. * Wait pls * Update frame/asset-conversion/src/lib.rs Co-authored-by: Squirrel <[email protected]> * Update frame/support/src/traits/tokens/fungibles/regular.rs Co-authored-by: joe petrowski <[email protected]> * Update docs/comments * Docs improvement * Update frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs Co-authored-by: joe petrowski <[email protected]> * Update frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs Co-authored-by: joe petrowski <[email protected]> * Update frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs Co-authored-by: joe petrowski <[email protected]> * Update frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs Co-authored-by: joe petrowski <[email protected]> * Update frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs Co-authored-by: joe petrowski <[email protected]> * Payed -> paid * Docs * Update frame/transaction-payment/asset-conversion-tx-payment/README.md Co-authored-by: Muharem Ismailov <[email protected]> * Rewrite docs * Try to clean the deps * Add debug assert * Return back frame-benchmarking * Update cargo * Update frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs Co-authored-by: joe petrowski <[email protected]> * Rename * clearer error message * Docs for Pay by Swap (paritytech#14445) * docs * better error name * more comments * more docs on swap trait * Fix compile errors * Another fix * Refactoring * Update frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs Co-authored-by: joe petrowski <[email protected]> * Emit an error if we fail to swap the refund back * Add integrity_test * Update frame/asset-conversion/src/lib.rs Co-authored-by: Kian Paimani <[email protected]> * Fmt * Use defensive_ok_or * child PR: Tidy swap event (paritytech#14441) * Dedup raising swap event * use expect rather than unwrap * Additional checks for future defence. * cargo fmt * Update frame/asset-conversion/src/lib.rs Co-authored-by: Jegor Sidorenko <[email protected]> --------- Co-authored-by: Jegor Sidorenko <[email protected]> --------- Co-authored-by: Squirrel <[email protected]> Co-authored-by: joe petrowski <[email protected]> Co-authored-by: Muharem Ismailov <[email protected]> Co-authored-by: Kian Paimani <[email protected]>
Allows to pay for the tx in any assets by swapping it into the native, given the liquidity pool exists
cumulus companion: paritytech/cumulus#2148