Skip to content

File: src/Scale/Compact/Compact.sol

Compact

Kind: library

ABI Surface

Errors

  • error InvalidCompactEncoding()
  • error NonCanonicalEncoding()
  • error OffsetOutOfBounds()
  • error ValueOutOfRange()

Function Surface

  • function encode(uint256 value) internal pure returns (bytes)
    • Encodes a uint256 value to SCALE Compact format
  • function encodedSizeAt(bytes data, uint256 offset) internal pure returns (uint256)
    • Returns the number of bytes that the Compact-encoded value at the given offset occupies
  • function decode(bytes data) internal pure returns (uint256, uint256)
    • Decodes a uint256 value from SCALE Compact format
  • function decodeAt(bytes data, uint256 offset) internal pure returns (uint256, uint256)
    • Decodes a uint256 value from SCALE Compact format
  • function \_encodeSingleByte(uint256 value) private pure returns (bytes)
    • Encodes values in the range [0, 63] using single-byte mode
  • function \_encodeTwoByte(uint256 value) private pure returns (bytes)
    • Encodes values in the range [64, 16383] using double-byte mode
  • function \_encodeFourByte(uint256 value) private pure returns (bytes)
    • Encodes values in the range [16384, 1073741823] using four-byte mode
  • function \_encodeBigInt(uint256 value) private pure returns (bytes)
    • Encodes values in the range [1073741824, 2^536−1] using "big-int" mode
  • function \_bytesNeeded(uint256 value) private pure returns (uint8)
    • Calculate minimum bytes needed to represent value in big-int mode (excluding header)
  • function \_assertCanonicalEncoding(uint256 value, uint8 mode) private pure
    • Asserts that the decoded value is using the canonical encoding for its mode

Created with solidity-doc-generator