Source Code
Overview
ETH Balance
0.0999928 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 15 from a total of 15 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Start Ping Pong | 5877109 | 547 days ago | IN | 0 ETH | 0.00031195 | ||||
| Start Ping Pong | 5877086 | 547 days ago | IN | 0 ETH | 0.00031194 | ||||
| Start Ping Pong | 5876128 | 547 days ago | IN | 0 ETH | 0.00031199 | ||||
| Start Ping Pong | 5876011 | 548 days ago | IN | 0 ETH | 0.00031201 | ||||
| Start Ping Pong | 5875375 | 548 days ago | IN | 0 ETH | 0.00031229 | ||||
| Start Ping Pong | 5875103 | 548 days ago | IN | 0 ETH | 0.00031225 | ||||
| Start Ping Pong | 5875006 | 548 days ago | IN | 0 ETH | 0.00031203 | ||||
| Start Ping Pong | 5869824 | 548 days ago | IN | 0 ETH | 0.00031199 | ||||
| Start Ping Pong | 5868967 | 549 days ago | IN | 0 ETH | 0.00209161 | ||||
| Transfer | 5868964 | 549 days ago | IN | 0.1 ETH | 0.00019366 | ||||
| Add Interchain C... | 5847993 | 552 days ago | IN | 0 ETH | 0.00607136 | ||||
| Set Execution Se... | 5847993 | 552 days ago | IN | 0 ETH | 0.00289974 | ||||
| Set App Config V... | 5847993 | 552 days ago | IN | 0 ETH | 0.00293522 | ||||
| Add Trusted Modu... | 5847993 | 552 days ago | IN | 0 ETH | 0.00562734 | ||||
| Link Remote App ... | 5847993 | 552 days ago | IN | 0 ETH | 0.00294298 |
Latest 12 internal transactions
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
To
|
Amount
|
||
|---|---|---|---|---|---|---|---|
| Interchain Send | 5877109 | 547 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5877086 | 547 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5876140 | 547 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5876128 | 547 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5876023 | 548 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5876011 | 548 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5875375 | 548 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5875103 | 548 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5875006 | 548 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5869836 | 548 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5869824 | 548 days ago | 0.0000006 ETH | ||||
| Interchain Send | 5868967 | 549 days ago | 0.0000006 ETH |
Loading...
Loading
Loading...
Loading
Contract Name:
PingPongApp
Compiler Version
v0.8.20+commit.a1b79de6
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.20;
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, uint64 entryIndex);
event PingSent(uint256 counter, uint64 dbNonce, uint64 entryIndex);
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,
uint64 entryIndex,
bytes calldata message
)
internal
override
{
uint256 counter = abi.decode(message, (uint256));
emit PingReceived(counter, dbNonce, entryIndex);
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, desc.entryIndex);
}
/// @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_DEFAULT} from "../libs/AppConfig.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";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.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 Address of the latest Interchain Client, used for sending messages.
/// Note: packed in a single storage slot with the `_requiredResponses` and `_optimisticPeriod`.
address private _latestClient;
/// @dev Required responses and optimistic period for the module responses.
uint16 private _requiredResponses;
uint48 private _optimisticPeriod;
/// @dev Address of the linked app deployed on the remote chain.
mapping(uint64 chainId => bytes32 remoteApp) private _linkedApp;
/// @dev Interchain Clients allowed to send messages to this app.
EnumerableSet.AddressSet private _interchainClients;
/// @dev Trusted Interchain modules.
EnumerableSet.AddressSet private _trustedModules;
/// @dev Execution Service to use for sending messages.
address private _executionService;
constructor(address admin) {
_grantRole(DEFAULT_ADMIN_ROLE, admin);
}
/// @inheritdoc IInterchainAppV1
function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {
_addClient(client, updateLatest);
}
/// @inheritdoc IInterchainAppV1
function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {
_removeClient(client);
}
/// @inheritdoc IInterchainAppV1
function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {
_setLatestClient(client);
}
/// @inheritdoc IInterchainAppV1
function linkRemoteApp(uint64 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {
_linkRemoteApp(chainId, remoteApp);
}
/// @inheritdoc IInterchainAppV1
function linkRemoteAppEVM(uint64 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {
_linkRemoteApp(chainId, remoteApp.addressToBytes32());
}
/// @inheritdoc IInterchainAppV1
function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {
if (module == address(0)) {
revert InterchainApp__ModuleZeroAddress();
}
bool added = _trustedModules.add(module);
if (!added) {
revert InterchainApp__ModuleAlreadyAdded(module);
}
emit TrustedModuleAdded(module);
}
/// @inheritdoc IInterchainAppV1
function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {
bool removed = _trustedModules.remove(module);
if (!removed) {
revert InterchainApp__ModuleNotAdded(module);
}
emit TrustedModuleRemoved(module);
}
/// @inheritdoc IInterchainAppV1
function setAppConfigV1(uint256 requiredResponses, uint256 optimisticPeriod) external onlyRole(IC_GOVERNOR_ROLE) {
if (requiredResponses == 0 || optimisticPeriod == 0) {
revert InterchainApp__AppConfigInvalid(requiredResponses, optimisticPeriod);
}
_requiredResponses = SafeCast.toUint16(requiredResponses);
_optimisticPeriod = SafeCast.toUint48(optimisticPeriod);
emit AppConfigV1Set(requiredResponses, optimisticPeriod);
}
/// @inheritdoc IInterchainAppV1
function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {
_executionService = executionService;
emit ExecutionServiceSet(executionService);
}
// ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════
/// @inheritdoc IInterchainAppV1
function getAppConfigV1() public view returns (AppConfigV1 memory) {
(uint8 guardFlag, address guard) = _getGuardConfig();
return AppConfigV1({
requiredResponses: _requiredResponses,
optimisticPeriod: _optimisticPeriod,
guardFlag: guardFlag,
guard: guard
});
}
/// @inheritdoc IInterchainAppV1
// solhint-disable-next-line ordering
function getExecutionService() external view returns (address) {
return _executionService;
}
/// @inheritdoc IInterchainAppV1
function getInterchainClients() external view returns (address[] memory) {
return _interchainClients.values();
}
/// @inheritdoc IInterchainAppV1
function getLatestInterchainClient() external view returns (address) {
return _latestClient;
}
/// @inheritdoc IInterchainAppV1
function getLinkedApp(uint64 chainId) external view returns (bytes32) {
return _linkedApp[chainId];
}
/// @inheritdoc IInterchainAppV1
function getLinkedAppEVM(uint64 chainId) external view returns (address linkedAppEVM) {
bytes32 linkedApp = _linkedApp[chainId];
linkedAppEVM = linkedApp.bytes32ToAddress();
if (linkedAppEVM.addressToBytes32() != linkedApp) {
revert InterchainApp__LinkedAppNotEVM(linkedApp);
}
}
/// @inheritdoc IInterchainAppV1
function getModules() external view returns (address[] memory) {
return _trustedModules.values();
}
// ═══════════════════════════════════════════ 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 guard flag and address in the app config.
/// By default, the ICApp is using the Client-provided guard, but it can be overridden in the derived contract.
function _getGuardConfig() internal view virtual returns (uint8 guardFlag, address guard) {
return (APP_CONFIG_GUARD_DEFAULT, address(0));
}
/// @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;
uint64 entryIndex;
bytes32 srcSender;
bytes32 dstReceiver;
bytes options;
bytes message;
}
struct InterchainTxDescriptor {
bytes32 transactionId;
uint64 dbNonce;
uint64 entryIndex;
}
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,
uint64 entryIndex,
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,
entryIndex: entryIndex,
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.entryIndex),
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, icTx.entryIndex) = 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, entryIndex) 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,
uint64 entryIndex
)
internal
pure
returns (ICTxHeader)
{
return ICTxHeader.wrap(
(uint256(srcChainId) << 192) | (uint256(dstChainId) << 128) | (uint256(dbNonce) << 64) | uint256(entryIndex)
);
}
function decodeTxHeader(ICTxHeader header)
internal
pure
returns (uint64 srcChainId, uint64 dstChainId, uint64 dbNonce, uint64 entryIndex)
{
srcChainId = uint64(ICTxHeader.unwrap(header) >> 192);
dstChainId = uint64(ICTxHeader.unwrap(header) >> 128);
dbNonce = uint64(ICTxHeader.unwrap(header) >> 64);
entryIndex = 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__CallerNotInterchainClient(address caller);
error InterchainApp__ChainIdNotRemote(uint64 chainId);
error InterchainApp__InterchainClientAlreadyAdded(address client);
error InterchainApp__InterchainClientAlreadyLatest(address client);
error InterchainApp__InterchainClientZeroAddress();
error InterchainApp__ReceiverZeroAddress(uint64 chainId);
error InterchainApp__SrcSenderNotAllowed(uint64 srcChainId, bytes32 sender);
/// @inheritdoc IInterchainApp
function appReceive(
uint64 srcChainId,
bytes32 sender,
uint64 dbNonce,
uint64 entryIndex,
bytes calldata message
)
external
payable
{
if (!_isInterchainClient(msg.sender)) {
revert InterchainApp__CallerNotInterchainClient(msg.sender);
}
if (srcChainId == block.chainid) {
revert InterchainApp__ChainIdNotRemote(srcChainId);
}
if (!_isAllowedSender(srcChainId, sender)) {
revert InterchainApp__SrcSenderNotAllowed(srcChainId, sender);
}
_receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);
}
/// @inheritdoc IInterchainApp
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__CallerNotInterchainClient(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__CallerNotInterchainClient(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,
uint64 entryIndex,
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 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 optimisticPeriod The time period after which a module response is considered final.
event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);
/// @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 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 {
error InterchainApp__AppConfigInvalid(uint256 requiredResponses, uint256 optimisticPeriod);
error InterchainApp__LinkedAppNotEVM(bytes32 linkedApp);
error InterchainApp__ModuleAlreadyAdded(address module);
error InterchainApp__ModuleNotAdded(address module);
error InterchainApp__ModuleZeroAddress();
error InterchainApp__RemoteAppZeroAddress();
/// @notice Allows the owner 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;
/// @notice Allows the owner 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;
/// @notice Allows the owner 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;
/// @notice Allows the owner 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;
/// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.
function linkRemoteAppEVM(uint64 chainId, address remoteApp) external;
/// @notice Allows the owner 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;
/// @notice Allows the owner to remove the module from the trusted modules set.
function removeTrustedModule(address module) external;
/// @notice Allows the owner to set the app config for the current app. App config includes:
/// - requiredResponses: the number of module responses required for accepting the message
/// - optimisticPeriod: the minimum time after which the module responses are considered final
function setAppConfigV1(uint256 requiredResponses, uint256 optimisticPeriod) external;
/// @notice Allows the owner 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;
// ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════
/// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.
function getAppConfigV1() external view returns (AppConfigV1 memory);
/// @notice Returns the address of the Execution Service used by this app for sending messages.
function getExecutionService() external view returns (address);
/// @notice Returns the list of Interchain Clients allowed to send messages to this app.
function getInterchainClients() external view returns (address[] memory);
/// @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);
/// @notice Returns the linked app address (as bytes32) for the given chain ID.
function getLinkedApp(uint64 chainId) external view returns (bytes32);
/// @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);
/// @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);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {VersionedPayloadLib} from "./VersionedPayload.sol";
// TODO: all of these could fit into a single 32 bytes slot
struct AppConfigV1 {
uint256 requiredResponses;
uint256 optimisticPeriod;
uint256 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.0;
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
// 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;
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.0;
// 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
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 {
/// @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 batch containing the message entry.
/// @param entryIndex The index of the message entry within the batch.
/// @param message The message being sent.
function appReceive(
uint64 srcChainId,
bytes32 sender,
uint64 dbNonce,
uint64 entryIndex,
bytes calldata message
)
external
payable;
/// @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);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {InterchainTransaction, InterchainTxDescriptor} from "../libs/InterchainTransaction.sol";
interface IInterchainClientV1 {
enum TxReadiness {
Ready,
AlreadyExecuted,
BatchAwaitingResponses,
BatchConflict,
ReceiverNotICApp,
ReceiverZeroRequiredResponses,
TxWrongDstChainId,
UndeterminedRevert
}
error InterchainClientV1__BatchConflict(address module);
error InterchainClientV1__ChainIdNotLinked(uint64 chainId);
error InterchainClientV1__ChainIdNotRemote(uint64 chainId);
error InterchainClientV1__DstChainIdNotLocal(uint64 chainId);
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__MsgValueMismatch(uint256 msgValue, uint256 required);
error InterchainClientV1__ReceiverNotICApp(address receiver);
error InterchainClientV1__ReceiverZeroAddress();
error InterchainClientV1__ReceiverZeroRequiredResponses(address receiver);
error InterchainClientV1__ResponsesAmountBelowMin(uint256 responsesAmount, uint256 minRequired);
error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);
error InterchainClientV1__TxNotExecuted(bytes32 transactionId);
error InterchainClientV1__TxVersionMismatch(uint16 txVersion, uint16 required);
/// @notice Allows the contract owner to set the address of the Guard module.
/// Note: batches marked as invalid by the Guard could not be used for message execution,
/// if the app opts in to use the Guard.
/// @param guard_ The address of the Guard module.
function setDefaultGuard(address guard_) external;
/**
* @notice Sets the linked client for a specific chain ID.
* @dev Stores the address of the linked client in a mapping with the chain ID as the key.
* @param chainId The chain ID for which the client is being set.
* @param client The address of the client being linked.
*/
function setLinkedClient(uint64 chainId, bytes32 client) external;
/**
* @notice Sends a message to another chain via the Interchain Communication Protocol.
* @dev Charges a fee for the message, which is payable upon calling this function:
* - Verification fees: paid to every module that verifies the message.
* - Execution fee: paid to the executor that executes the message.
* Note: while a specific execution service is specified to request the execution of the message,
* any executor is able to execute the message on destination chain, earning the execution fee.
* @param dstChainId The chain ID of the destination chain.
* @param receiver The address of the receiver on the destination chain.
* @param srcExecutionService The address of the execution service to use for the message.
* @param srcModules The source modules involved in the message sending.
* @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.
* @param message The message being sent.
* @return desc The descriptor of the sent transaction:
* - transactionId: the ID of the transaction that was sent.
* - dbNonce: the database nonce of the batch containing the written entry for transaction.
* - entryIndex: the index of the written entry for transaction within the batch.
*/
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);
/**
* @notice Executes a transaction that has been sent via the Interchain.
* @dev The transaction must have been previously sent and recorded.
* Transaction data includes the requested gas limit, but the executors could specify a different gas limit.
* If the specified gas limit is lower than requested, the requested gas limit will be used.
* Otherwise, the specified gas limit will be used.
* This allows to execute the transactions with requested gas limit set too low.
* @param gasLimit The gas limit to use for the execution.
* @param transaction The transaction data.
* @param proof The Merkle proof for transaction execution, fetched from the source chain.
*/
function interchainExecute(
uint256 gasLimit,
bytes calldata transaction,
bytes32[] calldata proof
)
external
payable;
/// @notice Writes the proof of execution for a transaction into the InterchainDB.
/// @dev Will revert if the transaction has not been executed.
/// @param transactionId The ID of the transaction to write the proof for.
/// @return dbNonce The database nonce of the batch containing the written proof for transaction.
/// @return entryIndex The index of the written proof for transaction within the batch.
function writeExecutionProof(bytes32 transactionId) external returns (uint64 dbNonce, uint64 entryIndex);
/**
* @notice Checks if a transaction is executable.
* @dev Determines if a transaction meets the criteria to be executed based on:
* - If approved modules have written to the InterchainDB
* - If the threshold of approved modules have been met
* - If the optimistic window has passed for all modules
* @param transaction The InterchainTransaction struct to be checked.
* @param proof The Merkle proof for transaction execution, fetched from the source chain.
* @return bool Returns true if the transaction is executable, false otherwise.
*/
function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);
/// @notice Returns the readiness status of a transaction to be executed.
/// @dev Some of the possible statuses have additional arguments that are returned:
/// - Ready: the transaction is ready to be executed.
/// - AlreadyExecuted: the transaction has already been executed.
/// - `firstArg` is the transaction ID.
/// - BatchAwaitingResponses: not enough responses have been received for the transaction.
/// - `firstArg` is the number of responses received.
/// - `secondArg` is the number of responses required.
/// - BatchConflict: one of the modules have submitted a conflicting batch.
/// - `firstArg` is the address of the module.
/// - This is either one of the modules that the app trusts, or the Guard module used by the app.
/// - ReceiverNotICApp: the receiver is not an Interchain app.
/// - `firstArg` is the receiver address.
/// - ReceiverZeroRequiredResponses: the app config requires zero responses for the transaction.
/// - TxWrongDstChainId: the destination chain ID does not match the local chain ID.
/// - `firstArg` is the destination chain ID.
/// - UndeterminedRevert: the transaction will revert for another reason.
///
/// Note: the arguments are abi-encoded bytes32 values (as their types could be different).
function getTxReadinessV1(
InterchainTransaction memory icTx,
bytes32[] calldata proof
)
external
view
returns (TxReadiness status, bytes32 firstArg, bytes32 secondArg);
/// @notice Returns the fee for sending an Interchain message.
/// @param dstChainId The chain ID of the destination chain.
/// @param srcExecutionService The address of the execution service to use for the message.
/// @param srcModules The source modules involved in the message sending.
/// @param options Execution options for the message sent, currently gas limit + native gas drop.
/// @param messageLen The length of the message being sent.
function getInterchainFee(
uint64 dstChainId,
address srcExecutionService,
address[] calldata srcModules,
bytes calldata options,
uint256 messageLen
)
external
view
returns (uint256);
/// @notice Returns the address of the executor for a transaction that has been sent to the local chain.
function getExecutor(bytes calldata transaction) external view returns (address);
/// @notice Returns the address of the executor for a transaction that has been sent to the local chain.
function getExecutorById(bytes32 transactionId) external view returns (address);
/// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.
/// @dev Will return 0x0 if no client is linked for the chain ID.
function getLinkedClient(uint64 chainId) external view returns (bytes32);
/// @notice Returns the EVM address of the linked client for a specific chain ID.
/// @dev Will return 0x0 if no client is linked for the chain ID.
/// Will revert if the client is not an EVM client.
function getLinkedClientEVM(uint64 chainId) external view returns (address);
}// 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/",
"ds-test/=node_modules/ds-test/src/",
"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": {}
}Contract ABI
API[{"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":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","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":"address","name":"caller","type":"address"}],"name":"InterchainApp__CallerNotInterchainClient","type":"error"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"InterchainApp__ChainIdNotRemote","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":[{"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":"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"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optimisticPeriod","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":"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":"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"},{"indexed":false,"internalType":"uint64","name":"entryIndex","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"},{"indexed":false,"internalType":"uint64","name":"entryIndex","type":"uint64"}],"name":"PingSent","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":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"gasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAppConfigV1","outputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"},{"internalType":"uint256","name":"guardFlag","type":"uint256"},{"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":"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":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"setAppConfigV1","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":"address","name":"client","type":"address"}],"name":"setLatestInterchainClient","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
60806040523480156200001157600080fd5b50604051620021f1380380620021f1833981016040819052620000349162000207565b806200004260008262000087565b506200007190507f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c848262000087565b50620000806207a120620000c4565b5062000232565b600080620000968484620000ff565b90508015620000bb576000848152600160205260409020620000b99084620001ad565b505b90505b92915050565b60098190556040518181527f336210500e2973a38a8d7b3f978ac5bf874a3326119f3dff68651e472a1ae7729060200160405180910390a150565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16620001a4576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556200015b3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620000be565b506000620000be565b6000620000bb836001600160a01b0384166000818152600183016020526040812054620001a457508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620000be565b6000602082840312156200021a57600080fd5b81516001600160a01b0381168114620000bb57600080fd5b611faf80620002426000396000f3fe6080604052600436106101f25760003560e01c806390a92c161161010d578063ca15c873116100a0578063ed5ec8901161006f578063ed5ec890146105e7578063ee7d72b414610607578063f22ba23d14610627578063f68016b714610647578063f6b266fd1461065d57600080fd5b8063ca15c87314610567578063cb5038fb14610587578063d547741f146105a7578063eb53b44e146105c757600080fd5b8063b2494df3116100dc578063b2494df3146104f6578063b70c40b31461050b578063bc0d912c1461052b578063c313c8071461054957600080fd5b806390a92c161461047f57806391d148541461049f578063a1aa5d68146104bf578063a217fddf146104e157600080fd5b80632f2ff15d116101855780634e6427e7116101545780634e6427e7146103ad5780636e9fd609146103e35780637717a647146103f65780639010d07c1461044757600080fd5b80632f2ff15d1461033857806336568abe146103585780633ccfd60b14610378578063496774b11461038d57600080fd5b80631c489e4f116101c15780631c489e4f146102955780631ec46e95146102c5578063248a9ca3146102e5578063287bc0571461031557600080fd5b806301ffc9a7146101fe5780630fb591561461023357806317d26286146102555780631856ddfe1461027557600080fd5b366101f957005b600080fd5b34801561020a57600080fd5b5061021e610219366004611a80565b61067d565b60405190151581526020015b60405180910390f35b34801561023f57600080fd5b5061025361024e366004611ac6565b6106a8565b005b34801561026157600080fd5b50610253610270366004611af6565b6106cd565b34801561028157600080fd5b50610253610290366004611b22565b6106d9565b3480156102a157600080fd5b506102b7600080516020611f5a83398151915281565b60405190815260200161022a565b3480156102d157600080fd5b506102536102e0366004611b57565b610709565b3480156102f157600080fd5b506102b7610300366004611b79565b60009081526020819052604090206001015490565b34801561032157600080fd5b5061032a6107ef565b60405161022a929190611c26565b34801561034457600080fd5b50610253610353366004611c4b565b61080a565b34801561036457600080fd5b50610253610373366004611c4b565b610835565b34801561038457600080fd5b50610253610868565b34801561039957600080fd5b506102536103a8366004611ac6565b610880565b3480156103b957600080fd5b506102b76103c8366004611c6e565b6001600160401b031660009081526003602052604090205490565b6102536103f1366004611c8b565b6108ee565b34801561040257600080fd5b5061040b6109aa565b60405161022a91908151815260208083015190820152604080830151908201526060918201516001600160a01b03169181019190915260800190565b34801561045357600080fd5b50610467610462366004611b57565b610a20565b6040516001600160a01b03909116815260200161022a565b34801561048b57600080fd5b5061046761049a366004611c6e565b610a3f565b3480156104ab57600080fd5b5061021e6104ba366004611c4b565b610a8b565b3480156104cb57600080fd5b506104d4610ab4565b60405161022a9190611d3d565b3480156104ed57600080fd5b506102b7600081565b34801561050257600080fd5b506104d4610ac5565b34801561051757600080fd5b50610253610526366004611ac6565b610ad1565b34801561053757600080fd5b506002546001600160a01b0316610467565b34801561055557600080fd5b506008546001600160a01b0316610467565b34801561057357600080fd5b506102b7610582366004611b79565b610b5a565b34801561059357600080fd5b506102536105a2366004611ac6565b610b71565b3480156105b357600080fd5b506102536105c2366004611c4b565b610c21565b3480156105d357600080fd5b506102536105e2366004611ac6565b610c46565b3480156105f357600080fd5b506102b7610602366004611c6e565b610c67565b34801561061357600080fd5b50610253610622366004611b79565b610cb3565b34801561063357600080fd5b50610253610642366004611d50565b610cd4565b34801561065357600080fd5b506102b760095481565b34801561066957600080fd5b50610253610678366004611af6565b610cf6565b60006001600160e01b03198216635a05180f60e01b14806106a257506106a282610d18565b92915050565b600080516020611f5a8339815191526106c081610d4d565b6106c982610d57565b5050565b6106c982826001610dfd565b600080516020611f5a8339815191526106f181610d4d565b610704836001600160a01b038416610f12565b505050565b600080516020611f5a83398151915261072181610d4d565b82158061072c575081155b1561075957604051636f2b4c2f60e11b815260048101849052602481018390526044015b60405180910390fd5b61076283610fb9565b600260146101000a81548161ffff021916908361ffff16021790555061078782610fec565b6002805465ffffffffffff92909216600160b01b0265ffffffffffff60b01b1990921691909117905560408051848152602081018490527f156e53f21add5e964d33e39e015675e24d4568202b47744bd8cc6080f76deabf91015b60405180910390a1505050565b6060806107fa61101f565b9150610804610ac5565b90509091565b60008281526020819052604090206001015461082581610d4d565b61082f8383611031565b50505050565b6001600160a01b038116331461085e5760405163334bd91960e11b815260040160405180910390fd5b6107048282611066565b600061087381610d4d565b61087d3347611093565b50565b600080516020611f5a83398151915261089881610d4d565b600880546001600160a01b0319166001600160a01b0384169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e906020015b60405180910390a15050565b6108f73361112a565b61091657604051633e336bbb60e01b8152336004820152602401610750565b46866001600160401b03160361094a57604051632c262dc960e11b81526001600160401b0387166004820152602401610750565b6001600160401b0386166000908152600360205260409020548514610994576040516377df34df60e01b81526001600160401b038716600482015260248101869052604401610750565b6109a2868686868686611137565b505050505050565b6109de604051806080016040528060008152602001600081526020016000815260200160006001600160a01b031681525090565b5060408051608081018252600254600160a01b810461ffff168252600160b01b900465ffffffffffff1660208201526001918101919091526000606082015290565b6000828152600160205260408120610a3890836111b7565b9392505050565b6001600160401b038116600090815260036020526040902054806001600160a01b0381168114610a85576040516382a4102b60e01b815260048101829052602401610750565b50919050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060610ac060046111c3565b905090565b6060610ac060066111c3565b600080516020611f5a833981519152610ae981610d4d565b6000610af66006846111d0565b905080610b2157604051635895247360e11b81526001600160a01b0384166004820152602401610750565b6040516001600160a01b03841681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020016107e2565b60008181526001602052604081206106a2906111e5565b600080516020611f5a833981519152610b8981610d4d565b6001600160a01b038216610bb057604051635467061760e11b815260040160405180910390fd5b6000610bbd6006846111ef565b905080610be85760405163215b8e2b60e21b81526001600160a01b0384166004820152602401610750565b6040516001600160a01b03841681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a50117509906020016107e2565b600082815260208190526040902060010154610c3c81610d4d565b61082f8383611066565b600080516020611f5a833981519152610c5e81610d4d565b6106c982611204565b604080518082018252600954815260006020808301829052835180820183905284518082039092018252840190935291610cab84610ca4846112ee565b835161132c565b949350505050565b600080516020611f5a833981519152610ccb81610d4d565b6106c982611400565b600080516020611f5a833981519152610cec81610d4d565b6107048383611435565b600080516020611f5a833981519152610d0e81610d4d565b6107048383610f12565b60006001600160e01b03198216637965db0b60e01b14806106a257506301ffc9a760e01b6001600160e01b03198316146106a2565b61087d81336114e4565b610d608161112a565b610d8857604051633e336bbb60e01b81526001600160a01b0382166004820152602401610750565b610d9381600061151d565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16002546001600160a01b03166001600160a01b0316816001600160a01b03160361087d5761087d6000611204565b60006040518060400160405280600954815260200160008152509050600083604051602001610e2e91815260200190565b60405160208183030381529060405290506000610e4d86848451611539565b90508047108015610e5c575083155b15610e9c576040518581527ff83d5148c4e705c82778f8aed1bb387ea5a8c0046cd647c807b70d65932210c29060200160405180910390a1505050505050565b6000610eaa87838686611552565b90507f02c339f6ec36750dc856c2ddcde980a8b7ae576e22d93b26e36d0805cbd917428682602001518360400151604051610f01939291909283526001600160401b03918216602084015216604082015260600190565b60405180910390a150505050505050565b46826001600160401b031603610f4657604051632c262dc960e11b81526001600160401b0383166004820152602401610750565b6000819003610f685760405163a72ac69d60e01b815260040160405180910390fd5b6001600160401b038216600081815260036020908152604091829020849055815192835282018390527f8991328923b5fe27cc7262398cb29b1b735f93970fd36a5a62a8a47545c9c5f791016108e2565b600061ffff821115610fe8576040516306dfcc6560e41b81526010600482015260248101839052604401610750565b5090565b600065ffffffffffff821115610fe8576040516306dfcc6560e41b81526030600482015260248101839052604401610750565b6060610ac061102c6109aa565b6115ac565b60008061103e84846115f3565b90508015610a3857600084815260016020526040902061105e90846111ef565b509392505050565b6000806110738484611685565b90508015610a3857600084815260016020526040902061105e90846111d0565b804710156110b65760405163cd78605960e01b8152306004820152602401610750565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611103576040519150601f19603f3d011682016040523d82523d6000602084013e611108565b606091505b505090508061070457604051630a12f52160e11b815260040160405180910390fd5b60006106a26004836116f0565b600061114582840184611b79565b604080518281526001600160401b03888116602083015287168183015290519192507fa522df82694ee71e523b279573938325ee0d16d8300f983ffe9d2e9e6a4dc388919081900360600190a180156111ae576111ae876111a7600184611d8c565b6000610dfd565b50505050505050565b6000610a388383611712565b60606000610a388361173c565b6000610a38836001600160a01b038416611798565b60006106a2825490565b6000610a38836001600160a01b03841661188b565b61120d8161112a565b15801561122257506001600160a01b03811615155b1561124b57604051633e336bbb60e01b81526001600160a01b0382166004820152602401610750565b6002546001600160a01b03166001600160a01b0316816001600160a01b03160361129357604051634542adbf60e11b81526001600160a01b0382166004820152602401610750565b600280546001600160a01b0319166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c169906020015b60405180910390a150565b60606106a26001836040516020016113189190815181526020918201519181019190915260400190565b6040516020818303038152906040526118d2565b6000806113416002546001600160a01b031690565b90506001600160a01b03811661136a576040516335f2562960e11b815260040160405180910390fd5b806001600160a01b031663cbb3c6318661138c6008546001600160a01b031690565b611394610ac5565b88886040518663ffffffff1660e01b81526004016113b6959493929190611dad565b602060405180830381865afa1580156113d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f79190611e05565b95945050505050565b60098190556040518181527f336210500e2973a38a8d7b3f978ac5bf874a3326119f3dff68651e472a1ae772906020016112e3565b6001600160a01b03821661145c576040516335f2562960e11b815260040160405180910390fd5b6114658261112a565b1561148e5760405163d497fddf60e01b81526001600160a01b0383166004820152602401610750565b61149982600161151d565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156106c9576106c982611204565b6114ee8282610a8b565b6106c95760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610750565b801561152e576107046004836111ef565b6107046004836111d0565b600080611545846112ee565b90506113f785828561132c565b6040805160608101825260008082526020820181905291810182905290611578846112ee565b6001600160401b0387166000908152600360205260409020549091506115a29087908784876118fe565b9695505050505050565b60606106a260018360405160200161131891908151815260208083015190820152604080830151908201526060918201516001600160a01b03169181019190915260800190565b60006115ff8383610a8b565b61167d576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556116353390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016106a2565b5060006106a2565b60006116918383610a8b565b1561167d576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016106a2565b6001600160a01b03811660009081526001830160205260408120541515610a38565b600082600001828154811061172957611729611e1e565b9060005260206000200154905092915050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561178c57602002820191906000526020600020905b815481526020019060010190808311611778575b50505050509050919050565b600081815260018301602052604081205480156118815760006117bc600183611d8c565b85549091506000906117d090600190611d8c565b90508082146118355760008660000182815481106117f0576117f0611e1e565b906000526020600020015490508087600001848154811061181357611813611e1e565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061184657611846611e34565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506106a2565b60009150506106a2565b600081815260018301602052604081205461167d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556106a2565b606082826040516020016118e7929190611e4a565b604051602081830303815290604052905092915050565b6040805160608101825260008082526020820181905291810191909152600061192f6002546001600160a01b031690565b90506001600160a01b038116611958576040516335f2562960e11b815260040160405180910390fd5b46876001600160401b03160361198c57604051632c262dc960e11b81526001600160401b0388166004820152602401610750565b60008690036119b95760405163cd256fe760e01b81526001600160401b0388166004820152602401610750565b844710156119e357604051630849070b60e31b815247600482015260248101869052604401610750565b806001600160a01b031663547efb84868989611a076008546001600160a01b031690565b611a0f610ac5565b8a8a6040518863ffffffff1660e01b8152600401611a3296959493929190611e7a565b60606040518083038185885af1158015611a50573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611a759190611ee3565b979650505050505050565b600060208284031215611a9257600080fd5b81356001600160e01b031981168114610a3857600080fd5b80356001600160a01b0381168114611ac157600080fd5b919050565b600060208284031215611ad857600080fd5b610a3882611aaa565b6001600160401b038116811461087d57600080fd5b60008060408385031215611b0957600080fd5b8235611b1481611ae1565b946020939093013593505050565b60008060408385031215611b3557600080fd5b8235611b4081611ae1565b9150611b4e60208401611aaa565b90509250929050565b60008060408385031215611b6a57600080fd5b50508035926020909101359150565b600060208284031215611b8b57600080fd5b5035919050565b60005b83811015611bad578181015183820152602001611b95565b50506000910152565b60008151808452611bce816020860160208601611b92565b601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b83811015611c1b5781516001600160a01b031687529582019590820190600101611bf6565b509495945050505050565b604081526000611c396040830185611bb6565b82810360208401526113f78185611be2565b60008060408385031215611c5e57600080fd5b82359150611b4e60208401611aaa565b600060208284031215611c8057600080fd5b8135610a3881611ae1565b60008060008060008060a08789031215611ca457600080fd5b8635611caf81611ae1565b9550602087013594506040870135611cc681611ae1565b93506060870135611cd681611ae1565b925060808701356001600160401b0380821115611cf257600080fd5b818901915089601f830112611d0657600080fd5b813581811115611d1557600080fd5b8a6020828501011115611d2757600080fd5b6020830194508093505050509295509295509295565b602081526000610a386020830184611be2565b60008060408385031215611d6357600080fd5b611d6c83611aaa565b915060208301358015158114611d8157600080fd5b809150509250929050565b818103818111156106a257634e487b7160e01b600052601160045260246000fd5b6001600160401b03861681526001600160a01b038516602082015260a060408201819052600090611de090830186611be2565b8281036060840152611df28186611bb6565b9150508260808301529695505050505050565b600060208284031215611e1757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b61ffff60f01b8360f01b16815260008251611e6c816002850160208701611b92565b919091016002019392505050565b6001600160401b038716815285602082015260018060a01b038516604082015260c060608201526000611eb060c0830186611be2565b8281036080840152611ec28186611bb6565b905082810360a0840152611ed68185611bb6565b9998505050505050505050565b600060608284031215611ef557600080fd5b604051606081018181106001600160401b0382111715611f2557634e487b7160e01b600052604160045260246000fd5b604052825181526020830151611f3a81611ae1565b60208201526040830151611f4d81611ae1565b6040820152939250505056fe67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84a2646970667358221220e80174d416f7b03398754cfa68a8b560ff4296332195871e45b98bc31ffbd7ae64736f6c63430008140033000000000000000000000000e7353bedc72d29f99d6ca5cde69f807cce5d57e4
Deployed Bytecode
0x6080604052600436106101f25760003560e01c806390a92c161161010d578063ca15c873116100a0578063ed5ec8901161006f578063ed5ec890146105e7578063ee7d72b414610607578063f22ba23d14610627578063f68016b714610647578063f6b266fd1461065d57600080fd5b8063ca15c87314610567578063cb5038fb14610587578063d547741f146105a7578063eb53b44e146105c757600080fd5b8063b2494df3116100dc578063b2494df3146104f6578063b70c40b31461050b578063bc0d912c1461052b578063c313c8071461054957600080fd5b806390a92c161461047f57806391d148541461049f578063a1aa5d68146104bf578063a217fddf146104e157600080fd5b80632f2ff15d116101855780634e6427e7116101545780634e6427e7146103ad5780636e9fd609146103e35780637717a647146103f65780639010d07c1461044757600080fd5b80632f2ff15d1461033857806336568abe146103585780633ccfd60b14610378578063496774b11461038d57600080fd5b80631c489e4f116101c15780631c489e4f146102955780631ec46e95146102c5578063248a9ca3146102e5578063287bc0571461031557600080fd5b806301ffc9a7146101fe5780630fb591561461023357806317d26286146102555780631856ddfe1461027557600080fd5b366101f957005b600080fd5b34801561020a57600080fd5b5061021e610219366004611a80565b61067d565b60405190151581526020015b60405180910390f35b34801561023f57600080fd5b5061025361024e366004611ac6565b6106a8565b005b34801561026157600080fd5b50610253610270366004611af6565b6106cd565b34801561028157600080fd5b50610253610290366004611b22565b6106d9565b3480156102a157600080fd5b506102b7600080516020611f5a83398151915281565b60405190815260200161022a565b3480156102d157600080fd5b506102536102e0366004611b57565b610709565b3480156102f157600080fd5b506102b7610300366004611b79565b60009081526020819052604090206001015490565b34801561032157600080fd5b5061032a6107ef565b60405161022a929190611c26565b34801561034457600080fd5b50610253610353366004611c4b565b61080a565b34801561036457600080fd5b50610253610373366004611c4b565b610835565b34801561038457600080fd5b50610253610868565b34801561039957600080fd5b506102536103a8366004611ac6565b610880565b3480156103b957600080fd5b506102b76103c8366004611c6e565b6001600160401b031660009081526003602052604090205490565b6102536103f1366004611c8b565b6108ee565b34801561040257600080fd5b5061040b6109aa565b60405161022a91908151815260208083015190820152604080830151908201526060918201516001600160a01b03169181019190915260800190565b34801561045357600080fd5b50610467610462366004611b57565b610a20565b6040516001600160a01b03909116815260200161022a565b34801561048b57600080fd5b5061046761049a366004611c6e565b610a3f565b3480156104ab57600080fd5b5061021e6104ba366004611c4b565b610a8b565b3480156104cb57600080fd5b506104d4610ab4565b60405161022a9190611d3d565b3480156104ed57600080fd5b506102b7600081565b34801561050257600080fd5b506104d4610ac5565b34801561051757600080fd5b50610253610526366004611ac6565b610ad1565b34801561053757600080fd5b506002546001600160a01b0316610467565b34801561055557600080fd5b506008546001600160a01b0316610467565b34801561057357600080fd5b506102b7610582366004611b79565b610b5a565b34801561059357600080fd5b506102536105a2366004611ac6565b610b71565b3480156105b357600080fd5b506102536105c2366004611c4b565b610c21565b3480156105d357600080fd5b506102536105e2366004611ac6565b610c46565b3480156105f357600080fd5b506102b7610602366004611c6e565b610c67565b34801561061357600080fd5b50610253610622366004611b79565b610cb3565b34801561063357600080fd5b50610253610642366004611d50565b610cd4565b34801561065357600080fd5b506102b760095481565b34801561066957600080fd5b50610253610678366004611af6565b610cf6565b60006001600160e01b03198216635a05180f60e01b14806106a257506106a282610d18565b92915050565b600080516020611f5a8339815191526106c081610d4d565b6106c982610d57565b5050565b6106c982826001610dfd565b600080516020611f5a8339815191526106f181610d4d565b610704836001600160a01b038416610f12565b505050565b600080516020611f5a83398151915261072181610d4d565b82158061072c575081155b1561075957604051636f2b4c2f60e11b815260048101849052602481018390526044015b60405180910390fd5b61076283610fb9565b600260146101000a81548161ffff021916908361ffff16021790555061078782610fec565b6002805465ffffffffffff92909216600160b01b0265ffffffffffff60b01b1990921691909117905560408051848152602081018490527f156e53f21add5e964d33e39e015675e24d4568202b47744bd8cc6080f76deabf91015b60405180910390a1505050565b6060806107fa61101f565b9150610804610ac5565b90509091565b60008281526020819052604090206001015461082581610d4d565b61082f8383611031565b50505050565b6001600160a01b038116331461085e5760405163334bd91960e11b815260040160405180910390fd5b6107048282611066565b600061087381610d4d565b61087d3347611093565b50565b600080516020611f5a83398151915261089881610d4d565b600880546001600160a01b0319166001600160a01b0384169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e906020015b60405180910390a15050565b6108f73361112a565b61091657604051633e336bbb60e01b8152336004820152602401610750565b46866001600160401b03160361094a57604051632c262dc960e11b81526001600160401b0387166004820152602401610750565b6001600160401b0386166000908152600360205260409020548514610994576040516377df34df60e01b81526001600160401b038716600482015260248101869052604401610750565b6109a2868686868686611137565b505050505050565b6109de604051806080016040528060008152602001600081526020016000815260200160006001600160a01b031681525090565b5060408051608081018252600254600160a01b810461ffff168252600160b01b900465ffffffffffff1660208201526001918101919091526000606082015290565b6000828152600160205260408120610a3890836111b7565b9392505050565b6001600160401b038116600090815260036020526040902054806001600160a01b0381168114610a85576040516382a4102b60e01b815260048101829052602401610750565b50919050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060610ac060046111c3565b905090565b6060610ac060066111c3565b600080516020611f5a833981519152610ae981610d4d565b6000610af66006846111d0565b905080610b2157604051635895247360e11b81526001600160a01b0384166004820152602401610750565b6040516001600160a01b03841681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020016107e2565b60008181526001602052604081206106a2906111e5565b600080516020611f5a833981519152610b8981610d4d565b6001600160a01b038216610bb057604051635467061760e11b815260040160405180910390fd5b6000610bbd6006846111ef565b905080610be85760405163215b8e2b60e21b81526001600160a01b0384166004820152602401610750565b6040516001600160a01b03841681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a50117509906020016107e2565b600082815260208190526040902060010154610c3c81610d4d565b61082f8383611066565b600080516020611f5a833981519152610c5e81610d4d565b6106c982611204565b604080518082018252600954815260006020808301829052835180820183905284518082039092018252840190935291610cab84610ca4846112ee565b835161132c565b949350505050565b600080516020611f5a833981519152610ccb81610d4d565b6106c982611400565b600080516020611f5a833981519152610cec81610d4d565b6107048383611435565b600080516020611f5a833981519152610d0e81610d4d565b6107048383610f12565b60006001600160e01b03198216637965db0b60e01b14806106a257506301ffc9a760e01b6001600160e01b03198316146106a2565b61087d81336114e4565b610d608161112a565b610d8857604051633e336bbb60e01b81526001600160a01b0382166004820152602401610750565b610d9381600061151d565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16002546001600160a01b03166001600160a01b0316816001600160a01b03160361087d5761087d6000611204565b60006040518060400160405280600954815260200160008152509050600083604051602001610e2e91815260200190565b60405160208183030381529060405290506000610e4d86848451611539565b90508047108015610e5c575083155b15610e9c576040518581527ff83d5148c4e705c82778f8aed1bb387ea5a8c0046cd647c807b70d65932210c29060200160405180910390a1505050505050565b6000610eaa87838686611552565b90507f02c339f6ec36750dc856c2ddcde980a8b7ae576e22d93b26e36d0805cbd917428682602001518360400151604051610f01939291909283526001600160401b03918216602084015216604082015260600190565b60405180910390a150505050505050565b46826001600160401b031603610f4657604051632c262dc960e11b81526001600160401b0383166004820152602401610750565b6000819003610f685760405163a72ac69d60e01b815260040160405180910390fd5b6001600160401b038216600081815260036020908152604091829020849055815192835282018390527f8991328923b5fe27cc7262398cb29b1b735f93970fd36a5a62a8a47545c9c5f791016108e2565b600061ffff821115610fe8576040516306dfcc6560e41b81526010600482015260248101839052604401610750565b5090565b600065ffffffffffff821115610fe8576040516306dfcc6560e41b81526030600482015260248101839052604401610750565b6060610ac061102c6109aa565b6115ac565b60008061103e84846115f3565b90508015610a3857600084815260016020526040902061105e90846111ef565b509392505050565b6000806110738484611685565b90508015610a3857600084815260016020526040902061105e90846111d0565b804710156110b65760405163cd78605960e01b8152306004820152602401610750565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611103576040519150601f19603f3d011682016040523d82523d6000602084013e611108565b606091505b505090508061070457604051630a12f52160e11b815260040160405180910390fd5b60006106a26004836116f0565b600061114582840184611b79565b604080518281526001600160401b03888116602083015287168183015290519192507fa522df82694ee71e523b279573938325ee0d16d8300f983ffe9d2e9e6a4dc388919081900360600190a180156111ae576111ae876111a7600184611d8c565b6000610dfd565b50505050505050565b6000610a388383611712565b60606000610a388361173c565b6000610a38836001600160a01b038416611798565b60006106a2825490565b6000610a38836001600160a01b03841661188b565b61120d8161112a565b15801561122257506001600160a01b03811615155b1561124b57604051633e336bbb60e01b81526001600160a01b0382166004820152602401610750565b6002546001600160a01b03166001600160a01b0316816001600160a01b03160361129357604051634542adbf60e11b81526001600160a01b0382166004820152602401610750565b600280546001600160a01b0319166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c169906020015b60405180910390a150565b60606106a26001836040516020016113189190815181526020918201519181019190915260400190565b6040516020818303038152906040526118d2565b6000806113416002546001600160a01b031690565b90506001600160a01b03811661136a576040516335f2562960e11b815260040160405180910390fd5b806001600160a01b031663cbb3c6318661138c6008546001600160a01b031690565b611394610ac5565b88886040518663ffffffff1660e01b81526004016113b6959493929190611dad565b602060405180830381865afa1580156113d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f79190611e05565b95945050505050565b60098190556040518181527f336210500e2973a38a8d7b3f978ac5bf874a3326119f3dff68651e472a1ae772906020016112e3565b6001600160a01b03821661145c576040516335f2562960e11b815260040160405180910390fd5b6114658261112a565b1561148e5760405163d497fddf60e01b81526001600160a01b0383166004820152602401610750565b61149982600161151d565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156106c9576106c982611204565b6114ee8282610a8b565b6106c95760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610750565b801561152e576107046004836111ef565b6107046004836111d0565b600080611545846112ee565b90506113f785828561132c565b6040805160608101825260008082526020820181905291810182905290611578846112ee565b6001600160401b0387166000908152600360205260409020549091506115a29087908784876118fe565b9695505050505050565b60606106a260018360405160200161131891908151815260208083015190820152604080830151908201526060918201516001600160a01b03169181019190915260800190565b60006115ff8383610a8b565b61167d576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556116353390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016106a2565b5060006106a2565b60006116918383610a8b565b1561167d576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016106a2565b6001600160a01b03811660009081526001830160205260408120541515610a38565b600082600001828154811061172957611729611e1e565b9060005260206000200154905092915050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561178c57602002820191906000526020600020905b815481526020019060010190808311611778575b50505050509050919050565b600081815260018301602052604081205480156118815760006117bc600183611d8c565b85549091506000906117d090600190611d8c565b90508082146118355760008660000182815481106117f0576117f0611e1e565b906000526020600020015490508087600001848154811061181357611813611e1e565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061184657611846611e34565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506106a2565b60009150506106a2565b600081815260018301602052604081205461167d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556106a2565b606082826040516020016118e7929190611e4a565b604051602081830303815290604052905092915050565b6040805160608101825260008082526020820181905291810191909152600061192f6002546001600160a01b031690565b90506001600160a01b038116611958576040516335f2562960e11b815260040160405180910390fd5b46876001600160401b03160361198c57604051632c262dc960e11b81526001600160401b0388166004820152602401610750565b60008690036119b95760405163cd256fe760e01b81526001600160401b0388166004820152602401610750565b844710156119e357604051630849070b60e31b815247600482015260248101869052604401610750565b806001600160a01b031663547efb84868989611a076008546001600160a01b031690565b611a0f610ac5565b8a8a6040518863ffffffff1660e01b8152600401611a3296959493929190611e7a565b60606040518083038185885af1158015611a50573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611a759190611ee3565b979650505050505050565b600060208284031215611a9257600080fd5b81356001600160e01b031981168114610a3857600080fd5b80356001600160a01b0381168114611ac157600080fd5b919050565b600060208284031215611ad857600080fd5b610a3882611aaa565b6001600160401b038116811461087d57600080fd5b60008060408385031215611b0957600080fd5b8235611b1481611ae1565b946020939093013593505050565b60008060408385031215611b3557600080fd5b8235611b4081611ae1565b9150611b4e60208401611aaa565b90509250929050565b60008060408385031215611b6a57600080fd5b50508035926020909101359150565b600060208284031215611b8b57600080fd5b5035919050565b60005b83811015611bad578181015183820152602001611b95565b50506000910152565b60008151808452611bce816020860160208601611b92565b601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b83811015611c1b5781516001600160a01b031687529582019590820190600101611bf6565b509495945050505050565b604081526000611c396040830185611bb6565b82810360208401526113f78185611be2565b60008060408385031215611c5e57600080fd5b82359150611b4e60208401611aaa565b600060208284031215611c8057600080fd5b8135610a3881611ae1565b60008060008060008060a08789031215611ca457600080fd5b8635611caf81611ae1565b9550602087013594506040870135611cc681611ae1565b93506060870135611cd681611ae1565b925060808701356001600160401b0380821115611cf257600080fd5b818901915089601f830112611d0657600080fd5b813581811115611d1557600080fd5b8a6020828501011115611d2757600080fd5b6020830194508093505050509295509295509295565b602081526000610a386020830184611be2565b60008060408385031215611d6357600080fd5b611d6c83611aaa565b915060208301358015158114611d8157600080fd5b809150509250929050565b818103818111156106a257634e487b7160e01b600052601160045260246000fd5b6001600160401b03861681526001600160a01b038516602082015260a060408201819052600090611de090830186611be2565b8281036060840152611df28186611bb6565b9150508260808301529695505050505050565b600060208284031215611e1757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b61ffff60f01b8360f01b16815260008251611e6c816002850160208701611b92565b919091016002019392505050565b6001600160401b038716815285602082015260018060a01b038516604082015260c060608201526000611eb060c0830186611be2565b8281036080840152611ec28186611bb6565b905082810360a0840152611ed68185611bb6565b9998505050505050505050565b600060608284031215611ef557600080fd5b604051606081018181106001600160401b0382111715611f2557634e487b7160e01b600052604160045260246000fd5b604052825181526020830151611f3a81611ae1565b60208201526040830151611f4d81611ae1565b6040820152939250505056fe67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84a2646970667358221220e80174d416f7b03398754cfa68a8b560ff4296332195871e45b98bc31ffbd7ae64736f6c63430008140033
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
Loading...
Loading
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.