solidity-scale-codec 2.1.1 → 2.1.2

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 (38) hide show
  1. package/guides/Definitions.md +186 -0
  2. package/package.json +2 -2
  3. package/src/Scale/Array/BoolArr.sol +3 -3
  4. package/src/Scale/Array/I128Arr.sol +3 -3
  5. package/src/Scale/Array/I16Arr.sol +3 -3
  6. package/src/Scale/Array/I256Arr.sol +3 -3
  7. package/src/Scale/Array/I32Arr.sol +3 -3
  8. package/src/Scale/Array/I64Arr.sol +3 -3
  9. package/src/Scale/Array/I8Arr.sol +3 -3
  10. package/src/Scale/Array/U128Arr.sol +3 -3
  11. package/src/Scale/Array/U16Arr.sol +3 -3
  12. package/src/Scale/Array/U256Arr.sol +3 -3
  13. package/src/Scale/Array/U32Arr.sol +3 -3
  14. package/src/Scale/Array/U64Arr.sol +3 -3
  15. package/src/Scale/Array/U8Arr.sol +3 -3
  16. package/src/Scale/Array.sol +14 -15
  17. package/src/Scale/Compact/Compact.sol +2 -4
  18. package/src/Scale/Signed/I128.sol +14 -9
  19. package/src/Scale/Signed/I16.sol +11 -8
  20. package/src/Scale/Signed/I256.sol +14 -9
  21. package/src/Scale/Signed/I32.sol +11 -8
  22. package/src/Scale/Signed/I64.sol +11 -8
  23. package/src/Scale/Signed/I8.sol +11 -8
  24. package/src/Scale/Signed.sol +7 -8
  25. package/src/Scale/Unsigned.sol +7 -8
  26. package/src/Xcm/v3/MaybeErrorCode/MaybeErrorCodeCodec.sol +6 -1
  27. package/src/Xcm/v5/AssetFilter/AssetFilterCodec.sol +6 -1
  28. package/src/Xcm/v5/AssetInstance/AssetInstanceCodec.sol +9 -1
  29. package/src/Xcm/v5/AssetTransferFilter/AssetTransferFilterCodec.sol +7 -1
  30. package/src/Xcm/v5/BodyPart/BodyPartCodec.sol +8 -1
  31. package/src/Xcm/v5/Fungibility/FungibilityCodec.sol +6 -1
  32. package/src/Xcm/v5/Instruction/InstructionCodec.sol +1295 -1246
  33. package/src/Xcm/v5/Junction/JunctionCodec.sol +13 -1
  34. package/src/Xcm/v5/NetworkId/NetworkIdCodec.sol +7 -1
  35. package/src/Xcm/v5/Response/ResponseCodec.sol +9 -1
  36. package/src/Xcm/v5/WeightLimit/WeightLimitCodec.sol +5 -1
  37. package/src/Xcm/v5/WildAsset/WildAssetCodec.sol +7 -1
  38. package/src/Xcm/v5/Xcm/XcmBuilder.sol +101 -1
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.28;
3
3
 
4
- import { U64 } from "../Unsigned/U64.sol";
4
+ import {U64} from "../Unsigned/U64.sol";
5
5
 
6
6
  /// @title Scale Codec for the `int64` type.
7
7
  /// @notice SCALE-compliant encoder/decoder for the `int64` type.
@@ -9,7 +9,7 @@ import { U64 } from "../Unsigned/U64.sol";
9
9
  library I64 {
10
10
  error OffsetOutOfBounds();
11
11
 
12
- /// @notice Encodes an `int64` into SCALE format (8-byte two's-complement little-endian).
12
+ /// @notice Encodes an `int64` into SCALE format (8-byte two's-complement little-endian).
13
13
  /// @param value The signed 64-bit integer to encode.
14
14
  /// @return SCALE-encoded byte sequence.
15
15
  function encode(int64 value) internal pure returns (bytes memory) {
@@ -17,10 +17,13 @@ library I64 {
17
17
  }
18
18
 
19
19
  /// @notice Returns the number of bytes that a `int64` would occupy when SCALE-encoded.
20
- /// @param data The byte sequence containing the encoded `int64`.
21
- /// @param offset The starting index in `data` from which to calculate the encoded size of the `int64`.
22
- /// @return The number of bytes that the `int64` would occupy when SCALE-encoded.
23
- function encodedSizeAt(bytes memory data, uint256 offset) internal pure returns (uint256) {
20
+ /// @param data The byte sequence containing the encoded `int64`.
21
+ /// @param offset The starting index in `data` from which to calculate the encoded size of the `int64`.
22
+ /// @return The number of bytes that the `int64` would occupy when SCALE-encoded.
23
+ function encodedSizeAt(
24
+ bytes memory data,
25
+ uint256 offset
26
+ ) internal pure returns (uint256) {
24
27
  return U64.encodedSizeAt(data, offset);
25
28
  }
26
29
 
@@ -43,10 +46,10 @@ library I64 {
43
46
  return int64(U64.decodeAt(data, offset));
44
47
  }
45
48
 
46
- /// @notice Converts an int64 to little-endian bytes8 (two's complement)
49
+ /// @notice Converts an int64 to little-endian bytes8 (two's complement)
47
50
  /// @param value The signed 64-bit integer to convert.
48
51
  /// @return result Little-endian byte representation of the input value.
49
52
  function toLittleEndian(int64 value) internal pure returns (bytes8 result) {
50
53
  return U64.toLittleEndian(uint64(value));
51
54
  }
52
- }
55
+ }
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.28;
3
3
 
4
- import { U8 } from "../Unsigned/U8.sol";
4
+ import {U8} from "../Unsigned/U8.sol";
5
5
 
6
6
  /// @title Scale Codec for the `int8` type.
7
7
  /// @notice SCALE-compliant encoder/decoder for the `int8` type.
@@ -9,7 +9,7 @@ import { U8 } from "../Unsigned/U8.sol";
9
9
  library I8 {
10
10
  error OffsetOutOfBounds();
11
11
 
12
- /// @notice Encodes an `int8` into SCALE format (1-byte two's-complement little-endian).
12
+ /// @notice Encodes an `int8` into SCALE format (1-byte two's-complement little-endian).
13
13
  /// @param value The signed 8-bit integer to encode.
14
14
  /// @return SCALE-encoded byte sequence.
15
15
  function encode(int8 value) internal pure returns (bytes memory) {
@@ -17,10 +17,13 @@ library I8 {
17
17
  }
18
18
 
19
19
  /// @notice Returns the number of bytes that a `int8` would occupy when SCALE-encoded.
20
- /// @param data The byte sequence containing the encoded `int8`.
21
- /// @param offset The starting index in `data` from which to calculate the encoded size of the `int8`.
22
- /// @return The number of bytes that the `int8` would occupy when SCALE-encoded.
23
- function encodedSizeAt(bytes memory data, uint256 offset) internal pure returns (uint256) {
20
+ /// @param data The byte sequence containing the encoded `int8`.
21
+ /// @param offset The starting index in `data` from which to calculate the encoded size of the `int8`.
22
+ /// @return The number of bytes that the `int8` would occupy when SCALE-encoded.
23
+ function encodedSizeAt(
24
+ bytes memory data,
25
+ uint256 offset
26
+ ) internal pure returns (uint256) {
24
27
  return U8.encodedSizeAt(data, offset);
25
28
  }
26
29
 
@@ -43,10 +46,10 @@ library I8 {
43
46
  return int8(U8.decodeAt(data, offset));
44
47
  }
45
48
 
46
- /// @notice Converts an int8 to little-endian bytes1 (two's complement)
49
+ /// @notice Converts an int8 to little-endian bytes1 (two's complement)
47
50
  /// @param value The signed 8-bit integer to convert.
48
51
  /// @return result Little-endian byte representation of the input value.
49
52
  function toLittleEndian(int8 value) internal pure returns (bytes1 result) {
50
53
  return U8.toLittleEndian(uint8(value));
51
54
  }
52
- }
55
+ }
@@ -1,10 +1,9 @@
1
-
2
1
  // SPDX-License-Identifier: Apache-2.0
3
- pragma solidity ^0.8.28;
2
+ pragma solidity ^0.8.28;
4
3
 
5
- import { I8 } from "./Signed/I8.sol";
6
- import { I16 } from "./Signed/I16.sol";
7
- import { I32 } from "./Signed/I32.sol";
8
- import { I64 } from "./Signed/I64.sol";
9
- import { I128 } from "./Signed/I128.sol";
10
- import { I256 } from "./Signed/I256.sol";
4
+ import {I8} from "./Signed/I8.sol";
5
+ import {I16} from "./Signed/I16.sol";
6
+ import {I32} from "./Signed/I32.sol";
7
+ import {I64} from "./Signed/I64.sol";
8
+ import {I128} from "./Signed/I128.sol";
9
+ import {I256} from "./Signed/I256.sol";
@@ -1,10 +1,9 @@
1
-
2
1
  // SPDX-License-Identifier: Apache-2.0
3
- pragma solidity ^0.8.28;
2
+ pragma solidity ^0.8.28;
4
3
 
5
- import { U8 } from "./Unsigned/U8.sol";
6
- import { U16 } from "./Unsigned/U16.sol";
7
- import { U32 } from "./Unsigned/U32.sol";
8
- import { U64 } from "./Unsigned/U64.sol";
9
- import { U128 } from "./Unsigned/U128.sol";
10
- import { U256 } from "./Unsigned/U256.sol";
4
+ import {U8} from "./Unsigned/U8.sol";
5
+ import {U16} from "./Unsigned/U16.sol";
6
+ import {U32} from "./Unsigned/U32.sol";
7
+ import {U64} from "./Unsigned/U64.sol";
8
+ import {U128} from "./Unsigned/U128.sol";
9
+ import {U256} from "./Unsigned/U256.sol";
@@ -2,7 +2,12 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import {Bytes} from "../../../Scale/Bytes.sol";
5
- import {MaybeErrorCode, MaybeErrorCodeVariant, ErrorParams, TruncatedErrorParams} from "./MaybeErrorCode.sol";
5
+ import {
6
+ MaybeErrorCode,
7
+ MaybeErrorCodeVariant,
8
+ ErrorParams,
9
+ TruncatedErrorParams
10
+ } from "./MaybeErrorCode.sol";
6
11
  import {BytesUtils} from "../../../Utils/BytesUtils.sol";
7
12
 
8
13
  /// @title SCALE Codec for XCM v3 `MaybeErrorCode`
@@ -5,7 +5,12 @@ import {Assets} from "../Assets/Assets.sol";
5
5
  import {AssetsCodec} from "../Assets/AssetsCodec.sol";
6
6
  import {WildAsset} from "../WildAsset/WildAsset.sol";
7
7
  import {WildAssetCodec} from "../WildAsset/WildAssetCodec.sol";
8
- import {AssetFilter, AssetFilterVariant, DefiniteParams, WildParams} from "./AssetFilter.sol";
8
+ import {
9
+ AssetFilter,
10
+ AssetFilterVariant,
11
+ DefiniteParams,
12
+ WildParams
13
+ } from "./AssetFilter.sol";
9
14
  import {BytesUtils} from "../../../Utils/BytesUtils.sol";
10
15
 
11
16
  /// @title SCALE Codec for XCM v5 `AssetFilter`
@@ -6,7 +6,15 @@ import {Bytes4} from "../../../Scale/Bytes/Bytes4.sol";
6
6
  import {Bytes8} from "../../../Scale/Bytes/Bytes8.sol";
7
7
  import {Bytes16} from "../../../Scale/Bytes/Bytes16.sol";
8
8
  import {Bytes32} from "../../../Scale/Bytes/Bytes32.sol";
9
- import {AssetInstance, AssetInstanceVariant, IndexParams, Array4Params, Array8Params, Array16Params, Array32Params} from "./AssetInstance.sol";
9
+ import {
10
+ AssetInstance,
11
+ AssetInstanceVariant,
12
+ IndexParams,
13
+ Array4Params,
14
+ Array8Params,
15
+ Array16Params,
16
+ Array32Params
17
+ } from "./AssetInstance.sol";
10
18
  import {BytesUtils} from "../../../Utils/BytesUtils.sol";
11
19
  import {UnsignedUtils} from "../../../Utils/UnsignedUtils.sol";
12
20
 
@@ -3,7 +3,13 @@ pragma solidity ^0.8.28;
3
3
 
4
4
  import {AssetFilter} from "../AssetFilter/AssetFilter.sol";
5
5
  import {AssetFilterCodec} from "../AssetFilter/AssetFilterCodec.sol";
6
- import {AssetTransferFilter, AssetTransferFilterVariant, TeleportParams, ReserveDepositParams, ReserveWithdrawParams} from "./AssetTransferFilter.sol";
6
+ import {
7
+ AssetTransferFilter,
8
+ AssetTransferFilterVariant,
9
+ TeleportParams,
10
+ ReserveDepositParams,
11
+ ReserveWithdrawParams
12
+ } from "./AssetTransferFilter.sol";
7
13
  import {BytesUtils} from "../../../Utils/BytesUtils.sol";
8
14
 
9
15
  /// @title SCALE Codec for XCM v5 `AssetTransferFilter`
@@ -2,7 +2,14 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import {Compact} from "../../../Scale/Compact.sol";
5
- import {BodyPart, BodyPartVariant, MembersParams, FractionParams, AtLeastProportionParams, MoreThanProportionParams} from "./BodyPart.sol";
5
+ import {
6
+ BodyPart,
7
+ BodyPartVariant,
8
+ MembersParams,
9
+ FractionParams,
10
+ AtLeastProportionParams,
11
+ MoreThanProportionParams
12
+ } from "./BodyPart.sol";
6
13
  import {BytesUtils} from "../../../Utils/BytesUtils.sol";
7
14
  import {UnsignedUtils} from "../../../Utils/UnsignedUtils.sol";
8
15
 
@@ -4,7 +4,12 @@ pragma solidity ^0.8.28;
4
4
  import {Compact} from "../../../Scale/Compact.sol";
5
5
  import {AssetInstance} from "../AssetInstance/AssetInstance.sol";
6
6
  import {AssetInstanceCodec} from "../AssetInstance/AssetInstanceCodec.sol";
7
- import {Fungibility, FungibilityVariant, FungibleParams, NonFungibleParams} from "./Fungibility.sol";
7
+ import {
8
+ Fungibility,
9
+ FungibilityVariant,
10
+ FungibleParams,
11
+ NonFungibleParams
12
+ } from "./Fungibility.sol";
8
13
  import {BytesUtils} from "../../../Utils/BytesUtils.sol";
9
14
  import {UnsignedUtils} from "../../../Utils/UnsignedUtils.sol";
10
15