{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/contracts/core/connext/libraries/ConnextMessage.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "library ConnextMessage {\n  // ============ Libraries ============\n\n  using TypedMemView for bytes;\n  using TypedMemView for bytes29;\n\n  // ============ Enums ============\n\n  // WARNING: do NOT re-write the numbers / order\n  // of message types in an upgrade;\n  // will cause in-flight messages to be mis-interpreted\n  enum Types {\n    Invalid, // 0\n    TokenId, // 1\n    Message, // 2\n    Transfer // 3\n  }\n\n  // ============ Structs ============\n\n  // Tokens are identified by a TokenId:\n  // domain - 4 byte chain ID of the chain from which the token originates\n  // id - 32 byte identifier of the token address on the origin chain, in that chain's address format\n  struct TokenId {\n    uint32 domain;\n    bytes32 id;\n  }\n\n  // ============ Constants ============\n\n  uint256 private constant TOKEN_ID_LEN = 36; // 4 bytes domain + 32 bytes id\n  uint256 private constant IDENTIFIER_LEN = 1;\n  uint256 private constant TRANSFER_LEN = 129;\n  // 1 byte identifier + 32 bytes recipient + 32 bytes amount + 32 bytes detailsHash + 32 bytes external hash\n\n  // ============ Modifiers ============\n\n  /**\n   * @notice Asserts a message is of type `_t`\n   * @param _view The message\n   * @param _t The expected type\n   */\n  modifier typeAssert(bytes29 _view, Types _t) {\n    _view.assertType(uint40(_t));\n    _;\n  }\n\n  // ============ Internal Functions: Validation ============\n\n  /**\n   * @notice Checks that Action is valid type\n   * @param _action The action\n   * @return TRUE if action is valid\n   */\n  function isValidAction(bytes29 _action) internal pure returns (bool) {\n    return isTransfer(_action);\n  }\n\n  /**\n   * @notice Checks that the message is of the specified type\n   * @param _type the type to check for\n   * @param _action The message\n   * @return True if the message is of the specified type\n   */\n  function isType(bytes29 _action, Types _type) internal pure returns (bool) {\n    return actionType(_action) == uint8(_type) && messageType(_action) == _type;\n  }\n\n  /**\n   * @notice Checks that the message is of type Transfer\n   * @param _action The message\n   * @return True if the message is of type Transfer\n   */\n  function isTransfer(bytes29 _action) internal pure returns (bool) {\n    return isType(_action, Types.Transfer);\n  }\n\n  /**\n   * @notice Checks that view is a valid message length\n   * @param _view The bytes string\n   * @return TRUE if message is valid\n   */\n  function isValidMessageLength(bytes29 _view) internal pure returns (bool) {\n    uint256 _len = _view.len();\n    return _len == TOKEN_ID_LEN + TRANSFER_LEN;\n  }\n\n  /**\n   * @notice Asserts that the message is of type Message\n   * @param _view The message\n   * @return The message\n   */\n  function mustBeMessage(bytes29 _view) internal pure returns (bytes29) {\n    return tryAsMessage(_view).assertValid();\n  }\n\n  // ============ Internal Functions: Formatting ============\n\n  /**\n   * @notice Formats an action message\n   * @param _tokenId The token ID\n   * @param _action The action\n   * @return The formatted message\n   */\n  function formatMessage(bytes29 _tokenId, bytes29 _action)\n    internal\n    view\n    typeAssert(_tokenId, Types.TokenId)\n    returns (bytes memory)\n  {\n    require(isValidAction(_action), \"!action\");\n    bytes29[] memory _views = new bytes29[](2);\n    _views[0] = _tokenId;\n    _views[1] = _action;\n    return TypedMemView.join(_views);\n  }\n\n  /**\n   * @notice Formats Transfer\n   * @param _to The recipient address as bytes32\n   * @param _amnt The transfer amount\n   * @param _detailsHash The token details hash\n   * @param _transferId Unique identifier for transfer\n   * @return\n   */\n  function formatTransfer(\n    bytes32 _to,\n    uint256 _amnt,\n    bytes32 _detailsHash,\n    bytes32 _transferId\n  ) internal pure returns (bytes29) {\n    return\n      abi.encodePacked(Types.Transfer, _to, _amnt, _detailsHash, _transferId).ref(0).castTo(uint40(Types.Transfer));\n  }\n\n  /**\n   * @notice Serializes a Token ID struct\n   * @param _tokenId The token id struct\n   * @return The formatted Token ID\n   */\n  function formatTokenId(TokenId memory _tokenId) internal pure returns (bytes29) {\n    return formatTokenId(_tokenId.domain, _tokenId.id);\n  }\n\n  /**\n   * @notice Creates a serialized Token ID from components\n   * @param _domain The domain\n   * @param _id The ID\n   * @return The formatted Token ID\n   */\n  function formatTokenId(uint32 _domain, bytes32 _id) internal pure returns (bytes29) {\n    return abi.encodePacked(_domain, _id).ref(0).castTo(uint40(Types.TokenId));\n  }\n\n  /**\n   * @notice Formats the keccak256 hash of the token details\n   * Token Details Format:\n   *      length of name cast to bytes - 32 bytes\n   *      name - x bytes (variable)\n   *      length of symbol cast to bytes - 32 bytes\n   *      symbol - x bytes (variable)\n   *      decimals - 1 byte\n   * @param _name The name\n   * @param _symbol The symbol\n   * @param _decimals The decimals\n   * @return The Details message\n   */\n  function formatDetailsHash(\n    string memory _name,\n    string memory _symbol,\n    uint8 _decimals\n  ) internal pure returns (bytes32) {\n    return keccak256(abi.encodePacked(bytes(_name).length, _name, bytes(_symbol).length, _symbol, _decimals));\n  }\n\n  /**\n   * @notice Converts to a Message\n   * @param _message The message\n   * @return The newly typed message\n   */\n  function tryAsMessage(bytes29 _message) internal pure returns (bytes29) {\n    if (isValidMessageLength(_message)) {\n      return _message.castTo(uint40(Types.Message));\n    }\n    return TypedMemView.nullView();\n  }\n\n  // ============ Internal Functions: Parsing msg ============\n\n  /**\n   * @notice Returns the type of the message\n   * @param _view The message\n   * @return The type of the message\n   */\n  function messageType(bytes29 _view) internal pure returns (Types) {\n    return Types(uint8(_view.typeOf()));\n  }\n\n  /**\n   * @notice Retrieves the token ID from a Message\n   * @param _message The message\n   * @return The ID\n   */\n  function tokenId(bytes29 _message) internal pure typeAssert(_message, Types.Message) returns (bytes29) {\n    return _message.slice(0, TOKEN_ID_LEN, uint40(Types.TokenId));\n  }\n\n  /**\n   * @notice Retrieves the action data from a Message\n   * @param _message The message\n   * @return The action\n   */\n  function action(bytes29 _message) internal pure typeAssert(_message, Types.Message) returns (bytes29) {\n    uint256 _actionLen = _message.len() - TOKEN_ID_LEN;\n    uint40 _type = uint40(msgType(_message));\n    return _message.slice(TOKEN_ID_LEN, _actionLen, _type);\n  }\n\n  // ============ Internal Functions: Parsing tokenId ============\n\n  /**\n   * @notice Retrieves the domain from a TokenID\n   * @param _tokenId The message\n   * @return The domain\n   */\n  function domain(bytes29 _tokenId) internal pure typeAssert(_tokenId, Types.TokenId) returns (uint32) {\n    return uint32(_tokenId.indexUint(0, 4));\n  }\n\n  /**\n   * @notice Retrieves the ID from a TokenID\n   * @param _tokenId The message\n   * @return The ID\n   */\n  function id(bytes29 _tokenId) internal pure typeAssert(_tokenId, Types.TokenId) returns (bytes32) {\n    // before = 4 bytes domain\n    return _tokenId.index(4, 32);\n  }\n\n  /**\n   * @notice Retrieves the EVM ID\n   * @param _tokenId The message\n   * @return The EVM ID\n   */\n  function evmId(bytes29 _tokenId) internal pure typeAssert(_tokenId, Types.TokenId) returns (address) {\n    // before = 4 bytes domain + 12 bytes empty to trim for address\n    return _tokenId.indexAddress(16);\n  }\n\n  // ============ Internal Functions: Parsing action ============\n\n  /**\n   * @notice Retrieves the action identifier from message\n   * @param _message The action\n   * @return The message type\n   */\n  function msgType(bytes29 _message) internal pure returns (uint8) {\n    return uint8(_message.indexUint(TOKEN_ID_LEN, 1));\n  }\n\n  /**\n   * @notice Retrieves the identifier from action\n   * @param _action The action\n   * @return The action type\n   */\n  function actionType(bytes29 _action) internal pure returns (uint8) {\n    return uint8(_action.indexUint(0, 1));\n  }\n\n  /**\n   * @notice Retrieves the recipient from a Transfer\n   * @param _transferAction The message\n   * @return The recipient address as bytes32\n   */\n  function recipient(bytes29 _transferAction) internal pure returns (bytes32) {\n    // before = 1 byte identifier\n    return _transferAction.index(1, 32);\n  }\n\n  /**\n   * @notice Retrieves the EVM Recipient from a Transfer\n   * @param _transferAction The message\n   * @return The EVM Recipient\n   */\n  function evmRecipient(bytes29 _transferAction) internal pure returns (address) {\n    // before = 1 byte identifier + 12 bytes empty to trim for address = 13 bytes\n    return _transferAction.indexAddress(13);\n  }\n\n  /**\n   * @notice Retrieves the amount from a Transfer\n   * @param _transferAction The message\n   * @return The amount\n   */\n  function amnt(bytes29 _transferAction) internal pure returns (uint256) {\n    // before = 1 byte identifier + 32 bytes ID = 33 bytes\n    return _transferAction.indexUint(33, 32);\n  }\n\n  /**\n   * @notice Retrieves the unique identifier from a Transfer\n   * @param _transferAction The message\n   * @return The amount\n   */\n  function transferId(bytes29 _transferAction) internal pure returns (bytes32) {\n    // before = 1 byte identifier + 32 bytes ID + 32 bytes amount + 32 bytes detailsHash = 97 bytes\n    return _transferAction.index(97, 32);\n  }\n\n  /**\n   * @notice Retrieves the detailsHash from a Transfer\n   * @param _transferAction The message\n   * @return The detailsHash\n   */\n  function detailsHash(bytes29 _transferAction) internal pure returns (bytes32) {\n    // before = 1 byte identifier + 32 bytes ID + 32 bytes amount = 65 bytes\n    return _transferAction.index(65, 32);\n  }\n}"
}