XCM: Proper Asset Checking #487
Labels
I5-enhancement
An additional feature request.
T1-FRAME
This PR/Issue is related to core FRAME, the framework.
T6-XCM
This PR/Issue is related to XCM.
Right now an account is used to represent all assets teleported to other chains (in the case that the assets are minted on the local chain) and to represent all assets teleported in from other chains (in the case that the assets are minted on a remote chain).
In the first case this is a somewhat harmless abuse of the account model, which is useful since a) it's an easy way of managing bookkeeping and b) total issuance is updated naturally to include foreign-held assets.
In the second case it is quite problematic since total issuance double-counts assets held locally as they're teleported in (once in owner's account and a second time in the checking account).
Instead, we should introduce and use a new feature in assets, uniques and balances pallets, exposed by new traits. Other pallets (e.g. ORML) which would want to be fully compatible with the teleportation system can also implement these traits.
The new trait introduces four new functions:
fn import(checking: AccountId, ... /* asset id, amount &c */)
: to be called aftermint
. Note internally that the asset has been imported. Any transfers/burn-and-mints should not alter this mark - the only way to alter the mark should be through theunimport
call.fn unimport(checking: AccountId, ... /* asset id, amount &c */) -> Result<(), ()>
: to be called beforeburn
; return anErr
if no outstandingimport
ed asset matches the asset given. Otherwise remove mark as imported.fn export(checking: AccountId, ... /* asset id, amount &c */)
: to be called afterburn
. Note internally that an asset exists in a foreign system. If total issuance is tracked then it should be increased accordingly. Any transfers/burn-and-mints should not alter this mark.fn unexport(checking: AccountId, dest: AccountId, ... /* asset id, amount &c */) -> Result<(), ()>
: Remove a mark/note previously placed on an asset byexport
. If there is no outstandingexport
ed asset, then return anErr
.The text was updated successfully, but these errors were encountered: