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

Gateway should no longer build token registration XCM #1381

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from

Conversation

vgeddes
Copy link
Collaborator

@vgeddes vgeddes commented Feb 12, 2025

Instead, I've modified the protocol so that:

  1. Users can still pass raw xcm blobs
  2. The gateway itself can pass a "template id" like CreateAssetXCM of raw xcm.

Then the inbound-queue on BH can either passthrough the raw xcm or build the create asset XCM.

Comment on lines +52 to +57
library XcmKind {
/// SCALE-encoded raw bytes for `VersionedXcm`
uint8 constant Raw = 0;
/// Create a new asset in the ForeignAssets pallet of AssetHub
uint8 constant CreateAsset = 1;
}
Copy link
Collaborator Author

@vgeddes vgeddes Feb 14, 2025

Choose a reason for hiding this comment

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

@alistair-singh @claravanstaden @yrong to give more context, this change opens up the possibility of users not strictly needing to pass raw XCM through the bridge to Polkadot.

Instead they can pass in a simpler ABI-encoded data, like:

struct Transfer {
  destination: Location,
  destination_fee: DestinationFee,
  beneficiary: Location,
  transact: Option<Bytes>,
}

// How to obtain destination fee on AH
enum DestinationFee {
    // Swap native ether in `message.value`
    SwapEther {
        in: amount
        out: (Location, amount)
    },
    // Swap asset in `message.assets`
    SwapAsset {
        in: (u8, amount)
        out: (Location, amount)
    },
    // Directly use some amount of an asset in `message.assets`.
    Asset: (u8, amount),
}

Then the inbound-queue can build an XCM that does the following:

  • Obtain the destination fee according to the DestinationFee instruction on AH
  • Adds an InitiateTransfer instruction that forwards message.assets to destination
    • Sets the asset claimer on the destination to beneficiary
    • Deposits into beneficiary account
    • Optionally executes an XCM::Transact

This would simplify the UX and also make it easier for to on-chain contracts to send messages to Polkadot without having to build XCM. It is hard to build XCM onchain.

Would this be useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants