Source Code
Overview
ETH Balance
0.999999983887390767 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 20 from a total of 20 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Start Ping Pong | 6457307 | 34 days ago | IN | 0 ETH | 0.0002048 | ||||
Start Ping Pong | 6323215 | 56 days ago | IN | 0 ETH | 0.0008689 | ||||
Start Ping Pong | 6298228 | 61 days ago | IN | 0 ETH | 0.00131266 | ||||
Start Ping Pong | 6291103 | 62 days ago | IN | 0 ETH | 0.00119619 | ||||
Start Ping Pong | 6285224 | 62 days ago | IN | 0 ETH | 0.00079751 | ||||
Start Ping Pong | 6273037 | 64 days ago | IN | 0 ETH | 0.00095021 | ||||
Start Ping Pong | 6272195 | 64 days ago | IN | 0 ETH | 0.0016106 | ||||
Start Ping Pong | 6259075 | 67 days ago | IN | 0 ETH | 0.00120029 | ||||
Start Ping Pong | 6259073 | 67 days ago | IN | 0 ETH | 0.00108969 | ||||
Start Ping Pong | 6259059 | 67 days ago | IN | 0 ETH | 0.00108295 | ||||
Transfer | 6101631 | 89 days ago | IN | 1 ETH | 0.00011644 | ||||
Set Required Res... | 6101624 | 89 days ago | IN | 0 ETH | 0.00017758 | ||||
Set Latest Inter... | 6101624 | 89 days ago | IN | 0 ETH | 0.00028676 | ||||
Add Interchain C... | 6101624 | 89 days ago | IN | 0 ETH | 0.00052055 | ||||
Set Execution Se... | 6101624 | 89 days ago | IN | 0 ETH | 0.00027261 | ||||
Set Guard Config | 6101624 | 89 days ago | IN | 0 ETH | 0.00027884 | ||||
Add Trusted Modu... | 6101624 | 89 days ago | IN | 0 ETH | 0.00051741 | ||||
Link Remote App | 6101624 | 89 days ago | IN | 0 ETH | 0.00028866 | ||||
Link Remote App | 6101624 | 89 days ago | IN | 0 ETH | 0.00028872 | ||||
0x60806040 | 6101598 | 89 days ago | IN | 0 ETH | 0.01237134 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
6459427 | 34 days ago | 0 ETH | ||||
6459315 | 34 days ago | 0 ETH | ||||
6459311 | 34 days ago | 0 ETH | ||||
6459214 | 34 days ago | 0 ETH | ||||
6459214 | 34 days ago | 0 ETH | ||||
6459088 | 34 days ago | 0 ETH | ||||
6459088 | 34 days ago | 0 ETH | ||||
6458978 | 34 days ago | 0 ETH | ||||
6458978 | 34 days ago | 0 ETH | ||||
6458893 | 34 days ago | 0 ETH | ||||
6458893 | 34 days ago | 0 ETH | ||||
6458784 | 34 days ago | 0 ETH | ||||
6458784 | 34 days ago | 0 ETH | ||||
6458690 | 34 days ago | 0 ETH | ||||
6458665 | 34 days ago | 0 ETH | ||||
6458593 | 34 days ago | 0 ETH | ||||
6458590 | 34 days ago | 0 ETH | ||||
6458471 | 34 days ago | 0 ETH | ||||
6458471 | 34 days ago | 0 ETH | ||||
6458364 | 34 days ago | 0 ETH | ||||
6458364 | 34 days ago | 0 ETH | ||||
6458278 | 34 days ago | 0 ETH | ||||
6458278 | 34 days ago | 0 ETH | ||||
6458170 | 34 days ago | 0 ETH | ||||
6458170 | 34 days ago | 0 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
PingPongApp
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {ICAppV1} from "../ICAppV1.sol"; import {InterchainTxDescriptor} from "../../libs/InterchainTransaction.sol"; import {OptionsV1} from "../../libs/Options.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; /// @notice A simple app that sends a message to the remote PingPongApp, which will respond with a message back. /// This app can be loaded with a native asset, which will be used to pay for the messages sent. contract PingPongApp is ICAppV1 { uint256 internal constant DEFAULT_GAS_LIMIT = 500_000; uint256 public gasLimit; event GasLimitSet(uint256 gasLimit); event PingDisrupted(uint256 counter); event PingReceived(uint256 counter, uint64 dbNonce); event PingSent(uint256 counter, uint64 dbNonce); constructor(address admin) ICAppV1(admin) { _grantRole(IC_GOVERNOR_ROLE, admin); _setGasLimit(DEFAULT_GAS_LIMIT); } /// @notice Enables the contract to accept native asset. receive() external payable {} /// @notice Allows the Interchain Governor to set the gas limit for the interchain messages. function setGasLimit(uint256 gasLimit_) external onlyRole(IC_GOVERNOR_ROLE) { _setGasLimit(gasLimit_); } /// @notice Allows the Admin to withdraw the native asset from the contract. function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) { Address.sendValue(payable(msg.sender), address(this).balance); } /// @notice Starts the ping-pong message exchange with the remote PingPongApp. function startPingPong(uint64 dstChainId, uint256 counter) external { // Revert if the balance is lower than the message fee. _sendPingPongMessage(dstChainId, counter, true); } /// @notice Returns the fee to send a single ping message to the remote PingPongApp. function getPingFee(uint64 dstChainId) external view returns (uint256) { OptionsV1 memory options = OptionsV1({gasLimit: gasLimit, gasAirdrop: 0}); bytes memory message = abi.encode(uint256(0)); return _getInterchainFee(dstChainId, options.encodeOptionsV1(), message.length); } /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked. function _receiveMessage( uint64 srcChainId, bytes32, // sender uint64 dbNonce, bytes calldata message ) internal override { uint256 counter = abi.decode(message, (uint256)); emit PingReceived(counter, dbNonce); if (counter > 0) { // Don't revert if the balance is low, just stop sending messages. _sendPingPongMessage({dstChainId: srcChainId, counter: counter - 1, lowBalanceRevert: false}); } } /// @dev Sends a message to the PingPongApp on the remote chain. /// If `counter > 0`, the remote app will respond with a message to this app, decrementing the counter. /// Once the counter reaches 0, the remote app will not respond. function _sendPingPongMessage(uint64 dstChainId, uint256 counter, bool lowBalanceRevert) internal { OptionsV1 memory options = OptionsV1({gasLimit: gasLimit, gasAirdrop: 0}); bytes memory message = abi.encode(counter); uint256 messageFee = _getMessageFee(dstChainId, options, message.length); if (address(this).balance < messageFee && !lowBalanceRevert) { emit PingDisrupted(counter); return; } InterchainTxDescriptor memory desc = _sendToLinkedApp(dstChainId, messageFee, options, message); emit PingSent(counter, desc.dbNonce); } /// @dev Sets the gas limit for the interchain messages. function _setGasLimit(uint256 gasLimit_) internal { gasLimit = gasLimit_; emit GasLimitSet(gasLimit_); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {AbstractICApp, InterchainTxDescriptor} from "./AbstractICApp.sol"; import {InterchainAppV1Events} from "../events/InterchainAppV1Events.sol"; import {IInterchainAppV1} from "../interfaces/IInterchainAppV1.sol"; import {AppConfigV1, APP_CONFIG_GUARD_DISABLED, APP_CONFIG_GUARD_DEFAULT} from "../libs/AppConfig.sol"; import {Freezable} from "../libs/Freezable.sol"; import {OptionsV1} from "../libs/Options.sol"; import {TypeCasts} from "../libs/TypeCasts.sol"; import {AccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; abstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 { using EnumerableSet for EnumerableSet.AddressSet; using TypeCasts for address; using TypeCasts for bytes32; /// @notice Role to manage the Interchain setup of the app. bytes32 public constant IC_GOVERNOR_ROLE = keccak256("IC_GOVERNOR_ROLE"); /// @dev The app config for the current app. AppConfigV1 private _appConfig; /// @dev Address of the linked app deployed on the remote chain. mapping(uint64 chainId => bytes32 remoteApp) private _linkedApp; /// @dev The linked apps frozen by the governor. Governor is no longer to change the linked app for the chain /// if it is frozen nor unfreeze it. Freezable private _frozenLinkedApps; /// @dev Set of Interchain Clients used for verification of messages received by the app. EnumerableSet.AddressSet private _interchainClients; /// @dev The latest version of Interchain Client. /// Note: this client will be used for sending all messages from this app. address private _latestClient; /// @dev Trusted Interchain modules. EnumerableSet.AddressSet private _trustedModules; /// @dev Execution Service to use for sending messages. address private _executionService; /// @dev The action frozen by the governor. Governor is no longer able to perform the action nor unfreeze it. Freezable private _frozenGovernorActions; /// @dev Modifier to check that the action has not been frozen. modifier whenGovernorActionNotFrozen(GovernorAction action) { if (_frozenGovernorActions.isFrozen(uint8(action))) { revert InterchainApp__GovernorActionFrozen(); } _; } /// @dev Modifier to check that the linked app for the chain is not frozen. modifier whenLinkedAppNotFrozen(uint64 chainId) { if (_frozenLinkedApps.isFrozen(chainId)) { revert InterchainApp__LinkedAppFrozen(); } _; } constructor(address admin) { _grantRole(DEFAULT_ADMIN_ROLE, admin); } /// @notice Allows the governor to irreversibly freeze an action. /// Once the action is frozen, the governor is no longer able to perform the action nor unfreeze it. /// @dev Will revert if the action is already frozen. function freezeGovernorAction(GovernorAction action) external onlyRole(IC_GOVERNOR_ROLE) { _frozenGovernorActions.freeze(uint8(action)); emit GovernorActionFrozen(uint8(action)); } /// @notice Allows the governor to freeze the linked app for a specific chain. /// @dev Will revert if either of the following is true: /// - LinkRemoteApp action is frozen (hence no need to freeze any individual linked app) /// - The linked app for the chain is not configured /// - The linked app for the chain is already frozen function freezeLinkedApp(uint64 chainId) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.LinkRemoteApp) { if (_linkedApp[chainId] == 0) { revert InterchainApp__RemoteAppZeroAddress(); } _frozenLinkedApps.freeze(chainId); emit LinkedAppFrozen(chainId); } /// @notice Allows the governor to add the interchain client to the allowed clients set, /// and optionally set the latest client to this one. /// Note: only the allowed clients can send messages to this app. /// Note: the latest client is used for sending messages from this app. /// @param client The address of the interchain client to add. /// @param updateLatest Whether to set the latest client to this one. function addInterchainClient( address client, bool updateLatest ) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.AddInterchainClient) { _addClient(client, updateLatest); } /// @notice Allows the governor to remove the interchain client from the allowed clients set. /// If the client is the latest client, the latest client is set to the zero address. /// @param client The address of the interchain client to remove. function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.RemoveInterchainClient) { _removeClient(client); } /// @notice Allows the governor to set the address of the latest interchain client. /// @dev The new latest client must be an allowed client or zero address. /// Setting the client to zero address effectively pauses the app ability to send messages, /// while allowing to receive them. /// @param client The address of the latest interchain client. function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.SetLatestInterchainClient) { _setLatestClient(client); } /// @notice Allows the governor to link the remote app for the given chain ID. /// - This address will be used as the receiver for the messages sent from this chain. /// - This address will be the only trusted sender for the messages sent to this chain. /// @param chainId The remote chain ID. /// @param remoteApp The address of the remote app to link. function linkRemoteApp( uint64 chainId, bytes32 remoteApp ) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.LinkRemoteApp) whenLinkedAppNotFrozen(chainId) { _linkRemoteApp(chainId, remoteApp); } /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter. function linkRemoteAppEVM( uint64 chainId, address remoteApp ) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.LinkRemoteApp) whenLinkedAppNotFrozen(chainId) { _linkRemoteApp(chainId, remoteApp.addressToBytes32()); } /// @notice Allows the governor to add the module to the trusted modules set. /// - This set of modules will be used to verify both sent and received messages. function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.AddTrustedModule) { if (module == address(0)) { revert InterchainApp__ModuleZeroAddress(); } bool added = _trustedModules.add(module); if (!added) { revert InterchainApp__ModuleAlreadyAdded(module); } emit TrustedModuleAdded(module); } /// @notice Allows the governor to remove the module from the trusted modules set. function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.RemoveTrustedModule) { bool removed = _trustedModules.remove(module); if (!removed) { revert InterchainApp__ModuleNotAdded(module); } emit TrustedModuleRemoved(module); } /// @notice Allows the governor to set the guard config for the current app. /// @param guardFlag The flag indicating the guard type (0 - none, 1 - client's default, 2 - custom) /// @param guard The address of the guard (if the guardFlag is set to 2) /// @param optimisticSeconds The time after which the module responses are optimistically considered correct function setGuardConfig( uint8 guardFlag, address guard, uint48 optimisticSeconds ) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.SetGuardConfig) { bool isDisabledOrDefault = guardFlag == APP_CONFIG_GUARD_DISABLED || guardFlag == APP_CONFIG_GUARD_DEFAULT; // Guard address must be undefined WHEN AND ONLY WHEN Guard is disabled or default. if ((guard == address(0)) != isDisabledOrDefault) { revert InterchainApp__GuardConfigInvalid(); } // For disabled Guard flag, the optimistic period must be 0. if (guardFlag == APP_CONFIG_GUARD_DISABLED && optimisticSeconds != 0) { revert InterchainApp__GuardConfigInvalid(); } // For other Guard flags, the optimistic period is optional. AppConfigV1 memory newConfig = AppConfigV1({ requiredResponses: _appConfig.requiredResponses, guardFlag: guardFlag, guard: guard, optimisticSeconds: optimisticSeconds }); _appConfig = newConfig; emit GuardConfigSet(guardFlag, guard, optimisticSeconds); } /// @notice Allows the governor to set the required number of module responses for the current app. /// @dev The Interchain Client contract will use the amount of trusted modules as a fallback value, /// should the required number of responses be set to 0. /// @param requiredResponses The number of module responses required for accepting the message function setRequiredResponses(uint8 requiredResponses) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.SetRequiredResponses) { _appConfig.requiredResponses = requiredResponses; emit RequiredResponsesSet(requiredResponses); } /// @notice Allows the governor to set the address of the Execution Service. /// This address will be used to request execution of the messages sent from this chain, /// by supplying the Service's execution fee. function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) whenGovernorActionNotFrozen(GovernorAction.SetExecutionService) { _executionService = executionService; emit ExecutionServiceSet(executionService); } // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════ /// @notice Returns the app config for the current app: /// - requiredResponses: the number of module responses required for accepting the message /// - optimisticSeconds: the minimum time after which the module responses are considered final /// - guardFlag: the flag indicating the guard type (0 - none, 1 - client's default, 2 - custom) /// - guard: the address of the guard contract (if the guardFlag is set to 2) function getAppConfigV1() public view returns (AppConfigV1 memory) { return _appConfig; } /// @notice Returns the address of the Execution Service used by this app for sending messages. // solhint-disable-next-line ordering function getExecutionService() external view returns (address) { return _executionService; } /// @notice Returns the list of Interchain Clients allowed to send messages to this app. function getInterchainClients() external view returns (address[] memory) { return _interchainClients.values(); } /// @notice Returns the address of the latest interchain client. /// This address is used for sending messages from this app. function getLatestInterchainClient() external view returns (address) { return _latestClient; } /// @notice Returns the linked app address (as bytes32) for the given chain ID. function getLinkedApp(uint64 chainId) external view returns (bytes32) { return _linkedApp[chainId]; } /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address. /// @dev Will revert if the linked app address is not an EVM address. function getLinkedAppEVM(uint64 chainId) external view returns (address linkedAppEVM) { bytes32 linkedApp = _linkedApp[chainId]; linkedAppEVM = linkedApp.bytes32ToAddress(); if (linkedAppEVM.addressToBytes32() != linkedApp) { revert InterchainApp__LinkedAppNotEVM(linkedApp); } } /// @notice Returns the list of Interchain Modules trusted by this app. /// This set of modules will be used to verify both sent and received messages. function getModules() external view returns (address[] memory) { return _trustedModules.values(); } /// @notice Checks whether the given action has been frozen by the governor. /// @dev Governor is no longer able to perform any of the frozen actions nor unfreeze them. function isGovernorActionFrozen(GovernorAction action) external view returns (bool) { return _frozenGovernorActions.isFrozen(uint8(action)); } /// @notice Checks whether the linked app for the given chain has been frozen by the governor. /// @dev Governor is no longer able to change the linked app for the chain nor unfreeze it. function isLinkedAppFrozen(uint64 chainId) external view returns (bool) { return _frozenLinkedApps.isFrozen(chainId); } // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════ /// @dev Links the remote app to the current app. /// Will revert if the chainId is the same as the chainId of the local app. /// Note: Should be guarded with permissions check. function _linkRemoteApp(uint64 chainId, bytes32 remoteApp) internal { if (chainId == block.chainid) { revert InterchainApp__ChainIdNotRemote(chainId); } if (remoteApp == 0) { revert InterchainApp__RemoteAppZeroAddress(); } _linkedApp[chainId] = remoteApp; emit AppLinked(chainId, remoteApp); } /// @dev Stores the address of the latest Interchain Client. /// - The exact storage location is up to the implementation. /// - Must NOT be called directly: use `_setLatestClient` instead. /// - Should not emit any events: this is done in the calling function. function _storeLatestClient(address client) internal override { _latestClient = client; } /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app). /// - The client is checked to be in the opposite state before the change. /// - The exact storage location is up to the implementation. /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead. /// - Should not emit any events: this is done in the calling functions. function _toggleClientState(address client, bool allowed) internal override { if (allowed) { _interchainClients.add(client); } else { _interchainClients.remove(client); } } // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════ /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app. function _sendToLinkedApp( uint64 dstChainId, uint256 messageFee, OptionsV1 memory options, bytes memory message ) internal returns (InterchainTxDescriptor memory) { bytes memory encodedOptions = options.encodeOptionsV1(); return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message); } // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════ /// @dev Returns the fee to send a message to the linked app on the remote chain. function _getMessageFee( uint64 dstChainId, OptionsV1 memory options, uint256 messageLen ) internal view returns (uint256) { bytes memory encodedOptions = options.encodeOptionsV1(); return _getInterchainFee(dstChainId, encodedOptions, messageLen); } /// @dev Returns the configuration of the app for validating the received messages. function _getAppConfig() internal view override returns (bytes memory) { return getAppConfigV1().encodeAppConfigV1(); } /// @dev Returns the address of the Execution Service to use for sending messages. function _getExecutionService() internal view override returns (address) { return _executionService; } /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages. function _getLatestClient() internal view override returns (address) { return _latestClient; } /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages. function _getModules() internal view override returns (address[] memory) { return _trustedModules.values(); } /// @dev Checks if the sender is allowed to send messages to this app. function _isAllowedSender(uint64 srcChainId, bytes32 sender) internal view override returns (bool) { return _linkedApp[srcChainId] == sender; } /// @dev Checks if the caller is an Interchain Client. /// Both latest and legacy Interchain Clients are allowed to call `appReceive`. function _isInterchainClient(address caller) internal view override returns (bool) { return _interchainClients.contains(caller); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {MathLib} from "./Math.sol"; import {TypeCasts} from "./TypeCasts.sol"; import {VersionedPayloadLib} from "./VersionedPayload.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; type ICTxHeader is uint256; struct InterchainTransaction { uint64 srcChainId; uint64 dstChainId; uint64 dbNonce; bytes32 srcSender; bytes32 dstReceiver; bytes options; bytes message; } struct InterchainTxDescriptor { bytes32 transactionId; uint64 dbNonce; } using InterchainTransactionLib for InterchainTransaction global; library InterchainTransactionLib { using MathLib for uint256; using VersionedPayloadLib for bytes; function constructLocalTransaction( address srcSender, uint64 dstChainId, bytes32 dstReceiver, uint64 dbNonce, bytes memory options, bytes memory message ) internal view returns (InterchainTransaction memory transaction) { return InterchainTransaction({ srcChainId: SafeCast.toUint64(block.chainid), srcSender: TypeCasts.addressToBytes32(srcSender), dstChainId: dstChainId, dstReceiver: dstReceiver, dbNonce: dbNonce, options: options, message: message }); } function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) { return abi.encode( encodeTxHeader(transaction.srcChainId, transaction.dstChainId, transaction.dbNonce), transaction.srcSender, transaction.dstReceiver, transaction.options, transaction.message ); } function decodeTransaction(bytes calldata transaction) internal pure returns (InterchainTransaction memory icTx) { ICTxHeader header; (header, icTx.srcSender, icTx.dstReceiver, icTx.options, icTx.message) = abi.decode(transaction, (ICTxHeader, bytes32, bytes32, bytes, bytes)); (icTx.srcChainId, icTx.dstChainId, icTx.dbNonce) = decodeTxHeader(header); } function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) { // 2 bytes are reserved for the transaction version // + 5 fields * 32 bytes (3 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 226 // (srcChainId, dstChainId, dbNonce) are merged into a single 32 bytes field // Both options and message are dynamic fields, which are padded up to 32 bytes return 226 + optionsLen.roundUpToWord() + messageLen.roundUpToWord(); } function encodeTxHeader(uint64 srcChainId, uint64 dstChainId, uint64 dbNonce) internal pure returns (ICTxHeader) { return ICTxHeader.wrap((uint256(srcChainId) << 128) | (uint256(dstChainId) << 64) | (uint256(dbNonce))); } function decodeTxHeader(ICTxHeader header) internal pure returns (uint64 srcChainId, uint64 dstChainId, uint64 dbNonce) { srcChainId = uint64(ICTxHeader.unwrap(header) >> 128); dstChainId = uint64(ICTxHeader.unwrap(header) >> 64); dbNonce = uint64(ICTxHeader.unwrap(header)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {VersionedPayloadLib} from "./VersionedPayload.sol"; /// @notice Struct to hold V1 of options data. /// @dev Next versions have to use the fields from the previous version and add new fields at the end. /// @param gasLimit The gas limit for the transaction. /// @param gasAirdrop The amount of gas to airdrop. struct OptionsV1 { uint256 gasLimit; uint256 gasAirdrop; } using OptionsLib for OptionsV1 global; /// @title OptionsLib /// @notice A library for encoding and decoding Interchain options related to interchain messages. library OptionsLib { using VersionedPayloadLib for bytes; uint16 internal constant OPTIONS_V1 = 1; error OptionsLib__VersionInvalid(uint16 version); /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct. /// @param data The options data in bytes format. function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) { uint16 version = data.getVersionFromMemory(); if (version < OPTIONS_V1) { revert OptionsLib__VersionInvalid(version); } // Structs of the same version will always be decoded correctly. // Following versions will be decoded correctly if they have the same fields as the previous version, // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload. return abi.decode(data.getPayloadFromMemory(), (OptionsV1)); } /// @notice Encodes V1 options into a bytes format. /// @param options The OptionsV1 to encode. function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) { return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {AbstractICAppEvents} from "../events/AbstractICAppEvents.sol"; import {IInterchainApp} from "../interfaces/IInterchainApp.sol"; import {IInterchainClientV1} from "../interfaces/IInterchainClientV1.sol"; import {InterchainTxDescriptor} from "../libs/InterchainTransaction.sol"; import {TypeCasts} from "../libs/TypeCasts.sol"; abstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp { using TypeCasts for address; error InterchainApp__BalanceBelowMin(uint256 balance, uint256 minRequired); error InterchainApp__ChainIdNotRemote(uint64 chainId); error InterchainApp__InterchainClientAlreadyAdded(address client); error InterchainApp__InterchainClientAlreadyLatest(address client); error InterchainApp__InterchainClientZeroAddress(); error InterchainApp__NotInterchainClient(address account); error InterchainApp__ReceiverZeroAddress(uint64 chainId); error InterchainApp__SrcSenderNotAllowed(uint64 srcChainId, bytes32 sender); /// @notice Allows the Interchain Client to pass the message to the Interchain App. /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender. /// @param srcChainId Chain ID of the source chain, where the message was sent from. /// @param sender Sender address on the source chain, as a bytes32 value. /// @param dbNonce The Interchain DB nonce of the message entry. /// @param message The message being sent. function appReceive(uint64 srcChainId, bytes32 sender, uint64 dbNonce, bytes calldata message) external payable { if (!_isInterchainClient(msg.sender)) { revert InterchainApp__NotInterchainClient(msg.sender); } if (srcChainId == block.chainid) { revert InterchainApp__ChainIdNotRemote(srcChainId); } if (!_isAllowedSender(srcChainId, sender)) { revert InterchainApp__SrcSenderNotAllowed(srcChainId, sender); } _receiveMessage(srcChainId, sender, dbNonce, message); } /// @notice Returns the verification configuration of the Interchain App. /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed /// by the Interchain Modules on the destination chain. /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which /// the message is considered confirmed by the module. Following versions may include additional fields. /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes. /// @return modules The list of Interchain Modules that app is trusting to confirm the messages. function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) { appConfig = _getAppConfig(); modules = _getModules(); } // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════ /// @dev Performs necessary checks and adds an Interchain Client. /// Optionally sets the latest client to this one. /// Note: should be guarded with permission checks in the derived contracts. function _addClient(address client, bool updateLatest) internal { if (client == address(0)) { revert InterchainApp__InterchainClientZeroAddress(); } if (_isInterchainClient(client)) { revert InterchainApp__InterchainClientAlreadyAdded(client); } _toggleClientState(client, true); emit InterchainClientAdded(client); if (updateLatest) { _setLatestClient(client); } } /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one, /// the latest client is set to zero address (effectively pausing the app ability to send messages). /// Note: should be guarded with permission checks in the derived contracts. function _removeClient(address client) internal { if (!_isInterchainClient(client)) { revert InterchainApp__NotInterchainClient(client); } _toggleClientState(client, false); emit InterchainClientRemoved(client); if (client == _getLatestClient()) { _setLatestClient(address(0)); } } /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them). /// Note: should be guarded with permission checks in the derived contracts. function _setLatestClient(address client) internal { // New latest client must be an allowed client or zero address. if (!_isInterchainClient(client) && client != address(0)) { revert InterchainApp__NotInterchainClient(client); } if (client == _getLatestClient()) { revert InterchainApp__InterchainClientAlreadyLatest(client); } _storeLatestClient(client); emit LatestClientSet(client); } /// @dev Stores the address of the latest Interchain Client. /// - The exact storage location is up to the implementation. /// - Must NOT be called directly: use `_setLatestClient` instead. /// - Should not emit any events: this is done in the calling function. function _storeLatestClient(address client) internal virtual; /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app). /// - The client is checked to be in the opposite state before the change. /// - The exact storage location is up to the implementation. /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead. /// - Should not emit any events: this is done in the calling functions. function _toggleClientState(address client, bool allowed) internal virtual; // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════ /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter. function _sendInterchainMessageEVM( uint64 dstChainId, address receiver, uint256 messageFee, bytes memory options, bytes memory message ) internal returns (InterchainTxDescriptor memory desc) { return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message); } /// @dev Performs necessary checks and sends an interchain message. function _sendInterchainMessage( uint64 dstChainId, bytes32 receiver, uint256 messageFee, bytes memory options, bytes memory message ) internal returns (InterchainTxDescriptor memory desc) { address client = _getLatestClient(); if (client == address(0)) { revert InterchainApp__InterchainClientZeroAddress(); } if (dstChainId == block.chainid) { revert InterchainApp__ChainIdNotRemote(dstChainId); } if (receiver == 0) { revert InterchainApp__ReceiverZeroAddress(dstChainId); } if (address(this).balance < messageFee) { revert InterchainApp__BalanceBelowMin({balance: address(this).balance, minRequired: messageFee}); } return IInterchainClientV1(client).interchainSend{value: messageFee}( dstChainId, receiver, _getExecutionService(), _getModules(), options, message ); } /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked. function _receiveMessage( uint64 srcChainId, bytes32 sender, uint64 dbNonce, bytes calldata message ) internal virtual; // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════ /// @dev Returns the fee for sending an Interchain message. function _getInterchainFee( uint64 dstChainId, bytes memory options, uint256 messageLen ) internal view returns (uint256) { address client = _getLatestClient(); if (client == address(0)) { revert InterchainApp__InterchainClientZeroAddress(); } return IInterchainClientV1(client).getInterchainFee( dstChainId, _getExecutionService(), _getModules(), options, messageLen ); } /// @dev Returns the configuration of the app for validating the received messages. function _getAppConfig() internal view virtual returns (bytes memory); /// @dev Returns the address of the Execution Service to use for sending messages. function _getExecutionService() internal view virtual returns (address); /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages. function _getLatestClient() internal view virtual returns (address); /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages. function _getModules() internal view virtual returns (address[] memory); /// @dev Checks if the sender is allowed to send messages to this app. function _isAllowedSender(uint64 srcChainId, bytes32 sender) internal view virtual returns (bool); /// @dev Checks if the caller is an Interchain Client. /// Both latest and legacy Interchain Clients are allowed to call `appReceive`. function _isInterchainClient(address caller) internal view virtual returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; abstract contract InterchainAppV1Events { /// @notice Emitted when an action is frozen. See IInterchainAppV1.GovernorAction enum for details. /// @param action The action that was frozen. event GovernorActionFrozen(uint256 action); /// @notice Emitted when a linked app is frozen for a specific chain. /// @param chainId The chain ID with the frozen linked app. event LinkedAppFrozen(uint64 chainId); /// @notice Emitted when the app configuration V1 is set. /// The V1 version of app config requests at least N confirmations that are at least T seconds old /// from trusted modules to execute a transaction. /// @param requiredResponses The number of module responses required for a transaction to be executed. /// @param optimisticSeconds The time period after which a module response is considered final. event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticSeconds); /// @notice Emitted when a remote instance of the app is linked. /// This instance is the only one that can send messages to this app from the remote chain. /// @param chainId The remote chain ID. /// @param remoteApp The address of the remote app on that chain. event AppLinked(uint64 chainId, bytes32 remoteApp); /// @notice Emitted when the execution service is set. /// This service will be used for requesting the execution of transactions on the remote chain. /// @param executionService The address of the execution service. event ExecutionServiceSet(address executionService); /// @notice Emitted when the guard config is set. /// @param guardFlag The flag indicating the guard type (0 - none, 1 - client's default, 2 - custom) /// @param guard The address of the guard contract (if the guardFlag is set to 2) /// @param optimisticSeconds The minimum time after which the module responses are considered final event GuardConfigSet(uint8 guardFlag, address guard, uint48 optimisticSeconds); /// @notice Emitted when the required number of module responses is set. /// @param requiredResponses The number of module responses required for accepting the message event RequiredResponsesSet(uint8 requiredResponses); /// @notice Emitted when a trusted module is added. /// The trusted modules will be used to verify the messages coming from the remote chains, /// as well as request the verification of the sent messages on the remote chains. /// @param module The address of the trusted module that was added. event TrustedModuleAdded(address module); /// @notice Emitted when a trusted module is removed. /// @param module The address of the trusted module that was removed. event TrustedModuleRemoved(address module); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {AppConfigV1} from "../libs/AppConfig.sol"; import {IInterchainApp} from "./IInterchainApp.sol"; interface IInterchainAppV1 is IInterchainApp { enum GovernorAction { AddInterchainClient, RemoveInterchainClient, SetLatestInterchainClient, AddTrustedModule, RemoveTrustedModule, SetRequiredResponses, SetGuardConfig, LinkRemoteApp, SetExecutionService } error InterchainApp__AppConfigInvalid(uint256 requiredResponses, uint256 optimisticSeconds); error InterchainApp__GovernorActionFrozen(); error InterchainApp__GuardConfigInvalid(); error InterchainApp__LinkedAppFrozen(); error InterchainApp__LinkedAppNotEVM(bytes32 linkedApp); error InterchainApp__ModuleAlreadyAdded(address module); error InterchainApp__ModuleNotAdded(address module); error InterchainApp__ModuleZeroAddress(); error InterchainApp__RemoteAppZeroAddress(); function freezeGovernorAction(GovernorAction action) external; function freezeLinkedApp(uint64 chainId) external; function addInterchainClient(address client, bool updateLatest) external; function removeInterchainClient(address client) external; function setLatestInterchainClient(address client) external; function linkRemoteApp(uint64 chainId, bytes32 remoteApp) external; function linkRemoteAppEVM(uint64 chainId, address remoteApp) external; function addTrustedModule(address module) external; function removeTrustedModule(address module) external; function setGuardConfig(uint8 guardFlag, address guard, uint48 optimisticSeconds) external; function setRequiredResponses(uint8 requiredResponses) external; function setExecutionService(address executionService) external; // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════ function getAppConfigV1() external view returns (AppConfigV1 memory); function getExecutionService() external view returns (address); function getInterchainClients() external view returns (address[] memory); function getLatestInterchainClient() external view returns (address); function getLinkedApp(uint64 chainId) external view returns (bytes32); function getLinkedAppEVM(uint64 chainId) external view returns (address); function getModules() external view returns (address[] memory); function isGovernorActionFrozen(GovernorAction action) external view returns (bool); function isLinkedAppFrozen(uint64 chainId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {VersionedPayloadLib} from "./VersionedPayload.sol"; struct AppConfigV1 { uint8 requiredResponses; uint48 optimisticSeconds; uint8 guardFlag; address guard; } using AppConfigLib for AppConfigV1 global; /// @dev Signals that the app opted out of using any Guard module. uint8 constant APP_CONFIG_GUARD_DISABLED = 0; /// @dev Signals that the app uses the default Guard module provided by InterchainClient contract. uint8 constant APP_CONFIG_GUARD_DEFAULT = 1; /// @dev Signals that the app uses a custom Guard module. uint8 constant APP_CONFIG_GUARD_CUSTOM = 2; library AppConfigLib { using VersionedPayloadLib for bytes; uint16 internal constant APP_CONFIG_V1 = 1; error AppConfigLib__VersionInvalid(uint16 version); /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct. /// @param data The app config data in bytes format. function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) { uint16 version = data.getVersionFromMemory(); if (version < APP_CONFIG_V1) { revert AppConfigLib__VersionInvalid(version); } // Structs of the same version will always be decoded correctly. // Following versions will be decoded correctly if they have the same fields as the previous version, // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload. return abi.decode(data.getPayloadFromMemory(), (AppConfigV1)); } /// @notice Encodes V1 app config into a bytes format. /// @param appConfig The AppConfigV1 to encode. function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) { return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {BitMaps} from "@openzeppelin/contracts/utils/structs/BitMaps.sol"; /// @notice Stores freeze status for a set of uint256 ids. /// Once the id is frozen, it cannot be unfrozen. struct Freezable { BitMaps.BitMap _frozenIds; } using FreezableLib for Freezable global; library FreezableLib { using BitMaps for BitMaps.BitMap; error Freezable__AlreadyFrozen(); /// @notice Freezes the given id. /// @dev Will revert if the id is already frozen. function freeze(Freezable storage self, uint256 id) internal { if (isFrozen(self, id)) { revert Freezable__AlreadyFrozen(); } self._frozenIds.set(id); } /// @notice Checks if the given id is frozen. function isFrozen(Freezable storage self, uint256 id) internal view returns (bool) { return self._frozenIds.get(id); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; library TypeCasts { function addressToBytes32(address addr) internal pure returns (bytes32) { return bytes32(uint256(uint160(addr))); } function bytes32ToAddress(bytes32 b) internal pure returns (address) { return address(uint160(uint256(b))); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol) pragma solidity ^0.8.20; import {IAccessControlEnumerable} from "./IAccessControlEnumerable.sol"; import {AccessControl} from "../AccessControl.sol"; import {EnumerableSet} from "../../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 role => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {AccessControl-_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override returns (bool) { bool granted = super._grantRole(role, account); if (granted) { _roleMembers[role].add(account); } return granted; } /** * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) { bool revoked = super._revokeRole(role, account); if (revoked) { _roleMembers[role].remove(account); } return revoked; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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; /// @solidity memory-safe-assembly assembly { 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; /// @solidity memory-safe-assembly assembly { 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; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; library MathLib { /// @notice Rounds up to the nearest multiple of 32. /// Note: Returns zero on overflows instead of reverting. This is fine for practical /// use cases, as this is used for determining the size of the payload in memory. function roundUpToWord(uint256 x) internal pure returns (uint256) { unchecked { return (x + 31) & ~uint256(31); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; // solhint-disable no-inline-assembly // solhint-disable ordering library VersionedPayloadLib { /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload uint256 internal constant VERSION_LENGTH = 2; error VersionedPayload__PayloadTooShort(bytes versionedPayload); error VersionedPayload__PrecompileFailed(); /// @notice Encodes the versioned payload into a single bytes array. /// @param version The payload's version. /// @param payload The payload to encode. function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) { return abi.encodePacked(version, payload); } /// @notice Extracts the version from the versioned payload (calldata reference). /// @param versionedPayload The versioned payload (calldata reference). function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) { if (versionedPayload.length < VERSION_LENGTH) { revert VersionedPayload__PayloadTooShort(versionedPayload); } assembly { // We are only interested in the highest 16 bits of the loaded full 32 bytes word. version := shr(240, calldataload(versionedPayload.offset)) } } /// @notice Extracts the payload from the versioned payload (calldata reference). /// @dev The extracted payload is also returned as a calldata reference. /// @param versionedPayload The versioned payload. function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) { if (versionedPayload.length < VERSION_LENGTH) { revert VersionedPayload__PayloadTooShort(versionedPayload); } return versionedPayload[VERSION_LENGTH:]; } /// @notice Extracts the version from the versioned payload (memory reference). /// @param versionedPayload The versioned payload (memory reference). function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) { if (versionedPayload.length < VERSION_LENGTH) { revert VersionedPayload__PayloadTooShort(versionedPayload); } assembly { // We are only interested in the highest 16 bits of the loaded full 32 bytes word. // We add 0x20 to skip the length of the bytes array. version := shr(240, mload(add(versionedPayload, 0x20))) } } /// @notice Extracts the payload from the versioned payload (memory reference). /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible /// to avoid extra memory allocation. /// @param versionedPayload The versioned payload (memory reference). function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) { if (versionedPayload.length < VERSION_LENGTH) { revert VersionedPayload__PayloadTooShort(versionedPayload); } // Figure how many bytes to copy and allocate the memory for the extracted payload. uint256 toCopy; unchecked { toCopy = versionedPayload.length - VERSION_LENGTH; } payload = new bytes(toCopy); // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains. bool res; assembly { // We add 0x20 to skip the length of the bytes array. // We add 0x02 to skip the 2 bytes reserved for the version. // Copy the payload to the previously allocated memory. res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy) } if (!res) { revert VersionedPayload__PrecompileFailed(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 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); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; abstract contract AbstractICAppEvents { /// @notice Emitted when a new interchain client is added. /// This client will be able to send messages to the app. /// @param client The address of the client. event InterchainClientAdded(address client); /// @notice Emitted when an interchain client is removed. /// @param client The address of the client. event InterchainClientRemoved(address client); /// @notice Emitted when the latest interchain client is set. /// This client will be used by the app to send messages. /// @param client The address of the client. event LatestClientSet(address client); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @notice Minimal interface for the Interchain App to work with the Interchain Client. interface IInterchainApp { function appReceive(uint64 srcChainId, bytes32 sender, uint64 dbNonce, bytes calldata message) external payable; // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════ function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {InterchainTransaction, InterchainTxDescriptor} from "../libs/InterchainTransaction.sol"; interface IInterchainClientV1 { enum TxReadiness { Ready, AlreadyExecuted, EntryAwaitingResponses, EntryConflict, ReceiverNotICApp, TxWrongDstChainId, UndeterminedRevert } error InterchainClientV1__ChainIdNotLinked(uint64 chainId); error InterchainClientV1__ChainIdNotRemote(uint64 chainId); error InterchainClientV1__DstChainIdNotLocal(uint64 chainId); error InterchainClientV1__EntryConflict(address module); error InterchainClientV1__ExecutionServiceZeroAddress(); error InterchainClientV1__FeeAmountBelowMin(uint256 feeAmount, uint256 minRequired); error InterchainClientV1__GasLeftBelowMin(uint256 gasLeft, uint256 minRequired); error InterchainClientV1__GuardZeroAddress(); error InterchainClientV1__LinkedClientNotEVM(bytes32 client); error InterchainClientV1__ModuleZeroAddress(); error InterchainClientV1__MsgValueMismatch(uint256 msgValue, uint256 required); error InterchainClientV1__ReceiverNotICApp(address receiver); error InterchainClientV1__ReceiverZeroAddress(); error InterchainClientV1__ResponsesAmountBelowMin(uint256 responsesAmount, uint256 minRequired); error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId); error InterchainClientV1__TxNotExecuted(bytes32 transactionId); error InterchainClientV1__TxVersionMismatch(uint16 txVersion, uint16 required); function setDefaultGuard(address guard) external; function setDefaultModule(address module) external; function setLinkedClient(uint64 chainId, bytes32 client) external; function interchainSend( uint64 dstChainId, bytes32 receiver, address srcExecutionService, address[] calldata srcModules, bytes calldata options, bytes calldata message ) external payable returns (InterchainTxDescriptor memory desc); function interchainSendEVM( uint64 dstChainId, address receiver, address srcExecutionService, address[] calldata srcModules, bytes calldata options, bytes calldata message ) external payable returns (InterchainTxDescriptor memory desc); function interchainExecute(uint256 gasLimit, bytes calldata transaction) external payable; function writeExecutionProof(bytes32 transactionId) external returns (uint64 dbNonce); // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════ function isExecutable(bytes calldata transaction) external view returns (bool); function getTxReadinessV1(InterchainTransaction memory icTx) external view returns (TxReadiness status, bytes32 firstArg, bytes32 secondArg); function getInterchainFee( uint64 dstChainId, address srcExecutionService, address[] calldata srcModules, bytes calldata options, uint256 messageLen ) external view returns (uint256); function getExecutor(bytes calldata transaction) external view returns (address); function getExecutorById(bytes32 transactionId) external view returns (address); function getLinkedClient(uint64 chainId) external view returns (bytes32); function getLinkedClientEVM(uint64 chainId) external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/BitMaps.sol) pragma solidity ^0.8.20; /** * @dev Library for managing uint256 to bool mapping in a compact and efficient way, provided the keys are sequential. * Largely inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. * * BitMaps pack 256 booleans across each bit of a single 256-bit slot of `uint256` type. * Hence booleans corresponding to 256 _sequential_ indices would only consume a single slot, * unlike the regular `bool` which would consume an entire slot for a single value. * * This results in gas savings in two ways: * * - Setting a zero value to non-zero only once every 256 times * - Accessing the same warm slot for every 256 _sequential_ indices */ library BitMaps { struct BitMap { mapping(uint256 bucket => uint256) _data; } /** * @dev Returns whether the bit at `index` is set. */ function get(BitMap storage bitmap, uint256 index) internal view returns (bool) { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); return bitmap._data[bucket] & mask != 0; } /** * @dev Sets the bit at `index` to the boolean `value`. */ function setTo(BitMap storage bitmap, uint256 index, bool value) internal { if (value) { set(bitmap, index); } else { unset(bitmap, index); } } /** * @dev Sets the bit at `index`. */ function set(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] |= mask; } /** * @dev Unsets the bit at `index`. */ function unset(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] &= ~mask; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol) pragma solidity ^0.8.20; import {IAccessControl} from "../IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "@openzeppelin/=node_modules/@openzeppelin/", "@synapsecns/=node_modules/@synapsecns/", "forge-std/=node_modules/forge-std/src/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"Freezable__AlreadyFrozen","type":"error"},{"inputs":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticSeconds","type":"uint256"}],"name":"InterchainApp__AppConfigInvalid","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"minRequired","type":"uint256"}],"name":"InterchainApp__BalanceBelowMin","type":"error"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"InterchainApp__ChainIdNotRemote","type":"error"},{"inputs":[],"name":"InterchainApp__GovernorActionFrozen","type":"error"},{"inputs":[],"name":"InterchainApp__GuardConfigInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__InterchainClientAlreadyAdded","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__InterchainClientAlreadyLatest","type":"error"},{"inputs":[],"name":"InterchainApp__InterchainClientZeroAddress","type":"error"},{"inputs":[],"name":"InterchainApp__LinkedAppFrozen","type":"error"},{"inputs":[{"internalType":"bytes32","name":"linkedApp","type":"bytes32"}],"name":"InterchainApp__LinkedAppNotEVM","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleAlreadyAdded","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleNotAdded","type":"error"},{"inputs":[],"name":"InterchainApp__ModuleZeroAddress","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"InterchainApp__NotInterchainClient","type":"error"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"InterchainApp__ReceiverZeroAddress","type":"error"},{"inputs":[],"name":"InterchainApp__RemoteAppZeroAddress","type":"error"},{"inputs":[{"internalType":"uint64","name":"srcChainId","type":"uint64"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"InterchainApp__SrcSenderNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optimisticSeconds","type":"uint256"}],"name":"AppConfigV1Set","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"chainId","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"AppLinked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionService","type":"address"}],"name":"ExecutionServiceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"GasLimitSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"action","type":"uint256"}],"name":"GovernorActionFrozen","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"guardFlag","type":"uint8"},{"indexed":false,"internalType":"address","name":"guard","type":"address"},{"indexed":false,"internalType":"uint48","name":"optimisticSeconds","type":"uint48"}],"name":"GuardConfigSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"LatestClientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"LinkedAppFrozen","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"counter","type":"uint256"}],"name":"PingDisrupted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"counter","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"dbNonce","type":"uint64"}],"name":"PingReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"counter","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"dbNonce","type":"uint64"}],"name":"PingSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"requiredResponses","type":"uint8"}],"name":"RequiredResponsesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleRemoved","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IC_GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"},{"internalType":"bool","name":"updateLatest","type":"bool"}],"name":"addInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"addTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"srcChainId","type":"uint64"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"dbNonce","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"enum IInterchainAppV1.GovernorAction","name":"action","type":"uint8"}],"name":"freezeGovernorAction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"freezeLinkedApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAppConfigV1","outputs":[{"components":[{"internalType":"uint8","name":"requiredResponses","type":"uint8"},{"internalType":"uint48","name":"optimisticSeconds","type":"uint48"},{"internalType":"uint8","name":"guardFlag","type":"uint8"},{"internalType":"address","name":"guard","type":"address"}],"internalType":"struct AppConfigV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExecutionService","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInterchainClients","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestInterchainClient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"getLinkedApp","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"getLinkedAppEVM","outputs":[{"internalType":"address","name":"linkedAppEVM","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getModules","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"dstChainId","type":"uint64"}],"name":"getPingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum IInterchainAppV1.GovernorAction","name":"action","type":"uint8"}],"name":"isGovernorActionFrozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"isLinkedAppFrozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"},{"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"linkRemoteApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"},{"internalType":"address","name":"remoteApp","type":"address"}],"name":"linkRemoteAppEVM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"removeInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"removeTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executionService","type":"address"}],"name":"setExecutionService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit_","type":"uint256"}],"name":"setGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"guardFlag","type":"uint8"},{"internalType":"address","name":"guard","type":"address"},{"internalType":"uint48","name":"optimisticSeconds","type":"uint48"}],"name":"setGuardConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"setLatestInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"requiredResponses","type":"uint8"}],"name":"setRequiredResponses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"dstChainId","type":"uint64"},{"internalType":"uint256","name":"counter","type":"uint256"}],"name":"startPingPong","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040523480156200001157600080fd5b506040516200276e3803806200276e833981016040819052620000349162000207565b806200004260008262000087565b506200007190507f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c848262000087565b50620000806207a120620000c4565b5062000232565b600080620000968484620000ff565b90508015620000bb576000848152600160205260409020620000b99084620001ad565b505b90505b92915050565b600c8190556040518181527f336210500e2973a38a8d7b3f978ac5bf874a3326119f3dff68651e472a1ae7729060200160405180910390a150565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16620001a4576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556200015b3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620000be565b506000620000be565b6000620000bb836001600160a01b0384166000818152600183016020526040812054620001a457508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620000be565b6000602082840312156200021a57600080fd5b81516001600160a01b0381168114620000bb57600080fd5b61252c80620002426000396000f3fe6080604052600436106102295760003560e01c80638ce3c1a411610123578063c313c807116100ab578063ed5ec8901161006f578063ed5ec8901461068f578063ee7d72b4146106af578063f22ba23d146106cf578063f68016b7146106ef578063f6b266fd1461070557600080fd5b8063c313c807146105f1578063ca15c8731461060f578063cb5038fb1461062f578063d547741f1461064f578063eb53b44e1461066f57600080fd5b8063a1aa5d68116100f2578063a1aa5d6814610567578063a217fddf14610589578063b2494df31461059e578063b70c40b3146105b3578063bc0d912c146105d357600080fd5b80638ce3c1a4146104cf5780639010d07c146104ef57806390a92c161461052757806391d148541461054757600080fd5b8063248a9ca3116101b157806336568abe1161017557806336568abe146104225780633ccfd60b14610442578063496774b1146104575780634e6427e7146104775780637717a647146104ad57600080fd5b8063248a9ca31461036f578063252760531461039f578063287bc057146103bf5780632f2ff15d146103e257806335f5ae501461040257600080fd5b806317d26286116101f857806317d26286146102bf5780631856ddfe146102df5780631969665b146102ff5780631b97bebf1461031f5780631c489e4f1461033f57600080fd5b806301ffc9a7146102355780630421a1f01461026a5780630fb591561461027f578063151778ea1461029f57600080fd5b3661023057005b600080fd5b34801561024157600080fd5b50610255610250366004611f2a565b610725565b60405190151581526020015b60405180910390f35b61027d610278366004611f69565b610750565b005b34801561028b57600080fd5b5061027d61029a366004612023565b61080f565b3480156102ab57600080fd5b5061027d6102ba36600461204f565b610865565b3480156102cb57600080fd5b5061027d6102da3660046120a1565b6109f3565b3480156102eb57600080fd5b5061027d6102fa3660046120cd565b610a03565b34801561030b57600080fd5b5061027d61031a366004612102565b610a8a565b34801561032b57600080fd5b5061027d61033a366004612123565b610b0f565b34801561034b57600080fd5b506103616000805160206124d783398151915281565b604051908152602001610261565b34801561037b57600080fd5b5061036161038a36600461213e565b60009081526020819052604090206001015490565b3480156103ab57600080fd5b506102556103ba366004612102565b610b9b565b3480156103cb57600080fd5b506103d4610bb2565b6040516102619291906121ec565b3480156103ee57600080fd5b5061027d6103fd366004612211565b610bcd565b34801561040e57600080fd5b5061027d61041d366004612234565b610bf8565b34801561042e57600080fd5b5061027d61043d366004612211565b610cbe565b34801561044e57600080fd5b5061027d610cf1565b34801561046357600080fd5b5061027d610472366004612023565b610d09565b34801561048357600080fd5b50610361610492366004612234565b6001600160401b031660009081526003602052604090205490565b3480156104b957600080fd5b506104c2610d98565b6040516102619190612251565b3480156104db57600080fd5b506102556104ea366004612234565b610e0b565b3480156104fb57600080fd5b5061050f61050a366004612295565b610e21565b6040516001600160a01b039091168152602001610261565b34801561053357600080fd5b5061050f610542366004612234565b610e40565b34801561055357600080fd5b50610255610562366004612211565b610e8c565b34801561057357600080fd5b5061057c610eb5565b60405161026191906122b7565b34801561059557600080fd5b50610361600081565b3480156105aa57600080fd5b5061057c610ec6565b3480156105bf57600080fd5b5061027d6105ce366004612023565b610ed2565b3480156105df57600080fd5b506007546001600160a01b031661050f565b3480156105fd57600080fd5b50600a546001600160a01b031661050f565b34801561061b57600080fd5b5061036161062a36600461213e565b610f8e565b34801561063b57600080fd5b5061027d61064a366004612023565b610fa5565b34801561065b57600080fd5b5061027d61066a366004612211565b61107e565b34801561067b57600080fd5b5061027d61068a366004612023565b6110a3565b34801561069b57600080fd5b506103616106aa366004612234565b6110ed565b3480156106bb57600080fd5b5061027d6106ca36600461213e565b611139565b3480156106db57600080fd5b5061027d6106ea3660046122ca565b61115a565b3480156106fb57600080fd5b50610361600c5481565b34801561071157600080fd5b5061027d6107203660046120a1565b6111a5565b60006001600160e01b03198216635a05180f60e01b148061074a575061074a82611223565b92915050565b61075933611258565b61077d57604051630578f69560e01b81523360048201526024015b60405180910390fd5b46856001600160401b0316036107b157604051632c262dc960e11b81526001600160401b0386166004820152602401610774565b6001600160401b03851660009081526003602052604090205484146107fb576040516377df34df60e01b81526001600160401b038616600482015260248101859052604401610774565b6108088585858585611265565b5050505050565b6000805160206124d7833981519152610827816112db565b6001610839815b600b9060ff166112e5565b15610857576040516377e4743360e11b815260040160405180910390fd5b61086083611308565b505050565b6000805160206124d783398151915261087d816112db565b60066108888161082e565b156108a6576040516377e4743360e11b815260040160405180910390fd5b600060ff861615806108bb575060ff86166001145b90506001600160a01b03851615811515146108e95760405163d120e60960e01b815260040160405180910390fd5b60ff8616158015610901575065ffffffffffff841615155b1561091f5760405163d120e60960e01b815260040160405180910390fd5b604080516080810182526002805460ff80821680855265ffffffffffff8a166020808701829052928d168688018190526001600160a01b038d16606080890182905266ffffffffffffff19909616909317610100830217670100000000000000600160e01b031916600160381b820268010000000000000000600160e01b03191617600160401b8402179095558651948552918401529382019390935290917f47b82ae8864c6de48fdd58ee55ed66e5c4fc4df4b49b28a2bca7eb59d2dcb0ef91015b60405180910390a150505050505050565b6109ff828260016113ae565b5050565b6000805160206124d7833981519152610a1b816112db565b6007610a268161082e565b15610a44576040516377e4743360e11b815260040160405180910390fd5b83610a5960046001600160401b0383166112e5565b15610a7757604051631485319360e21b815260040160405180910390fd5b610808856001600160a01b0386166114a4565b6000805160206124d7833981519152610aa2816112db565b610ac2826008811115610ab757610ab7612306565b600b9060ff1661154b565b7f65840c8b382352386060f3362f518d70a3790366f3ff9af03f887e6926bc1c6f826008811115610af557610af5612306565b60405160ff90911681526020015b60405180910390a15050565b6000805160206124d7833981519152610b27816112db565b6005610b328161082e565b15610b50576040516377e4743360e11b815260040160405180910390fd5b6002805460ff191660ff85169081179091556040519081527f5c20111b4bcf5d08e18bb70101145657707fddb47f62f4229f64847e78d4faf4906020015b60405180910390a1505050565b600061074a82600881111561082e5761082e612306565b606080610bbd611596565b9150610bc7610ec6565b90509091565b600082815260208190526040902060010154610be8816112db565b610bf283836115a8565b50505050565b6000805160206124d7833981519152610c10816112db565b6007610c1b8161082e565b15610c39576040516377e4743360e11b815260040160405180910390fd5b6001600160401b0383166000908152600360205260408120549003610c715760405163a72ac69d60e01b815260040160405180910390fd5b610c8560046001600160401b03851661154b565b6040516001600160401b03841681527fb8cbced7b060aa2cc7439d8e2dae953b6e104f2a4c72a77001db8a8d0fe5718990602001610b8e565b6001600160a01b0381163314610ce75760405163334bd91960e11b815260040160405180910390fd5b61086082826115dd565b6000610cfc816112db565b610d06334761160a565b50565b6000805160206124d7833981519152610d21816112db565b6008610d2c8161082e565b15610d4a576040516377e4743360e11b815260040160405180910390fd5b600a80546001600160a01b0319166001600160a01b0385169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e90602001610b8e565b604080516080810182526000808252602082018190529181018290526060810191909152506040805160808101825260025460ff8082168352610100820465ffffffffffff166020840152600160381b82041692820192909252600160401b9091046001600160a01b0316606082015290565b600061074a60046001600160401b0384166112e5565b6000828152600160205260408120610e3990836116a1565b9392505050565b6001600160401b038116600090815260036020526040902054806001600160a01b0381168114610e86576040516382a4102b60e01b815260048101829052602401610774565b50919050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060610ec160056116ad565b905090565b6060610ec160086116ad565b6000805160206124d7833981519152610eea816112db565b6004610ef58161082e565b15610f13576040516377e4743360e11b815260040160405180910390fd5b6000610f206008856116ba565b905080610f4b57604051635895247360e11b81526001600160a01b0385166004820152602401610774565b6040516001600160a01b03851681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020015b60405180910390a150505050565b600081815260016020526040812061074a906116cf565b6000805160206124d7833981519152610fbd816112db565b6003610fc88161082e565b15610fe6576040516377e4743360e11b815260040160405180910390fd5b6001600160a01b03831661100d57604051635467061760e11b815260040160405180910390fd5b600061101a6008856116d9565b9050806110455760405163215b8e2b60e21b81526001600160a01b0385166004820152602401610774565b6040516001600160a01b03851681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a5011750990602001610f80565b600082815260208190526040902060010154611099816112db565b610bf283836115dd565b6000805160206124d78339815191526110bb816112db565b60026110c68161082e565b156110e4576040516377e4743360e11b815260040160405180910390fd5b610860836116ee565b604080518082018252600c548152600060208083018290528351808201839052845180820390920182528401909352916111318461112a846117d8565b8351611816565b949350505050565b6000805160206124d7833981519152611151816112db565b6109ff826118ea565b6000805160206124d7833981519152611172816112db565b600061117d8161082e565b1561119b576040516377e4743360e11b815260040160405180910390fd5b610bf2848461191f565b6000805160206124d78339815191526111bd816112db565b60076111c88161082e565b156111e6576040516377e4743360e11b815260040160405180910390fd5b836111fb60046001600160401b0383166112e5565b1561121957604051631485319360e21b815260040160405180910390fd5b61080885856114a4565b60006001600160e01b03198216637965db0b60e01b148061074a57506301ffc9a760e01b6001600160e01b031983161461074a565b600061074a6005836119ce565b60006112738284018461213e565b604080518281526001600160401b03871660208201529192507fc3d24d80f3729a777c08ca6b879a4a162aa5e25c4744c55841b1558c38c0233e910160405180910390a180156112d3576112d3866112cc60018461231c565b60006113ae565b505050505050565b610d0681336119f0565b600881901c600090815260208390526040812054600160ff84161b161515610e39565b61131181611258565b61133957604051630578f69560e01b81526001600160a01b0382166004820152602401610774565b611344816000611a29565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16007546001600160a01b03166001600160a01b0316816001600160a01b031603610d0657610d0660006116ee565b60006040518060400160405280600c548152602001600081525090506000836040516020016113df91815260200190565b604051602081830303815290604052905060006113fe86848451611a45565b9050804710801561140d575083155b1561144d576040518581527ff83d5148c4e705c82778f8aed1bb387ea5a8c0046cd647c807b70d65932210c29060200160405180910390a1505050505050565b600061145b87838686611a5e565b90507ff49ca760b7c158bf7657b69ea354b3c05e11991cc8688298400f98764aee22998682602001516040516109e29291909182526001600160401b0316602082015260400190565b46826001600160401b0316036114d857604051632c262dc960e11b81526001600160401b0383166004820152602401610774565b60008190036114fa5760405163a72ac69d60e01b815260040160405180910390fd5b6001600160401b038216600081815260036020908152604091829020849055815192835282018390527f8991328923b5fe27cc7262398cb29b1b735f93970fd36a5a62a8a47545c9c5f79101610b03565b61155582826112e5565b156115735760405163cab8db6960e01b815260040160405180910390fd5b600881901c60009081526020839052604090208054600160ff84161b1790555050565b6060610ec16115a3610d98565b611ab1565b6000806115b58484611ac9565b90508015610e395760008481526001602052604090206115d590846116d9565b509392505050565b6000806115ea8484611b5b565b90508015610e395760008481526001602052604090206115d590846116ba565b8047101561162d5760405163cd78605960e01b8152306004820152602401610774565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461167a576040519150601f19603f3d011682016040523d82523d6000602084013e61167f565b606091505b505090508061086057604051630a12f52160e11b815260040160405180910390fd5b6000610e398383611bc6565b60606000610e3983611bf0565b6000610e39836001600160a01b038416611c4c565b600061074a825490565b6000610e39836001600160a01b038416611d3f565b6116f781611258565b15801561170c57506001600160a01b03811615155b1561173557604051630578f69560e01b81526001600160a01b0382166004820152602401610774565b6007546001600160a01b03166001600160a01b0316816001600160a01b03160361177d57604051634542adbf60e11b81526001600160a01b0382166004820152602401610774565b600780546001600160a01b0319166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c169906020015b60405180910390a150565b606061074a6001836040516020016118029190815181526020918201519181019190915260400190565b604051602081830303815290604052611d86565b60008061182b6007546001600160a01b031690565b90506001600160a01b038116611854576040516335f2562960e11b815260040160405180910390fd5b806001600160a01b031663cbb3c63186611876600a546001600160a01b031690565b61187e610ec6565b88886040518663ffffffff1660e01b81526004016118a095949392919061233d565b602060405180830381865afa1580156118bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e19190612395565b95945050505050565b600c8190556040518181527f336210500e2973a38a8d7b3f978ac5bf874a3326119f3dff68651e472a1ae772906020016117cd565b6001600160a01b038216611946576040516335f2562960e11b815260040160405180910390fd5b61194f82611258565b156119785760405163d497fddf60e01b81526001600160a01b0383166004820152602401610774565b611983826001611a29565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156109ff576109ff826116ee565b6001600160a01b03811660009081526001830160205260408120541515610e39565b6119fa8282610e8c565b6109ff5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610774565b8015611a3a576108606005836116d9565b6108606005836116ba565b600080611a51846117d8565b90506118e1858285611816565b60408051808201909152600080825260208201526000611a7d846117d8565b6001600160401b038716600090815260036020526040902054909150611aa7908790878487611db2565b9695505050505050565b606061074a6001836040516020016118029190612251565b6000611ad58383610e8c565b611b53576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055611b0b3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161074a565b50600061074a565b6000611b678383610e8c565b15611b53576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161074a565b6000826000018281548110611bdd57611bdd6123ae565b9060005260206000200154905092915050565b606081600001805480602002602001604051908101604052809291908181526020018280548015611c4057602002820191906000526020600020905b815481526020019060010190808311611c2c575b50505050509050919050565b60008181526001830160205260408120548015611d35576000611c7060018361231c565b8554909150600090611c849060019061231c565b9050808214611ce9576000866000018281548110611ca457611ca46123ae565b9060005260206000200154905080876000018481548110611cc757611cc76123ae565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611cfa57611cfa6123c4565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061074a565b600091505061074a565b6000818152600183016020526040812054611b535750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561074a565b60608282604051602001611d9b9291906123da565b604051602081830303815290604052905092915050565b60408051808201909152600080825260208201526000611dda6007546001600160a01b031690565b90506001600160a01b038116611e03576040516335f2562960e11b815260040160405180910390fd5b46876001600160401b031603611e3757604051632c262dc960e11b81526001600160401b0388166004820152602401610774565b6000869003611e645760405163cd256fe760e01b81526001600160401b0388166004820152602401610774565b84471015611e8e57604051630849070b60e31b815247600482015260248101869052604401610774565b806001600160a01b031663547efb84868989611eb2600a546001600160a01b031690565b611eba610ec6565b8a8a6040518863ffffffff1660e01b8152600401611edd9695949392919061240a565b604080518083038185885af1158015611efa573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611f1f9190612473565b979650505050505050565b600060208284031215611f3c57600080fd5b81356001600160e01b031981168114610e3957600080fd5b6001600160401b0381168114610d0657600080fd5b600080600080600060808688031215611f8157600080fd5b8535611f8c81611f54565b9450602086013593506040860135611fa381611f54565b925060608601356001600160401b0380821115611fbf57600080fd5b818801915088601f830112611fd357600080fd5b813581811115611fe257600080fd5b896020828501011115611ff457600080fd5b9699959850939650602001949392505050565b80356001600160a01b038116811461201e57600080fd5b919050565b60006020828403121561203557600080fd5b610e3982612007565b803560ff8116811461201e57600080fd5b60008060006060848603121561206457600080fd5b61206d8461203e565b925061207b60208501612007565b9150604084013565ffffffffffff8116811461209657600080fd5b809150509250925092565b600080604083850312156120b457600080fd5b82356120bf81611f54565b946020939093013593505050565b600080604083850312156120e057600080fd5b82356120eb81611f54565b91506120f960208401612007565b90509250929050565b60006020828403121561211457600080fd5b813560098110610e3957600080fd5b60006020828403121561213557600080fd5b610e398261203e565b60006020828403121561215057600080fd5b5035919050565b60005b8381101561217257818101518382015260200161215a565b50506000910152565b60008151808452612193816020860160208601612157565b601f01601f19169290920160200192915050565b60008151808452602080850194506020840160005b838110156121e15781516001600160a01b0316875295820195908201906001016121bc565b509495945050505050565b6040815260006121ff604083018561217b565b82810360208401526118e181856121a7565b6000806040838503121561222457600080fd5b823591506120f960208401612007565b60006020828403121561224657600080fd5b8135610e3981611f54565b815160ff908116825260208084015165ffffffffffff1690830152604080840151909116908201526060918201516001600160a01b03169181019190915260800190565b600080604083850312156122a857600080fd5b50508035926020909101359150565b602081526000610e3960208301846121a7565b600080604083850312156122dd57600080fd5b6122e683612007565b9150602083013580151581146122fb57600080fd5b809150509250929050565b634e487b7160e01b600052602160045260246000fd5b8181038181111561074a57634e487b7160e01b600052601160045260246000fd5b6001600160401b03861681526001600160a01b038516602082015260a060408201819052600090612370908301866121a7565b8281036060840152612382818661217b565b9150508260808301529695505050505050565b6000602082840312156123a757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b61ffff60f01b8360f01b168152600082516123fc816002850160208701612157565b919091016002019392505050565b6001600160401b038716815285602082015260018060a01b038516604082015260c06060820152600061244060c08301866121a7565b8281036080840152612452818661217b565b905082810360a0840152612466818561217b565b9998505050505050505050565b60006040828403121561248557600080fd5b604051604081018181106001600160401b03821117156124b557634e487b7160e01b600052604160045260246000fd5b6040528251815260208301516124ca81611f54565b6020820152939250505056fe67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84a26469706673582212207c64c9959eda1575fcacc2fc5a1baa6467ac92e01f5c4a410359898284fa596864736f6c63430008180033000000000000000000000000e7353bedc72d29f99d6ca5cde69f807cce5d57e4
Deployed Bytecode
0x6080604052600436106102295760003560e01c80638ce3c1a411610123578063c313c807116100ab578063ed5ec8901161006f578063ed5ec8901461068f578063ee7d72b4146106af578063f22ba23d146106cf578063f68016b7146106ef578063f6b266fd1461070557600080fd5b8063c313c807146105f1578063ca15c8731461060f578063cb5038fb1461062f578063d547741f1461064f578063eb53b44e1461066f57600080fd5b8063a1aa5d68116100f2578063a1aa5d6814610567578063a217fddf14610589578063b2494df31461059e578063b70c40b3146105b3578063bc0d912c146105d357600080fd5b80638ce3c1a4146104cf5780639010d07c146104ef57806390a92c161461052757806391d148541461054757600080fd5b8063248a9ca3116101b157806336568abe1161017557806336568abe146104225780633ccfd60b14610442578063496774b1146104575780634e6427e7146104775780637717a647146104ad57600080fd5b8063248a9ca31461036f578063252760531461039f578063287bc057146103bf5780632f2ff15d146103e257806335f5ae501461040257600080fd5b806317d26286116101f857806317d26286146102bf5780631856ddfe146102df5780631969665b146102ff5780631b97bebf1461031f5780631c489e4f1461033f57600080fd5b806301ffc9a7146102355780630421a1f01461026a5780630fb591561461027f578063151778ea1461029f57600080fd5b3661023057005b600080fd5b34801561024157600080fd5b50610255610250366004611f2a565b610725565b60405190151581526020015b60405180910390f35b61027d610278366004611f69565b610750565b005b34801561028b57600080fd5b5061027d61029a366004612023565b61080f565b3480156102ab57600080fd5b5061027d6102ba36600461204f565b610865565b3480156102cb57600080fd5b5061027d6102da3660046120a1565b6109f3565b3480156102eb57600080fd5b5061027d6102fa3660046120cd565b610a03565b34801561030b57600080fd5b5061027d61031a366004612102565b610a8a565b34801561032b57600080fd5b5061027d61033a366004612123565b610b0f565b34801561034b57600080fd5b506103616000805160206124d783398151915281565b604051908152602001610261565b34801561037b57600080fd5b5061036161038a36600461213e565b60009081526020819052604090206001015490565b3480156103ab57600080fd5b506102556103ba366004612102565b610b9b565b3480156103cb57600080fd5b506103d4610bb2565b6040516102619291906121ec565b3480156103ee57600080fd5b5061027d6103fd366004612211565b610bcd565b34801561040e57600080fd5b5061027d61041d366004612234565b610bf8565b34801561042e57600080fd5b5061027d61043d366004612211565b610cbe565b34801561044e57600080fd5b5061027d610cf1565b34801561046357600080fd5b5061027d610472366004612023565b610d09565b34801561048357600080fd5b50610361610492366004612234565b6001600160401b031660009081526003602052604090205490565b3480156104b957600080fd5b506104c2610d98565b6040516102619190612251565b3480156104db57600080fd5b506102556104ea366004612234565b610e0b565b3480156104fb57600080fd5b5061050f61050a366004612295565b610e21565b6040516001600160a01b039091168152602001610261565b34801561053357600080fd5b5061050f610542366004612234565b610e40565b34801561055357600080fd5b50610255610562366004612211565b610e8c565b34801561057357600080fd5b5061057c610eb5565b60405161026191906122b7565b34801561059557600080fd5b50610361600081565b3480156105aa57600080fd5b5061057c610ec6565b3480156105bf57600080fd5b5061027d6105ce366004612023565b610ed2565b3480156105df57600080fd5b506007546001600160a01b031661050f565b3480156105fd57600080fd5b50600a546001600160a01b031661050f565b34801561061b57600080fd5b5061036161062a36600461213e565b610f8e565b34801561063b57600080fd5b5061027d61064a366004612023565b610fa5565b34801561065b57600080fd5b5061027d61066a366004612211565b61107e565b34801561067b57600080fd5b5061027d61068a366004612023565b6110a3565b34801561069b57600080fd5b506103616106aa366004612234565b6110ed565b3480156106bb57600080fd5b5061027d6106ca36600461213e565b611139565b3480156106db57600080fd5b5061027d6106ea3660046122ca565b61115a565b3480156106fb57600080fd5b50610361600c5481565b34801561071157600080fd5b5061027d6107203660046120a1565b6111a5565b60006001600160e01b03198216635a05180f60e01b148061074a575061074a82611223565b92915050565b61075933611258565b61077d57604051630578f69560e01b81523360048201526024015b60405180910390fd5b46856001600160401b0316036107b157604051632c262dc960e11b81526001600160401b0386166004820152602401610774565b6001600160401b03851660009081526003602052604090205484146107fb576040516377df34df60e01b81526001600160401b038616600482015260248101859052604401610774565b6108088585858585611265565b5050505050565b6000805160206124d7833981519152610827816112db565b6001610839815b600b9060ff166112e5565b15610857576040516377e4743360e11b815260040160405180910390fd5b61086083611308565b505050565b6000805160206124d783398151915261087d816112db565b60066108888161082e565b156108a6576040516377e4743360e11b815260040160405180910390fd5b600060ff861615806108bb575060ff86166001145b90506001600160a01b03851615811515146108e95760405163d120e60960e01b815260040160405180910390fd5b60ff8616158015610901575065ffffffffffff841615155b1561091f5760405163d120e60960e01b815260040160405180910390fd5b604080516080810182526002805460ff80821680855265ffffffffffff8a166020808701829052928d168688018190526001600160a01b038d16606080890182905266ffffffffffffff19909616909317610100830217670100000000000000600160e01b031916600160381b820268010000000000000000600160e01b03191617600160401b8402179095558651948552918401529382019390935290917f47b82ae8864c6de48fdd58ee55ed66e5c4fc4df4b49b28a2bca7eb59d2dcb0ef91015b60405180910390a150505050505050565b6109ff828260016113ae565b5050565b6000805160206124d7833981519152610a1b816112db565b6007610a268161082e565b15610a44576040516377e4743360e11b815260040160405180910390fd5b83610a5960046001600160401b0383166112e5565b15610a7757604051631485319360e21b815260040160405180910390fd5b610808856001600160a01b0386166114a4565b6000805160206124d7833981519152610aa2816112db565b610ac2826008811115610ab757610ab7612306565b600b9060ff1661154b565b7f65840c8b382352386060f3362f518d70a3790366f3ff9af03f887e6926bc1c6f826008811115610af557610af5612306565b60405160ff90911681526020015b60405180910390a15050565b6000805160206124d7833981519152610b27816112db565b6005610b328161082e565b15610b50576040516377e4743360e11b815260040160405180910390fd5b6002805460ff191660ff85169081179091556040519081527f5c20111b4bcf5d08e18bb70101145657707fddb47f62f4229f64847e78d4faf4906020015b60405180910390a1505050565b600061074a82600881111561082e5761082e612306565b606080610bbd611596565b9150610bc7610ec6565b90509091565b600082815260208190526040902060010154610be8816112db565b610bf283836115a8565b50505050565b6000805160206124d7833981519152610c10816112db565b6007610c1b8161082e565b15610c39576040516377e4743360e11b815260040160405180910390fd5b6001600160401b0383166000908152600360205260408120549003610c715760405163a72ac69d60e01b815260040160405180910390fd5b610c8560046001600160401b03851661154b565b6040516001600160401b03841681527fb8cbced7b060aa2cc7439d8e2dae953b6e104f2a4c72a77001db8a8d0fe5718990602001610b8e565b6001600160a01b0381163314610ce75760405163334bd91960e11b815260040160405180910390fd5b61086082826115dd565b6000610cfc816112db565b610d06334761160a565b50565b6000805160206124d7833981519152610d21816112db565b6008610d2c8161082e565b15610d4a576040516377e4743360e11b815260040160405180910390fd5b600a80546001600160a01b0319166001600160a01b0385169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e90602001610b8e565b604080516080810182526000808252602082018190529181018290526060810191909152506040805160808101825260025460ff8082168352610100820465ffffffffffff166020840152600160381b82041692820192909252600160401b9091046001600160a01b0316606082015290565b600061074a60046001600160401b0384166112e5565b6000828152600160205260408120610e3990836116a1565b9392505050565b6001600160401b038116600090815260036020526040902054806001600160a01b0381168114610e86576040516382a4102b60e01b815260048101829052602401610774565b50919050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060610ec160056116ad565b905090565b6060610ec160086116ad565b6000805160206124d7833981519152610eea816112db565b6004610ef58161082e565b15610f13576040516377e4743360e11b815260040160405180910390fd5b6000610f206008856116ba565b905080610f4b57604051635895247360e11b81526001600160a01b0385166004820152602401610774565b6040516001600160a01b03851681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020015b60405180910390a150505050565b600081815260016020526040812061074a906116cf565b6000805160206124d7833981519152610fbd816112db565b6003610fc88161082e565b15610fe6576040516377e4743360e11b815260040160405180910390fd5b6001600160a01b03831661100d57604051635467061760e11b815260040160405180910390fd5b600061101a6008856116d9565b9050806110455760405163215b8e2b60e21b81526001600160a01b0385166004820152602401610774565b6040516001600160a01b03851681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a5011750990602001610f80565b600082815260208190526040902060010154611099816112db565b610bf283836115dd565b6000805160206124d78339815191526110bb816112db565b60026110c68161082e565b156110e4576040516377e4743360e11b815260040160405180910390fd5b610860836116ee565b604080518082018252600c548152600060208083018290528351808201839052845180820390920182528401909352916111318461112a846117d8565b8351611816565b949350505050565b6000805160206124d7833981519152611151816112db565b6109ff826118ea565b6000805160206124d7833981519152611172816112db565b600061117d8161082e565b1561119b576040516377e4743360e11b815260040160405180910390fd5b610bf2848461191f565b6000805160206124d78339815191526111bd816112db565b60076111c88161082e565b156111e6576040516377e4743360e11b815260040160405180910390fd5b836111fb60046001600160401b0383166112e5565b1561121957604051631485319360e21b815260040160405180910390fd5b61080885856114a4565b60006001600160e01b03198216637965db0b60e01b148061074a57506301ffc9a760e01b6001600160e01b031983161461074a565b600061074a6005836119ce565b60006112738284018461213e565b604080518281526001600160401b03871660208201529192507fc3d24d80f3729a777c08ca6b879a4a162aa5e25c4744c55841b1558c38c0233e910160405180910390a180156112d3576112d3866112cc60018461231c565b60006113ae565b505050505050565b610d0681336119f0565b600881901c600090815260208390526040812054600160ff84161b161515610e39565b61131181611258565b61133957604051630578f69560e01b81526001600160a01b0382166004820152602401610774565b611344816000611a29565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16007546001600160a01b03166001600160a01b0316816001600160a01b031603610d0657610d0660006116ee565b60006040518060400160405280600c548152602001600081525090506000836040516020016113df91815260200190565b604051602081830303815290604052905060006113fe86848451611a45565b9050804710801561140d575083155b1561144d576040518581527ff83d5148c4e705c82778f8aed1bb387ea5a8c0046cd647c807b70d65932210c29060200160405180910390a1505050505050565b600061145b87838686611a5e565b90507ff49ca760b7c158bf7657b69ea354b3c05e11991cc8688298400f98764aee22998682602001516040516109e29291909182526001600160401b0316602082015260400190565b46826001600160401b0316036114d857604051632c262dc960e11b81526001600160401b0383166004820152602401610774565b60008190036114fa5760405163a72ac69d60e01b815260040160405180910390fd5b6001600160401b038216600081815260036020908152604091829020849055815192835282018390527f8991328923b5fe27cc7262398cb29b1b735f93970fd36a5a62a8a47545c9c5f79101610b03565b61155582826112e5565b156115735760405163cab8db6960e01b815260040160405180910390fd5b600881901c60009081526020839052604090208054600160ff84161b1790555050565b6060610ec16115a3610d98565b611ab1565b6000806115b58484611ac9565b90508015610e395760008481526001602052604090206115d590846116d9565b509392505050565b6000806115ea8484611b5b565b90508015610e395760008481526001602052604090206115d590846116ba565b8047101561162d5760405163cd78605960e01b8152306004820152602401610774565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461167a576040519150601f19603f3d011682016040523d82523d6000602084013e61167f565b606091505b505090508061086057604051630a12f52160e11b815260040160405180910390fd5b6000610e398383611bc6565b60606000610e3983611bf0565b6000610e39836001600160a01b038416611c4c565b600061074a825490565b6000610e39836001600160a01b038416611d3f565b6116f781611258565b15801561170c57506001600160a01b03811615155b1561173557604051630578f69560e01b81526001600160a01b0382166004820152602401610774565b6007546001600160a01b03166001600160a01b0316816001600160a01b03160361177d57604051634542adbf60e11b81526001600160a01b0382166004820152602401610774565b600780546001600160a01b0319166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c169906020015b60405180910390a150565b606061074a6001836040516020016118029190815181526020918201519181019190915260400190565b604051602081830303815290604052611d86565b60008061182b6007546001600160a01b031690565b90506001600160a01b038116611854576040516335f2562960e11b815260040160405180910390fd5b806001600160a01b031663cbb3c63186611876600a546001600160a01b031690565b61187e610ec6565b88886040518663ffffffff1660e01b81526004016118a095949392919061233d565b602060405180830381865afa1580156118bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e19190612395565b95945050505050565b600c8190556040518181527f336210500e2973a38a8d7b3f978ac5bf874a3326119f3dff68651e472a1ae772906020016117cd565b6001600160a01b038216611946576040516335f2562960e11b815260040160405180910390fd5b61194f82611258565b156119785760405163d497fddf60e01b81526001600160a01b0383166004820152602401610774565b611983826001611a29565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156109ff576109ff826116ee565b6001600160a01b03811660009081526001830160205260408120541515610e39565b6119fa8282610e8c565b6109ff5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610774565b8015611a3a576108606005836116d9565b6108606005836116ba565b600080611a51846117d8565b90506118e1858285611816565b60408051808201909152600080825260208201526000611a7d846117d8565b6001600160401b038716600090815260036020526040902054909150611aa7908790878487611db2565b9695505050505050565b606061074a6001836040516020016118029190612251565b6000611ad58383610e8c565b611b53576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055611b0b3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161074a565b50600061074a565b6000611b678383610e8c565b15611b53576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161074a565b6000826000018281548110611bdd57611bdd6123ae565b9060005260206000200154905092915050565b606081600001805480602002602001604051908101604052809291908181526020018280548015611c4057602002820191906000526020600020905b815481526020019060010190808311611c2c575b50505050509050919050565b60008181526001830160205260408120548015611d35576000611c7060018361231c565b8554909150600090611c849060019061231c565b9050808214611ce9576000866000018281548110611ca457611ca46123ae565b9060005260206000200154905080876000018481548110611cc757611cc76123ae565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611cfa57611cfa6123c4565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061074a565b600091505061074a565b6000818152600183016020526040812054611b535750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561074a565b60608282604051602001611d9b9291906123da565b604051602081830303815290604052905092915050565b60408051808201909152600080825260208201526000611dda6007546001600160a01b031690565b90506001600160a01b038116611e03576040516335f2562960e11b815260040160405180910390fd5b46876001600160401b031603611e3757604051632c262dc960e11b81526001600160401b0388166004820152602401610774565b6000869003611e645760405163cd256fe760e01b81526001600160401b0388166004820152602401610774565b84471015611e8e57604051630849070b60e31b815247600482015260248101869052604401610774565b806001600160a01b031663547efb84868989611eb2600a546001600160a01b031690565b611eba610ec6565b8a8a6040518863ffffffff1660e01b8152600401611edd9695949392919061240a565b604080518083038185885af1158015611efa573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611f1f9190612473565b979650505050505050565b600060208284031215611f3c57600080fd5b81356001600160e01b031981168114610e3957600080fd5b6001600160401b0381168114610d0657600080fd5b600080600080600060808688031215611f8157600080fd5b8535611f8c81611f54565b9450602086013593506040860135611fa381611f54565b925060608601356001600160401b0380821115611fbf57600080fd5b818801915088601f830112611fd357600080fd5b813581811115611fe257600080fd5b896020828501011115611ff457600080fd5b9699959850939650602001949392505050565b80356001600160a01b038116811461201e57600080fd5b919050565b60006020828403121561203557600080fd5b610e3982612007565b803560ff8116811461201e57600080fd5b60008060006060848603121561206457600080fd5b61206d8461203e565b925061207b60208501612007565b9150604084013565ffffffffffff8116811461209657600080fd5b809150509250925092565b600080604083850312156120b457600080fd5b82356120bf81611f54565b946020939093013593505050565b600080604083850312156120e057600080fd5b82356120eb81611f54565b91506120f960208401612007565b90509250929050565b60006020828403121561211457600080fd5b813560098110610e3957600080fd5b60006020828403121561213557600080fd5b610e398261203e565b60006020828403121561215057600080fd5b5035919050565b60005b8381101561217257818101518382015260200161215a565b50506000910152565b60008151808452612193816020860160208601612157565b601f01601f19169290920160200192915050565b60008151808452602080850194506020840160005b838110156121e15781516001600160a01b0316875295820195908201906001016121bc565b509495945050505050565b6040815260006121ff604083018561217b565b82810360208401526118e181856121a7565b6000806040838503121561222457600080fd5b823591506120f960208401612007565b60006020828403121561224657600080fd5b8135610e3981611f54565b815160ff908116825260208084015165ffffffffffff1690830152604080840151909116908201526060918201516001600160a01b03169181019190915260800190565b600080604083850312156122a857600080fd5b50508035926020909101359150565b602081526000610e3960208301846121a7565b600080604083850312156122dd57600080fd5b6122e683612007565b9150602083013580151581146122fb57600080fd5b809150509250929050565b634e487b7160e01b600052602160045260246000fd5b8181038181111561074a57634e487b7160e01b600052601160045260246000fd5b6001600160401b03861681526001600160a01b038516602082015260a060408201819052600090612370908301866121a7565b8281036060840152612382818661217b565b9150508260808301529695505050505050565b6000602082840312156123a757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b61ffff60f01b8360f01b168152600082516123fc816002850160208701612157565b919091016002019392505050565b6001600160401b038716815285602082015260018060a01b038516604082015260c06060820152600061244060c08301866121a7565b8281036080840152612452818661217b565b905082810360a0840152612466818561217b565b9998505050505050505050565b60006040828403121561248557600080fd5b604051604081018181106001600160401b03821117156124b557634e487b7160e01b600052604160045260246000fd5b6040528251815260208301516124ca81611f54565b6020820152939250505056fe67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84a26469706673582212207c64c9959eda1575fcacc2fc5a1baa6467ac92e01f5c4a410359898284fa596864736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000e7353bedc72d29f99d6ca5cde69f807cce5d57e4
-----Decoded View---------------
Arg [0] : admin (address): 0xE7353BEdc72D29f99D6cA5CDE69F807cCE5d57e4
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000e7353bedc72d29f99d6ca5cde69f807cce5d57e4
Loading...
Loading
[ Download: CSV Export ]
[ 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.