solidity-scale-codec 0.3.4 → 1.0.0

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 (46) hide show
  1. package/CHANGELOG.md +31 -3
  2. package/package.json +1 -1
  3. package/src/Utils/BytesUtils.sol +26 -0
  4. package/src/Utils/UnsignedUtils.sol +52 -0
  5. package/src/Xcm/VersionedXcm/VersionedXcm.sol +4 -1
  6. package/src/Xcm/VersionedXcm/VersionedXcmCodec.sol +11 -0
  7. package/src/Xcm/v3/MaybeErrorCode/MaybeErrorCode.sol +8 -7
  8. package/src/Xcm/v3/MaybeErrorCode/MaybeErrorCodeCodec.sol +18 -19
  9. package/src/Xcm/v5/AssetFilter/AssetFilter.sol +8 -8
  10. package/src/Xcm/v5/AssetFilter/AssetFilterCodec.sol +47 -34
  11. package/src/Xcm/v5/AssetInstance/AssetInstance.sol +13 -12
  12. package/src/Xcm/v5/AssetInstance/AssetInstanceCodec.sol +53 -56
  13. package/src/Xcm/v5/AssetTransferFilter/AssetTransferFilter.sol +12 -12
  14. package/src/Xcm/v5/AssetTransferFilter/AssetTransferFilterCodec.sol +48 -20
  15. package/src/Xcm/v5/Assets/Assets.sol +16 -0
  16. package/src/Xcm/v5/Assets/AssetsCodec.sol +3 -3
  17. package/src/Xcm/v5/BodyId/BodyId.sol +24 -24
  18. package/src/Xcm/v5/BodyId/BodyIdCodec.sol +41 -48
  19. package/src/Xcm/v5/BodyPart/BodyPart.sol +44 -28
  20. package/src/Xcm/v5/BodyPart/BodyPartCodec.sol +70 -37
  21. package/src/Xcm/v5/Constants.sol +2 -2
  22. package/src/Xcm/v5/Fungibility/Fungibility.sol +6 -6
  23. package/src/Xcm/v5/Fungibility/FungibilityCodec.sol +40 -36
  24. package/src/Xcm/v5/Hint/Hint.sol +5 -5
  25. package/src/Xcm/v5/Hint/HintCodec.sol +24 -20
  26. package/src/Xcm/v5/Instruction/Instruction.sol +81 -55
  27. package/src/Xcm/v5/Instruction/InstructionCodec.sol +1047 -73
  28. package/src/Xcm/v5/Junction/Junction.sol +55 -69
  29. package/src/Xcm/v5/Junction/JunctionCodec.sol +72 -135
  30. package/src/Xcm/v5/Junctions/Junctions.sol +34 -0
  31. package/src/Xcm/v5/Junctions/JunctionsCodec.sol +0 -18
  32. package/src/Xcm/v5/Location/Location.sol +8 -0
  33. package/src/Xcm/v5/NetworkId/NetworkId.sol +15 -16
  34. package/src/Xcm/v5/NetworkId/NetworkIdCodec.sol +57 -34
  35. package/src/Xcm/v5/OriginKind/OriginKindCodec.sol +1 -1
  36. package/src/Xcm/v5/Response/Response.sol +49 -40
  37. package/src/Xcm/v5/Response/ResponseCodec.sol +64 -54
  38. package/src/Xcm/v5/Weight/WeightCodec.sol +3 -2
  39. package/src/Xcm/v5/WeightLimit/WeightLimit.sol +6 -6
  40. package/src/Xcm/v5/WeightLimit/WeightLimitCodec.sol +32 -23
  41. package/src/Xcm/v5/WildAsset/WildAsset.sol +17 -25
  42. package/src/Xcm/v5/WildAsset/WildAssetCodec.sol +35 -38
  43. package/src/Xcm/v5/WildFungibility/WildFungibilityCodec.sol +6 -6
  44. package/src/Xcm/v5/Xcm/XcmBuilder.sol +689 -0
  45. package/src/Xcm/v5/XcmError/XcmError.sol +7 -7
  46. package/src/Xcm/v5/XcmError/XcmErrorCodec.sol +25 -22
@@ -5,16 +5,16 @@ import {Location} from "../Location/Location.sol";
5
5
  import {LocationCodec} from "../Location/LocationCodec.sol";
6
6
 
7
7
  /// @notice Discriminant for the `Hint` enum.
8
- enum HintType {
8
+ enum HintVariant {
9
9
  /// @custom:variant Set asset claimer for all the trapped assets during the execution.
10
10
  AssetClaimer
11
11
  }
12
12
 
13
13
  /// @notice A hint for XCM execution, changing the behaviour of the XCM program.
14
14
  struct Hint {
15
- /// @custom:property The type of the hint. See `HintType` enum for possible values.
16
- HintType hType;
17
- /// @custom:property The SCALE-encoded payload of the hint. Structure depends on `hType`.
15
+ /// @custom:property The type of the hint. See `HintVariant` enum for possible values.
16
+ HintVariant variant;
17
+ /// @custom:property The SCALE-encoded payload of the hint. Structure depends on `variant`.
18
18
  bytes payload;
19
19
  }
20
20
 
@@ -34,7 +34,7 @@ function assetClaimer(
34
34
  ) pure returns (Hint memory) {
35
35
  return
36
36
  Hint({
37
- hType: HintType.AssetClaimer,
37
+ variant: HintVariant.AssetClaimer,
38
38
  payload: LocationCodec.encode(params.location)
39
39
  });
40
40
  }
@@ -3,7 +3,8 @@ pragma solidity ^0.8.28;
3
3
 
4
4
  import {Location} from "../Location/Location.sol";
5
5
  import {LocationCodec} from "../Location/LocationCodec.sol";
6
- import {Hint, HintType} from "./Hint.sol";
6
+ import {Hint, HintVariant, AssetClaimerParams} from "./Hint.sol";
7
+ import {BytesUtils} from "../../../Utils/BytesUtils.sol";
7
8
 
8
9
  /// @title SCALE Codec for XCM v5 `Hint`
9
10
  /// @notice SCALE-compliant encoder/decoder for the `Hint` type.
@@ -11,13 +12,13 @@ import {Hint, HintType} from "./Hint.sol";
11
12
  /// @dev XCM v5 reference: https://paritytech.github.io/polkadot-sdk/master/staging_xcm/v5/enum.Hint.html
12
13
  library HintCodec {
13
14
  error InvalidHintLength();
14
- error InvalidHintType(uint8 hType);
15
+ error InvalidHintVariant(uint8 variant);
15
16
 
16
17
  /// @notice Encodes a `Hint` struct into SCALE bytes.
17
18
  /// @param hint The `Hint` struct to encode.
18
19
  /// @return SCALE-encoded bytes representing the `Hint`.
19
20
  function encode(Hint memory hint) internal pure returns (bytes memory) {
20
- return abi.encodePacked(uint8(hint.hType), hint.payload);
21
+ return abi.encodePacked(uint8(hint.variant), hint.payload);
21
22
  }
22
23
 
23
24
  /// @notice Returns the number of bytes that a `Hint` would occupy when SCALE-encoded.
@@ -29,11 +30,12 @@ library HintCodec {
29
30
  uint256 offset
30
31
  ) internal pure returns (uint256) {
31
32
  if (data.length < offset + 1) revert InvalidHintLength();
32
- uint8 hType = uint8(data[offset]);
33
- if (hType == uint8(HintType.AssetClaimer)) {
33
+ uint8 variant = uint8(data[offset]);
34
+ if (variant == uint8(HintVariant.AssetClaimer)) {
34
35
  return 1 + LocationCodec.encodedSizeAt(data, offset + 1);
36
+ } else {
37
+ revert InvalidHintVariant(variant);
35
38
  }
36
- revert InvalidHintType(hType);
37
39
  }
38
40
 
39
41
  /// @notice Decodes a `Hint` from SCALE bytes starting at the beginning.
@@ -55,28 +57,30 @@ library HintCodec {
55
57
  bytes memory data,
56
58
  uint256 offset
57
59
  ) internal pure returns (Hint memory hint, uint256 bytesRead) {
58
- if (data.length < offset + 1) revert InvalidHintLength();
59
- uint8 hType = uint8(data[offset]);
60
- if (hType > uint8(HintType.AssetClaimer)) revert InvalidHintType(hType);
61
60
  uint256 size = encodedSizeAt(data, offset);
61
+ uint8 variant = uint8(data[offset]);
62
62
  uint256 payloadLength = size - 1;
63
- bytes memory payload = new bytes(payloadLength);
64
- for (uint256 i = 0; i < payloadLength; ++i) {
65
- payload[i] = data[offset + 1 + i];
66
- }
67
- hint = Hint({hType: HintType(hType), payload: payload});
63
+ bytes memory payload = BytesUtils.copy(data, offset + 1, payloadLength);
64
+ hint = Hint({variant: HintVariant(variant), payload: payload});
68
65
  bytesRead = size;
69
66
  }
70
67
 
71
68
  /// @notice Decodes the `Location` from an `AssetClaimer` hint.
72
69
  /// @param hint The `Hint` struct. Must be of type `AssetClaimer`.
73
- /// @return The claimer `Location`.
70
+ /// @return params An `AssetClaimerParams` struct containing the claimer location.
74
71
  function asAssetClaimer(
75
72
  Hint memory hint
76
- ) internal pure returns (Location memory) {
77
- if (hint.hType != HintType.AssetClaimer)
78
- revert InvalidHintType(uint8(hint.hType));
79
- (Location memory location, ) = LocationCodec.decode(hint.payload);
80
- return location;
73
+ ) internal pure returns (AssetClaimerParams memory params) {
74
+ _assertVariant(hint, HintVariant.AssetClaimer);
75
+ (params.location, ) = LocationCodec.decode(hint.payload);
76
+ }
77
+
78
+ function _assertVariant(
79
+ Hint memory hint,
80
+ HintVariant expected
81
+ ) internal pure {
82
+ if (hint.variant != expected) {
83
+ revert InvalidHintVariant(uint8(hint.variant));
84
+ }
81
85
  }
82
86
  }
@@ -48,7 +48,7 @@ import {Bytes} from "../../../Scale/Bytes/Bytes.sol";
48
48
  error InvalidInstruction();
49
49
 
50
50
  /// @notice Discriminant for the `Instruction` enum, representing the type of instruction being executed.
51
- enum InstructionType {
51
+ enum InstructionVariant {
52
52
  /// @custom:variant Withdraw asset(s) from the ownership of `origin` and place them into the Holding Register.
53
53
  WithdrawAsset,
54
54
  /// @custom:variant Asset(s) have been received into the ownership of this system on the `origin` system and equivalent derivatives should be placed into the Holding Register.
@@ -534,8 +534,8 @@ struct SetHintsParams {
534
534
  /// @notice Cross-Consensus Message: A message from one consensus system to another.
535
535
  /// @dev This is the inner XCM format and is version-sensitive. Messages are typically passed using the outer XCM format, known as `VersionedXcm`.
536
536
  struct Instruction {
537
- /// @custom:property The type of the instruction. See `InstructionType` enum for possible values.
538
- InstructionType iType;
537
+ /// @custom:property The type of the instruction. See `InstructionVariant` enum for possible values.
538
+ InstructionVariant variant;
539
539
  /// @custom:property SCALE-encoded instruction parameters. The type of the parameters depends on the instruction type; see the corresponding `Params` struct for each variant.
540
540
  bytes payload;
541
541
  }
@@ -548,7 +548,7 @@ function withdrawAsset(
548
548
  ) pure returns (Instruction memory) {
549
549
  return
550
550
  Instruction({
551
- iType: InstructionType.WithdrawAsset,
551
+ variant: InstructionVariant.WithdrawAsset,
552
552
  payload: AssetsCodec.encode(params.assets)
553
553
  });
554
554
  }
@@ -559,7 +559,7 @@ function reserveAssetDeposited(
559
559
  ) pure returns (Instruction memory) {
560
560
  return
561
561
  Instruction({
562
- iType: InstructionType.ReserveAssetDeposited,
562
+ variant: InstructionVariant.ReserveAssetDeposited,
563
563
  payload: AssetsCodec.encode(params.assets)
564
564
  });
565
565
  }
@@ -570,7 +570,7 @@ function receiveTeleportedAsset(
570
570
  ) pure returns (Instruction memory) {
571
571
  return
572
572
  Instruction({
573
- iType: InstructionType.ReceiveTeleportedAsset,
573
+ variant: InstructionVariant.ReceiveTeleportedAsset,
574
574
  payload: AssetsCodec.encode(params.assets)
575
575
  });
576
576
  }
@@ -592,7 +592,10 @@ function queryResponse(
592
592
  );
593
593
  }
594
594
  return
595
- Instruction({iType: InstructionType.QueryResponse, payload: payload});
595
+ Instruction({
596
+ variant: InstructionVariant.QueryResponse,
597
+ payload: payload
598
+ });
596
599
  }
597
600
 
598
601
  /// @notice Creates an `Instruction` struct representing the `TransferAsset` variant with the provided `params`.
@@ -601,7 +604,7 @@ function transferAsset(
601
604
  ) pure returns (Instruction memory) {
602
605
  return
603
606
  Instruction({
604
- iType: InstructionType.TransferAsset,
607
+ variant: InstructionVariant.TransferAsset,
605
608
  payload: abi.encodePacked(
606
609
  AssetsCodec.encode(params.assets),
607
610
  LocationCodec.encode(params.beneficiary)
@@ -615,7 +618,7 @@ function transferReserveAsset(
615
618
  ) pure returns (Instruction memory) {
616
619
  return
617
620
  Instruction({
618
- iType: InstructionType.TransferReserveAsset,
621
+ variant: InstructionVariant.TransferReserveAsset,
619
622
  payload: abi.encodePacked(
620
623
  AssetsCodec.encode(params.assets),
621
624
  LocationCodec.encode(params.dest),
@@ -639,7 +642,8 @@ function transact(
639
642
  );
640
643
  }
641
644
  payload = abi.encodePacked(payload, Bytes.encode(params.call));
642
- return Instruction({iType: InstructionType.Transact, payload: payload});
645
+ return
646
+ Instruction({variant: InstructionVariant.Transact, payload: payload});
643
647
  }
644
648
 
645
649
  /// @notice Creates an `Instruction` struct representing the `HrmpNewChannelOpenRequest` variant with the provided `params`.
@@ -648,7 +652,7 @@ function hrmpNewChannelOpenRequest(
648
652
  ) pure returns (Instruction memory) {
649
653
  return
650
654
  Instruction({
651
- iType: InstructionType.HrmpNewChannelOpenRequest,
655
+ variant: InstructionVariant.HrmpNewChannelOpenRequest,
652
656
  payload: abi.encodePacked(
653
657
  Compact.encode(params.sender),
654
658
  Compact.encode(params.maxMessageSize),
@@ -663,7 +667,7 @@ function hrmpChannelAccepted(
663
667
  ) pure returns (Instruction memory) {
664
668
  return
665
669
  Instruction({
666
- iType: InstructionType.HrmpChannelAccepted,
670
+ variant: InstructionVariant.HrmpChannelAccepted,
667
671
  payload: Compact.encode(params.recipient)
668
672
  });
669
673
  }
@@ -674,7 +678,7 @@ function hrmpChannelClosing(
674
678
  ) pure returns (Instruction memory) {
675
679
  return
676
680
  Instruction({
677
- iType: InstructionType.HrmpChannelClosing,
681
+ variant: InstructionVariant.HrmpChannelClosing,
678
682
  payload: abi.encodePacked(
679
683
  Compact.encode(params.initiator),
680
684
  Compact.encode(params.sender),
@@ -685,7 +689,7 @@ function hrmpChannelClosing(
685
689
 
686
690
  /// @notice Creates an `Instruction` struct representing the `ClearOrigin` variant.
687
691
  function clearOrigin() pure returns (Instruction memory) {
688
- return Instruction({iType: InstructionType.ClearOrigin, payload: ""});
692
+ return Instruction({variant: InstructionVariant.ClearOrigin, payload: ""});
689
693
  }
690
694
 
691
695
  /// @notice Creates an `Instruction` struct representing the `DescendOrigin` variant with the provided `params`.
@@ -694,7 +698,7 @@ function descendOrigin(
694
698
  ) pure returns (Instruction memory) {
695
699
  return
696
700
  Instruction({
697
- iType: InstructionType.DescendOrigin,
701
+ variant: InstructionVariant.DescendOrigin,
698
702
  payload: JunctionsCodec.encode(params.interior)
699
703
  });
700
704
  }
@@ -705,7 +709,7 @@ function reportError(
705
709
  ) pure returns (Instruction memory) {
706
710
  return
707
711
  Instruction({
708
- iType: InstructionType.ReportError,
712
+ variant: InstructionVariant.ReportError,
709
713
  payload: QueryResponseInfoCodec.encode(params.responseInfo)
710
714
  });
711
715
  }
@@ -716,7 +720,7 @@ function depositAsset(
716
720
  ) pure returns (Instruction memory) {
717
721
  return
718
722
  Instruction({
719
- iType: InstructionType.DepositAsset,
723
+ variant: InstructionVariant.DepositAsset,
720
724
  payload: abi.encodePacked(
721
725
  AssetFilterCodec.encode(params.assets),
722
726
  LocationCodec.encode(params.beneficiary)
@@ -730,7 +734,7 @@ function depositReserveAsset(
730
734
  ) pure returns (Instruction memory) {
731
735
  return
732
736
  Instruction({
733
- iType: InstructionType.DepositReserveAsset,
737
+ variant: InstructionVariant.DepositReserveAsset,
734
738
  payload: abi.encodePacked(
735
739
  AssetFilterCodec.encode(params.assets),
736
740
  LocationCodec.encode(params.dest),
@@ -745,7 +749,7 @@ function exchangeAsset(
745
749
  ) pure returns (Instruction memory) {
746
750
  return
747
751
  Instruction({
748
- iType: InstructionType.ExchangeAsset,
752
+ variant: InstructionVariant.ExchangeAsset,
749
753
  payload: abi.encodePacked(
750
754
  AssetFilterCodec.encode(params.give),
751
755
  AssetsCodec.encode(params.want),
@@ -760,7 +764,7 @@ function initiateReserveWithdraw(
760
764
  ) pure returns (Instruction memory) {
761
765
  return
762
766
  Instruction({
763
- iType: InstructionType.InitiateReserveWithdraw,
767
+ variant: InstructionVariant.InitiateReserveWithdraw,
764
768
  payload: abi.encodePacked(
765
769
  AssetFilterCodec.encode(params.assets),
766
770
  LocationCodec.encode(params.reserve),
@@ -775,7 +779,7 @@ function initiateTeleport(
775
779
  ) pure returns (Instruction memory) {
776
780
  return
777
781
  Instruction({
778
- iType: InstructionType.InitiateTeleport,
782
+ variant: InstructionVariant.InitiateTeleport,
779
783
  payload: abi.encodePacked(
780
784
  AssetFilterCodec.encode(params.assets),
781
785
  LocationCodec.encode(params.dest),
@@ -790,7 +794,7 @@ function reportHolding(
790
794
  ) pure returns (Instruction memory) {
791
795
  return
792
796
  Instruction({
793
- iType: InstructionType.ReportHolding,
797
+ variant: InstructionVariant.ReportHolding,
794
798
  payload: abi.encodePacked(
795
799
  QueryResponseInfoCodec.encode(params.responseInfo),
796
800
  AssetFilterCodec.encode(params.assets)
@@ -804,7 +808,7 @@ function buyExecution(
804
808
  ) pure returns (Instruction memory) {
805
809
  return
806
810
  Instruction({
807
- iType: InstructionType.BuyExecution,
811
+ variant: InstructionVariant.BuyExecution,
808
812
  payload: abi.encodePacked(
809
813
  AssetCodec.encode(params.fees),
810
814
  WeightLimitCodec.encode(params.weightLimit)
@@ -814,7 +818,8 @@ function buyExecution(
814
818
 
815
819
  /// @notice Creates an `Instruction` struct representing the `RefundSurplus` variant.
816
820
  function refundSurplus() pure returns (Instruction memory) {
817
- return Instruction({iType: InstructionType.RefundSurplus, payload: ""});
821
+ return
822
+ Instruction({variant: InstructionVariant.RefundSurplus, payload: ""});
818
823
  }
819
824
 
820
825
  /// @notice Creates an `Instruction` struct representing the `SetErrorHandler` variant with the provided `params`.
@@ -823,7 +828,7 @@ function setErrorHandler(
823
828
  ) pure returns (Instruction memory) {
824
829
  return
825
830
  Instruction({
826
- iType: InstructionType.SetErrorHandler,
831
+ variant: InstructionVariant.SetErrorHandler,
827
832
  payload: params.xcm
828
833
  });
829
834
  }
@@ -833,12 +838,15 @@ function setAppendix(
833
838
  SetAppendixParams memory params
834
839
  ) pure returns (Instruction memory) {
835
840
  return
836
- Instruction({iType: InstructionType.SetAppendix, payload: params.xcm});
841
+ Instruction({
842
+ variant: InstructionVariant.SetAppendix,
843
+ payload: params.xcm
844
+ });
837
845
  }
838
846
 
839
847
  /// @notice Creates an `Instruction` struct representing the `ClearError` variant.
840
848
  function clearError() pure returns (Instruction memory) {
841
- return Instruction({iType: InstructionType.ClearError, payload: ""});
849
+ return Instruction({variant: InstructionVariant.ClearError, payload: ""});
842
850
  }
843
851
 
844
852
  /// @notice Creates an `Instruction` struct representing the `ClaimAsset` variant with the provided `params`.
@@ -847,7 +855,7 @@ function claimAsset(
847
855
  ) pure returns (Instruction memory) {
848
856
  return
849
857
  Instruction({
850
- iType: InstructionType.ClaimAsset,
858
+ variant: InstructionVariant.ClaimAsset,
851
859
  payload: abi.encodePacked(
852
860
  AssetsCodec.encode(params.assets),
853
861
  LocationCodec.encode(params.ticket)
@@ -859,7 +867,7 @@ function claimAsset(
859
867
  function trap(TrapParams memory params) pure returns (Instruction memory) {
860
868
  return
861
869
  Instruction({
862
- iType: InstructionType.Trap,
870
+ variant: InstructionVariant.Trap,
863
871
  payload: Compact.encode(params.code)
864
872
  });
865
873
  }
@@ -870,7 +878,7 @@ function subscribeVersion(
870
878
  ) pure returns (Instruction memory) {
871
879
  return
872
880
  Instruction({
873
- iType: InstructionType.SubscribeVersion,
881
+ variant: InstructionVariant.SubscribeVersion,
874
882
  payload: abi.encodePacked(
875
883
  Compact.encode(uint256(QueryId.unwrap(params.queryId))),
876
884
  WeightCodec.encode(params.maxResponseWeight)
@@ -881,7 +889,10 @@ function subscribeVersion(
881
889
  /// @notice Creates an `Instruction` struct representing the `UnsubscribeVersion` variant.
882
890
  function unsubscribeVersion() pure returns (Instruction memory) {
883
891
  return
884
- Instruction({iType: InstructionType.UnsubscribeVersion, payload: ""});
892
+ Instruction({
893
+ variant: InstructionVariant.UnsubscribeVersion,
894
+ payload: ""
895
+ });
885
896
  }
886
897
 
887
898
  /// @notice Creates an `Instruction` struct representing the `BurnAsset` variant with the provided `params`.
@@ -890,7 +901,7 @@ function burnAsset(
890
901
  ) pure returns (Instruction memory) {
891
902
  return
892
903
  Instruction({
893
- iType: InstructionType.BurnAsset,
904
+ variant: InstructionVariant.BurnAsset,
894
905
  payload: AssetsCodec.encode(params.assets)
895
906
  });
896
907
  }
@@ -901,7 +912,7 @@ function expectAsset(
901
912
  ) pure returns (Instruction memory) {
902
913
  return
903
914
  Instruction({
904
- iType: InstructionType.ExpectAsset,
915
+ variant: InstructionVariant.ExpectAsset,
905
916
  payload: AssetsCodec.encode(params.assets)
906
917
  });
907
918
  }
@@ -917,7 +928,11 @@ function expectOrigin(
917
928
  LocationCodec.encode(params.origin)
918
929
  );
919
930
  }
920
- return Instruction({iType: InstructionType.ExpectOrigin, payload: payload});
931
+ return
932
+ Instruction({
933
+ variant: InstructionVariant.ExpectOrigin,
934
+ payload: payload
935
+ });
921
936
  }
922
937
 
923
938
  /// @notice Creates an `Instruction` struct representing the `ExpectError` variant with the provided `params`.
@@ -932,7 +947,11 @@ function expectError(
932
947
  XcmErrorCodec.encode(params.err)
933
948
  );
934
949
  }
935
- return Instruction({iType: InstructionType.ExpectError, payload: payload});
950
+ return
951
+ Instruction({
952
+ variant: InstructionVariant.ExpectError,
953
+ payload: payload
954
+ });
936
955
  }
937
956
 
938
957
  /// @notice Creates an `Instruction` struct representing the `ExpectTransactStatus` variant with the provided `params`.
@@ -941,7 +960,7 @@ function expectTransactStatus(
941
960
  ) pure returns (Instruction memory) {
942
961
  return
943
962
  Instruction({
944
- iType: InstructionType.ExpectTransactStatus,
963
+ variant: InstructionVariant.ExpectTransactStatus,
945
964
  payload: MaybeErrorCodeCodec.encode(params.transactStatus)
946
965
  });
947
966
  }
@@ -952,7 +971,7 @@ function queryPallet(
952
971
  ) pure returns (Instruction memory) {
953
972
  return
954
973
  Instruction({
955
- iType: InstructionType.QueryPallet,
974
+ variant: InstructionVariant.QueryPallet,
956
975
  payload: abi.encodePacked(
957
976
  Bytes.encode(params.moduleName),
958
977
  QueryResponseInfoCodec.encode(params.responseInfo)
@@ -966,7 +985,7 @@ function expectPallet(
966
985
  ) pure returns (Instruction memory) {
967
986
  return
968
987
  Instruction({
969
- iType: InstructionType.ExpectPallet,
988
+ variant: InstructionVariant.ExpectPallet,
970
989
  payload: abi.encodePacked(
971
990
  Compact.encode(params.index),
972
991
  Bytes.encode(params.name),
@@ -983,7 +1002,7 @@ function reportTransactStatus(
983
1002
  ) pure returns (Instruction memory) {
984
1003
  return
985
1004
  Instruction({
986
- iType: InstructionType.ReportTransactStatus,
1005
+ variant: InstructionVariant.ReportTransactStatus,
987
1006
  payload: QueryResponseInfoCodec.encode(params.responseInfo)
988
1007
  });
989
1008
  }
@@ -991,7 +1010,10 @@ function reportTransactStatus(
991
1010
  /// @notice Creates an `Instruction` struct representing the `ClearTransactStatus` variant.
992
1011
  function clearTransactStatus() pure returns (Instruction memory) {
993
1012
  return
994
- Instruction({iType: InstructionType.ClearTransactStatus, payload: ""});
1013
+ Instruction({
1014
+ variant: InstructionVariant.ClearTransactStatus,
1015
+ payload: ""
1016
+ });
995
1017
  }
996
1018
 
997
1019
  /// @notice Creates an `Instruction` struct representing the `UniversalOrigin` variant with the provided `params`.
@@ -1000,7 +1022,7 @@ function universalOrigin(
1000
1022
  ) pure returns (Instruction memory) {
1001
1023
  return
1002
1024
  Instruction({
1003
- iType: InstructionType.UniversalOrigin,
1025
+ variant: InstructionVariant.UniversalOrigin,
1004
1026
  payload: JunctionCodec.encode(params.junction)
1005
1027
  });
1006
1028
  }
@@ -1011,7 +1033,7 @@ function exportMessage(
1011
1033
  ) pure returns (Instruction memory) {
1012
1034
  return
1013
1035
  Instruction({
1014
- iType: InstructionType.ExportMessage,
1036
+ variant: InstructionVariant.ExportMessage,
1015
1037
  payload: abi.encodePacked(
1016
1038
  NetworkIdCodec.encode(params.network),
1017
1039
  JunctionsCodec.encode(params.destination),
@@ -1026,7 +1048,7 @@ function lockAsset(
1026
1048
  ) pure returns (Instruction memory) {
1027
1049
  return
1028
1050
  Instruction({
1029
- iType: InstructionType.LockAsset,
1051
+ variant: InstructionVariant.LockAsset,
1030
1052
  payload: abi.encodePacked(
1031
1053
  AssetCodec.encode(params.asset),
1032
1054
  LocationCodec.encode(params.unlocker)
@@ -1040,7 +1062,7 @@ function unlockAsset(
1040
1062
  ) pure returns (Instruction memory) {
1041
1063
  return
1042
1064
  Instruction({
1043
- iType: InstructionType.UnlockAsset,
1065
+ variant: InstructionVariant.UnlockAsset,
1044
1066
  payload: abi.encodePacked(
1045
1067
  AssetCodec.encode(params.asset),
1046
1068
  LocationCodec.encode(params.target)
@@ -1054,7 +1076,7 @@ function noteUnlockable(
1054
1076
  ) pure returns (Instruction memory) {
1055
1077
  return
1056
1078
  Instruction({
1057
- iType: InstructionType.NoteUnlockable,
1079
+ variant: InstructionVariant.NoteUnlockable,
1058
1080
  payload: abi.encodePacked(
1059
1081
  AssetCodec.encode(params.asset),
1060
1082
  LocationCodec.encode(params.owner)
@@ -1068,7 +1090,7 @@ function requestUnlock(
1068
1090
  ) pure returns (Instruction memory) {
1069
1091
  return
1070
1092
  Instruction({
1071
- iType: InstructionType.RequestUnlock,
1093
+ variant: InstructionVariant.RequestUnlock,
1072
1094
  payload: abi.encodePacked(
1073
1095
  AssetCodec.encode(params.asset),
1074
1096
  LocationCodec.encode(params.locker)
@@ -1082,7 +1104,7 @@ function setFeesMode(
1082
1104
  ) pure returns (Instruction memory) {
1083
1105
  return
1084
1106
  Instruction({
1085
- iType: InstructionType.SetFeesMode,
1107
+ variant: InstructionVariant.SetFeesMode,
1086
1108
  payload: Bool.encode(params.jitWithdraw)
1087
1109
  });
1088
1110
  }
@@ -1093,14 +1115,14 @@ function setTopic(
1093
1115
  ) pure returns (Instruction memory) {
1094
1116
  return
1095
1117
  Instruction({
1096
- iType: InstructionType.SetTopic,
1118
+ variant: InstructionVariant.SetTopic,
1097
1119
  payload: Bytes32.encode(params.topic)
1098
1120
  });
1099
1121
  }
1100
1122
 
1101
1123
  /// @notice Creates an `Instruction` struct representing the `ClearTopic` variant.
1102
1124
  function clearTopic() pure returns (Instruction memory) {
1103
- return Instruction({iType: InstructionType.ClearTopic, payload: ""});
1125
+ return Instruction({variant: InstructionVariant.ClearTopic, payload: ""});
1104
1126
  }
1105
1127
 
1106
1128
  /// @notice Creates an `Instruction` struct representing the `AliasOrigin` variant with the provided `params`.
@@ -1109,7 +1131,7 @@ function aliasOrigin(
1109
1131
  ) pure returns (Instruction memory) {
1110
1132
  return
1111
1133
  Instruction({
1112
- iType: InstructionType.AliasOrigin,
1134
+ variant: InstructionVariant.AliasOrigin,
1113
1135
  payload: LocationCodec.encode(params.location)
1114
1136
  });
1115
1137
  }
@@ -1129,7 +1151,10 @@ function unpaidExecution(
1129
1151
  );
1130
1152
  }
1131
1153
  return
1132
- Instruction({iType: InstructionType.UnpaidExecution, payload: payload});
1154
+ Instruction({
1155
+ variant: InstructionVariant.UnpaidExecution,
1156
+ payload: payload
1157
+ });
1133
1158
  }
1134
1159
 
1135
1160
  /// @notice Creates an `Instruction` struct representing the `PayFees` variant with the provided `params`.
@@ -1138,7 +1163,7 @@ function payFees(
1138
1163
  ) pure returns (Instruction memory) {
1139
1164
  return
1140
1165
  Instruction({
1141
- iType: InstructionType.PayFees,
1166
+ variant: InstructionVariant.PayFees,
1142
1167
  payload: AssetCodec.encode(params.asset)
1143
1168
  });
1144
1169
  }
@@ -1178,7 +1203,7 @@ function initiateTransfer(
1178
1203
  );
1179
1204
  return
1180
1205
  Instruction({
1181
- iType: InstructionType.InitiateTransfer,
1206
+ variant: InstructionVariant.InitiateTransfer,
1182
1207
  payload: payload
1183
1208
  });
1184
1209
  }
@@ -1197,7 +1222,7 @@ function executeWithOrigin(
1197
1222
  payload = abi.encodePacked(payload, params.xcm);
1198
1223
  return
1199
1224
  Instruction({
1200
- iType: InstructionType.ExecuteWithOrigin,
1225
+ variant: InstructionVariant.ExecuteWithOrigin,
1201
1226
  payload: payload
1202
1227
  });
1203
1228
  }
@@ -1213,5 +1238,6 @@ function setHints(
1213
1238
  for (uint256 i = 0; i < params.hints.length; i++) {
1214
1239
  payload = abi.encodePacked(payload, HintCodec.encode(params.hints[i]));
1215
1240
  }
1216
- return Instruction({iType: InstructionType.SetHints, payload: payload});
1241
+ return
1242
+ Instruction({variant: InstructionVariant.SetHints, payload: payload});
1217
1243
  }