Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
6857475 | 121 days ago | Contract Creation | 0 ETH |
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.
Contract Source Code Verified (Exact Match)
Contract Name:
ERC20CoreInitializable
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 10000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; import {ERC20Base} from "./ERC20Base.sol"; import {Initializable} from "@solady/utils/Initializable.sol"; contract ERC20CoreInitializable is ERC20Base, Initializable { constructor() { _disableInitializers(); } function initialize( string memory _name, string memory _symbol, string memory _contractURI, address _owner, address[] memory _modules, bytes[] memory _moduleInstallData ) external payable initializer { _initialize(_name, _symbol, _contractURI, _owner, _modules, _moduleInstallData); } }
// 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 Simple ERC20 + EIP-2612 implementation. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC20.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol) /// /// @dev Note: /// - The ERC20 standard allows minting and transferring to and from the zero address, /// minting and transferring zero tokens, as well as self-approvals. /// For performance, this implementation WILL NOT revert for such actions. /// Please add any checks with overrides if desired. /// - The `permit` function uses the ecrecover precompile (0x1). /// /// If you are overriding: /// - NEVER violate the ERC20 invariant: /// the total sum of all balances must be equal to `totalSupply()`. /// - Check that the overridden function is actually used in the function you want to /// change the behavior of. Much of the code has been manually inlined for performance. abstract contract ERC20 { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The total supply has overflowed. error TotalSupplyOverflow(); /// @dev The allowance has overflowed. error AllowanceOverflow(); /// @dev The allowance has underflowed. error AllowanceUnderflow(); /// @dev Insufficient balance. error InsufficientBalance(); /// @dev Insufficient allowance. error InsufficientAllowance(); /// @dev The permit is invalid. error InvalidPermit(); /// @dev The permit has expired. error PermitExpired(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Emitted when `amount` tokens is transferred from `from` to `to`. event Transfer(address indexed from, address indexed to, uint256 amount); /// @dev Emitted when `amount` tokens is approved by `owner` to be used by `spender`. event Approval(address indexed owner, address indexed spender, uint256 amount); /// @dev `keccak256(bytes("Transfer(address,address,uint256)"))`. uint256 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; /// @dev `keccak256(bytes("Approval(address,address,uint256)"))`. uint256 private constant _APPROVAL_EVENT_SIGNATURE = 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The storage slot for the total supply. uint256 private constant _TOTAL_SUPPLY_SLOT = 0x05345cdf77eb68f44c; /// @dev The balance slot of `owner` is given by: /// ``` /// mstore(0x0c, _BALANCE_SLOT_SEED) /// mstore(0x00, owner) /// let balanceSlot := keccak256(0x0c, 0x20) /// ``` uint256 private constant _BALANCE_SLOT_SEED = 0x87a211a2; /// @dev The allowance slot of (`owner`, `spender`) is given by: /// ``` /// mstore(0x20, spender) /// mstore(0x0c, _ALLOWANCE_SLOT_SEED) /// mstore(0x00, owner) /// let allowanceSlot := keccak256(0x0c, 0x34) /// ``` uint256 private constant _ALLOWANCE_SLOT_SEED = 0x7f5e9f20; /// @dev The nonce slot of `owner` is given by: /// ``` /// mstore(0x0c, _NONCES_SLOT_SEED) /// mstore(0x00, owner) /// let nonceSlot := keccak256(0x0c, 0x20) /// ``` uint256 private constant _NONCES_SLOT_SEED = 0x38377508; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev `(_NONCES_SLOT_SEED << 16) | 0x1901`. uint256 private constant _NONCES_SLOT_SEED_WITH_SIGNATURE_PREFIX = 0x383775081901; /// @dev `keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")`. bytes32 private constant _DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; /// @dev `keccak256("1")`. bytes32 private constant _VERSION_HASH = 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6; /// @dev `keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")`. bytes32 private constant _PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC20 METADATA */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the name of the token. function name() public view virtual returns (string memory); /// @dev Returns the symbol of the token. function symbol() public view virtual returns (string memory); /// @dev Returns the decimals places of the token. function decimals() public view virtual returns (uint8) { return 18; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC20 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the amount of tokens in existence. function totalSupply() public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { result := sload(_TOTAL_SUPPLY_SLOT) } } /// @dev Returns the amount of tokens owned by `owner`. function balanceOf(address owner) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { mstore(0x0c, _BALANCE_SLOT_SEED) mstore(0x00, owner) result := sload(keccak256(0x0c, 0x20)) } } /// @dev Returns the amount of tokens that `spender` can spend on behalf of `owner`. function allowance(address owner, address spender) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { mstore(0x20, spender) mstore(0x0c, _ALLOWANCE_SLOT_SEED) mstore(0x00, owner) result := sload(keccak256(0x0c, 0x34)) } } /// @dev Sets `amount` as the allowance of `spender` over the caller's tokens. /// /// Emits a {Approval} event. function approve(address spender, uint256 amount) public virtual returns (bool) { /// @solidity memory-safe-assembly assembly { // Compute the allowance slot and store the amount. mstore(0x20, spender) mstore(0x0c, _ALLOWANCE_SLOT_SEED) mstore(0x00, caller()) sstore(keccak256(0x0c, 0x34), amount) // Emit the {Approval} event. mstore(0x00, amount) log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, caller(), shr(96, mload(0x2c))) } return true; } /// @dev Transfer `amount` tokens from the caller to `to`. /// /// Requirements: /// - `from` must at least have `amount`. /// /// Emits a {Transfer} event. function transfer(address to, uint256 amount) public virtual returns (bool) { _beforeTokenTransfer(msg.sender, to, amount); /// @solidity memory-safe-assembly assembly { // Compute the balance slot and load its value. mstore(0x0c, _BALANCE_SLOT_SEED) mstore(0x00, caller()) let fromBalanceSlot := keccak256(0x0c, 0x20) let fromBalance := sload(fromBalanceSlot) // Revert if insufficient balance. if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } // Subtract and store the updated balance. sstore(fromBalanceSlot, sub(fromBalance, amount)) // Compute the balance slot of `to`. mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x20) // Add and store the updated balance of `to`. // Will not overflow because the sum of all user balances // cannot exceed the maximum uint256 value. sstore(toBalanceSlot, add(sload(toBalanceSlot), amount)) // Emit the {Transfer} event. mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, caller(), shr(96, mload(0x0c))) } _afterTokenTransfer(msg.sender, to, amount); return true; } /// @dev Transfers `amount` tokens from `from` to `to`. /// /// Note: Does not update the allowance if it is the maximum uint256 value. /// /// Requirements: /// - `from` must at least have `amount`. /// - The caller must have at least `amount` of allowance to transfer the tokens of `from`. /// /// Emits a {Transfer} event. function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) { _beforeTokenTransfer(from, to, amount); /// @solidity memory-safe-assembly assembly { let from_ := shl(96, from) // Compute the allowance slot and load its value. mstore(0x20, caller()) mstore(0x0c, or(from_, _ALLOWANCE_SLOT_SEED)) let allowanceSlot := keccak256(0x0c, 0x34) let allowance_ := sload(allowanceSlot) // If the allowance is not the maximum uint256 value. if add(allowance_, 1) { // Revert if the amount to be transferred exceeds the allowance. if gt(amount, allowance_) { mstore(0x00, 0x13be252b) // `InsufficientAllowance()`. revert(0x1c, 0x04) } // Subtract and store the updated allowance. sstore(allowanceSlot, sub(allowance_, amount)) } // Compute the balance slot and load its value. mstore(0x0c, or(from_, _BALANCE_SLOT_SEED)) let fromBalanceSlot := keccak256(0x0c, 0x20) let fromBalance := sload(fromBalanceSlot) // Revert if insufficient balance. if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } // Subtract and store the updated balance. sstore(fromBalanceSlot, sub(fromBalance, amount)) // Compute the balance slot of `to`. mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x20) // Add and store the updated balance of `to`. // Will not overflow because the sum of all user balances // cannot exceed the maximum uint256 value. sstore(toBalanceSlot, add(sload(toBalanceSlot), amount)) // Emit the {Transfer} event. mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c))) } _afterTokenTransfer(from, to, amount); return true; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EIP-2612 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev For more performance, override to return the constant value /// of `keccak256(bytes(name()))` if `name()` will never change. function _constantNameHash() internal view virtual returns (bytes32 result) {} /// @dev Returns the current nonce for `owner`. /// This value is used to compute the signature for EIP-2612 permit. function nonces(address owner) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { // Compute the nonce slot and load its value. mstore(0x0c, _NONCES_SLOT_SEED) mstore(0x00, owner) result := sload(keccak256(0x0c, 0x20)) } } /// @dev Sets `value` as the allowance of `spender` over the tokens of `owner`, /// authorized by a signed approval by `owner`. /// /// Emits a {Approval} event. function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { bytes32 nameHash = _constantNameHash(); // We simply calculate it on-the-fly to allow for cases where the `name` may change. if (nameHash == bytes32(0)) nameHash = keccak256(bytes(name())); /// @solidity memory-safe-assembly assembly { // Revert if the block timestamp is greater than `deadline`. if gt(timestamp(), deadline) { mstore(0x00, 0x1a15a3cc) // `PermitExpired()`. revert(0x1c, 0x04) } let m := mload(0x40) // Grab the free memory pointer. // Clean the upper 96 bits. owner := shr(96, shl(96, owner)) spender := shr(96, shl(96, spender)) // Compute the nonce slot and load its value. mstore(0x0e, _NONCES_SLOT_SEED_WITH_SIGNATURE_PREFIX) mstore(0x00, owner) let nonceSlot := keccak256(0x0c, 0x20) let nonceValue := sload(nonceSlot) // Prepare the domain separator. mstore(m, _DOMAIN_TYPEHASH) mstore(add(m, 0x20), nameHash) mstore(add(m, 0x40), _VERSION_HASH) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) mstore(0x2e, keccak256(m, 0xa0)) // Prepare the struct hash. mstore(m, _PERMIT_TYPEHASH) mstore(add(m, 0x20), owner) mstore(add(m, 0x40), spender) mstore(add(m, 0x60), value) mstore(add(m, 0x80), nonceValue) mstore(add(m, 0xa0), deadline) mstore(0x4e, keccak256(m, 0xc0)) // Prepare the ecrecover calldata. mstore(0x00, keccak256(0x2c, 0x42)) mstore(0x20, and(0xff, v)) mstore(0x40, r) mstore(0x60, s) let t := staticcall(gas(), 1, 0, 0x80, 0x20, 0x20) // If the ecrecover fails, the returndatasize will be 0x00, // `owner` will be checked if it equals the hash at 0x00, // which evaluates to false (i.e. 0), and we will revert. // If the ecrecover succeeds, the returndatasize will be 0x20, // `owner` will be compared against the returned address at 0x20. if iszero(eq(mload(returndatasize()), owner)) { mstore(0x00, 0xddafbaef) // `InvalidPermit()`. revert(0x1c, 0x04) } // Increment and store the updated nonce. sstore(nonceSlot, add(nonceValue, t)) // `t` is 1 if ecrecover succeeds. // Compute the allowance slot and store the value. // The `owner` is already at slot 0x20. mstore(0x40, or(shl(160, _ALLOWANCE_SLOT_SEED), spender)) sstore(keccak256(0x2c, 0x34), value) // Emit the {Approval} event. log3(add(m, 0x60), 0x20, _APPROVAL_EVENT_SIGNATURE, owner, spender) mstore(0x40, m) // Restore the free memory pointer. mstore(0x60, 0) // Restore the zero pointer. } } /// @dev Returns the EIP-712 domain separator for the EIP-2612 permit. function DOMAIN_SEPARATOR() public view virtual returns (bytes32 result) { bytes32 nameHash = _constantNameHash(); // We simply calculate it on-the-fly to allow for cases where the `name` may change. if (nameHash == bytes32(0)) nameHash = keccak256(bytes(name())); /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Grab the free memory pointer. mstore(m, _DOMAIN_TYPEHASH) mstore(add(m, 0x20), nameHash) mstore(add(m, 0x40), _VERSION_HASH) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) result := keccak256(m, 0xa0) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL MINT FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Mints `amount` tokens to `to`, increasing the total supply. /// /// Emits a {Transfer} event. function _mint(address to, uint256 amount) internal virtual { _beforeTokenTransfer(address(0), to, amount); /// @solidity memory-safe-assembly assembly { let totalSupplyBefore := sload(_TOTAL_SUPPLY_SLOT) let totalSupplyAfter := add(totalSupplyBefore, amount) // Revert if the total supply overflows. if lt(totalSupplyAfter, totalSupplyBefore) { mstore(0x00, 0xe5cfe957) // `TotalSupplyOverflow()`. revert(0x1c, 0x04) } // Store the updated total supply. sstore(_TOTAL_SUPPLY_SLOT, totalSupplyAfter) // Compute the balance slot and load its value. mstore(0x0c, _BALANCE_SLOT_SEED) mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x20) // Add and store the updated balance. sstore(toBalanceSlot, add(sload(toBalanceSlot), amount)) // Emit the {Transfer} event. mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, mload(0x0c))) } _afterTokenTransfer(address(0), to, amount); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL BURN FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Burns `amount` tokens from `from`, reducing the total supply. /// /// Emits a {Transfer} event. function _burn(address from, uint256 amount) internal virtual { _beforeTokenTransfer(from, address(0), amount); /// @solidity memory-safe-assembly assembly { // Compute the balance slot and load its value. mstore(0x0c, _BALANCE_SLOT_SEED) mstore(0x00, from) let fromBalanceSlot := keccak256(0x0c, 0x20) let fromBalance := sload(fromBalanceSlot) // Revert if insufficient balance. if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } // Subtract and store the updated balance. sstore(fromBalanceSlot, sub(fromBalance, amount)) // Subtract and store the updated total supply. sstore(_TOTAL_SUPPLY_SLOT, sub(sload(_TOTAL_SUPPLY_SLOT), amount)) // Emit the {Transfer} event. mstore(0x00, amount) log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), 0) } _afterTokenTransfer(from, address(0), amount); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL TRANSFER FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Moves `amount` of tokens from `from` to `to`. function _transfer(address from, address to, uint256 amount) internal virtual { _beforeTokenTransfer(from, to, amount); /// @solidity memory-safe-assembly assembly { let from_ := shl(96, from) // Compute the balance slot and load its value. mstore(0x0c, or(from_, _BALANCE_SLOT_SEED)) let fromBalanceSlot := keccak256(0x0c, 0x20) let fromBalance := sload(fromBalanceSlot) // Revert if insufficient balance. if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } // Subtract and store the updated balance. sstore(fromBalanceSlot, sub(fromBalance, amount)) // Compute the balance slot of `to`. mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x20) // Add and store the updated balance of `to`. // Will not overflow because the sum of all user balances // cannot exceed the maximum uint256 value. sstore(toBalanceSlot, add(sload(toBalanceSlot), amount)) // Emit the {Transfer} event. mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c))) } _afterTokenTransfer(from, to, amount); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL ALLOWANCE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Updates the allowance of `owner` for `spender` based on spent `amount`. function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { /// @solidity memory-safe-assembly assembly { // Compute the allowance slot and load its value. mstore(0x20, spender) mstore(0x0c, _ALLOWANCE_SLOT_SEED) mstore(0x00, owner) let allowanceSlot := keccak256(0x0c, 0x34) let allowance_ := sload(allowanceSlot) // If the allowance is not the maximum uint256 value. if add(allowance_, 1) { // Revert if the amount to be transferred exceeds the allowance. if gt(amount, allowance_) { mstore(0x00, 0x13be252b) // `InsufficientAllowance()`. revert(0x1c, 0x04) } // Subtract and store the updated allowance. sstore(allowanceSlot, sub(allowance_, amount)) } } } /// @dev Sets `amount` as the allowance of `spender` over the tokens of `owner`. /// /// Emits a {Approval} event. function _approve(address owner, address spender, uint256 amount) internal virtual { /// @solidity memory-safe-assembly assembly { let owner_ := shl(96, owner) // Compute the allowance slot and store the amount. mstore(0x20, spender) mstore(0x0c, or(owner_, _ALLOWANCE_SLOT_SEED)) sstore(keccak256(0x0c, 0x34), amount) // Emit the {Approval} event. mstore(0x00, amount) log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, shr(96, owner_), shr(96, mload(0x2c))) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HOOKS TO OVERRIDE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Hook that is called before any transfer of tokens. /// This includes minting and burning. function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /// @dev Hook that is called after any transfer of tokens. /// This includes minting and burning. function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Gas optimized ECDSA wrapper. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ECDSA.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ECDSA.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol) /// /// @dev Note: /// - The recovery functions use the ecrecover precompile (0x1). /// - As of Solady version 0.0.68, the `recover` variants will revert upon recovery failure. /// This is for more safety by default. /// Use the `tryRecover` variants if you need to get the zero address back /// upon recovery failure instead. /// - As of Solady version 0.0.134, all `bytes signature` variants accept both /// regular 65-byte `(r, s, v)` and EIP-2098 `(r, vs)` short form signatures. /// See: https://eips.ethereum.org/EIPS/eip-2098 /// This is for calldata efficiency on smart accounts prevalent on L2s. /// /// WARNING! Do NOT use signatures as unique identifiers: /// - Use a nonce in the digest to prevent replay attacks on the same contract. /// - Use EIP-712 for the digest to prevent replay attacks across different chains and contracts. /// EIP-712 also enables readable signing of typed data for better user safety. /// This implementation does NOT check if a signature is non-malleable. library ECDSA { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The signature is invalid. error InvalidSignature(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* RECOVERY OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`. function recover(bytes32 hash, bytes memory signature) internal view returns (address result) { /// @solidity memory-safe-assembly assembly { result := 1 let m := mload(0x40) // Cache the free memory pointer. for {} 1 {} { mstore(0x00, hash) mstore(0x40, mload(add(signature, 0x20))) // `r`. if eq(mload(signature), 64) { let vs := mload(add(signature, 0x40)) mstore(0x20, add(shr(255, vs), 27)) // `v`. mstore(0x60, shr(1, shl(1, vs))) // `s`. break } if eq(mload(signature), 65) { mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`. mstore(0x60, mload(add(signature, 0x40))) // `s`. break } result := 0 break } result := mload( staticcall( gas(), // Amount of gas left for the transaction. result, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(returndatasize()) { mstore(0x00, 0x8baa579f) // `InvalidSignature()`. revert(0x1c, 0x04) } mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`. function recoverCalldata(bytes32 hash, bytes calldata signature) internal view returns (address result) { /// @solidity memory-safe-assembly assembly { result := 1 let m := mload(0x40) // Cache the free memory pointer. mstore(0x00, hash) for {} 1 {} { if eq(signature.length, 64) { let vs := calldataload(add(signature.offset, 0x20)) mstore(0x20, add(shr(255, vs), 27)) // `v`. mstore(0x40, calldataload(signature.offset)) // `r`. mstore(0x60, shr(1, shl(1, vs))) // `s`. break } if eq(signature.length, 65) { mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`. calldatacopy(0x40, signature.offset, 0x40) // Copy `r` and `s`. break } result := 0 break } result := mload( staticcall( gas(), // Amount of gas left for the transaction. result, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(returndatasize()) { mstore(0x00, 0x8baa579f) // `InvalidSignature()`. revert(0x1c, 0x04) } mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Recovers the signer's address from a message digest `hash`, /// and the EIP-2098 short form signature defined by `r` and `vs`. function recover(bytes32 hash, bytes32 r, bytes32 vs) internal view returns (address result) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x00, hash) mstore(0x20, add(shr(255, vs), 27)) // `v`. mstore(0x40, r) mstore(0x60, shr(1, shl(1, vs))) // `s`. result := mload( staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(returndatasize()) { mstore(0x00, 0x8baa579f) // `InvalidSignature()`. revert(0x1c, 0x04) } mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Recovers the signer's address from a message digest `hash`, /// and the signature defined by `v`, `r`, `s`. function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal view returns (address result) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x00, hash) mstore(0x20, and(v, 0xff)) mstore(0x40, r) mstore(0x60, s) result := mload( staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(returndatasize()) { mstore(0x00, 0x8baa579f) // `InvalidSignature()`. revert(0x1c, 0x04) } mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* TRY-RECOVER OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ // WARNING! // These functions will NOT revert upon recovery failure. // Instead, they will return the zero address upon recovery failure. // It is critical that the returned address is NEVER compared against // a zero address (e.g. an uninitialized address variable). /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`. function tryRecover(bytes32 hash, bytes memory signature) internal view returns (address result) { /// @solidity memory-safe-assembly assembly { result := 1 let m := mload(0x40) // Cache the free memory pointer. for {} 1 {} { mstore(0x00, hash) mstore(0x40, mload(add(signature, 0x20))) // `r`. if eq(mload(signature), 64) { let vs := mload(add(signature, 0x40)) mstore(0x20, add(shr(255, vs), 27)) // `v`. mstore(0x60, shr(1, shl(1, vs))) // `s`. break } if eq(mload(signature), 65) { mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`. mstore(0x60, mload(add(signature, 0x40))) // `s`. break } result := 0 break } pop( staticcall( gas(), // Amount of gas left for the transaction. result, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x40, // Start of output. 0x20 // Size of output. ) ) mstore(0x60, 0) // Restore the zero slot. // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. result := mload(xor(0x60, returndatasize())) mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Recovers the signer's address from a message digest `hash`, and the `signature`. function tryRecoverCalldata(bytes32 hash, bytes calldata signature) internal view returns (address result) { /// @solidity memory-safe-assembly assembly { result := 1 let m := mload(0x40) // Cache the free memory pointer. mstore(0x00, hash) for {} 1 {} { if eq(signature.length, 64) { let vs := calldataload(add(signature.offset, 0x20)) mstore(0x20, add(shr(255, vs), 27)) // `v`. mstore(0x40, calldataload(signature.offset)) // `r`. mstore(0x60, shr(1, shl(1, vs))) // `s`. break } if eq(signature.length, 65) { mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`. calldatacopy(0x40, signature.offset, 0x40) // Copy `r` and `s`. break } result := 0 break } pop( staticcall( gas(), // Amount of gas left for the transaction. result, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x40, // Start of output. 0x20 // Size of output. ) ) mstore(0x60, 0) // Restore the zero slot. // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. result := mload(xor(0x60, returndatasize())) mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Recovers the signer's address from a message digest `hash`, /// and the EIP-2098 short form signature defined by `r` and `vs`. function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal view returns (address result) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x00, hash) mstore(0x20, add(shr(255, vs), 27)) // `v`. mstore(0x40, r) mstore(0x60, shr(1, shl(1, vs))) // `s`. pop( staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x40, // Start of output. 0x20 // Size of output. ) ) mstore(0x60, 0) // Restore the zero slot. // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. result := mload(xor(0x60, returndatasize())) mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Recovers the signer's address from a message digest `hash`, /// and the signature defined by `v`, `r`, `s`. function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal view returns (address result) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x00, hash) mstore(0x20, and(v, 0xff)) mstore(0x40, r) mstore(0x60, s) pop( staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x40, // Start of output. 0x20 // Size of output. ) ) mstore(0x60, 0) // Restore the zero slot. // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. result := mload(xor(0x60, returndatasize())) mstore(0x40, m) // Restore the free memory pointer. } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HASHING OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns an Ethereum Signed Message, created from a `hash`. /// This produces a hash corresponding to the one signed with the /// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign) /// JSON-RPC method as part of EIP-191. function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { mstore(0x20, hash) // Store into scratch space for keccak256. mstore(0x00, "\x00\x00\x00\x00\x19Ethereum Signed Message:\n32") // 28 bytes. result := keccak256(0x04, 0x3c) // `32 * 2 - (32 - 28) = 60 = 0x3c`. } } /// @dev Returns an Ethereum Signed Message, created from `s`. /// This produces a hash corresponding to the one signed with the /// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign) /// JSON-RPC method as part of EIP-191. /// Note: Supports lengths of `s` up to 999999 bytes. function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { let sLength := mload(s) let o := 0x20 mstore(o, "\x19Ethereum Signed Message:\n") // 26 bytes, zero-right-padded. mstore(0x00, 0x00) // Convert the `s.length` to ASCII decimal representation: `base10(s.length)`. for { let temp := sLength } 1 {} { o := sub(o, 1) mstore8(o, add(48, mod(temp, 10))) temp := div(temp, 10) if iszero(temp) { break } } let n := sub(0x3a, o) // Header length: `26 + 32 - o`. // Throw an out-of-offset error (consumes all gas) if the header exceeds 32 bytes. returndatacopy(returndatasize(), returndatasize(), gt(n, 0x20)) mstore(s, or(mload(0x00), mload(n))) // Temporarily store the header. result := keccak256(add(s, sub(0x20, n)), add(n, sLength)) mstore(s, sLength) // Restore the length. } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EMPTY CALLDATA HELPERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns an empty calldata bytes. function emptySignature() internal pure returns (bytes calldata signature) { /// @solidity memory-safe-assembly assembly { signature.length := 0 } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Contract for EIP-712 typed structured data hashing and signing. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/EIP712.sol) /// @author Modified from Solbase (https://github.com/Sol-DAO/solbase/blob/main/src/utils/EIP712.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol) /// /// @dev Note, this implementation: /// - Uses `address(this)` for the `verifyingContract` field. /// - Does NOT use the optional EIP-712 salt. /// - Does NOT use any EIP-712 extensions. /// This is for simplicity and to save gas. /// If you need to customize, please fork / modify accordingly. abstract contract EIP712 { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS AND IMMUTABLES */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev `keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")`. bytes32 internal constant _DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; uint256 private immutable _cachedThis; uint256 private immutable _cachedChainId; bytes32 private immutable _cachedNameHash; bytes32 private immutable _cachedVersionHash; bytes32 private immutable _cachedDomainSeparator; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTRUCTOR */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Cache the hashes for cheaper runtime gas costs. /// In the case of upgradeable contracts (i.e. proxies), /// or if the chain id changes due to a hard fork, /// the domain separator will be seamlessly calculated on-the-fly. constructor() { _cachedThis = uint256(uint160(address(this))); _cachedChainId = block.chainid; string memory name; string memory version; if (!_domainNameAndVersionMayChange()) (name, version) = _domainNameAndVersion(); bytes32 nameHash = _domainNameAndVersionMayChange() ? bytes32(0) : keccak256(bytes(name)); bytes32 versionHash = _domainNameAndVersionMayChange() ? bytes32(0) : keccak256(bytes(version)); _cachedNameHash = nameHash; _cachedVersionHash = versionHash; bytes32 separator; if (!_domainNameAndVersionMayChange()) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Load the free memory pointer. mstore(m, _DOMAIN_TYPEHASH) mstore(add(m, 0x20), nameHash) mstore(add(m, 0x40), versionHash) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) separator := keccak256(m, 0xa0) } } _cachedDomainSeparator = separator; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* FUNCTIONS TO OVERRIDE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Please override this function to return the domain name and version. /// ``` /// function _domainNameAndVersion() /// internal /// pure /// virtual /// returns (string memory name, string memory version) /// { /// name = "Solady"; /// version = "1"; /// } /// ``` /// /// Note: If the returned result may change after the contract has been deployed, /// you must override `_domainNameAndVersionMayChange()` to return true. function _domainNameAndVersion() internal view virtual returns (string memory name, string memory version); /// @dev Returns if `_domainNameAndVersion()` may change /// after the contract has been deployed (i.e. after the constructor). /// Default: false. function _domainNameAndVersionMayChange() internal pure virtual returns (bool result) {} /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HASHING OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the EIP-712 domain separator. function _domainSeparator() internal view virtual returns (bytes32 separator) { if (_domainNameAndVersionMayChange()) { separator = _buildDomainSeparator(); } else { separator = _cachedDomainSeparator; if (_cachedDomainSeparatorInvalidated()) separator = _buildDomainSeparator(); } } /// @dev Returns the hash of the fully encoded EIP-712 message for this domain, /// given `structHash`, as defined in /// https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct. /// /// The hash can be used together with {ECDSA-recover} to obtain the signer of a message: /// ``` /// bytes32 digest = _hashTypedData(keccak256(abi.encode( /// keccak256("Mail(address to,string contents)"), /// mailTo, /// keccak256(bytes(mailContents)) /// ))); /// address signer = ECDSA.recover(digest, signature); /// ``` function _hashTypedData(bytes32 structHash) internal view virtual returns (bytes32 digest) { // We will use `digest` to store the domain separator to save a bit of gas. if (_domainNameAndVersionMayChange()) { digest = _buildDomainSeparator(); } else { digest = _cachedDomainSeparator; if (_cachedDomainSeparatorInvalidated()) digest = _buildDomainSeparator(); } /// @solidity memory-safe-assembly assembly { // Compute the digest. mstore(0x00, 0x1901000000000000) // Store "\x19\x01". mstore(0x1a, digest) // Store the domain separator. mstore(0x3a, structHash) // Store the struct hash. digest := keccak256(0x18, 0x42) // Restore the part of the free memory slot that was overwritten. mstore(0x3a, 0) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EIP-5267 OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev See: https://eips.ethereum.org/EIPS/eip-5267 function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { fields = hex"0f"; // `0b01111`. (name, version) = _domainNameAndVersion(); chainId = block.chainid; verifyingContract = address(this); salt = salt; // `bytes32(0)`. extensions = extensions; // `new uint256[](0)`. } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PRIVATE HELPERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the EIP-712 domain separator. function _buildDomainSeparator() private view returns (bytes32 separator) { // We will use `separator` to store the name hash to save a bit of gas. bytes32 versionHash; if (_domainNameAndVersionMayChange()) { (string memory name, string memory version) = _domainNameAndVersion(); separator = keccak256(bytes(name)); versionHash = keccak256(bytes(version)); } else { separator = _cachedNameHash; versionHash = _cachedVersionHash; } /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Load the free memory pointer. mstore(m, _DOMAIN_TYPEHASH) mstore(add(m, 0x20), separator) // Name hash. mstore(add(m, 0x40), versionHash) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) separator := keccak256(m, 0xa0) } } /// @dev Returns if the cached domain separator has been invalidated. function _cachedDomainSeparatorInvalidated() private view returns (bool result) { uint256 cachedChainId = _cachedChainId; uint256 cachedThis = _cachedThis; /// @solidity memory-safe-assembly assembly { result := iszero(and(eq(chainid(), cachedChainId), eq(address(), cachedThis))) } } }
// 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 Initializable mixin for the upgradeable contracts. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/Initializable.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/proxy/utils/Initializable.sol) abstract contract Initializable { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The contract is already initialized. error InvalidInitialization(); /// @dev The contract is not initializing. error NotInitializing(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Triggered when the contract has been initialized. event Initialized(uint64 version); /// @dev `keccak256(bytes("Initialized(uint64)"))`. bytes32 private constant _INTIALIZED_EVENT_SIGNATURE = 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The default initializable slot is given by: /// `bytes32(~uint256(uint32(bytes4(keccak256("_INITIALIZABLE_SLOT")))))`. /// /// Bits Layout: /// - [0] `initializing` /// - [1..64] `initializedVersion` bytes32 private constant _INITIALIZABLE_SLOT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf601132; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Override to return a custom storage slot if required. function _initializableSlot() internal pure virtual returns (bytes32) { return _INITIALIZABLE_SLOT; } /// @dev Guards an initializer function so that it can be invoked at most once. /// /// You can guard a function with `onlyInitializing` such that it can be called /// through a function guarded with `initializer`. /// /// This is similar to `reinitializer(1)`, except that in the context of a constructor, /// an `initializer` guarded function can be invoked multiple times. /// This can be useful during testing and is not expected to be used in production. /// /// Emits an {Initialized} event. modifier initializer() virtual { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { let i := sload(s) // Set `initializing` to 1, `initializedVersion` to 1. sstore(s, 3) // If `!(initializing == 0 && initializedVersion == 0)`. if i { // If `!(address(this).code.length == 0 && initializedVersion == 1)`. if iszero(lt(extcodesize(address()), eq(shr(1, i), 1))) { mstore(0x00, 0xf92ee8a9) // `InvalidInitialization()`. revert(0x1c, 0x04) } s := shl(shl(255, i), s) // Skip initializing if `initializing == 1`. } } _; /// @solidity memory-safe-assembly assembly { if s { // Set `initializing` to 0, `initializedVersion` to 1. sstore(s, 2) // Emit the {Initialized} event. mstore(0x20, 1) log1(0x20, 0x20, _INTIALIZED_EVENT_SIGNATURE) } } } /// @dev Guards an reinitialzer function so that it can be invoked at most once. /// /// You can guard a function with `onlyInitializing` such that it can be called /// through a function guarded with `reinitializer`. /// /// Emits an {Initialized} event. modifier reinitializer(uint64 version) virtual { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { version := and(version, 0xffffffffffffffff) // Clean upper bits. let i := sload(s) // If `initializing == 1 || initializedVersion >= version`. if iszero(lt(and(i, 1), lt(shr(1, i), version))) { mstore(0x00, 0xf92ee8a9) // `InvalidInitialization()`. revert(0x1c, 0x04) } // Set `initializing` to 1, `initializedVersion` to `version`. sstore(s, or(1, shl(1, version))) } _; /// @solidity memory-safe-assembly assembly { // Set `initializing` to 0, `initializedVersion` to `version`. sstore(s, shl(1, version)) // Emit the {Initialized} event. mstore(0x20, version) log1(0x20, 0x20, _INTIALIZED_EVENT_SIGNATURE) } } /// @dev Guards a function such that it can only be called in the scope /// of a function guarded with `initializer` or `reinitializer`. modifier onlyInitializing() virtual { _checkInitializing(); _; } /// @dev Reverts if the contract is not initializing. function _checkInitializing() internal view virtual { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { if iszero(and(1, sload(s))) { mstore(0x00, 0xd7e6bcf8) // `NotInitializing()`. revert(0x1c, 0x04) } } } /// @dev Locks any future initializations by setting the initialized version to `2**64 - 1`. /// /// Calling this in the constructor will prevent the contract from being initialized /// or reinitialized. It is recommended to use this to lock implementation contracts /// that are designed to be called through proxies. /// /// Emits an {Initialized} event the first time it is successfully called. function _disableInitializers() internal virtual { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { let i := sload(s) if and(i, 1) { mstore(0x00, 0xf92ee8a9) // `InvalidInitialization()`. revert(0x1c, 0x04) } let uint64max := shr(192, s) // Computed to save bytecode. if iszero(eq(shr(1, i), uint64max)) { // Set `initializing` to 0, `initializedVersion` to `2**64 - 1`. sstore(s, shl(1, uint64max)) // Emit the {Initialized} event. mstore(0x20, uint64max) log1(0x20, 0x20, _INTIALIZED_EVENT_SIGNATURE) } } } /// @dev Returns the highest version that has been initialized. function _getInitializedVersion() internal view virtual returns (uint64 version) { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { version := shr(1, sload(s)) } } /// @dev Returns whether the contract is currently initializing. function _isInitializing() internal view virtual returns (bool result) { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { result := and(1, sload(s)) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Contract that enables a single call to call multiple methods on itself. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/Multicallable.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/Multicallable.sol) /// /// WARNING: /// This implementation is NOT to be used with ERC2771 out-of-the-box. /// https://blog.openzeppelin.com/arbitrary-address-spoofing-vulnerability-erc2771context-multicall-public-disclosure /// This also applies to potentially other ERCs / patterns appending to the back of calldata. /// /// We do NOT have a check for ERC2771, as we do not inherit from OpenZeppelin's context. /// Moreover, it is infeasible and inefficient for us to add checks and mitigations /// for all possible ERC / patterns appending to the back of calldata. /// /// We would highly recommend using an alternative pattern such as /// https://github.com/Vectorized/multicaller /// which is more flexible, futureproof, and safer by default. abstract contract Multicallable { /// @dev Apply `DELEGATECALL` with the current contract to each calldata in `data`, /// and store the `abi.encode` formatted results of each `DELEGATECALL` into `results`. /// If any of the `DELEGATECALL`s reverts, the entire context is reverted, /// and the error is bubbled up. /// /// This function is deliberately made non-payable to guard against double-spending. /// (See: https://www.paradigm.xyz/2021/08/two-rights-might-make-a-wrong) /// /// For efficiency, this function will directly return the results, terminating the context. /// If called internally, it must be called at the end of a function /// that returns `(bytes[] memory)`. function multicall(bytes[] calldata data) public virtual returns (bytes[] memory) { assembly { mstore(0x00, 0x20) mstore(0x20, data.length) // Store `data.length` into `results`. // Early return if no data. if iszero(data.length) { return(0x00, 0x40) } let results := 0x40 // `shl` 5 is equivalent to multiplying by 0x20. let end := shl(5, data.length) // Copy the offsets from calldata into memory. calldatacopy(0x40, data.offset, end) // Offset into `results`. let resultsOffset := end // Pointer to the end of `results`. end := add(results, end) for {} 1 {} { // The offset of the current bytes in the calldata. let o := add(data.offset, mload(results)) let m := add(resultsOffset, 0x40) // Copy the current bytes from calldata to the memory. calldatacopy( m, add(o, 0x20), // The offset of the current bytes' bytes. calldataload(o) // The length of the current bytes. ) if iszero(delegatecall(gas(), address(), m, calldataload(o), codesize(), 0x00)) { // Bubble up the revert if the delegatecall reverts. returndatacopy(0x00, 0x00, returndatasize()) revert(0x00, returndatasize()) } // Append the current `resultsOffset` into `results`. mstore(results, resultsOffset) results := add(results, 0x20) // Append the `returndatasize()`, and the return data. mstore(m, returndatasize()) returndatacopy(add(m, 0x20), 0x00, returndatasize()) // Advance the `resultsOffset` by `returndatasize() + 0x20`, // rounded up to the next multiple of 32. resultsOffset := and(add(add(resultsOffset, returndatasize()), 0x3f), 0xffffffffffffffe0) if iszero(lt(results, end)) { break } } return(0x00, add(resultsOffset, 0x40)) } } }
// 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 {ICore} from "./interface/ICore.sol"; import {IInstallationCallback} from "./interface/IInstallationCallback.sol"; import {IModule} from "./interface/IModule.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 Core is ICore, 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 a module is installed. event ModuleInstalled(address caller, address implementation, address installedModule); /// @notice Emitted when a 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: IModule(implementation).getModuleConfig()}); } } /*////////////////////////////////////////////////////////////// EXTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /// @notice Installs a module contract. function installModule(address _module, bytes calldata _data) external payable onlyOwnerOrRoles(Role._INSTALLER_ROLE) { // Install module. _installModule(_module, _data); } /// @notice Uninstalls a 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 (interfaceId == 0x01ffc9a7) { // ERC165 Interface ID for ERC165 return true; } 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 a module contract. function _installModule(address _module, bytes memory _data) internal { if (!modules.add(_module)) { revert ModuleAlreadyInstalled(); } // Get module config. ModuleConfig memory config = IModule(_module).getModuleConfig(); // Check: Core 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 a 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 = IModule(_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 a 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(); } if (callbackFunction.implementation != address(0)) { (success, returndata) = callbackFunction.implementation.delegatecall(_abiEncodedCalldata); if (!success) { _revert(returndata, CallbackExecutionReverted.selector); } } else { // Get callback mode -- required or not required. SupportedCallbackFunction[] memory functions = getSupportedCallbackFunctions(); uint256 len = functions.length; for (uint256 i = 0; i < len; i++) { if (functions[i].selector == _selector) { if (functions[i].mode == CallbackMode.REQUIRED) { revert CallbackFunctionRequired(); } break; } } } } /// @dev Calls a 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(); } if (callbackFunction.implementation != address(0)) { (success, returndata) = address(this).staticcall(_abiEncodedCalldata); if (!success) { _revert(returndata, CallbackExecutionReverted.selector); } } else { // Get callback mode -- required or not required. SupportedCallbackFunction[] memory functions = getSupportedCallbackFunctions(); uint256 len = functions.length; for (uint256 i = 0; i < len; i++) { if (functions[i].selector == _selector) { if (functions[i].mode == CallbackMode.REQUIRED) { revert CallbackFunctionRequired(); } break; } } } } /// @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; contract BeforeApproveCallbackERC20 { /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ error BeforeApproveCallbackERC20NotImplemented(); /*////////////////////////////////////////////////////////////// EXTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /** * @notice The beforeApproveERC20 hook that is called by a core token before approving tokens. * * @param _from The address that is approving tokens. * @param _to The address that is being approved. * @param _amount The amount of tokens being approved. * @return result Abi encoded bytes result of the hook. */ function beforeApproveERC20(address _from, address _to, uint256 _amount) external virtual returns (bytes memory result) { revert BeforeApproveCallbackERC20NotImplemented(); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; contract BeforeBurnCallbackERC20 { /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ error BeforeBurnCallbackERC20NotImplemented(); /*////////////////////////////////////////////////////////////// EXTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /** * @notice The beforeBurnERC20 hook that is called by a core token before burning tokens. * * @param _from The address whose tokens are being burned. * @param _amount The amount of tokens being burned. * @param _data The encoded arguments for the beforeBurn hook. * @return result Abi encoded bytes result of the hook. */ function beforeBurnERC20(address _from, uint256 _amount, bytes memory _data) external payable virtual returns (bytes memory result) { revert BeforeBurnCallbackERC20NotImplemented(); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; contract BeforeMintCallbackERC20 { /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ error BeforeMintCallbackERC20NotImplemented(); /*////////////////////////////////////////////////////////////// EXTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /** * @notice The beforeMintERC20 hook that is called by a core token before minting tokens. * * @param _to The address to mint tokens to. * @param _amount The amount of tokens to mint. * @param _data Optional extra data passed to the hook. * @return result Abi encoded bytes result of the hook. */ function beforeMintERC20(address _to, uint256 _amount, bytes memory _data) external payable virtual returns (bytes memory result) { revert BeforeMintCallbackERC20NotImplemented(); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; contract BeforeMintWithSignatureCallbackERC20 { /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ error BeforeMintWithSignatureCallbackERC20NotImplemented(); /*////////////////////////////////////////////////////////////// EXTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /** * @notice The beforeMintWithSignatureERC20 hook that is called by a core token before minting tokens. * * @param _to The address that is minting tokens. * @param _amount The amount of tokens to mint. * @param _data Optional extra data passed to the hook. * @param _signer The address that signed the minting request. * @return result Abi encoded bytes result of the hook. */ function beforeMintWithSignatureERC20(address _to, uint256 _amount, bytes memory _data, address _signer) external payable virtual returns (bytes memory result) { revert BeforeMintWithSignatureCallbackERC20NotImplemented(); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; contract BeforeTransferCallbackERC20 { /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ error BeforeTransferCallbackERC20NotImplemented(); /*////////////////////////////////////////////////////////////// EXTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /** * @notice The beforeTransferERC20 hook that is called by a core token before transferring tokens. * * @param _from The address that is transferring tokens. * @param _to The address that is receiving tokens. * @param _amount The amount of tokens being transferred. * @return result Abi encoded bytes result of the hook. */ function beforeTransferERC20(address _from, address _to, uint256 _amount) external virtual returns (bytes memory result) { revert BeforeTransferCallbackERC20NotImplemented(); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; import {Core} from "../../Core.sol"; import {ERC20} from "@solady/tokens/ERC20.sol"; import {ECDSA} from "@solady/utils/ECDSA.sol"; import {EIP712} from "@solady/utils/EIP712.sol"; import {Multicallable} from "@solady/utils/Multicallable.sol"; import {ReentrancyGuard} from "@solady/utils/ReentrancyGuard.sol"; import {IERC20} from "../../interface/IERC20.sol"; import {BeforeApproveCallbackERC20} from "../../callback/BeforeApproveCallbackERC20.sol"; import {BeforeBurnCallbackERC20} from "../../callback/BeforeBurnCallbackERC20.sol"; import {BeforeMintCallbackERC20} from "../../callback/BeforeMintCallbackERC20.sol"; import {BeforeMintWithSignatureCallbackERC20} from "../../callback/BeforeMintWithSignatureCallbackERC20.sol"; import {BeforeTransferCallbackERC20} from "../../callback/BeforeTransferCallbackERC20.sol"; contract ERC20Base is ERC20, Multicallable, Core, EIP712 { using ECDSA for bytes32; /*////////////////////////////////////////////////////////////// CONSTANTS //////////////////////////////////////////////////////////////*/ bytes32 private constant TYPEHASH_SIGNATURE_MINT_ERC20 = keccak256("MintRequestERC20(address to,uint256 amount,bytes data)"); /*////////////////////////////////////////////////////////////// STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The name of the token. string private name_; /// @notice The symbol of the token. string private symbol_; /// @notice The contract metadata URI of the contract. string private contractURI_; /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ /// @notice Emitted when the contract URI is updated. event ContractURIUpdated(); /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ function _initialize( string memory _name, string memory _symbol, string memory _contractURI, address _owner, address[] memory _modules, bytes[] memory _moduleInstallData ) internal { // Set contract metadata name_ = _name; symbol_ = _symbol; _setupContractURI(_contractURI); _initializeOwner(_owner); // Install and initialize modules require(_modules.length == _moduleInstallData.length); for (uint256 i = 0; i < _modules.length; i++) { _installModule(_modules[i], _moduleInstallData[i]); } } /*////////////////////////////////////////////////////////////// VIEW FUNCTIONS //////////////////////////////////////////////////////////////*/ /// @notice Returns the name of the token. function name() public view override returns (string memory) { return name_; } /// @notice Returns the symbol of the token. function symbol() public view override returns (string memory) { return symbol_; } /** * @notice Returns the contract URI of the contract. * @return uri The contract URI of the contract. */ function contractURI() external view returns (string memory) { return contractURI_; } function getSupportedCallbackFunctions() public pure override returns (SupportedCallbackFunction[] memory supportedCallbackFunctions) { supportedCallbackFunctions = new SupportedCallbackFunction[](5); supportedCallbackFunctions[0] = SupportedCallbackFunction({ selector: BeforeMintCallbackERC20.beforeMintERC20.selector, mode: CallbackMode.REQUIRED }); supportedCallbackFunctions[1] = SupportedCallbackFunction({ selector: BeforeMintWithSignatureCallbackERC20.beforeMintWithSignatureERC20.selector, mode: CallbackMode.REQUIRED }); supportedCallbackFunctions[2] = SupportedCallbackFunction({ selector: BeforeTransferCallbackERC20.beforeTransferERC20.selector, mode: CallbackMode.OPTIONAL }); supportedCallbackFunctions[3] = SupportedCallbackFunction({ selector: BeforeBurnCallbackERC20.beforeBurnERC20.selector, mode: CallbackMode.OPTIONAL }); supportedCallbackFunctions[4] = SupportedCallbackFunction({ selector: BeforeApproveCallbackERC20.beforeApproveERC20.selector, mode: CallbackMode.OPTIONAL }); } /// @notice Returns whether a given interface is implemented by the contract. function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165 || interfaceId == 0xe8a3d485 // ERC-7572 || interfaceId == 0x7f5828d0 // ERC-173 || interfaceId == type(IERC20).interfaceId || _supportsInterfaceViaModules(interfaceId); } /*////////////////////////////////////////////////////////////// EXTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /** * @notice Sets the contract URI of the contract. * @dev Only callable by contract admin. * @param contractURI The contract URI to set. */ function setContractURI(string memory contractURI) external onlyOwner { _setupContractURI(contractURI); } /** * @notice Mints tokens. Calls the beforeMint hook. * @dev Reverts if beforeMint hook is absent or unsuccessful. * @param to The address to mint the tokens to. * @param amount The amount of tokens to mint. * @param data ABI encoded data to pass to the beforeMintERC20 hook. */ function mint(address to, uint256 amount, bytes calldata data) external payable { _beforeMint(to, amount, data); _mint(to, amount); } /** * @notice Mints a token with a signature. Calls the beforeMint hook. * @dev Reverts if beforeMint hook is absent or unsuccessful. * @param to The address to mint the token to. * @param amount The amount of tokens to mint. * @param data ABI encoded data to pass to the beforeMint hook. * @param signature The signature produced from signing the minting request. */ function mintWithSignature(address to, uint256 amount, bytes calldata data, bytes memory signature) external payable { address signer = _hashTypedData( keccak256(abi.encode(TYPEHASH_SIGNATURE_MINT_ERC20, to, amount, keccak256(data))) ).recover(signature); _beforeMintWithSignature(to, amount, data, signer); _mint(to, amount); } /** * @notice Burns tokens. * @dev Calls the beforeBurn hook. Skips calling the hook if it doesn't exist. * @param from The address to burn tokens from. * @param amount The amount of tokens to burn. * @param data ABI encoded arguments to pass to the beforeBurnERC20 hook. */ function burn(address from, uint256 amount, bytes calldata data) external payable { _beforeBurn(from, amount, data); if (from != msg.sender) { _spendAllowance(from, msg.sender, amount); } _burn(from, amount); } /** * @notice Transfers tokens to a recipient. * @param to The address to transfer tokens to. * @param amount The quantity of tokens to transfer. */ function transfer(address to, uint256 amount) public override returns (bool) { _beforeTransfer(msg.sender, to, amount); return super.transfer(to, amount); } /** * @notice Transfers tokens from a sender to a recipient. * @param from The address to transfer tokens from. * @param to The address to transfer tokens to. * @param amount The quantity of tokens to transfer. */ function transferFrom(address from, address to, uint256 amount) public override returns (bool) { _beforeTransfer(from, to, amount); return super.transferFrom(from, to, amount); } /** * @notice Approves a spender to spend tokens on behalf of an owner. * @param spender The address to approve spending on behalf of the token owner. * @param amount The quantity of tokens to approve. */ function approve(address spender, uint256 amount) public override returns (bool) { _beforeApprove(msg.sender, spender, amount); return super.approve(spender, amount); } /** * @notice Sets allowance based on token owner's signed approval. * * See https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * @param owner The account approving the tokens * @param spender The address to approve * @param amount Amount of tokens to approve * @param deadline Deadline after which the approval is no longer valid * @param v Signature param * @param r Signature param * @param s Signature param */ function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public override { _beforeApprove(owner, spender, amount); super.permit(owner, spender, amount, deadline, v, r, s); } /*////////////////////////////////////////////////////////////// INTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /// @dev Sets contract URI function _setupContractURI(string memory _contractURI) internal { contractURI_ = _contractURI; emit ContractURIUpdated(); } /*////////////////////////////////////////////////////////////// CALLBACK INTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /// @dev Calls the beforeMint hook. function _beforeMint(address to, uint256 amount, bytes calldata data) internal virtual { _executeCallbackFunction( BeforeMintCallbackERC20.beforeMintERC20.selector, abi.encodeCall(BeforeMintCallbackERC20.beforeMintERC20, (to, amount, data)) ); } /// @dev Calls the beforeMint hook. function _beforeMintWithSignature(address to, uint256 amount, bytes calldata data, address signer) internal virtual { _executeCallbackFunction( BeforeMintWithSignatureCallbackERC20.beforeMintWithSignatureERC20.selector, abi.encodeCall( BeforeMintWithSignatureCallbackERC20.beforeMintWithSignatureERC20, (to, amount, data, signer) ) ); } /// @dev Calls the beforeTransfer hook, if installed. function _beforeTransfer(address from, address to, uint256 amount) internal virtual { _executeCallbackFunction( BeforeTransferCallbackERC20.beforeTransferERC20.selector, abi.encodeCall(BeforeTransferCallbackERC20.beforeTransferERC20, (from, to, amount)) ); } /// @dev Calls the beforeBurn hook, if installed. function _beforeBurn(address from, uint256 amount, bytes calldata data) internal virtual { _executeCallbackFunction( BeforeBurnCallbackERC20.beforeBurnERC20.selector, abi.encodeCall(BeforeBurnCallbackERC20.beforeBurnERC20, (from, amount, data)) ); } /// @dev Calls the beforeApprove hook, if installed. function _beforeApprove(address from, address to, uint256 amount) internal virtual { _executeCallbackFunction( BeforeApproveCallbackERC20.beforeApproveERC20.selector, abi.encodeCall(BeforeApproveCallbackERC20.beforeApproveERC20, (from, to, amount)) ); } /// @dev Returns the domain name and version for EIP712. function _domainNameAndVersion() internal pure override returns (string memory name, string memory version) { name = "ERC20Core"; version = "1"; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; import {IModuleConfig} from "./IModuleConfig.sol"; interface ICore 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; 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 IERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external 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 {IModuleConfig} from "./IModuleConfig.sol"; interface IModule 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": 10000 }, "evmVersion": "paris", "remappings": [ ":@erc721a-upgradeable/=lib/ERC721A-Upgradeable/contracts/", ":@erc721a/=lib/erc721a/contracts/", ":@limitbreak/creator-token-standards/=lib/creator-token-standards/src/", ":@limitbreak/permit-c/=lib/PermitC/src/", ":@opensea/tstorish/=lib/creator-token-standards/lib/tstorish/src/", ":@openzeppelin/=lib/creator-token-contracts/node_modules/@openzeppelin/", ":@rari-capital/solmate/=lib/PermitC/lib/solmate/", ":@solady/=lib/solady/src/", ":ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/", ":ERC721A/=lib/creator-token-standards/lib/ERC721A/contracts/", ":PermitC/=lib/PermitC/", ":creator-token-contracts/=lib/creator-token-contracts/contracts/", ":creator-token-standards/=lib/creator-token-standards/", ":ds-test/=lib/forge-std/lib/ds-test/src/", ":erc4626-tests/=lib/PermitC/lib/openzeppelin-contracts/lib/erc4626-tests/", ":erc721a/=lib/erc721a/contracts/", ":forge-gas-metering/=lib/PermitC/lib/forge-gas-metering/", ":forge-std/=lib/forge-std/src/", ":hardhat/=lib/creator-token-contracts/node_modules/hardhat/", ":murky/=lib/creator-token-standards/lib/murky/", ":openzeppelin-contracts/=lib/creator-token-standards/lib/openzeppelin-contracts/", ":openzeppelin/=lib/PermitC/lib/openzeppelin-contracts/contracts/", ":solady/=lib/solady/src/", ":solmate/=lib/PermitC/lib/solmate/src/", ":tstorish/=lib/creator-token-standards/lib/tstorish/src/" ], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AllowanceOverflow","type":"error"},{"inputs":[],"name":"AllowanceUnderflow","type":"error"},{"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":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidPermit","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":"NotInitializing","type":"error"},{"inputs":[],"name":"PermitExpired","type":"error"},{"inputs":[],"name":"Reentrancy","type":"error"},{"inputs":[],"name":"TotalSupplyOverflow","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[],"name":"ContractURIUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","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":"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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"result","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"burn","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","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 ICore.InstalledModule[]","name":"_installedModules","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedCallbackFunctions","outputs":[{"components":[{"internalType":"bytes4","name":"selector","type":"bytes4"},{"internalType":"enum ICore.CallbackMode","name":"mode","type":"uint8"}],"internalType":"struct ICore.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":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_contractURI","type":"string"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address[]","name":"_modules","type":"address[]"},{"internalType":"bytes[]","name":"_moduleInstallData","type":"bytes[]"}],"name":"initialize","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_module","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"installModule","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"mintWithSignature","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","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":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","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":"string","name":"contractURI","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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
61012060405234801561001157600080fd5b50306080524660a05260608061005b60408051808201825260098152684552433230436f726560b81b602080830191909152825180840190935260018352603160f81b9083015291565b815160209283012081519183019190912060c082905260e0819052604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8152938401929092529082015246606082015230608082015260a0902061010052506100c790506100cc565b61012e565b63409feecd19805460018116156100eb5763f92ee8a96000526004601cfd5b8160c01c808260011c14610129578060011b8355806020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b505050565b60805160a05160c05160e0516101005161455f61017260003960006115fc015260006116b601526000611690015260006116400152600061161d015261455f6000f3fe6080604052600436106102855760003560e01c806370a082311161015357806395d89b41116100cb578063e8a3d4851161007f578063f147db8a11610064578063f147db8a14610866578063f2fde38b14610888578063fee81cf41461089b57610285565b8063e8a3d4851461083e578063f04e283e1461085357610285565b8063ac9650d8116100b0578063ac9650d8146107bb578063d505accf146107e8578063dd62ed3e1461080857610285565b806395d89b4114610786578063a9059cbb1461079b57610285565b806384b0196e116101225780638da798da116101075780638da798da14610740578063938e3d7b1461075357806394d008ef1461077357610285565b806384b0196e146106c45780638da5cb5b146106ec57610285565b806370a082311461064357806370c109cd14610676578063715018a6146106895780637ecebe001461069157610285565b8063256929621161020157806344d17187116101b5578063514e62fc1161019a578063514e62fc146105f157806354d1f13d1461062857806362835ade1461063057610285565b806344d17187146105cb5780634a4ee7b1146105de57610285565b8063313ce567116101e6578063313ce567146105785780633644e515146105945780633e429396146105a957610285565b8063256929621461053d5780632de948071461054557610285565b806318160ddd116102585780631c10893f1161023d5780631c10893f146104d35780631cd64df4146104e657806323b872dd1461051d57610285565b806318160ddd14610499578063183a4f6e146104c057610285565b806301ffc9a71461040f57806306fdde0314610444578063095ea7b3146104665780630f7d365214610486575b600080357fffffffff000000000000000000000000000000000000000000000000000000001681526002602081815260408084208151606081018352815473ffffffffffffffffffffffffffffffffffffffff168152600180830154948201949094529381015490929184019160ff9091169081111561030757610307613358565b600181111561031857610318613358565b905250805190915073ffffffffffffffffffffffffffffffffffffffff1661036c576040517fb6b8317700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008160400151600181111561038457610384613358565b036103c7573330146103c2576040517f295dcf7800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610402565b6001816040015160018111156103df576103df613358565b1480156103f0575060008160200151115b156104025761040281602001516108ce565b805161040d9061091f565b005b34801561041b57600080fd5b5061042f61042a3660046133b5565b61095a565b60405190151581526020015b60405180910390f35b34801561045057600080fd5b50610459610a9a565b60405161043b9190613422565b34801561047257600080fd5b5061042f61048136600461345e565b610b2c565b61040d610494366004613617565b610b4a565b3480156104a557600080fd5b506805345cdf77eb68f44c545b60405190815260200161043b565b61040d6104ce3660046136a0565b610c0c565b61040d6104e136600461345e565b610c16565b3480156104f257600080fd5b5061042f61050136600461345e565b638b78c6d8600c90815260009290925260209091205481161490565b34801561052957600080fd5b5061042f6105383660046136b9565b610c2c565b61040d610c4c565b34801561055157600080fd5b506104b26105603660046136f6565b638b78c6d8600c908152600091909152602090205490565b34801561058457600080fd5b506040516012815260200161043b565b3480156105a057600080fd5b506104b2610c9c565b3480156105b557600080fd5b506105be610d19565b60405161043b91906137cf565b61040d6105d9366004613997565b610e5f565b61040d6105ec36600461345e565b610ea3565b3480156105fd57600080fd5b5061042f61060c36600461345e565b638b78c6d8600c90815260009290925260209091205416151590565b61040d610eb5565b61040d61063e366004613b0c565b610ef1565b34801561064f57600080fd5b506104b261065e3660046136f6565b6387a211a2600c908152600091909152602090205490565b61040d610684366004613c07565b610f90565b61040d610ffa565b34801561069d57600080fd5b506104b26106ac3660046136f6565b6338377508600c908152600091909152602090205490565b3480156106d057600080fd5b506106d961100e565b60405161043b9796959493929190613c5a565b3480156106f857600080fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff909116815260200161043b565b61040d61074e366004613c07565b6110b7565b34801561075f57600080fd5b5061040d61076e366004613d1b565b611121565b61040d610781366004613997565b611132565b34801561079257600080fd5b50610459611148565b3480156107a757600080fd5b5061042f6107b636600461345e565b611157565b3480156107c757600080fd5b506107db6107d6366004613d50565b61116e565b60405161043b9190613dc7565b3480156107f457600080fd5b5061040d610803366004613e3e565b6111ef565b34801561081457600080fd5b506104b2610823366004613eb1565b602052637f5e9f20600c908152600091909152603490205490565b34801561084a57600080fd5b50610459611209565b61040d6108613660046136f6565b611218565b34801561087257600080fd5b5061087b611255565b60405161043b9190613ee4565b61040d6108963660046136f6565b61144a565b3480156108a757600080fd5b506104b26108b63660046136f6565b63389a75e1600c908152600091909152602090205490565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff7487392754331461091c57638b78c6d8600c5233600052806020600c20541661091c576382b429006000526004601cfd5b50565b6040805136810190915236600082376000803683855af490506109483d60408051918201905290565b3d6000823e81610956573d81fd5b3d81f35b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614806109ed57507fe8a3d485000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b80610a3957507f7f5828d0000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b80610a8557507fffffffff0000000000000000000000000000000000000000000000000000000082167f36372b0700000000000000000000000000000000000000000000000000000000145b80610a945750610a9482611471565b92915050565b606060038054610aa990613f90565b80601f0160208091040260200160405190810160405280929190818152602001828054610ad590613f90565b8015610b225780601f10610af757610100808354040283529160200191610b22565b820191906000526020600020905b815481529060010190602001808311610b0557829003601f168201915b5050505050905090565b6000610b393384846114ec565b610b4383836115a7565b9392505050565b6000610beb82610be57fde142acd02ed59c31a431f5c6143024510c10aa45a1296dcd068c6981de86e8e89898989604051610b86929190613fe3565b604051908190038120610bca9493929160200193845273ffffffffffffffffffffffffffffffffffffffff9290921660208401526040830152606082015260800190565b604051602081830303815290604052805190602001206115fa565b90611712565b9050610bfa86868686856117bc565b610c04868661183d565b505050505050565b61091c33826118bc565b610c1e6118c8565b610c2882826118fe565b5050565b6000610c3984848461190a565b610c448484846119be565b949350505050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b600080610ca7610a9a565b8051906020012090506040517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81528160208201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604082015246606082015230608082015260a081209250505090565b60606000610d276000611a7c565b90508067ffffffffffffffff811115610d4257610d426134d1565b604051908082528060200260200182016040528015610d7b57816020015b610d686132f7565b815260200190600190039081610d605790505b50915060005b81811015610e5a576000610d958183611ace565b905060405180604001604052808273ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e09573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e319190810190614178565b815250848381518110610e4657610e4661427e565b602090810291909101015250600101610d81565b505090565b610e6b84848484611b41565b73ffffffffffffffffffffffffffffffffffffffff84163314610e9357610e93843385611bc0565b610e9d8484611c00565b50505050565b610eab6118c8565b610c2882826118bc565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf6011328054600382558015610f435760018160011c14303b10610f3a5763f92ee8a96000526004601cfd5b818160ff1b1b91505b50610f52878787878787611c84565b8015610f87576002815560016020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b50505050505050565b7f8000000000000000000000000000000000000000000000000000000000000000610fba816108ce565b610e9d8484848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d0e92505050565b6110026118c8565b61100c6000612129565b565b7f0f0000000000000000000000000000000000000000000000000000000000000060608060008080836110a5604080518082018252600981527f4552433230436f726500000000000000000000000000000000000000000000006020808301919091528251808401909352600183527f31000000000000000000000000000000000000000000000000000000000000009083015291565b97989097965046955030945091925090565b7f80000000000000000000000000000000000000000000000000000000000000006110e1816108ce565b610e9d8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061218f92505050565b6111296118c8565b61091c8161298b565b61113e848484846129c4565b610e9d848461183d565b606060048054610aa990613f90565b600061116433848461190a565b610b438383612a43565b6060602060005281602052816111845760406000f35b60408260051b8085604037818101905b82518601604082018135602083018237600038833583305af46111bb573d6000803e3d6000fd5b8285526020850194503d81523d6000602083013e50503d01603f0167ffffffffffffffe01681831061119457604081016000f35b6111fa8787876114ec565b610f8787878787878787612abe565b606060058054610aa990613f90565b6112206118c8565b63389a75e1600c52806000526020600c20805442111561124857636f5e88186000526004601cfd5b6000905561091c81612129565b60408051600580825260c08201909252606091816020015b604080518082019091526000808252602082015281526020019060019003908161126d57905050604080518082019091527f7ce7cf07000000000000000000000000000000000000000000000000000000008152909150602081016001815250816000815181106112e0576112e061427e565b602090810291909101810191909152604080518082019091527f89c154b50000000000000000000000000000000000000000000000000000000081529081016001815250816001815181106113375761133761427e565b602090810291909101810191909152604080518082019091527f98074eed00000000000000000000000000000000000000000000000000000000815290810160008152508160028151811061138e5761138e61427e565b602090810291909101810191909152604080518082019091527f7fda8dc10000000000000000000000000000000000000000000000000000000081529081016000815250816003815181106113e5576113e561427e565b602090810291909101810191909152604080518082019091527f837406a600000000000000000000000000000000000000000000000000000000815290810160008152508160048151811061143c5761143c61427e565b602002602001018190525090565b6114526118c8565b8060601b61146857637448fbae6000526004601cfd5b61091c81612129565b60007fffffffff0000000000000000000000000000000000000000000000000000000080831690036114a557506000919050565b7fffffffff000000000000000000000000000000000000000000000000000000008216600090815260016020526040902054156114e457506001919050565b506000919050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526115a0907f837406a6000000000000000000000000000000000000000000000000000000009060840160408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f837406a600000000000000000000000000000000000000000000000000000000179052612c58565b5050505050565b600082602052637f5e9f20600c5233600052816034600c205581600052602c5160601c337f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560206000a350600192915050565b7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000030147f00000000000000000000000000000000000000000000000000000000000000004614166116ed5750604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81527f000000000000000000000000000000000000000000000000000000000000000060208201527f00000000000000000000000000000000000000000000000000000000000000009181019190915246606082015230608082015260a090205b67190100000000000060005280601a5281603a52604260182090506000603a52919050565b604051600190836000526020830151604052604083510361176757604083015160ff81901c601b016020527f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1660605261178d565b604183510361178857606083015160001a602052604083015160605261178d565b600091505b6020600160806000855afa5191503d6117ae57638baa579f6000526004601cfd5b600060605260405292915050565b610f876389c154b560e01b86868686866040516024016117e09594939291906142d8565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f89c154b500000000000000000000000000000000000000000000000000000000179052612c58565b6805345cdf77eb68f44c54818101818110156118615763e5cfe9576000526004601cfd5b806805345cdf77eb68f44c5550506387a211a2600c52816000526020600c208181540181555080602052600c5160601c60007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a35050565b610c2882826000612f3c565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff7487392754331461100c576382b429006000526004601cfd5b610c2882826001612f3c565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526115a0907f98074eed000000000000000000000000000000000000000000000000000000009060840160408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f98074eed00000000000000000000000000000000000000000000000000000000179052612c58565b60008360601b33602052637f5e9f208117600c526034600c20805460018101156119fe57808511156119f8576313be252b6000526004601cfd5b84810382555b50506387a211a28117600c526020600c20805480851115611a275763f4d678b86000526004601cfd5b84810382555050836000526020600c208381540181555082602052600c5160601c8160601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3505060019392505050565b63978aab9260045260008181526024812080548060a01b60a01c8060011c9350808260601c1517611ac657600193508383015415611ac657600293508383015415611ac657600393505b505050919050565b63978aab926004526000828152602481208281015460601c915068fbb67fda52d4bfb8bf82141582029150611b0284611a7c565b8310611b3a576040517f4e23d03500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5092915050565b610c04637fda8dc160e01b85858585604051602401611b639493929190614336565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f7fda8dc100000000000000000000000000000000000000000000000000000000179052612c58565b81602052637f5e9f20600c52826000526034600c20805460018101156115a05780831115611bf6576313be252b6000526004601cfd5b9190910390555050565b6387a211a2600c52816000526020600c20805480831115611c295763f4d678b86000526004601cfd5b82900390556805345cdf77eb68f44c80548290039055600081815273ffffffffffffffffffffffffffffffffffffffff83167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602083a35050565b6003611c9087826143bd565b506004611c9d86826143bd565b50611ca78461298b565b611cb083612f95565b8051825114611cbe57600080fd5b60005b8251811015610f8757611d06838281518110611cdf57611cdf61427e565b6020026020010151838381518110611cf957611cf961427e565b602002602001015161218f565b600101611cc1565b611d19600083612ff9565b611d4f576040517f2a6f792900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611d9c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611dc49190810190614178565b60408101515190915060005b81811015611e6357600180600085604001518481518110611df357611df361427e565b60200260200101517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681526020019081526020016000206000828254611e5691906144e7565b9091555050600101611dd0565b5060808201515160005b81811015611f2c576002600085608001518381518110611e8f57611e8f61427e565b602090810291909101810151517fffffffff00000000000000000000000000000000000000000000000000000000168252810191909152604001600090812080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560018082019290925560020180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905501611e6d565b5060608301515160005b81811015611ff5576002600086606001518381518110611f5857611f5861427e565b602090810291909101810151517fffffffff00000000000000000000000000000000000000000000000000000000168252810191909152604001600090812080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560018082019290925560020180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905501611f36565b508351156120cc578573ffffffffffffffffffffffffffffffffffffffff16856040516024016120259190613422565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8a91b0e3000000000000000000000000000000000000000000000000000000001790525161208891906144fa565b600060405180830381855af49150503d80600081146120c3576040519150601f19603f3d011682016040523d82523d6000602084013e6120c8565b606091505b5050505b6040805133815273ffffffffffffffffffffffffffffffffffffffff8816602082018190528183015290517fef3b2e20acbb62d61d782c5449bd73d3970cb9be1050a6ad6f846b2cbe21c03a9181900360600190a1505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b61219a600083613167565b6121d0576040517f24c377e200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561221d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526122459190810190614178565b905080602001515160001461231a5760005b8160200151518110156123185761228a8260200151828151811061227d5761227d61427e565b602002602001015161095a565b61231057816020015181815181106122a4576122a461427e565b60200260200101516040517f56ba3a7f00000000000000000000000000000000000000000000000000000000815260040161230791907fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b60405180910390fd5b600101612257565b505b60408101515160005b818110156123b6576001806000856040015184815181106123465761234661427e565b60200260200101517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060008282546123a99190614516565b9091555050600101612323565b5060006123c1611255565b80516060850151519192509060005b81811015612658576000866060015182815181106123f0576123f061427e565b60209081029190910181015180517fffffffff00000000000000000000000000000000000000000000000000000000166000908152600290925260409091205490915073ffffffffffffffffffffffffffffffffffffffff1615612480576040517f4cc04b1700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805b858110156125035782600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168782815181106124c2576124c261427e565b6020026020010151600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036124fb5760019150612503565b600101612484565b508061253b576040517fae7ff83e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405180606001604052808b73ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000600181111561257c5761257c613358565b905282517fffffffff0000000000000000000000000000000000000000000000000000000016600090815260026020818152604092839020845181547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90911617815590840151600180830191909155928401519181018054919390917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690838181111561264357612643613358565b021790555050600190930192506123d0915050565b5060808501515160005b8181101561281f576000876080015182815181106126825761268261427e565b60209081029190910181015180517fffffffff00000000000000000000000000000000000000000000000000000000166000908152600290925260409091205490915073ffffffffffffffffffffffffffffffffffffffff1615612712576040517f92bffc6500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160608101825273ffffffffffffffffffffffffffffffffffffffff8c168152602083810151908201529081016001905281517fffffffff0000000000000000000000000000000000000000000000000000000016600090815260026020818152604092839020845181547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90911617815590840151600180830191909155928401519181018054919390917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690838181111561280b5761280b613358565b021790555050600190920191506126629050565b5085511561292c576000808973ffffffffffffffffffffffffffffffffffffffff16896040516024016128529190613422565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f6d61fe7000000000000000000000000000000000000000000000000000000000179052516128b591906144fa565b600060405180830381855af49150503d80600081146128f0576040519150601f19603f3d011682016040523d82523d6000602084013e6128f5565b606091505b50915091508161292957612929817f3fcb9045000000000000000000000000000000000000000000000000000000006132de565b50505b6040805133815273ffffffffffffffffffffffffffffffffffffffff8a16602082018190528183015290517fbcd03fe408dcc45614e803cbab9f500dddff61b17380b993e76d30398da472299181900360600190a15050505050505050565b600561299782826143bd565b506040517fa5d4097edda6d87cb9329af83fb3712ef77eeb13738ffe43cc35a4ce305ad96290600090a150565b610c04637ce7cf0760e01b858585856040516024016129e69493929190614336565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f7ce7cf0700000000000000000000000000000000000000000000000000000000179052612c58565b60006387a211a2600c52336000526020600c20805480841115612a6e5763f4d678b86000526004601cfd5b83810382555050826000526020600c208281540181555081602052600c5160601c337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a350600192915050565b6000612ac8610a9a565b80519060200120905084421115612ae757631a15a3cc6000526004601cfd5b6040518860601b60601c98508760601b60601c975065383775081901600e52886000526020600c2080547f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f83528360208401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604084015246606084015230608084015260a08320602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c983528a60208401528960408401528860608401528060808401528760a084015260c08320604e526042602c206000528660ff1660205285604052846060526020806080600060015afa8b3d5114612bf35763ddafbaef6000526004601cfd5b019055777f5e9f20000000000000000000000000000000000000000088176040526034602c2087905587897f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925602060608501a360405250506000606052505050505050565b600060603068929eee149b4bd212685403612c7b5763ab143c066000526004601cfd5b3068929eee149b4bd21268557fffffffff00000000000000000000000000000000000000000000000000000000841660009081526002602081815260408084208151606081018352815473ffffffffffffffffffffffffffffffffffffffff168152600180830154948201949094529381015490929184019160ff90911690811115612d0957612d09613358565b6001811115612d1a57612d1a613358565b9052509050600081604001516001811115612d3757612d37613358565b14612d6e576040517fae7ff83e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805173ffffffffffffffffffffffffffffffffffffffff1615612e2e57806000015173ffffffffffffffffffffffffffffffffffffffff1684604051612db491906144fa565b600060405180830381855af49150503d8060008114612def576040519150601f19603f3d011682016040523d82523d6000602084013e612df4565b606091505b50909350915082612e2957612e29827f3fcb9045000000000000000000000000000000000000000000000000000000006132de565b612f23565b6000612e38611255565b805190915060005b81811015612f1f57877bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916838281518110612e7a57612e7a61427e565b6020026020010151600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603612f17576001838281518110612ebe57612ebe61427e565b6020026020010151602001516001811115612edb57612edb613358565b03612f12576040517f2d51781900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612f1f565b600101612e40565b5050505b503868929eee149b4bd21268559250929050565b505050565b638b78c6d8600c52826000526020600c20805483811783612f5e575080841681185b80835580600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26600080a3505050505050565b73ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739278190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b63978aab9260045260008281526024812073ffffffffffffffffffffffffffffffffffffffff92909216917fffffffffffffffffffffffffffffffffffffffffffffff04498025ad2b40474183016130595763f5a267f16000526004601cfd5b8261306b5768fbb67fda52d4bfb8bf92505b80546bffffffffffffffffffffffff8116806130ee5760019350848260601c036130a95760018301805484556002840180549091556000905561315e565b84600184015460601c036130cb5760028301805460018501556000905561315e565b84600284015460601c036130e5576000600284015561315e565b6000935061315e565b8260205284600052604060002080548061310957505061315e565b60018360011c039250826001820314613141578285015460601c8060601b600183038701556000848701558060005250806040600020555b5060018260011b17845460601c60601b1784556000815550600193505b50505092915050565b63978aab9260045260008281526024812073ffffffffffffffffffffffffffffffffffffffff92909216917fffffffffffffffffffffffffffffffffffffffffffffff04498025ad2b40474183016131c75763f5a267f16000526004601cfd5b826131d95768fbb67fda52d4bfb8bf92505b80546bffffffffffffffffffffffff811682602052806132a1578160601c8061320c578560601b8455600194505061315e565b858103613219575061315e565b600184015460601c8061323a578660601b600186015560019550505061315e565b86810361324857505061315e565b600285015460601c8061326a578760601b60028701556001965050505061315e565b8781036132795750505061315e565b6000928352604080842060019055918352818320600290558252902060039055506007908117905b84600052604060002080546132d4578160011c91508560601b82850155816001018155826002018455600194505061315e565b5050505092915050565b8151156132ed57815182602001fd5b806000526004601cfd5b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016133536040518060a00160405280600015158152602001606081526020016060815260200160608152602001606081525090565b905290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7fffffffff000000000000000000000000000000000000000000000000000000008116811461091c57600080fd5b6000602082840312156133c757600080fd5b8135610b4381613387565b60005b838110156133ed5781810151838201526020016133d5565b50506000910152565b6000815180845261340e8160208601602086016133d2565b601f01601f19169290920160200192915050565b602081526000610b4360208301846133f6565b803573ffffffffffffffffffffffffffffffffffffffff8116811461345957600080fd5b919050565b6000806040838503121561347157600080fd5b61347a83613435565b946020939093013593505050565b60008083601f84011261349a57600080fd5b50813567ffffffffffffffff8111156134b257600080fd5b6020830191508360208285010111156134ca57600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516020810167ffffffffffffffff81118282101715613523576135236134d1565b60405290565b6040805190810167ffffffffffffffff81118282101715613523576135236134d1565b60405160a0810167ffffffffffffffff81118282101715613523576135236134d1565b604051601f8201601f1916810167ffffffffffffffff81118282101715613598576135986134d1565b604052919050565b600082601f8301126135b157600080fd5b81356020830160008067ffffffffffffffff8411156135d2576135d26134d1565b50601f8301601f19166020016135e78161356f565b9150508281528583830111156135fc57600080fd5b82826020830137600092810160200192909252509392505050565b60008060008060006080868803121561362f57600080fd5b61363886613435565b945060208601359350604086013567ffffffffffffffff81111561365b57600080fd5b61366788828901613488565b909450925050606086013567ffffffffffffffff81111561368757600080fd5b613693888289016135a0565b9150509295509295909350565b6000602082840312156136b257600080fd5b5035919050565b6000806000606084860312156136ce57600080fd5b6136d784613435565b92506136e560208501613435565b929592945050506040919091013590565b60006020828403121561370857600080fd5b610b4382613435565b600081518084526020840193506020830160005b828110156137655781517fffffffff0000000000000000000000000000000000000000000000000000000016865260209586019590910190600101613725565b5093949350505050565b600081518084526020840193506020830160005b8281101561376557815180517fffffffff000000000000000000000000000000000000000000000000000000001687526020908101518188015260409096019590910190600101613783565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b8281101561398b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0878603018452815173ffffffffffffffffffffffffffffffffffffffff81511686526020810151905060406020870152805115156040870152602081015160a0606088015261387260e0880182613711565b905060408201517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08883030160808901526138ad8282613711565b60608401518982037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00160a08b0152805180835260209182019450600093509101905b80831015613936577fffffffff000000000000000000000000000000000000000000000000000000008451511682526020820191506020840193506001830192506138f0565b50608084015193507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08982030160c08a0152613972818561376f565b98505050602095860195939093019250506001016137f7565b50929695505050505050565b600080600080606085870312156139ad57600080fd5b6139b685613435565b935060208501359250604085013567ffffffffffffffff8111156139d957600080fd5b6139e587828801613488565b95989497509550505050565b600067ffffffffffffffff821115613a0b57613a0b6134d1565b5060051b60200190565b600082601f830112613a2657600080fd5b8135613a39613a34826139f1565b61356f565b8082825260208201915060208360051b860101925085831115613a5b57600080fd5b602085015b83811015613a7f57613a7181613435565b835260209283019201613a60565b5095945050505050565b600082601f830112613a9a57600080fd5b8135613aa8613a34826139f1565b8082825260208201915060208360051b860101925085831115613aca57600080fd5b602085015b83811015613a7f57803567ffffffffffffffff811115613aee57600080fd5b613afd886020838a01016135a0565b84525060209283019201613acf565b60008060008060008060c08789031215613b2557600080fd5b863567ffffffffffffffff811115613b3c57600080fd5b613b4889828a016135a0565b965050602087013567ffffffffffffffff811115613b6557600080fd5b613b7189828a016135a0565b955050604087013567ffffffffffffffff811115613b8e57600080fd5b613b9a89828a016135a0565b945050613ba960608801613435565b9250608087013567ffffffffffffffff811115613bc557600080fd5b613bd189828a01613a15565b92505060a087013567ffffffffffffffff811115613bee57600080fd5b613bfa89828a01613a89565b9150509295509295509295565b600080600060408486031215613c1c57600080fd5b613c2584613435565b9250602084013567ffffffffffffffff811115613c4157600080fd5b613c4d86828701613488565b9497909650939450505050565b7fff000000000000000000000000000000000000000000000000000000000000008816815260e060208201526000613c9560e08301896133f6565b8281036040840152613ca781896133f6565b6060840188905273ffffffffffffffffffffffffffffffffffffffff8716608085015260a0840186905283810360c08501528451808252602080870193509091019060005b81811015613d0a578351835260209384019390920191600101613cec565b50909b9a5050505050505050505050565b600060208284031215613d2d57600080fd5b813567ffffffffffffffff811115613d4457600080fd5b610c44848285016135a0565b60008060208385031215613d6357600080fd5b823567ffffffffffffffff811115613d7a57600080fd5b8301601f81018513613d8b57600080fd5b803567ffffffffffffffff811115613da257600080fd5b8560208260051b8401011115613db757600080fd5b6020919091019590945092505050565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b8281101561398b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0878603018452613e298583516133f6565b94506020938401939190910190600101613def565b600080600080600080600060e0888a031215613e5957600080fd5b613e6288613435565b9650613e7060208901613435565b95506040880135945060608801359350608088013560ff81168114613e9457600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613ec457600080fd5b613ecd83613435565b9150613edb60208401613435565b90509250929050565b602080825282518282018190526000918401906040840190835b81811015613f8557835180517fffffffff000000000000000000000000000000000000000000000000000000001684526020015160028110613f69577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6020848101919091529390930192604090920191600101613efe565b509095945050505050565b600181811c90821680613fa457607f821691505b602082108103613fdd577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b8183823760009101908152919050565b8051801515811461345957600080fd5b600082601f83011261401457600080fd5b8151614022613a34826139f1565b8082825260208201915060208360051b86010192508583111561404457600080fd5b602085015b83811015613a7f57805161405c81613387565b835260209283019201614049565b600082601f83011261407b57600080fd5b8151614089613a34826139f1565b8082825260208201915060208360051b8601019250858311156140ab57600080fd5b602085015b83811015613a7f57602081880312156140c857600080fd5b6140d0613500565b81516140db81613387565b81528352602092830192016140b0565b600082601f8301126140fc57600080fd5b815161410a613a34826139f1565b8082825260208201915060208360061b86010192508583111561412c57600080fd5b602085015b83811015613a7f576040818803121561414957600080fd5b614151613529565b815161415c81613387565b8152602082810151818301529084529290920191604001614131565b60006020828403121561418a57600080fd5b815167ffffffffffffffff8111156141a157600080fd5b820160a081850312156141b357600080fd5b6141bb61354c565b6141c482613ff3565b8152602082015167ffffffffffffffff8111156141e057600080fd5b6141ec86828501614003565b602083015250604082015167ffffffffffffffff81111561420c57600080fd5b61421886828501614003565b604083015250606082015167ffffffffffffffff81111561423857600080fd5b6142448682850161406a565b606083015250608082015167ffffffffffffffff81111561426457600080fd5b614270868285016140eb565b608083015250949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8616815284602082015260806040820152600061430e6080830185876142ad565b905073ffffffffffffffffffffffffffffffffffffffff831660608301529695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061436c6060830184866142ad565b9695505050505050565b601f821115612f3757806000526020600020601f840160051c8101602085101561439d5750805b601f840160051c820191505b818110156115a057600081556001016143a9565b815167ffffffffffffffff8111156143d7576143d76134d1565b6143eb816143e58454613f90565b84614376565b6020601f82116001811461443d57600083156144075750848201515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600385901b1c1916600184901b1784556115a0565b600084815260208120601f198516915b8281101561446d578785015182556020948501946001909201910161444d565b50848210156144a957868401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b60f8161c191681555b50505050600190811b01905550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610a9457610a946144b8565b6000825161450c8184602087016133d2565b9190910192915050565b80820180821115610a9457610a946144b856fea264697066735822122097c0c5035ed26c1e10bd6c4bb1db4ef1abe7565a691f014e72ce13bb33e39a1864736f6c634300081a0033
Deployed Bytecode
0x6080604052600436106102855760003560e01c806370a082311161015357806395d89b41116100cb578063e8a3d4851161007f578063f147db8a11610064578063f147db8a14610866578063f2fde38b14610888578063fee81cf41461089b57610285565b8063e8a3d4851461083e578063f04e283e1461085357610285565b8063ac9650d8116100b0578063ac9650d8146107bb578063d505accf146107e8578063dd62ed3e1461080857610285565b806395d89b4114610786578063a9059cbb1461079b57610285565b806384b0196e116101225780638da798da116101075780638da798da14610740578063938e3d7b1461075357806394d008ef1461077357610285565b806384b0196e146106c45780638da5cb5b146106ec57610285565b806370a082311461064357806370c109cd14610676578063715018a6146106895780637ecebe001461069157610285565b8063256929621161020157806344d17187116101b5578063514e62fc1161019a578063514e62fc146105f157806354d1f13d1461062857806362835ade1461063057610285565b806344d17187146105cb5780634a4ee7b1146105de57610285565b8063313ce567116101e6578063313ce567146105785780633644e515146105945780633e429396146105a957610285565b8063256929621461053d5780632de948071461054557610285565b806318160ddd116102585780631c10893f1161023d5780631c10893f146104d35780631cd64df4146104e657806323b872dd1461051d57610285565b806318160ddd14610499578063183a4f6e146104c057610285565b806301ffc9a71461040f57806306fdde0314610444578063095ea7b3146104665780630f7d365214610486575b600080357fffffffff000000000000000000000000000000000000000000000000000000001681526002602081815260408084208151606081018352815473ffffffffffffffffffffffffffffffffffffffff168152600180830154948201949094529381015490929184019160ff9091169081111561030757610307613358565b600181111561031857610318613358565b905250805190915073ffffffffffffffffffffffffffffffffffffffff1661036c576040517fb6b8317700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008160400151600181111561038457610384613358565b036103c7573330146103c2576040517f295dcf7800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610402565b6001816040015160018111156103df576103df613358565b1480156103f0575060008160200151115b156104025761040281602001516108ce565b805161040d9061091f565b005b34801561041b57600080fd5b5061042f61042a3660046133b5565b61095a565b60405190151581526020015b60405180910390f35b34801561045057600080fd5b50610459610a9a565b60405161043b9190613422565b34801561047257600080fd5b5061042f61048136600461345e565b610b2c565b61040d610494366004613617565b610b4a565b3480156104a557600080fd5b506805345cdf77eb68f44c545b60405190815260200161043b565b61040d6104ce3660046136a0565b610c0c565b61040d6104e136600461345e565b610c16565b3480156104f257600080fd5b5061042f61050136600461345e565b638b78c6d8600c90815260009290925260209091205481161490565b34801561052957600080fd5b5061042f6105383660046136b9565b610c2c565b61040d610c4c565b34801561055157600080fd5b506104b26105603660046136f6565b638b78c6d8600c908152600091909152602090205490565b34801561058457600080fd5b506040516012815260200161043b565b3480156105a057600080fd5b506104b2610c9c565b3480156105b557600080fd5b506105be610d19565b60405161043b91906137cf565b61040d6105d9366004613997565b610e5f565b61040d6105ec36600461345e565b610ea3565b3480156105fd57600080fd5b5061042f61060c36600461345e565b638b78c6d8600c90815260009290925260209091205416151590565b61040d610eb5565b61040d61063e366004613b0c565b610ef1565b34801561064f57600080fd5b506104b261065e3660046136f6565b6387a211a2600c908152600091909152602090205490565b61040d610684366004613c07565b610f90565b61040d610ffa565b34801561069d57600080fd5b506104b26106ac3660046136f6565b6338377508600c908152600091909152602090205490565b3480156106d057600080fd5b506106d961100e565b60405161043b9796959493929190613c5a565b3480156106f857600080fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff909116815260200161043b565b61040d61074e366004613c07565b6110b7565b34801561075f57600080fd5b5061040d61076e366004613d1b565b611121565b61040d610781366004613997565b611132565b34801561079257600080fd5b50610459611148565b3480156107a757600080fd5b5061042f6107b636600461345e565b611157565b3480156107c757600080fd5b506107db6107d6366004613d50565b61116e565b60405161043b9190613dc7565b3480156107f457600080fd5b5061040d610803366004613e3e565b6111ef565b34801561081457600080fd5b506104b2610823366004613eb1565b602052637f5e9f20600c908152600091909152603490205490565b34801561084a57600080fd5b50610459611209565b61040d6108613660046136f6565b611218565b34801561087257600080fd5b5061087b611255565b60405161043b9190613ee4565b61040d6108963660046136f6565b61144a565b3480156108a757600080fd5b506104b26108b63660046136f6565b63389a75e1600c908152600091909152602090205490565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff7487392754331461091c57638b78c6d8600c5233600052806020600c20541661091c576382b429006000526004601cfd5b50565b6040805136810190915236600082376000803683855af490506109483d60408051918201905290565b3d6000823e81610956573d81fd5b3d81f35b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614806109ed57507fe8a3d485000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b80610a3957507f7f5828d0000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b80610a8557507fffffffff0000000000000000000000000000000000000000000000000000000082167f36372b0700000000000000000000000000000000000000000000000000000000145b80610a945750610a9482611471565b92915050565b606060038054610aa990613f90565b80601f0160208091040260200160405190810160405280929190818152602001828054610ad590613f90565b8015610b225780601f10610af757610100808354040283529160200191610b22565b820191906000526020600020905b815481529060010190602001808311610b0557829003601f168201915b5050505050905090565b6000610b393384846114ec565b610b4383836115a7565b9392505050565b6000610beb82610be57fde142acd02ed59c31a431f5c6143024510c10aa45a1296dcd068c6981de86e8e89898989604051610b86929190613fe3565b604051908190038120610bca9493929160200193845273ffffffffffffffffffffffffffffffffffffffff9290921660208401526040830152606082015260800190565b604051602081830303815290604052805190602001206115fa565b90611712565b9050610bfa86868686856117bc565b610c04868661183d565b505050505050565b61091c33826118bc565b610c1e6118c8565b610c2882826118fe565b5050565b6000610c3984848461190a565b610c448484846119be565b949350505050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b600080610ca7610a9a565b8051906020012090506040517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81528160208201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604082015246606082015230608082015260a081209250505090565b60606000610d276000611a7c565b90508067ffffffffffffffff811115610d4257610d426134d1565b604051908082528060200260200182016040528015610d7b57816020015b610d686132f7565b815260200190600190039081610d605790505b50915060005b81811015610e5a576000610d958183611ace565b905060405180604001604052808273ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e09573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e319190810190614178565b815250848381518110610e4657610e4661427e565b602090810291909101015250600101610d81565b505090565b610e6b84848484611b41565b73ffffffffffffffffffffffffffffffffffffffff84163314610e9357610e93843385611bc0565b610e9d8484611c00565b50505050565b610eab6118c8565b610c2882826118bc565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf6011328054600382558015610f435760018160011c14303b10610f3a5763f92ee8a96000526004601cfd5b818160ff1b1b91505b50610f52878787878787611c84565b8015610f87576002815560016020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b50505050505050565b7f8000000000000000000000000000000000000000000000000000000000000000610fba816108ce565b610e9d8484848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d0e92505050565b6110026118c8565b61100c6000612129565b565b7f0f0000000000000000000000000000000000000000000000000000000000000060608060008080836110a5604080518082018252600981527f4552433230436f726500000000000000000000000000000000000000000000006020808301919091528251808401909352600183527f31000000000000000000000000000000000000000000000000000000000000009083015291565b97989097965046955030945091925090565b7f80000000000000000000000000000000000000000000000000000000000000006110e1816108ce565b610e9d8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061218f92505050565b6111296118c8565b61091c8161298b565b61113e848484846129c4565b610e9d848461183d565b606060048054610aa990613f90565b600061116433848461190a565b610b438383612a43565b6060602060005281602052816111845760406000f35b60408260051b8085604037818101905b82518601604082018135602083018237600038833583305af46111bb573d6000803e3d6000fd5b8285526020850194503d81523d6000602083013e50503d01603f0167ffffffffffffffe01681831061119457604081016000f35b6111fa8787876114ec565b610f8787878787878787612abe565b606060058054610aa990613f90565b6112206118c8565b63389a75e1600c52806000526020600c20805442111561124857636f5e88186000526004601cfd5b6000905561091c81612129565b60408051600580825260c08201909252606091816020015b604080518082019091526000808252602082015281526020019060019003908161126d57905050604080518082019091527f7ce7cf07000000000000000000000000000000000000000000000000000000008152909150602081016001815250816000815181106112e0576112e061427e565b602090810291909101810191909152604080518082019091527f89c154b50000000000000000000000000000000000000000000000000000000081529081016001815250816001815181106113375761133761427e565b602090810291909101810191909152604080518082019091527f98074eed00000000000000000000000000000000000000000000000000000000815290810160008152508160028151811061138e5761138e61427e565b602090810291909101810191909152604080518082019091527f7fda8dc10000000000000000000000000000000000000000000000000000000081529081016000815250816003815181106113e5576113e561427e565b602090810291909101810191909152604080518082019091527f837406a600000000000000000000000000000000000000000000000000000000815290810160008152508160048151811061143c5761143c61427e565b602002602001018190525090565b6114526118c8565b8060601b61146857637448fbae6000526004601cfd5b61091c81612129565b60007fffffffff0000000000000000000000000000000000000000000000000000000080831690036114a557506000919050565b7fffffffff000000000000000000000000000000000000000000000000000000008216600090815260016020526040902054156114e457506001919050565b506000919050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526115a0907f837406a6000000000000000000000000000000000000000000000000000000009060840160408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f837406a600000000000000000000000000000000000000000000000000000000179052612c58565b5050505050565b600082602052637f5e9f20600c5233600052816034600c205581600052602c5160601c337f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560206000a350600192915050565b7fb0b5b00e172f19a7fb8c48c273ce3144bfcbb31a16957991e9b771af28d8cad57f000000000000000000000000a6b59721ac0cad7a4f502914b5872b6782a0908530147f0000000000000000000000000000000000000000000000000000000000aa36a74614166116ed5750604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81527f369d0738e0ff621944749898e309c1990bb96df1ac8f521b92700fdb7b10f3a060208201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc69181019190915246606082015230608082015260a090205b67190100000000000060005280601a5281603a52604260182090506000603a52919050565b604051600190836000526020830151604052604083510361176757604083015160ff81901c601b016020527f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1660605261178d565b604183510361178857606083015160001a602052604083015160605261178d565b600091505b6020600160806000855afa5191503d6117ae57638baa579f6000526004601cfd5b600060605260405292915050565b610f876389c154b560e01b86868686866040516024016117e09594939291906142d8565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f89c154b500000000000000000000000000000000000000000000000000000000179052612c58565b6805345cdf77eb68f44c54818101818110156118615763e5cfe9576000526004601cfd5b806805345cdf77eb68f44c5550506387a211a2600c52816000526020600c208181540181555080602052600c5160601c60007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a35050565b610c2882826000612f3c565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff7487392754331461100c576382b429006000526004601cfd5b610c2882826001612f3c565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526115a0907f98074eed000000000000000000000000000000000000000000000000000000009060840160408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f98074eed00000000000000000000000000000000000000000000000000000000179052612c58565b60008360601b33602052637f5e9f208117600c526034600c20805460018101156119fe57808511156119f8576313be252b6000526004601cfd5b84810382555b50506387a211a28117600c526020600c20805480851115611a275763f4d678b86000526004601cfd5b84810382555050836000526020600c208381540181555082602052600c5160601c8160601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3505060019392505050565b63978aab9260045260008181526024812080548060a01b60a01c8060011c9350808260601c1517611ac657600193508383015415611ac657600293508383015415611ac657600393505b505050919050565b63978aab926004526000828152602481208281015460601c915068fbb67fda52d4bfb8bf82141582029150611b0284611a7c565b8310611b3a576040517f4e23d03500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5092915050565b610c04637fda8dc160e01b85858585604051602401611b639493929190614336565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f7fda8dc100000000000000000000000000000000000000000000000000000000179052612c58565b81602052637f5e9f20600c52826000526034600c20805460018101156115a05780831115611bf6576313be252b6000526004601cfd5b9190910390555050565b6387a211a2600c52816000526020600c20805480831115611c295763f4d678b86000526004601cfd5b82900390556805345cdf77eb68f44c80548290039055600081815273ffffffffffffffffffffffffffffffffffffffff83167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602083a35050565b6003611c9087826143bd565b506004611c9d86826143bd565b50611ca78461298b565b611cb083612f95565b8051825114611cbe57600080fd5b60005b8251811015610f8757611d06838281518110611cdf57611cdf61427e565b6020026020010151838381518110611cf957611cf961427e565b602002602001015161218f565b600101611cc1565b611d19600083612ff9565b611d4f576040517f2a6f792900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611d9c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611dc49190810190614178565b60408101515190915060005b81811015611e6357600180600085604001518481518110611df357611df361427e565b60200260200101517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681526020019081526020016000206000828254611e5691906144e7565b9091555050600101611dd0565b5060808201515160005b81811015611f2c576002600085608001518381518110611e8f57611e8f61427e565b602090810291909101810151517fffffffff00000000000000000000000000000000000000000000000000000000168252810191909152604001600090812080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560018082019290925560020180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905501611e6d565b5060608301515160005b81811015611ff5576002600086606001518381518110611f5857611f5861427e565b602090810291909101810151517fffffffff00000000000000000000000000000000000000000000000000000000168252810191909152604001600090812080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560018082019290925560020180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905501611f36565b508351156120cc578573ffffffffffffffffffffffffffffffffffffffff16856040516024016120259190613422565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8a91b0e3000000000000000000000000000000000000000000000000000000001790525161208891906144fa565b600060405180830381855af49150503d80600081146120c3576040519150601f19603f3d011682016040523d82523d6000602084013e6120c8565b606091505b5050505b6040805133815273ffffffffffffffffffffffffffffffffffffffff8816602082018190528183015290517fef3b2e20acbb62d61d782c5449bd73d3970cb9be1050a6ad6f846b2cbe21c03a9181900360600190a1505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b61219a600083613167565b6121d0576040517f24c377e200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff166389e04e0e6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561221d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526122459190810190614178565b905080602001515160001461231a5760005b8160200151518110156123185761228a8260200151828151811061227d5761227d61427e565b602002602001015161095a565b61231057816020015181815181106122a4576122a461427e565b60200260200101516040517f56ba3a7f00000000000000000000000000000000000000000000000000000000815260040161230791907fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b60405180910390fd5b600101612257565b505b60408101515160005b818110156123b6576001806000856040015184815181106123465761234661427e565b60200260200101517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060008282546123a99190614516565b9091555050600101612323565b5060006123c1611255565b80516060850151519192509060005b81811015612658576000866060015182815181106123f0576123f061427e565b60209081029190910181015180517fffffffff00000000000000000000000000000000000000000000000000000000166000908152600290925260409091205490915073ffffffffffffffffffffffffffffffffffffffff1615612480576040517f4cc04b1700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805b858110156125035782600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168782815181106124c2576124c261427e565b6020026020010151600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036124fb5760019150612503565b600101612484565b508061253b576040517fae7ff83e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405180606001604052808b73ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000600181111561257c5761257c613358565b905282517fffffffff0000000000000000000000000000000000000000000000000000000016600090815260026020818152604092839020845181547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90911617815590840151600180830191909155928401519181018054919390917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690838181111561264357612643613358565b021790555050600190930192506123d0915050565b5060808501515160005b8181101561281f576000876080015182815181106126825761268261427e565b60209081029190910181015180517fffffffff00000000000000000000000000000000000000000000000000000000166000908152600290925260409091205490915073ffffffffffffffffffffffffffffffffffffffff1615612712576040517f92bffc6500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160608101825273ffffffffffffffffffffffffffffffffffffffff8c168152602083810151908201529081016001905281517fffffffff0000000000000000000000000000000000000000000000000000000016600090815260026020818152604092839020845181547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90911617815590840151600180830191909155928401519181018054919390917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690838181111561280b5761280b613358565b021790555050600190920191506126629050565b5085511561292c576000808973ffffffffffffffffffffffffffffffffffffffff16896040516024016128529190613422565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f6d61fe7000000000000000000000000000000000000000000000000000000000179052516128b591906144fa565b600060405180830381855af49150503d80600081146128f0576040519150601f19603f3d011682016040523d82523d6000602084013e6128f5565b606091505b50915091508161292957612929817f3fcb9045000000000000000000000000000000000000000000000000000000006132de565b50505b6040805133815273ffffffffffffffffffffffffffffffffffffffff8a16602082018190528183015290517fbcd03fe408dcc45614e803cbab9f500dddff61b17380b993e76d30398da472299181900360600190a15050505050505050565b600561299782826143bd565b506040517fa5d4097edda6d87cb9329af83fb3712ef77eeb13738ffe43cc35a4ce305ad96290600090a150565b610c04637ce7cf0760e01b858585856040516024016129e69493929190614336565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f7ce7cf0700000000000000000000000000000000000000000000000000000000179052612c58565b60006387a211a2600c52336000526020600c20805480841115612a6e5763f4d678b86000526004601cfd5b83810382555050826000526020600c208281540181555081602052600c5160601c337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a350600192915050565b6000612ac8610a9a565b80519060200120905084421115612ae757631a15a3cc6000526004601cfd5b6040518860601b60601c98508760601b60601c975065383775081901600e52886000526020600c2080547f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f83528360208401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604084015246606084015230608084015260a08320602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c983528a60208401528960408401528860608401528060808401528760a084015260c08320604e526042602c206000528660ff1660205285604052846060526020806080600060015afa8b3d5114612bf35763ddafbaef6000526004601cfd5b019055777f5e9f20000000000000000000000000000000000000000088176040526034602c2087905587897f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925602060608501a360405250506000606052505050505050565b600060603068929eee149b4bd212685403612c7b5763ab143c066000526004601cfd5b3068929eee149b4bd21268557fffffffff00000000000000000000000000000000000000000000000000000000841660009081526002602081815260408084208151606081018352815473ffffffffffffffffffffffffffffffffffffffff168152600180830154948201949094529381015490929184019160ff90911690811115612d0957612d09613358565b6001811115612d1a57612d1a613358565b9052509050600081604001516001811115612d3757612d37613358565b14612d6e576040517fae7ff83e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805173ffffffffffffffffffffffffffffffffffffffff1615612e2e57806000015173ffffffffffffffffffffffffffffffffffffffff1684604051612db491906144fa565b600060405180830381855af49150503d8060008114612def576040519150601f19603f3d011682016040523d82523d6000602084013e612df4565b606091505b50909350915082612e2957612e29827f3fcb9045000000000000000000000000000000000000000000000000000000006132de565b612f23565b6000612e38611255565b805190915060005b81811015612f1f57877bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916838281518110612e7a57612e7a61427e565b6020026020010151600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603612f17576001838281518110612ebe57612ebe61427e565b6020026020010151602001516001811115612edb57612edb613358565b03612f12576040517f2d51781900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612f1f565b600101612e40565b5050505b503868929eee149b4bd21268559250929050565b505050565b638b78c6d8600c52826000526020600c20805483811783612f5e575080841681185b80835580600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26600080a3505050505050565b73ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739278190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b63978aab9260045260008281526024812073ffffffffffffffffffffffffffffffffffffffff92909216917fffffffffffffffffffffffffffffffffffffffffffffff04498025ad2b40474183016130595763f5a267f16000526004601cfd5b8261306b5768fbb67fda52d4bfb8bf92505b80546bffffffffffffffffffffffff8116806130ee5760019350848260601c036130a95760018301805484556002840180549091556000905561315e565b84600184015460601c036130cb5760028301805460018501556000905561315e565b84600284015460601c036130e5576000600284015561315e565b6000935061315e565b8260205284600052604060002080548061310957505061315e565b60018360011c039250826001820314613141578285015460601c8060601b600183038701556000848701558060005250806040600020555b5060018260011b17845460601c60601b1784556000815550600193505b50505092915050565b63978aab9260045260008281526024812073ffffffffffffffffffffffffffffffffffffffff92909216917fffffffffffffffffffffffffffffffffffffffffffffff04498025ad2b40474183016131c75763f5a267f16000526004601cfd5b826131d95768fbb67fda52d4bfb8bf92505b80546bffffffffffffffffffffffff811682602052806132a1578160601c8061320c578560601b8455600194505061315e565b858103613219575061315e565b600184015460601c8061323a578660601b600186015560019550505061315e565b86810361324857505061315e565b600285015460601c8061326a578760601b60028701556001965050505061315e565b8781036132795750505061315e565b6000928352604080842060019055918352818320600290558252902060039055506007908117905b84600052604060002080546132d4578160011c91508560601b82850155816001018155826002018455600194505061315e565b5050505092915050565b8151156132ed57815182602001fd5b806000526004601cfd5b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016133536040518060a00160405280600015158152602001606081526020016060815260200160608152602001606081525090565b905290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7fffffffff000000000000000000000000000000000000000000000000000000008116811461091c57600080fd5b6000602082840312156133c757600080fd5b8135610b4381613387565b60005b838110156133ed5781810151838201526020016133d5565b50506000910152565b6000815180845261340e8160208601602086016133d2565b601f01601f19169290920160200192915050565b602081526000610b4360208301846133f6565b803573ffffffffffffffffffffffffffffffffffffffff8116811461345957600080fd5b919050565b6000806040838503121561347157600080fd5b61347a83613435565b946020939093013593505050565b60008083601f84011261349a57600080fd5b50813567ffffffffffffffff8111156134b257600080fd5b6020830191508360208285010111156134ca57600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516020810167ffffffffffffffff81118282101715613523576135236134d1565b60405290565b6040805190810167ffffffffffffffff81118282101715613523576135236134d1565b60405160a0810167ffffffffffffffff81118282101715613523576135236134d1565b604051601f8201601f1916810167ffffffffffffffff81118282101715613598576135986134d1565b604052919050565b600082601f8301126135b157600080fd5b81356020830160008067ffffffffffffffff8411156135d2576135d26134d1565b50601f8301601f19166020016135e78161356f565b9150508281528583830111156135fc57600080fd5b82826020830137600092810160200192909252509392505050565b60008060008060006080868803121561362f57600080fd5b61363886613435565b945060208601359350604086013567ffffffffffffffff81111561365b57600080fd5b61366788828901613488565b909450925050606086013567ffffffffffffffff81111561368757600080fd5b613693888289016135a0565b9150509295509295909350565b6000602082840312156136b257600080fd5b5035919050565b6000806000606084860312156136ce57600080fd5b6136d784613435565b92506136e560208501613435565b929592945050506040919091013590565b60006020828403121561370857600080fd5b610b4382613435565b600081518084526020840193506020830160005b828110156137655781517fffffffff0000000000000000000000000000000000000000000000000000000016865260209586019590910190600101613725565b5093949350505050565b600081518084526020840193506020830160005b8281101561376557815180517fffffffff000000000000000000000000000000000000000000000000000000001687526020908101518188015260409096019590910190600101613783565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b8281101561398b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0878603018452815173ffffffffffffffffffffffffffffffffffffffff81511686526020810151905060406020870152805115156040870152602081015160a0606088015261387260e0880182613711565b905060408201517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08883030160808901526138ad8282613711565b60608401518982037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00160a08b0152805180835260209182019450600093509101905b80831015613936577fffffffff000000000000000000000000000000000000000000000000000000008451511682526020820191506020840193506001830192506138f0565b50608084015193507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08982030160c08a0152613972818561376f565b98505050602095860195939093019250506001016137f7565b50929695505050505050565b600080600080606085870312156139ad57600080fd5b6139b685613435565b935060208501359250604085013567ffffffffffffffff8111156139d957600080fd5b6139e587828801613488565b95989497509550505050565b600067ffffffffffffffff821115613a0b57613a0b6134d1565b5060051b60200190565b600082601f830112613a2657600080fd5b8135613a39613a34826139f1565b61356f565b8082825260208201915060208360051b860101925085831115613a5b57600080fd5b602085015b83811015613a7f57613a7181613435565b835260209283019201613a60565b5095945050505050565b600082601f830112613a9a57600080fd5b8135613aa8613a34826139f1565b8082825260208201915060208360051b860101925085831115613aca57600080fd5b602085015b83811015613a7f57803567ffffffffffffffff811115613aee57600080fd5b613afd886020838a01016135a0565b84525060209283019201613acf565b60008060008060008060c08789031215613b2557600080fd5b863567ffffffffffffffff811115613b3c57600080fd5b613b4889828a016135a0565b965050602087013567ffffffffffffffff811115613b6557600080fd5b613b7189828a016135a0565b955050604087013567ffffffffffffffff811115613b8e57600080fd5b613b9a89828a016135a0565b945050613ba960608801613435565b9250608087013567ffffffffffffffff811115613bc557600080fd5b613bd189828a01613a15565b92505060a087013567ffffffffffffffff811115613bee57600080fd5b613bfa89828a01613a89565b9150509295509295509295565b600080600060408486031215613c1c57600080fd5b613c2584613435565b9250602084013567ffffffffffffffff811115613c4157600080fd5b613c4d86828701613488565b9497909650939450505050565b7fff000000000000000000000000000000000000000000000000000000000000008816815260e060208201526000613c9560e08301896133f6565b8281036040840152613ca781896133f6565b6060840188905273ffffffffffffffffffffffffffffffffffffffff8716608085015260a0840186905283810360c08501528451808252602080870193509091019060005b81811015613d0a578351835260209384019390920191600101613cec565b50909b9a5050505050505050505050565b600060208284031215613d2d57600080fd5b813567ffffffffffffffff811115613d4457600080fd5b610c44848285016135a0565b60008060208385031215613d6357600080fd5b823567ffffffffffffffff811115613d7a57600080fd5b8301601f81018513613d8b57600080fd5b803567ffffffffffffffff811115613da257600080fd5b8560208260051b8401011115613db757600080fd5b6020919091019590945092505050565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b8281101561398b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0878603018452613e298583516133f6565b94506020938401939190910190600101613def565b600080600080600080600060e0888a031215613e5957600080fd5b613e6288613435565b9650613e7060208901613435565b95506040880135945060608801359350608088013560ff81168114613e9457600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613ec457600080fd5b613ecd83613435565b9150613edb60208401613435565b90509250929050565b602080825282518282018190526000918401906040840190835b81811015613f8557835180517fffffffff000000000000000000000000000000000000000000000000000000001684526020015160028110613f69577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6020848101919091529390930192604090920191600101613efe565b509095945050505050565b600181811c90821680613fa457607f821691505b602082108103613fdd577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b8183823760009101908152919050565b8051801515811461345957600080fd5b600082601f83011261401457600080fd5b8151614022613a34826139f1565b8082825260208201915060208360051b86010192508583111561404457600080fd5b602085015b83811015613a7f57805161405c81613387565b835260209283019201614049565b600082601f83011261407b57600080fd5b8151614089613a34826139f1565b8082825260208201915060208360051b8601019250858311156140ab57600080fd5b602085015b83811015613a7f57602081880312156140c857600080fd5b6140d0613500565b81516140db81613387565b81528352602092830192016140b0565b600082601f8301126140fc57600080fd5b815161410a613a34826139f1565b8082825260208201915060208360061b86010192508583111561412c57600080fd5b602085015b83811015613a7f576040818803121561414957600080fd5b614151613529565b815161415c81613387565b8152602082810151818301529084529290920191604001614131565b60006020828403121561418a57600080fd5b815167ffffffffffffffff8111156141a157600080fd5b820160a081850312156141b357600080fd5b6141bb61354c565b6141c482613ff3565b8152602082015167ffffffffffffffff8111156141e057600080fd5b6141ec86828501614003565b602083015250604082015167ffffffffffffffff81111561420c57600080fd5b61421886828501614003565b604083015250606082015167ffffffffffffffff81111561423857600080fd5b6142448682850161406a565b606083015250608082015167ffffffffffffffff81111561426457600080fd5b614270868285016140eb565b608083015250949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8616815284602082015260806040820152600061430e6080830185876142ad565b905073ffffffffffffffffffffffffffffffffffffffff831660608301529695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061436c6060830184866142ad565b9695505050505050565b601f821115612f3757806000526020600020601f840160051c8101602085101561439d5750805b601f840160051c820191505b818110156115a057600081556001016143a9565b815167ffffffffffffffff8111156143d7576143d76134d1565b6143eb816143e58454613f90565b84614376565b6020601f82116001811461443d57600083156144075750848201515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600385901b1c1916600184901b1784556115a0565b600084815260208120601f198516915b8281101561446d578785015182556020948501946001909201910161444d565b50848210156144a957868401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b60f8161c191681555b50505050600190811b01905550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610a9457610a946144b8565b6000825161450c8184602087016133d2565b9190910192915050565b80820180821115610a9457610a946144b856fea264697066735822122097c0c5035ed26c1e10bd6c4bb1db4ef1abe7565a691f014e72ce13bb33e39a1864736f6c634300081a0033
Loading...
Loading
[ 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.