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
5 changes: 5 additions & 0 deletions precompiles/pallet-xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ xcm-primitives = { workspace = true }
# Substrate
frame-support = { workspace = true }
frame-system = { workspace = true }
scale-info = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
sp-weights = { workspace = true }
parity-scale-codec = { workspace = true, features = [ "derive" ] }

# Frontier
evm = { workspace = true, features = [ "with-codec" ] }
Expand All @@ -28,6 +30,7 @@ pallet-evm = { workspace = true, features = [ "forbid-evm-reentrancy" ] }

# Polkadot
xcm = { workspace = true }
xcm-executor = { workspace = true }
pallet-xcm = { workspace = true }

# Cumulus
Expand Down Expand Up @@ -61,7 +64,9 @@ std = [
"frame-system/std",
"pallet-evm/std",
"pallet-xcm/std",
"parity-scale-codec/std",
"precompile-utils/std",
"scale-info/std",
"sp-core/std",
"sp-std/std",
"xcm/std",
Expand Down
74 changes: 54 additions & 20 deletions precompiles/pallet-xcm/XcmInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,68 +29,102 @@ interface XCM {
uint256 amount;
}

// The values start at `0` and are represented as `uint8`
enum TransferType {
Teleport,
LocalReserve,
DestinationReserve,
RemoteReserve
Agusrodri marked this conversation as resolved.
Show resolved Hide resolved
}

/// @dev Function to send assets via XCM using transfer_assets() pallet-xcm extrinsic.
/// @custom:selector 59df8416
/// @custom:selector 9ea8ada7
/// @param dest The destination chain.
/// @param beneficiary The actual account that will receive the tokens on dest.
/// @param assets The combination (array) of assets to send.
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
/// @param weight The weight to be used for the whole XCM operation.
/// (uint64::MAX in refTime means Unlimited weight)
function transferAssetsLocation(
Location memory dest,
Location memory beneficiary,
AssetLocationInfo[] memory assets,
uint32 feeAssetItem,
Weight memory weight
uint32 feeAssetItem
) external;

/// @dev Function to send assets via XCM to a 20 byte-like parachain
/// using transfer_assets() pallet-xcm extrinsic.
/// @custom:selector b489262e
/// @custom:selector a0aeb5fe
/// @param paraId The para-id of the destination chain.
/// @param beneficiary The actual account that will receive the tokens on paraId destination.
/// @param assets The combination (array) of assets to send.
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
/// @param weight The weight to be used for the whole XCM operation.
/// (uint64::MAX in refTime means Unlimited weight)
function transferAssetsToPara20(
uint32 paraId,
address beneficiary,
AssetAddressInfo[] memory assets,
uint32 feeAssetItem,
Weight memory weight
uint32 feeAssetItem
) external;

/// @dev Function to send assets via XCM to a 32 byte-like parachain
/// using transfer_assets() pallet-xcm extrinsic.
/// @custom:selector 4461e6f5
/// @custom:selector f23032c3
/// @param paraId The para-id of the destination chain.
/// @param beneficiary The actual account that will receive the tokens on paraId destination.
/// @param assets The combination (array) of assets to send.
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
/// @param weight The weight to be used for the whole XCM operation.
/// (uint64::MAX in refTime means Unlimited weight)
function transferAssetsToPara32(
uint32 paraId,
bytes32 beneficiary,
AssetAddressInfo[] memory assets,
uint32 feeAssetItem,
Weight memory weight
uint32 feeAssetItem
) external;

/// @dev Function to send assets via XCM to the relay chain
/// using transfer_assets() pallet-xcm extrinsic.
/// @custom:selector d7c89659
/// @custom:selector 6521cc2c
/// @param beneficiary The actual account that will receive the tokens on the relay chain.
/// @param assets The combination (array) of assets to send.
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
/// @param weight The weight to be used for the whole XCM operation.
/// (uint64::MAX in refTime means Unlimited weight)
function transferAssetsToRelay(
bytes32 beneficiary,
AssetAddressInfo[] memory assets,
uint32 feeAssetItem,
Weight memory weight
uint32 feeAssetItem
) external;

// No RemoteReserve at all
function transferAssetsUsingTypeAndThenLocation(
Location memory dest,
AssetLocationInfo[] memory assets,
TransferType assetsTransferType,
uint8 remoteFeesIdIndex,
TransferType feesTransferType,
bytes memory customXcmOnDest
) external;

// Reserve for assets and fees (must share same reserve if the transfer type is RemoteReserve)
Agusrodri marked this conversation as resolved.
Show resolved Hide resolved
function transferAssetsUsingTypeAndThenLocation(
Location memory dest,
AssetLocationInfo[] memory assets,
uint8 remoteFeesIdIndex,
bytes memory customXcmOnDest,
Location memory remoteReserve
) external;

// No RemoteReserve at all
function transferAssetsUsingTypeAndThenAddress(
Location memory dest,
AssetAddressInfo[] memory assets,
TransferType assetsTransferType,
uint8 remoteFeesIdIndex,
TransferType feesTransferType,
bytes memory customXcmOnDest
) external;

// Reserve for assets and fees (must share same reserve if the transfer type is RemoteReserve)
Agusrodri marked this conversation as resolved.
Show resolved Hide resolved
function transferAssetsUsingTypeAndThenAddress(
Location memory dest,
AssetAddressInfo[] memory assets,
uint8 remoteFeesIdIndex,
bytes memory customXcmOnDest,
Location memory remoteReserve
) external;
}
Loading
Loading