{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/contracts/core/promise/libraries/PromiseMessage.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "library PromiseMessage {\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    PromiseCallback // 1\n  }\n\n  // ============ Constants ============\n  uint256 private constant IDENTIFIER_LEN = 1;\n  // 1 byte identifier + 32 bytes transferId + 20 bytes callback + 1 byte success + 32 bytes length + x bytes data\n  // before: 1 byte identifier + 32 bytes transferId + 20 bytes callback + 1 byte success= 54 bytes\n  uint256 private constant LENGTH_RETURNDATA_START = 54;\n  uint8 private constant LENGTH_RETURNDATA_LEN = 32;\n\n  // before: 1 byte identifier + 32 bytes transferId + 20 bytes callback +  1 byte success + 32 bytes length = 86 bytes\n  uint256 private constant RETURNDATA_START = 86;\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  // ============ Formatters ============\n\n  /**\n   * @notice Formats an promise callback message\n   * @param _transferId The address of the relayer\n   * @param _callbackAddress The callback address on destination domain\n   * @param _returnSuccess The success of the call\n   * @param _returnData The return data of the call\n   * @return The formatted message\n   */\n  function formatPromiseCallback(\n    bytes32 _transferId,\n    address _callbackAddress,\n    bool _returnSuccess,\n    bytes calldata _returnData\n  ) internal pure returns (bytes memory) {\n    return\n      abi.encodePacked(\n        uint8(Types.PromiseCallback),\n        _transferId,\n        _callbackAddress,\n        uint8(_returnSuccess ? 1 : 0),\n        _returnData.length,\n        _returnData\n      );\n  }\n\n  // ============ Getters ============\n\n  /**\n   * @notice Parse the transferId from the message\n   * @param _view The message\n   * @return The transferId\n   */\n  function transferId(bytes29 _view) internal pure typeAssert(_view, Types.PromiseCallback) returns (bytes32) {\n    // before = 1 byte identifier\n    return _view.index(1, 32);\n  }\n\n  /**\n   * @notice Parse the callback address from the message\n   * @param _view The message\n   * @return The callback address\n   */\n  function callbackAddress(bytes29 _view) internal pure typeAssert(_view, Types.PromiseCallback) returns (address) {\n    // before = 1 byte identifier + 32 bytes transferId\n    return _view.indexAddress(33);\n  }\n\n  /**\n   * @notice Parse the result of execution on the destination domain\n   * @param _view The message\n   * @return The call result\n   */\n  function returnSuccess(bytes29 _view) internal pure typeAssert(_view, Types.PromiseCallback) returns (bool) {\n    // before: 1 byte identifier + 32 bytes transferId + 20 bytes callback = 53 bytes\n    return _view.indexUint(53, 1) == 1;\n  }\n\n  /**\n   * @notice Parse the returnData length from the message\n   * @param _view The message\n   * @return The returnData length\n   */\n  function lengthOfReturnData(bytes29 _view) internal pure returns (uint256) {\n    return _view.indexUint(LENGTH_RETURNDATA_START, LENGTH_RETURNDATA_LEN);\n  }\n\n  /**\n   * @notice Parse returnData from the message\n   * @param _view The message\n   * @return data\n   */\n  function returnData(bytes29 _view)\n    internal\n    view\n    typeAssert(_view, Types.PromiseCallback)\n    returns (bytes memory data)\n  {\n    uint256 length = lengthOfReturnData(_view);\n\n    data = _view.slice(RETURNDATA_START, length, 0).clone();\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 isValidPromiseCallbackLength(bytes29 _view) internal pure returns (bool) {\n    uint256 _len = _view.len();\n    if (_len <= LENGTH_RETURNDATA_START) {\n      return false;\n    }\n    uint256 _length = lengthOfReturnData(_view);\n    // before = 1 byte identifier + 32 bytes transferId + 20 bytes callback address + 1 byte success + 32 bytes length + x bytes data\n    // nonzero return data\n    return _length > 0 && (RETURNDATA_START + _length) == _len;\n  }\n\n  /**\n   * @notice Converts to a Promise callback message\n   * @param _view The message\n   * @return The newly typed message\n   */\n  function tryAsPromiseCallback(bytes29 _view) internal pure returns (bytes29) {\n    if (isValidPromiseCallbackLength(_view)) {\n      return _view.castTo(uint40(Types.PromiseCallback));\n    }\n    return TypedMemView.nullView();\n  }\n\n  /**\n   * @notice Asserts that the message is of type PromiseCallback\n   * @param _view The message\n   * @return The message\n   */\n  function mustBePromiseCallback(bytes29 _view) internal pure returns (bytes29) {\n    return tryAsPromiseCallback(_view).assertValid();\n  }\n}"
}