Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 25 from a total of 23,956 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Initiate Token P... | 8058254 | 344 days ago | IN | 0.0202 ETH | 0.00070051 | ||||
| Initiate Token P... | 8057683 | 344 days ago | IN | 0.101 ETH | 0.00007729 | ||||
| Initiate Token P... | 8057646 | 344 days ago | IN | 0.101 ETH | 0.00000171 | ||||
| Initiate Token P... | 8039819 | 346 days ago | IN | 0.000101 ETH | 0.00000029 | ||||
| Initiate Token P... | 8039798 | 346 days ago | IN | 0.000101 ETH | 0.00000026 | ||||
| Initiate Token P... | 8013549 | 350 days ago | IN | 0 ETH | 0.0000002 | ||||
| Initiate Token P... | 8008839 | 351 days ago | IN | 0 ETH | 0.00000045 | ||||
| Initiate Token P... | 8008791 | 351 days ago | IN | 0 ETH | 0.00000045 | ||||
| Initiate Token P... | 8002339 | 351 days ago | IN | 0 ETH | 0.00000048 | ||||
| Initiate Token P... | 8002096 | 352 days ago | IN | 0 ETH | 0.00000046 | ||||
| Initiate Token P... | 8002088 | 352 days ago | IN | 0 ETH | 0.00000039 | ||||
| Initiate Token P... | 8002065 | 352 days ago | IN | 0 ETH | 0.00000045 | ||||
| Initiate Token P... | 8000755 | 352 days ago | IN | 0 ETH | 0.00000315 | ||||
| Initiate Token P... | 8000388 | 352 days ago | IN | 0.02655407 ETH | 0.00013136 | ||||
| Initiate Token P... | 7999988 | 352 days ago | IN | 0.02635254 ETH | 0.00012762 | ||||
| Initiate Token P... | 7999029 | 352 days ago | IN | 0 ETH | 0.00000069 | ||||
| Initiate Token P... | 7987611 | 354 days ago | IN | 0 ETH | 0.00002114 | ||||
| Initiate Token P... | 7987555 | 354 days ago | IN | 0 ETH | 0.0000273 | ||||
| Initiate Token P... | 7987520 | 354 days ago | IN | 0 ETH | 0.00004622 | ||||
| Initiate Token P... | 7987468 | 354 days ago | IN | 0.00250967 ETH | 0.0000949 | ||||
| Initiate Token P... | 7987431 | 354 days ago | IN | 0.0005021 ETH | 0.00010113 | ||||
| Initiate Token P... | 7985855 | 354 days ago | IN | 0.00049132 ETH | 0.00117938 | ||||
| Initiate Token P... | 7985849 | 354 days ago | IN | 0 ETH | 0.00156546 | ||||
| Initiate Token P... | 7985827 | 354 days ago | IN | 0 ETH | 0.00176889 | ||||
| Initiate Token P... | 7985755 | 354 days ago | IN | 0 ETH | 0.00247571 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
To
|
Amount
|
||
|---|---|---|---|---|---|---|---|
| Deposit Transact... | 8058254 | 344 days ago | 0.02 ETH | ||||
| Transfer | 8058254 | 344 days ago | 0.00006 ETH | ||||
| Transfer | 8058254 | 344 days ago | 0.00014 ETH | ||||
| Deposit Transact... | 8057683 | 344 days ago | 0.1 ETH | ||||
| Transfer | 8057683 | 344 days ago | 0.0003 ETH | ||||
| Transfer | 8057683 | 344 days ago | 0.0007 ETH | ||||
| Deposit Transact... | 8057646 | 344 days ago | 0.1 ETH | ||||
| Transfer | 8057646 | 344 days ago | 0.0003 ETH | ||||
| Transfer | 8057646 | 344 days ago | 0.0007 ETH | ||||
| Deposit Transact... | 8039819 | 346 days ago | 0.0001 ETH | ||||
| Transfer | 8039819 | 346 days ago | 0.0000003 ETH | ||||
| Transfer | 8039819 | 346 days ago | 0.0000007 ETH | ||||
| Deposit Transact... | 8039798 | 346 days ago | 0.0001 ETH | ||||
| Transfer | 8039798 | 346 days ago | 0.0000003 ETH | ||||
| Transfer | 8039798 | 346 days ago | 0.0000007 ETH | ||||
| Transfer | 8000388 | 352 days ago | 0.02655407 ETH | ||||
| Transfer | 7999988 | 352 days ago | 0.02635254 ETH | ||||
| Transfer | 7987468 | 354 days ago | 0.00250967 ETH | ||||
| Transfer | 7987431 | 354 days ago | 0.0005021 ETH | ||||
| Transfer | 7985855 | 354 days ago | 0.00049132 ETH | ||||
| Transfer | 7985338 | 354 days ago | 0.0005 ETH | ||||
| Transfer | 7985321 | 354 days ago | 0.0005 ETH | ||||
| Transfer | 7985276 | 354 days ago | 0.0005 ETH | ||||
| Transfer | 7984933 | 354 days ago | 0.0005 ETH | ||||
| Transfer | 7984839 | 354 days ago | 0.0005 ETH |
Loading...
Loading
Loading...
Loading
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xE34aDBb9...93bb6F9c2 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
PayGateway
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 200 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.22;
import { ModularCore } from "lib/modular-contracts/src/ModularCore.sol";
contract PayGateway is ModularCore {
constructor(address _owner, address[] memory _modules, bytes[] memory _moduleInstallData) {
_initializeOwner(_owner);
// Install and initialize modules
require(_modules.length == _moduleInstallData.length);
for (uint256 i = 0; i < _modules.length; i++) {
_installModule(_modules[i], _moduleInstallData[i]);
}
}
function getSupportedCallbackFunctions()
public
pure
override
returns (SupportedCallbackFunction[] memory supportedCallbackFunctions)
{}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Simple single owner authorization mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)
///
/// @dev Note:
/// This implementation does NOT auto-initialize the owner to `msg.sender`.
/// You MUST call the `_initializeOwner` in the constructor / initializer.
///
/// While the ownable portion follows
/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,
/// the nomenclature for the 2-step ownership handover may be unique to this codebase.
abstract contract Ownable {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The caller is not authorized to call the function.
error Unauthorized();
/// @dev The `newOwner` cannot be the zero address.
error NewOwnerIsZeroAddress();
/// @dev The `pendingOwner` does not have a valid handover request.
error NoHandoverRequest();
/// @dev Cannot double-initialize.
error AlreadyInitialized();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EVENTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The ownership is transferred from `oldOwner` to `newOwner`.
/// This event is intentionally kept the same as OpenZeppelin's Ownable to be
/// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),
/// despite it not being as lightweight as a single argument event.
event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
/// @dev An ownership handover to `pendingOwner` has been requested.
event OwnershipHandoverRequested(address indexed pendingOwner);
/// @dev The ownership handover to `pendingOwner` has been canceled.
event OwnershipHandoverCanceled(address indexed pendingOwner);
/// @dev `keccak256(bytes("OwnershipTransferred(address,address)"))`.
uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =
0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;
/// @dev `keccak256(bytes("OwnershipHandoverRequested(address)"))`.
uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =
0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;
/// @dev `keccak256(bytes("OwnershipHandoverCanceled(address)"))`.
uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =
0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The owner slot is given by:
/// `bytes32(~uint256(uint32(bytes4(keccak256("_OWNER_SLOT_NOT")))))`.
/// It is intentionally chosen to be a high value
/// to avoid collision with lower slots.
/// The choice of manual storage layout is to enable compatibility
/// with both regular and upgradeable contracts.
bytes32 internal constant _OWNER_SLOT =
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927;
/// The ownership handover slot of `newOwner` is given by:
/// ```
/// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))
/// let handoverSlot := keccak256(0x00, 0x20)
/// ```
/// It stores the expiry timestamp of the two-step ownership handover.
uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INTERNAL FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Override to return true to make `_initializeOwner` prevent double-initialization.
function _guardInitializeOwner() internal pure virtual returns (bool guard) {}
/// @dev Initializes the owner directly without authorization guard.
/// This function must be called upon initialization,
/// regardless of whether the contract is upgradeable or not.
/// This is to enable generalization to both regular and upgradeable contracts,
/// and to save gas in case the initial owner is not the caller.
/// For performance reasons, this function will not check if there
/// is an existing owner.
function _initializeOwner(address newOwner) internal virtual {
if (_guardInitializeOwner()) {
/// @solidity memory-safe-assembly
assembly {
let ownerSlot := _OWNER_SLOT
if sload(ownerSlot) {
mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`.
revert(0x1c, 0x04)
}
// Clean the upper 96 bits.
newOwner := shr(96, shl(96, newOwner))
// Store the new value.
sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
// Emit the {OwnershipTransferred} event.
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
}
} else {
/// @solidity memory-safe-assembly
assembly {
// Clean the upper 96 bits.
newOwner := shr(96, shl(96, newOwner))
// Store the new value.
sstore(_OWNER_SLOT, newOwner)
// Emit the {OwnershipTransferred} event.
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
}
}
}
/// @dev Sets the owner directly without authorization guard.
function _setOwner(address newOwner) internal virtual {
if (_guardInitializeOwner()) {
/// @solidity memory-safe-assembly
assembly {
let ownerSlot := _OWNER_SLOT
// Clean the upper 96 bits.
newOwner := shr(96, shl(96, newOwner))
// Emit the {OwnershipTransferred} event.
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
// Store the new value.
sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
}
} else {
/// @solidity memory-safe-assembly
assembly {
let ownerSlot := _OWNER_SLOT
// Clean the upper 96 bits.
newOwner := shr(96, shl(96, newOwner))
// Emit the {OwnershipTransferred} event.
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
// Store the new value.
sstore(ownerSlot, newOwner)
}
}
}
/// @dev Throws if the sender is not the owner.
function _checkOwner() internal view virtual {
/// @solidity memory-safe-assembly
assembly {
// If the caller is not the stored owner, revert.
if iszero(eq(caller(), sload(_OWNER_SLOT))) {
mstore(0x00, 0x82b42900) // `Unauthorized()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Returns how long a two-step ownership handover is valid for in seconds.
/// Override to return a different value if needed.
/// Made internal to conserve bytecode. Wrap it in a public function if needed.
function _ownershipHandoverValidFor() internal view virtual returns (uint64) {
return 48 * 3600;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC UPDATE FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Allows the owner to transfer the ownership to `newOwner`.
function transferOwnership(address newOwner) public payable virtual onlyOwner {
/// @solidity memory-safe-assembly
assembly {
if iszero(shl(96, newOwner)) {
mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.
revert(0x1c, 0x04)
}
}
_setOwner(newOwner);
}
/// @dev Allows the owner to renounce their ownership.
function renounceOwnership() public payable virtual onlyOwner {
_setOwner(address(0));
}
/// @dev Request a two-step ownership handover to the caller.
/// The request will automatically expire in 48 hours (172800 seconds) by default.
function requestOwnershipHandover() public payable virtual {
unchecked {
uint256 expires = block.timestamp + _ownershipHandoverValidFor();
/// @solidity memory-safe-assembly
assembly {
// Compute and set the handover slot to `expires`.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, caller())
sstore(keccak256(0x0c, 0x20), expires)
// Emit the {OwnershipHandoverRequested} event.
log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())
}
}
}
/// @dev Cancels the two-step ownership handover to the caller, if any.
function cancelOwnershipHandover() public payable virtual {
/// @solidity memory-safe-assembly
assembly {
// Compute and set the handover slot to 0.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, caller())
sstore(keccak256(0x0c, 0x20), 0)
// Emit the {OwnershipHandoverCanceled} event.
log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())
}
}
/// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.
/// Reverts if there is no existing ownership handover requested by `pendingOwner`.
function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {
/// @solidity memory-safe-assembly
assembly {
// Compute and set the handover slot to 0.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, pendingOwner)
let handoverSlot := keccak256(0x0c, 0x20)
// If the handover does not exist, or has expired.
if gt(timestamp(), sload(handoverSlot)) {
mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.
revert(0x1c, 0x04)
}
// Set the handover slot to 0.
sstore(handoverSlot, 0)
}
_setOwner(pendingOwner);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC READ FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the owner of the contract.
function owner() public view virtual returns (address result) {
/// @solidity memory-safe-assembly
assembly {
result := sload(_OWNER_SLOT)
}
}
/// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.
function ownershipHandoverExpiresAt(address pendingOwner)
public
view
virtual
returns (uint256 result)
{
/// @solidity memory-safe-assembly
assembly {
// Compute the handover slot.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, pendingOwner)
// Load the handover slot.
result := sload(keccak256(0x0c, 0x20))
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* MODIFIERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Marks a function as only callable by the owner.
modifier onlyOwner() virtual {
_checkOwner();
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {Ownable} from "./Ownable.sol";
/// @notice Simple single owner and multiroles authorization mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)
/// @dev While the ownable portion follows [EIP-173](https://eips.ethereum.org/EIPS/eip-173)
/// for compatibility, the nomenclature for the 2-step ownership handover and roles
/// may be unique to this codebase.
abstract contract OwnableRoles is Ownable {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EVENTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The `user`'s roles is updated to `roles`.
/// Each bit of `roles` represents whether the role is set.
event RolesUpdated(address indexed user, uint256 indexed roles);
/// @dev `keccak256(bytes("RolesUpdated(address,uint256)"))`.
uint256 private constant _ROLES_UPDATED_EVENT_SIGNATURE =
0x715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The role slot of `user` is given by:
/// ```
/// mstore(0x00, or(shl(96, user), _ROLE_SLOT_SEED))
/// let roleSlot := keccak256(0x00, 0x20)
/// ```
/// This automatically ignores the upper bits of the `user` in case
/// they are not clean, as well as keep the `keccak256` under 32-bytes.
///
/// Note: This is equivalent to `uint32(bytes4(keccak256("_OWNER_SLOT_NOT")))`.
uint256 private constant _ROLE_SLOT_SEED = 0x8b78c6d8;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INTERNAL FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Overwrite the roles directly without authorization guard.
function _setRoles(address user, uint256 roles) internal virtual {
/// @solidity memory-safe-assembly
assembly {
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, user)
// Store the new value.
sstore(keccak256(0x0c, 0x20), roles)
// Emit the {RolesUpdated} event.
log3(0, 0, _ROLES_UPDATED_EVENT_SIGNATURE, shr(96, mload(0x0c)), roles)
}
}
/// @dev Updates the roles directly without authorization guard.
/// If `on` is true, each set bit of `roles` will be turned on,
/// otherwise, each set bit of `roles` will be turned off.
function _updateRoles(address user, uint256 roles, bool on) internal virtual {
/// @solidity memory-safe-assembly
assembly {
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, user)
let roleSlot := keccak256(0x0c, 0x20)
// Load the current value.
let current := sload(roleSlot)
// Compute the updated roles if `on` is true.
let updated := or(current, roles)
// Compute the updated roles if `on` is false.
// Use `and` to compute the intersection of `current` and `roles`,
// `xor` it with `current` to flip the bits in the intersection.
if iszero(on) { updated := xor(current, and(current, roles)) }
// Then, store the new value.
sstore(roleSlot, updated)
// Emit the {RolesUpdated} event.
log3(0, 0, _ROLES_UPDATED_EVENT_SIGNATURE, shr(96, mload(0x0c)), updated)
}
}
/// @dev Grants the roles directly without authorization guard.
/// Each bit of `roles` represents the role to turn on.
function _grantRoles(address user, uint256 roles) internal virtual {
_updateRoles(user, roles, true);
}
/// @dev Removes the roles directly without authorization guard.
/// Each bit of `roles` represents the role to turn off.
function _removeRoles(address user, uint256 roles) internal virtual {
_updateRoles(user, roles, false);
}
/// @dev Throws if the sender does not have any of the `roles`.
function _checkRoles(uint256 roles) internal view virtual {
/// @solidity memory-safe-assembly
assembly {
// Compute the role slot.
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, caller())
// Load the stored value, and if the `and` intersection
// of the value and `roles` is zero, revert.
if iszero(and(sload(keccak256(0x0c, 0x20)), roles)) {
mstore(0x00, 0x82b42900) // `Unauthorized()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Throws if the sender is not the owner,
/// and does not have any of the `roles`.
/// Checks for ownership first, then lazily checks for roles.
function _checkOwnerOrRoles(uint256 roles) internal view virtual {
/// @solidity memory-safe-assembly
assembly {
// If the caller is not the stored owner.
// Note: `_ROLE_SLOT_SEED` is equal to `_OWNER_SLOT_NOT`.
if iszero(eq(caller(), sload(not(_ROLE_SLOT_SEED)))) {
// Compute the role slot.
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, caller())
// Load the stored value, and if the `and` intersection
// of the value and `roles` is zero, revert.
if iszero(and(sload(keccak256(0x0c, 0x20)), roles)) {
mstore(0x00, 0x82b42900) // `Unauthorized()`.
revert(0x1c, 0x04)
}
}
}
}
/// @dev Throws if the sender does not have any of the `roles`,
/// and is not the owner.
/// Checks for roles first, then lazily checks for ownership.
function _checkRolesOrOwner(uint256 roles) internal view virtual {
/// @solidity memory-safe-assembly
assembly {
// Compute the role slot.
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, caller())
// Load the stored value, and if the `and` intersection
// of the value and `roles` is zero, revert.
if iszero(and(sload(keccak256(0x0c, 0x20)), roles)) {
// If the caller is not the stored owner.
// Note: `_ROLE_SLOT_SEED` is equal to `_OWNER_SLOT_NOT`.
if iszero(eq(caller(), sload(not(_ROLE_SLOT_SEED)))) {
mstore(0x00, 0x82b42900) // `Unauthorized()`.
revert(0x1c, 0x04)
}
}
}
}
/// @dev Convenience function to return a `roles` bitmap from an array of `ordinals`.
/// This is meant for frontends like Etherscan, and is therefore not fully optimized.
/// Not recommended to be called on-chain.
/// Made internal to conserve bytecode. Wrap it in a public function if needed.
function _rolesFromOrdinals(uint8[] memory ordinals) internal pure returns (uint256 roles) {
/// @solidity memory-safe-assembly
assembly {
for { let i := shl(5, mload(ordinals)) } i { i := sub(i, 0x20) } {
// We don't need to mask the values of `ordinals`, as Solidity
// cleans dirty upper bits when storing variables into memory.
roles := or(shl(mload(add(ordinals, i)), 1), roles)
}
}
}
/// @dev Convenience function to return an array of `ordinals` from the `roles` bitmap.
/// This is meant for frontends like Etherscan, and is therefore not fully optimized.
/// Not recommended to be called on-chain.
/// Made internal to conserve bytecode. Wrap it in a public function if needed.
function _ordinalsFromRoles(uint256 roles) internal pure returns (uint8[] memory ordinals) {
/// @solidity memory-safe-assembly
assembly {
// Grab the pointer to the free memory.
ordinals := mload(0x40)
let ptr := add(ordinals, 0x20)
let o := 0
// The absence of lookup tables, De Bruijn, etc., here is intentional for
// smaller bytecode, as this function is not meant to be called on-chain.
for { let t := roles } 1 {} {
mstore(ptr, o)
// `shr` 5 is equivalent to multiplying by 0x20.
// Push back into the ordinals array if the bit is set.
ptr := add(ptr, shl(5, and(t, 1)))
o := add(o, 1)
t := shr(o, roles)
if iszero(t) { break }
}
// Store the length of `ordinals`.
mstore(ordinals, shr(5, sub(ptr, add(ordinals, 0x20))))
// Allocate the memory.
mstore(0x40, ptr)
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC UPDATE FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Allows the owner to grant `user` `roles`.
/// If the `user` already has a role, then it will be an no-op for the role.
function grantRoles(address user, uint256 roles) public payable virtual onlyOwner {
_grantRoles(user, roles);
}
/// @dev Allows the owner to remove `user` `roles`.
/// If the `user` does not have a role, then it will be an no-op for the role.
function revokeRoles(address user, uint256 roles) public payable virtual onlyOwner {
_removeRoles(user, roles);
}
/// @dev Allow the caller to remove their own roles.
/// If the caller does not have a role, then it will be an no-op for the role.
function renounceRoles(uint256 roles) public payable virtual {
_removeRoles(msg.sender, roles);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC READ FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the roles of `user`.
function rolesOf(address user) public view virtual returns (uint256 roles) {
/// @solidity memory-safe-assembly
assembly {
// Compute the role slot.
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, user)
// Load the stored value.
roles := sload(keccak256(0x0c, 0x20))
}
}
/// @dev Returns whether `user` has any of `roles`.
function hasAnyRole(address user, uint256 roles) public view virtual returns (bool) {
return rolesOf(user) & roles != 0;
}
/// @dev Returns whether `user` has all of `roles`.
function hasAllRoles(address user, uint256 roles) public view virtual returns (bool) {
return rolesOf(user) & roles == roles;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* MODIFIERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Marks a function as only callable by an account with `roles`.
modifier onlyRoles(uint256 roles) virtual {
_checkRoles(roles);
_;
}
/// @dev Marks a function as only callable by the owner or by an account
/// with `roles`. Checks for ownership first, then lazily checks for roles.
modifier onlyOwnerOrRoles(uint256 roles) virtual {
_checkOwnerOrRoles(roles);
_;
}
/// @dev Marks a function as only callable by an account with `roles`
/// or the owner. Checks for roles first, then lazily checks for ownership.
modifier onlyRolesOrOwner(uint256 roles) virtual {
_checkRolesOrOwner(roles);
_;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ROLE CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// IYKYK
uint256 internal constant _ROLE_0 = 1 << 0;
uint256 internal constant _ROLE_1 = 1 << 1;
uint256 internal constant _ROLE_2 = 1 << 2;
uint256 internal constant _ROLE_3 = 1 << 3;
uint256 internal constant _ROLE_4 = 1 << 4;
uint256 internal constant _ROLE_5 = 1 << 5;
uint256 internal constant _ROLE_6 = 1 << 6;
uint256 internal constant _ROLE_7 = 1 << 7;
uint256 internal constant _ROLE_8 = 1 << 8;
uint256 internal constant _ROLE_9 = 1 << 9;
uint256 internal constant _ROLE_10 = 1 << 10;
uint256 internal constant _ROLE_11 = 1 << 11;
uint256 internal constant _ROLE_12 = 1 << 12;
uint256 internal constant _ROLE_13 = 1 << 13;
uint256 internal constant _ROLE_14 = 1 << 14;
uint256 internal constant _ROLE_15 = 1 << 15;
uint256 internal constant _ROLE_16 = 1 << 16;
uint256 internal constant _ROLE_17 = 1 << 17;
uint256 internal constant _ROLE_18 = 1 << 18;
uint256 internal constant _ROLE_19 = 1 << 19;
uint256 internal constant _ROLE_20 = 1 << 20;
uint256 internal constant _ROLE_21 = 1 << 21;
uint256 internal constant _ROLE_22 = 1 << 22;
uint256 internal constant _ROLE_23 = 1 << 23;
uint256 internal constant _ROLE_24 = 1 << 24;
uint256 internal constant _ROLE_25 = 1 << 25;
uint256 internal constant _ROLE_26 = 1 << 26;
uint256 internal constant _ROLE_27 = 1 << 27;
uint256 internal constant _ROLE_28 = 1 << 28;
uint256 internal constant _ROLE_29 = 1 << 29;
uint256 internal constant _ROLE_30 = 1 << 30;
uint256 internal constant _ROLE_31 = 1 << 31;
uint256 internal constant _ROLE_32 = 1 << 32;
uint256 internal constant _ROLE_33 = 1 << 33;
uint256 internal constant _ROLE_34 = 1 << 34;
uint256 internal constant _ROLE_35 = 1 << 35;
uint256 internal constant _ROLE_36 = 1 << 36;
uint256 internal constant _ROLE_37 = 1 << 37;
uint256 internal constant _ROLE_38 = 1 << 38;
uint256 internal constant _ROLE_39 = 1 << 39;
uint256 internal constant _ROLE_40 = 1 << 40;
uint256 internal constant _ROLE_41 = 1 << 41;
uint256 internal constant _ROLE_42 = 1 << 42;
uint256 internal constant _ROLE_43 = 1 << 43;
uint256 internal constant _ROLE_44 = 1 << 44;
uint256 internal constant _ROLE_45 = 1 << 45;
uint256 internal constant _ROLE_46 = 1 << 46;
uint256 internal constant _ROLE_47 = 1 << 47;
uint256 internal constant _ROLE_48 = 1 << 48;
uint256 internal constant _ROLE_49 = 1 << 49;
uint256 internal constant _ROLE_50 = 1 << 50;
uint256 internal constant _ROLE_51 = 1 << 51;
uint256 internal constant _ROLE_52 = 1 << 52;
uint256 internal constant _ROLE_53 = 1 << 53;
uint256 internal constant _ROLE_54 = 1 << 54;
uint256 internal constant _ROLE_55 = 1 << 55;
uint256 internal constant _ROLE_56 = 1 << 56;
uint256 internal constant _ROLE_57 = 1 << 57;
uint256 internal constant _ROLE_58 = 1 << 58;
uint256 internal constant _ROLE_59 = 1 << 59;
uint256 internal constant _ROLE_60 = 1 << 60;
uint256 internal constant _ROLE_61 = 1 << 61;
uint256 internal constant _ROLE_62 = 1 << 62;
uint256 internal constant _ROLE_63 = 1 << 63;
uint256 internal constant _ROLE_64 = 1 << 64;
uint256 internal constant _ROLE_65 = 1 << 65;
uint256 internal constant _ROLE_66 = 1 << 66;
uint256 internal constant _ROLE_67 = 1 << 67;
uint256 internal constant _ROLE_68 = 1 << 68;
uint256 internal constant _ROLE_69 = 1 << 69;
uint256 internal constant _ROLE_70 = 1 << 70;
uint256 internal constant _ROLE_71 = 1 << 71;
uint256 internal constant _ROLE_72 = 1 << 72;
uint256 internal constant _ROLE_73 = 1 << 73;
uint256 internal constant _ROLE_74 = 1 << 74;
uint256 internal constant _ROLE_75 = 1 << 75;
uint256 internal constant _ROLE_76 = 1 << 76;
uint256 internal constant _ROLE_77 = 1 << 77;
uint256 internal constant _ROLE_78 = 1 << 78;
uint256 internal constant _ROLE_79 = 1 << 79;
uint256 internal constant _ROLE_80 = 1 << 80;
uint256 internal constant _ROLE_81 = 1 << 81;
uint256 internal constant _ROLE_82 = 1 << 82;
uint256 internal constant _ROLE_83 = 1 << 83;
uint256 internal constant _ROLE_84 = 1 << 84;
uint256 internal constant _ROLE_85 = 1 << 85;
uint256 internal constant _ROLE_86 = 1 << 86;
uint256 internal constant _ROLE_87 = 1 << 87;
uint256 internal constant _ROLE_88 = 1 << 88;
uint256 internal constant _ROLE_89 = 1 << 89;
uint256 internal constant _ROLE_90 = 1 << 90;
uint256 internal constant _ROLE_91 = 1 << 91;
uint256 internal constant _ROLE_92 = 1 << 92;
uint256 internal constant _ROLE_93 = 1 << 93;
uint256 internal constant _ROLE_94 = 1 << 94;
uint256 internal constant _ROLE_95 = 1 << 95;
uint256 internal constant _ROLE_96 = 1 << 96;
uint256 internal constant _ROLE_97 = 1 << 97;
uint256 internal constant _ROLE_98 = 1 << 98;
uint256 internal constant _ROLE_99 = 1 << 99;
uint256 internal constant _ROLE_100 = 1 << 100;
uint256 internal constant _ROLE_101 = 1 << 101;
uint256 internal constant _ROLE_102 = 1 << 102;
uint256 internal constant _ROLE_103 = 1 << 103;
uint256 internal constant _ROLE_104 = 1 << 104;
uint256 internal constant _ROLE_105 = 1 << 105;
uint256 internal constant _ROLE_106 = 1 << 106;
uint256 internal constant _ROLE_107 = 1 << 107;
uint256 internal constant _ROLE_108 = 1 << 108;
uint256 internal constant _ROLE_109 = 1 << 109;
uint256 internal constant _ROLE_110 = 1 << 110;
uint256 internal constant _ROLE_111 = 1 << 111;
uint256 internal constant _ROLE_112 = 1 << 112;
uint256 internal constant _ROLE_113 = 1 << 113;
uint256 internal constant _ROLE_114 = 1 << 114;
uint256 internal constant _ROLE_115 = 1 << 115;
uint256 internal constant _ROLE_116 = 1 << 116;
uint256 internal constant _ROLE_117 = 1 << 117;
uint256 internal constant _ROLE_118 = 1 << 118;
uint256 internal constant _ROLE_119 = 1 << 119;
uint256 internal constant _ROLE_120 = 1 << 120;
uint256 internal constant _ROLE_121 = 1 << 121;
uint256 internal constant _ROLE_122 = 1 << 122;
uint256 internal constant _ROLE_123 = 1 << 123;
uint256 internal constant _ROLE_124 = 1 << 124;
uint256 internal constant _ROLE_125 = 1 << 125;
uint256 internal constant _ROLE_126 = 1 << 126;
uint256 internal constant _ROLE_127 = 1 << 127;
uint256 internal constant _ROLE_128 = 1 << 128;
uint256 internal constant _ROLE_129 = 1 << 129;
uint256 internal constant _ROLE_130 = 1 << 130;
uint256 internal constant _ROLE_131 = 1 << 131;
uint256 internal constant _ROLE_132 = 1 << 132;
uint256 internal constant _ROLE_133 = 1 << 133;
uint256 internal constant _ROLE_134 = 1 << 134;
uint256 internal constant _ROLE_135 = 1 << 135;
uint256 internal constant _ROLE_136 = 1 << 136;
uint256 internal constant _ROLE_137 = 1 << 137;
uint256 internal constant _ROLE_138 = 1 << 138;
uint256 internal constant _ROLE_139 = 1 << 139;
uint256 internal constant _ROLE_140 = 1 << 140;
uint256 internal constant _ROLE_141 = 1 << 141;
uint256 internal constant _ROLE_142 = 1 << 142;
uint256 internal constant _ROLE_143 = 1 << 143;
uint256 internal constant _ROLE_144 = 1 << 144;
uint256 internal constant _ROLE_145 = 1 << 145;
uint256 internal constant _ROLE_146 = 1 << 146;
uint256 internal constant _ROLE_147 = 1 << 147;
uint256 internal constant _ROLE_148 = 1 << 148;
uint256 internal constant _ROLE_149 = 1 << 149;
uint256 internal constant _ROLE_150 = 1 << 150;
uint256 internal constant _ROLE_151 = 1 << 151;
uint256 internal constant _ROLE_152 = 1 << 152;
uint256 internal constant _ROLE_153 = 1 << 153;
uint256 internal constant _ROLE_154 = 1 << 154;
uint256 internal constant _ROLE_155 = 1 << 155;
uint256 internal constant _ROLE_156 = 1 << 156;
uint256 internal constant _ROLE_157 = 1 << 157;
uint256 internal constant _ROLE_158 = 1 << 158;
uint256 internal constant _ROLE_159 = 1 << 159;
uint256 internal constant _ROLE_160 = 1 << 160;
uint256 internal constant _ROLE_161 = 1 << 161;
uint256 internal constant _ROLE_162 = 1 << 162;
uint256 internal constant _ROLE_163 = 1 << 163;
uint256 internal constant _ROLE_164 = 1 << 164;
uint256 internal constant _ROLE_165 = 1 << 165;
uint256 internal constant _ROLE_166 = 1 << 166;
uint256 internal constant _ROLE_167 = 1 << 167;
uint256 internal constant _ROLE_168 = 1 << 168;
uint256 internal constant _ROLE_169 = 1 << 169;
uint256 internal constant _ROLE_170 = 1 << 170;
uint256 internal constant _ROLE_171 = 1 << 171;
uint256 internal constant _ROLE_172 = 1 << 172;
uint256 internal constant _ROLE_173 = 1 << 173;
uint256 internal constant _ROLE_174 = 1 << 174;
uint256 internal constant _ROLE_175 = 1 << 175;
uint256 internal constant _ROLE_176 = 1 << 176;
uint256 internal constant _ROLE_177 = 1 << 177;
uint256 internal constant _ROLE_178 = 1 << 178;
uint256 internal constant _ROLE_179 = 1 << 179;
uint256 internal constant _ROLE_180 = 1 << 180;
uint256 internal constant _ROLE_181 = 1 << 181;
uint256 internal constant _ROLE_182 = 1 << 182;
uint256 internal constant _ROLE_183 = 1 << 183;
uint256 internal constant _ROLE_184 = 1 << 184;
uint256 internal constant _ROLE_185 = 1 << 185;
uint256 internal constant _ROLE_186 = 1 << 186;
uint256 internal constant _ROLE_187 = 1 << 187;
uint256 internal constant _ROLE_188 = 1 << 188;
uint256 internal constant _ROLE_189 = 1 << 189;
uint256 internal constant _ROLE_190 = 1 << 190;
uint256 internal constant _ROLE_191 = 1 << 191;
uint256 internal constant _ROLE_192 = 1 << 192;
uint256 internal constant _ROLE_193 = 1 << 193;
uint256 internal constant _ROLE_194 = 1 << 194;
uint256 internal constant _ROLE_195 = 1 << 195;
uint256 internal constant _ROLE_196 = 1 << 196;
uint256 internal constant _ROLE_197 = 1 << 197;
uint256 internal constant _ROLE_198 = 1 << 198;
uint256 internal constant _ROLE_199 = 1 << 199;
uint256 internal constant _ROLE_200 = 1 << 200;
uint256 internal constant _ROLE_201 = 1 << 201;
uint256 internal constant _ROLE_202 = 1 << 202;
uint256 internal constant _ROLE_203 = 1 << 203;
uint256 internal constant _ROLE_204 = 1 << 204;
uint256 internal constant _ROLE_205 = 1 << 205;
uint256 internal constant _ROLE_206 = 1 << 206;
uint256 internal constant _ROLE_207 = 1 << 207;
uint256 internal constant _ROLE_208 = 1 << 208;
uint256 internal constant _ROLE_209 = 1 << 209;
uint256 internal constant _ROLE_210 = 1 << 210;
uint256 internal constant _ROLE_211 = 1 << 211;
uint256 internal constant _ROLE_212 = 1 << 212;
uint256 internal constant _ROLE_213 = 1 << 213;
uint256 internal constant _ROLE_214 = 1 << 214;
uint256 internal constant _ROLE_215 = 1 << 215;
uint256 internal constant _ROLE_216 = 1 << 216;
uint256 internal constant _ROLE_217 = 1 << 217;
uint256 internal constant _ROLE_218 = 1 << 218;
uint256 internal constant _ROLE_219 = 1 << 219;
uint256 internal constant _ROLE_220 = 1 << 220;
uint256 internal constant _ROLE_221 = 1 << 221;
uint256 internal constant _ROLE_222 = 1 << 222;
uint256 internal constant _ROLE_223 = 1 << 223;
uint256 internal constant _ROLE_224 = 1 << 224;
uint256 internal constant _ROLE_225 = 1 << 225;
uint256 internal constant _ROLE_226 = 1 << 226;
uint256 internal constant _ROLE_227 = 1 << 227;
uint256 internal constant _ROLE_228 = 1 << 228;
uint256 internal constant _ROLE_229 = 1 << 229;
uint256 internal constant _ROLE_230 = 1 << 230;
uint256 internal constant _ROLE_231 = 1 << 231;
uint256 internal constant _ROLE_232 = 1 << 232;
uint256 internal constant _ROLE_233 = 1 << 233;
uint256 internal constant _ROLE_234 = 1 << 234;
uint256 internal constant _ROLE_235 = 1 << 235;
uint256 internal constant _ROLE_236 = 1 << 236;
uint256 internal constant _ROLE_237 = 1 << 237;
uint256 internal constant _ROLE_238 = 1 << 238;
uint256 internal constant _ROLE_239 = 1 << 239;
uint256 internal constant _ROLE_240 = 1 << 240;
uint256 internal constant _ROLE_241 = 1 << 241;
uint256 internal constant _ROLE_242 = 1 << 242;
uint256 internal constant _ROLE_243 = 1 << 243;
uint256 internal constant _ROLE_244 = 1 << 244;
uint256 internal constant _ROLE_245 = 1 << 245;
uint256 internal constant _ROLE_246 = 1 << 246;
uint256 internal constant _ROLE_247 = 1 << 247;
uint256 internal constant _ROLE_248 = 1 << 248;
uint256 internal constant _ROLE_249 = 1 << 249;
uint256 internal constant _ROLE_250 = 1 << 250;
uint256 internal constant _ROLE_251 = 1 << 251;
uint256 internal constant _ROLE_252 = 1 << 252;
uint256 internal constant _ROLE_253 = 1 << 253;
uint256 internal constant _ROLE_254 = 1 << 254;
uint256 internal constant _ROLE_255 = 1 << 255;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Library for managing enumerable sets in storage.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibMap.sol)
///
/// @dev Note:
/// In many applications, the number of elements in an enumerable set is small.
/// This enumerable set implementation avoids storing the length and indices
/// for up to 3 elements. Once the length exceeds 3 for the first time, the length
/// and indices will be initialized. The amortized cost of adding elements is O(1).
///
/// The AddressSet implementation packs the length with the 0th entry.
library EnumerableSetLib {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The index must be less than the length.
error IndexOutOfBounds();
/// @dev The value cannot be the zero sentinel.
error ValueIsZeroSentinel();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev A sentinel value to denote the zero value in storage.
/// No elements can be equal to this value.
/// `uint72(bytes9(keccak256(bytes("_ZERO_SENTINEL"))))`.
uint256 private constant _ZERO_SENTINEL = 0xfbb67fda52d4bfb8bf;
/// @dev The storage layout is given by:
/// ```
/// mstore(0x04, _ENUMERABLE_ADDRESS_SET_SLOT_SEED)
/// mstore(0x00, set.slot)
/// let rootSlot := keccak256(0x00, 0x24)
/// mstore(0x20, rootSlot)
/// mstore(0x00, shr(96, shl(96, value)))
/// let positionSlot := keccak256(0x00, 0x40)
/// let valueSlot := add(rootSlot, sload(positionSlot))
/// let valueInStorage := shr(96, sload(valueSlot))
/// let lazyLength := shr(160, shl(160, sload(rootSlot)))
/// ```
uint256 private constant _ENUMERABLE_ADDRESS_SET_SLOT_SEED = 0x978aab92;
/// @dev The storage layout is given by:
/// ```
/// mstore(0x04, _ENUMERABLE_WORD_SET_SLOT_SEED)
/// mstore(0x00, set.slot)
/// let rootSlot := keccak256(0x00, 0x24)
/// mstore(0x20, rootSlot)
/// mstore(0x00, value)
/// let positionSlot := keccak256(0x00, 0x40)
/// let valueSlot := add(rootSlot, sload(positionSlot))
/// let valueInStorage := sload(valueSlot)
/// let lazyLength := sload(not(rootSlot))
/// ```
uint256 private constant _ENUMERABLE_WORD_SET_SLOT_SEED = 0x18fb5864;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STRUCTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev An enumerable address set in storage.
struct AddressSet {
uint256 _spacer;
}
/// @dev An enumerable bytes32 set in storage.
struct Bytes32Set {
uint256 _spacer;
}
/// @dev An enumerable uint256 set in storage.
struct Uint256Set {
uint256 _spacer;
}
/// @dev An enumerable int256 set in storage.
struct Int256Set {
uint256 _spacer;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* GETTERS / SETTERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the number of elements in the set.
function length(AddressSet storage set) internal view returns (uint256 result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
let rootPacked := sload(rootSlot)
let n := shr(160, shl(160, rootPacked))
result := shr(1, n)
for {} iszero(or(iszero(shr(96, rootPacked)), n)) {} {
result := 1
if iszero(sload(add(rootSlot, result))) { break }
result := 2
if iszero(sload(add(rootSlot, result))) { break }
result := 3
break
}
}
}
/// @dev Returns the number of elements in the set.
function length(Bytes32Set storage set) internal view returns (uint256 result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
let n := sload(not(rootSlot))
result := shr(1, n)
for {} iszero(n) {} {
result := 0
if iszero(sload(add(rootSlot, result))) { break }
result := 1
if iszero(sload(add(rootSlot, result))) { break }
result := 2
if iszero(sload(add(rootSlot, result))) { break }
result := 3
break
}
}
}
/// @dev Returns the number of elements in the set.
function length(Uint256Set storage set) internal view returns (uint256 result) {
result = length(_toBytes32Set(set));
}
/// @dev Returns the number of elements in the set.
function length(Int256Set storage set) internal view returns (uint256 result) {
result = length(_toBytes32Set(set));
}
/// @dev Returns whether `value` is in the set.
function contains(AddressSet storage set, address value) internal view returns (bool result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
value := shr(96, shl(96, value))
if eq(value, _ZERO_SENTINEL) {
mstore(0x00, 0xf5a267f1) // `ValueIsZeroSentinel()`.
revert(0x1c, 0x04)
}
if iszero(value) { value := _ZERO_SENTINEL }
let rootPacked := sload(rootSlot)
for {} 1 {} {
if iszero(shr(160, shl(160, rootPacked))) {
result := 1
if eq(shr(96, rootPacked), value) { break }
if eq(shr(96, sload(add(rootSlot, 1))), value) { break }
if eq(shr(96, sload(add(rootSlot, 2))), value) { break }
result := 0
break
}
mstore(0x20, rootSlot)
mstore(0x00, value)
result := iszero(iszero(sload(keccak256(0x00, 0x40))))
break
}
}
}
/// @dev Returns whether `value` is in the set.
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
if eq(value, _ZERO_SENTINEL) {
mstore(0x00, 0xf5a267f1) // `ValueIsZeroSentinel()`.
revert(0x1c, 0x04)
}
if iszero(value) { value := _ZERO_SENTINEL }
for {} 1 {} {
if iszero(sload(not(rootSlot))) {
result := 1
if eq(sload(rootSlot), value) { break }
if eq(sload(add(rootSlot, 1)), value) { break }
if eq(sload(add(rootSlot, 2)), value) { break }
result := 0
break
}
mstore(0x20, rootSlot)
mstore(0x00, value)
result := iszero(iszero(sload(keccak256(0x00, 0x40))))
break
}
}
}
/// @dev Returns whether `value` is in the set.
function contains(Uint256Set storage set, uint256 value) internal view returns (bool result) {
result = contains(_toBytes32Set(set), bytes32(value));
}
/// @dev Returns whether `value` is in the set.
function contains(Int256Set storage set, int256 value) internal view returns (bool result) {
result = contains(_toBytes32Set(set), bytes32(uint256(value)));
}
/// @dev Adds `value` to the set. Returns whether `value` was not in the set.
function add(AddressSet storage set, address value) internal returns (bool result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
value := shr(96, shl(96, value))
if eq(value, _ZERO_SENTINEL) {
mstore(0x00, 0xf5a267f1) // `ValueIsZeroSentinel()`.
revert(0x1c, 0x04)
}
if iszero(value) { value := _ZERO_SENTINEL }
let rootPacked := sload(rootSlot)
for { let n := shr(160, shl(160, rootPacked)) } 1 {} {
mstore(0x20, rootSlot)
if iszero(n) {
let v0 := shr(96, rootPacked)
if iszero(v0) {
sstore(rootSlot, shl(96, value))
result := 1
break
}
if eq(v0, value) { break }
let v1 := shr(96, sload(add(rootSlot, 1)))
if iszero(v1) {
sstore(add(rootSlot, 1), shl(96, value))
result := 1
break
}
if eq(v1, value) { break }
let v2 := shr(96, sload(add(rootSlot, 2)))
if iszero(v2) {
sstore(add(rootSlot, 2), shl(96, value))
result := 1
break
}
if eq(v2, value) { break }
mstore(0x00, v0)
sstore(keccak256(0x00, 0x40), 1)
mstore(0x00, v1)
sstore(keccak256(0x00, 0x40), 2)
mstore(0x00, v2)
sstore(keccak256(0x00, 0x40), 3)
rootPacked := or(rootPacked, 7)
n := 7
}
mstore(0x00, value)
let p := keccak256(0x00, 0x40)
if iszero(sload(p)) {
n := shr(1, n)
sstore(add(rootSlot, n), shl(96, value))
sstore(p, add(1, n))
sstore(rootSlot, add(2, rootPacked))
result := 1
break
}
break
}
}
}
/// @dev Adds `value` to the set. Returns whether `value` was not in the set.
function add(Bytes32Set storage set, bytes32 value) internal returns (bool result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
if eq(value, _ZERO_SENTINEL) {
mstore(0x00, 0xf5a267f1) // `ValueIsZeroSentinel()`.
revert(0x1c, 0x04)
}
if iszero(value) { value := _ZERO_SENTINEL }
for { let n := sload(not(rootSlot)) } 1 {} {
mstore(0x20, rootSlot)
if iszero(n) {
let v0 := sload(rootSlot)
if iszero(v0) {
sstore(rootSlot, value)
result := 1
break
}
if eq(v0, value) { break }
let v1 := sload(add(rootSlot, 1))
if iszero(v1) {
sstore(add(rootSlot, 1), value)
result := 1
break
}
if eq(v1, value) { break }
let v2 := sload(add(rootSlot, 2))
if iszero(v2) {
sstore(add(rootSlot, 2), value)
result := 1
break
}
if eq(v2, value) { break }
mstore(0x00, v0)
sstore(keccak256(0x00, 0x40), 1)
mstore(0x00, v1)
sstore(keccak256(0x00, 0x40), 2)
mstore(0x00, v2)
sstore(keccak256(0x00, 0x40), 3)
n := 7
}
mstore(0x00, value)
let p := keccak256(0x00, 0x40)
if iszero(sload(p)) {
n := shr(1, n)
sstore(add(rootSlot, n), value)
sstore(p, add(1, n))
sstore(not(rootSlot), or(1, shl(1, add(1, n))))
result := 1
break
}
break
}
}
}
/// @dev Adds `value` to the set. Returns whether `value` was not in the set.
function add(Uint256Set storage set, uint256 value) internal returns (bool result) {
result = add(_toBytes32Set(set), bytes32(value));
}
/// @dev Adds `value` to the set. Returns whether `value` was not in the set.
function add(Int256Set storage set, int256 value) internal returns (bool result) {
result = add(_toBytes32Set(set), bytes32(uint256(value)));
}
/// @dev Removes `value` from the set. Returns whether `value` was in the set.
function remove(AddressSet storage set, address value) internal returns (bool result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
value := shr(96, shl(96, value))
if eq(value, _ZERO_SENTINEL) {
mstore(0x00, 0xf5a267f1) // `ValueIsZeroSentinel()`.
revert(0x1c, 0x04)
}
if iszero(value) { value := _ZERO_SENTINEL }
let rootPacked := sload(rootSlot)
for { let n := shr(160, shl(160, rootPacked)) } 1 {} {
if iszero(n) {
result := 1
if eq(shr(96, rootPacked), value) {
sstore(rootSlot, sload(add(rootSlot, 1)))
sstore(add(rootSlot, 1), sload(add(rootSlot, 2)))
sstore(add(rootSlot, 2), 0)
break
}
if eq(shr(96, sload(add(rootSlot, 1))), value) {
sstore(add(rootSlot, 1), sload(add(rootSlot, 2)))
sstore(add(rootSlot, 2), 0)
break
}
if eq(shr(96, sload(add(rootSlot, 2))), value) {
sstore(add(rootSlot, 2), 0)
break
}
result := 0
break
}
mstore(0x20, rootSlot)
mstore(0x00, value)
let p := keccak256(0x00, 0x40)
let position := sload(p)
if iszero(position) { break }
n := sub(shr(1, n), 1)
if iszero(eq(sub(position, 1), n)) {
let lastValue := shr(96, sload(add(rootSlot, n)))
sstore(add(rootSlot, sub(position, 1)), shl(96, lastValue))
sstore(add(rootSlot, n), 0)
mstore(0x00, lastValue)
sstore(keccak256(0x00, 0x40), position)
}
sstore(rootSlot, or(shl(96, shr(96, sload(rootSlot))), or(shl(1, n), 1)))
sstore(p, 0)
result := 1
break
}
}
}
/// @dev Removes `value` from the set. Returns whether `value` was in the set.
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
if eq(value, _ZERO_SENTINEL) {
mstore(0x00, 0xf5a267f1) // `ValueIsZeroSentinel()`.
revert(0x1c, 0x04)
}
if iszero(value) { value := _ZERO_SENTINEL }
for { let n := sload(not(rootSlot)) } 1 {} {
if iszero(n) {
result := 1
if eq(sload(rootSlot), value) {
sstore(rootSlot, sload(add(rootSlot, 1)))
sstore(add(rootSlot, 1), sload(add(rootSlot, 2)))
sstore(add(rootSlot, 2), 0)
break
}
if eq(sload(add(rootSlot, 1)), value) {
sstore(add(rootSlot, 1), sload(add(rootSlot, 2)))
sstore(add(rootSlot, 2), 0)
break
}
if eq(sload(add(rootSlot, 2)), value) {
sstore(add(rootSlot, 2), 0)
break
}
result := 0
break
}
mstore(0x20, rootSlot)
mstore(0x00, value)
let p := keccak256(0x00, 0x40)
let position := sload(p)
if iszero(position) { break }
n := sub(shr(1, n), 1)
if iszero(eq(sub(position, 1), n)) {
let lastValue := sload(add(rootSlot, n))
sstore(add(rootSlot, sub(position, 1)), lastValue)
sstore(add(rootSlot, n), 0)
mstore(0x00, lastValue)
sstore(keccak256(0x00, 0x40), position)
}
sstore(not(rootSlot), or(shl(1, n), 1))
sstore(p, 0)
result := 1
break
}
}
}
/// @dev Removes `value` from the set. Returns whether `value` was in the set.
function remove(Uint256Set storage set, uint256 value) internal returns (bool result) {
result = remove(_toBytes32Set(set), bytes32(value));
}
/// @dev Removes `value` from the set. Returns whether `value` was in the set.
function remove(Int256Set storage set, int256 value) internal returns (bool result) {
result = remove(_toBytes32Set(set), bytes32(uint256(value)));
}
/// @dev Returns all of the values in the set.
/// Note: This can consume more gas than the block gas limit for large sets.
function values(AddressSet storage set) internal view returns (address[] memory result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
let zs := _ZERO_SENTINEL
let rootPacked := sload(rootSlot)
let n := shr(160, shl(160, rootPacked))
result := mload(0x40)
let o := add(0x20, result)
let v := shr(96, rootPacked)
mstore(o, mul(v, iszero(eq(v, zs))))
for {} 1 {} {
if iszero(n) {
if v {
n := 1
v := shr(96, sload(add(rootSlot, n)))
if v {
n := 2
mstore(add(o, 0x20), mul(v, iszero(eq(v, zs))))
v := shr(96, sload(add(rootSlot, n)))
if v {
n := 3
mstore(add(o, 0x40), mul(v, iszero(eq(v, zs))))
}
}
}
break
}
n := shr(1, n)
for { let i := 1 } lt(i, n) { i := add(i, 1) } {
v := shr(96, sload(add(rootSlot, i)))
mstore(add(o, shl(5, i)), mul(v, iszero(eq(v, zs))))
}
break
}
mstore(result, n)
mstore(0x40, add(o, shl(5, n)))
}
}
/// @dev Returns all of the values in the set.
/// Note: This can consume more gas than the block gas limit for large sets.
function values(Bytes32Set storage set) internal view returns (bytes32[] memory result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
let zs := _ZERO_SENTINEL
let n := sload(not(rootSlot))
result := mload(0x40)
let o := add(0x20, result)
for {} 1 {} {
if iszero(n) {
let v := sload(rootSlot)
if v {
n := 1
mstore(o, mul(v, iszero(eq(v, zs))))
v := sload(add(rootSlot, n))
if v {
n := 2
mstore(add(o, 0x20), mul(v, iszero(eq(v, zs))))
v := sload(add(rootSlot, n))
if v {
n := 3
mstore(add(o, 0x40), mul(v, iszero(eq(v, zs))))
}
}
}
break
}
n := shr(1, n)
for { let i := 0 } lt(i, n) { i := add(i, 1) } {
let v := sload(add(rootSlot, i))
mstore(add(o, shl(5, i)), mul(v, iszero(eq(v, zs))))
}
break
}
mstore(result, n)
mstore(0x40, add(o, shl(5, n)))
}
}
/// @dev Returns all of the values in the set.
/// Note: This can consume more gas than the block gas limit for large sets.
function values(Uint256Set storage set) internal view returns (uint256[] memory result) {
result = _toUints(values(_toBytes32Set(set)));
}
/// @dev Returns all of the values in the set.
/// Note: This can consume more gas than the block gas limit for large sets.
function values(Int256Set storage set) internal view returns (int256[] memory result) {
result = _toInts(values(_toBytes32Set(set)));
}
/// @dev Returns the element at index `i` in the set.
function at(AddressSet storage set, uint256 i) internal view returns (address result) {
bytes32 rootSlot = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
result := shr(96, sload(add(rootSlot, i)))
result := mul(result, iszero(eq(result, _ZERO_SENTINEL)))
}
if (i >= length(set)) revert IndexOutOfBounds();
}
/// @dev Returns the element at index `i` in the set.
function at(Bytes32Set storage set, uint256 i) internal view returns (bytes32 result) {
result = _rootSlot(set);
/// @solidity memory-safe-assembly
assembly {
result := sload(add(result, i))
result := mul(result, iszero(eq(result, _ZERO_SENTINEL)))
}
if (i >= length(set)) revert IndexOutOfBounds();
}
/// @dev Returns the element at index `i` in the set.
function at(Uint256Set storage set, uint256 i) internal view returns (uint256 result) {
result = uint256(at(_toBytes32Set(set), i));
}
/// @dev Returns the element at index `i` in the set.
function at(Int256Set storage set, uint256 i) internal view returns (int256 result) {
result = int256(uint256(at(_toBytes32Set(set), i)));
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PRIVATE HELPERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the root slot.
function _rootSlot(AddressSet storage s) private pure returns (bytes32 r) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x04, _ENUMERABLE_ADDRESS_SET_SLOT_SEED)
mstore(0x00, s.slot)
r := keccak256(0x00, 0x24)
}
}
/// @dev Returns the root slot.
function _rootSlot(Bytes32Set storage s) private pure returns (bytes32 r) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x04, _ENUMERABLE_WORD_SET_SLOT_SEED)
mstore(0x00, s.slot)
r := keccak256(0x00, 0x24)
}
}
/// @dev Casts to a Bytes32Set.
function _toBytes32Set(Uint256Set storage s) private pure returns (Bytes32Set storage c) {
/// @solidity memory-safe-assembly
assembly {
c.slot := s.slot
}
}
/// @dev Casts to a Bytes32Set.
function _toBytes32Set(Int256Set storage s) private pure returns (Bytes32Set storage c) {
/// @solidity memory-safe-assembly
assembly {
c.slot := s.slot
}
}
/// @dev Casts to a uint256 array.
function _toUints(bytes32[] memory a) private pure returns (uint256[] memory c) {
/// @solidity memory-safe-assembly
assembly {
c := a
}
}
/// @dev Casts to a int256 array.
function _toInts(bytes32[] memory a) private pure returns (int256[] memory c) {
/// @solidity memory-safe-assembly
assembly {
c := a
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Reentrancy guard mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Unauthorized reentrant call.
error Reentrancy();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Equivalent to: `uint72(bytes9(keccak256("_REENTRANCY_GUARD_SLOT")))`.
/// 9 bytes is large enough to avoid collisions with lower slots,
/// but not too large to result in excessive bytecode bloat.
uint256 private constant _REENTRANCY_GUARD_SLOT = 0x929eee149b4bd21268;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* REENTRANCY GUARD */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Guards a function from reentrancy.
modifier nonReentrant() virtual {
/// @solidity memory-safe-assembly
assembly {
if eq(sload(_REENTRANCY_GUARD_SLOT), address()) {
mstore(0x00, 0xab143c06) // `Reentrancy()`.
revert(0x1c, 0x04)
}
sstore(_REENTRANCY_GUARD_SLOT, address())
}
_;
/// @solidity memory-safe-assembly
assembly {
sstore(_REENTRANCY_GUARD_SLOT, codesize())
}
}
/// @dev Guards a view function from read-only reentrancy.
modifier nonReadReentrant() virtual {
/// @solidity memory-safe-assembly
assembly {
if eq(sload(_REENTRANCY_GUARD_SLOT), address()) {
mstore(0x00, 0xab143c06) // `Reentrancy()`.
revert(0x1c, 0x04)
}
}
_;
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;
// Interface
import {IInstallationCallback} from "./interface/IInstallationCallback.sol";
import {IModularCore} from "./interface/IModularCore.sol";
import {IModularModule} from "./interface/IModularModule.sol";
// Utils
import {Role} from "./Role.sol";
import {OwnableRoles} from "@solady/auth/OwnableRoles.sol";
import {EnumerableSetLib} from "@solady/utils/EnumerableSetLib.sol";
import {ReentrancyGuard} from "@solady/utils/ReentrancyGuard.sol";
abstract contract ModularCore is IModularCore, OwnableRoles, ReentrancyGuard {
using EnumerableSetLib for EnumerableSetLib.AddressSet;
/*//////////////////////////////////////////////////////////////
TYPES
//////////////////////////////////////////////////////////////*/
/// @dev The type of function callable on module contracts.
enum FunctionType {
CALLBACK,
FALLBACK
}
/// @dev Internal representation of a fallback function callable via fallback().
struct InstalledFunction {
address implementation;
uint256 permissionBits;
FunctionType fnType;
}
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
/// @notice Emitted when an module is installed.
event ModuleInstalled(address caller, address implementation, address installedModule);
/// @notice Emitted when an module is uninstalled.
event ModuleUninstalled(address caller, address implementation, address installedModule);
/*//////////////////////////////////////////////////////////////
STORAGE
//////////////////////////////////////////////////////////////*/
/// @dev The set of addresses of installed modules.
EnumerableSetLib.AddressSet private modules;
/// @dev interface ID => counter of modules supporting the interface.
mapping(bytes4 => uint256) private supportedInterfaceRefCounter;
/// @dev function selector => function data.
mapping(bytes4 => InstalledFunction) private functionData_;
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error ModuleOutOfSync();
error ModuleNotInstalled();
error ModuleAlreadyInstalled();
error CallbackFunctionRequired();
error CallbackExecutionReverted();
error CallbackFunctionNotSupported();
error CallbackFunctionAlreadyInstalled();
error CallbackFunctionUnauthorizedCall();
error FallbackFunctionAlreadyInstalled();
error FallbackFunctionNotInstalled();
error ModuleInterfaceNotCompatible(bytes4 requiredInterfaceId);
/*//////////////////////////////////////////////////////////////
FALLBACK FUNCTION
//////////////////////////////////////////////////////////////*/
/// @notice Routes a call to the appropriate module contract.
fallback() external payable {
// Get module function data.
InstalledFunction memory fn = functionData_[msg.sig];
// Check: module function data exists.
if (fn.implementation == address(0)) {
revert FallbackFunctionNotInstalled();
}
// Check: authorized to call permissioned module function
if (fn.fnType == FunctionType.CALLBACK) {
if (msg.sender != address(this)) {
revert CallbackFunctionUnauthorizedCall();
}
} else if (fn.fnType == FunctionType.FALLBACK && fn.permissionBits > 0) {
_checkOwnerOrRoles(fn.permissionBits);
}
_delegateAndReturn(fn.implementation);
}
/*//////////////////////////////////////////////////////////////
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Returns the list of all callback functions called on some module contract.
function getSupportedCallbackFunctions() public pure virtual returns (SupportedCallbackFunction[] memory);
/// @notice Returns a list of addresess and respective module configs of all installed modules.
function getInstalledModules() external view returns (InstalledModule[] memory _installedModules) {
uint256 totalInstalled = modules.length();
_installedModules = new InstalledModule[](totalInstalled);
for (uint256 i = 0; i < totalInstalled; i++) {
address implementation = modules.at(i);
_installedModules[i] = InstalledModule({
implementation: implementation,
config: IModularModule(implementation).getModuleConfig()
});
}
}
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Installs an module contract.
function installModule(address _module, bytes calldata _data)
external
payable
onlyOwnerOrRoles(Role._INSTALLER_ROLE)
{
// Install module.
_installModule(_module, _data);
}
/// @notice Uninstalls an module contract.
function uninstallModule(address _module, bytes calldata _data)
external
payable
onlyOwnerOrRoles(Role._INSTALLER_ROLE)
{
// Uninstall module.
_uninstallModule(_module, _data);
}
/// @notice Returns whether a given interface is implemented by the contract.
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
if (interfaceId == 0xffffffff) {
return false;
}
if (supportedInterfaceRefCounter[interfaceId] > 0) {
return true;
}
return false;
}
/*//////////////////////////////////////////////////////////////
INTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Returns whether a given interface is implemented by the contract.
function _supportsInterfaceViaModules(bytes4 interfaceId) internal view virtual returns (bool) {
if (interfaceId == 0xffffffff) {
return false;
}
if (supportedInterfaceRefCounter[interfaceId] > 0) {
return true;
}
return false;
}
/// @dev Installs an module contract.
function _installModule(address _module, bytes memory _data) internal {
if (!modules.add(_module)) {
revert ModuleAlreadyInstalled();
}
// Get module config.
ModuleConfig memory config = IModularModule(_module).getModuleConfig();
// Check: ModularCore supports interface required by module.
if (config.requiredInterfaces.length != 0) {
for (uint256 i = 0; i < config.requiredInterfaces.length; i++) {
if (!supportsInterface(config.requiredInterfaces[i])) {
revert ModuleInterfaceNotCompatible(config.requiredInterfaces[i]);
}
}
}
// Store interface support inherited via module installation.
uint256 supportedInterfaceLength = config.supportedInterfaces.length;
for (uint256 i = 0; i < supportedInterfaceLength; i++) {
supportedInterfaceRefCounter[config.supportedInterfaces[i]] += 1;
}
// Store callback function data. Only install supported callback functions
SupportedCallbackFunction[] memory supportedCallbacks = getSupportedCallbackFunctions();
uint256 supportedCallbacksLength = supportedCallbacks.length;
uint256 callbackLength = config.callbackFunctions.length;
for (uint256 i = 0; i < callbackLength; i++) {
CallbackFunction memory callbackFunction = config.callbackFunctions[i];
// Check: callback function data not already stored.
if (functionData_[callbackFunction.selector].implementation != address(0)) {
revert CallbackFunctionAlreadyInstalled();
}
// Check: callback function is supported
bool supported = false;
for (uint256 j = 0; j < supportedCallbacksLength; j++) {
if (supportedCallbacks[j].selector == callbackFunction.selector) {
supported = true;
break;
}
}
if (!supported) {
revert CallbackFunctionNotSupported();
}
functionData_[callbackFunction.selector] =
InstalledFunction({implementation: _module, permissionBits: 0, fnType: FunctionType.CALLBACK});
}
// Store module function data.
uint256 functionLength = config.fallbackFunctions.length;
for (uint256 i = 0; i < functionLength; i++) {
FallbackFunction memory ext = config.fallbackFunctions[i];
// Check: module function data not already stored.
if (functionData_[ext.selector].implementation != address(0)) {
revert FallbackFunctionAlreadyInstalled();
}
functionData_[ext.selector] = InstalledFunction({
implementation: _module,
permissionBits: ext.permissionBits,
fnType: FunctionType.FALLBACK
});
}
// Call `onInstall` callback function if module has registered installation callback.
if (config.registerInstallationCallback) {
(bool success, bytes memory returndata) =
_module.delegatecall(abi.encodeCall(IInstallationCallback.onInstall, (_data)));
if (!success) {
_revert(returndata, CallbackExecutionReverted.selector);
}
}
emit ModuleInstalled(msg.sender, _module, _module);
}
/// @notice Uninstalls an module contract.
function _uninstallModule(address _module, bytes memory _data) internal {
// Check: remove and check if the module is installed
if (!modules.remove(_module)) {
revert ModuleNotInstalled();
}
// Get module config.
ModuleConfig memory config = IModularModule(_module).getModuleConfig();
uint256 supportedInterfaceLength = config.supportedInterfaces.length;
for (uint256 i = 0; i < supportedInterfaceLength; i++) {
// Note: This should not underflow because module needs to be installed before uninstalling. getModuleConfig should returns the same value during installation and uninstallation.
supportedInterfaceRefCounter[config.supportedInterfaces[i]] -= 1;
}
// Remove module function data
uint256 functionLength = config.fallbackFunctions.length;
for (uint256 i = 0; i < functionLength; i++) {
delete functionData_[config.fallbackFunctions[i].selector];
}
// Remove callback function data
uint256 callbackLength = config.callbackFunctions.length;
for (uint256 i = 0; i < callbackLength; i++) {
delete functionData_[config.callbackFunctions[i].selector];
}
if (config.registerInstallationCallback) {
_module.delegatecall(abi.encodeCall(IInstallationCallback.onUninstall, (_data)));
}
emit ModuleUninstalled(msg.sender, _module, _module);
}
/// @dev Calls an module callback function and checks whether it is optional or required.
function _executeCallbackFunction(bytes4 _selector, bytes memory _abiEncodedCalldata)
internal
nonReentrant
returns (bool success, bytes memory returndata)
{
InstalledFunction memory callbackFunction = functionData_[_selector];
// Verify that the function is a callback function
if (callbackFunction.fnType != FunctionType.CALLBACK) {
revert CallbackFunctionNotSupported();
}
// Get callback mode -- required or not required.
SupportedCallbackFunction[] memory functions = getSupportedCallbackFunctions();
uint256 len = functions.length;
CallbackMode callbackMode;
for (uint256 i = 0; i < len; i++) {
if (functions[i].selector == _selector) {
callbackMode = functions[i].mode;
break;
}
}
if (callbackFunction.implementation != address(0)) {
(success, returndata) = callbackFunction.implementation.delegatecall(_abiEncodedCalldata);
if (!success) {
_revert(returndata, CallbackExecutionReverted.selector);
}
} else if (callbackMode == CallbackMode.REQUIRED) {
revert CallbackFunctionRequired();
}
}
/// @dev Calls an module callback function and checks whether it is optional or required.
function _executeCallbackFunctionView(bytes4 _selector, bytes memory _abiEncodedCalldata)
internal
view
returns (bool success, bytes memory returndata)
{
InstalledFunction memory callbackFunction = functionData_[_selector];
// Verify that the function is a callback function
if (callbackFunction.fnType != FunctionType.CALLBACK) {
revert CallbackFunctionNotSupported();
}
// Get callback mode -- required or not required.
SupportedCallbackFunction[] memory functions = getSupportedCallbackFunctions();
uint256 len = functions.length;
CallbackMode callbackMode;
for (uint256 i = 0; i < len; i++) {
if (functions[i].selector == _selector) {
callbackMode = functions[i].mode;
break;
}
}
if (callbackFunction.implementation != address(0)) {
(success, returndata) = address(this).staticcall(_abiEncodedCalldata);
if (!success) {
_revert(returndata, CallbackExecutionReverted.selector);
}
} else if (callbackMode == CallbackMode.REQUIRED) {
revert CallbackFunctionRequired();
}
}
/// @dev delegateCalls an `implementation` smart contract.
/// @notice Only use this at the end of the function as it reverts or returns the result
function _delegateAndReturn(address _implementation) private {
/// @solidity memory-safe-assembly
assembly {
function allocate(length) -> pos {
pos := mload(0x40)
mstore(0x40, add(pos, length))
}
let calldataPtr := allocate(calldatasize())
calldatacopy(calldataPtr, 0, calldatasize())
let success := delegatecall(gas(), _implementation, calldataPtr, calldatasize(), 0, 0)
let returnDataPtr := allocate(returndatasize())
returndatacopy(returnDataPtr, 0, returndatasize())
if iszero(success) { revert(returnDataPtr, returndatasize()) }
return(returnDataPtr, returndatasize())
}
}
/// @dev Reverts with the given return data / error message.
function _revert(bytes memory _returnData, bytes4 _errorSignature) internal 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 {
revert(add(0x20, _returnData), mload(_returnData))
}
} else {
assembly {
mstore(0x00, _errorSignature)
revert(0x1c, 0x04)
}
}
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;
library Role {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* NAMED ROLE CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
uint256 internal constant _MINTER_ROLE = 1 << 0;
uint256 internal constant _MANAGER_ROLE = 1 << 1;
uint256 internal constant _INSTALLER_ROLE = 1 << 255;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ROLE CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
uint256 internal constant _ROLE_0 = 1 << 0;
uint256 internal constant _ROLE_1 = 1 << 1;
uint256 internal constant _ROLE_2 = 1 << 2;
uint256 internal constant _ROLE_3 = 1 << 3;
uint256 internal constant _ROLE_4 = 1 << 4;
uint256 internal constant _ROLE_5 = 1 << 5;
uint256 internal constant _ROLE_6 = 1 << 6;
uint256 internal constant _ROLE_7 = 1 << 7;
uint256 internal constant _ROLE_8 = 1 << 8;
uint256 internal constant _ROLE_9 = 1 << 9;
uint256 internal constant _ROLE_10 = 1 << 10;
uint256 internal constant _ROLE_11 = 1 << 11;
uint256 internal constant _ROLE_12 = 1 << 12;
uint256 internal constant _ROLE_13 = 1 << 13;
uint256 internal constant _ROLE_14 = 1 << 14;
uint256 internal constant _ROLE_15 = 1 << 15;
uint256 internal constant _ROLE_16 = 1 << 16;
uint256 internal constant _ROLE_17 = 1 << 17;
uint256 internal constant _ROLE_18 = 1 << 18;
uint256 internal constant _ROLE_19 = 1 << 19;
uint256 internal constant _ROLE_20 = 1 << 20;
uint256 internal constant _ROLE_21 = 1 << 21;
uint256 internal constant _ROLE_22 = 1 << 22;
uint256 internal constant _ROLE_23 = 1 << 23;
uint256 internal constant _ROLE_24 = 1 << 24;
uint256 internal constant _ROLE_25 = 1 << 25;
uint256 internal constant _ROLE_26 = 1 << 26;
uint256 internal constant _ROLE_27 = 1 << 27;
uint256 internal constant _ROLE_28 = 1 << 28;
uint256 internal constant _ROLE_29 = 1 << 29;
uint256 internal constant _ROLE_30 = 1 << 30;
uint256 internal constant _ROLE_31 = 1 << 31;
uint256 internal constant _ROLE_32 = 1 << 32;
uint256 internal constant _ROLE_33 = 1 << 33;
uint256 internal constant _ROLE_34 = 1 << 34;
uint256 internal constant _ROLE_35 = 1 << 35;
uint256 internal constant _ROLE_36 = 1 << 36;
uint256 internal constant _ROLE_37 = 1 << 37;
uint256 internal constant _ROLE_38 = 1 << 38;
uint256 internal constant _ROLE_39 = 1 << 39;
uint256 internal constant _ROLE_40 = 1 << 40;
uint256 internal constant _ROLE_41 = 1 << 41;
uint256 internal constant _ROLE_42 = 1 << 42;
uint256 internal constant _ROLE_43 = 1 << 43;
uint256 internal constant _ROLE_44 = 1 << 44;
uint256 internal constant _ROLE_45 = 1 << 45;
uint256 internal constant _ROLE_46 = 1 << 46;
uint256 internal constant _ROLE_47 = 1 << 47;
uint256 internal constant _ROLE_48 = 1 << 48;
uint256 internal constant _ROLE_49 = 1 << 49;
uint256 internal constant _ROLE_50 = 1 << 50;
uint256 internal constant _ROLE_51 = 1 << 51;
uint256 internal constant _ROLE_52 = 1 << 52;
uint256 internal constant _ROLE_53 = 1 << 53;
uint256 internal constant _ROLE_54 = 1 << 54;
uint256 internal constant _ROLE_55 = 1 << 55;
uint256 internal constant _ROLE_56 = 1 << 56;
uint256 internal constant _ROLE_57 = 1 << 57;
uint256 internal constant _ROLE_58 = 1 << 58;
uint256 internal constant _ROLE_59 = 1 << 59;
uint256 internal constant _ROLE_60 = 1 << 60;
uint256 internal constant _ROLE_61 = 1 << 61;
uint256 internal constant _ROLE_62 = 1 << 62;
uint256 internal constant _ROLE_63 = 1 << 63;
uint256 internal constant _ROLE_64 = 1 << 64;
uint256 internal constant _ROLE_65 = 1 << 65;
uint256 internal constant _ROLE_66 = 1 << 66;
uint256 internal constant _ROLE_67 = 1 << 67;
uint256 internal constant _ROLE_68 = 1 << 68;
uint256 internal constant _ROLE_69 = 1 << 69;
uint256 internal constant _ROLE_70 = 1 << 70;
uint256 internal constant _ROLE_71 = 1 << 71;
uint256 internal constant _ROLE_72 = 1 << 72;
uint256 internal constant _ROLE_73 = 1 << 73;
uint256 internal constant _ROLE_74 = 1 << 74;
uint256 internal constant _ROLE_75 = 1 << 75;
uint256 internal constant _ROLE_76 = 1 << 76;
uint256 internal constant _ROLE_77 = 1 << 77;
uint256 internal constant _ROLE_78 = 1 << 78;
uint256 internal constant _ROLE_79 = 1 << 79;
uint256 internal constant _ROLE_80 = 1 << 80;
uint256 internal constant _ROLE_81 = 1 << 81;
uint256 internal constant _ROLE_82 = 1 << 82;
uint256 internal constant _ROLE_83 = 1 << 83;
uint256 internal constant _ROLE_84 = 1 << 84;
uint256 internal constant _ROLE_85 = 1 << 85;
uint256 internal constant _ROLE_86 = 1 << 86;
uint256 internal constant _ROLE_87 = 1 << 87;
uint256 internal constant _ROLE_88 = 1 << 88;
uint256 internal constant _ROLE_89 = 1 << 89;
uint256 internal constant _ROLE_90 = 1 << 90;
uint256 internal constant _ROLE_91 = 1 << 91;
uint256 internal constant _ROLE_92 = 1 << 92;
uint256 internal constant _ROLE_93 = 1 << 93;
uint256 internal constant _ROLE_94 = 1 << 94;
uint256 internal constant _ROLE_95 = 1 << 95;
uint256 internal constant _ROLE_96 = 1 << 96;
uint256 internal constant _ROLE_97 = 1 << 97;
uint256 internal constant _ROLE_98 = 1 << 98;
uint256 internal constant _ROLE_99 = 1 << 99;
uint256 internal constant _ROLE_100 = 1 << 100;
uint256 internal constant _ROLE_101 = 1 << 101;
uint256 internal constant _ROLE_102 = 1 << 102;
uint256 internal constant _ROLE_103 = 1 << 103;
uint256 internal constant _ROLE_104 = 1 << 104;
uint256 internal constant _ROLE_105 = 1 << 105;
uint256 internal constant _ROLE_106 = 1 << 106;
uint256 internal constant _ROLE_107 = 1 << 107;
uint256 internal constant _ROLE_108 = 1 << 108;
uint256 internal constant _ROLE_109 = 1 << 109;
uint256 internal constant _ROLE_110 = 1 << 110;
uint256 internal constant _ROLE_111 = 1 << 111;
uint256 internal constant _ROLE_112 = 1 << 112;
uint256 internal constant _ROLE_113 = 1 << 113;
uint256 internal constant _ROLE_114 = 1 << 114;
uint256 internal constant _ROLE_115 = 1 << 115;
uint256 internal constant _ROLE_116 = 1 << 116;
uint256 internal constant _ROLE_117 = 1 << 117;
uint256 internal constant _ROLE_118 = 1 << 118;
uint256 internal constant _ROLE_119 = 1 << 119;
uint256 internal constant _ROLE_120 = 1 << 120;
uint256 internal constant _ROLE_121 = 1 << 121;
uint256 internal constant _ROLE_122 = 1 << 122;
uint256 internal constant _ROLE_123 = 1 << 123;
uint256 internal constant _ROLE_124 = 1 << 124;
uint256 internal constant _ROLE_125 = 1 << 125;
uint256 internal constant _ROLE_126 = 1 << 126;
uint256 internal constant _ROLE_127 = 1 << 127;
uint256 internal constant _ROLE_128 = 1 << 128;
uint256 internal constant _ROLE_129 = 1 << 129;
uint256 internal constant _ROLE_130 = 1 << 130;
uint256 internal constant _ROLE_131 = 1 << 131;
uint256 internal constant _ROLE_132 = 1 << 132;
uint256 internal constant _ROLE_133 = 1 << 133;
uint256 internal constant _ROLE_134 = 1 << 134;
uint256 internal constant _ROLE_135 = 1 << 135;
uint256 internal constant _ROLE_136 = 1 << 136;
uint256 internal constant _ROLE_137 = 1 << 137;
uint256 internal constant _ROLE_138 = 1 << 138;
uint256 internal constant _ROLE_139 = 1 << 139;
uint256 internal constant _ROLE_140 = 1 << 140;
uint256 internal constant _ROLE_141 = 1 << 141;
uint256 internal constant _ROLE_142 = 1 << 142;
uint256 internal constant _ROLE_143 = 1 << 143;
uint256 internal constant _ROLE_144 = 1 << 144;
uint256 internal constant _ROLE_145 = 1 << 145;
uint256 internal constant _ROLE_146 = 1 << 146;
uint256 internal constant _ROLE_147 = 1 << 147;
uint256 internal constant _ROLE_148 = 1 << 148;
uint256 internal constant _ROLE_149 = 1 << 149;
uint256 internal constant _ROLE_150 = 1 << 150;
uint256 internal constant _ROLE_151 = 1 << 151;
uint256 internal constant _ROLE_152 = 1 << 152;
uint256 internal constant _ROLE_153 = 1 << 153;
uint256 internal constant _ROLE_154 = 1 << 154;
uint256 internal constant _ROLE_155 = 1 << 155;
uint256 internal constant _ROLE_156 = 1 << 156;
uint256 internal constant _ROLE_157 = 1 << 157;
uint256 internal constant _ROLE_158 = 1 << 158;
uint256 internal constant _ROLE_159 = 1 << 159;
uint256 internal constant _ROLE_160 = 1 << 160;
uint256 internal constant _ROLE_161 = 1 << 161;
uint256 internal constant _ROLE_162 = 1 << 162;
uint256 internal constant _ROLE_163 = 1 << 163;
uint256 internal constant _ROLE_164 = 1 << 164;
uint256 internal constant _ROLE_165 = 1 << 165;
uint256 internal constant _ROLE_166 = 1 << 166;
uint256 internal constant _ROLE_167 = 1 << 167;
uint256 internal constant _ROLE_168 = 1 << 168;
uint256 internal constant _ROLE_169 = 1 << 169;
uint256 internal constant _ROLE_170 = 1 << 170;
uint256 internal constant _ROLE_171 = 1 << 171;
uint256 internal constant _ROLE_172 = 1 << 172;
uint256 internal constant _ROLE_173 = 1 << 173;
uint256 internal constant _ROLE_174 = 1 << 174;
uint256 internal constant _ROLE_175 = 1 << 175;
uint256 internal constant _ROLE_176 = 1 << 176;
uint256 internal constant _ROLE_177 = 1 << 177;
uint256 internal constant _ROLE_178 = 1 << 178;
uint256 internal constant _ROLE_179 = 1 << 179;
uint256 internal constant _ROLE_180 = 1 << 180;
uint256 internal constant _ROLE_181 = 1 << 181;
uint256 internal constant _ROLE_182 = 1 << 182;
uint256 internal constant _ROLE_183 = 1 << 183;
uint256 internal constant _ROLE_184 = 1 << 184;
uint256 internal constant _ROLE_185 = 1 << 185;
uint256 internal constant _ROLE_186 = 1 << 186;
uint256 internal constant _ROLE_187 = 1 << 187;
uint256 internal constant _ROLE_188 = 1 << 188;
uint256 internal constant _ROLE_189 = 1 << 189;
uint256 internal constant _ROLE_190 = 1 << 190;
uint256 internal constant _ROLE_191 = 1 << 191;
uint256 internal constant _ROLE_192 = 1 << 192;
uint256 internal constant _ROLE_193 = 1 << 193;
uint256 internal constant _ROLE_194 = 1 << 194;
uint256 internal constant _ROLE_195 = 1 << 195;
uint256 internal constant _ROLE_196 = 1 << 196;
uint256 internal constant _ROLE_197 = 1 << 197;
uint256 internal constant _ROLE_198 = 1 << 198;
uint256 internal constant _ROLE_199 = 1 << 199;
uint256 internal constant _ROLE_200 = 1 << 200;
uint256 internal constant _ROLE_201 = 1 << 201;
uint256 internal constant _ROLE_202 = 1 << 202;
uint256 internal constant _ROLE_203 = 1 << 203;
uint256 internal constant _ROLE_204 = 1 << 204;
uint256 internal constant _ROLE_205 = 1 << 205;
uint256 internal constant _ROLE_206 = 1 << 206;
uint256 internal constant _ROLE_207 = 1 << 207;
uint256 internal constant _ROLE_208 = 1 << 208;
uint256 internal constant _ROLE_209 = 1 << 209;
uint256 internal constant _ROLE_210 = 1 << 210;
uint256 internal constant _ROLE_211 = 1 << 211;
uint256 internal constant _ROLE_212 = 1 << 212;
uint256 internal constant _ROLE_213 = 1 << 213;
uint256 internal constant _ROLE_214 = 1 << 214;
uint256 internal constant _ROLE_215 = 1 << 215;
uint256 internal constant _ROLE_216 = 1 << 216;
uint256 internal constant _ROLE_217 = 1 << 217;
uint256 internal constant _ROLE_218 = 1 << 218;
uint256 internal constant _ROLE_219 = 1 << 219;
uint256 internal constant _ROLE_220 = 1 << 220;
uint256 internal constant _ROLE_221 = 1 << 221;
uint256 internal constant _ROLE_222 = 1 << 222;
uint256 internal constant _ROLE_223 = 1 << 223;
uint256 internal constant _ROLE_224 = 1 << 224;
uint256 internal constant _ROLE_225 = 1 << 225;
uint256 internal constant _ROLE_226 = 1 << 226;
uint256 internal constant _ROLE_227 = 1 << 227;
uint256 internal constant _ROLE_228 = 1 << 228;
uint256 internal constant _ROLE_229 = 1 << 229;
uint256 internal constant _ROLE_230 = 1 << 230;
uint256 internal constant _ROLE_231 = 1 << 231;
uint256 internal constant _ROLE_232 = 1 << 232;
uint256 internal constant _ROLE_233 = 1 << 233;
uint256 internal constant _ROLE_234 = 1 << 234;
uint256 internal constant _ROLE_235 = 1 << 235;
uint256 internal constant _ROLE_236 = 1 << 236;
uint256 internal constant _ROLE_237 = 1 << 237;
uint256 internal constant _ROLE_238 = 1 << 238;
uint256 internal constant _ROLE_239 = 1 << 239;
uint256 internal constant _ROLE_240 = 1 << 240;
uint256 internal constant _ROLE_241 = 1 << 241;
uint256 internal constant _ROLE_242 = 1 << 242;
uint256 internal constant _ROLE_243 = 1 << 243;
uint256 internal constant _ROLE_244 = 1 << 244;
uint256 internal constant _ROLE_245 = 1 << 245;
uint256 internal constant _ROLE_246 = 1 << 246;
uint256 internal constant _ROLE_247 = 1 << 247;
uint256 internal constant _ROLE_248 = 1 << 248;
uint256 internal constant _ROLE_249 = 1 << 249;
uint256 internal constant _ROLE_250 = 1 << 250;
uint256 internal constant _ROLE_251 = 1 << 251;
uint256 internal constant _ROLE_252 = 1 << 252;
uint256 internal constant _ROLE_253 = 1 << 253;
uint256 internal constant _ROLE_254 = 1 << 254;
uint256 internal constant _ROLE_255 = 1 << 255;
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;
interface IERC165 {
/// @notice Query if a contract implements an interface
/// @param interfaceID The interface identifier, as specified in ERC-165
/// @dev Interface identification is specified in ERC-165. This function
/// uses less than 30,000 gas.
/// @return `true` if the contract implements `interfaceID` and
/// `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;
interface IInstallationCallback {
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @dev Called by a Core into an Module during the installation of the Module.
*
* @param data The data passed to the Core's installModule function.
*/
function onInstall(bytes calldata data) external;
/**
* @dev Called by a Core into an Module during the uninstallation of the Module.
*
* @param data The data passed to the Core's uninstallModule function.
*/
function onUninstall(bytes calldata data) external;
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
import {IModuleConfig} from "./IModuleConfig.sol";
interface IModularCore is IModuleConfig, IERC165 {
/*//////////////////////////////////////////////////////////////
STRUCTS & ENUMS
//////////////////////////////////////////////////////////////*/
/**
* @dev Whether execution reverts when the callback function is not implemented by any installed Module.
* @param OPTIONAL Execution does not revert when the callback function is not implemented.
* @param REQUIRED Execution reverts when the callback function is not implemented.
*/
enum CallbackMode {
OPTIONAL,
REQUIRED
}
/**
* @dev Struct representing a callback function called on an Module during some fixed function's execution.
* @param selector The 4-byte function selector of the callback function.
* @param mode Whether execution reverts when the callback function is not implemented by any installed Module.
*/
struct SupportedCallbackFunction {
bytes4 selector;
CallbackMode mode;
}
/**
* @dev Struct representing an installed Module.
* @param implementation The address of the Module contract.
* @param config The Module Config of the Module contract.
*/
struct InstalledModule {
address implementation;
ModuleConfig config;
}
/*//////////////////////////////////////////////////////////////
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @dev Returns all callback function calls made to Modules at some point during a fixed function's execution.
function getSupportedCallbackFunctions() external pure returns (SupportedCallbackFunction[] memory);
/// @dev Returns all installed modules and their respective module configs.
function getInstalledModules() external view returns (InstalledModule[] memory);
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @dev Installs an Module in the Core.
*
* @param moduleContract The address of the Module contract to be installed.
* @param data The data to be passed to the Module's onInstall callback function.
*
* MUST implement authorization control.
* MUST call `onInstall` callback function if Module Config has registerd for installation callbacks.
* MUST revert if Core does not implement the interface required by the Module, specified in the Module Config.
* MUST revert if any callback or fallback function in the Module's ModuleConfig is already registered in the Core with another Module.
*
* MAY interpret the provided address as the implementation address of the Module contract to install as a proxy.
*/
function installModule(address moduleContract, bytes calldata data) external payable;
/**
* @dev Uninstalls an Module from the Core.
*
* @param moduleContract The address of the Module contract to be uninstalled.
* @param data The data to be passed to the Module's onUninstall callback function.
*
* MUST implement authorization control.
* MUST call `onUninstall` callback function if Module Config has registerd for installation callbacks.
*
* MAY interpret the provided address as the implementation address of the Module contract which is installed as a proxy.
*/
function uninstallModule(address moduleContract, bytes calldata data) external payable;
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;
import {IModuleConfig} from "./IModuleConfig.sol";
interface IModularModule is IModuleConfig {
/*//////////////////////////////////////////////////////////////
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @dev Returns the ModuleConfig of the Module contract.
*/
function getModuleConfig() external pure returns (ModuleConfig memory);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;
interface IModuleConfig {
/*//////////////////////////////////////////////////////////////
STRUCTS & ENUMS
//////////////////////////////////////////////////////////////*/
/**
* @dev Struct for a callback function. Called by a Core into an Module during the execution of some fixed function.
*
* @param selector The 4-byte selector of the function.
* @param callType The type of call to be made to the function.
*/
struct CallbackFunction {
bytes4 selector;
}
/**
* @dev Struct for a fallback function. Called by a Core into an Module via the Core's fallback.
*
* @param selector The 4-byte selector of the function.
* @param callType The type of call to be made to the function.
* @param permissionBits Core’s fallback function MUST check that msg.sender has these permissions before
* performing a call on the Module. (OPTIONAL field)
*/
struct FallbackFunction {
bytes4 selector;
uint256 permissionBits;
}
/**
* @dev Struct containing all information that a Core uses to check whether an Module is compatible for installation.
*
* @param registerInstallationCallback Whether the Module expects onInstall and onUninstall callback function calls at
* installation and uninstallation time, respectively
* @param requiredInterfaces The ERC-165 interface that a Core MUST support to be compatible for installation. OPTIONAL -- can be bytes4(0)
* if there is no required interface id.
* @param supportedInterfaces The ERC-165 interfaces that a Core supports upon installing the Module.
* @param callbackFunctions List of callback functions that the Core MUST call at some point in the execution of its fixed functions.
* @param fallbackFunctions List of functions that the Core MUST call via its fallback function with the Module as the call destination.
*/
struct ModuleConfig {
bool registerInstallationCallback;
bytes4[] requiredInterfaces;
bytes4[] supportedInterfaces;
CallbackFunction[] callbackFunctions;
FallbackFunction[] fallbackFunctions;
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "london",
"remappings": [
":@ds-test/=lib/ds-test/src/",
":@erc721a-upgradeable/=lib/modular-contracts/lib/ERC721A-Upgradeable/contracts/",
":@erc721a/=lib/modular-contracts/lib/erc721a/contracts/",
":@solady/=lib/modular-contracts/lib/solady/src/",
":@std/=lib/forge-std/src/",
":ERC721A-Upgradeable/=lib/modular-contracts/lib/ERC721A-Upgradeable/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc721a/=lib/modular-contracts/lib/erc721a/contracts/",
":forge-std/=lib/forge-std/src/",
":modular-contracts/=lib/modular-contracts/",
":solady/=lib/solady/src/"
],
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract ABI
API[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address[]","name":"_modules","type":"address[]"},{"internalType":"bytes[]","name":"_moduleInstallData","type":"bytes[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"CallbackExecutionReverted","type":"error"},{"inputs":[],"name":"CallbackFunctionAlreadyInstalled","type":"error"},{"inputs":[],"name":"CallbackFunctionNotSupported","type":"error"},{"inputs":[],"name":"CallbackFunctionRequired","type":"error"},{"inputs":[],"name":"CallbackFunctionUnauthorizedCall","type":"error"},{"inputs":[],"name":"FallbackFunctionAlreadyInstalled","type":"error"},{"inputs":[],"name":"FallbackFunctionNotInstalled","type":"error"},{"inputs":[],"name":"IndexOutOfBounds","type":"error"},{"inputs":[],"name":"ModuleAlreadyInstalled","type":"error"},{"inputs":[{"internalType":"bytes4","name":"requiredInterfaceId","type":"bytes4"}],"name":"ModuleInterfaceNotCompatible","type":"error"},{"inputs":[],"name":"ModuleNotInstalled","type":"error"},{"inputs":[],"name":"ModuleOutOfSync","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[],"name":"Reentrancy","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"implementation","type":"address"},{"indexed":false,"internalType":"address","name":"installedModule","type":"address"}],"name":"ModuleInstalled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"implementation","type":"address"},{"indexed":false,"internalType":"address","name":"installedModule","type":"address"}],"name":"ModuleUninstalled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"roles","type":"uint256"}],"name":"RolesUpdated","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getInstalledModules","outputs":[{"components":[{"internalType":"address","name":"implementation","type":"address"},{"components":[{"internalType":"bool","name":"registerInstallationCallback","type":"bool"},{"internalType":"bytes4[]","name":"requiredInterfaces","type":"bytes4[]"},{"internalType":"bytes4[]","name":"supportedInterfaces","type":"bytes4[]"},{"components":[{"internalType":"bytes4","name":"selector","type":"bytes4"}],"internalType":"struct IModuleConfig.CallbackFunction[]","name":"callbackFunctions","type":"tuple[]"},{"components":[{"internalType":"bytes4","name":"selector","type":"bytes4"},{"internalType":"uint256","name":"permissionBits","type":"uint256"}],"internalType":"struct IModuleConfig.FallbackFunction[]","name":"fallbackFunctions","type":"tuple[]"}],"internalType":"struct IModuleConfig.ModuleConfig","name":"config","type":"tuple"}],"internalType":"struct IModularCore.InstalledModule[]","name":"_installedModules","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedCallbackFunctions","outputs":[{"components":[{"internalType":"bytes4","name":"selector","type":"bytes4"},{"internalType":"enum IModularCore.CallbackMode","name":"mode","type":"uint8"}],"internalType":"struct IModularCore.SupportedCallbackFunction[]","name":"supportedCallbackFunctions","type":"tuple[]"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"grantRoles","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"hasAllRoles","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"hasAnyRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_module","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"installModule","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"ownershipHandoverExpiresAt","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"renounceRoles","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"revokeRoles","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"rolesOf","outputs":[{"internalType":"uint256","name":"roles","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_module","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"uninstallModule","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
0x60806040523480156200001157600080fd5b5060405162002baa38038062002baa833981016040819052620000349162000a7e565b6200003f83620000b8565b80518251146200004e57600080fd5b60005b8251811015620000ae57620000a583828151811062000074576200007462000b62565b602002602001015183838151811062000091576200009162000b62565b6020026020010151620000f460201b60201c565b60010162000051565b5050505062000ee1565b6001600160a01b0316638b78c6d8198190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b62000101600083620006b9565b6200011f57604051631261bbf160e11b815260040160405180910390fd5b6000826001600160a01b03166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa15801562000160573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526200018a919081019062000d54565b9050806020015151600014620002415760005b8160200151518110156200023f57620001dc82602001518281518110620001c857620001c862000b62565b60200260200101516200081a60201b60201c565b620002365781602001518181518110620001fa57620001fa62000b62565b60200260200101516040516356ba3a7f60e01b81526004016200022d91906001600160e01b031991909116815260200190565b60405180910390fd5b6001016200019d565b505b60408101515160005b81811015620002ba5760018060008560400151848151811062000271576200027162000b62565b60200260200101516001600160e01b0319166001600160e01b03191681526020019081526020016000206000828254620002ac919062000e50565b90915550506001016200024a565b5060608051838201515160005b818110156200047a57600086606001518281518110620002eb57620002eb62000b62565b60209081029190910181015180516001600160e01b031916600090815260029092526040909120549091506001600160a01b0316156200033e57604051634cc04b1760e01b815260040160405180910390fd5b6000805b858110156200039e5782600001516001600160e01b0319168782815181106200036f576200036f62000b62565b6020026020010151600001516001600160e01b031916036200039557600191506200039e565b60010162000342565b5080620003be5760405163573ffc1f60e11b815260040160405180910390fd5b60405180606001604052808b6001600160a01b031681526020016000815260200160006001811115620003f557620003f562000e78565b905282516001600160e01b031916600090815260026020818152604092839020845181546001600160a01b0319166001600160a01b03909116178155908401516001808301919091559284015191810180549193909160ff191690838181111562000464576200046462000e78565b02179055505060019093019250620002c7915050565b5060808501515160005b81811015620005a457600087608001518281518110620004a857620004a862000b62565b60209081029190910181015180516001600160e01b031916600090815260029092526040909120549091506001600160a01b031615620004fb576040516392bffc6560e01b815260040160405180910390fd5b604080516060810182526001600160a01b038c168152602083810151908201529081016001905281516001600160e01b031916600090815260026020818152604092839020845181546001600160a01b0319166001600160a01b03909116178155908401516001808301919091559284015191810180549193909160ff19169083818111156200058f576200058f62000e78565b02179055505060019092019150620004849050565b508551156200066757600080896001600160a01b031689604051602401620005cd919062000e8e565b60408051601f198184030181529181526020820180516001600160e01b03166306d61fe760e41b1790525162000604919062000ec3565b600060405180830381855af49150503d806000811462000641576040519150601f19603f3d011682016040523d82523d6000602084013e62000646565b606091505b50915091508162000664576200066481633fcb904560e01b62000867565b50505b604080513381526001600160a01b038a16602082018190528183015290517fbcd03fe408dcc45614e803cbab9f500dddff61b17380b993e76d30398da472299181900360600190a15050505050505050565b63978aab926004526000828152602481206001600160a01b03929092169168fbb67fda52d4bfb8be198301620006f75763f5a267f16000526004601cfd5b826200070a5768fbb67fda52d4bfb8bf92505b80546001600160601b0381168260205280620007da578160601c806200073b578560601b8455600194505062000811565b8581036200074a575062000811565b600184015460601c806200076d578660601b600186015560019550505062000811565b8681036200077d57505062000811565b600285015460601c80620007a1578760601b60028701556001965050505062000811565b878103620007b25750505062000811565b6000928352604080842060019055918352818320600290558252902060039055506007908117905b84600052604060002080546200080f578160011c91508560601b82850155816001018155826002018455600194505062000811565b505b50505092915050565b60006001600160e01b031980831690036200083757506000919050565b6001600160e01b03198216600090815260016020526040902054156200085f57506001919050565b506000919050565b8151156200087757815182602001fd5b806000526004601cfd5b80516001600160a01b03811681146200089957600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b0381118282101715620008d957620008d96200089e565b60405290565b60405160a081016001600160401b0381118282101715620008d957620008d96200089e565b604051601f8201601f191681016001600160401b03811182821017156200092f576200092f6200089e565b604052919050565b60006001600160401b038211156200095357620009536200089e565b5060051b60200190565b60005b838110156200097a57818101518382015260200162000960565b50506000910152565b6000601f83601f8401126200099757600080fd5b82516020620009b0620009aa8362000937565b62000904565b82815260059290921b85018101918181019087841115620009d057600080fd5b8287015b8481101562000a725780516001600160401b0380821115620009f65760008081fd5b818a0191508a603f83011262000a0c5760008081fd5b8582015160408282111562000a255762000a256200089e565b62000a38828b01601f1916890162000904565b92508183528c8183860101111562000a505760008081fd5b62000a61828985018387016200095d565b5050845250918301918301620009d4565b50979650505050505050565b60008060006060848603121562000a9457600080fd5b62000a9f8462000881565b602085810151919450906001600160401b038082111562000abf57600080fd5b818701915087601f83011262000ad457600080fd5b815162000ae5620009aa8262000937565b81815260059190911b8301840190848101908a83111562000b0557600080fd5b938501935b8285101562000b2e5762000b1e8562000881565b8252938501939085019062000b0a565b60408a0151909750945050508083111562000b4857600080fd5b505062000b588682870162000983565b9150509250925092565b634e487b7160e01b600052603260045260246000fd5b805180151581146200089957600080fd5b80516001600160e01b0319811681146200089957600080fd5b600082601f83011262000bb457600080fd5b8151602062000bc7620009aa8362000937565b8083825260208201915060208460051b87010193508684111562000bea57600080fd5b602086015b8481101562000c115762000c038162000b89565b835291830191830162000bef565b509695505050505050565b600082601f83011262000c2e57600080fd5b8151602062000c41620009aa8362000937565b82815260059290921b8401810191818101908684111562000c6157600080fd5b8286015b8481101562000c115783818903121562000c7f5760008081fd5b604080518581016001600160401b038111828210171562000ca45762000ca46200089e565b825262000cb18362000b89565b815284525091830191830162000c65565b600082601f83011262000cd457600080fd5b8151602062000ce7620009aa8362000937565b82815260069290921b8401810191818101908684111562000d0757600080fd5b8286015b8481101562000c11576040818903121562000d265760008081fd5b62000d30620008b4565b62000d3b8262000b89565b8152818501518582015283529183019160400162000d0b565b60006020828403121562000d6757600080fd5b81516001600160401b038082111562000d7f57600080fd5b9083019060a0828603121562000d9457600080fd5b62000d9e620008df565b62000da98362000b78565b815260208301518281111562000dbe57600080fd5b62000dcc8782860162000ba2565b60208301525060408301518281111562000de557600080fd5b62000df38782860162000ba2565b60408301525060608301518281111562000e0c57600080fd5b62000e1a8782860162000c1c565b60608301525060808301518281111562000e3357600080fd5b62000e418782860162000cc2565b60808301525095945050505050565b8082018082111562000e7257634e487b7160e01b600052601160045260246000fd5b92915050565b634e487b7160e01b600052602160045260246000fd5b602081526000825180602084015262000eaf8160408501602087016200095d565b601f01601f19169190910160400192915050565b6000825162000ed78184602087016200095d565b9190910192915050565b611cb98062000ef16000396000f3fe6080604052600436106101095760003560e01c806354d1f13d116100955780638da798da116100645780638da798da146103ae578063f04e283e146103c1578063f147db8a146103d4578063f2fde38b146103f0578063fee81cf41461040357610109565b806354d1f13d1461035f57806370c109cd14610367578063715018a61461037a5780638da5cb5b1461038257610109565b806325692962116100dc57806325692962146102aa5780632de94807146102b25780633e429396146102f35780634a4ee7b114610315578063514e62fc1461032857610109565b806301ffc9a71461022f578063183a4f6e146102645780631c10893f146102775780631cd64df41461028a575b600080356001600160e01b0319168152600260208181526040808420815160608101835281546001600160a01b03168152600180830154948201949094529381015490929184019160ff90911690811115610166576101666114fc565b6001811115610177576101776114fc565b90525080519091506001600160a01b03166101a55760405163b6b8317760e01b815260040160405180910390fd5b6000816040015160018111156101bd576101bd6114fc565b036101e7573330146101e25760405163052bb9ef60e31b815260040160405180910390fd5b610222565b6001816040015160018111156101ff576101ff6114fc565b148015610210575060008160200151115b15610222576102228160200151610436565b805161022d9061046c565b005b34801561023b57600080fd5b5061024f61024a366004611528565b6104a7565b60405190151581526020015b60405180910390f35b61022d61027236600461154c565b6104f2565b61022d610285366004611581565b6104fc565b34801561029657600080fd5b5061024f6102a5366004611581565b610512565b61022d610531565b3480156102be57600080fd5b506102e56102cd3660046115ab565b638b78c6d8600c908152600091909152602090205490565b60405190815260200161025b565b3480156102ff57600080fd5b50610308610581565b60405161025b9190611652565b61022d610323366004611581565b6106ad565b34801561033457600080fd5b5061024f610343366004611581565b638b78c6d8600c90815260009290925260209091205416151590565b61022d6106bf565b61022d610375366004611775565b6106fb565b61022d61074f565b34801561038e57600080fd5b50638b78c6d819546040516001600160a01b03909116815260200161025b565b61022d6103bc366004611775565b610763565b61022d6103cf3660046115ab565b6107b1565b3480156103e057600080fd5b50606060405161025b91906117f8565b61022d6103fe3660046115ab565b6107ee565b34801561040f57600080fd5b506102e561041e3660046115ab565b63389a75e1600c908152600091909152602090205490565b638b78c6d81954331461046957638b78c6d8600c5233600052806020600c205416610469576382b429006000526004601cfd5b50565b6040805136810190915236600082376000803683855af490506104953d60408051918201905290565b3d6000823e816104a3573d81fd5b3d81f35b60006001600160e01b031980831690036104c357506000919050565b6001600160e01b03198216600090815260016020526040902054156104ea57506001919050565b506000919050565b6104693382610815565b610504610821565b61050e828261083c565b5050565b638b78c6d8600c90815260008390526020902054811681145b92915050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b6060600061058f6000610848565b90508067ffffffffffffffff8111156105aa576105aa61186f565b6040519080825280602002602001820160405280156105e357816020015b6105d06114a8565b8152602001906001900390816105c85790505b50915060005b818110156106a85760006105fd818361089a565b90506040518060400160405280826001600160a01b03168152602001826001600160a01b03166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610657573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261067f9190810190611ad4565b81525084838151811061069457610694611bbe565b6020908102919091010152506001016105e9565b505090565b6106b5610821565b61050e8282610815565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b600160ff1b61070981610436565b6107498484848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506108f492505050565b50505050565b610757610821565b6107616000610bdb565b565b600160ff1b61077181610436565b6107498484848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610c1992505050565b6107b9610821565b63389a75e1600c52806000526020600c2080544211156107e157636f5e88186000526004601cfd5b6000905561046981610bdb565b6107f6610821565b8060601b61080c57637448fbae6000526004601cfd5b61046981610bdb565b61050e82826000611197565b638b78c6d819543314610761576382b429006000526004601cfd5b61050e82826001611197565b63978aab9260045260008181526024812080548060a01b60a01c8060011c9350808260601c1517610892576001935083830154156108925760029350838301541561089257600393505b505050919050565b63978aab926004526000828152602481208281015460601c915068fbb67fda52d4bfb8bf821415820291506108ce84610848565b83106108ed57604051634e23d03560e01b815260040160405180910390fd5b5092915050565b6108ff6000836111f0565b61091c57604051632a6f792960e01b815260040160405180910390fd5b6000826001600160a01b03166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561095c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109849190810190611ad4565b60408101515190915060005b818110156109f9576001806000856040015184815181106109b3576109b3611bbe565b60200260200101516001600160e01b0319166001600160e01b031916815260200190815260200160002060008282546109ec9190611bea565b9091555050600101610990565b5060808201515160005b81811015610a74576002600085608001518381518110610a2557610a25611bbe565b602090810291909101810151516001600160e01b0319168252810191909152604001600090812080546001600160a01b0319168155600180820192909255600201805460ff1916905501610a03565b5060608301515160005b81811015610aef576002600086606001518381518110610aa057610aa0611bbe565b602090810291909101810151516001600160e01b0319168252810191909152604001600090812080546001600160a01b0319168155600180820192909255600201805460ff1916905501610a7e565b50835115610b8b57856001600160a01b031685604051602401610b129190611c21565b60408051601f198184030181529181526020820180516001600160e01b0316638a91b0e360e01b17905251610b479190611c54565b600060405180830381855af49150503d8060008114610b82576040519150601f19603f3d011682016040523d82523d6000602084013e610b87565b606091505b5050505b604080513381526001600160a01b038816602082018190528183015290517fef3b2e20acbb62d61d782c5449bd73d3970cb9be1050a6ad6f846b2cbe21c03a9181900360600190a1505050505050565b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b610c2460008361133b565b610c4157604051631261bbf160e11b815260040160405180910390fd5b6000826001600160a01b03166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610c81573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ca99190810190611ad4565b9050806020015151600014610d4d5760005b816020015151811015610d4b57610cee82602001518281518110610ce157610ce1611bbe565b60200260200101516104a7565b610d435781602001518181518110610d0857610d08611bbe565b60200260200101516040516356ba3a7f60e01b8152600401610d3a91906001600160e01b031991909116815260200190565b60405180910390fd5b600101610cbb565b505b60408101515160005b81811015610dbf57600180600085604001518481518110610d7957610d79611bbe565b60200260200101516001600160e01b0319166001600160e01b03191681526020019081526020016000206000828254610db29190611c70565b9091555050600101610d56565b5060608051838201515160005b81811015610f6b57600086606001518281518110610dec57610dec611bbe565b60209081029190910181015180516001600160e01b031916600090815260029092526040909120549091506001600160a01b031615610e3e57604051634cc04b1760e01b815260040160405180910390fd5b6000805b85811015610e975782600001516001600160e01b031916878281518110610e6b57610e6b611bbe565b6020026020010151600001516001600160e01b03191603610e8f5760019150610e97565b600101610e42565b5080610eb65760405163573ffc1f60e11b815260040160405180910390fd5b60405180606001604052808b6001600160a01b031681526020016000815260200160006001811115610eea57610eea6114fc565b905282516001600160e01b031916600090815260026020818152604092839020845181546001600160a01b0319166001600160a01b03909116178155908401516001808301919091559284015191810180549193909160ff1916908381811115610f5657610f566114fc565b02179055505060019093019250610dcc915050565b5060808501515160005b8181101561108c57600087608001518281518110610f9557610f95611bbe565b60209081029190910181015180516001600160e01b031916600090815260029092526040909120549091506001600160a01b031615610fe7576040516392bffc6560e01b815260040160405180910390fd5b604080516060810182526001600160a01b038c168152602083810151908201529081016001905281516001600160e01b031916600090815260026020818152604092839020845181546001600160a01b0319166001600160a01b03909116178155908401516001808301919091559284015191810180549193909160ff1916908381811115611078576110786114fc565b02179055505060019092019150610f759050565b5085511561114557600080896001600160a01b0316896040516024016110b29190611c21565b60408051601f198184030181529181526020820180516001600160e01b03166306d61fe760e41b179052516110e79190611c54565b600060405180830381855af49150503d8060008114611122576040519150601f19603f3d011682016040523d82523d6000602084013e611127565b606091505b5091509150816111425761114281633fcb904560e01b61148f565b50505b604080513381526001600160a01b038a16602082018190528183015290517fbcd03fe408dcc45614e803cbab9f500dddff61b17380b993e76d30398da472299181900360600190a15050505050505050565b638b78c6d8600c52826000526020600c208054838117836111b9575080841681185b80835580600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26600080a3505050505050565b63978aab926004526000828152602481206001600160a01b03929092169168fbb67fda52d4bfb8be19830161122d5763f5a267f16000526004601cfd5b8261123f5768fbb67fda52d4bfb8bf92505b80546bffffffffffffffffffffffff8116806112c25760019350848260601c0361127d57600183018054845560028401805490915560009055611332565b84600184015460601c0361129f57600283018054600185015560009055611332565b84600284015460601c036112b95760006002840155611332565b60009350611332565b826020528460005260406000208054806112dd575050611332565b60018360011c039250826001820314611315578285015460601c8060601b600183038701556000848701558060005250806040600020555b5060018260011b17845460601c60601b1784556000815550600193505b50505092915050565b63978aab926004526000828152602481206001600160a01b03929092169168fbb67fda52d4bfb8be1983016113785763f5a267f16000526004601cfd5b8261138a5768fbb67fda52d4bfb8bf92505b80546bffffffffffffffffffffffff81168260205280611452578160601c806113bd578560601b84556001945050611332565b8581036113ca5750611332565b600184015460601c806113eb578660601b6001860155600195505050611332565b8681036113f9575050611332565b600285015460601c8061141b578760601b600287015560019650505050611332565b87810361142a57505050611332565b6000928352604080842060019055918352818320600290558252902060039055506007908117905b8460005260406000208054611485578160011c91508560601b828501558160010181558260020184556001945050611332565b5050505092915050565b81511561149e57815182602001fd5b806000526004601cfd5b604051806040016040528060006001600160a01b031681526020016114f76040518060a00160405280600015158152602001606081526020016060815260200160608152602001606081525090565b905290565b634e487b7160e01b600052602160045260246000fd5b6001600160e01b03198116811461046957600080fd5b60006020828403121561153a57600080fd5b813561154581611512565b9392505050565b60006020828403121561155e57600080fd5b5035919050565b80356001600160a01b038116811461157c57600080fd5b919050565b6000806040838503121561159457600080fd5b61159d83611565565b946020939093013593505050565b6000602082840312156115bd57600080fd5b61154582611565565b60008151808452602080850194506020840160005b838110156116015781516001600160e01b031916875295820195908201906001016115db565b509495945050505050565b60008151808452602080850194506020840160005b8381101561160157815180516001600160e01b03191688528301518388015260409096019590820190600101611621565b600060208083018184528085518083526040925060408601915060408160051b8701018488016000805b8481101561176657603f198a850381018752835180516001600160a01b031686528901518986018990528051151589870152808a015160a060608089018290526116c960e08a01846115c6565b92508b8401516080868b860301818c01526116e485836115c6565b928601518b84038801948c01949094528351808452938f019450918e019288929091505b81831015611733578451516001600160e01b0319168452938e0193928e019260019290920191611708565b808601519550505050838882030160c0890152611750818461160c565b998c01999750505093890193505060010161167c565b50919998505050505050505050565b60008060006040848603121561178a57600080fd5b61179384611565565b9250602084013567ffffffffffffffff808211156117b057600080fd5b818601915086601f8301126117c457600080fd5b8135818111156117d357600080fd5b8760208285010111156117e557600080fd5b6020830194508093505050509250925092565b60208082528251828201819052600091906040908185019086840185805b8381101561186157825180516001600160e01b03191686528701516002811061184d57634e487b7160e01b83526021600452602483fd5b858801529385019391860191600101611816565b509298975050505050505050565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156118a8576118a861186f565b60405290565b60405160a0810167ffffffffffffffff811182821017156118a8576118a861186f565b604051601f8201601f1916810167ffffffffffffffff811182821017156118fa576118fa61186f565b604052919050565b8051801515811461157c57600080fd5b600067ffffffffffffffff82111561192c5761192c61186f565b5060051b60200190565b600082601f83011261194757600080fd5b8151602061195c61195783611912565b6118d1565b8083825260208201915060208460051b87010193508684111561197e57600080fd5b602086015b848110156119a357805161199681611512565b8352918301918301611983565b509695505050505050565b600082601f8301126119bf57600080fd5b815160206119cf61195783611912565b82815260059290921b840181019181810190868411156119ee57600080fd5b8286015b848110156119a357838189031215611a0a5760008081fd5b6040805185810181811067ffffffffffffffff82111715611a2d57611a2d61186f565b909152815190611a3c82611512565b90815283529183019183016119f2565b600082601f830112611a5d57600080fd5b81516020611a6d61195783611912565b82815260069290921b84018101918181019086841115611a8c57600080fd5b8286015b848110156119a35760408189031215611aa95760008081fd5b611ab1611885565b8151611abc81611512565b81528185015185820152835291830191604001611a90565b600060208284031215611ae657600080fd5b815167ffffffffffffffff80821115611afe57600080fd5b9083019060a08286031215611b1257600080fd5b611b1a6118ae565b611b2383611902565b8152602083015182811115611b3757600080fd5b611b4387828601611936565b602083015250604083015182811115611b5b57600080fd5b611b6787828601611936565b604083015250606083015182811115611b7f57600080fd5b611b8b878286016119ae565b606083015250608083015182811115611ba357600080fd5b611baf87828601611a4c565b60808301525095945050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561052b5761052b611bd4565b60005b83811015611c18578181015183820152602001611c00565b50506000910152565b6020815260008251806020840152611c40816040850160208701611bfd565b601f01601f19169190910160400192915050565b60008251611c66818460208701611bfd565b9190910192915050565b8082018082111561052b5761052b611bd456fea2646970667358221220615bef00ea45c79b431c0cc175760e81c290a4c6a699332e9fb855c8a41f3d0e64736f6c634300081700330000000000000000000000001629ce9df01b10e7cf8837f559037a49d983aa10000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006c0aa5c1ea02a81a60f77f7117ceb987b39f3c1f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106101095760003560e01c806354d1f13d116100955780638da798da116100645780638da798da146103ae578063f04e283e146103c1578063f147db8a146103d4578063f2fde38b146103f0578063fee81cf41461040357610109565b806354d1f13d1461035f57806370c109cd14610367578063715018a61461037a5780638da5cb5b1461038257610109565b806325692962116100dc57806325692962146102aa5780632de94807146102b25780633e429396146102f35780634a4ee7b114610315578063514e62fc1461032857610109565b806301ffc9a71461022f578063183a4f6e146102645780631c10893f146102775780631cd64df41461028a575b600080356001600160e01b0319168152600260208181526040808420815160608101835281546001600160a01b03168152600180830154948201949094529381015490929184019160ff90911690811115610166576101666114fc565b6001811115610177576101776114fc565b90525080519091506001600160a01b03166101a55760405163b6b8317760e01b815260040160405180910390fd5b6000816040015160018111156101bd576101bd6114fc565b036101e7573330146101e25760405163052bb9ef60e31b815260040160405180910390fd5b610222565b6001816040015160018111156101ff576101ff6114fc565b148015610210575060008160200151115b15610222576102228160200151610436565b805161022d9061046c565b005b34801561023b57600080fd5b5061024f61024a366004611528565b6104a7565b60405190151581526020015b60405180910390f35b61022d61027236600461154c565b6104f2565b61022d610285366004611581565b6104fc565b34801561029657600080fd5b5061024f6102a5366004611581565b610512565b61022d610531565b3480156102be57600080fd5b506102e56102cd3660046115ab565b638b78c6d8600c908152600091909152602090205490565b60405190815260200161025b565b3480156102ff57600080fd5b50610308610581565b60405161025b9190611652565b61022d610323366004611581565b6106ad565b34801561033457600080fd5b5061024f610343366004611581565b638b78c6d8600c90815260009290925260209091205416151590565b61022d6106bf565b61022d610375366004611775565b6106fb565b61022d61074f565b34801561038e57600080fd5b50638b78c6d819546040516001600160a01b03909116815260200161025b565b61022d6103bc366004611775565b610763565b61022d6103cf3660046115ab565b6107b1565b3480156103e057600080fd5b50606060405161025b91906117f8565b61022d6103fe3660046115ab565b6107ee565b34801561040f57600080fd5b506102e561041e3660046115ab565b63389a75e1600c908152600091909152602090205490565b638b78c6d81954331461046957638b78c6d8600c5233600052806020600c205416610469576382b429006000526004601cfd5b50565b6040805136810190915236600082376000803683855af490506104953d60408051918201905290565b3d6000823e816104a3573d81fd5b3d81f35b60006001600160e01b031980831690036104c357506000919050565b6001600160e01b03198216600090815260016020526040902054156104ea57506001919050565b506000919050565b6104693382610815565b610504610821565b61050e828261083c565b5050565b638b78c6d8600c90815260008390526020902054811681145b92915050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b6060600061058f6000610848565b90508067ffffffffffffffff8111156105aa576105aa61186f565b6040519080825280602002602001820160405280156105e357816020015b6105d06114a8565b8152602001906001900390816105c85790505b50915060005b818110156106a85760006105fd818361089a565b90506040518060400160405280826001600160a01b03168152602001826001600160a01b03166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610657573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261067f9190810190611ad4565b81525084838151811061069457610694611bbe565b6020908102919091010152506001016105e9565b505090565b6106b5610821565b61050e8282610815565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b600160ff1b61070981610436565b6107498484848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506108f492505050565b50505050565b610757610821565b6107616000610bdb565b565b600160ff1b61077181610436565b6107498484848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610c1992505050565b6107b9610821565b63389a75e1600c52806000526020600c2080544211156107e157636f5e88186000526004601cfd5b6000905561046981610bdb565b6107f6610821565b8060601b61080c57637448fbae6000526004601cfd5b61046981610bdb565b61050e82826000611197565b638b78c6d819543314610761576382b429006000526004601cfd5b61050e82826001611197565b63978aab9260045260008181526024812080548060a01b60a01c8060011c9350808260601c1517610892576001935083830154156108925760029350838301541561089257600393505b505050919050565b63978aab926004526000828152602481208281015460601c915068fbb67fda52d4bfb8bf821415820291506108ce84610848565b83106108ed57604051634e23d03560e01b815260040160405180910390fd5b5092915050565b6108ff6000836111f0565b61091c57604051632a6f792960e01b815260040160405180910390fd5b6000826001600160a01b03166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561095c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109849190810190611ad4565b60408101515190915060005b818110156109f9576001806000856040015184815181106109b3576109b3611bbe565b60200260200101516001600160e01b0319166001600160e01b031916815260200190815260200160002060008282546109ec9190611bea565b9091555050600101610990565b5060808201515160005b81811015610a74576002600085608001518381518110610a2557610a25611bbe565b602090810291909101810151516001600160e01b0319168252810191909152604001600090812080546001600160a01b0319168155600180820192909255600201805460ff1916905501610a03565b5060608301515160005b81811015610aef576002600086606001518381518110610aa057610aa0611bbe565b602090810291909101810151516001600160e01b0319168252810191909152604001600090812080546001600160a01b0319168155600180820192909255600201805460ff1916905501610a7e565b50835115610b8b57856001600160a01b031685604051602401610b129190611c21565b60408051601f198184030181529181526020820180516001600160e01b0316638a91b0e360e01b17905251610b479190611c54565b600060405180830381855af49150503d8060008114610b82576040519150601f19603f3d011682016040523d82523d6000602084013e610b87565b606091505b5050505b604080513381526001600160a01b038816602082018190528183015290517fef3b2e20acbb62d61d782c5449bd73d3970cb9be1050a6ad6f846b2cbe21c03a9181900360600190a1505050505050565b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b610c2460008361133b565b610c4157604051631261bbf160e11b815260040160405180910390fd5b6000826001600160a01b03166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610c81573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ca99190810190611ad4565b9050806020015151600014610d4d5760005b816020015151811015610d4b57610cee82602001518281518110610ce157610ce1611bbe565b60200260200101516104a7565b610d435781602001518181518110610d0857610d08611bbe565b60200260200101516040516356ba3a7f60e01b8152600401610d3a91906001600160e01b031991909116815260200190565b60405180910390fd5b600101610cbb565b505b60408101515160005b81811015610dbf57600180600085604001518481518110610d7957610d79611bbe565b60200260200101516001600160e01b0319166001600160e01b03191681526020019081526020016000206000828254610db29190611c70565b9091555050600101610d56565b5060608051838201515160005b81811015610f6b57600086606001518281518110610dec57610dec611bbe565b60209081029190910181015180516001600160e01b031916600090815260029092526040909120549091506001600160a01b031615610e3e57604051634cc04b1760e01b815260040160405180910390fd5b6000805b85811015610e975782600001516001600160e01b031916878281518110610e6b57610e6b611bbe565b6020026020010151600001516001600160e01b03191603610e8f5760019150610e97565b600101610e42565b5080610eb65760405163573ffc1f60e11b815260040160405180910390fd5b60405180606001604052808b6001600160a01b031681526020016000815260200160006001811115610eea57610eea6114fc565b905282516001600160e01b031916600090815260026020818152604092839020845181546001600160a01b0319166001600160a01b03909116178155908401516001808301919091559284015191810180549193909160ff1916908381811115610f5657610f566114fc565b02179055505060019093019250610dcc915050565b5060808501515160005b8181101561108c57600087608001518281518110610f9557610f95611bbe565b60209081029190910181015180516001600160e01b031916600090815260029092526040909120549091506001600160a01b031615610fe7576040516392bffc6560e01b815260040160405180910390fd5b604080516060810182526001600160a01b038c168152602083810151908201529081016001905281516001600160e01b031916600090815260026020818152604092839020845181546001600160a01b0319166001600160a01b03909116178155908401516001808301919091559284015191810180549193909160ff1916908381811115611078576110786114fc565b02179055505060019092019150610f759050565b5085511561114557600080896001600160a01b0316896040516024016110b29190611c21565b60408051601f198184030181529181526020820180516001600160e01b03166306d61fe760e41b179052516110e79190611c54565b600060405180830381855af49150503d8060008114611122576040519150601f19603f3d011682016040523d82523d6000602084013e611127565b606091505b5091509150816111425761114281633fcb904560e01b61148f565b50505b604080513381526001600160a01b038a16602082018190528183015290517fbcd03fe408dcc45614e803cbab9f500dddff61b17380b993e76d30398da472299181900360600190a15050505050505050565b638b78c6d8600c52826000526020600c208054838117836111b9575080841681185b80835580600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26600080a3505050505050565b63978aab926004526000828152602481206001600160a01b03929092169168fbb67fda52d4bfb8be19830161122d5763f5a267f16000526004601cfd5b8261123f5768fbb67fda52d4bfb8bf92505b80546bffffffffffffffffffffffff8116806112c25760019350848260601c0361127d57600183018054845560028401805490915560009055611332565b84600184015460601c0361129f57600283018054600185015560009055611332565b84600284015460601c036112b95760006002840155611332565b60009350611332565b826020528460005260406000208054806112dd575050611332565b60018360011c039250826001820314611315578285015460601c8060601b600183038701556000848701558060005250806040600020555b5060018260011b17845460601c60601b1784556000815550600193505b50505092915050565b63978aab926004526000828152602481206001600160a01b03929092169168fbb67fda52d4bfb8be1983016113785763f5a267f16000526004601cfd5b8261138a5768fbb67fda52d4bfb8bf92505b80546bffffffffffffffffffffffff81168260205280611452578160601c806113bd578560601b84556001945050611332565b8581036113ca5750611332565b600184015460601c806113eb578660601b6001860155600195505050611332565b8681036113f9575050611332565b600285015460601c8061141b578760601b600287015560019650505050611332565b87810361142a57505050611332565b6000928352604080842060019055918352818320600290558252902060039055506007908117905b8460005260406000208054611485578160011c91508560601b828501558160010181558260020184556001945050611332565b5050505092915050565b81511561149e57815182602001fd5b806000526004601cfd5b604051806040016040528060006001600160a01b031681526020016114f76040518060a00160405280600015158152602001606081526020016060815260200160608152602001606081525090565b905290565b634e487b7160e01b600052602160045260246000fd5b6001600160e01b03198116811461046957600080fd5b60006020828403121561153a57600080fd5b813561154581611512565b9392505050565b60006020828403121561155e57600080fd5b5035919050565b80356001600160a01b038116811461157c57600080fd5b919050565b6000806040838503121561159457600080fd5b61159d83611565565b946020939093013593505050565b6000602082840312156115bd57600080fd5b61154582611565565b60008151808452602080850194506020840160005b838110156116015781516001600160e01b031916875295820195908201906001016115db565b509495945050505050565b60008151808452602080850194506020840160005b8381101561160157815180516001600160e01b03191688528301518388015260409096019590820190600101611621565b600060208083018184528085518083526040925060408601915060408160051b8701018488016000805b8481101561176657603f198a850381018752835180516001600160a01b031686528901518986018990528051151589870152808a015160a060608089018290526116c960e08a01846115c6565b92508b8401516080868b860301818c01526116e485836115c6565b928601518b84038801948c01949094528351808452938f019450918e019288929091505b81831015611733578451516001600160e01b0319168452938e0193928e019260019290920191611708565b808601519550505050838882030160c0890152611750818461160c565b998c01999750505093890193505060010161167c565b50919998505050505050505050565b60008060006040848603121561178a57600080fd5b61179384611565565b9250602084013567ffffffffffffffff808211156117b057600080fd5b818601915086601f8301126117c457600080fd5b8135818111156117d357600080fd5b8760208285010111156117e557600080fd5b6020830194508093505050509250925092565b60208082528251828201819052600091906040908185019086840185805b8381101561186157825180516001600160e01b03191686528701516002811061184d57634e487b7160e01b83526021600452602483fd5b858801529385019391860191600101611816565b509298975050505050505050565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156118a8576118a861186f565b60405290565b60405160a0810167ffffffffffffffff811182821017156118a8576118a861186f565b604051601f8201601f1916810167ffffffffffffffff811182821017156118fa576118fa61186f565b604052919050565b8051801515811461157c57600080fd5b600067ffffffffffffffff82111561192c5761192c61186f565b5060051b60200190565b600082601f83011261194757600080fd5b8151602061195c61195783611912565b6118d1565b8083825260208201915060208460051b87010193508684111561197e57600080fd5b602086015b848110156119a357805161199681611512565b8352918301918301611983565b509695505050505050565b600082601f8301126119bf57600080fd5b815160206119cf61195783611912565b82815260059290921b840181019181810190868411156119ee57600080fd5b8286015b848110156119a357838189031215611a0a5760008081fd5b6040805185810181811067ffffffffffffffff82111715611a2d57611a2d61186f565b909152815190611a3c82611512565b90815283529183019183016119f2565b600082601f830112611a5d57600080fd5b81516020611a6d61195783611912565b82815260069290921b84018101918181019086841115611a8c57600080fd5b8286015b848110156119a35760408189031215611aa95760008081fd5b611ab1611885565b8151611abc81611512565b81528185015185820152835291830191604001611a90565b600060208284031215611ae657600080fd5b815167ffffffffffffffff80821115611afe57600080fd5b9083019060a08286031215611b1257600080fd5b611b1a6118ae565b611b2383611902565b8152602083015182811115611b3757600080fd5b611b4387828601611936565b602083015250604083015182811115611b5b57600080fd5b611b6787828601611936565b604083015250606083015182811115611b7f57600080fd5b611b8b878286016119ae565b606083015250608083015182811115611ba357600080fd5b611baf87828601611a4c565b60808301525095945050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561052b5761052b611bd4565b60005b83811015611c18578181015183820152602001611c00565b50506000910152565b6020815260008251806020840152611c40816040850160208701611bfd565b601f01601f19169190910160400192915050565b60008251611c66818460208701611bfd565b9190910192915050565b8082018082111561052b5761052b611bd456fea2646970667358221220615bef00ea45c79b431c0cc175760e81c290a4c6a699332e9fb855c8a41f3d0e64736f6c63430008170033
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.