Skip to content

Commit 0779a15

Browse files
authored
Improve pallet-xcm-precompile docs (assets ordering) (#58)
* improve pallet-xcm precompile docs * add examples for assets ordering
1 parent d21f713 commit 0779a15

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

precompiles/pallet-xcm/XcmInterface.sol

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ interface XCM {
4141
/// @param dest The destination chain.
4242
/// @param beneficiary The actual account that will receive the tokens on dest.
4343
/// @param assets The combination (array) of assets to send in Location format.
44+
/// Assets MUST be sorted, otherwise there may be discrepancies with the feeAssetItem.
45+
///
46+
/// Example a) of sorted assets (native asset and para 1000 asset):
47+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
48+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
49+
///
50+
/// Example b) of sorted assets: (native asset and relay asset)
51+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
52+
/// 2nd - Location { parents: 1, interior: Here}
53+
///
54+
/// Example c) of sorted assets: (relay asset and para 1000 asset)
55+
/// 1st - Location { parents: 1, interior: Here}
56+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
57+
///
4458
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
4559
function transferAssetsLocation(
4660
Location memory dest,
@@ -55,6 +69,20 @@ interface XCM {
5569
/// @param paraId The para-id of the destination chain.
5670
/// @param beneficiary The actual account that will receive the tokens on paraId destination.
5771
/// @param assets The combination (array) of assets to send in Address format.
72+
/// Assets MUST be sorted, otherwise there may be discrepancies with the feeAssetItem.
73+
///
74+
/// Example a) of sorted assets (native asset and para 1000 asset):
75+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
76+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
77+
///
78+
/// Example b) of sorted assets: (native asset and relay asset)
79+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
80+
/// 2nd - Location { parents: 1, interior: Here}
81+
///
82+
/// Example c) of sorted assets: (relay asset and para 1000 asset)
83+
/// 1st - Location { parents: 1, interior: Here}
84+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
85+
///
5886
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
5987
function transferAssetsToPara20(
6088
uint32 paraId,
@@ -69,6 +97,20 @@ interface XCM {
6997
/// @param paraId The para-id of the destination chain.
7098
/// @param beneficiary The actual account that will receive the tokens on paraId destination.
7199
/// @param assets The combination (array) of assets to send in Address format.
100+
/// Assets MUST be sorted, otherwise there may be discrepancies with the feeAssetItem.
101+
///
102+
/// Example a) of sorted assets (native asset and para 1000 asset):
103+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
104+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
105+
///
106+
/// Example b) of sorted assets: (native asset and relay asset)
107+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
108+
/// 2nd - Location { parents: 1, interior: Here}
109+
///
110+
/// Example c) of sorted assets: (relay asset and para 1000 asset)
111+
/// 1st - Location { parents: 1, interior: Here}
112+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
113+
///
72114
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
73115
function transferAssetsToPara32(
74116
uint32 paraId,
@@ -82,6 +124,20 @@ interface XCM {
82124
/// @custom:selector 6521cc2c
83125
/// @param beneficiary The actual account that will receive the tokens on the relay chain.
84126
/// @param assets The combination (array) of assets to send in Address format.
127+
/// Assets MUST be sorted, otherwise there may be discrepancies with the feeAssetItem.
128+
///
129+
/// Example a) of sorted assets (native asset and para 1000 asset):
130+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
131+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
132+
///
133+
/// Example b) of sorted assets: (native asset and relay asset)
134+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
135+
/// 2nd - Location { parents: 1, interior: Here}
136+
///
137+
/// Example c) of sorted assets: (relay asset and para 1000 asset)
138+
/// 1st - Location { parents: 1, interior: Here}
139+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
140+
///
85141
/// @param feeAssetItem The index of the asset that will be used to pay for fees.
86142
function transferAssetsToRelay(
87143
bytes32 beneficiary,
@@ -97,6 +153,20 @@ interface XCM {
97153
/// @custom:selector 8425d893
98154
/// @param dest The destination chain.
99155
/// @param assets The combination (array) of assets to send in Location format.
156+
/// Assets MUST be sorted, otherwise there may be discrepancies with the remoteFeesIdIndex.
157+
///
158+
/// Example a) of sorted assets (native asset and para 1000 asset):
159+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
160+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
161+
///
162+
/// Example b) of sorted assets: (native asset and relay asset)
163+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
164+
/// 2nd - Location { parents: 1, interior: Here}
165+
///
166+
/// Example c) of sorted assets: (relay asset and para 1000 asset)
167+
/// 1st - Location { parents: 1, interior: Here}
168+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
169+
///
100170
/// @param assetsTransferType The TransferType corresponding to assets being sent.
101171
/// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees.
102172
/// @param feesTransferType The TransferType corresponding to the asset used as fees.
@@ -115,6 +185,20 @@ interface XCM {
115185
/// @custom:selector fc19376c
116186
/// @param dest The destination chain.
117187
/// @param assets The combination (array) of assets to send in Location format.
188+
/// Assets MUST be sorted, otherwise there may be discrepancies with the remoteFeesIdIndex.
189+
///
190+
/// Example a) of sorted assets (native asset and para 1000 asset):
191+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
192+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
193+
///
194+
/// Example b) of sorted assets: (native asset and relay asset)
195+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
196+
/// 2nd - Location { parents: 1, interior: Here}
197+
///
198+
/// Example c) of sorted assets: (relay asset and para 1000 asset)
199+
/// 1st - Location { parents: 1, interior: Here}
200+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
201+
///
118202
/// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees.
119203
/// @param customXcmOnDest The XCM message to execute on destination chain (SCALE encoded).
120204
/// @param remoteReserve The remote reserve corresponding for assets and fees. They MUST
@@ -135,6 +219,20 @@ interface XCM {
135219
/// @custom:selector 998093ee
136220
/// @param dest The destination chain.
137221
/// @param assets The combination (array) of assets to send in Address format.
222+
/// Assets MUST be sorted, otherwise there may be discrepancies with the remoteFeesIdIndex.
223+
///
224+
/// Example a) of sorted assets (native asset and para 1000 asset):
225+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
226+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
227+
///
228+
/// Example b) of sorted assets: (native asset and relay asset)
229+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
230+
/// 2nd - Location { parents: 1, interior: Here}
231+
///
232+
/// Example c) of sorted assets: (relay asset and para 1000 asset)
233+
/// 1st - Location { parents: 1, interior: Here}
234+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
235+
///
138236
/// @param assetsTransferType The TransferType corresponding to assets being sent.
139237
/// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees.
140238
/// @param feesTransferType The TransferType corresponding to the asset used as fees.
@@ -153,6 +251,20 @@ interface XCM {
153251
/// @custom:selector aaecfc62
154252
/// @param dest The destination chain.
155253
/// @param assets The combination (array) of assets to send in Address format.
254+
/// Assets MUST be sorted, otherwise there may be discrepancies with the remoteFeesIdIndex.
255+
///
256+
/// Example a) of sorted assets (native asset and para 1000 asset):
257+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
258+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
259+
///
260+
/// Example b) of sorted assets: (native asset and relay asset)
261+
/// 1st - Location { parents: 0, interior: [PalletInstance(3)]}
262+
/// 2nd - Location { parents: 1, interior: Here}
263+
///
264+
/// Example c) of sorted assets: (relay asset and para 1000 asset)
265+
/// 1st - Location { parents: 1, interior: Here}
266+
/// 2nd - Location { parents: 1, interior: [Parachain(1000), PalletInstance(3)]}
267+
///
156268
/// @param remoteFeesIdIndex The index of the asset (inside assets array) to use as fees.
157269
/// @param customXcmOnDest The XCM message to execute on destination chain (SCALE encoded).
158270
/// @param remoteReserve The remote reserve corresponding for assets and fees. They MUST

0 commit comments

Comments
 (0)