Description
Hi guys, we would like to propose a new feature for xtokens and want to start a discussion to see if it is reasonable and can be worked on.
Given that users can privatize any asset on our chain, we want to enable them to move cross-chain assets to our chain and privatize them in one call. Our idea is to allow users to send, along with token transfers, a Transact instruction that includes the encoded privatization extrinsic. Moving some assets and using them in an extrinsic with one call seems like something that can be useful for other use-cases as well.
The design that we've come up with so far is the following:
- Add new
transfer_with_transact
extrinsic that will use existing token transfer logic and sends a message to move some assets:
a. for the encoded call in the Transact instruction (our case to be privatized)
b. to pay for execution fees - All the assets will be deposited to an account created by converting the
MultiLocation
of the sender user account on the sender chain (from the viewpoint of the receiver chain) withAccount32Hash
or whatever converter is implemented on the receiver chain. - Then an additional xcm message will be sent: (DescendOrigin + WithdrawAsset + BuyExecution + Transact)
a. first descend the origin to the account from step 2
b. withdraw the fee assets from 1.b. to holding
c. buy execution with the assets in holding
d. Transact the encoded manta-pay extrinsic to privatize the assets from 1.a.
e. Change can be deposited back to the same account or a different account
Here's a very rough shot implementation of the idea for reference https://github.com/Manta-Network/open-runtime-module-library/pull/4/files
Also some impl details:
- For starters we can limit the new extrinsic where:
a.asset
is a CurrencyId andfee
is the same CurrencyId.
b.asset
andfee
are withdrawn separately from sender. - The receiver account which will also dispatch the Transact call, should be the origin of the extrinsic on the sender chain:
a.self_location.append_with(sender_account_origin).reanchor(destination_chain, ancestry)
b. the above destination won't be valid according to thedest != self_location
check
c. to work around 2.b. we need to construct a "fake" destination to pass the check
d. then use themaybe_recipient_override
argument to override with the "real" destination from 2.a. - Ideally we want to deposit change to any account on the destination chain
a. it would be easier to do a refund to the destination from 2.a.
b. we can start off without depositing any change