Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for transfer_assets_using_type_and_then extrinsic in pallet-xcm precompile #54

Merged
merged 12 commits into from
Oct 8, 2024

Conversation

Agusrodri
Copy link
Contributor

@Agusrodri Agusrodri commented Oct 3, 2024

What does it do?

This PR adds support for transfer_assets_using_type_and_then extrinsic in pallet-xcm precompile.

In total 4 new selectors were added to the pallet-xcm precompile interface:

  • Selector 8425d893:

This function allows calling transfer_assets_using_type_and_then extrinsic (with assets being represented in Location format) by ONLY allowing combinations of LocalReserve, Teleport, and DestinationReserve transfer types. RemoteReserve type is not allowed here. It was decided to split the behavior in two functions for better params organization.

    /// @custom:selector 8425d893
    function transferAssetsUsingTypeAndThenLocation(
        Location memory dest,
        AssetLocationInfo[] memory assets,
        TransferType assetsTransferType,
        uint8 remoteFeesIdIndex,
        TransferType feesTransferType,
        bytes memory customXcmOnDest
    ) external;
  • Selector fc19376c:

This function allows calling transfer_assets_using_type_and_then extrinsic (with assets being represented in Location format) through the RemoteReserve transfer type for both assets and fees. In this case, assets and fees MUST share the same reserve for the extrinsic to execute properly. This is being restricted by pallet-xcm, as it doesn't allow to send XCMs to separate chains, given that there is no guarantee of delivery order on final destination (more details here).

    /// @custom:selector fc19376c
    function transferAssetsUsingTypeAndThenLocation(
        Location memory dest,
        AssetLocationInfo[] memory assets,
        uint8 remoteFeesIdIndex,
        bytes memory customXcmOnDest,
        Location memory remoteReserve
    ) external;
  • The other 2 remaining selectors (998093ee and aaecfc62) are identical to the ones described above. The only difference is that they receive the assets in Address format.
    /// @custom:selector 998093ee
    function transferAssetsUsingTypeAndThenAddress(
        Location memory dest,
        AssetAddressInfo[] memory assets,
        TransferType assetsTransferType,
        uint8 remoteFeesIdIndex,
        TransferType feesTransferType,
        bytes memory customXcmOnDest
    ) external;

    /// @custom:selector aaecfc62
    function transferAssetsUsingTypeAndThenAddress(
        Location memory dest,
        AssetAddressInfo[] memory assets,
        uint8 remoteFeesIdIndex,
        bytes memory customXcmOnDest,
        Location memory remoteReserve
    ) external;

Related upstream PRs

@Agusrodri Agusrodri marked this pull request as ready for review October 5, 2024 19:25
Copy link
Collaborator

@librelois librelois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Agusrodri Overall it's good, can you just explain in the solidity doc that customXcmOnDest should be SCALE encoded?

@Agusrodri Agusrodri merged commit 767eb0c into main Oct 8, 2024
9 of 10 checks passed
@Agusrodri Agusrodri deleted the agustin-xcm-transfer-assets-using branch October 8, 2024 16:57
Agusrodri added a commit that referenced this pull request Oct 8, 2024
…llet-xcm precompile (#54)

* start adding transfer_assets_using_type_and_then to pallet-xcm precompile

* add function variant for address type

* use WeightLimit::Unlimited in all selectors

* add remaining functions and overall refactor

* remove unnecessary selectors and add a couple tests

* add more tests

* pr suggestions

* add documentation for solidity selectors

* fmt

* fix test

* fix rust tests compilation

* add clarification for SCALE encoding in custom xcm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants