solidity-scale-codec 0.3.4 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +37 -3
  2. package/README.md +10 -28
  3. package/package.json +2 -2
  4. package/src/Utils/BytesUtils.sol +26 -0
  5. package/src/Utils/UnsignedUtils.sol +52 -0
  6. package/src/Xcm/VersionedXcm/VersionedXcm.sol +4 -1
  7. package/src/Xcm/VersionedXcm/VersionedXcmCodec.sol +11 -0
  8. package/src/Xcm/v3/MaybeErrorCode/MaybeErrorCode.sol +8 -7
  9. package/src/Xcm/v3/MaybeErrorCode/MaybeErrorCodeCodec.sol +18 -19
  10. package/src/Xcm/v5/AssetFilter/AssetFilter.sol +8 -8
  11. package/src/Xcm/v5/AssetFilter/AssetFilterCodec.sol +47 -34
  12. package/src/Xcm/v5/AssetInstance/AssetInstance.sol +13 -12
  13. package/src/Xcm/v5/AssetInstance/AssetInstanceCodec.sol +53 -56
  14. package/src/Xcm/v5/AssetTransferFilter/AssetTransferFilter.sol +12 -12
  15. package/src/Xcm/v5/AssetTransferFilter/AssetTransferFilterCodec.sol +48 -20
  16. package/src/Xcm/v5/Assets/Assets.sol +16 -0
  17. package/src/Xcm/v5/Assets/AssetsCodec.sol +3 -3
  18. package/src/Xcm/v5/BodyId/BodyId.sol +24 -24
  19. package/src/Xcm/v5/BodyId/BodyIdCodec.sol +41 -48
  20. package/src/Xcm/v5/BodyPart/BodyPart.sol +44 -28
  21. package/src/Xcm/v5/BodyPart/BodyPartCodec.sol +70 -37
  22. package/src/Xcm/v5/Constants.sol +2 -2
  23. package/src/Xcm/v5/Fungibility/Fungibility.sol +6 -6
  24. package/src/Xcm/v5/Fungibility/FungibilityCodec.sol +40 -36
  25. package/src/Xcm/v5/Hint/Hint.sol +5 -5
  26. package/src/Xcm/v5/Hint/HintCodec.sol +24 -20
  27. package/src/Xcm/v5/Instruction/Instruction.sol +81 -55
  28. package/src/Xcm/v5/Instruction/InstructionCodec.sol +1047 -73
  29. package/src/Xcm/v5/Junction/Junction.sol +55 -69
  30. package/src/Xcm/v5/Junction/JunctionCodec.sol +72 -135
  31. package/src/Xcm/v5/Junctions/Junctions.sol +34 -0
  32. package/src/Xcm/v5/Junctions/JunctionsCodec.sol +0 -18
  33. package/src/Xcm/v5/Location/Location.sol +8 -0
  34. package/src/Xcm/v5/NetworkId/NetworkId.sol +15 -16
  35. package/src/Xcm/v5/NetworkId/NetworkIdCodec.sol +57 -34
  36. package/src/Xcm/v5/OriginKind/OriginKindCodec.sol +1 -1
  37. package/src/Xcm/v5/Response/Response.sol +49 -40
  38. package/src/Xcm/v5/Response/ResponseCodec.sol +64 -54
  39. package/src/Xcm/v5/Weight/WeightCodec.sol +3 -2
  40. package/src/Xcm/v5/WeightLimit/WeightLimit.sol +6 -6
  41. package/src/Xcm/v5/WeightLimit/WeightLimitCodec.sol +32 -23
  42. package/src/Xcm/v5/WildAsset/WildAsset.sol +17 -25
  43. package/src/Xcm/v5/WildAsset/WildAssetCodec.sol +35 -38
  44. package/src/Xcm/v5/WildFungibility/WildFungibilityCodec.sol +6 -6
  45. package/src/Xcm/v5/Xcm/XcmBuilder.sol +689 -0
  46. package/src/Xcm/v5/XcmError/XcmError.sol +7 -7
  47. package/src/Xcm/v5/XcmError/XcmErrorCodec.sol +25 -22
@@ -0,0 +1,689 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.28;
3
+
4
+ import {
5
+ aliasOrigin as _aliasOrigin,
6
+ burnAsset as _burnAsset,
7
+ buyExecution as _buyExecution,
8
+ claimAsset as _claimAsset,
9
+ clearError as _clearError,
10
+ clearOrigin as _clearOrigin,
11
+ clearTopic as _clearTopic,
12
+ clearTransactStatus as _clearTransactStatus,
13
+ depositAsset as _depositAsset,
14
+ depositReserveAsset as _depositReserveAsset,
15
+ descendOrigin as _descendOrigin,
16
+ executeWithOrigin as _executeWithOrigin,
17
+ expectAsset as _expectAsset,
18
+ expectError as _expectError,
19
+ expectOrigin as _expectOrigin,
20
+ expectPallet as _expectPallet,
21
+ expectTransactStatus as _expectTransactStatus,
22
+ exchangeAsset as _exchangeAsset,
23
+ exportMessage as _exportMessage,
24
+ hrmpChannelAccepted as _hrmpChannelAccepted,
25
+ hrmpChannelClosing as _hrmpChannelClosing,
26
+ hrmpNewChannelOpenRequest as _hrmpNewChannelOpenRequest,
27
+ initiateReserveWithdraw as _initiateReserveWithdraw,
28
+ initiateTeleport as _initiateTeleport,
29
+ initiateTransfer as _initiateTransfer,
30
+ lockAsset as _lockAsset,
31
+ noteUnlockable as _noteUnlockable,
32
+ payFees as _payFees,
33
+ queryPallet as _queryPallet,
34
+ queryResponse as _queryResponse,
35
+ receiveTeleportedAsset as _receiveTeleportedAsset,
36
+ refundSurplus as _refundSurplus,
37
+ reportError as _reportError,
38
+ reportHolding as _reportHolding,
39
+ reportTransactStatus as _reportTransactStatus,
40
+ requestUnlock as _requestUnlock,
41
+ reserveAssetDeposited as _reserveAssetDeposited,
42
+ setAppendix as _setAppendix,
43
+ setErrorHandler as _setErrorHandler,
44
+ setFeesMode as _setFeesMode,
45
+ setHints as _setHints,
46
+ setTopic as _setTopic,
47
+ subscribeVersion as _subscribeVersion,
48
+ transact as _transact,
49
+ transferAsset as _transferAsset,
50
+ transferReserveAsset as _transferReserveAsset,
51
+ trap as _trap,
52
+ universalOrigin as _universalOrigin,
53
+ unpaidExecution as _unpaidExecution,
54
+ unlockAsset as _unlockAsset,
55
+ unsubscribeVersion as _unsubscribeVersion,
56
+ withdrawAsset as _withdrawAsset,
57
+ AliasOriginParams,
58
+ BurnAssetParams,
59
+ BuyExecutionParams,
60
+ ClaimAssetParams,
61
+ DepositAssetParams,
62
+ DepositReserveAssetParams,
63
+ DescendOriginParams,
64
+ ExecuteWithOriginParams,
65
+ ExpectAssetParams,
66
+ ExpectErrorParams,
67
+ ExpectOriginParams,
68
+ ExpectPalletParams,
69
+ ExpectTransactStatusParams,
70
+ ExchangeAssetParams,
71
+ ExportMessageParams,
72
+ HrmpChannelAcceptedParams,
73
+ HrmpChannelClosingParams,
74
+ HrmpNewChannelOpenRequestParams,
75
+ InitiateReserveWithdrawParams,
76
+ InitiateTeleportParams,
77
+ InitiateTransferParams,
78
+ Instruction,
79
+ LockAssetParams,
80
+ NoteUnlockableParams,
81
+ PayFeesParams,
82
+ QueryPalletParams,
83
+ QueryResponseParams,
84
+ ReceiveTeleportedAssetParams,
85
+ ReportErrorParams,
86
+ ReportHoldingParams,
87
+ ReportTransactStatusParams,
88
+ RequestUnlockParams,
89
+ ReserveAssetDepositedParams,
90
+ SetAppendixParams,
91
+ SetErrorHandlerParams,
92
+ SetFeesModeParams,
93
+ SetHintsParams,
94
+ SetTopicParams,
95
+ SubscribeVersionParams,
96
+ TransactParams,
97
+ TransferAssetParams,
98
+ TransferReserveAssetParams,
99
+ TrapParams,
100
+ UniversalOriginParams,
101
+ UnpaidExecutionParams,
102
+ UnlockAssetParams,
103
+ WithdrawAssetParams
104
+ } from "../Instruction/Instruction.sol";
105
+ import {Xcm, fromInstructions, newXcm} from "./Xcm.sol";
106
+
107
+ library XcmBuilder {
108
+ /// @notice Creates a new empty XCM program.
109
+ /// @return An `Xcm` instance with no instructions.
110
+ function create() internal pure returns (Xcm memory) {
111
+ return newXcm();
112
+ }
113
+
114
+ /// @notice Creates an XCM program from an instruction array.
115
+ /// @param instructions Ordered instructions to include in the program.
116
+ /// @return An `Xcm` instance containing `instructions`.
117
+ function from(
118
+ Instruction[] memory instructions
119
+ ) internal pure returns (Xcm memory) {
120
+ return fromInstructions(instructions);
121
+ }
122
+
123
+ /// @notice Appends a `WithdrawAsset` instruction to an XCM program.
124
+ /// @param xcm The program to extend.
125
+ /// @param params The instruction parameters.
126
+ /// @return A new program with the instruction appended.
127
+ function withdrawAsset(
128
+ Xcm memory xcm,
129
+ WithdrawAssetParams memory params
130
+ ) internal pure returns (Xcm memory) {
131
+ return _append(xcm, _withdrawAsset(params));
132
+ }
133
+
134
+ /// @notice Appends a `ReserveAssetDeposited` instruction to an XCM program.
135
+ /// @param xcm The program to extend.
136
+ /// @param params The instruction parameters.
137
+ /// @return A new program with the instruction appended.
138
+ function reserveAssetDeposited(
139
+ Xcm memory xcm,
140
+ ReserveAssetDepositedParams memory params
141
+ ) internal pure returns (Xcm memory) {
142
+ return _append(xcm, _reserveAssetDeposited(params));
143
+ }
144
+
145
+ /// @notice Appends a `ReceiveTeleportedAsset` instruction to an XCM program.
146
+ /// @param xcm The program to extend.
147
+ /// @param params The instruction parameters.
148
+ /// @return A new program with the instruction appended.
149
+ function receiveTeleportedAsset(
150
+ Xcm memory xcm,
151
+ ReceiveTeleportedAssetParams memory params
152
+ ) internal pure returns (Xcm memory) {
153
+ return _append(xcm, _receiveTeleportedAsset(params));
154
+ }
155
+
156
+ /// @notice Appends a `QueryResponse` instruction to an XCM program.
157
+ /// @param xcm The program to extend.
158
+ /// @param params The instruction parameters.
159
+ /// @return A new program with the instruction appended.
160
+ function queryResponse(
161
+ Xcm memory xcm,
162
+ QueryResponseParams memory params
163
+ ) internal pure returns (Xcm memory) {
164
+ return _append(xcm, _queryResponse(params));
165
+ }
166
+
167
+ /// @notice Appends a `TransferAsset` instruction to an XCM program.
168
+ /// @param xcm The program to extend.
169
+ /// @param params The instruction parameters.
170
+ /// @return A new program with the instruction appended.
171
+ function transferAsset(
172
+ Xcm memory xcm,
173
+ TransferAssetParams memory params
174
+ ) internal pure returns (Xcm memory) {
175
+ return _append(xcm, _transferAsset(params));
176
+ }
177
+
178
+ /// @notice Appends a `TransferReserveAsset` instruction to an XCM program.
179
+ /// @param xcm The program to extend.
180
+ /// @param params The instruction parameters.
181
+ /// @return A new program with the instruction appended.
182
+ function transferReserveAsset(
183
+ Xcm memory xcm,
184
+ TransferReserveAssetParams memory params
185
+ ) internal pure returns (Xcm memory) {
186
+ return _append(xcm, _transferReserveAsset(params));
187
+ }
188
+
189
+ /// @notice Appends a `Transact` instruction to an XCM program.
190
+ /// @param xcm The program to extend.
191
+ /// @param params The instruction parameters.
192
+ /// @return A new program with the instruction appended.
193
+ function transact(
194
+ Xcm memory xcm,
195
+ TransactParams memory params
196
+ ) internal pure returns (Xcm memory) {
197
+ return _append(xcm, _transact(params));
198
+ }
199
+
200
+ /// @notice Appends a `HrmpNewChannelOpenRequest` instruction to an XCM program.
201
+ /// @param xcm The program to extend.
202
+ /// @param params The instruction parameters.
203
+ /// @return A new program with the instruction appended.
204
+ function hrmpNewChannelOpenRequest(
205
+ Xcm memory xcm,
206
+ HrmpNewChannelOpenRequestParams memory params
207
+ ) internal pure returns (Xcm memory) {
208
+ return _append(xcm, _hrmpNewChannelOpenRequest(params));
209
+ }
210
+
211
+ /// @notice Appends a `HrmpChannelAccepted` instruction to an XCM program.
212
+ /// @param xcm The program to extend.
213
+ /// @param params The instruction parameters.
214
+ /// @return A new program with the instruction appended.
215
+ function hrmpChannelAccepted(
216
+ Xcm memory xcm,
217
+ HrmpChannelAcceptedParams memory params
218
+ ) internal pure returns (Xcm memory) {
219
+ return _append(xcm, _hrmpChannelAccepted(params));
220
+ }
221
+
222
+ /// @notice Appends a `HrmpChannelClosing` instruction to an XCM program.
223
+ /// @param xcm The program to extend.
224
+ /// @param params The instruction parameters.
225
+ /// @return A new program with the instruction appended.
226
+ function hrmpChannelClosing(
227
+ Xcm memory xcm,
228
+ HrmpChannelClosingParams memory params
229
+ ) internal pure returns (Xcm memory) {
230
+ return _append(xcm, _hrmpChannelClosing(params));
231
+ }
232
+
233
+ /// @notice Appends a `ClearOrigin` instruction to an XCM program.
234
+ /// @param xcm The program to extend.
235
+ /// @return A new program with the instruction appended.
236
+ function clearOrigin(Xcm memory xcm) internal pure returns (Xcm memory) {
237
+ return _append(xcm, _clearOrigin());
238
+ }
239
+
240
+ /// @notice Appends a `DescendOrigin` instruction to an XCM program.
241
+ /// @param xcm The program to extend.
242
+ /// @param params The instruction parameters.
243
+ /// @return A new program with the instruction appended.
244
+ function descendOrigin(
245
+ Xcm memory xcm,
246
+ DescendOriginParams memory params
247
+ ) internal pure returns (Xcm memory) {
248
+ return _append(xcm, _descendOrigin(params));
249
+ }
250
+
251
+ /// @notice Appends a `ReportError` instruction to an XCM program.
252
+ /// @param xcm The program to extend.
253
+ /// @param params The instruction parameters.
254
+ /// @return A new program with the instruction appended.
255
+ function reportError(
256
+ Xcm memory xcm,
257
+ ReportErrorParams memory params
258
+ ) internal pure returns (Xcm memory) {
259
+ return _append(xcm, _reportError(params));
260
+ }
261
+
262
+ /// @notice Appends a `DepositAsset` instruction to an XCM program.
263
+ /// @param xcm The program to extend.
264
+ /// @param params The instruction parameters.
265
+ /// @return A new program with the instruction appended.
266
+ function depositAsset(
267
+ Xcm memory xcm,
268
+ DepositAssetParams memory params
269
+ ) internal pure returns (Xcm memory) {
270
+ return _append(xcm, _depositAsset(params));
271
+ }
272
+
273
+ /// @notice Appends a `DepositReserveAsset` instruction to an XCM program.
274
+ /// @param xcm The program to extend.
275
+ /// @param params The instruction parameters.
276
+ /// @return A new program with the instruction appended.
277
+ function depositReserveAsset(
278
+ Xcm memory xcm,
279
+ DepositReserveAssetParams memory params
280
+ ) internal pure returns (Xcm memory) {
281
+ return _append(xcm, _depositReserveAsset(params));
282
+ }
283
+
284
+ /// @notice Appends an `ExchangeAsset` instruction to an XCM program.
285
+ /// @param xcm The program to extend.
286
+ /// @param params The instruction parameters.
287
+ /// @return A new program with the instruction appended.
288
+ function exchangeAsset(
289
+ Xcm memory xcm,
290
+ ExchangeAssetParams memory params
291
+ ) internal pure returns (Xcm memory) {
292
+ return _append(xcm, _exchangeAsset(params));
293
+ }
294
+
295
+ /// @notice Appends an `InitiateReserveWithdraw` instruction to an XCM program.
296
+ /// @param xcm The program to extend.
297
+ /// @param params The instruction parameters.
298
+ /// @return A new program with the instruction appended.
299
+ function initiateReserveWithdraw(
300
+ Xcm memory xcm,
301
+ InitiateReserveWithdrawParams memory params
302
+ ) internal pure returns (Xcm memory) {
303
+ return _append(xcm, _initiateReserveWithdraw(params));
304
+ }
305
+
306
+ /// @notice Appends an `InitiateTeleport` instruction to an XCM program.
307
+ /// @param xcm The program to extend.
308
+ /// @param params The instruction parameters.
309
+ /// @return A new program with the instruction appended.
310
+ function initiateTeleport(
311
+ Xcm memory xcm,
312
+ InitiateTeleportParams memory params
313
+ ) internal pure returns (Xcm memory) {
314
+ return _append(xcm, _initiateTeleport(params));
315
+ }
316
+
317
+ /// @notice Appends a `ReportHolding` instruction to an XCM program.
318
+ /// @param xcm The program to extend.
319
+ /// @param params The instruction parameters.
320
+ /// @return A new program with the instruction appended.
321
+ function reportHolding(
322
+ Xcm memory xcm,
323
+ ReportHoldingParams memory params
324
+ ) internal pure returns (Xcm memory) {
325
+ return _append(xcm, _reportHolding(params));
326
+ }
327
+
328
+ /// @notice Appends a `BuyExecution` instruction to an XCM program.
329
+ /// @param xcm The program to extend.
330
+ /// @param params The instruction parameters.
331
+ /// @return A new program with the instruction appended.
332
+ function buyExecution(
333
+ Xcm memory xcm,
334
+ BuyExecutionParams memory params
335
+ ) internal pure returns (Xcm memory) {
336
+ return _append(xcm, _buyExecution(params));
337
+ }
338
+
339
+ /// @notice Appends a `RefundSurplus` instruction to an XCM program.
340
+ /// @param xcm The program to extend.
341
+ /// @return A new program with the instruction appended.
342
+ function refundSurplus(Xcm memory xcm) internal pure returns (Xcm memory) {
343
+ return _append(xcm, _refundSurplus());
344
+ }
345
+
346
+ /// @notice Appends a `SetErrorHandler` instruction to an XCM program.
347
+ /// @param xcm The program to extend.
348
+ /// @param params The instruction parameters.
349
+ /// @return A new program with the instruction appended.
350
+ function setErrorHandler(
351
+ Xcm memory xcm,
352
+ SetErrorHandlerParams memory params
353
+ ) internal pure returns (Xcm memory) {
354
+ return _append(xcm, _setErrorHandler(params));
355
+ }
356
+
357
+ /// @notice Appends a `SetAppendix` instruction to an XCM program.
358
+ /// @param xcm The program to extend.
359
+ /// @param params The instruction parameters.
360
+ /// @return A new program with the instruction appended.
361
+ function setAppendix(
362
+ Xcm memory xcm,
363
+ SetAppendixParams memory params
364
+ ) internal pure returns (Xcm memory) {
365
+ return _append(xcm, _setAppendix(params));
366
+ }
367
+
368
+ /// @notice Appends a `ClearError` instruction to an XCM program.
369
+ /// @param xcm The program to extend.
370
+ /// @return A new program with the instruction appended.
371
+ function clearError(Xcm memory xcm) internal pure returns (Xcm memory) {
372
+ return _append(xcm, _clearError());
373
+ }
374
+
375
+ /// @notice Appends a `ClaimAsset` instruction to an XCM program.
376
+ /// @param xcm The program to extend.
377
+ /// @param params The instruction parameters.
378
+ /// @return A new program with the instruction appended.
379
+ function claimAsset(
380
+ Xcm memory xcm,
381
+ ClaimAssetParams memory params
382
+ ) internal pure returns (Xcm memory) {
383
+ return _append(xcm, _claimAsset(params));
384
+ }
385
+
386
+ /// @notice Appends a `Trap` instruction to an XCM program.
387
+ /// @param xcm The program to extend.
388
+ /// @param params The instruction parameters.
389
+ /// @return A new program with the instruction appended.
390
+ function trap(
391
+ Xcm memory xcm,
392
+ TrapParams memory params
393
+ ) internal pure returns (Xcm memory) {
394
+ return _append(xcm, _trap(params));
395
+ }
396
+
397
+ /// @notice Appends a `SubscribeVersion` instruction to an XCM program.
398
+ /// @param xcm The program to extend.
399
+ /// @param params The instruction parameters.
400
+ /// @return A new program with the instruction appended.
401
+ function subscribeVersion(
402
+ Xcm memory xcm,
403
+ SubscribeVersionParams memory params
404
+ ) internal pure returns (Xcm memory) {
405
+ return _append(xcm, _subscribeVersion(params));
406
+ }
407
+
408
+ /// @notice Appends an `UnsubscribeVersion` instruction to an XCM program.
409
+ /// @param xcm The program to extend.
410
+ /// @return A new program with the instruction appended.
411
+ function unsubscribeVersion(
412
+ Xcm memory xcm
413
+ ) internal pure returns (Xcm memory) {
414
+ return _append(xcm, _unsubscribeVersion());
415
+ }
416
+
417
+ /// @notice Appends a `BurnAsset` instruction to an XCM program.
418
+ /// @param xcm The program to extend.
419
+ /// @param params The instruction parameters.
420
+ /// @return A new program with the instruction appended.
421
+ function burnAsset(
422
+ Xcm memory xcm,
423
+ BurnAssetParams memory params
424
+ ) internal pure returns (Xcm memory) {
425
+ return _append(xcm, _burnAsset(params));
426
+ }
427
+
428
+ /// @notice Appends an `ExpectAsset` instruction to an XCM program.
429
+ /// @param xcm The program to extend.
430
+ /// @param params The instruction parameters.
431
+ /// @return A new program with the instruction appended.
432
+ function expectAsset(
433
+ Xcm memory xcm,
434
+ ExpectAssetParams memory params
435
+ ) internal pure returns (Xcm memory) {
436
+ return _append(xcm, _expectAsset(params));
437
+ }
438
+
439
+ /// @notice Appends an `ExpectOrigin` instruction to an XCM program.
440
+ /// @param xcm The program to extend.
441
+ /// @param params The instruction parameters.
442
+ /// @return A new program with the instruction appended.
443
+ function expectOrigin(
444
+ Xcm memory xcm,
445
+ ExpectOriginParams memory params
446
+ ) internal pure returns (Xcm memory) {
447
+ return _append(xcm, _expectOrigin(params));
448
+ }
449
+
450
+ /// @notice Appends an `ExpectError` instruction to an XCM program.
451
+ /// @param xcm The program to extend.
452
+ /// @param params The instruction parameters.
453
+ /// @return A new program with the instruction appended.
454
+ function expectError(
455
+ Xcm memory xcm,
456
+ ExpectErrorParams memory params
457
+ ) internal pure returns (Xcm memory) {
458
+ return _append(xcm, _expectError(params));
459
+ }
460
+
461
+ /// @notice Appends an `ExpectTransactStatus` instruction to an XCM program.
462
+ /// @param xcm The program to extend.
463
+ /// @param params The instruction parameters.
464
+ /// @return A new program with the instruction appended.
465
+ function expectTransactStatus(
466
+ Xcm memory xcm,
467
+ ExpectTransactStatusParams memory params
468
+ ) internal pure returns (Xcm memory) {
469
+ return _append(xcm, _expectTransactStatus(params));
470
+ }
471
+
472
+ /// @notice Appends a `QueryPallet` instruction to an XCM program.
473
+ /// @param xcm The program to extend.
474
+ /// @param params The instruction parameters.
475
+ /// @return A new program with the instruction appended.
476
+ function queryPallet(
477
+ Xcm memory xcm,
478
+ QueryPalletParams memory params
479
+ ) internal pure returns (Xcm memory) {
480
+ return _append(xcm, _queryPallet(params));
481
+ }
482
+
483
+ /// @notice Appends an `ExpectPallet` instruction to an XCM program.
484
+ /// @param xcm The program to extend.
485
+ /// @param params The instruction parameters.
486
+ /// @return A new program with the instruction appended.
487
+ function expectPallet(
488
+ Xcm memory xcm,
489
+ ExpectPalletParams memory params
490
+ ) internal pure returns (Xcm memory) {
491
+ return _append(xcm, _expectPallet(params));
492
+ }
493
+
494
+ /// @notice Appends a `ReportTransactStatus` instruction to an XCM program.
495
+ /// @param xcm The program to extend.
496
+ /// @param params The instruction parameters.
497
+ /// @return A new program with the instruction appended.
498
+ function reportTransactStatus(
499
+ Xcm memory xcm,
500
+ ReportTransactStatusParams memory params
501
+ ) internal pure returns (Xcm memory) {
502
+ return _append(xcm, _reportTransactStatus(params));
503
+ }
504
+
505
+ /// @notice Appends a `ClearTransactStatus` instruction to an XCM program.
506
+ /// @param xcm The program to extend.
507
+ /// @return A new program with the instruction appended.
508
+ function clearTransactStatus(
509
+ Xcm memory xcm
510
+ ) internal pure returns (Xcm memory) {
511
+ return _append(xcm, _clearTransactStatus());
512
+ }
513
+
514
+ /// @notice Appends a `UniversalOrigin` instruction to an XCM program.
515
+ /// @param xcm The program to extend.
516
+ /// @param params The instruction parameters.
517
+ /// @return A new program with the instruction appended.
518
+ function universalOrigin(
519
+ Xcm memory xcm,
520
+ UniversalOriginParams memory params
521
+ ) internal pure returns (Xcm memory) {
522
+ return _append(xcm, _universalOrigin(params));
523
+ }
524
+
525
+ /// @notice Appends an `ExportMessage` instruction to an XCM program.
526
+ /// @param xcm The program to extend.
527
+ /// @param params The instruction parameters.
528
+ /// @return A new program with the instruction appended.
529
+ function exportMessage(
530
+ Xcm memory xcm,
531
+ ExportMessageParams memory params
532
+ ) internal pure returns (Xcm memory) {
533
+ return _append(xcm, _exportMessage(params));
534
+ }
535
+
536
+ /// @notice Appends a `LockAsset` instruction to an XCM program.
537
+ /// @param xcm The program to extend.
538
+ /// @param params The instruction parameters.
539
+ /// @return A new program with the instruction appended.
540
+ function lockAsset(
541
+ Xcm memory xcm,
542
+ LockAssetParams memory params
543
+ ) internal pure returns (Xcm memory) {
544
+ return _append(xcm, _lockAsset(params));
545
+ }
546
+
547
+ /// @notice Appends an `UnlockAsset` instruction to an XCM program.
548
+ /// @param xcm The program to extend.
549
+ /// @param params The instruction parameters.
550
+ /// @return A new program with the instruction appended.
551
+ function unlockAsset(
552
+ Xcm memory xcm,
553
+ UnlockAssetParams memory params
554
+ ) internal pure returns (Xcm memory) {
555
+ return _append(xcm, _unlockAsset(params));
556
+ }
557
+
558
+ /// @notice Appends a `NoteUnlockable` instruction to an XCM program.
559
+ /// @param xcm The program to extend.
560
+ /// @param params The instruction parameters.
561
+ /// @return A new program with the instruction appended.
562
+ function noteUnlockable(
563
+ Xcm memory xcm,
564
+ NoteUnlockableParams memory params
565
+ ) internal pure returns (Xcm memory) {
566
+ return _append(xcm, _noteUnlockable(params));
567
+ }
568
+
569
+ /// @notice Appends a `RequestUnlock` instruction to an XCM program.
570
+ /// @param xcm The program to extend.
571
+ /// @param params The instruction parameters.
572
+ /// @return A new program with the instruction appended.
573
+ function requestUnlock(
574
+ Xcm memory xcm,
575
+ RequestUnlockParams memory params
576
+ ) internal pure returns (Xcm memory) {
577
+ return _append(xcm, _requestUnlock(params));
578
+ }
579
+
580
+ /// @notice Appends a `SetFeesMode` instruction to an XCM program.
581
+ /// @param xcm The program to extend.
582
+ /// @param params The instruction parameters.
583
+ /// @return A new program with the instruction appended.
584
+ function setFeesMode(
585
+ Xcm memory xcm,
586
+ SetFeesModeParams memory params
587
+ ) internal pure returns (Xcm memory) {
588
+ return _append(xcm, _setFeesMode(params));
589
+ }
590
+
591
+ /// @notice Appends a `SetTopic` instruction to an XCM program.
592
+ /// @param xcm The program to extend.
593
+ /// @param params The instruction parameters.
594
+ /// @return A new program with the instruction appended.
595
+ function setTopic(
596
+ Xcm memory xcm,
597
+ SetTopicParams memory params
598
+ ) internal pure returns (Xcm memory) {
599
+ return _append(xcm, _setTopic(params));
600
+ }
601
+
602
+ /// @notice Appends a `ClearTopic` instruction to an XCM program.
603
+ /// @param xcm The program to extend.
604
+ /// @return A new program with the instruction appended.
605
+ function clearTopic(Xcm memory xcm) internal pure returns (Xcm memory) {
606
+ return _append(xcm, _clearTopic());
607
+ }
608
+
609
+ /// @notice Appends an `AliasOrigin` instruction to an XCM program.
610
+ /// @param xcm The program to extend.
611
+ /// @param params The instruction parameters.
612
+ /// @return A new program with the instruction appended.
613
+ function aliasOrigin(
614
+ Xcm memory xcm,
615
+ AliasOriginParams memory params
616
+ ) internal pure returns (Xcm memory) {
617
+ return _append(xcm, _aliasOrigin(params));
618
+ }
619
+
620
+ /// @notice Appends an `UnpaidExecution` instruction to an XCM program.
621
+ /// @param xcm The program to extend.
622
+ /// @param params The instruction parameters.
623
+ /// @return A new program with the instruction appended.
624
+ function unpaidExecution(
625
+ Xcm memory xcm,
626
+ UnpaidExecutionParams memory params
627
+ ) internal pure returns (Xcm memory) {
628
+ return _append(xcm, _unpaidExecution(params));
629
+ }
630
+
631
+ /// @notice Appends a `PayFees` instruction to an XCM program.
632
+ /// @param xcm The program to extend.
633
+ /// @param params The instruction parameters.
634
+ /// @return A new program with the instruction appended.
635
+ function payFees(
636
+ Xcm memory xcm,
637
+ PayFeesParams memory params
638
+ ) internal pure returns (Xcm memory) {
639
+ return _append(xcm, _payFees(params));
640
+ }
641
+
642
+ /// @notice Appends an `InitiateTransfer` instruction to an XCM program.
643
+ /// @param xcm The program to extend.
644
+ /// @param params The instruction parameters.
645
+ /// @return A new program with the instruction appended.
646
+ function initiateTransfer(
647
+ Xcm memory xcm,
648
+ InitiateTransferParams memory params
649
+ ) internal pure returns (Xcm memory) {
650
+ return _append(xcm, _initiateTransfer(params));
651
+ }
652
+
653
+ /// @notice Appends an `ExecuteWithOrigin` instruction to an XCM program.
654
+ /// @param xcm The program to extend.
655
+ /// @param params The instruction parameters.
656
+ /// @return A new program with the instruction appended.
657
+ function executeWithOrigin(
658
+ Xcm memory xcm,
659
+ ExecuteWithOriginParams memory params
660
+ ) internal pure returns (Xcm memory) {
661
+ return _append(xcm, _executeWithOrigin(params));
662
+ }
663
+
664
+ /// @notice Appends a `SetHints` instruction to an XCM program.
665
+ /// @param xcm The program to extend.
666
+ /// @param params The instruction parameters.
667
+ /// @return A new program with the instruction appended.
668
+ function setHints(
669
+ Xcm memory xcm,
670
+ SetHintsParams memory params
671
+ ) internal pure returns (Xcm memory) {
672
+ return _append(xcm, _setHints(params));
673
+ }
674
+
675
+ function _append(
676
+ Xcm memory xcm,
677
+ Instruction memory instruction
678
+ ) private pure returns (Xcm memory) {
679
+ uint256 length = xcm.instructions.length;
680
+ Instruction[] memory instructions = new Instruction[](length + 1);
681
+
682
+ for (uint256 i = 0; i < length; i++) {
683
+ instructions[i] = xcm.instructions[i];
684
+ }
685
+
686
+ instructions[length] = instruction;
687
+ return fromInstructions(instructions);
688
+ }
689
+ }