Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
7280088 | 11 days ago | Contract Creation | 0 S |
Loading...
Loading
Contract Name:
LayerZeroAdapter
Compiler Version
v0.8.22+commit.4fc1097e
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.8; import {ILayerZeroReceiver} from './interfaces/ILayerZeroReceiver.sol'; import {MessagingParams, Origin, MessagingFee, MessagingReceipt} from './interfaces/ILayerZeroEndpointV2.sol'; import {SafeCast} from 'openzeppelin-contracts/contracts/utils/math/SafeCast.sol'; import {OptionsBuilder} from './libs/OptionsBuilder.sol'; import {BaseAdapter, IBaseAdapter} from '../BaseAdapter.sol'; import {ILayerZeroAdapter, ILayerZeroEndpointV2} from './ILayerZeroAdapter.sol'; import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; import {Errors} from '../../libs/Errors.sol'; /** * @title LayerZeroAdapter * @author BGD Labs * @notice LayerZero bridge adapter. Used to send and receive messages cross chain * @dev it uses the eth balance of CrossChainController contract to pay for message bridging as the method to bridge is called via delegate call */ contract LayerZeroAdapter is BaseAdapter, ILayerZeroAdapter, ILayerZeroReceiver { /// @inheritdoc ILayerZeroAdapter ILayerZeroEndpointV2 public immutable LZ_ENDPOINT; /// @notice modifier to check that caller is LayerZero endpoint modifier onlyLZEndpoint() { require(msg.sender == address(LZ_ENDPOINT), Errors.CALLER_NOT_LZ_ENDPOINT); _; } /** * @notice constructor for the Layer Zero adapter * @param crossChainController address of the contract that manages cross chain infrastructure * @param lzEndpoint address of the layer zero endpoint on the current chain where adapter is deployed * @param providerGasLimit base gas limit used by the bridge adapter * @param trustedRemotes array of objects with chain id and origin addresses which will be allowed to send messages to this adapter */ constructor( address crossChainController, address lzEndpoint, uint256 providerGasLimit, TrustedRemotesConfig[] memory trustedRemotes ) BaseAdapter(crossChainController, providerGasLimit, 'LayerZero adapter', trustedRemotes) { require(lzEndpoint != address(0), Errors.INVALID_LZ_ENDPOINT); LZ_ENDPOINT = ILayerZeroEndpointV2(lzEndpoint); } /// @inheritdoc ILayerZeroReceiver function nextNonce(uint32 /*_srcEid*/, bytes32 /*_sender*/) public pure returns (uint64) { return 0; } /// @inheritdoc ILayerZeroReceiver function lzReceive( Origin calldata _origin, bytes32, bytes calldata _message, address, bytes calldata ) external payable onlyLZEndpoint { uint256 originChainId = nativeToInfraChainId(_origin.srcEid); require(allowInitializePath(_origin), Errors.REMOTE_NOT_TRUSTED); _registerReceivedMessage(_message, originChainId); } /// @inheritdoc ILayerZeroReceiver function allowInitializePath(Origin calldata origin) public view returns (bool) { uint256 originChainId = nativeToInfraChainId(origin.srcEid); address srcAddress = address(uint160(uint256(origin.sender))); return _trustedRemotes[originChainId] == srcAddress && srcAddress != address(0); } /// @inheritdoc IBaseAdapter function forwardMessage( address receiver, uint256 executionGasLimit, uint256 destinationChainId, bytes calldata message ) external returns (address, uint256) { uint32 nativeChainId = SafeCast.toUint32(infraToNativeChainId(destinationChainId)); require(nativeChainId != uint32(0), Errors.DESTINATION_CHAIN_ID_NOT_SUPPORTED); require(receiver != address(0), Errors.RECEIVER_NOT_SET); bytes32 receiverAddress = bytes32(uint256(uint160(receiver))); uint256 totalGasLimit = executionGasLimit + BASE_GAS_LIMIT; bytes memory options = _generateOptions(SafeCast.toUint128(totalGasLimit)); MessagingFee memory fee = LZ_ENDPOINT.quote( MessagingParams(nativeChainId, receiverAddress, message, options, false), address(this) ); require(fee.nativeFee <= address(this).balance, Errors.NOT_ENOUGH_VALUE_TO_PAY_BRIDGE_FEES); MessagingReceipt memory receipt = LZ_ENDPOINT.send{value: fee.nativeFee}( MessagingParams(nativeChainId, receiverAddress, message, options, false), address(this) ); return (address(LZ_ENDPOINT), uint256(receipt.nonce)); } /// @inheritdoc IBaseAdapter function nativeToInfraChainId( uint256 nativeChainId ) public pure virtual override returns (uint256) { if (nativeChainId == 30101) { return ChainIds.ETHEREUM; } else if (nativeChainId == 30106) { return ChainIds.AVALANCHE; } else if (nativeChainId == 30109) { return ChainIds.POLYGON; } else if (nativeChainId == 30110) { return ChainIds.ARBITRUM; } else if (nativeChainId == 30111) { return ChainIds.OPTIMISM; } else if (nativeChainId == 30112) { return ChainIds.FANTOM; } else if (nativeChainId == 30116) { return ChainIds.HARMONY; } else if (nativeChainId == 30102) { return ChainIds.BNB; } else if (nativeChainId == 30151) { return ChainIds.METIS; } else if (nativeChainId == 30145) { return ChainIds.GNOSIS; } else if (nativeChainId == 30125) { return ChainIds.CELO; } else if (nativeChainId == 30332) { return ChainIds.SONIC; } else { return 0; } } /// @inheritdoc IBaseAdapter function infraToNativeChainId( uint256 infraChainId ) public pure virtual override returns (uint256) { if (infraChainId == ChainIds.ETHEREUM) { return 30101; } else if (infraChainId == ChainIds.AVALANCHE) { return 30106; } else if (infraChainId == ChainIds.POLYGON) { return 30109; } else if (infraChainId == ChainIds.ARBITRUM) { return 30110; } else if (infraChainId == ChainIds.OPTIMISM) { return 30111; } else if (infraChainId == ChainIds.FANTOM) { return 30112; } else if (infraChainId == ChainIds.HARMONY) { return 30116; } else if (infraChainId == ChainIds.METIS) { return 30151; } else if (infraChainId == ChainIds.BNB) { return 30102; } else if (infraChainId == ChainIds.GNOSIS) { return 30145; } else if (infraChainId == ChainIds.CELO) { return 30125; } else if (infraChainId == ChainIds.SONIC) { return 30332; } else { return uint16(0); } } /** * @notice method to generate LayerZero options * @param gasLimit the gas limit to use on destination chain * @return bytes with the packed options */ function _generateOptions(uint128 gasLimit) internal pure returns (bytes memory) { bytes memory options = OptionsBuilder.newOptions(); return OptionsBuilder.addExecutorLzReceiveOption(options, gasLimit, 0); } }
// SPDX-License-Identifier: MIT // Modified from commit: https://github.com/LayerZero-Labs/LayerZero-v2/commit/4b2985921af42a778d26a48c9dee7b9644812cbd pragma solidity ^0.8.0; import {Origin} from './ILayerZeroEndpointV2.sol'; interface ILayerZeroReceiver { /** * @dev Entry point for receiving messages or packets from the endpoint. * @param _origin The origin information containing the source endpoint and sender address. * - srcEid: The source chain endpoint ID. * - sender: The sender address on the src chain. * - nonce: The nonce of the message. * @param _guid The unique identifier for the received LayerZero message. * @param _message The payload of the received message. * @param _executor The address of the executor for the received message. * @param _extraData Additional arbitrary data provided by the corresponding executor. * * @dev Entry point for receiving msg/packet from the LayerZero endpoint. */ function lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) external payable; /** * @notice Retrieves the next nonce for a given source endpoint and sender address. * @dev _srcEid The source endpoint ID. * @dev _sender The sender address. * @return nonce The next nonce. * * @dev The path nonce starts from 1. If 0 is returned it means that there is NO nonce ordered enforcement. * @dev Is required by the off-chain executor to determine the OApp expects msg execution is ordered. * @dev This is also enforced by the OApp. * @dev By default this is NOT enabled. ie. nextNonce is hardcoded to return 0. */ function nextNonce(uint32 /*_srcEid*/, bytes32 /*_sender*/) external view returns (uint64 nonce); /** * @notice Checks if the path initialization is allowed based on the provided origin. * @param origin The origin information containing the source endpoint and sender address. * @return Whether the path has been initialized. * * @dev This indicates to the endpoint that the OApp has enabled msgs for this particular path to be received. * @dev This defaults to assuming if a peer has been set, its initialized. * Can be overridden by the OApp if there is other logic to determine this. */ function allowInitializePath(Origin calldata origin) external view returns (bool); }
// SPDX-License-Identifier: MIT // Modified from commit: https://github.com/LayerZero-Labs/LayerZero-v2/commit/4b2985921af42a778d26a48c9dee7b9644812cbd pragma solidity ^0.8.0; struct MessagingParams { uint32 dstEid; bytes32 receiver; bytes message; bytes options; bool payInLzToken; } struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; } struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; } struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; } interface ILayerZeroEndpointV2 { function quote( MessagingParams calldata _params, address _sender ) external view returns (MessagingFee memory); function send( MessagingParams calldata _params, address _refundAddress ) external payable returns (MessagingReceipt memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } /** * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump. */ function toUint(bool b) internal pure returns (uint256 u) { assembly ("memory-safe") { u := iszero(iszero(b)) } } }
// SPDX-License-Identifier: MIT // Modified from commit: https://github.com/LayerZero-Labs/LayerZero-v2/commit/bf4318b5e88e46400931bb4c1f6aa0343c035a79 pragma solidity ^0.8.0; import {BytesLib} from './BytesLib.sol'; import {SafeCast} from 'openzeppelin-contracts/contracts/utils/math/SafeCast.sol'; import {ExecutorOptions} from './ExecutorOptions.sol'; /** * @title OptionsBuilder * @dev Library for building and encoding various message options. */ library OptionsBuilder { using SafeCast for uint256; using BytesLib for bytes; // Constants for options types uint16 internal constant TYPE_3 = 3; // Custom error message error InvalidOptionType(uint16 optionType); // Modifier to ensure only options of type 3 are used modifier onlyType3(bytes memory _options) { if (_options.toUint16(0) != TYPE_3) revert InvalidOptionType(_options.toUint16(0)); _; } /** * @dev Creates a new options container with type 3. * @return options The newly created options container. */ function newOptions() internal pure returns (bytes memory) { return abi.encodePacked(TYPE_3); } /** * @dev Adds an executor LZ receive option to the existing options. * @param _options The existing options container. * @param _gas The gasLimit used on the lzReceive() function in the OApp. * @param _value The msg.value passed to the lzReceive() function in the OApp. * @return options The updated options container. * * @dev When multiples of this option are added, they are summed by the executor * eg. if (_gas: 200k, and _value: 1 ether) AND (_gas: 100k, _value: 0.5 ether) are sent in an option to the LayerZeroEndpoint, * that becomes (300k, 1.5 ether) when the message is executed on the remote lzReceive() function. */ function addExecutorLzReceiveOption( bytes memory _options, uint128 _gas, uint128 _value ) internal pure onlyType3(_options) returns (bytes memory) { bytes memory option = ExecutorOptions.encodeLzReceiveOption(_gas, _value); return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZRECEIVE, option); } /** * @dev Adds an executor option to the existing options. * @param _options The existing options container. * @param _optionType The type of the executor option. * @param _option The encoded data for the executor option. * @return options The updated options container. */ function addExecutorOption( bytes memory _options, uint8 _optionType, bytes memory _option ) internal pure onlyType3(_options) returns (bytes memory) { return abi.encodePacked( _options, ExecutorOptions.WORKER_ID, _option.length.toUint16() + 1, // +1 for optionType _optionType, _option ); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.8; import {IBaseAdapter, IBaseCrossChainController} from './IBaseAdapter.sol'; import {Errors} from '../libs/Errors.sol'; /** * @title BaseAdapter * @author BGD Labs * @notice base contract implementing the method to route a bridged message to the CrossChainController contract. * @dev All bridge adapters must implement this contract */ abstract contract BaseAdapter is IBaseAdapter { /// @inheritdoc IBaseAdapter IBaseCrossChainController public immutable CROSS_CHAIN_CONTROLLER; /// @inheritdoc IBaseAdapter uint256 public immutable BASE_GAS_LIMIT; // @dev this is the original address of the contract. Required to identify and prevent delegate calls. address private immutable _selfAddress; // (standard chain id -> origin forwarder address) saves for every chain the address that can forward messages to this adapter mapping(uint256 => address) internal _trustedRemotes; /// @inheritdoc IBaseAdapter string public adapterName; /** * @param crossChainController address of the CrossChainController the bridged messages will be routed to * @param providerGasLimit base gas limit used by the bridge adapter * @param name name of the bridge adapter contract * @param originConfigs pair of origin address and chain id that adapter is allowed to get messages from */ constructor( address crossChainController, uint256 providerGasLimit, string memory name, TrustedRemotesConfig[] memory originConfigs ) { require(crossChainController != address(0), Errors.INVALID_BASE_ADAPTER_CROSS_CHAIN_CONTROLLER); CROSS_CHAIN_CONTROLLER = IBaseCrossChainController(crossChainController); BASE_GAS_LIMIT = providerGasLimit; adapterName = name; _selfAddress = address(this); for (uint256 i = 0; i < originConfigs.length; i++) { TrustedRemotesConfig memory originConfig = originConfigs[i]; require(originConfig.originForwarder != address(0), Errors.INVALID_TRUSTED_REMOTE); _trustedRemotes[originConfig.originChainId] = originConfig.originForwarder; emit SetTrustedRemote(originConfig.originChainId, originConfig.originForwarder); } } /// @inheritdoc IBaseAdapter function nativeToInfraChainId(uint256 nativeChainId) public view virtual returns (uint256); /// @inheritdoc IBaseAdapter function infraToNativeChainId(uint256 infraChainId) public view virtual returns (uint256); /// @inheritdoc IBaseAdapter function setupPayments() external virtual {} /// @inheritdoc IBaseAdapter function getTrustedRemoteByChainId(uint256 chainId) external view returns (address) { return _trustedRemotes[chainId]; } /** * @notice calls CrossChainController to register the bridged payload * @param _payload bytes containing the bridged message * @param originChainId id of the chain where the message originated */ function _registerReceivedMessage(bytes calldata _payload, uint256 originChainId) internal { // this method should be always called via call require(address(this) == _selfAddress, Errors.DELEGATE_CALL_FORBIDDEN); CROSS_CHAIN_CONTROLLER.receiveCrossChainMessage(_payload, originChainId); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {ILayerZeroEndpointV2} from './interfaces/ILayerZeroEndpointV2.sol'; /** * @title ILayerZeroAdapter * @author BGD Labs * @notice interface containing the events, objects and method definitions used in the LayerZero bridge adapter */ interface ILayerZeroAdapter { /** * @notice returns the layer zero endpoint address * @return LayerZero endpoint address */ function LZ_ENDPOINT() external view returns (ILayerZeroEndpointV2); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {Vm} from 'forge-std/Vm.sol'; library ChainIds { uint256 internal constant MAINNET = 1; uint256 internal constant ETHEREUM = 1; uint256 internal constant OPTIMISM = 10; uint256 internal constant BNB = 56; uint256 internal constant POLYGON = 137; uint256 internal constant FANTOM = 250; uint256 internal constant ZKSYNC = 324; uint256 internal constant METIS = 1088; uint256 internal constant ZK_EVM = 1101; uint256 internal constant BASE = 8453; uint256 internal constant ARBITRUM = 42161; uint256 internal constant AVALANCHE = 43114; uint256 internal constant GNOSIS = 100; uint256 internal constant SCROLL = 534352; uint256 internal constant SEPOLIA = 11155111; uint256 internal constant HARMONY = 1666600000; uint256 internal constant CELO = 42220; uint256 internal constant POLYGON_ZK_EVM = 1101; uint256 internal constant LINEA = 59144; uint256 internal constant SONIC = 146; uint256 internal constant MANTLE = 5000; } library TestNetChainIds { uint256 internal constant ETHEREUM_SEPOLIA = 11155111; uint256 internal constant POLYGON_AMOY = 80002; uint256 internal constant AVALANCHE_FUJI = 43113; uint256 internal constant FANTOM_TESTNET = 4002; uint256 internal constant HARMONY_TESTNET = 1666700000; uint256 internal constant METIS_TESTNET = 599; uint256 internal constant BNB_TESTNET = 97; uint256 internal constant GNOSIS_CHIADO = 10200; uint256 internal constant SCROLL_SEPOLIA = 534351; uint256 internal constant BASE_SEPOLIA = 84532; uint256 internal constant CELO_ALFAJORES = 44787; uint256 internal constant OPTIMISM_SEPOLIA = 11155420; uint256 internal constant ARBITRUM_SEPOLIA = 421614; uint256 internal constant ZKSYNC_SEPOLIA = 300; uint256 internal constant LINEA_SEPOLIA = 59141; uint256 internal constant SONIC_BLAZE = 57054; uint256 internal constant MANTLE_SEPOLIA = 5003; } library ChainHelpers { error UnknownChainId(); function selectChain(Vm vm, uint256 chainId) internal returns (uint256, uint256) { uint256 previousFork = vm.activeFork(); if (chainId == block.chainid) return (previousFork, previousFork); uint256 newFork; if (chainId == ChainIds.MAINNET) { newFork = vm.createSelectFork(vm.rpcUrl('mainnet')); } else if (chainId == ChainIds.OPTIMISM) { newFork = vm.createSelectFork(vm.rpcUrl('optimism')); } else if (chainId == ChainIds.BNB) { newFork = vm.createSelectFork(vm.rpcUrl('bnb')); } else if (chainId == ChainIds.POLYGON) { newFork = vm.createSelectFork(vm.rpcUrl('polygon')); } else if (chainId == ChainIds.FANTOM) { newFork = vm.createSelectFork(vm.rpcUrl('fantom')); } else if (chainId == ChainIds.ZKSYNC) { newFork = vm.createSelectFork(vm.rpcUrl('zkSync')); } else if (chainId == ChainIds.METIS) { newFork = vm.createSelectFork(vm.rpcUrl('metis')); } else if (chainId == ChainIds.ZK_EVM) { newFork = vm.createSelectFork(vm.rpcUrl('zkEvm')); } else if (chainId == ChainIds.BASE) { newFork = vm.createSelectFork(vm.rpcUrl('base')); } else if (chainId == ChainIds.GNOSIS) { newFork = vm.createSelectFork(vm.rpcUrl('gnosis')); } else if (chainId == ChainIds.SCROLL) { newFork = vm.createSelectFork(vm.rpcUrl('scroll')); } else if (chainId == ChainIds.ARBITRUM) { newFork = vm.createSelectFork(vm.rpcUrl('arbitrum')); } else if (chainId == ChainIds.AVALANCHE) { newFork = vm.createSelectFork(vm.rpcUrl('avalanche')); } else if (chainId == ChainIds.SEPOLIA) { newFork = vm.createSelectFork(vm.rpcUrl('sepolia')); } else if (chainId == ChainIds.HARMONY) { newFork = vm.createSelectFork(vm.rpcUrl('harmony')); } else if (chainId == ChainIds.ZKSYNC) { newFork = vm.createSelectFork(vm.rpcUrl('zksync')); } else if (chainId == ChainIds.LINEA) { newFork = vm.createSelectFork(vm.rpcUrl('linea')); } else if (chainId == ChainIds.SONIC) { newFork = vm.createSelectFork(vm.rpcUrl('sonic')); } else if (chainId == ChainIds.MANTLE) { newFork = vm.createSelectFork(vm.rpcUrl('mantle')); } else { revert UnknownChainId(); } return (previousFork, newFork); } function getNetworkNameFromId(uint256 chainId) internal pure returns (string memory) { string memory networkName; if (chainId == ChainIds.ETHEREUM) { networkName = 'ethereum'; } else if (chainId == ChainIds.POLYGON) { networkName = 'polygon'; } else if (chainId == ChainIds.AVALANCHE) { networkName = 'avalanche'; } else if (chainId == ChainIds.ARBITRUM) { networkName = 'arbitrum'; } else if (chainId == ChainIds.OPTIMISM) { networkName = 'optimism'; } else if (chainId == ChainIds.METIS) { networkName = 'metis'; } else if (chainId == ChainIds.BNB) { networkName = 'binance'; } else if (chainId == ChainIds.BASE) { networkName = 'base'; } else if (chainId == ChainIds.POLYGON_ZK_EVM) { networkName = 'zkevm'; } else if (chainId == ChainIds.GNOSIS) { networkName = 'gnosis'; } else if (chainId == ChainIds.SCROLL) { networkName = 'scroll'; } else if (chainId == ChainIds.CELO) { networkName = 'celo'; } else if (chainId == ChainIds.ZKSYNC) { networkName = 'zksync'; } else if (chainId == ChainIds.LINEA) { networkName = 'linea'; } else if (chainId == ChainIds.SONIC) { networkName = 'sonic'; } else if (chainId == ChainIds.MANTLE) { networkName = 'mantle'; } // testnets else if (chainId == TestNetChainIds.ETHEREUM_SEPOLIA) { networkName = 'ethereum_sepolia'; } else if (chainId == TestNetChainIds.POLYGON_AMOY) { networkName = 'polygon_amoy'; } else if (chainId == TestNetChainIds.AVALANCHE_FUJI) { networkName = 'avalanche_fuji'; } else if (chainId == TestNetChainIds.ARBITRUM_SEPOLIA) { networkName = 'arbitrum_sepolia'; } else if (chainId == TestNetChainIds.OPTIMISM_SEPOLIA) { networkName = 'optimism_sepolia'; } else if (chainId == TestNetChainIds.METIS_TESTNET) { networkName = 'metis_test'; } else if (chainId == TestNetChainIds.BNB_TESTNET) { networkName = 'binance_testnet'; } else if (chainId == TestNetChainIds.BASE_SEPOLIA) { networkName = 'base_sepolia'; } else if (chainId == TestNetChainIds.GNOSIS_CHIADO) { networkName = 'gno_chiado'; } else if (chainId == TestNetChainIds.SCROLL_SEPOLIA) { networkName = 'scroll_sepolia'; } else if (chainId == TestNetChainIds.CELO_ALFAJORES) { networkName = 'celo_alfajores'; } else if (chainId == TestNetChainIds.ZKSYNC_SEPOLIA) { networkName = 'zksync_sepolia'; } else if (chainId == TestNetChainIds.LINEA_SEPOLIA) { networkName = 'linea_sepolia'; } else if (chainId == TestNetChainIds.SONIC_BLAZE) { networkName = 'sonic_blaze'; } else if (chainId == TestNetChainIds.MANTLE_SEPOLIA) { networkName = 'mantle_sepolia'; } else { revert('chain id is not supported'); } return networkName; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Errors library * @author BGD Labs * @notice Defines the error messages emitted by the different contracts of the Aave CrossChain Infrastructure */ library Errors { string public constant ETH_TRANSFER_FAILED = '1'; // failed to transfer eth to destination string public constant CALLER_IS_NOT_APPROVED_SENDER = '2'; // caller must be an approved message sender string public constant ENVELOPE_NOT_PREVIOUSLY_REGISTERED = '3'; // envelope can only be retried if it has been previously registered string public constant CURRENT_OR_DESTINATION_CHAIN_ADAPTER_NOT_SET = '4'; // can not enable bridge adapter if the current or destination chain adapter is 0 address string public constant CALLER_NOT_APPROVED_BRIDGE = '5'; // caller must be an approved bridge string public constant INVALID_VALIDITY_TIMESTAMP = '6'; // new validity timestamp is not correct (< last validity or in the future string public constant CALLER_NOT_CCIP_ROUTER = '7'; // caller must be bridge provider contract string public constant CCIP_ROUTER_CANT_BE_ADDRESS_0 = '8'; // CCIP bridge adapters needs a CCIP Router string public constant RECEIVER_NOT_SET = '9'; // receiver address on destination chain can not be 0 string public constant DESTINATION_CHAIN_ID_NOT_SUPPORTED = '10'; // destination chain id must be supported by bridge provider string public constant NOT_ENOUGH_VALUE_TO_PAY_BRIDGE_FEES = '11'; // cross chain controller does not have enough funds to forward the message string public constant REMOTE_NOT_TRUSTED = '12'; // remote address has not been registered as a trusted origin string public constant CALLER_NOT_HL_MAILBOX = '13'; // caller must be the HyperLane Mailbox contract string public constant NO_BRIDGE_ADAPTERS_FOR_SPECIFIED_CHAIN = '14'; // no bridge adapters are configured for the specified destination chain string public constant ONLY_ONE_EMERGENCY_UPDATE_PER_CHAIN = '15'; // only one emergency update is allowed at the time string public constant INVALID_REQUIRED_CONFIRMATIONS = '16'; // required confirmations must be less or equal than allowed adapters or bigger or equal than 1 string public constant DESTINATION_CHAIN_NOT_SAME_AS_CURRENT_CHAIN = '17'; // destination chain must be the same chain as the current chain where contract is deployed string public constant INVALID_BRIDGE_ADAPTER = '18'; // a bridge adapter address can not be the 0 address string public constant TRANSACTION_NOT_PREVIOUSLY_FORWARDED = '19'; // to retry sending a transaction, it needs to have been previously sent string public constant TRANSACTION_RETRY_FAILED = '20'; // transaction retry has failed (no bridge adapters where able to send) string public constant BRIDGE_ADAPTERS_SHOULD_BE_UNIQUE = '21'; // can not use the same bridge adapter twice string public constant ENVELOPE_NOT_CONFIRMED_OR_DELIVERED = '22'; // to deliver an envelope, this should have been previously confirmed string public constant INVALID_BASE_ADAPTER_CROSS_CHAIN_CONTROLLER = '23'; // crossChainController address can not be 0 string public constant DELEGATE_CALL_FORBIDDEN = '24'; // calling this function during delegatecall is forbidden string public constant CALLER_NOT_LZ_ENDPOINT = '25'; // caller must be the LayerZero endpoint contract string public constant INVALID_LZ_ENDPOINT = '26'; // LayerZero endpoint can't be 0 string public constant INVALID_TRUSTED_REMOTE = '27'; // trusted remote endpoint can't be 0 string public constant INVALID_EMERGENCY_ORACLE = '28'; // emergency oracle can not be 0 because if not, system could not be rescued on emergency string public constant NOT_IN_EMERGENCY = '29'; // execution can only happen when in an emergency string public constant LINK_TOKEN_CANT_BE_ADDRESS_0 = '30'; // link token address should be set string public constant CCIP_MESSAGE_IS_INVALID = '31'; // ccip message is not an accepted message string public constant ADAPTER_PAYMENT_SETUP_FAILED = '32'; // adapter payment setup failed string public constant CHAIN_ID_MISMATCH = '33'; // the message delivered to/from wrong network string public constant CALLER_NOT_OVM = '34'; // the caller must be the optimism ovm contract string public constant CALLER_NOT_FX_TUNNEL = '35'; // the caller must be the fx tunnel contract string public constant INVALID_SENDER = '36'; // sender can not be address 0 string public constant CALLER_NOT_GNOSIS_ARBITRARY_MESSAGE_BRIDGE = '37'; // the caller must be the Gnosis AMB contract string public constant ZERO_GNOSIS_ARBITRARY_MESSAGE_BRIDGE = '38'; // The passed Gnosis AMB contract is zero string public constant CALLER_NOT_ZK_EVM_BRIDGE = '39'; // the caller must be the zk evm bridge string public constant INVALID_HL_MAILBOX = '40'; // the Hyperlane mailbox address can not be 0 string public constant WORMHOLE_RELAYER_CANT_BE_ADDRESS_0 = '41'; // Wormhole relayer can not be address 0 string public constant CALLER_NOT_WORMHOLE_RELAYER = '42'; // caller must be the Wormhole relayer string public constant ZK_SYNC_BRIDGE_HUB_CANT_BE_ADDRESS_0 = '43'; // ZkSync Bridgehub can not be address 0 string public constant CL_GAS_PRICE_ORACLE_CANT_BE_ADDRESS_0 = '44'; // ChainLink gas price oracle can not be address 0 string public constant CALLER_NOT_LINEA_MESSAGE_SERVICE = '45'; // caller must be the Linea message service string public constant LINEA_MESSAGE_SERVICE_CANT_BE_ADDRESS_0 = '46'; // Linea message service can not be address 0 }
// SPDX-License-Identifier: Unlicense // Modified from commit: https://github.com/GNSPS/solidity-bytes-utils/commit/1dff13ef21304eb3634cb9e7f86c119cf280bd35 /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity ^0.8.0; library BytesLib { function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, 'toUint16_outOfBounds'); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } }
// SPDX-License-Identifier: LZBL-1.2 // Modified from commit: https://github.com/LayerZero-Labs/LayerZero-v2/commit/982c549236622c6bb9eaa6c65afcf1e0e559b624 pragma solidity ^0.8.0; library ExecutorOptions { uint8 internal constant WORKER_ID = 1; uint8 internal constant OPTION_TYPE_LZRECEIVE = 1; function encodeLzReceiveOption( uint128 _gas, uint128 _value ) internal pure returns (bytes memory) { return _value == 0 ? abi.encodePacked(_gas) : abi.encodePacked(_gas, _value); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IBaseCrossChainController} from '../interfaces/IBaseCrossChainController.sol'; /** * @title IBaseAdapter * @author BGD Labs * @notice interface containing the event and method used in all bridge adapters */ interface IBaseAdapter { /** * @notice emitted when a trusted remote is set * @param originChainId id of the chain where the trusted remote is from * @param originForwarder address of the contract that will send the messages */ event SetTrustedRemote(uint256 originChainId, address originForwarder); /** * @notice pair of origin address and origin chain * @param originForwarder address of the contract that will send the messages * @param originChainId id of the chain where the trusted remote is from */ struct TrustedRemotesConfig { address originForwarder; uint256 originChainId; } /** * @notice method that will bridge the payload to the chain specified * @param receiver address of the receiver contract on destination chain * @param executionGasLimit amount of the gas limit in wei to use for delivering the message on destination network. Each adapter will manage this as needed. * @param destinationChainId id of the destination chain in the bridge notation * @param message to send to the specified chain * @return the third-party bridge entrypoint, the third-party bridge message id */ function forwardMessage( address receiver, uint256 executionGasLimit, uint256 destinationChainId, bytes calldata message ) external returns (address, uint256); /** * @notice method to get the address of the linked cross chain controller * @return address of CrossChainController */ function CROSS_CHAIN_CONTROLLER() external returns (IBaseCrossChainController); /** * @notice method to get the name of the adapter contract * @return name of the adapter contract */ function adapterName() external view returns (string memory); /** * @notice method to get the base gas limit used by the bridge adapter */ function BASE_GAS_LIMIT() external returns (uint256); /** * @notice method used to setup payment, ie grant approvals over tokens used to pay for tx fees */ function setupPayments() external; /** * @notice method to get the trusted remote address from a specified chain id * @param chainId id of the chain from where to get the trusted remote * @return address of the trusted remote */ function getTrustedRemoteByChainId(uint256 chainId) external view returns (address); /** * @notice method to get infrastructure chain id from bridge native chain id * @param bridgeChainId bridge native chain id */ function nativeToInfraChainId(uint256 bridgeChainId) external returns (uint256); /** * @notice method to get bridge native chain id from native bridge chain id * @param infraChainId infrastructure chain id */ function infraToNativeChainId(uint256 infraChainId) external returns (uint256); }
// Automatically @generated by scripts/vm.py. Do not modify manually. // SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.6.2 <0.9.0; pragma experimental ABIEncoderV2; /// The `VmSafe` interface does not allow manipulation of the EVM state or other actions that may /// result in Script simulations differing from on-chain execution. It is recommended to only use /// these cheats in scripts. interface VmSafe { /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. enum CallerMode { // No caller modification is currently active. None, // A one time broadcast triggered by a `vm.broadcast()` call is currently active. Broadcast, // A recurrent broadcast triggered by a `vm.startBroadcast()` call is currently active. RecurrentBroadcast, // A one time prank triggered by a `vm.prank()` call is currently active. Prank, // A recurrent prank triggered by a `vm.startPrank()` call is currently active. RecurrentPrank } /// The kind of account access that occurred. enum AccountAccessKind { // The account was called. Call, // The account was called via delegatecall. DelegateCall, // The account was called via callcode. CallCode, // The account was called via staticcall. StaticCall, // The account was created. Create, // The account was selfdestructed. SelfDestruct, // Synthetic access indicating the current context has resumed after a previous sub-context (AccountAccess). Resume, // The account's balance was read. Balance, // The account's codesize was read. Extcodesize, // The account's codehash was read. Extcodehash, // The account's code was copied. Extcodecopy } /// Forge execution contexts. enum ForgeContext { // Test group execution context (test, coverage or snapshot). TestGroup, // `forge test` execution context. Test, // `forge coverage` execution context. Coverage, // `forge snapshot` execution context. Snapshot, // Script group execution context (dry run, broadcast or resume). ScriptGroup, // `forge script` execution context. ScriptDryRun, // `forge script --broadcast` execution context. ScriptBroadcast, // `forge script --resume` execution context. ScriptResume, // Unknown `forge` execution context. Unknown } /// The transaction type (`txType`) of the broadcast. enum BroadcastTxType { // Represents a CALL broadcast tx. Call, // Represents a CREATE broadcast tx. Create, // Represents a CREATE2 broadcast tx. Create2 } /// An Ethereum log. Returned by `getRecordedLogs`. struct Log { // The topics of the log, including the signature, if any. bytes32[] topics; // The raw data of the log. bytes data; // The address of the log's emitter. address emitter; } /// An RPC URL and its alias. Returned by `rpcUrlStructs`. struct Rpc { // The alias of the RPC URL. string key; // The RPC URL. string url; } /// An RPC log object. Returned by `eth_getLogs`. struct EthGetLogs { // The address of the log's emitter. address emitter; // The topics of the log, including the signature, if any. bytes32[] topics; // The raw data of the log. bytes data; // The block hash. bytes32 blockHash; // The block number. uint64 blockNumber; // The transaction hash. bytes32 transactionHash; // The transaction index in the block. uint64 transactionIndex; // The log index. uint256 logIndex; // Whether the log was removed. bool removed; } /// A single entry in a directory listing. Returned by `readDir`. struct DirEntry { // The error message, if any. string errorMessage; // The path of the entry. string path; // The depth of the entry. uint64 depth; // Whether the entry is a directory. bool isDir; // Whether the entry is a symlink. bool isSymlink; } /// Metadata information about a file. /// This structure is returned from the `fsMetadata` function and represents known /// metadata about a file such as its permissions, size, modification /// times, etc. struct FsMetadata { // True if this metadata is for a directory. bool isDir; // True if this metadata is for a symlink. bool isSymlink; // The size of the file, in bytes, this metadata is for. uint256 length; // True if this metadata is for a readonly (unwritable) file. bool readOnly; // The last modification time listed in this metadata. uint256 modified; // The last access time of this metadata. uint256 accessed; // The creation time listed in this metadata. uint256 created; } /// A wallet with a public and private key. struct Wallet { // The wallet's address. address addr; // The wallet's public key `X`. uint256 publicKeyX; // The wallet's public key `Y`. uint256 publicKeyY; // The wallet's private key. uint256 privateKey; } /// The result of a `tryFfi` call. struct FfiResult { // The exit code of the call. int32 exitCode; // The optionally hex-decoded `stdout` data. bytes stdout; // The `stderr` data. bytes stderr; } /// Information on the chain and fork. struct ChainInfo { // The fork identifier. Set to zero if no fork is active. uint256 forkId; // The chain ID of the current fork. uint256 chainId; } /// The result of a `stopAndReturnStateDiff` call. struct AccountAccess { // The chain and fork the access occurred. ChainInfo chainInfo; // The kind of account access that determines what the account is. // If kind is Call, DelegateCall, StaticCall or CallCode, then the account is the callee. // If kind is Create, then the account is the newly created account. // If kind is SelfDestruct, then the account is the selfdestruct recipient. // If kind is a Resume, then account represents a account context that has resumed. AccountAccessKind kind; // The account that was accessed. // It's either the account created, callee or a selfdestruct recipient for CREATE, CALL or SELFDESTRUCT. address account; // What accessed the account. address accessor; // If the account was initialized or empty prior to the access. // An account is considered initialized if it has code, a // non-zero nonce, or a non-zero balance. bool initialized; // The previous balance of the accessed account. uint256 oldBalance; // The potential new balance of the accessed account. // That is, all balance changes are recorded here, even if reverts occurred. uint256 newBalance; // Code of the account deployed by CREATE. bytes deployedCode; // Value passed along with the account access uint256 value; // Input data provided to the CREATE or CALL bytes data; // If this access reverted in either the current or parent context. bool reverted; // An ordered list of storage accesses made during an account access operation. StorageAccess[] storageAccesses; // Call depth traversed during the recording of state differences uint64 depth; } /// The storage accessed during an `AccountAccess`. struct StorageAccess { // The account whose storage was accessed. address account; // The slot that was accessed. bytes32 slot; // If the access was a write. bool isWrite; // The previous value of the slot. bytes32 previousValue; // The new value of the slot. bytes32 newValue; // If the access was reverted. bool reverted; } /// Gas used. Returned by `lastCallGas`. struct Gas { // The gas limit of the call. uint64 gasLimit; // The total gas used. uint64 gasTotalUsed; // DEPRECATED: The amount of gas used for memory expansion. Ref: <https://github.com/foundry-rs/foundry/pull/7934#pullrequestreview-2069236939> uint64 gasMemoryUsed; // The amount of gas refunded. int64 gasRefunded; // The amount of gas remaining. uint64 gasRemaining; } /// The result of the `stopDebugTraceRecording` call struct DebugStep { // The stack before executing the step of the run. // stack\[0\] represents the top of the stack. // and only stack data relevant to the opcode execution is contained. uint256[] stack; // The memory input data before executing the step of the run. // only input data relevant to the opcode execution is contained. // e.g. for MLOAD, it will have memory\[offset:offset+32\] copied here. // the offset value can be get by the stack data. bytes memoryInput; // The opcode that was accessed. uint8 opcode; // The call depth of the step. uint64 depth; // Whether the call end up with out of gas error. bool isOutOfGas; // The contract address where the opcode is running address contractAddr; } /// Represents a transaction's broadcast details. struct BroadcastTxSummary { // The hash of the transaction that was broadcasted bytes32 txHash; // Represent the type of transaction among CALL, CREATE, CREATE2 BroadcastTxType txType; // The address of the contract that was called or created. // This is address of the contract that is created if the txType is CREATE or CREATE2. address contractAddress; // The block number the transaction landed in. uint64 blockNumber; // Status of the transaction, retrieved from the transaction receipt. bool success; } /// Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation. struct SignedDelegation { // The y-parity of the recovered secp256k1 signature (0 or 1). uint8 v; // First 32 bytes of the signature. bytes32 r; // Second 32 bytes of the signature. bytes32 s; // The current nonce of the authority account at signing time. // Used to ensure signature can't be replayed after account nonce changes. uint64 nonce; // Address of the contract implementation that will be delegated to. // Gets encoded into delegation code: 0xef0100 || implementation. address implementation; } /// Represents a "potential" revert reason from a single subsequent call when using `vm.assumeNoReverts`. /// Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced /// as normal. struct PotentialRevert { // The allowed origin of the revert opcode; address(0) allows reverts from any address address reverter; // When true, only matches on the beginning of the revert data, otherwise, matches on entire revert data bool partialMatch; // The data to use to match encountered reverts bytes revertData; } // ======== Crypto ======== /// Derives a private key from the name, labels the account with that name, and returns the wallet. function createWallet(string calldata walletLabel) external returns (Wallet memory wallet); /// Generates a wallet from the private key and returns the wallet. function createWallet(uint256 privateKey) external returns (Wallet memory wallet); /// Generates a wallet from the private key, labels the account with that name, and returns the wallet. function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet); /// Derive a private key from a provided mnenomic string (or mnenomic file path) /// at the derivation path `m/44'/60'/0'/0/{index}`. function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey); /// Derive a private key from a provided mnenomic string (or mnenomic file path) /// at `{derivationPath}{index}`. function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index) external pure returns (uint256 privateKey); /// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language /// at the derivation path `m/44'/60'/0'/0/{index}`. function deriveKey(string calldata mnemonic, uint32 index, string calldata language) external pure returns (uint256 privateKey); /// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language /// at `{derivationPath}{index}`. function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language) external pure returns (uint256 privateKey); /// Derives secp256r1 public key from the provided `privateKey`. function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY); /// Adds a private key to the local forge wallet and returns the address. function rememberKey(uint256 privateKey) external returns (address keyAddr); /// Derive a set number of wallets from a mnemonic at the derivation path `m/44'/60'/0'/0/{0..count}`. /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned. function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) external returns (address[] memory keyAddrs); /// Derive a set number of wallets from a mnemonic in the specified language at the derivation path `m/44'/60'/0'/0/{0..count}`. /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned. function rememberKeys( string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count ) external returns (address[] memory keyAddrs); /// Signs data with a `Wallet`. /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the /// signature's `s` value, and the recovery id `v` in a single bytes32. /// This format reduces the signature size from 65 to 64 bytes. function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs); /// Signs `digest` with `privateKey` using the secp256k1 curve. /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the /// signature's `s` value, and the recovery id `v` in a single bytes32. /// This format reduces the signature size from 65 to 64 bytes. function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); /// Signs `digest` with signer provided to script using the secp256k1 curve. /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the /// signature's `s` value, and the recovery id `v` in a single bytes32. /// This format reduces the signature size from 65 to 64 bytes. /// If `--sender` is provided, the signer with provided address is used, otherwise, /// if exactly one signer is provided to the script, that signer is used. /// Raises error if signer passed through `--sender` does not match any unlocked signers or /// if `--sender` is not provided and not exactly one signer is passed to the script. function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs); /// Signs `digest` with signer provided to script using the secp256k1 curve. /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the /// signature's `s` value, and the recovery id `v` in a single bytes32. /// This format reduces the signature size from 65 to 64 bytes. /// Raises error if none of the signers passed into the script have provided address. function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); /// Signs `digest` with `privateKey` using the secp256r1 curve. function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); /// Signs data with a `Wallet`. function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); /// Signs `digest` with `privateKey` using the secp256k1 curve. function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); /// Signs `digest` with signer provided to script using the secp256k1 curve. /// If `--sender` is provided, the signer with provided address is used, otherwise, /// if exactly one signer is provided to the script, that signer is used. /// Raises error if signer passed through `--sender` does not match any unlocked signers or /// if `--sender` is not provided and not exactly one signer is passed to the script. function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); /// Signs `digest` with signer provided to script using the secp256k1 curve. /// Raises error if none of the signers passed into the script have provided address. function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); // ======== Environment ======== /// Gets the environment variable `name` and parses it as `address`. /// Reverts if the variable was not found or could not be parsed. function envAddress(string calldata name) external view returns (address value); /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`. /// Reverts if the variable was not found or could not be parsed. function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value); /// Gets the environment variable `name` and parses it as `bool`. /// Reverts if the variable was not found or could not be parsed. function envBool(string calldata name) external view returns (bool value); /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`. /// Reverts if the variable was not found or could not be parsed. function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value); /// Gets the environment variable `name` and parses it as `bytes32`. /// Reverts if the variable was not found or could not be parsed. function envBytes32(string calldata name) external view returns (bytes32 value); /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`. /// Reverts if the variable was not found or could not be parsed. function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value); /// Gets the environment variable `name` and parses it as `bytes`. /// Reverts if the variable was not found or could not be parsed. function envBytes(string calldata name) external view returns (bytes memory value); /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`. /// Reverts if the variable was not found or could not be parsed. function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value); /// Gets the environment variable `name` and returns true if it exists, else returns false. function envExists(string calldata name) external view returns (bool result); /// Gets the environment variable `name` and parses it as `int256`. /// Reverts if the variable was not found or could not be parsed. function envInt(string calldata name) external view returns (int256 value); /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`. /// Reverts if the variable was not found or could not be parsed. function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value); /// Gets the environment variable `name` and parses it as `bool`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, bool defaultValue) external view returns (bool value); /// Gets the environment variable `name` and parses it as `uint256`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value); /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) external view returns (address[] memory value); /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) external view returns (bytes32[] memory value); /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) external view returns (string[] memory value); /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) external view returns (bytes[] memory value); /// Gets the environment variable `name` and parses it as `int256`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, int256 defaultValue) external view returns (int256 value); /// Gets the environment variable `name` and parses it as `address`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, address defaultValue) external view returns (address value); /// Gets the environment variable `name` and parses it as `bytes32`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value); /// Gets the environment variable `name` and parses it as `string`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value); /// Gets the environment variable `name` and parses it as `bytes`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value); /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) external view returns (bool[] memory value); /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) external view returns (uint256[] memory value); /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) external view returns (int256[] memory value); /// Gets the environment variable `name` and parses it as `string`. /// Reverts if the variable was not found or could not be parsed. function envString(string calldata name) external view returns (string memory value); /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`. /// Reverts if the variable was not found or could not be parsed. function envString(string calldata name, string calldata delim) external view returns (string[] memory value); /// Gets the environment variable `name` and parses it as `uint256`. /// Reverts if the variable was not found or could not be parsed. function envUint(string calldata name) external view returns (uint256 value); /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`. /// Reverts if the variable was not found or could not be parsed. function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value); /// Returns true if `forge` command was executed in given context. function isContext(ForgeContext context) external view returns (bool result); /// Sets environment variables. function setEnv(string calldata name, string calldata value) external; // ======== EVM ======== /// Gets all accessed reads and write slot from a `vm.record` session, for a given address. function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots); /// Gets the address for a given private key. function addr(uint256 privateKey) external pure returns (address keyAddr); /// Gets all the logs according to specified filter. function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics) external returns (EthGetLogs[] memory logs); /// Gets the current `block.blobbasefee`. /// You should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction, /// and as a result will get optimized out by the compiler. /// See https://github.com/foundry-rs/foundry/issues/6180 function getBlobBaseFee() external view returns (uint256 blobBaseFee); /// Gets the current `block.number`. /// You should use this instead of `block.number` if you use `vm.roll`, as `block.number` is assumed to be constant across a transaction, /// and as a result will get optimized out by the compiler. /// See https://github.com/foundry-rs/foundry/issues/6180 function getBlockNumber() external view returns (uint256 height); /// Gets the current `block.timestamp`. /// You should use this instead of `block.timestamp` if you use `vm.warp`, as `block.timestamp` is assumed to be constant across a transaction, /// and as a result will get optimized out by the compiler. /// See https://github.com/foundry-rs/foundry/issues/6180 function getBlockTimestamp() external view returns (uint256 timestamp); /// Gets the map key and parent of a mapping at a given slot, for a given address. function getMappingKeyAndParentOf(address target, bytes32 elementSlot) external returns (bool found, bytes32 key, bytes32 parent); /// Gets the number of elements in the mapping at the given slot, for a given address. function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length); /// Gets the elements at index idx of the mapping at the given slot, for a given address. The /// index must be less than the length of the mapping (i.e. the number of keys in the mapping). function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value); /// Gets the nonce of an account. function getNonce(address account) external view returns (uint64 nonce); /// Get the nonce of a `Wallet`. function getNonce(Wallet calldata wallet) external returns (uint64 nonce); /// Gets all the recorded logs. function getRecordedLogs() external returns (Log[] memory logs); /// Returns state diffs from current `vm.startStateDiffRecording` session. function getStateDiff() external view returns (string memory diff); /// Returns state diffs from current `vm.startStateDiffRecording` session, in json format. function getStateDiffJson() external view returns (string memory diff); /// Gets the gas used in the last call from the callee perspective. function lastCallGas() external view returns (Gas memory gas); /// Loads a storage slot from an address. function load(address target, bytes32 slot) external view returns (bytes32 data); /// Pauses gas metering (i.e. gas usage is not counted). Noop if already paused. function pauseGasMetering() external; /// Records all storage reads and writes. function record() external; /// Record all the transaction logs. function recordLogs() external; /// Reset gas metering (i.e. gas usage is set to gas limit). function resetGasMetering() external; /// Resumes gas metering (i.e. gas usage is counted again). Noop if already on. function resumeGasMetering() external; /// Performs an Ethereum JSON-RPC request to the current fork URL. function rpc(string calldata method, string calldata params) external returns (bytes memory data); /// Performs an Ethereum JSON-RPC request to the given endpoint. function rpc(string calldata urlOrAlias, string calldata method, string calldata params) external returns (bytes memory data); /// Records the debug trace during the run. function startDebugTraceRecording() external; /// Starts recording all map SSTOREs for later retrieval. function startMappingRecording() external; /// Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order, /// along with the context of the calls function startStateDiffRecording() external; /// Stop debug trace recording and returns the recorded debug trace. function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step); /// Returns an ordered array of all account accesses from a `vm.startStateDiffRecording` session. function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses); /// Stops recording all map SSTOREs for later retrieval and clears the recorded data. function stopMappingRecording() external; // ======== Filesystem ======== /// Closes file for reading, resetting the offset and allowing to read it from beginning with readLine. /// `path` is relative to the project root. function closeFile(string calldata path) external; /// Copies the contents of one file to another. This function will **overwrite** the contents of `to`. /// On success, the total number of bytes copied is returned and it is equal to the length of the `to` file as reported by `metadata`. /// Both `from` and `to` are relative to the project root. function copyFile(string calldata from, string calldata to) external returns (uint64 copied); /// Creates a new, empty directory at the provided path. /// This cheatcode will revert in the following situations, but is not limited to just these cases: /// - User lacks permissions to modify `path`. /// - A parent of the given path doesn't exist and `recursive` is false. /// - `path` already exists and `recursive` is false. /// `path` is relative to the project root. function createDir(string calldata path, bool recursive) external; /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional. function deployCode(string calldata artifactPath) external returns (address deployedAddress); /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional. /// Additionally accepts abi-encoded constructor arguments. function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress); /// Returns true if the given path points to an existing entity, else returns false. function exists(string calldata path) external view returns (bool result); /// Performs a foreign function call via the terminal. function ffi(string[] calldata commandInput) external returns (bytes memory result); /// Given a path, query the file system to get information about a file, directory, etc. function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); /// Gets the artifact path from code (aka. creation code). function getArtifactPathByCode(bytes calldata code) external view returns (string memory path); /// Gets the artifact path from deployed code (aka. runtime code). function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path); /// Returns the most recent broadcast for the given contract on `chainId` matching `txType`. /// For example: /// The most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`. /// The most recent call can be fetched by passing `txType` as `CALL`. function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory); /// Returns all broadcasts for the given contract on `chainId` with the specified `txType`. /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory); /// Returns all broadcasts for the given contract on `chainId`. /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. function getBroadcasts(string calldata contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory); /// Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional. function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); /// Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional. function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); /// Returns the most recent deployment for the current `chainId`. function getDeployment(string calldata contractName) external view returns (address deployedAddress); /// Returns the most recent deployment for the given contract on `chainId` function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress); /// Returns all deployments for the given contract on `chainId` /// Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber. /// The most recent deployment is the first element, and the oldest is the last. function getDeployments(string calldata contractName, uint64 chainId) external view returns (address[] memory deployedAddresses); /// Returns true if the path exists on disk and is pointing at a directory, else returns false. function isDir(string calldata path) external view returns (bool result); /// Returns true if the path exists on disk and is pointing at a regular file, else returns false. function isFile(string calldata path) external view returns (bool result); /// Get the path of the current project root. function projectRoot() external view returns (string memory path); /// Prompts the user for a string value in the terminal. function prompt(string calldata promptText) external returns (string memory input); /// Prompts the user for an address in the terminal. function promptAddress(string calldata promptText) external returns (address); /// Prompts the user for a hidden string value in the terminal. function promptSecret(string calldata promptText) external returns (string memory input); /// Prompts the user for hidden uint256 in the terminal (usually pk). function promptSecretUint(string calldata promptText) external returns (uint256); /// Prompts the user for uint256 in the terminal. function promptUint(string calldata promptText) external returns (uint256); /// Reads the directory at the given path recursively, up to `maxDepth`. /// `maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned. /// Follows symbolic links if `followLinks` is true. function readDir(string calldata path) external view returns (DirEntry[] memory entries); /// See `readDir(string)`. function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries); /// See `readDir(string)`. function readDir(string calldata path, uint64 maxDepth, bool followLinks) external view returns (DirEntry[] memory entries); /// Reads the entire content of file to string. `path` is relative to the project root. function readFile(string calldata path) external view returns (string memory data); /// Reads the entire content of file as binary. `path` is relative to the project root. function readFileBinary(string calldata path) external view returns (bytes memory data); /// Reads next line of file to string. function readLine(string calldata path) external view returns (string memory line); /// Reads a symbolic link, returning the path that the link points to. /// This cheatcode will revert in the following situations, but is not limited to just these cases: /// - `path` is not a symbolic link. /// - `path` does not exist. function readLink(string calldata linkPath) external view returns (string memory targetPath); /// Removes a directory at the provided path. /// This cheatcode will revert in the following situations, but is not limited to just these cases: /// - `path` doesn't exist. /// - `path` isn't a directory. /// - User lacks permissions to modify `path`. /// - The directory is not empty and `recursive` is false. /// `path` is relative to the project root. function removeDir(string calldata path, bool recursive) external; /// Removes a file from the filesystem. /// This cheatcode will revert in the following situations, but is not limited to just these cases: /// - `path` points to a directory. /// - The file doesn't exist. /// - The user lacks permissions to remove the file. /// `path` is relative to the project root. function removeFile(string calldata path) external; /// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr. function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result); /// Returns the time since unix epoch in milliseconds. function unixTime() external view returns (uint256 milliseconds); /// Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does. /// `path` is relative to the project root. function writeFile(string calldata path, string calldata data) external; /// Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does. /// `path` is relative to the project root. function writeFileBinary(string calldata path, bytes calldata data) external; /// Writes line to file, creating a file if it does not exist. /// `path` is relative to the project root. function writeLine(string calldata path, string calldata data) external; // ======== JSON ======== /// Checks if `key` exists in a JSON object. function keyExistsJson(string calldata json, string calldata key) external view returns (bool); /// Parses a string of JSON data at `key` and coerces it to `address`. function parseJsonAddress(string calldata json, string calldata key) external pure returns (address); /// Parses a string of JSON data at `key` and coerces it to `address[]`. function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory); /// Parses a string of JSON data at `key` and coerces it to `bool`. function parseJsonBool(string calldata json, string calldata key) external pure returns (bool); /// Parses a string of JSON data at `key` and coerces it to `bool[]`. function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory); /// Parses a string of JSON data at `key` and coerces it to `bytes`. function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory); /// Parses a string of JSON data at `key` and coerces it to `bytes32`. function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32); /// Parses a string of JSON data at `key` and coerces it to `bytes32[]`. function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory); /// Parses a string of JSON data at `key` and coerces it to `bytes[]`. function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory); /// Parses a string of JSON data at `key` and coerces it to `int256`. function parseJsonInt(string calldata json, string calldata key) external pure returns (int256); /// Parses a string of JSON data at `key` and coerces it to `int256[]`. function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory); /// Returns an array of all the keys in a JSON object. function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys); /// Parses a string of JSON data at `key` and coerces it to `string`. function parseJsonString(string calldata json, string calldata key) external pure returns (string memory); /// Parses a string of JSON data at `key` and coerces it to `string[]`. function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory); /// Parses a string of JSON data at `key` and coerces it to type array corresponding to `typeDescription`. function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory); /// Parses a string of JSON data and coerces it to type corresponding to `typeDescription`. function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory); /// Parses a string of JSON data at `key` and coerces it to type corresponding to `typeDescription`. function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory); /// Parses a string of JSON data at `key` and coerces it to `uint256`. function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256); /// Parses a string of JSON data at `key` and coerces it to `uint256[]`. function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory); /// ABI-encodes a JSON object. function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData); /// ABI-encodes a JSON object at `key`. function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData); /// See `serializeJson`. function serializeAddress(string calldata objectKey, string calldata valueKey, address value) external returns (string memory json); /// See `serializeJson`. function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values) external returns (string memory json); /// See `serializeJson`. function serializeBool(string calldata objectKey, string calldata valueKey, bool value) external returns (string memory json); /// See `serializeJson`. function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values) external returns (string memory json); /// See `serializeJson`. function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value) external returns (string memory json); /// See `serializeJson`. function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values) external returns (string memory json); /// See `serializeJson`. function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value) external returns (string memory json); /// See `serializeJson`. function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values) external returns (string memory json); /// See `serializeJson`. function serializeInt(string calldata objectKey, string calldata valueKey, int256 value) external returns (string memory json); /// See `serializeJson`. function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values) external returns (string memory json); /// Serializes a key and value to a JSON object stored in-memory that can be later written to a file. /// Returns the stringified version of the specific JSON file up to that moment. function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json); /// See `serializeJson`. function serializeJsonType(string calldata typeDescription, bytes calldata value) external pure returns (string memory json); /// See `serializeJson`. function serializeJsonType( string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes calldata value ) external returns (string memory json); /// See `serializeJson`. function serializeString(string calldata objectKey, string calldata valueKey, string calldata value) external returns (string memory json); /// See `serializeJson`. function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values) external returns (string memory json); /// See `serializeJson`. function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value) external returns (string memory json); /// See `serializeJson`. function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value) external returns (string memory json); /// See `serializeJson`. function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values) external returns (string memory json); /// Write a serialized JSON object to a file. If the file exists, it will be overwritten. function writeJson(string calldata json, string calldata path) external; /// Write a serialized JSON object to an **existing** JSON file, replacing a value with key = <value_key.> /// This is useful to replace a specific value of a JSON file, without having to parse the entire thing. function writeJson(string calldata json, string calldata path, string calldata valueKey) external; /// Checks if `key` exists in a JSON object /// `keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions. function keyExists(string calldata json, string calldata key) external view returns (bool); // ======== Scripting ======== /// Designate the next call as an EIP-7702 transaction function attachDelegation(SignedDelegation calldata signedDelegation) external; /// Takes a signed transaction and broadcasts it to the network. function broadcastRawTransaction(bytes calldata data) external; /// Has the next call (at this call depth only) create transactions that can later be signed and sent onchain. /// Broadcasting address is determined by checking the following in order: /// 1. If `--sender` argument was provided, that address is used. /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used. /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used. function broadcast() external; /// Has the next call (at this call depth only) create a transaction with the address provided /// as the sender that can later be signed and sent onchain. function broadcast(address signer) external; /// Has the next call (at this call depth only) create a transaction with the private key /// provided as the sender that can later be signed and sent onchain. function broadcast(uint256 privateKey) external; /// Returns addresses of available unlocked wallets in the script environment. function getWallets() external returns (address[] memory wallets); /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction function signAndAttachDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation); /// Sign an EIP-7702 authorization for delegation function signDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation); /// Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain. /// Broadcasting address is determined by checking the following in order: /// 1. If `--sender` argument was provided, that address is used. /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used. /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used. function startBroadcast() external; /// Has all subsequent calls (at this call depth only) create transactions with the address /// provided that can later be signed and sent onchain. function startBroadcast(address signer) external; /// Has all subsequent calls (at this call depth only) create transactions with the private key /// provided that can later be signed and sent onchain. function startBroadcast(uint256 privateKey) external; /// Stops collecting onchain transactions. function stopBroadcast() external; // ======== String ======== /// Returns true if `search` is found in `subject`, false otherwise. function contains(string calldata subject, string calldata search) external returns (bool result); /// Returns the index of the first occurrence of a `key` in an `input` string. /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found. /// Returns 0 in case of an empty `key`. function indexOf(string calldata input, string calldata key) external pure returns (uint256); /// Parses the given `string` into an `address`. function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue); /// Parses the given `string` into a `bool`. function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue); /// Parses the given `string` into `bytes`. function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue); /// Parses the given `string` into a `bytes32`. function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue); /// Parses the given `string` into a `int256`. function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue); /// Parses the given `string` into a `uint256`. function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue); /// Replaces occurrences of `from` in the given `string` with `to`. function replace(string calldata input, string calldata from, string calldata to) external pure returns (string memory output); /// Splits the given `string` into an array of strings divided by the `delimiter`. function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs); /// Converts the given `string` value to Lowercase. function toLowercase(string calldata input) external pure returns (string memory output); /// Converts the given value to a `string`. function toString(address value) external pure returns (string memory stringifiedValue); /// Converts the given value to a `string`. function toString(bytes calldata value) external pure returns (string memory stringifiedValue); /// Converts the given value to a `string`. function toString(bytes32 value) external pure returns (string memory stringifiedValue); /// Converts the given value to a `string`. function toString(bool value) external pure returns (string memory stringifiedValue); /// Converts the given value to a `string`. function toString(uint256 value) external pure returns (string memory stringifiedValue); /// Converts the given value to a `string`. function toString(int256 value) external pure returns (string memory stringifiedValue); /// Converts the given `string` value to Uppercase. function toUppercase(string calldata input) external pure returns (string memory output); /// Trims leading and trailing whitespace from the given `string` value. function trim(string calldata input) external pure returns (string memory output); // ======== Testing ======== /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`. /// Formats values with decimals in failure message. function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure; /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertApproxEqAbsDecimal( uint256 left, uint256 right, uint256 maxDelta, uint256 decimals, string calldata error ) external pure; /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. /// Formats values with decimals in failure message. function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure; /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertApproxEqAbsDecimal( int256 left, int256 right, uint256 maxDelta, uint256 decimals, string calldata error ) external pure; /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`. function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure; /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`. /// Includes error message into revert string on failure. function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) external pure; /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure; /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. /// Includes error message into revert string on failure. function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata error) external pure; /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% /// Formats values with decimals in failure message. function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals) external pure; /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertApproxEqRelDecimal( uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals, string calldata error ) external pure; /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% /// Formats values with decimals in failure message. function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals) external pure; /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertApproxEqRelDecimal( int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals, string calldata error ) external pure; /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure; /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% /// Includes error message into revert string on failure. function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error) external pure; /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure; /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% /// Includes error message into revert string on failure. function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) external pure; /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message. function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure; /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message. /// Includes error message into revert string on failure. function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; /// Asserts that two `int256` values are equal, formatting them with decimals in failure message. function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure; /// Asserts that two `int256` values are equal, formatting them with decimals in failure message. /// Includes error message into revert string on failure. function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; /// Asserts that two `bool` values are equal. function assertEq(bool left, bool right) external pure; /// Asserts that two `bool` values are equal and includes error message into revert string on failure. function assertEq(bool left, bool right, string calldata error) external pure; /// Asserts that two `string` values are equal. function assertEq(string calldata left, string calldata right) external pure; /// Asserts that two `string` values are equal and includes error message into revert string on failure. function assertEq(string calldata left, string calldata right, string calldata error) external pure; /// Asserts that two `bytes` values are equal. function assertEq(bytes calldata left, bytes calldata right) external pure; /// Asserts that two `bytes` values are equal and includes error message into revert string on failure. function assertEq(bytes calldata left, bytes calldata right, string calldata error) external pure; /// Asserts that two arrays of `bool` values are equal. function assertEq(bool[] calldata left, bool[] calldata right) external pure; /// Asserts that two arrays of `bool` values are equal and includes error message into revert string on failure. function assertEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `uint256 values are equal. function assertEq(uint256[] calldata left, uint256[] calldata right) external pure; /// Asserts that two arrays of `uint256` values are equal and includes error message into revert string on failure. function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `int256` values are equal. function assertEq(int256[] calldata left, int256[] calldata right) external pure; /// Asserts that two arrays of `int256` values are equal and includes error message into revert string on failure. function assertEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure; /// Asserts that two `uint256` values are equal. function assertEq(uint256 left, uint256 right) external pure; /// Asserts that two arrays of `address` values are equal. function assertEq(address[] calldata left, address[] calldata right) external pure; /// Asserts that two arrays of `address` values are equal and includes error message into revert string on failure. function assertEq(address[] calldata left, address[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `bytes32` values are equal. function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure; /// Asserts that two arrays of `bytes32` values are equal and includes error message into revert string on failure. function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `string` values are equal. function assertEq(string[] calldata left, string[] calldata right) external pure; /// Asserts that two arrays of `string` values are equal and includes error message into revert string on failure. function assertEq(string[] calldata left, string[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `bytes` values are equal. function assertEq(bytes[] calldata left, bytes[] calldata right) external pure; /// Asserts that two arrays of `bytes` values are equal and includes error message into revert string on failure. function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure; /// Asserts that two `uint256` values are equal and includes error message into revert string on failure. function assertEq(uint256 left, uint256 right, string calldata error) external pure; /// Asserts that two `int256` values are equal. function assertEq(int256 left, int256 right) external pure; /// Asserts that two `int256` values are equal and includes error message into revert string on failure. function assertEq(int256 left, int256 right, string calldata error) external pure; /// Asserts that two `address` values are equal. function assertEq(address left, address right) external pure; /// Asserts that two `address` values are equal and includes error message into revert string on failure. function assertEq(address left, address right, string calldata error) external pure; /// Asserts that two `bytes32` values are equal. function assertEq(bytes32 left, bytes32 right) external pure; /// Asserts that two `bytes32` values are equal and includes error message into revert string on failure. function assertEq(bytes32 left, bytes32 right, string calldata error) external pure; /// Asserts that the given condition is false. function assertFalse(bool condition) external pure; /// Asserts that the given condition is false and includes error message into revert string on failure. function assertFalse(bool condition, string calldata error) external pure; /// Compares two `uint256` values. Expects first value to be greater than or equal to second. /// Formats values with decimals in failure message. function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure; /// Compares two `uint256` values. Expects first value to be greater than or equal to second. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; /// Compares two `int256` values. Expects first value to be greater than or equal to second. /// Formats values with decimals in failure message. function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure; /// Compares two `int256` values. Expects first value to be greater than or equal to second. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; /// Compares two `uint256` values. Expects first value to be greater than or equal to second. function assertGe(uint256 left, uint256 right) external pure; /// Compares two `uint256` values. Expects first value to be greater than or equal to second. /// Includes error message into revert string on failure. function assertGe(uint256 left, uint256 right, string calldata error) external pure; /// Compares two `int256` values. Expects first value to be greater than or equal to second. function assertGe(int256 left, int256 right) external pure; /// Compares two `int256` values. Expects first value to be greater than or equal to second. /// Includes error message into revert string on failure. function assertGe(int256 left, int256 right, string calldata error) external pure; /// Compares two `uint256` values. Expects first value to be greater than second. /// Formats values with decimals in failure message. function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure; /// Compares two `uint256` values. Expects first value to be greater than second. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; /// Compares two `int256` values. Expects first value to be greater than second. /// Formats values with decimals in failure message. function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure; /// Compares two `int256` values. Expects first value to be greater than second. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; /// Compares two `uint256` values. Expects first value to be greater than second. function assertGt(uint256 left, uint256 right) external pure; /// Compares two `uint256` values. Expects first value to be greater than second. /// Includes error message into revert string on failure. function assertGt(uint256 left, uint256 right, string calldata error) external pure; /// Compares two `int256` values. Expects first value to be greater than second. function assertGt(int256 left, int256 right) external pure; /// Compares two `int256` values. Expects first value to be greater than second. /// Includes error message into revert string on failure. function assertGt(int256 left, int256 right, string calldata error) external pure; /// Compares two `uint256` values. Expects first value to be less than or equal to second. /// Formats values with decimals in failure message. function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure; /// Compares two `uint256` values. Expects first value to be less than or equal to second. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; /// Compares two `int256` values. Expects first value to be less than or equal to second. /// Formats values with decimals in failure message. function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure; /// Compares two `int256` values. Expects first value to be less than or equal to second. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; /// Compares two `uint256` values. Expects first value to be less than or equal to second. function assertLe(uint256 left, uint256 right) external pure; /// Compares two `uint256` values. Expects first value to be less than or equal to second. /// Includes error message into revert string on failure. function assertLe(uint256 left, uint256 right, string calldata error) external pure; /// Compares two `int256` values. Expects first value to be less than or equal to second. function assertLe(int256 left, int256 right) external pure; /// Compares two `int256` values. Expects first value to be less than or equal to second. /// Includes error message into revert string on failure. function assertLe(int256 left, int256 right, string calldata error) external pure; /// Compares two `uint256` values. Expects first value to be less than second. /// Formats values with decimals in failure message. function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure; /// Compares two `uint256` values. Expects first value to be less than second. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; /// Compares two `int256` values. Expects first value to be less than second. /// Formats values with decimals in failure message. function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure; /// Compares two `int256` values. Expects first value to be less than second. /// Formats values with decimals in failure message. Includes error message into revert string on failure. function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; /// Compares two `uint256` values. Expects first value to be less than second. function assertLt(uint256 left, uint256 right) external pure; /// Compares two `uint256` values. Expects first value to be less than second. /// Includes error message into revert string on failure. function assertLt(uint256 left, uint256 right, string calldata error) external pure; /// Compares two `int256` values. Expects first value to be less than second. function assertLt(int256 left, int256 right) external pure; /// Compares two `int256` values. Expects first value to be less than second. /// Includes error message into revert string on failure. function assertLt(int256 left, int256 right, string calldata error) external pure; /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message. function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure; /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message. /// Includes error message into revert string on failure. function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message. function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure; /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message. /// Includes error message into revert string on failure. function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; /// Asserts that two `bool` values are not equal. function assertNotEq(bool left, bool right) external pure; /// Asserts that two `bool` values are not equal and includes error message into revert string on failure. function assertNotEq(bool left, bool right, string calldata error) external pure; /// Asserts that two `string` values are not equal. function assertNotEq(string calldata left, string calldata right) external pure; /// Asserts that two `string` values are not equal and includes error message into revert string on failure. function assertNotEq(string calldata left, string calldata right, string calldata error) external pure; /// Asserts that two `bytes` values are not equal. function assertNotEq(bytes calldata left, bytes calldata right) external pure; /// Asserts that two `bytes` values are not equal and includes error message into revert string on failure. function assertNotEq(bytes calldata left, bytes calldata right, string calldata error) external pure; /// Asserts that two arrays of `bool` values are not equal. function assertNotEq(bool[] calldata left, bool[] calldata right) external pure; /// Asserts that two arrays of `bool` values are not equal and includes error message into revert string on failure. function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `uint256` values are not equal. function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure; /// Asserts that two arrays of `uint256` values are not equal and includes error message into revert string on failure. function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `int256` values are not equal. function assertNotEq(int256[] calldata left, int256[] calldata right) external pure; /// Asserts that two arrays of `int256` values are not equal and includes error message into revert string on failure. function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure; /// Asserts that two `uint256` values are not equal. function assertNotEq(uint256 left, uint256 right) external pure; /// Asserts that two arrays of `address` values are not equal. function assertNotEq(address[] calldata left, address[] calldata right) external pure; /// Asserts that two arrays of `address` values are not equal and includes error message into revert string on failure. function assertNotEq(address[] calldata left, address[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `bytes32` values are not equal. function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure; /// Asserts that two arrays of `bytes32` values are not equal and includes error message into revert string on failure. function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `string` values are not equal. function assertNotEq(string[] calldata left, string[] calldata right) external pure; /// Asserts that two arrays of `string` values are not equal and includes error message into revert string on failure. function assertNotEq(string[] calldata left, string[] calldata right, string calldata error) external pure; /// Asserts that two arrays of `bytes` values are not equal. function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure; /// Asserts that two arrays of `bytes` values are not equal and includes error message into revert string on failure. function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure; /// Asserts that two `uint256` values are not equal and includes error message into revert string on failure. function assertNotEq(uint256 left, uint256 right, string calldata error) external pure; /// Asserts that two `int256` values are not equal. function assertNotEq(int256 left, int256 right) external pure; /// Asserts that two `int256` values are not equal and includes error message into revert string on failure. function assertNotEq(int256 left, int256 right, string calldata error) external pure; /// Asserts that two `address` values are not equal. function assertNotEq(address left, address right) external pure; /// Asserts that two `address` values are not equal and includes error message into revert string on failure. function assertNotEq(address left, address right, string calldata error) external pure; /// Asserts that two `bytes32` values are not equal. function assertNotEq(bytes32 left, bytes32 right) external pure; /// Asserts that two `bytes32` values are not equal and includes error message into revert string on failure. function assertNotEq(bytes32 left, bytes32 right, string calldata error) external pure; /// Asserts that the given condition is true. function assertTrue(bool condition) external pure; /// Asserts that the given condition is true and includes error message into revert string on failure. function assertTrue(bool condition, string calldata error) external pure; /// If the condition is false, discard this run's fuzz inputs and generate new ones. function assume(bool condition) external pure; /// Discard this run's fuzz inputs and generate new ones if next call reverted. function assumeNoRevert() external pure; /// Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters. function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure; /// Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters. function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure; /// Writes a breakpoint to jump to in the debugger. function breakpoint(string calldata char) external pure; /// Writes a conditional breakpoint to jump to in the debugger. function breakpoint(string calldata char, bool value) external pure; /// Returns the Foundry version. /// Format: <cargo_version>-<tag>+<git_sha_short>.<unix_build_timestamp>.<profile> /// Sample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug /// Note: Build timestamps may vary slightly across platforms due to separate CI jobs. /// For reliable version comparisons, use UNIX format (e.g., >= 1700000000) /// to compare timestamps while ignoring minor time differences. function getFoundryVersion() external view returns (string memory version); /// Returns the RPC url for the given alias. function rpcUrl(string calldata rpcAlias) external view returns (string memory json); /// Returns all rpc urls and their aliases as structs. function rpcUrlStructs() external view returns (Rpc[] memory urls); /// Returns all rpc urls and their aliases `[alias, url][]`. function rpcUrls() external view returns (string[2][] memory urls); /// Suspends execution of the main thread for `duration` milliseconds. function sleep(uint256 duration) external; // ======== Toml ======== /// Checks if `key` exists in a TOML table. function keyExistsToml(string calldata toml, string calldata key) external view returns (bool); /// Parses a string of TOML data at `key` and coerces it to `address`. function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address); /// Parses a string of TOML data at `key` and coerces it to `address[]`. function parseTomlAddressArray(string calldata toml, string calldata key) external pure returns (address[] memory); /// Parses a string of TOML data at `key` and coerces it to `bool`. function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool); /// Parses a string of TOML data at `key` and coerces it to `bool[]`. function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory); /// Parses a string of TOML data at `key` and coerces it to `bytes`. function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory); /// Parses a string of TOML data at `key` and coerces it to `bytes32`. function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32); /// Parses a string of TOML data at `key` and coerces it to `bytes32[]`. function parseTomlBytes32Array(string calldata toml, string calldata key) external pure returns (bytes32[] memory); /// Parses a string of TOML data at `key` and coerces it to `bytes[]`. function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory); /// Parses a string of TOML data at `key` and coerces it to `int256`. function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256); /// Parses a string of TOML data at `key` and coerces it to `int256[]`. function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory); /// Returns an array of all the keys in a TOML table. function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys); /// Parses a string of TOML data at `key` and coerces it to `string`. function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory); /// Parses a string of TOML data at `key` and coerces it to `string[]`. function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory); /// Parses a string of TOML data at `key` and coerces it to type array corresponding to `typeDescription`. function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory); /// Parses a string of TOML data and coerces it to type corresponding to `typeDescription`. function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory); /// Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`. function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory); /// Parses a string of TOML data at `key` and coerces it to `uint256`. function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256); /// Parses a string of TOML data at `key` and coerces it to `uint256[]`. function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory); /// ABI-encodes a TOML table. function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData); /// ABI-encodes a TOML table at `key`. function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData); /// Takes serialized JSON, converts to TOML and write a serialized TOML to a file. function writeToml(string calldata json, string calldata path) external; /// Takes serialized JSON, converts to TOML and write a serialized TOML table to an **existing** TOML file, replacing a value with key = <value_key.> /// This is useful to replace a specific value of a TOML file, without having to parse the entire thing. function writeToml(string calldata json, string calldata path, string calldata valueKey) external; // ======== Utilities ======== /// Compute the address of a contract created with CREATE2 using the given CREATE2 deployer. function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address); /// Compute the address of a contract created with CREATE2 using the default CREATE2 deployer. function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address); /// Compute the address a contract will be deployed at for a given deployer address and nonce. function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address); /// Utility cheatcode to copy storage of `from` contract to another `to` contract. function copyStorage(address from, address to) external; /// Returns ENS namehash for provided string. function ensNamehash(string calldata name) external pure returns (bytes32); /// Gets the label for the specified address. function getLabel(address account) external view returns (string memory currentLabel); /// Labels an address in call traces. function label(address account, string calldata newLabel) external; /// Pauses collection of call traces. Useful in cases when you want to skip tracing of /// complex calls which are not useful for debugging. function pauseTracing() external view; /// Returns a random `address`. function randomAddress() external returns (address); /// Returns a random `bool`. function randomBool() external view returns (bool); /// Returns a random byte array value of the given length. function randomBytes(uint256 len) external view returns (bytes memory); /// Returns a random fixed-size byte array of length 4. function randomBytes4() external view returns (bytes4); /// Returns a random fixed-size byte array of length 8. function randomBytes8() external view returns (bytes8); /// Returns a random `int256` value. function randomInt() external view returns (int256); /// Returns a random `int256` value of given bits. function randomInt(uint256 bits) external view returns (int256); /// Returns a random uint256 value. function randomUint() external returns (uint256); /// Returns random uint256 value between the provided range (=min..=max). function randomUint(uint256 min, uint256 max) external returns (uint256); /// Returns a random `uint256` value of given bits. function randomUint(uint256 bits) external view returns (uint256); /// Unpauses collection of call traces. function resumeTracing() external view; /// Utility cheatcode to set arbitrary storage for given target address. function setArbitraryStorage(address target) external; /// Encodes a `bytes` value to a base64url string. function toBase64URL(bytes calldata data) external pure returns (string memory); /// Encodes a `string` value to a base64url string. function toBase64URL(string calldata data) external pure returns (string memory); /// Encodes a `bytes` value to a base64 string. function toBase64(bytes calldata data) external pure returns (string memory); /// Encodes a `string` value to a base64 string. function toBase64(string calldata data) external pure returns (string memory); } /// The `Vm` interface does allow manipulation of the EVM state. These are all intended to be used /// in tests, but it is not recommended to use these cheats in scripts. interface Vm is VmSafe { // ======== EVM ======== /// Returns the identifier of the currently active fork. Reverts if no fork is currently active. function activeFork() external view returns (uint256 forkId); /// In forking mode, explicitly grant the given address cheatcode access. function allowCheatcodes(address account) external; /// Sets `block.blobbasefee` function blobBaseFee(uint256 newBlobBaseFee) external; /// Sets the blobhashes in the transaction. /// Not available on EVM versions before Cancun. /// If used on unsupported EVM versions it will revert. function blobhashes(bytes32[] calldata hashes) external; /// Sets `block.chainid`. function chainId(uint256 newChainId) external; /// Clears all mocked calls. function clearMockedCalls() external; /// Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state. function cloneAccount(address source, address target) external; /// Sets `block.coinbase`. function coinbase(address newCoinbase) external; /// Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork. function createFork(string calldata urlOrAlias) external returns (uint256 forkId); /// Creates a new fork with the given endpoint and block and returns the identifier of the fork. function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId); /// Creates a new fork with the given endpoint and at the block the given transaction was mined in, /// replays all transaction mined in the block before the transaction, and returns the identifier of the fork. function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId); /// Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork. function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId); /// Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork. function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId); /// Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in, /// replays all transaction mined in the block before the transaction, returns the identifier of the fork. function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId); /// Sets an address' balance. function deal(address account, uint256 newBalance) external; /// Removes the snapshot with the given ID created by `snapshot`. /// Takes the snapshot ID to delete. /// Returns `true` if the snapshot was successfully deleted. /// Returns `false` if the snapshot does not exist. function deleteStateSnapshot(uint256 snapshotId) external returns (bool success); /// Removes _all_ snapshots previously created by `snapshot`. function deleteStateSnapshots() external; /// Sets `block.difficulty`. /// Not available on EVM versions from Paris onwards. Use `prevrandao` instead. /// Reverts if used on unsupported EVM versions. function difficulty(uint256 newDifficulty) external; /// Dump a genesis JSON file's `allocs` to disk. function dumpState(string calldata pathToStateJson) external; /// Sets an address' code. function etch(address target, bytes calldata newRuntimeBytecode) external; /// Sets `block.basefee`. function fee(uint256 newBasefee) external; /// Gets the blockhashes from the current transaction. /// Not available on EVM versions before Cancun. /// If used on unsupported EVM versions it will revert. function getBlobhashes() external view returns (bytes32[] memory hashes); /// Returns true if the account is marked as persistent. function isPersistent(address account) external view returns (bool persistent); /// Load a genesis JSON file's `allocs` into the in-memory EVM state. function loadAllocs(string calldata pathToAllocsJson) external; /// Marks that the account(s) should use persistent storage across fork swaps in a multifork setup /// Meaning, changes made to the state of this account will be kept when switching forks. function makePersistent(address account) external; /// See `makePersistent(address)`. function makePersistent(address account0, address account1) external; /// See `makePersistent(address)`. function makePersistent(address account0, address account1, address account2) external; /// See `makePersistent(address)`. function makePersistent(address[] calldata accounts) external; /// Reverts a call to an address with specified revert data. function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external; /// Reverts a call to an address with a specific `msg.value`, with specified revert data. function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external; /// Reverts a call to an address with specified revert data. /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`. function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external; /// Reverts a call to an address with a specific `msg.value`, with specified revert data. /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`. function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) external; /// Mocks a call to an address, returning specified data. /// Calldata can either be strict or a partial match, e.g. if you only /// pass a Solidity selector to the expected calldata, then the entire Solidity /// function will be mocked. function mockCall(address callee, bytes calldata data, bytes calldata returnData) external; /// Mocks a call to an address with a specific `msg.value`, returning specified data. /// Calldata match takes precedence over `msg.value` in case of ambiguity. function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external; /// Mocks a call to an address, returning specified data. /// Calldata can either be strict or a partial match, e.g. if you only /// pass a Solidity selector to the expected calldata, then the entire Solidity /// function will be mocked. /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`. function mockCall(address callee, bytes4 data, bytes calldata returnData) external; /// Mocks a call to an address with a specific `msg.value`, returning specified data. /// Calldata match takes precedence over `msg.value` in case of ambiguity. /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`. function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external; /// Mocks multiple calls to an address, returning specified data for each call. function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external; /// Mocks multiple calls to an address with a specific `msg.value`, returning specified data for each call. function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external; /// Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls /// `target` with the same calldata. This functionality is similar to a delegate call made to /// `target` contract from `callee`. /// Can be used to substitute a call to a function with another implementation that captures /// the primary logic of the original function but is easier to reason about. /// If calldata is not a strict match then partial match by selector is attempted. function mockFunction(address callee, address target, bytes calldata data) external; /// Sets the *next* call's `msg.sender` to be the input address. function prank(address msgSender) external; /// Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input. function prank(address msgSender, address txOrigin) external; /// Sets the *next* delegate call's `msg.sender` to be the input address. function prank(address msgSender, bool delegateCall) external; /// Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input. function prank(address msgSender, address txOrigin, bool delegateCall) external; /// Sets `block.prevrandao`. /// Not available on EVM versions before Paris. Use `difficulty` instead. /// If used on unsupported EVM versions it will revert. function prevrandao(bytes32 newPrevrandao) external; /// Sets `block.prevrandao`. /// Not available on EVM versions before Paris. Use `difficulty` instead. /// If used on unsupported EVM versions it will revert. function prevrandao(uint256 newPrevrandao) external; /// Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification. function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin); /// Resets the nonce of an account to 0 for EOAs and 1 for contract accounts. function resetNonce(address account) external; /// Revert the state of the EVM to a previous snapshot /// Takes the snapshot ID to revert to. /// Returns `true` if the snapshot was successfully reverted. /// Returns `false` if the snapshot does not exist. /// **Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteStateSnapshot`. function revertToState(uint256 snapshotId) external returns (bool success); /// Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots /// Takes the snapshot ID to revert to. /// Returns `true` if the snapshot was successfully reverted and deleted. /// Returns `false` if the snapshot does not exist. function revertToStateAndDelete(uint256 snapshotId) external returns (bool success); /// Revokes persistent status from the address, previously added via `makePersistent`. function revokePersistent(address account) external; /// See `revokePersistent(address)`. function revokePersistent(address[] calldata accounts) external; /// Sets `block.height`. function roll(uint256 newHeight) external; /// Updates the currently active fork to given block number /// This is similar to `roll` but for the currently active fork. function rollFork(uint256 blockNumber) external; /// Updates the currently active fork to given transaction. This will `rollFork` with the number /// of the block the transaction was mined in and replays all transaction mined before it in the block. function rollFork(bytes32 txHash) external; /// Updates the given fork to given block number. function rollFork(uint256 forkId, uint256 blockNumber) external; /// Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block. function rollFork(uint256 forkId, bytes32 txHash) external; /// Takes a fork identifier created by `createFork` and sets the corresponding forked state as active. function selectFork(uint256 forkId) external; /// Set blockhash for the current block. /// It only sets the blockhash for blocks where `block.number - 256 <= number < block.number`. function setBlockhash(uint256 blockNumber, bytes32 blockHash) external; /// Sets the nonce of an account. Must be higher than the current nonce of the account. function setNonce(address account, uint64 newNonce) external; /// Sets the nonce of an account to an arbitrary value. function setNonceUnsafe(address account, uint64 newNonce) external; /// Snapshot capture the gas usage of the last call by name from the callee perspective. function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed); /// Snapshot capture the gas usage of the last call by name in a group from the callee perspective. function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed); /// Snapshot the current state of the evm. /// Returns the ID of the snapshot that was created. /// To revert a snapshot use `revertToState`. function snapshotState() external returns (uint256 snapshotId); /// Snapshot capture an arbitrary numerical value by name. /// The group name is derived from the contract name. function snapshotValue(string calldata name, uint256 value) external; /// Snapshot capture an arbitrary numerical value by name in a group. function snapshotValue(string calldata group, string calldata name, uint256 value) external; /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called. function startPrank(address msgSender) external; /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input. function startPrank(address msgSender, address txOrigin) external; /// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called. function startPrank(address msgSender, bool delegateCall) external; /// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input. function startPrank(address msgSender, address txOrigin, bool delegateCall) external; /// Start a snapshot capture of the current gas usage by name. /// The group name is derived from the contract name. function startSnapshotGas(string calldata name) external; /// Start a snapshot capture of the current gas usage by name in a group. function startSnapshotGas(string calldata group, string calldata name) external; /// Resets subsequent calls' `msg.sender` to be `address(this)`. function stopPrank() external; /// Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start. function stopSnapshotGas() external returns (uint256 gasUsed); /// Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start. /// The group name is derived from the contract name. function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed); /// Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start. function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed); /// Stores a value to an address' storage slot. function store(address target, bytes32 slot, bytes32 value) external; /// Fetches the given transaction from the active fork and executes it on the current state. function transact(bytes32 txHash) external; /// Fetches the given transaction from the given fork and executes it on the current state. function transact(uint256 forkId, bytes32 txHash) external; /// Sets `tx.gasprice`. function txGasPrice(uint256 newGasPrice) external; /// Sets `block.timestamp`. function warp(uint256 newTimestamp) external; /// `deleteSnapshot` is being deprecated in favor of `deleteStateSnapshot`. It will be removed in future versions. function deleteSnapshot(uint256 snapshotId) external returns (bool success); /// `deleteSnapshots` is being deprecated in favor of `deleteStateSnapshots`. It will be removed in future versions. function deleteSnapshots() external; /// `revertToAndDelete` is being deprecated in favor of `revertToStateAndDelete`. It will be removed in future versions. function revertToAndDelete(uint256 snapshotId) external returns (bool success); /// `revertTo` is being deprecated in favor of `revertToState`. It will be removed in future versions. function revertTo(uint256 snapshotId) external returns (bool success); /// `snapshot` is being deprecated in favor of `snapshotState`. It will be removed in future versions. function snapshot() external returns (uint256 snapshotId); // ======== Testing ======== /// Expect a call to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas. function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external; /// Expect given number of calls to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas. function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count) external; /// Expects a call to an address with the specified calldata. /// Calldata can either be a strict or a partial match. function expectCall(address callee, bytes calldata data) external; /// Expects given number of calls to an address with the specified calldata. function expectCall(address callee, bytes calldata data, uint64 count) external; /// Expects a call to an address with the specified `msg.value` and calldata. function expectCall(address callee, uint256 msgValue, bytes calldata data) external; /// Expects given number of calls to an address with the specified `msg.value` and calldata. function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external; /// Expect a call to an address with the specified `msg.value`, gas, and calldata. function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external; /// Expects given number of calls to an address with the specified `msg.value`, gas, and calldata. function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external; /// Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans). function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external; /// Same as the previous method, but also checks supplied address against emitting contract. function expectEmitAnonymous( bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter ) external; /// Prepare an expected anonymous log with all topic and data checks enabled. /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if /// logs were emitted in the expected order with the expected topics and data. function expectEmitAnonymous() external; /// Same as the previous method, but also checks supplied address against emitting contract. function expectEmitAnonymous(address emitter) external; /// Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). /// Call this function, then emit an event, then call a function. Internally after the call, we check if /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans). function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external; /// Same as the previous method, but also checks supplied address against emitting contract. function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external; /// Prepare an expected log with all topic and data checks enabled. /// Call this function, then emit an event, then call a function. Internally after the call, we check if /// logs were emitted in the expected order with the expected topics and data. function expectEmit() external; /// Same as the previous method, but also checks supplied address against emitting contract. function expectEmit(address emitter) external; /// Expect a given number of logs with the provided topics. function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external; /// Expect a given number of logs from a specific emitter with the provided topics. function expectEmit( bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count ) external; /// Expect a given number of logs with all topic and data checks enabled. function expectEmit(uint64 count) external; /// Expect a given number of logs from a specific emitter with all topic and data checks enabled. function expectEmit(address emitter, uint64 count) external; /// Expects an error on next call that starts with the revert data. function expectPartialRevert(bytes4 revertData) external; /// Expects an error on next call to reverter address, that starts with the revert data. function expectPartialRevert(bytes4 revertData, address reverter) external; /// Expects an error on next call with any revert data. function expectRevert() external; /// Expects an error on next call that exactly matches the revert data. function expectRevert(bytes4 revertData) external; /// Expects a `count` number of reverts from the upcoming calls from the reverter address that match the revert data. function expectRevert(bytes4 revertData, address reverter, uint64 count) external; /// Expects a `count` number of reverts from the upcoming calls from the reverter address that exactly match the revert data. function expectRevert(bytes calldata revertData, address reverter, uint64 count) external; /// Expects an error on next call that exactly matches the revert data. function expectRevert(bytes calldata revertData) external; /// Expects an error with any revert data on next call to reverter address. function expectRevert(address reverter) external; /// Expects an error from reverter address on next call, with any revert data. function expectRevert(bytes4 revertData, address reverter) external; /// Expects an error from reverter address on next call, that exactly matches the revert data. function expectRevert(bytes calldata revertData, address reverter) external; /// Expects a `count` number of reverts from the upcoming calls with any revert data or reverter. function expectRevert(uint64 count) external; /// Expects a `count` number of reverts from the upcoming calls that match the revert data. function expectRevert(bytes4 revertData, uint64 count) external; /// Expects a `count` number of reverts from the upcoming calls that exactly match the revert data. function expectRevert(bytes calldata revertData, uint64 count) external; /// Expects a `count` number of reverts from the upcoming calls from the reverter address. function expectRevert(address reverter, uint64 count) external; /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other /// memory is written to, the test will fail. Can be called multiple times to add more ranges to the set. function expectSafeMemory(uint64 min, uint64 max) external; /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext. /// If any other memory is written to, the test will fail. Can be called multiple times to add more ranges /// to the set. function expectSafeMemoryCall(uint64 min, uint64 max) external; /// Marks a test as skipped. Must be called at the top level of a test. function skip(bool skipTest) external; /// Marks a test as skipped with a reason. Must be called at the top level of a test. function skip(bool skipTest, string calldata reason) external; /// Stops all safe memory expectation in the current subcontext. function stopExpectSafeMemory() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './ICrossChainForwarder.sol'; import './ICrossChainReceiver.sol'; import {IRescuable} from 'solidity-utils/contracts/utils/interfaces/IRescuable.sol'; /** * @title IBaseCrossChainController * @author BGD Labs * @notice interface containing the objects, events and methods definitions of the CrossChainController contract */ interface IBaseCrossChainController is IRescuable, ICrossChainForwarder, ICrossChainReceiver { }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; import {Transaction, Envelope} from '../libs/EncodingUtils.sol'; /** * @title ICrossChainForwarder * @author BGD Labs * @notice interface containing the objects, events and methods definitions of the CrossChainForwarder contract */ interface ICrossChainForwarder { /** * @notice Object containing the optimal bandwidth for communication with a receiver chain id * @param chainId id of the receiver chain * @param optimalBandwidth optimal number of bridge adapters to use to send a message to receiver chain */ struct OptimalBandwidthByChain { uint256 chainId; uint256 optimalBandwidth; } /** * @notice object storing the connected pair of bridge adapters, on current and destination chain * @param destinationBridgeAdapter address of the bridge adapter on the destination chain * @param currentChainBridgeAdapter address of the bridge adapter deployed on current network */ struct ChainIdBridgeConfig { address destinationBridgeAdapter; address currentChainBridgeAdapter; } /** * @notice object with the necessary information to remove bridge adapters * @param bridgeAdapter address of the bridge adapter to remove * @param chainIds array of chain ids where the bridge adapter connects */ struct BridgeAdapterToDisable { address bridgeAdapter; uint256[] chainIds; } /** * @notice object storing the pair bridgeAdapter (current deployed chain) destination chain bridge adapter configuration * @param currentChainBridgeAdapter address of the bridge adapter deployed on current chain * @param destinationBridgeAdapter address of the bridge adapter on the destination chain * @param destinationChainId id of the destination chain using our own nomenclature */ struct ForwarderBridgeAdapterConfigInput { address currentChainBridgeAdapter; address destinationBridgeAdapter; uint256 destinationChainId; } /** * @notice emitted when a transaction is successfully forwarded through a bridge adapter * @param envelopeId internal id of the envelope * @param envelope the Envelope type data */ event EnvelopeRegistered(bytes32 indexed envelopeId, Envelope envelope); /** * @notice emitted when a transaction forwarding is attempted through a bridge adapter * @param transactionId id of the forwarded transaction * @param envelopeId internal id of the envelope * @param encodedTransaction object intended to be bridged * @param destinationChainId id of the destination chain in our notation * @param bridgeAdapter address of the bridge adapter that failed (deployed on current network) * @param destinationBridgeAdapter address of the connected bridge adapter on destination chain * @param adapterSuccessful adapter was able to forward the message * @param returnData bytes with error information */ event TransactionForwardingAttempted( bytes32 transactionId, bytes32 indexed envelopeId, bytes encodedTransaction, uint256 destinationChainId, address indexed bridgeAdapter, address destinationBridgeAdapter, bool indexed adapterSuccessful, bytes returnData ); /** * @notice emitted when a bridge adapter has been added to the allowed list * @param destinationChainId id of the destination chain in our notation * @param bridgeAdapter address of the bridge adapter added (deployed on current network) * @param destinationBridgeAdapter address of the connected bridge adapter on destination chain * @param allowed boolean indicating if the bridge adapter is allowed or disallowed */ event BridgeAdapterUpdated( uint256 indexed destinationChainId, address indexed bridgeAdapter, address destinationBridgeAdapter, bool indexed allowed ); /** * @notice emitted when the optimal bandwidth is updated for a specified receiver chain * @param chainId id of the receiver chain that gets the new optimal bandwidth * @param optimalBandwidth optimal number of adapters to use for sending a message to a receiver chain */ event OptimalBandwidthUpdated(uint256 indexed chainId, uint256 optimalBandwidth); /** * @notice emitted when a sender has been updated * @param sender address of the updated sender * @param isApproved boolean that indicates if the sender has been approved or removed */ event SenderUpdated(address indexed sender, bool indexed isApproved); /** * @notice method to get the current valid envelope nonce * @return the current valid envelope nonce */ function getCurrentEnvelopeNonce() external view returns (uint256); /** * @notice method to get the current valid transaction nonce * @return the current valid transaction nonce */ function getCurrentTransactionNonce() external view returns (uint256); /** * @notice method to check if a envelope has been previously forwarded. * @param envelope the Envelope type data * @return boolean indicating if the envelope has been registered */ function isEnvelopeRegistered(Envelope memory envelope) external view returns (bool); /** * @notice method to check if a envelope has been previously forwarded. * @param envelopeId the hashed id of the envelope * @return boolean indicating if the envelope has been registered */ function isEnvelopeRegistered(bytes32 envelopeId) external view returns (bool); /** * @notice method to get if a transaction has been forwarded * @param transaction the Transaction type data * @return flag indicating if a transaction has been forwarded */ function isTransactionForwarded(Transaction memory transaction) external view returns (bool); /** * @notice method to get if a transaction has been forwarded * @param transactionId hashed id of the transaction * @return flag indicating if a transaction has been forwarded */ function isTransactionForwarded(bytes32 transactionId) external view returns (bool); /** * @notice method called to initiate message forwarding to other networks. * @param destinationChainId id of the destination chain where the message needs to be bridged * @param destination address where the message is intended for * @param gasLimit gas cost on receiving side of the message * @param message bytes that need to be bridged * @return internal id of the envelope and transaction */ function forwardMessage( uint256 destinationChainId, address destination, uint256 gasLimit, bytes memory message ) external returns (bytes32, bytes32); /** * @notice method called to re forward a previously sent envelope. * @param envelope the Envelope type data * @param gasLimit gas cost on receiving side of the message * @return the transaction id that has the retried envelope * @dev This method will send an existing Envelope using a new Transaction. * @dev This method should be used when the intention is to send the Envelope as if it was a new message. This way on the Receiver side it will start from 0 to count for the required confirmations. (usual use case would be for when an envelope has been invalidated on Receiver side, and needs to be retried as a new message) */ function retryEnvelope(Envelope memory envelope, uint256 gasLimit) external returns (bytes32); /** * @notice method to retry forwarding an already forwarded transaction * @param encodedTransaction the encoded Transaction data * @param gasLimit limit of gas to spend on forwarding per bridge * @param bridgeAdaptersToRetry list of bridge adapters to be used for the transaction forwarding retry * @dev This method will send an existing Transaction with its Envelope to the specified adapters. * @dev Should be used when some of the bridges on the initial forwarding did not work (out of gas), and we want the Transaction with Envelope to still account for the required confirmations on the Receiver side */ function retryTransaction( bytes memory encodedTransaction, uint256 gasLimit, address[] memory bridgeAdaptersToRetry ) external; /** * @notice method to enable bridge adapters * @param bridgeAdapters array of new bridge adapter configurations */ function enableBridgeAdapters(ForwarderBridgeAdapterConfigInput[] memory bridgeAdapters) external; /** * @notice method to disable bridge adapters * @param bridgeAdapters array of bridge adapter addresses to disable */ function disableBridgeAdapters(BridgeAdapterToDisable[] memory bridgeAdapters) external; /** * @notice method to remove sender addresses * @param senders list of addresses to remove */ function removeSenders(address[] memory senders) external; /** * @notice method to approve new sender addresses * @param senders list of addresses to approve */ function approveSenders(address[] memory senders) external; /** * @notice method to get all the forwarder bridge adapters of a chain * @param chainId id of the chain we want to get the adapters from * @return an array of chain configurations where the bridge adapter can communicate */ function getForwarderBridgeAdaptersByChain( uint256 chainId ) external view returns (ChainIdBridgeConfig[] memory); /** * @notice method to get if a sender is approved * @param sender address that we want to check if approved * @return boolean indicating if the address has been approved as sender */ function isSenderApproved(address sender) external view returns (bool); /** * @notice method to update the optimal bandwidth for communication with a receiver chain * @param optimalBandwidthByChain array of objects containing the optimal bandwidth for a specified receiver chain id */ function updateOptimalBandwidthByChain( OptimalBandwidthByChain[] memory optimalBandwidthByChain ) external; /** * @notice method to get the optimal bandwidth for communication with the receiver chain * @param chainId id of the receiver chain to get the optimal bandwidth from * @return optimal bandwidth of the receiver chain */ function getOptimalBandwidthByChain(uint256 chainId) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; import {EnumerableSet} from 'openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol'; import {Transaction, Envelope} from '../libs/EncodingUtils.sol'; /** * @title ICrossChainReceiver * @author BGD Labs * @notice interface containing the objects, events and methods definitions of the CrossChainReceiver contract */ interface ICrossChainReceiver { /** * @notice object with information to set new required confirmations * @param chainId id of the origin chain * @param requiredConfirmations required confirmations to set a message as confirmed */ struct ConfirmationInput { uint256 chainId; uint8 requiredConfirmations; } /** * @notice object with information to set new validity timestamp * @param chainId id of the origin chain * @param validityTimestamp new timestamp in seconds to set as validity point */ struct ValidityTimestampInput { uint256 chainId; uint120 validityTimestamp; } /** * @notice object with necessary information to configure bridge adapters * @param bridgeAdapter address of the bridge adapter to configure * @param chainIds array of ids of the chains the adapter receives messages from */ struct ReceiverBridgeAdapterConfigInput { address bridgeAdapter; uint256[] chainIds; } /** * @notice object containing the receiver configuration * @param requiredConfirmation number of bridges that are needed to make a bridged message valid from origin chain * @param validityTimestamp all messages originated but not finally confirmed before this timestamp per origin chain, are invalid */ struct ReceiverConfiguration { uint8 requiredConfirmation; uint120 validityTimestamp; } /** * @notice object with full information of the receiver configuration for a chain * @param configuration object containing the specifications of the receiver for a chain * @param allowedBridgeAdapters stores if a bridge adapter is allowed for a chain */ struct ReceiverConfigurationFull { ReceiverConfiguration configuration; EnumerableSet.AddressSet allowedBridgeAdapters; } /** * @notice object that stores the internal information of the transaction * @param confirmations number of times that this transaction has been bridged * @param firstBridgedAt timestamp in seconds indicating the first time a transaction was received */ struct TransactionStateWithoutAdapters { uint8 confirmations; uint120 firstBridgedAt; } /** * @notice object that stores the internal information of the transaction with bridge adapters state * @param confirmations number of times that this transactions has been bridged * @param firstBridgedAt timestamp in seconds indicating the first time a transaction was received * @param bridgedByAdapter list of bridge adapters that have bridged the message */ struct TransactionState { uint8 confirmations; uint120 firstBridgedAt; mapping(address => bool) bridgedByAdapter; } /** * @notice object with the current state of an envelope * @param confirmed boolean indicating if the bridged message has been confirmed by the infrastructure * @param delivered boolean indicating if the bridged message has been delivered to the destination */ enum EnvelopeState { None, Confirmed, Delivered } /** * @notice emitted when a transaction has been received successfully * @param transactionId id of the transaction * @param envelopeId id of the envelope * @param originChainId id of the chain where the envelope originated * @param transaction the Transaction type data * @param bridgeAdapter address of the bridge adapter who received the message (deployed on current network) * @param confirmations number of current confirmations for this message */ event TransactionReceived( bytes32 transactionId, bytes32 indexed envelopeId, uint256 indexed originChainId, Transaction transaction, address indexed bridgeAdapter, uint8 confirmations ); /** * @notice emitted when an envelope has been delivery attempted * @param envelopeId id of the envelope * @param envelope the Envelope type data * @param isDelivered flag indicating if the message has been delivered successfully */ event EnvelopeDeliveryAttempted(bytes32 envelopeId, Envelope envelope, bool isDelivered); /** * @notice emitted when a bridge adapter gets updated (allowed or disallowed) * @param bridgeAdapter address of the updated bridge adapter * @param allowed boolean indicating if the bridge adapter has been allowed or disallowed * @param chainId id of the chain updated */ event ReceiverBridgeAdaptersUpdated( address indexed bridgeAdapter, bool indexed allowed, uint256 indexed chainId ); /** * @notice emitted when number of confirmations needed to validate a message changes * @param newConfirmations number of new confirmations needed for a message to be valid * @param chainId id of the chain updated */ event ConfirmationsUpdated(uint8 newConfirmations, uint256 indexed chainId); /** * @notice emitted when a new timestamp for invalidations gets set * @param invalidTimestamp timestamp to invalidate previous messages * @param chainId id of the chain updated */ event NewInvalidation(uint256 invalidTimestamp, uint256 indexed chainId); /** * @notice method to get the current allowed receiver bridge adapters for a chain * @param chainId id of the chain to get the allowed bridge adapter list * @return the list of allowed bridge adapters */ function getReceiverBridgeAdaptersByChain( uint256 chainId ) external view returns (address[] memory); /** * @notice method to get the current supported chains (at least one allowed bridge adapter) * @return list of supported chains */ function getSupportedChains() external view returns (uint256[] memory); /** * @notice method to get the current configuration of a chain * @param chainId id of the chain to get the configuration from * @return the specified chain configuration object */ function getConfigurationByChain( uint256 chainId ) external view returns (ReceiverConfiguration memory); /** * @notice method to get if a bridge adapter is allowed * @param bridgeAdapter address of the bridge adapter to check * @param chainId id of the chain to check * @return boolean indicating if bridge adapter is allowed */ function isReceiverBridgeAdapterAllowed( address bridgeAdapter, uint256 chainId ) external view returns (bool); /** * @notice method to get the current state of a transaction * @param transactionId the id of transaction * @return number of confirmations of internal message identified by the transactionId and the updated timestamp */ function getTransactionState( bytes32 transactionId ) external view returns (TransactionStateWithoutAdapters memory); /** * @notice method to get the internal transaction information * @param transaction Transaction type data * @return number of confirmations of internal message identified by internalId and the updated timestamp */ function getTransactionState( Transaction memory transaction ) external view returns (TransactionStateWithoutAdapters memory); /** * @notice method to get the internal state of an envelope * @param envelope the Envelope type data * @return the envelope current state, containing if it has been confirmed and delivered */ function getEnvelopeState(Envelope memory envelope) external view returns (EnvelopeState); /** * @notice method to get the internal state of an envelope * @param envelopeId id of the envelope * @return the envelope current state, containing if it has been confirmed and delivered */ function getEnvelopeState(bytes32 envelopeId) external view returns (EnvelopeState); /** * @notice method to get if transaction has been received by bridge adapter * @param transactionId id of the transaction as stored internally * @param bridgeAdapter address of the bridge adapter to check if it has bridged the message * @return boolean indicating if the message has been received */ function isTransactionReceivedByAdapter( bytes32 transactionId, address bridgeAdapter ) external view returns (bool); /** * @notice method to set a new timestamp from where the messages will be valid. * @param newValidityTimestamp array of objects containing the chain and timestamp where all the previous unconfirmed messages must be invalidated. */ function updateMessagesValidityTimestamp( ValidityTimestampInput[] memory newValidityTimestamp ) external; /** * @notice method to update the number of confirmations necessary for the messages to be accepted as valid * @param newConfirmations array of objects with the chainId and the new number of needed confirmations */ function updateConfirmations(ConfirmationInput[] memory newConfirmations) external; /** * @notice method that receives a bridged transaction and tries to deliver the contents to destination if possible * @param encodedTransaction bytes containing the bridged information * @param originChainId id of the chain where the transaction originated */ function receiveCrossChainMessage( bytes memory encodedTransaction, uint256 originChainId ) external; /** * @notice method to deliver an envelope to its destination * @param envelope the Envelope typed data * @dev to deliver an envelope, it needs to have been previously confirmed and not delivered */ function deliverEnvelope(Envelope memory envelope) external; /** * @notice method to add bridge adapters to the allowed list * @param bridgeAdaptersInput array of objects with the new bridge adapters and supported chains */ function allowReceiverBridgeAdapters( ReceiverBridgeAdapterConfigInput[] memory bridgeAdaptersInput ) external; /** * @notice method to remove bridge adapters from the allowed list * @param bridgeAdaptersInput array of objects with the bridge adapters and supported chains to disallow */ function disallowReceiverBridgeAdapters( ReceiverBridgeAdapterConfigInput[] memory bridgeAdaptersInput ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; import {IRescuableBase} from './IRescuableBase.sol'; /** * @title IRescuable * @author BGD Labs * @notice interface containing the objects, events and methods definitions of the Rescuable contract */ interface IRescuable is IRescuableBase { error OnlyRescueGuardian(); /** * @notice method called to rescue tokens sent erroneously to the contract. Only callable by owner * @param erc20Token address of the token to rescue * @param to address to send the tokens * @param amount of tokens to rescue */ function emergencyTokenTransfer(address erc20Token, address to, uint256 amount) external; /** * @notice method called to rescue ether sent erroneously to the contract. Only callable by owner * @param to address to send the eth * @param amount of eth to rescue */ function emergencyEtherTransfer(address to, uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; using EnvelopeUtils for Envelope global; using TransactionUtils for Transaction global; /** * @notice Object with the necessary information to define a unique envelope * @param nonce sequential (unique) numeric indicator of the Envelope creation * @param origin address that originated the bridging of a message * @param destination address where the message needs to be sent * @param originChainId id of the chain where the message originated * @param destinationChainId id of the chain where the message needs to be bridged * @param message bytes that needs to be bridged */ struct Envelope { uint256 nonce; address origin; address destination; uint256 originChainId; uint256 destinationChainId; bytes message; } /** * @notice Object containing the information of an envelope for internal usage * @param data bytes of the encoded envelope * @param id hash of the encoded envelope */ struct EncodedEnvelope { bytes data; bytes32 id; } /** * @title EnvelopeUtils library * @author BGD Labs * @notice Defines utility functions for Envelopes */ library EnvelopeUtils { /** * @notice method that encodes an Envelope and generates its id * @param envelope object with the routing information necessary to send a message to a destination chain * @return object containing the encoded envelope and the envelope id */ function encode(Envelope memory envelope) internal pure returns (EncodedEnvelope memory) { EncodedEnvelope memory encodedEnvelope; encodedEnvelope.data = abi.encode(envelope); encodedEnvelope.id = getId(encodedEnvelope.data); return encodedEnvelope; } /** * @notice method to decode and encoded envelope to its raw parameters * @param envelope bytes with the encoded envelope data * @return object with the decoded envelope information */ function decode(bytes memory envelope) internal pure returns (Envelope memory) { return abi.decode(envelope, (Envelope)); } /** * @notice method to get an envelope's id * @param envelope object with the routing information necessary to send a message to a destination chain * @return hash id of the envelope */ function getId(Envelope memory envelope) internal pure returns (bytes32) { EncodedEnvelope memory encodedEnvelope = encode(envelope); return encodedEnvelope.id; } /** * @notice method to get an envelope's id * @param envelope bytes with the encoded envelope data * @return hash id of the envelope */ function getId(bytes memory envelope) internal pure returns (bytes32) { return keccak256(envelope); } } /** * @notice Object with the necessary information to send an envelope to a bridge * @param nonce sequential (unique) numeric indicator of the Transaction creation * @param encodedEnvelope bytes of an encoded envelope object */ struct Transaction { uint256 nonce; bytes encodedEnvelope; } /** * @notice Object containing the information of a transaction for internal usage * @param data bytes of the encoded transaction * @param id hash of the encoded transaction */ struct EncodedTransaction { bytes data; bytes32 id; } /** * @title TransactionUtils library * @author BGD Labs * @notice Defines utility functions for Transactions */ library TransactionUtils { /** * @notice method that encodes a Transaction and generates its id * @param transaction object with the information necessary to send an envelope to a bridge * @return object containing the encoded transaction and the transaction id */ function encode( Transaction memory transaction ) internal pure returns (EncodedTransaction memory) { EncodedTransaction memory encodedTransaction; encodedTransaction.data = abi.encode(transaction); encodedTransaction.id = getId(encodedTransaction.data); return encodedTransaction; } /** * @notice method that decodes an encoded transaction (bytes) into a Transaction object * @param transaction encoded transaction object * @return object containing the decoded Transaction object */ function decode(bytes memory transaction) internal pure returns (Transaction memory) { return abi.decode(transaction, (Transaction)); } /** * @notice method to get a transaction id * @param transaction object with the information necessary to send an envelope to a bridge * @return hash id of the transaction */ function getId(Transaction memory transaction) internal pure returns (bytes32) { EncodedTransaction memory encodedTransaction = encode(transaction); return encodedTransaction.id; } /** * @notice method to get a transaction id * @param transaction encoded transaction object * @return hash id of the transaction */ function getId(bytes memory transaction) internal pure returns (bytes32) { return keccak256(transaction); } /** * @notice method to get the envelope information from the transaction object * @param transaction object with the information necessary to send an envelope to a bridge * @return object with decoded information of the envelope in the transaction */ function getEnvelope(Transaction memory transaction) internal pure returns (Envelope memory) { return EnvelopeUtils.decode(transaction.encodedEnvelope); } /** * @notice method to get the envelope id from the transaction object * @param transaction object with the information necessary to send an envelope to a bridge * @return hash id of the envelope on a transaction */ function getEnvelopeId(Transaction memory transaction) internal pure returns (bytes32) { return EnvelopeUtils.getId(transaction.encodedEnvelope); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; assembly ("memory-safe") { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly ("memory-safe") { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly ("memory-safe") { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; /** * @title IRescuableBase * @author BGD Labs * @notice interface containing the objects, events and methods definitions of the RescuableBase contract */ interface IRescuableBase { error EthTransferFailed(); /** * @notice emitted when erc20 tokens get rescued * @param caller address that triggers the rescue * @param token address of the rescued token * @param to address that will receive the rescued tokens * @param amount quantity of tokens rescued */ event ERC20Rescued( address indexed caller, address indexed token, address indexed to, uint256 amount ); /** * @notice emitted when native tokens get rescued * @param caller address that triggers the rescue * @param to address that will receive the rescued tokens * @param amount quantity of tokens rescued */ event NativeTokensRescued(address indexed caller, address indexed to, uint256 amount); /** * @notice method that defined the maximum amount rescuable for any given asset. * @dev there's currently no way to limit the rescuable "native asset", as we assume erc20s as intended underlying. * @return the maximum amount of */ function maxRescue(address erc20Token) external view returns (uint256); }
{ "remappings": [ "solidity-utils/=lib/aave-delivery-infrastructure/lib/solidity-utils/src/", "forge-std/=lib/aave-helpers/lib/forge-std/src/", "openzeppelin-contracts/=lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/", "aave-helpers/=lib/aave-helpers/src/", "aave-address-book/=lib/aave-helpers/lib/aave-address-book/src/", "adi/=lib/aave-delivery-infrastructure/src/contracts/", "adi-scripts/=lib/aave-delivery-infrastructure/scripts/", "adi-tests/=lib/aave-delivery-infrastructure/tests/", "aave-v3-origin/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src/", "@openzeppelin/=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts/", "@openzeppelin/contracts-upgradeable/=lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/", "aave-delivery-infrastructure/=lib/aave-delivery-infrastructure/", "aave-v3-origin-tests/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/tests/", "ds-test/=lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "halmos-cheatcodes/=lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/", "hyperlane-monorepo/=lib/aave-delivery-infrastructure/lib/hyperlane-monorepo/solidity/contracts/", "openzeppelin-contracts-upgradeable/=lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "shanghai", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"crossChainController","type":"address"},{"internalType":"address","name":"lzEndpoint","type":"address"},{"internalType":"uint256","name":"providerGasLimit","type":"uint256"},{"components":[{"internalType":"address","name":"originForwarder","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"}],"internalType":"struct IBaseAdapter.TrustedRemotesConfig[]","name":"trustedRemotes","type":"tuple[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint16","name":"optionType","type":"uint16"}],"name":"InvalidOptionType","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"originChainId","type":"uint256"},{"indexed":false,"internalType":"address","name":"originForwarder","type":"address"}],"name":"SetTrustedRemote","type":"event"},{"inputs":[],"name":"BASE_GAS_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CROSS_CHAIN_CONTROLLER","outputs":[{"internalType":"contract IBaseCrossChainController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LZ_ENDPOINT","outputs":[{"internalType":"contract ILayerZeroEndpointV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adapterName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"origin","type":"tuple"}],"name":"allowInitializePath","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"executionGasLimit","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"forwardMessage","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getTrustedRemoteByChainId","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"infraChainId","type":"uint256"}],"name":"infraToNativeChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"_origin","type":"tuple"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nativeChainId","type":"uint256"}],"name":"nativeToInfraChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"nextNonce","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"setupPayments","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
61010060405234801562000011575f80fd5b50604051620017a8380380620017a88339810160408190526200003491620002c9565b8382604051806040016040528060118152602001702630bcb2b92d32b9379030b230b83a32b960791b815250835f6001600160a01b0316846001600160a01b0316141560405180604001604052806002815260200161323360f01b81525090620000bc5760405162461bcd60e51b8152600401620000b39190620003d4565b60405180910390fd5b506001600160a01b03841660805260a08390526001620000dd8382620004ac565b503060c0525f5b8151811015620001dc575f82828151811062000104576200010462000578565b602002602001015190505f6001600160a01b0316815f01516001600160a01b0316141560405180604001604052806002815260200161323760f01b81525090620001635760405162461bcd60e51b8152600401620000b39190620003d4565b508051602080830180515f90815280835260409081902080546001600160a01b0319166001600160a01b03958616179055905184518251918252909316918301919091527fa214744f665691ef0eb9e4277cfa3c9198106c8925d6fa6880b6813f705c1aab910160405180910390a150600101620000e4565b5050604080518082019091526002815261191b60f11b6020820152925050506001600160a01b038416620002255760405162461bcd60e51b8152600401620000b39190620003d4565b5050506001600160a01b031660e052506200058c565b80516001600160a01b038116811462000252575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b604080519081016001600160401b038111828210171562000290576200029062000257565b60405290565b604051601f8201601f191681016001600160401b0381118282101715620002c157620002c162000257565b604052919050565b5f805f8060808587031215620002dd575f80fd5b620002e8856200023b565b93506020620002f98187016200023b565b60408781015160608901519296509450906001600160401b03808211156200031f575f80fd5b818901915089601f83011262000333575f80fd5b81518181111562000348576200034862000257565b62000358858260051b0162000296565b818152858101925060069190911b83018501908b82111562000378575f80fd5b928501925b81841015620003c45784848d03121562000395575f80fd5b6200039f6200026b565b620003aa856200023b565b81528487015187820152835292840192918501916200037d565b989b979a50959850505050505050565b5f602080835283518060208501525f5b818110156200040257858101830151858201604001528201620003e4565b505f604082860101526040601f19601f8301168501019250505092915050565b600181811c908216806200043757607f821691505b6020821081036200045657634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115620004a757805f5260205f20601f840160051c81016020851015620004835750805b601f840160051c820191505b81811015620004a4575f81556001016200048f565b50505b505050565b81516001600160401b03811115620004c857620004c862000257565b620004e081620004d9845462000422565b846200045c565b602080601f83116001811462000516575f8415620004fe5750858301515b5f19600386901b1c1916600185901b17855562000570565b5f85815260208120601f198616915b82811015620005465788860151825594840194600190910190840162000525565b50858210156200056457878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b634e487b7160e01b5f52603260045260245ffd5b60805160a05160c05160e0516111be620005ea5f395f8181610255015281816102e90152818161056a01528181610699015261079301525f6109ae01525f8181610182015261052c01525f81816102220152610a0401526111be5ff3fe6080604052600436106100a5575f3560e01c8063b86a616111610062578063b86a6161146101a4578063ba286578146101f0578063c495636614610211578063cd4d1c6414610244578063d688758114610277578063ff7bd03d14610296575f80fd5b806313137d65146100a95780631e02e77c146100be57806336da7a06146100f057806352d1043d1461012e5780637d25a05e1461013957806381fbadad14610171575b5f80fd5b6100bc6100b7366004610d54565b6102c5565b005b3480156100c9575f80fd5b506100dd6100d8366004610dec565b6103a7565b6040519081526020015b60405180910390f35b3480156100fb575f80fd5b5061010f61010a366004610e03565b610487565b604080516001600160a01b0390931683526020830191909152016100e7565b3480156100bc575f80fd5b348015610144575f80fd5b50610158610153366004610e79565b6107d0565b60405167ffffffffffffffff90911681526020016100e7565b34801561017c575f80fd5b506100dd7f000000000000000000000000000000000000000000000000000000000000000081565b3480156101af575f80fd5b506101d86101be366004610dec565b5f908152602081905260409020546001600160a01b031690565b6040516001600160a01b0390911681526020016100e7565b3480156101fb575f80fd5b506102046107d8565b6040516100e79190610eee565b34801561021c575f80fd5b506101d87f000000000000000000000000000000000000000000000000000000000000000081565b34801561024f575f80fd5b506101d87f000000000000000000000000000000000000000000000000000000000000000081565b348015610282575f80fd5b506100dd610291366004610dec565b610864565b3480156102a1575f80fd5b506102b56102b0366004610f00565b610938565b60405190151581526020016100e7565b604080518082019091526002815261323560f01b6020820152336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146103305760405162461bcd60e51b81526004016103279190610eee565b60405180910390fd5b505f61034d61034260208a018a610f1a565b63ffffffff166103a7565b905061035888610938565b60405180604001604052806002815260200161189960f11b815250906103915760405162461bcd60e51b81526004016103279190610eee565b5061039d86868361098a565b5050505050505050565b5f81617595036103b957506001919050565b8161759a036103cb575061a86a919050565b8161759d036103dc57506089919050565b8161759e036103ee575061a4b1919050565b8161759f036103ff5750600a919050565b816175a003610410575060fa919050565b816175a40361042457506363564c40919050565b816175960361043557506038919050565b816175c7036104475750610440919050565b816175c10361045857506064919050565b816175ad0361046a575061a4ec919050565b8161767c0361047b57506092919050565b505f919050565b919050565b5f805f61049b61049687610864565b610a6f565b604080518082019091526002815261031360f41b602082015290915063ffffffff82166104db5760405162461bcd60e51b81526004016103279190610eee565b506040805180820190915260018152603960f81b60208201526001600160a01b03891661051b5760405162461bcd60e51b81526004016103279190610eee565b506001600160a01b0388165f6105517f00000000000000000000000000000000000000000000000000000000000000008a610f47565b90505f61056561056083610aa3565b610ad6565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ddc28c586040518060a001604052808863ffffffff1681526020018781526020018c8c8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92018290525093855250505060208201879052604091820152516001600160e01b031960e084901b16815261061991903090600401610f5a565b6040805180830381865afa158015610633573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610657919061102b565b8051604080518082019091526002815261313160f01b60208201529192504710156106955760405162461bcd60e51b81526004016103279190610eee565b505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632637a450835f01516040518060a001604052808a63ffffffff1681526020018981526020018e8e8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92018290525093855250505060208201899052604091820152516001600160e01b031960e085901b16815261074c91903090600401610f5a565b60806040518083038185885af1158015610768573d5f803e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061078d9190611045565b602001517f0000000000000000000000000000000000000000000000000000000000000000985067ffffffffffffffff1696505050505050509550959350505050565b5f5b92915050565b600180546107e5906110c0565b80601f0160208091040260200160405190810160405280929190818152602001828054610811906110c0565b801561085c5780601f106108335761010080835404028352916020019161085c565b820191905f5260205f20905b81548152906001019060200180831161083f57829003601f168201915b505050505081565b5f600182036108765750617595919050565b61a86a8203610888575061759a919050565b60898203610899575061759d919050565b61a4b182036108ab575061759e919050565b600a82036108bc575061759f919050565b60fa82036108cd57506175a0919050565b6363564c4082036108e157506175a4919050565b61044082036108f357506175c7919050565b603882036109045750617596919050565b6064820361091557506175c1919050565b61a4ec820361092757506175ad919050565b6092820361047b575061767c919050565b5f8061094a6103426020850185610f1a565b5f8181526020818152604090912054919250840135906001600160a01b03808316911614801561098257506001600160a01b03811615155b949350505050565b6040805180820190915260028152610c8d60f21b6020820152306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146109ec5760405162461bcd60e51b81526004016103279190610eee565b506040516376b42cad60e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ed68595a90610a3d908690869086906004016110f2565b5f604051808303815f87803b158015610a54575f80fd5b505af1158015610a66573d5f803e3d5ffd5b50505050505050565b5f63ffffffff821115610a9f576040516306dfcc6560e41b81526020600482015260248101839052604401610327565b5090565b5f6001600160801b03821115610a9f576040516306dfcc6560e41b81526080600482015260248101839052604401610327565b60605f610aff60408051600360f01b602082015281516002818303018152602290910190915290565b9050610b0c81845f610b13565b9392505050565b6060836003610b22825f610b78565b61ffff1614610b5557610b35815f610b78565b604051633a51740d60e01b815261ffff9091166004820152602401610327565b5f610b608585610bd4565b9050610b6e86600183610c4c565b9695505050505050565b5f610b84826002610f47565b83511015610bcb5760405162461bcd60e51b8152602060048201526014602482015273746f55696e7431365f6f75744f66426f756e647360601b6044820152606401610327565b50016002015190565b60606001600160801b03821615610c1c57604080516001600160801b0319608086811b8216602084015285901b16603082015201604051602081830303815290604052610b0c565b6040516001600160801b0319608085901b1660208201526030016040516020818303038152906040529392505050565b6060836003610c5b825f610b78565b61ffff1614610c6e57610b35815f610b78565b846001610c7b8551610cb5565b610c86906001611129565b8686604051602001610c9c95949392919061114b565b6040516020818303038152906040529150509392505050565b5f61ffff821115610a9f576040516306dfcc6560e41b81526010600482015260248101839052604401610327565b5f60608284031215610cf3575f80fd5b50919050565b5f8083601f840112610d09575f80fd5b50813567ffffffffffffffff811115610d20575f80fd5b602083019150836020828501011115610d37575f80fd5b9250929050565b80356001600160a01b0381168114610482575f80fd5b5f805f805f805f60e0888a031215610d6a575f80fd5b610d748989610ce3565b965060608801359550608088013567ffffffffffffffff80821115610d97575f80fd5b610da38b838c01610cf9565b9097509550859150610db760a08b01610d3e565b945060c08a0135915080821115610dcc575f80fd5b50610dd98a828b01610cf9565b989b979a50959850939692959293505050565b5f60208284031215610dfc575f80fd5b5035919050565b5f805f805f60808688031215610e17575f80fd5b610e2086610d3e565b94506020860135935060408601359250606086013567ffffffffffffffff811115610e49575f80fd5b610e5588828901610cf9565b969995985093965092949392505050565b803563ffffffff81168114610482575f80fd5b5f8060408385031215610e8a575f80fd5b610e9383610e66565b946020939093013593505050565b5f5b83811015610ebb578181015183820152602001610ea3565b50505f910152565b5f8151808452610eda816020860160208601610ea1565b601f01601f19169290920160200192915050565b602081525f610b0c6020830184610ec3565b5f60608284031215610f10575f80fd5b610b0c8383610ce3565b5f60208284031215610f2a575f80fd5b610b0c82610e66565b634e487b7160e01b5f52601160045260245ffd5b808201808211156107d2576107d2610f33565b6040815263ffffffff8351166040820152602083015160608201525f604084015160a06080840152610f8f60e0840182610ec3565b90506060850151603f198483030160a0850152610fac8282610ec3565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b5f60408284031215610fe2575f80fd5b6040516040810181811067ffffffffffffffff8211171561101157634e487b7160e01b5f52604160045260245ffd5b604052825181526020928301519281019290925250919050565b5f6040828403121561103b575f80fd5b610b0c8383610fd2565b5f60808284031215611055575f80fd5b6040516060810167ffffffffffffffff828210818311171561108557634e487b7160e01b5f52604160045260245ffd5b81604052845183526020850151915080821682146110a1575f80fd5b5060208201526110b48460408501610fd2565b60408201529392505050565b600181811c908216806110d457607f821691505b602082108103610cf357634e487b7160e01b5f52602260045260245ffd5b60408152826040820152828460608301375f606084830101525f6060601f19601f8601168301019050826020830152949350505050565b61ffff81811683821601908082111561114457611144610f33565b5092915050565b5f865161115c818460208b01610ea1565b6001600160f81b031960f888811b82169285019283526001600160f01b031960f089901b16600184015286901b16600382015283516111a2816004840160208801610ea1565b0160040197965050505050505056fea164736f6c6343000816000a00000000000000000000000058e003a3c6f2aeed6a2a6bc77b504566523cb15c0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ed42a7d8559a463722ca4bed50e0cc05a386b0e10000000000000000000000000000000000000000000000000000000000000001
Deployed Bytecode
0x6080604052600436106100a5575f3560e01c8063b86a616111610062578063b86a6161146101a4578063ba286578146101f0578063c495636614610211578063cd4d1c6414610244578063d688758114610277578063ff7bd03d14610296575f80fd5b806313137d65146100a95780631e02e77c146100be57806336da7a06146100f057806352d1043d1461012e5780637d25a05e1461013957806381fbadad14610171575b5f80fd5b6100bc6100b7366004610d54565b6102c5565b005b3480156100c9575f80fd5b506100dd6100d8366004610dec565b6103a7565b6040519081526020015b60405180910390f35b3480156100fb575f80fd5b5061010f61010a366004610e03565b610487565b604080516001600160a01b0390931683526020830191909152016100e7565b3480156100bc575f80fd5b348015610144575f80fd5b50610158610153366004610e79565b6107d0565b60405167ffffffffffffffff90911681526020016100e7565b34801561017c575f80fd5b506100dd7f000000000000000000000000000000000000000000000000000000000000000081565b3480156101af575f80fd5b506101d86101be366004610dec565b5f908152602081905260409020546001600160a01b031690565b6040516001600160a01b0390911681526020016100e7565b3480156101fb575f80fd5b506102046107d8565b6040516100e79190610eee565b34801561021c575f80fd5b506101d87f00000000000000000000000058e003a3c6f2aeed6a2a6bc77b504566523cb15c81565b34801561024f575f80fd5b506101d87f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b81565b348015610282575f80fd5b506100dd610291366004610dec565b610864565b3480156102a1575f80fd5b506102b56102b0366004610f00565b610938565b60405190151581526020016100e7565b604080518082019091526002815261323560f01b6020820152336001600160a01b037f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b16146103305760405162461bcd60e51b81526004016103279190610eee565b60405180910390fd5b505f61034d61034260208a018a610f1a565b63ffffffff166103a7565b905061035888610938565b60405180604001604052806002815260200161189960f11b815250906103915760405162461bcd60e51b81526004016103279190610eee565b5061039d86868361098a565b5050505050505050565b5f81617595036103b957506001919050565b8161759a036103cb575061a86a919050565b8161759d036103dc57506089919050565b8161759e036103ee575061a4b1919050565b8161759f036103ff5750600a919050565b816175a003610410575060fa919050565b816175a40361042457506363564c40919050565b816175960361043557506038919050565b816175c7036104475750610440919050565b816175c10361045857506064919050565b816175ad0361046a575061a4ec919050565b8161767c0361047b57506092919050565b505f919050565b919050565b5f805f61049b61049687610864565b610a6f565b604080518082019091526002815261031360f41b602082015290915063ffffffff82166104db5760405162461bcd60e51b81526004016103279190610eee565b506040805180820190915260018152603960f81b60208201526001600160a01b03891661051b5760405162461bcd60e51b81526004016103279190610eee565b506001600160a01b0388165f6105517f00000000000000000000000000000000000000000000000000000000000000008a610f47565b90505f61056561056083610aa3565b610ad6565b90505f7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b6001600160a01b031663ddc28c586040518060a001604052808863ffffffff1681526020018781526020018c8c8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92018290525093855250505060208201879052604091820152516001600160e01b031960e084901b16815261061991903090600401610f5a565b6040805180830381865afa158015610633573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610657919061102b565b8051604080518082019091526002815261313160f01b60208201529192504710156106955760405162461bcd60e51b81526004016103279190610eee565b505f7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b6001600160a01b0316632637a450835f01516040518060a001604052808a63ffffffff1681526020018981526020018e8e8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92018290525093855250505060208201899052604091820152516001600160e01b031960e085901b16815261074c91903090600401610f5a565b60806040518083038185885af1158015610768573d5f803e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061078d9190611045565b602001517f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b985067ffffffffffffffff1696505050505050509550959350505050565b5f5b92915050565b600180546107e5906110c0565b80601f0160208091040260200160405190810160405280929190818152602001828054610811906110c0565b801561085c5780601f106108335761010080835404028352916020019161085c565b820191905f5260205f20905b81548152906001019060200180831161083f57829003601f168201915b505050505081565b5f600182036108765750617595919050565b61a86a8203610888575061759a919050565b60898203610899575061759d919050565b61a4b182036108ab575061759e919050565b600a82036108bc575061759f919050565b60fa82036108cd57506175a0919050565b6363564c4082036108e157506175a4919050565b61044082036108f357506175c7919050565b603882036109045750617596919050565b6064820361091557506175c1919050565b61a4ec820361092757506175ad919050565b6092820361047b575061767c919050565b5f8061094a6103426020850185610f1a565b5f8181526020818152604090912054919250840135906001600160a01b03808316911614801561098257506001600160a01b03811615155b949350505050565b6040805180820190915260028152610c8d60f21b6020820152306001600160a01b037f0000000000000000000000007b8fac105a7a85f02c3f31559d2ee7313bdc5d7f16146109ec5760405162461bcd60e51b81526004016103279190610eee565b506040516376b42cad60e11b81526001600160a01b037f00000000000000000000000058e003a3c6f2aeed6a2a6bc77b504566523cb15c169063ed68595a90610a3d908690869086906004016110f2565b5f604051808303815f87803b158015610a54575f80fd5b505af1158015610a66573d5f803e3d5ffd5b50505050505050565b5f63ffffffff821115610a9f576040516306dfcc6560e41b81526020600482015260248101839052604401610327565b5090565b5f6001600160801b03821115610a9f576040516306dfcc6560e41b81526080600482015260248101839052604401610327565b60605f610aff60408051600360f01b602082015281516002818303018152602290910190915290565b9050610b0c81845f610b13565b9392505050565b6060836003610b22825f610b78565b61ffff1614610b5557610b35815f610b78565b604051633a51740d60e01b815261ffff9091166004820152602401610327565b5f610b608585610bd4565b9050610b6e86600183610c4c565b9695505050505050565b5f610b84826002610f47565b83511015610bcb5760405162461bcd60e51b8152602060048201526014602482015273746f55696e7431365f6f75744f66426f756e647360601b6044820152606401610327565b50016002015190565b60606001600160801b03821615610c1c57604080516001600160801b0319608086811b8216602084015285901b16603082015201604051602081830303815290604052610b0c565b6040516001600160801b0319608085901b1660208201526030016040516020818303038152906040529392505050565b6060836003610c5b825f610b78565b61ffff1614610c6e57610b35815f610b78565b846001610c7b8551610cb5565b610c86906001611129565b8686604051602001610c9c95949392919061114b565b6040516020818303038152906040529150509392505050565b5f61ffff821115610a9f576040516306dfcc6560e41b81526010600482015260248101839052604401610327565b5f60608284031215610cf3575f80fd5b50919050565b5f8083601f840112610d09575f80fd5b50813567ffffffffffffffff811115610d20575f80fd5b602083019150836020828501011115610d37575f80fd5b9250929050565b80356001600160a01b0381168114610482575f80fd5b5f805f805f805f60e0888a031215610d6a575f80fd5b610d748989610ce3565b965060608801359550608088013567ffffffffffffffff80821115610d97575f80fd5b610da38b838c01610cf9565b9097509550859150610db760a08b01610d3e565b945060c08a0135915080821115610dcc575f80fd5b50610dd98a828b01610cf9565b989b979a50959850939692959293505050565b5f60208284031215610dfc575f80fd5b5035919050565b5f805f805f60808688031215610e17575f80fd5b610e2086610d3e565b94506020860135935060408601359250606086013567ffffffffffffffff811115610e49575f80fd5b610e5588828901610cf9565b969995985093965092949392505050565b803563ffffffff81168114610482575f80fd5b5f8060408385031215610e8a575f80fd5b610e9383610e66565b946020939093013593505050565b5f5b83811015610ebb578181015183820152602001610ea3565b50505f910152565b5f8151808452610eda816020860160208601610ea1565b601f01601f19169290920160200192915050565b602081525f610b0c6020830184610ec3565b5f60608284031215610f10575f80fd5b610b0c8383610ce3565b5f60208284031215610f2a575f80fd5b610b0c82610e66565b634e487b7160e01b5f52601160045260245ffd5b808201808211156107d2576107d2610f33565b6040815263ffffffff8351166040820152602083015160608201525f604084015160a06080840152610f8f60e0840182610ec3565b90506060850151603f198483030160a0850152610fac8282610ec3565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b5f60408284031215610fe2575f80fd5b6040516040810181811067ffffffffffffffff8211171561101157634e487b7160e01b5f52604160045260245ffd5b604052825181526020928301519281019290925250919050565b5f6040828403121561103b575f80fd5b610b0c8383610fd2565b5f60808284031215611055575f80fd5b6040516060810167ffffffffffffffff828210818311171561108557634e487b7160e01b5f52604160045260245ffd5b81604052845183526020850151915080821682146110a1575f80fd5b5060208201526110b48460408501610fd2565b60408201529392505050565b600181811c908216806110d457607f821691505b602082108103610cf357634e487b7160e01b5f52602260045260245ffd5b60408152826040820152828460608301375f606084830101525f6060601f19601f8601168301019050826020830152949350505050565b61ffff81811683821601908082111561114457611144610f33565b5092915050565b5f865161115c818460208b01610ea1565b6001600160f81b031960f888811b82169285019283526001600160f01b031960f089901b16600184015286901b16600382015283516111a2816004840160208801610ea1565b0160040197965050505050505056fea164736f6c6343000816000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000058e003a3c6f2aeed6a2a6bc77b504566523cb15c0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ed42a7d8559a463722ca4bed50e0cc05a386b0e10000000000000000000000000000000000000000000000000000000000000001
-----Decoded View---------------
Arg [0] : crossChainController (address): 0x58e003a3C6f2Aeed6a2a6Bc77B504566523cb15c
Arg [1] : lzEndpoint (address): 0x6F475642a6e85809B1c36Fa62763669b1b48DD5B
Arg [2] : providerGasLimit (uint256): 0
Arg [3] : trustedRemotes (tuple[]): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 00000000000000000000000058e003a3c6f2aeed6a2a6bc77b504566523cb15c
Arg [1] : 0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [5] : 000000000000000000000000ed42a7d8559a463722ca4bed50e0cc05a386b0e1
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000001
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.