Skip to content

Commit

Permalink
add documentation for solidity selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusrodri committed Oct 5, 2024
1 parent aea402d commit 92b18fa
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
54 changes: 46 additions & 8 deletions precompiles/pallet-xcm/XcmInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface XCM {
/// @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 assets The combination (array) of assets to send in Location format.
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
function transferAssetsLocation(
Location memory dest,
Expand All @@ -54,7 +54,7 @@ interface XCM {
/// @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 assets The combination (array) of assets to send in Address format.
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
function transferAssetsToPara20(
uint32 paraId,
Expand All @@ -68,7 +68,7 @@ interface XCM {
/// @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 assets The combination (array) of assets to send in Address format.
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
function transferAssetsToPara32(
uint32 paraId,
Expand All @@ -81,15 +81,26 @@ interface XCM {
/// using transfer_assets() pallet-xcm extrinsic.
/// @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 assets The combination (array) of assets to send in Address format.
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
function transferAssetsToRelay(
bytes32 beneficiary,
AssetAddressInfo[] memory assets,
uint32 feeAssetItem
) external;

// No RemoteReserve at all
/// @dev Function to send assets through transfer_assets_using_type_and_then() pallet-xcm
/// extrinsic.
/// Important: in this selector RemoteReserve type (for either assets or fees) is not allowed.
/// If users want to send assets and fees (in Location format) with a remote reserve,
/// they must use the selector fc19376c.
/// @custom:selector 8425d893
/// @param dest The destination chain.
/// @param assets The combination (array) of assets to send in Location format.
/// @param assetsTransferType The TransferType corresponding to assets being sent.
/// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees.
/// @param feesTransferType The TransferType corresponding to the asset used as fees.
/// @param customXcmOnDest The XCM message to execute on destination chain.
function transferAssetsUsingTypeAndThenLocation(
Location memory dest,
AssetLocationInfo[] memory assets,
Expand All @@ -99,7 +110,15 @@ interface XCM {
bytes memory customXcmOnDest
) external;

// Remote reserve for assets and fees (must share same remote reserve)
/// @dev Function to send assets through transfer_assets_using_type_and_then() pallet-xcm
/// extrinsic.
/// @custom:selector fc19376c
/// @param dest The destination chain.
/// @param assets The combination (array) of assets to send in Location format.
/// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees.
/// @param customXcmOnDest The XCM message to execute on destination chain.
/// @param remoteReserve The remote reserve corresponding for assets and fees. They MUST
/// share the same reserve.
function transferAssetsUsingTypeAndThenLocation(
Location memory dest,
AssetLocationInfo[] memory assets,
Expand All @@ -108,7 +127,18 @@ interface XCM {
Location memory remoteReserve
) external;

// No RemoteReserve at all
/// @dev Function to send assets through transfer_assets_using_type_and_then() pallet-xcm
/// extrinsic.
/// Important: in this selector RemoteReserve type (for either assets or fees) is not allowed.
/// If users want to send assets and fees (in Address format) with a remote reserve,
/// they must use the selector aaecfc62.
/// @custom:selector 998093ee
/// @param dest The destination chain.
/// @param assets The combination (array) of assets to send in Address format.
/// @param assetsTransferType The TransferType corresponding to assets being sent.
/// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees.
/// @param feesTransferType The TransferType corresponding to the asset used as fees.
/// @param customXcmOnDest The XCM message to execute on destination chain.
function transferAssetsUsingTypeAndThenAddress(
Location memory dest,
AssetAddressInfo[] memory assets,
Expand All @@ -118,7 +148,15 @@ interface XCM {
bytes memory customXcmOnDest
) external;

// Remote reserve for assets and fees (must share same reserve)
/// @dev Function to send assets through transfer_assets_using_type_and_then() pallet-xcm
/// extrinsic.
/// @custom:selector aaecfc62
/// @param dest The destination chain.
/// @param assets The combination (array) of assets to send in Address format.
/// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees.
/// @param customXcmOnDest The XCM message to execute on destination chain.
/// @param remoteReserve The remote reserve corresponding for assets and fees. They MUST
/// share the same reserve.
function transferAssetsUsingTypeAndThenAddress(
Location memory dest,
AssetAddressInfo[] memory assets,
Expand Down
4 changes: 4 additions & 0 deletions precompiles/pallet-xcm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ fn selectors() {
assert!(PCall::transfer_assets_to_para_20_selectors().contains(&0xa0aeb5fe));
assert!(PCall::transfer_assets_to_para_32_selectors().contains(&0xf23032c3));
assert!(PCall::transfer_assets_to_relay_selectors().contains(&0x6521cc2c));
assert!(PCall::transfer_assets_using_type_and_then_location_no_remote_reserve_selectors().contains(&0x8425d893));
assert!(PCall::transfer_assets_using_type_and_then_location_remote_reserve_selectors().contains(&0xfc19376c));
assert!(PCall::transfer_assets_using_type_and_then_address_no_remote_reserve_selectors().contains(&0x998093ee));
assert!(PCall::transfer_assets_using_type_and_then_address_remote_reserve_selectors().contains(&0xaaecfc62));
}

#[test]
Expand Down

0 comments on commit 92b18fa

Please sign in to comment.