paritytech / asset-transfer-api

Typescript API aiming to provide clear, and simple to use tools for transferring assets across common good parachains.
Apache License 2.0
44 stars 11 forks source link

Add support for the new `transfer_assets_using_type_and_then()` call in pallet XCM #400

Closed IkerAlus closed 6 months ago

IkerAlus commented 6 months ago

Following from the original issue: https://github.com/paritytech/asset-transfer-api/issues/384

The new transfer_assets_using_type_and_then() call in pallet XCM will add heavy changes to the original interface. Among other things, this call allows to transfer more than one asset in a proper manner (see discussion here). Asset Transfer API should support this call but leaving up to the user the flexibility and extra complexity that transfer_assets does not allow. This is, this call should meant to be only for advanced API users. More concretely:

acatangiu commented 6 months ago

In any case, the value of custom_xcm_on_dest input should default to Xcm(vec![DepositAsset { assets: Wild(AllCounted(assets.len())), beneficiary }]) as explained here. But the user should have the option to input their own custom instructions for destination.

I am hoping that this library be more than just a wrapper and instead can build on top of the pallet_xcm::transfer_assets_using_type_and_then functionality and be "smarter" and more helpful to the user.

The limitation of pallet-xcm/xtokens or any on-chain functionality is that it only has a limited view of the whole picture, its knowledge is limited to the local chain. Whereas this library (especially with the use of its registry https://github.com/paritytech/asset-transfer-api-registry/issues/134) has information about the whole ecosystem. Therefore, it could build any type of transfer for the user, without having the user write (or understand) any XCM.

I would really like to start from some "complex" user stories (bridged assets, multiple hops, multiple assets, mixing teleports with reserves, etc) that are either not possible or hard to do in practice in our ecosystem, and come up with some helper APIs here to do them, hiding all that complexity from the user.

For this ^ we really need to work backwards from the usecase, I expect we will find we still need some missing pieces from the chain to make it really great UX.

Lemme know what you think.

IkerAlus commented 6 months ago

@acatangiu Thanks for the comment, I totally agree, the main purpose of this API is to facilitate every kind of cross-chain transfers.

After thinking a bit about your comment my initial idea would be to:

acatangiu commented 6 months ago

Sounds great to me! 👍