Polygon Sponsored slots available. Book your slot here!
Overview
MATIC Balance
0 MATIC
MATIC Value
$0.00More Info
Private Name Tags
ContractCreator:
Sponsored
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x60c06040 | 25941342 | 745 days ago | IN | Create: Dispatch | 0 MATIC | 0.0808821 |
Loading...
Loading
Contract Name:
Dispatch
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "../BaseComponentUpgradeable.sol"; import "../agents/AgentRegistry.sol"; import "../scanners/ScannerRegistry.sol"; contract Dispatch is BaseComponentUpgradeable { using EnumerableSet for EnumerableSet.UintSet; AgentRegistry private _agents; ScannerRegistry private _scanners; string public constant version = "0.1.3"; mapping(uint256 => EnumerableSet.UintSet) private scannerToAgents; mapping(uint256 => EnumerableSet.UintSet) private agentToScanners; error Disabled(string name); error InvalidId(string name, uint256 id); event AlreadyLinked(uint256 agentId, uint256 scannerId, bool enable); event Link(uint256 agentId, uint256 scannerId, bool enable); /// @custom:oz-upgrades-unsafe-allow constructor constructor(address forwarder) initializer ForwardedContext(forwarder) {} /** * @notice Initializer method, access point to initialize inheritance tree. * @param __manager address of AccessManager. * @param __router address of Router. * @param __agents address of AgentRegistry. * @param __scanners address of ScannerRegistry. */ function initialize( address __manager, address __router, address __agents, address __scanners ) public initializer { __AccessManaged_init(__manager); __Routed_init(__router); _agents = AgentRegistry(__agents); _scanners = ScannerRegistry(__scanners); } /** * @notice Getter for AgentRegistry. * @return AgentRegistry. */ function agentRegistry() public view returns (AgentRegistry) { return _agents; } /** * @notice Getter for ScannerRegistry. * @return ScannerRegistry. */ function scannerRegistry() public view returns (ScannerRegistry) { return _scanners; } /** * @notice Get total agents linked to a scanner. * @dev helper for external iteration. * @param scannerId ERC1155 token id of the scanner. * @return total agents linked to a scanner */ function numAgentsFor(uint256 scannerId) public view returns (uint256) { return scannerToAgents[scannerId].length(); } /** * @notice Get total scanners where an agent is running in. * @dev helper for external iteration. * @param agentId ERC1155 token id of the agent. * @return total scanners running an scanner */ function numScannersFor(uint256 agentId) public view returns (uint256) { return agentToScanners[agentId].length(); } /** * @notice Get agentId linked to a scanner in certain position. * @dev helper for external iteration. * @param scannerId ERC1155 token id of the scanner. * @param pos index for iteration. * @return ERC1155 token id of the agent. */ function agentAt(uint256 scannerId, uint256 pos) public view returns (uint256) { return scannerToAgents[scannerId].at(pos); } /** * @notice Get data of an agent linked to a scanner at a certain position. * @dev helper for external iteration. * @param scannerId ERC1155 token id of the scanner. * @param pos index for iteration. * @return registered bool if agent exists, false otherwise. * @return owner address. * @return agentId ERC1155 token id of the agent. * @return agentVersion agent version number. * @return metadata IPFS pointer for agent metadata. * @return chainIds ordered array of chainId were the agent wants to run. * @return enabled bool if agent is enabled, false otherwise. */ function agentRefAt(uint256 scannerId, uint256 pos) external view returns (bool registered, address owner, uint256 agentId, uint256 agentVersion, string memory metadata, uint256[] memory chainIds, bool enabled) { agentId = agentAt(scannerId, pos); (registered, owner, agentVersion, metadata, chainIds, enabled) = _agents.getAgentState(agentId); return (registered, owner,agentId, agentVersion, metadata, chainIds, enabled); } /** * @notice Get scannerId running an agent at a certain position. * @dev helper for external iteration. * @param agentId ERC1155 token id of the scanner. * @param pos index for iteration. * @return ERC1155 token id of the scanner. */ function scannerAt(uint256 agentId, uint256 pos) public view returns (uint256) { return agentToScanners[agentId].at(pos); } /** * @notice Get data of ascanner running an agent at a certain position. * @dev helper for external iteration. * @param agentId ERC1155 token id of the agent. * @param pos index for iteration. * @return registered true if scanner is registered. * @return scannerId ERC1155 token id of the scanner. * @return owner address. * @return chainId that the scanner monitors. * @return metadata IPFS pointer for agent metadata. * @return enabled true if scanner is enabled, false otherwise. */ function scannerRefAt(uint256 agentId, uint256 pos) external view returns (bool registered,uint256 scannerId, address owner, uint256 chainId, string memory metadata, bool enabled) { scannerId = scannerAt(agentId, pos); (registered,owner, chainId, metadata, enabled) = _scanners.getScannerState(scannerId); return (registered, scannerId, owner, chainId, metadata, enabled); } /// Returns true if scanner and agents are linked, false otherwise. function areTheyLinked(uint256 agentId, uint256 scannerId) external view returns(bool) { return scannerToAgents[scannerId].contains(agentId) && agentToScanners[agentId].contains(scannerId); } /** * @notice Assigns the job of running an agent to a scanner. * @dev currently only allowed for DISPATCHER_ROLE (Assigner software). * @dev emits Link(agentId, scannerId, true) event. * @param agentId ERC1155 token id of the agent. * @param scannerId ERC1155 token id of the scanner. */ function link(uint256 agentId, uint256 scannerId) public onlyRole(DISPATCHER_ROLE) { if (!_agents.isEnabled(agentId)) revert Disabled("Agent"); if (!_scanners.isEnabled(scannerId)) revert Disabled("Scanner"); if (!scannerToAgents[scannerId].add(agentId) || !agentToScanners[agentId].add(scannerId)) { emit AlreadyLinked(agentId, scannerId, true); } else { emit Link(agentId, scannerId, true); } } /** * @notice Unassigns the job of running an agent to a scanner. * @dev currently only allowed for DISPATCHER_ROLE (Assigner software). * @dev emits Link(agentId, scannerId, false) event. * @param agentId ERC1155 token id of the agent. * @param scannerId ERC1155 token id of the scanner. */ function unlink(uint256 agentId, uint256 scannerId) public onlyRole(DISPATCHER_ROLE) { if (!_agents.isCreated(agentId)) revert InvalidId("Agent", agentId); if (!_scanners.isRegistered(scannerId)) revert InvalidId("Scanner", scannerId); if (!scannerToAgents[scannerId].remove(agentId) || !agentToScanners[agentId].remove(scannerId)) { emit AlreadyLinked(agentId, scannerId, false); } else { emit Link(agentId, scannerId, false); } } /** * @notice Sets agent registry address. * @dev only DEFAULT_ADMIN_ROLE (governance). * @param newAgentRegistry agent of the new AgentRegistry. */ function setAgentRegistry(address newAgentRegistry) public onlyRole(DEFAULT_ADMIN_ROLE) { _agents = AgentRegistry(newAgentRegistry); } /** * @notice Sets scanner registry address. * @dev only DEFAULT_ADMIN_ROLE (governance). * @param newScannerRegistry agent of the new ScannerRegistry. */ function setScannerRegistry(address newScannerRegistry) public onlyRole(DEFAULT_ADMIN_ROLE) { _scanners = ScannerRegistry(newScannerRegistry); } /** * Method to hash the amount of scanners an agent is running in, and their status * @dev method marked for deprecation in next version. */ function agentHash(uint256 agentId) external view returns (uint256 length, bytes32 manifest) { uint256[] memory scanners = agentToScanners[agentId].values(); bool[] memory enabled = new bool[](scanners.length); for (uint256 i = 0; i < scanners.length; i++) { enabled[i] = _scanners.isEnabled(scanners[i]); } return ( scanners.length, keccak256(abi.encodePacked(scanners, enabled)) ); } /** * @dev method used by Scanner Node software to know if their list of assigned agents has changed, * their enabled state or version has changed so they can start managing changes * (loading new agent images, removing not assigned agents, updating agents...). * @param scannerId ERC1155 token id of the scanner. * @return length amount of agents. * @return manifest keccak256 of list of agents, list of agentVersion and list of enabled states. */ function scannerHash(uint256 scannerId) external view returns (uint256 length, bytes32 manifest) { uint256[] memory agents = scannerToAgents[scannerId].values(); uint256[] memory agentVersion = new uint256[](agents.length); bool[] memory enabled = new bool[](agents.length); for (uint256 i = 0; i < agents.length; i++) { (,,agentVersion[i],,) = _agents.getAgent(agents[i]); enabled[i] = _agents.isEnabled(agents[i]); } return ( agents.length, keccak256(abi.encodePacked(agents, agentVersion, enabled)) ); } uint256[48] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/Multicall.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "./Roles.sol"; import "./utils/AccessManaged.sol"; import "./utils/IVersioned.sol"; import "./utils/ForwardedContext.sol"; import "./utils/Routed.sol"; import "../tools/ENSReverseRegistration.sol"; /** * @dev The Forta platform is composed of "component" smart contracts that are upgradeable, share a common access * control scheme and can send use routed hooks to signal one another. They also support the multicall pattern. * * This contract contains the base of Forta components. Contract inheriting this will have to call * - __AccessManaged_init(address manager) * - __Routed_init(address router) * in their initialization process. */ abstract contract BaseComponentUpgradeable is ForwardedContext, AccessManagedUpgradeable, RoutedUpgradeable, Multicall, UUPSUpgradeable, IVersioned { // Access control for the upgrade process function _authorizeUpgrade(address newImplementation) internal virtual override onlyRole(UPGRADER_ROLE) { } // Allow the upgrader to set ENS reverse registration function setName(address ensRegistry, string calldata ensName) public onlyRole(ENS_MANAGER_ROLE) { ENSReverseRegistration.setName(ensRegistry, ensName); } /** * @notice Helper to get either msg msg.sender if not a meta transaction, signer of forwarder metatx if it is. * @inheritdoc ForwardedContext */ function _msgSender() internal view virtual override(ContextUpgradeable, ForwardedContext) returns (address sender) { return super._msgSender(); } /** * @notice Helper to get msg.data if not a meta transaction, forwarder data in metatx if it is. * @inheritdoc ForwardedContext */ function _msgData() internal view virtual override(ContextUpgradeable, ForwardedContext) returns (bytes calldata) { return super._msgData(); } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "../BaseComponentUpgradeable.sol"; import "./AgentRegistryCore.sol"; import "./AgentRegistryEnable.sol"; import "./AgentRegistryEnumerable.sol"; import "./AgentRegistryMetadata.sol"; contract AgentRegistry is BaseComponentUpgradeable, AgentRegistryCore, AgentRegistryEnable, AgentRegistryMetadata, AgentRegistryEnumerable { string public constant version = "0.1.2"; /// @custom:oz-upgrades-unsafe-allow constructor constructor(address forwarder) initializer ForwardedContext(forwarder) {} /** * @notice Initializer method, access point to initialize inheritance tree. * @param __manager address of AccessManager. * @param __router address of Router. * @param __name ERC1155 token name. * @param __symbol ERC1155 token symbol. */ function initialize( address __manager, address __router, string calldata __name, string calldata __symbol ) public initializer { __AccessManaged_init(__manager); __Routed_init(__router); __UUPSUpgradeable_init(); __ERC721_init(__name, __symbol); } /** * @notice Gets all Agent state. * @param agentId ERC1155 token id of the agent. * @return created if agent exists. * @return owner address. * @return agentVersion of the agent. * @return metadata IPFS pointer. * @return chainIds the agent wants to run in. */ function getAgentState(uint256 agentId) public view returns (bool created, address owner,uint256 agentVersion, string memory metadata, uint256[] memory chainIds, bool enabled) { (created, owner, agentVersion, metadata, chainIds) = getAgent(agentId); return (created, owner, agentVersion, metadata, chainIds, isEnabled(agentId)); } /** * @notice Inheritance disambiguation for hook fired befire agent update (and creation). * @param agentId id of the agent. * @param newMetadata IPFS pointer to agent's metadata * @param newChainIds chain ids that the agent wants to scan */ function _beforeAgentUpdate(uint256 agentId, string memory newMetadata, uint256[] calldata newChainIds) internal virtual override(AgentRegistryCore, AgentRegistryEnumerable) { super._beforeAgentUpdate(agentId, newMetadata, newChainIds); } /** * @notice Obligatory inheritance disambiguation for hook fired for agent update (and creation). * @param agentId id of the agent. * @param newMetadata IPFS pointer to agent's metadata * @param newChainIds chain ids that the agent wants to scan */ function _agentUpdate(uint256 agentId, string memory newMetadata, uint256[] calldata newChainIds) internal virtual override(AgentRegistryCore, AgentRegistryMetadata) { super._agentUpdate(agentId, newMetadata, newChainIds); } /** * @notice Helper to get either msg msg.sender if not a meta transaction, signer of forwarder metatx if it is. * @inheritdoc ForwardedContext */ function _msgSender() internal view virtual override(BaseComponentUpgradeable, AgentRegistryCore, AgentRegistryEnable) returns (address sender) { return super._msgSender(); } /** * @notice Helper to get msg.data if not a meta transaction, forwarder data in metatx if it is. * @inheritdoc ForwardedContext */ function _msgData() internal view virtual override(BaseComponentUpgradeable, AgentRegistryCore, AgentRegistryEnable) returns (bytes calldata) { return super._msgData(); } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "../BaseComponentUpgradeable.sol"; import "./ScannerRegistryCore.sol"; import "./ScannerRegistryManaged.sol"; import "./ScannerRegistryEnable.sol"; import "./ScannerRegistryMetadata.sol"; contract ScannerRegistry is BaseComponentUpgradeable, ScannerRegistryCore, ScannerRegistryManaged, ScannerRegistryEnable, ScannerRegistryMetadata { string public constant version = "0.1.1"; /// @custom:oz-upgrades-unsafe-allow constructor constructor(address forwarder) initializer ForwardedContext(forwarder) {} /** * @notice Initializer method, access point to initialize inheritance tree. * @param __manager address of AccessManager. * @param __router address of Router. * @param __name ERC1155 token name. * @param __symbol ERC1155 token symbol. */ function initialize( address __manager, address __router, string calldata __name, string calldata __symbol ) public initializer { __AccessManaged_init(__manager); __Routed_init(__router); __UUPSUpgradeable_init(); __ERC721_init(__name, __symbol); } /** * @notice Gets all scanner properties and state * @param scannerId ERC1155 token id of the scanner. * @return registered true if scanner exists. * @return owner address. * @return chainId the scanner is monitoring. * @return metadata IPFS pointer for the scanner's JSON metadata. */ function getScannerState(uint256 scannerId) external view returns (bool registered, address owner, uint256 chainId, string memory metadata, bool enabled) { (registered, owner, chainId, metadata) = super.getScanner(scannerId); return ( registered, owner, chainId, metadata, isEnabled(scannerId) ); } /** * @notice Inheritance disambiguation for _scannerUpdate internal logic. * @inheritdoc ScannerRegistryCore */ function _scannerUpdate( uint256 scannerId, uint256 chainId, string calldata metadata ) internal virtual override( ScannerRegistryCore, ScannerRegistryMetadata ) { super._scannerUpdate(scannerId, chainId, metadata); } /** * @dev inheritance disambiguation for _getStakeThreshold * see ScannerRegistryMetadata */ function _getStakeThreshold(uint256 subject) internal virtual override(ScannerRegistryCore, ScannerRegistryMetadata) view returns(StakeThreshold memory) { return super._getStakeThreshold(subject); } /** * @notice Helper to get either msg msg.sender if not a meta transaction, signer of forwarder metatx if it is. * @inheritdoc ForwardedContext */ function _msgSender() internal view virtual override(BaseComponentUpgradeable, ScannerRegistryCore, ScannerRegistryEnable) returns (address sender) { return super._msgSender(); } /** * @notice Helper to get msg.data if not a meta transaction, forwarder data in metatx if it is. * @inheritdoc ForwardedContext */ function _msgData() internal view virtual override(BaseComponentUpgradeable, ScannerRegistryCore, ScannerRegistryEnable) returns (bytes calldata) { return super._msgData(); } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Multicall.sol) pragma solidity ^0.8.0; import "./Address.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ abstract contract Multicall { /** * @dev Receives and executes a batch of function calls on this contract. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionDelegateCall(address(this), data[i]); } return results; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal initializer { __ERC1967Upgrade_init_unchained(); __UUPSUpgradeable_init_unchained(); } function __UUPSUpgradeable_init_unchained() internal initializer { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; // These are the roles used in the components of the Forta system, except // Forta token itself, that needs to define it's own roles for consistency across chains bytes32 constant DEFAULT_ADMIN_ROLE = bytes32(0); // Routing bytes32 constant ROUTER_ADMIN_ROLE = keccak256("ROUTER_ADMIN_ROLE"); // Base component bytes32 constant ENS_MANAGER_ROLE = keccak256("ENS_MANAGER_ROLE"); bytes32 constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE"); // Registries bytes32 constant AGENT_ADMIN_ROLE = keccak256("AGENT_ADMIN_ROLE"); bytes32 constant SCANNER_ADMIN_ROLE = keccak256("SCANNER_ADMIN_ROLE"); bytes32 constant DISPATCHER_ROLE = keccak256("DISPATCHER_ROLE"); // Staking bytes32 constant SLASHER_ROLE = keccak256("SLASHER_ROLE"); bytes32 constant SWEEPER_ROLE = keccak256("SWEEPER_ROLE"); bytes32 constant REWARDS_ADMIN = keccak256("REWARDS_ADMIN_ROLE"); // Scanner Node Version bytes32 constant SCANNER_VERSION_ROLE = keccak256("SCANNER_VERSION_ROLE");
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/access/IAccessControl.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165CheckerUpgradeable.sol"; import "../Roles.sol"; import "../../errors/GeneralErrors.sol"; abstract contract AccessManagedUpgradeable is ContextUpgradeable { using ERC165CheckerUpgradeable for address; IAccessControl private _accessControl; event AccessManagerUpdated(address indexed newAddressManager); error MissingRole(bytes32 role, address account); /** * @notice Checks if _msgSender() has `role`, reverts if not. * @param role the role to be tested, defined in Roles.sol and set in AccessManager instance. */ modifier onlyRole(bytes32 role) { if (!hasRole(role, _msgSender())) { revert MissingRole(role, _msgSender()); } _; } /** * @notice Initializer method, access point to initialize inheritance tree. * @param manager address of AccessManager. */ function __AccessManaged_init(address manager) internal initializer { if (!manager.supportsInterface(type(IAccessControl).interfaceId)) revert UnsupportedInterface("IAccessControl"); _accessControl = IAccessControl(manager); emit AccessManagerUpdated(manager); } /** * @notice Checks if `accoung has `role` assigned. * @param role the role to be tested, defined in Roles.sol and set in AccessManager instance. * @param account the address to be tested for the role. * @return return true if account has role, false otherwise. */ function hasRole(bytes32 role, address account) internal view returns (bool) { return _accessControl.hasRole(role, account); } /** * @notice Sets AccessManager instance. Restricted to DEFAULT_ADMIN_ROLE * @param newManager address of the new instance of AccessManager. */ function setAccessManager(address newManager) public onlyRole(DEFAULT_ADMIN_ROLE) { if (!newManager.supportsInterface(type(IAccessControl).interfaceId)) revert UnsupportedInterface("IAccessControl"); _accessControl = IAccessControl(newManager); emit AccessManagerUpdated(newManager); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IVersioned { function version() external returns(string memory v); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; abstract contract ForwardedContext is ContextUpgradeable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable _trustedForwarder; uint256 private constant ADDRESS_SIZE_BYTES = 20; /// @custom:oz-upgrades-unsafe-allow constructor constructor(address trustedForwarder) { _trustedForwarder = trustedForwarder; } /// Checks if `forwarder` address provided is the trustedForwarder set in the constructor. function isTrustedForwarder(address forwarder) public view virtual returns (bool) { return forwarder == _trustedForwarder; } /** * @notice Gets sender of the transaction of signer if meta transaction. * @dev If the tx is sent by the trusted forwarded, we assume it is a meta transaction and * the signer address is encoded in the last 20 bytes of msg.data. * @return sender address of sender of the transaction of signer if meta transaction. */ function _msgSender() internal view virtual override returns (address sender) { if (isTrustedForwarder(msg.sender)) { return address(bytes20(msg.data[msg.data.length - ADDRESS_SIZE_BYTES: msg.data.length])); } else { return super._msgSender(); } } /** * @notice Gets msg.data of the transaction or meta-tx. * @dev If the tx is sent by the trusted forwarded, we assume it is a meta transaction and * msg.data must have the signer address (encoded in the last 20 bytes of msg.data) removed. * @return msg.data of the transaction of msg.data - signer address if meta transaction. */ function _msgData() internal view virtual override returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[:msg.data.length - ADDRESS_SIZE_BYTES]; } else { return super._msgData(); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./AccessManaged.sol"; import "../router/IRouter.sol"; import "../../errors/GeneralErrors.sol"; abstract contract RoutedUpgradeable is AccessManagedUpgradeable { IRouter private _router; event RouterUpdated(address indexed router); /** * @notice Initializer method, access point to initialize inheritance tree. * @param router address of Routed. */ function __Routed_init(address router) internal initializer { if (router == address(0)) revert ZeroAddress("router"); _router = IRouter(router); emit RouterUpdated(router); } /** * @dev Routed contracts can use this method to notify the subscribed observers registered * in Router routing table. Hooks may revert on failure or not, as set when calling * Router.setRoutingTable(bytes4 sig, address target, bool enable, bool revertsOnFail) * @param data keccak256 of the method signature and param values the listener contracts. * will execute. */ function _emitHook(bytes memory data) internal { if (address(_router) != address(0)) { try _router.hookHandler(data) {} catch {} } } /// Sets new Router instance. Restricted to DEFAULT_ADMIN_ROLE. function setRouter(address newRouter) public onlyRole(DEFAULT_ADMIN_ROLE) { if (newRouter == address(0)) revert ZeroAddress("newRouter"); _router = IRouter(newRouter); emit RouterUpdated(newRouter); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import { ENS } from "@ensdomains/ens-contracts/contracts/registry/ENS.sol"; interface IReverseRegistrar { function ADDR_REVERSE_NODE() external view returns (bytes32); function ens() external view returns (ENS); function defaultResolver() external view returns (address); function claim(address) external returns (bytes32); function claimWithResolver(address, address) external returns (bytes32); function setName(string calldata) external returns (bytes32); function node(address) external pure returns (bytes32); } library ENSReverseRegistration { // namehash('addr.reverse') bytes32 internal constant ADDR_REVERSE_NODE = 0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2; function setName(address ensregistry, string calldata ensname) internal { IReverseRegistrar(ENS(ensregistry).owner(ADDR_REVERSE_NODE)).setName(ensname); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal initializer { __ERC1967Upgrade_init_unchained(); } function __ERC1967Upgrade_init_unchained() internal initializer { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; _functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165Checker.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165CheckerUpgradeable { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /** * @dev Returns true if `account` supports the {IERC165} interface, */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return _supportsERC165Interface(account, type(IERC165Upgradeable).interfaceId) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. * * _Available since v3.4._ */ function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in _interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!_supportsERC165Interface(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * Interface identification is specified in ERC-165. */ function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { bytes memory encodedParams = abi.encodeWithSelector(IERC165Upgradeable.supportsInterface.selector, interfaceId); (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams); if (result.length < 32) return false; return success && abi.decode(result, (bool)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; error ZeroAddress(string name); error ZeroAmount(string name); error EmptyArray(string name); error UnorderedArray(string name); error UnsupportedInterface(string name); error SenderNotOwner(address sender, uint256 ownedId); error DoesNotHaveAccess(address sender, string access); // Permission here refers to XXXRegistry.sol Permission enums error DoesNotHavePermission(address sender, uint8 permission, uint256 id);
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IRouter { function hookHandler(bytes calldata) external; }
pragma solidity >=0.8.4; interface ENS { // Logged when the owner of a node assigns a new owner to a subnode. event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); // Logged when the owner of a node transfers ownership to a new account. event Transfer(bytes32 indexed node, address owner); // Logged when the resolver for a node changes. event NewResolver(bytes32 indexed node, address resolver); // Logged when the TTL of a node changes event NewTTL(bytes32 indexed node, uint64 ttl); // Logged when an operator is added or removed. event ApprovalForAll(address indexed owner, address indexed operator, bool approved); function setRecord(bytes32 node, address owner, address resolver, uint64 ttl) external virtual; function setSubnodeRecord(bytes32 node, bytes32 label, address owner, address resolver, uint64 ttl) external virtual; function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external virtual returns(bytes32); function setResolver(bytes32 node, address resolver) external virtual; function setOwner(bytes32 node, address owner) external virtual; function setTTL(bytes32 node, uint64 ttl) external virtual; function setApprovalForAll(address operator, bool approved) external virtual; function owner(bytes32 node) external virtual view returns (address); function resolver(bytes32 node) external virtual view returns (address); function ttl(bytes32 node) external virtual view returns (uint64); function recordExists(bytes32 node) external virtual view returns (bool); function isApprovedForAll(address owner, address operator) external virtual view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "../BaseComponentUpgradeable.sol"; import "../staking/StakeSubject.sol"; import "../../tools/FrontRunningProtection.sol"; import "../../errors/GeneralErrors.sol"; abstract contract AgentRegistryCore is BaseComponentUpgradeable, FrontRunningProtection, ERC721Upgradeable, StakeSubjectUpgradeable { StakeThreshold private _stakeThreshold; // 3 storage slots // Initially 0 because the frontrunning protection starts disabled. uint256 public frontRunningDelay; event AgentCommitted(bytes32 indexed commit); event AgentUpdated(uint256 indexed agentId, address indexed by, string metadata, uint256[] chainIds); event StakeThresholdChanged(uint256 min, uint256 max, bool activated); event FrontRunningDelaySet(uint256 delay); /** * @notice Checks sender (or metatx signer) is owner of the agent token. * @param agentId ERC1155 token id of the agent. */ modifier onlyOwnerOf(uint256 agentId) { if (_msgSender() != ownerOf(agentId)) revert SenderNotOwner(_msgSender(), agentId); _; } /** * @notice Checks if array of uint256 is sorted from lower (index 0) to higher (array.length -1) * @param array to check */ modifier onlySorted(uint256[] memory array) { if (array.length == 0 ) revert EmptyArray("chainIds"); for (uint256 i = 1; i < array.length; i++ ) { if (array[i] <= array[i-1]) revert UnorderedArray("chainIds"); } _; } /** * @notice Save commit representing an agent to prevent frontrunning of their creation * @param commit keccak256 hash of the agent creation's parameters */ function prepareAgent(bytes32 commit) public { _frontrunCommit(commit); } /** * @notice Agent creation method. Mints an ERC1155 token with the agent id for the owner and stores metadata. * @dev fires _before and _after hooks within the inheritance tree. * If front run protection is enabled (disabled by default), it will check if the keccak256 hash of the parameters * has been committed in prepareAgent(bytes32). * @param agentId ERC1155 token id of the agent to be created. * @param owner address to have ownership privileges in the agent methods. * @param metadata IPFS pointer to agent's metadata JSON. * @param chainIds ordered list of chainIds where the agent wants to run. */ function createAgent(uint256 agentId, address owner, string calldata metadata, uint256[] calldata chainIds) public onlySorted(chainIds) frontrunProtected(keccak256(abi.encodePacked(agentId, owner, metadata, chainIds)), frontRunningDelay) { _mint(owner, agentId); _beforeAgentUpdate(agentId, metadata, chainIds); _agentUpdate(agentId, metadata, chainIds); _afterAgentUpdate(agentId, metadata, chainIds); } /** * @notice Checks if the agentId has been minted. * @param agentId ERC1155 token id of the agent. * @return true if agentId exists, false otherwise. */ function isCreated(uint256 agentId) public view returns(bool) { return _exists(agentId); } /** * @notice Updates parameters of an agentId (metadata, image, chain IDs...) if called by the agent owner. * @dev fires _before and _after hooks within the inheritance tree. * @param agentId ERC1155 token id of the agent to be updated. * @param metadata IPFS pointer to agent's metadata JSON. * @param chainIds ordered list of chainIds where the agent wants to run. */ function updateAgent(uint256 agentId, string calldata metadata, uint256[] calldata chainIds) public onlyOwnerOf(agentId) onlySorted(chainIds) { _beforeAgentUpdate(agentId, metadata, chainIds); _agentUpdate(agentId, metadata, chainIds); _afterAgentUpdate(agentId, metadata, chainIds); } /** @dev StakeThreshold setter, common to all Agents. Restricted to AGENT_ADMIN_ROLE, emits StakeThresholdChanged */ function setStakeThreshold(StakeThreshold memory newStakeThreshold) external onlyRole(AGENT_ADMIN_ROLE) { if (newStakeThreshold.max <= newStakeThreshold.min) revert StakeThresholdMaxLessOrEqualMin(); _stakeThreshold = newStakeThreshold; emit StakeThresholdChanged(newStakeThreshold.min, newStakeThreshold.max, newStakeThreshold.activated); } /** @dev stake threshold common for all agents */ function getStakeThreshold(uint256 /*subject*/) public override view returns (StakeThreshold memory) { return _stakeThreshold; } /** * Checks if agent is staked over minimum stake * @param subject agentId * @return true if agent is staked over the minimum threshold, or staking is not yet enabled (stakeController = 0). * false otherwise */ function _isStakedOverMin(uint256 subject) internal override view returns(bool) { if (address(getStakeController()) == address(0)) { return true; } return getStakeController().activeStakeFor(AGENT_SUBJECT, subject) >= _stakeThreshold.min; } /** * @dev allows AGENT_ADMIN_ROLE to activate frontrunning protection for agents * @param delay in seconds */ function setFrontRunningDelay(uint256 delay) external onlyRole(AGENT_ADMIN_ROLE) { frontRunningDelay = delay; emit FrontRunningDelaySet(delay); } /** * @notice hook fired before agent creation or update. * @dev does nothing in this contract. * @param agentId ERC1155 token id of the agent to be created or updated. * @param newMetadata IPFS pointer to agent's metadata JSON. * @param newChainIds ordered list of chainIds where the agent wants to run. */ function _beforeAgentUpdate(uint256 agentId, string memory newMetadata, uint256[] calldata newChainIds) internal virtual { } /** * @notice logic for agent update. * @dev emits AgentUpdated, will be extended by child contracts. * @param agentId ERC1155 token id of the agent to be created or updated. * @param newMetadata IPFS pointer to agent's metadata JSON. * @param newChainIds ordered list of chainIds where the agent wants to run. */ function _agentUpdate(uint256 agentId, string memory newMetadata, uint256[] calldata newChainIds) internal virtual { emit AgentUpdated(agentId, _msgSender(), newMetadata, newChainIds); } /** * @notice hook fired after agent creation or update. * @dev emits Router hook. * @param agentId ERC1155 token id of the agent to be created or updated. * @param newMetadata IPFS pointer to agent's metadata JSON. * @param newChainIds ordered list of chainIds where the agent wants to run. */ function _afterAgentUpdate(uint256 agentId, string memory newMetadata, uint256[] calldata newChainIds) internal virtual { _emitHook(abi.encodeWithSignature("hook_afterAgentUpdate(uint256,string,uint256[])", agentId, newMetadata, newChainIds)); } /** * Obligatory inheritance dismambiguation of ForwardedContext's _msgSender() * @return sender msg.sender if not a meta transaction, signer of forwarder metatx if it is. */ function _msgSender() internal view virtual override(ContextUpgradeable, BaseComponentUpgradeable) returns (address sender) { return super._msgSender(); } /** * Obligatory inheritance dismambiguation of ForwardedContext's _msgSender() * @return sender msg.data if not a meta transaction, forwarder data in metatx if it is. */ function _msgData() internal view virtual override(ContextUpgradeable, BaseComponentUpgradeable) returns (bytes calldata) { return super._msgData(); } uint256[41] private __gap; // 50 - 1 (frontRunningDelay) - 3 (_stakeThreshold) - 5 StakeSubjectUpgradeable }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/structs/BitMaps.sol"; import "./AgentRegistryCore.sol"; /** * @dev AgentRegistry methods and state handling disabling and enabling agents, and * recognizing stake changes that might disable an agent. * NOTE: This contract was deployed before StakeAwareUpgradeable was created, so __StakeAwareUpgradeable_init * is not called. */ abstract contract AgentRegistryEnable is AgentRegistryCore { using BitMaps for BitMaps.BitMap; enum Permission { ADMIN, OWNER, length } mapping(uint256 => BitMaps.BitMap) private _disabled; event AgentEnabled(uint256 indexed agentId, bool indexed enabled, Permission permission, bool value); /** * @notice Check if agent is enabled * @param agentId ERC1155 token id of the agent. * @return true if the agent exist, has not been disabled, and is staked over minimum * Returns false if otherwise */ function isEnabled(uint256 agentId) public view virtual returns (bool) { return isCreated(agentId) && _getDisableFlags(agentId) == 0 && _isStakedOverMin(agentId); } /** * @notice Enable an agent if sender has correct permission and the agent is staked over minimum stake. * @dev agents can be disabled by ADMIN or OWNER. * @param agentId ERC1155 token id of the agent. * @param permission the sender claims to have to enable the agent. */ function enableAgent(uint256 agentId, Permission permission) public virtual { if (!_isStakedOverMin(agentId)) revert StakedUnderMinimum(agentId); if (!_hasPermission(agentId, permission)) revert DoesNotHavePermission(_msgSender(), uint8(permission), agentId); _enable(agentId, permission, true); } /** * @notice Disable an agent if sender has correct permission. * @dev agents can be disabled by ADMIN or OWNER. * @param agentId ERC1155 token id of the agent. * @param permission the sender claims to have to enable the agent. */ function disableAgent(uint256 agentId, Permission permission) public virtual { if (!_hasPermission(agentId, permission)) revert DoesNotHavePermission(_msgSender(), uint8(permission), agentId); _enable(agentId, permission, false); } /** * @notice Permission check. * @dev it does not uses AccessManager since it is agent specific * @param agentId ERC1155 token id of the agent. * @param permission the sender claims to have to enable the agent. * @return true if: permission.ADMIN and _msgSender is ADMIN_ROLE, Permission.OWNER and owner of agentId, * false otherwise. */ function _hasPermission(uint256 agentId, Permission permission) internal view returns (bool) { if (permission == Permission.ADMIN) { return hasRole(AGENT_ADMIN_ROLE, _msgSender()); } if (permission == Permission.OWNER) { return _msgSender() == ownerOf(agentId); } return false; } /** * @notice Internal methods for enabling the agent. * @dev fires hook _before and _after enable within the inheritance tree. * @param agentId ERC1155 token id of the agent. * @param permission the sender claims to have to enable the agent. * @param enable true if enabling, false if disabling. */ function _enable(uint256 agentId, Permission permission, bool enable) internal { _beforeAgentEnable(agentId, permission, enable); _agentEnable(agentId, permission, enable); _afterAgentEnable(agentId, permission, enable); } /** * @notice Get the disabled flags for an agentId. * @dev Permission (uint8) is used for indexing, so we don't need to loop. * If not disabled, all flags will be 0. * @param agentId ERC1155 token id of the agent. * @return uint256 containing the byte flags. */ function _getDisableFlags(uint256 agentId) internal view returns (uint256) { return _disabled[agentId]._data[0]; } /** * @notice Hook _before agent enable * @dev does nothing in this contract * @param agentId ERC1155 token id of the agent. * @param permission the sender claims to have to enable the agent. * @param value true if enabling, false if disabling. */ function _beforeAgentEnable(uint256 agentId, Permission permission, bool value) internal virtual { } /** * @notice Logic for enabling agents, sets flag corresponding to permission. * @dev does nothing in this contract * @param agentId ERC1155 token id of the agent. * @param permission the sender claims to have to enable the agent. * @param value true if enabling, false if disabling. */ function _agentEnable(uint256 agentId, Permission permission, bool value) internal virtual { _disabled[agentId].setTo(uint8(permission), !value); emit AgentEnabled(agentId, isEnabled(agentId), permission, value); } /** * @notice Hook _after agent enable * @dev emits Router hook * @param agentId ERC1155 token id of the agent. * @param permission the sender claims to have to enable the agent. * @param value true if enabling, false if disabling. */ function _afterAgentEnable(uint256 agentId, Permission permission, bool value) internal virtual { _emitHook(abi.encodeWithSignature("hook_afterAgentEnable(uint256,uint8,bool)", agentId, uint8(permission), value)); } /** * Obligatory inheritance dismambiguation of ForwardedContext's _msgSender() * @return sender msg.sender if not a meta transaction, signer of forwarder metatx if it is. */ function _msgSender() internal view virtual override(AgentRegistryCore) returns (address sender) { return super._msgSender(); } /** * Obligatory inheritance dismambiguation of ForwardedContext's _msgSender() * @return sender msg.data if not a meta transaction, forwarder data in metatx if it is. */ function _msgData() internal view virtual override(AgentRegistryCore) returns (bytes calldata) { return super._msgData(); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "./AgentRegistryMetadata.sol"; abstract contract AgentRegistryEnumerable is AgentRegistryMetadata { using EnumerableSet for EnumerableSet.UintSet; EnumerableSet.UintSet private _allAgents; mapping(uint256 => EnumerableSet.UintSet) private _chainAgents; /** * Agent count. * @dev Helper for external iteration. * @return total amount of registered agents. */ function getAgentCount() public view returns (uint256) { return _allAgents.length(); } /** * Agent id at index in _allAgents array. * @dev Helper for external iteration. * @param index of agent in _allAgents array. * @return agentId at index. */ function getAgentByIndex(uint256 index) public view returns (uint256) { return _allAgents.at(index); } /** * Registered agent count by chainId. * @dev Helper for external iteration. * @param chainId. * @return agent total registered by chainId. */ function getAgentCountByChain(uint256 chainId) public view returns (uint256) { return _chainAgents[chainId].length(); } /** * Agent id at index, by chainId * @dev Helper for external iteration. * @param chainId where the agent was registered. * @param index of agent in _chainAgents[chainId] array. * @return agentId at index for that chainId. */ function getAgentByChainAndIndex(uint256 chainId, uint256 index) public view returns (uint256) { return _chainAgents[chainId].at(index); } /** * @notice hook fired before agent creation or update. * @dev stores agent in _allAgents if it wasn't there, manages agent arrays by chain. * @param agentId ERC1155 token id of the agent to be created or updated. * @param newMetadata IPFS pointer to agent's metadata JSON. * @param newChainIds ordered list of chainIds where the agent wants to run. */ function _beforeAgentUpdate(uint256 agentId, string memory newMetadata, uint256[] calldata newChainIds) internal virtual override { super._beforeAgentUpdate(agentId, newMetadata, newChainIds); (,,uint256 version,, uint256[] memory oldChainIds) = getAgent(agentId); if (version == 0) { _allAgents.add(agentId); } //NOTE: ignoring EnumerableSet.add() bool output; We don't care if already added. uint256 i = 0; uint256 j = 0; while (i < oldChainIds.length || j < newChainIds.length) { if (i == oldChainIds.length) { // no more old chains, just add the remaining new chains _chainAgents[newChainIds[j++]].add(agentId); } else if (j == newChainIds.length) { // no more new chain, just remove the remaining old chains _chainAgents[oldChainIds[i++]].remove(agentId); } else if (oldChainIds[i] < newChainIds[j]) { // old chain smaller, remove if _chainAgents[oldChainIds[i++]].remove(agentId); } else if (oldChainIds[i] > newChainIds[j]) { // new chain smaller, add it _chainAgents[newChainIds[j++]].add(agentId); } else { // chainIds are the same do nothing i++; j++; } } } uint256[48] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./AgentRegistryCore.sol"; abstract contract AgentRegistryMetadata is AgentRegistryCore { struct AgentMetadata { uint256 version; string metadata; uint256[] chainIds; } mapping(uint256 => AgentMetadata) private _agentMetadata; mapping(bytes32 => bool) private _agentMetadataUniqueness; error MetadataNotUnique(bytes32 hash); /** * @notice Gets agent metadata, version and chain Ids. * @param agentId ERC1155 token id of the agent. * @return created if agent exists. * @return owner address. * @return agentVersion of the agent. * @return metadata IPFS pointer. * @return chainIds the agent wants to run in. */ function getAgent(uint256 agentId) public view returns (bool created, address owner,uint256 agentVersion, string memory metadata, uint256[] memory chainIds) { bool exists = _exists(agentId); return ( exists, exists ? ownerOf(agentId) : address(0), _agentMetadata[agentId].version, _agentMetadata[agentId].metadata, _agentMetadata[agentId].chainIds ); } /** * @notice logic for agent update. * @dev checks metadata uniqueness and updates agent metadata and version. * @param agentId ERC1155 token id of the agent to be created or updated. * @param newMetadata IPFS pointer to agent's metadata JSON. * @param newChainIds ordered list of chainIds where the agent wants to run. */ function _agentUpdate(uint256 agentId, string memory newMetadata, uint256[] calldata newChainIds) internal virtual override { super._agentUpdate(agentId, newMetadata, newChainIds); bytes32 oldHash = keccak256(bytes(_agentMetadata[agentId].metadata)); bytes32 newHash = keccak256(bytes(newMetadata)); if (_agentMetadataUniqueness[newHash]) revert MetadataNotUnique(newHash); _agentMetadataUniqueness[newHash] = true; _agentMetadataUniqueness[oldHash] = false; uint256 version = _agentMetadata[agentId].version + 1; _agentMetadata[agentId] = AgentMetadata({ version: version, metadata: newMetadata, chainIds: newChainIds }); } uint256[48] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} uint256[44] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "../../errors/GeneralErrors.sol"; import "../staking/IStakeController.sol"; import "../staking/SubjectTypes.sol"; import "../Roles.sol"; import "../utils/AccessManaged.sol"; abstract contract StakeSubjectUpgradeable is AccessManagedUpgradeable, IStakeSubject { IStakeController private _stakeController; event StakeControllerUpdated(address indexed newstakeController); error StakeThresholdMaxLessOrEqualMin(); error StakedUnderMinimum(uint256 subject); /* * @dev: For contracts made StakeAwareUpgradeable via upgrade, initializer call is not available. * Use setStakeController(stakeController) when upgrading instead. * @param stakeController address. */ function __StakeAwareUpgradeable_init(address stakeController) internal initializer { _setStakeController(stakeController); } /// Stake controller setter, restricted to DEFAULT_ADMIN_ROLE function setStakeController(address stakeController) public onlyRole(DEFAULT_ADMIN_ROLE) { _setStakeController(stakeController); } /// Getter for stakeController function getStakeController() public view returns(IStakeController) { return _stakeController; } /// Internal setter for StakeController, emits StakeControllerUpdated function _setStakeController(address stakeController) private { if (stakeController == address(0)) revert ZeroAddress("stakeController"); _stakeController = IStakeController(stakeController); emit StakeControllerUpdated(stakeController); } /// Returns true if `subject` amount of staked tokens is bigger or equal the minimum stake set /// for it. It's for contracts implementing `StakeSubjectUpgradeable` to decide what that means. function isStakedOverMin(uint256 subject) external virtual override view returns(bool) { return _isStakedOverMin(subject); } function _isStakedOverMin(uint256 subject) internal virtual view returns(bool); uint256[4] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /** *@dev FrontRunningProtection class usef for commit-reveal schemes with deadline. * We don't emit events to not broadcast the commits, devs will have to use the getter. */ contract FrontRunningProtection { mapping(bytes32 => uint256) private _commits; error CommitNotReady(); error CommitAlreadyExists(); /** * Use it to enforce the need of a previous commit within duration * Will consume the commit if we are within deadline * @param commit the commit ID * @param duration duration in seconds */ modifier frontrunProtected(bytes32 commit, uint256 duration) { uint256 timestamp = _commits[commit]; if (!(duration == 0 || (timestamp != 0 && timestamp + duration <= block.timestamp))) revert CommitNotReady(); delete _commits[commit]; _; } /** * Gets duration for a commit * @param commit ID * @return commit duration or zero if not found */ function getCommitTimestamp(bytes32 commit) external view returns(uint256) { return _commits[commit]; } /** * Saves commits deadline if commit does not exist * @param commit id */ function _frontrunCommit(bytes32 commit) internal { if (_commits[commit] != 0) revert CommitAlreadyExists(); _commits[commit] = block.timestamp; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./IStakeSubject.sol"; interface IStakeController { event StakeSubjectHandlerChanged(address newHandler, address oldHandler); function setStakeSubjectHandler(uint8 subjectType, IStakeSubject subjectHandler) external; function activeStakeFor(uint8 subjectType, uint256 subject) external view returns(uint256); function maxStakeFor(uint8 subjectType, uint256 subject) external view returns(uint256); function minStakeFor(uint8 subjectType, uint256 subject) external view returns(uint256); function isStakeActivatedFor(uint8 subjectType, uint256 subject) external view returns(bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; uint8 constant SCANNER_SUBJECT = 0; uint8 constant AGENT_SUBJECT = 1; contract SubjectTypeValidator { error InvalidSubjectType(uint8 subjectType); /** * @dev check if `subjectType` belongs to the defined SUBJECT_TYPES * @param subjectType is not an enum because some contracts using subjectTypes are not * upgradeable (StakinEscrow) */ modifier onlyValidSubjectType(uint8 subjectType) { if ( subjectType != SCANNER_SUBJECT && subjectType != AGENT_SUBJECT ) revert InvalidSubjectType(subjectType); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface IStakeSubject { struct StakeThreshold { uint256 min; uint256 max; bool activated; } function getStakeThreshold(uint256 subject) external view returns (StakeThreshold memory); function isStakedOverMin(uint256 subject) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/structs/BitMaps.sol) pragma solidity ^0.8.0; /** * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential. * Largelly inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. */ library BitMaps { struct BitMap { mapping(uint256 => uint256) _data; } /** * @dev Returns whether the bit at `index` is set. */ function get(BitMap storage bitmap, uint256 index) internal view returns (bool) { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); return bitmap._data[bucket] & mask != 0; } /** * @dev Sets the bit at `index` to the boolean `value`. */ function setTo( BitMap storage bitmap, uint256 index, bool value ) internal { if (value) { set(bitmap, index); } else { unset(bitmap, index); } } /** * @dev Sets the bit at `index`. */ function set(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] |= mask; } /** * @dev Unsets the bit at `index`. */ function unset(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] &= ~mask; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "../BaseComponentUpgradeable.sol"; import "../staking/StakeSubject.sol"; import "../../errors/GeneralErrors.sol"; abstract contract ScannerRegistryCore is BaseComponentUpgradeable, ERC721Upgradeable, StakeSubjectUpgradeable { mapping(uint256 => StakeThreshold) internal _stakeThresholds; event ScannerUpdated(uint256 indexed scannerId, uint256 indexed chainId, string metadata); event StakeThresholdChanged(uint256 indexed chainId, uint256 min, uint256 max, bool activated); error ScannerNotRegistered(address scanner); error PublicRegistrationDisabled(uint256 chainId); /** * @notice Checks sender (or metatx signer) is owner of the scanner token. * @param scannerId ERC1155 token id of the scanner. */ modifier onlyOwnerOf(uint256 scannerId) { if (_msgSender() != ownerOf(scannerId)) revert SenderNotOwner(_msgSender(), scannerId); _; } /** * @notice Scanner registration via admin key. * @dev restricted to SCANNER_ADMIN_ROLE. Scanner address will be converted to uin256 ERC1155 token id. * @param scanner address generated by scanner software. * @param owner of the scanner. Will have admin privileges over the registering scanner. * @param chainId that the scanner will monitor. * @param metadata IPFS pointer to scanner's metadata JSON */ function adminRegister(address scanner, address owner, uint256 chainId, string calldata metadata) public onlyRole(SCANNER_ADMIN_ROLE) { _register(scanner, owner, chainId, metadata); } /** * @notice Checks if scannerId has been registered (minted). * @param scannerId ERC1155 token id of the scanner. * @return true if scannerId exists, false otherwise. */ function isRegistered(uint256 scannerId) public view returns(bool) { return _exists(scannerId); } /** * @notice Public method for scanners to self register in Forta and mint registration ERC1155 token. * @dev _msgSender() will be considered the Scanner Node address. * @param owner of the scanner. Will have admin privileges over the registering scanner. * @param chainId that the scanner will monitor. * @param metadata IPFS pointer to scanner's metadata JSON */ function register(address owner, uint256 chainId, string calldata metadata) virtual public { if (!(_stakeThresholds[chainId].activated)) revert PublicRegistrationDisabled(chainId); _register(_msgSender(), owner, chainId, metadata); } /** * @notice Internal method for scanners to self register in Forta and mint registration ERC1155 token. * Public staking must be activated in the target chainId. * @dev Scanner address will be converted to uin256 ERC1155 token id. Will trigger _before and _after hooks within * the inheritance tree. * @param owner of the scanner. Will have admin privileges over the registering scanner. * @param chainId that the scanner will monitor. * @param metadata IPFS pointer to scanner's metadata JSON */ function _register(address scanner, address owner, uint256 chainId, string calldata metadata) internal { uint256 scannerId = scannerAddressToId(scanner); _mint(owner, scannerId); _beforeScannerUpdate(scannerId, chainId, metadata); _scannerUpdate(scannerId, chainId, metadata); _afterScannerUpdate(scannerId, chainId, metadata); } /** * @notice Allows the admin to update chainId and metadata. * @dev Restricted to SCANNER_ADMIN_ROLE. Will trigger _before and _after hooks within the inheritance tree. * @param scanner address of the Scanner Node. * @param chainId that the scanner will monitor. * @param metadata IPFS pointer to scanner's metadata JSON */ function adminUpdate(address scanner, uint256 chainId, string calldata metadata) public onlyRole(SCANNER_ADMIN_ROLE) { uint256 scannerId = scannerAddressToId(scanner); if (!isRegistered(scannerId)) revert ScannerNotRegistered(scanner); _beforeScannerUpdate(scannerId, chainId, metadata); _scannerUpdate(scannerId, chainId, metadata); _afterScannerUpdate(scannerId, chainId, metadata); } /// Converts scanner address to uint256 for ERC1155 Token Id. function scannerAddressToId(address scanner) public pure returns(uint256) { return uint256(uint160(scanner)); } /** * @notice Sets stake parameters (min, max, activated) for a `chainId`. Restricted to SCANNER_ADMIN_ROLE * @param newStakeThreshold struct with stake parameters. * @param chainId chain the parameters will affect. */ function setStakeThreshold(StakeThreshold calldata newStakeThreshold, uint256 chainId) external onlyRole(SCANNER_ADMIN_ROLE) { if (newStakeThreshold.max <= newStakeThreshold.min) revert StakeThresholdMaxLessOrEqualMin(); emit StakeThresholdChanged(chainId, newStakeThreshold.min, newStakeThreshold.max, newStakeThreshold.activated); _stakeThresholds[chainId] = newStakeThreshold; } /** * @dev internal getter for _getStakeThreshold, inheriting contracts may define logic to associate * a scanner with a StakeThreshold */ function _getStakeThreshold(uint256 subject) internal virtual view returns(StakeThreshold memory); /** * @notice Getter for StakeThreshold for the scanner with id `subject` */ function getStakeThreshold(uint256 subject) external view returns(StakeThreshold memory) { return _getStakeThreshold(subject); } /** * Checks if scanner is staked over minimum stake * @param scannerId scanner * @return true if scanner is staked over the minimum threshold for that chainId, or staking is not yet enabled (stakeController = 0). * false otherwise */ function _isStakedOverMin(uint256 scannerId) internal virtual override view returns(bool) { if (address(getStakeController()) == address(0)) { return true; } return getStakeController().activeStakeFor(SCANNER_SUBJECT, scannerId) >= _getStakeThreshold(scannerId).min; } /** * @notice _before hook triggered before scanner creation or update. * @dev Does nothing in this base contract. * @param scannerId ERC1155 token id of the scanner. * @param chainId that the scanner will monitor. * @param metadata IPFS pointer to scanner's metadata JSON */ function _beforeScannerUpdate(uint256 scannerId, uint256 chainId, string calldata metadata) internal virtual { } /** * @notice Scanner update logic. * @dev Emits ScannerUpdated(scannerId, chainId, metadata) * @param scannerId ERC1155 token id of the scanner. * @param chainId that the scanner will monitor. * @param metadata IPFS pointer to scanner's metadata JSON */ function _scannerUpdate(uint256 scannerId, uint256 chainId, string calldata metadata) internal virtual { emit ScannerUpdated(scannerId, chainId, metadata); } /** * @notice _after hook triggered after scanner creation or update. * @dev emits Router hook * @param scannerId ERC1155 token id of the scanner. * @param chainId that the scanner will monitor. * @param metadata IPFS pointer to scanner's metadata JSON */ function _afterScannerUpdate(uint256 scannerId, uint256 chainId, string calldata metadata) internal virtual { _emitHook(abi.encodeWithSignature("hook_afterScannerUpdate(uint256,uint256,string)", scannerId, chainId, metadata)); } /** * @notice Helper to get either msg msg.sender if not a meta transaction, signer of forwarder metatx if it is. * @inheritdoc ForwardedContext */ function _msgSender() internal view virtual override(BaseComponentUpgradeable, ContextUpgradeable) returns (address sender) { return super._msgSender(); } /** * @notice Helper to get msg.data if not a meta transaction, forwarder data in metatx if it is. * @inheritdoc ForwardedContext */ function _msgData() internal view virtual override(BaseComponentUpgradeable, ContextUpgradeable) returns (bytes calldata) { return super._msgData(); } uint256[44] private __gap; // 50 - 1 (_stakeThresholds) - 5 (StakeSubjectUpgradeable) }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "./ScannerRegistryCore.sol"; abstract contract ScannerRegistryManaged is ScannerRegistryCore { using EnumerableSet for EnumerableSet.AddressSet; mapping(uint256 => EnumerableSet.AddressSet) private _managers; event ManagerEnabled(uint256 indexed scannerId, address indexed manager, bool enabled); error SenderNotManager(address sender, uint256 scannerId); /** * @notice Checks sender (or metatx signer) is manager of the scanner token. * @param scannerId ERC1155 token id of the scanner. */ modifier onlyManagerOf(uint256 scannerId) { if (!_managers[scannerId].contains(_msgSender())) revert SenderNotManager(_msgSender(), scannerId); _; } /** * @notice Checks if address is defined as a manager for a scanner. * @param scannerId ERC1155 token id of the scanner. * @param manager address to check. * @return true if defined as manager for scanner, false otherwise. */ function isManager(uint256 scannerId, address manager) public view virtual returns (bool) { return _managers[scannerId].contains(manager); } /** * @notice Gets total managers defined for a scanner. * @dev helper for external iteration. * @param scannerId ERC1155 token id of the scanner. * @return total managers defined for a scanner. */ function getManagerCount(uint256 scannerId) public view virtual returns (uint256) { return _managers[scannerId].length(); } /** * @notice Gets manager address at certain position of the scanner's manager set. * @dev helper for external iteration. * @param scannerId ERC1155 token id of the scanner. * @param index position in the set. * @return address of the manager at index. */ function getManagerAt(uint256 scannerId, uint256 index) public view virtual returns (address) { return _managers[scannerId].at(index); } /** * @notice Adds or removes a manager to a certain scanner. Restricted to scanner owner. * @param scannerId ERC1155 token id of the scanner. * @param manager address to be added or removed fromm manager list for the scanner. * @param enable true for adding, false for removing. */ function setManager(uint256 scannerId, address manager, bool enable) public onlyOwnerOf(scannerId) { if (enable) { _managers[scannerId].add(manager); } else { _managers[scannerId].remove(manager); } emit ManagerEnabled(scannerId, manager, enable); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/structs/BitMaps.sol"; import "./ScannerRegistryManaged.sol"; /** * @dev ScannerRegistry methods and state handling disabling and enabling scanners, and * recognizing stake changes that might disable a scanner. * NOTE: This contract was deployed before StakeAwareUpgradeable was created, so __StakeAwareUpgradeable_init * is not called. */ abstract contract ScannerRegistryEnable is ScannerRegistryManaged { using BitMaps for BitMaps.BitMap; enum Permission { ADMIN, SELF, OWNER, MANAGER, length } mapping(uint256 => BitMaps.BitMap) private _disabled; event ScannerEnabled(uint256 indexed scannerId, bool indexed enabled, Permission permission, bool value); /** * @notice Check if scanner is enabled * @param scannerId ERC1155 token id of the scanner. * @return true if the scanner is registered, has not been disabled, and is staked over minimum value. * Returns false if otherwise */ function isEnabled(uint256 scannerId) public view virtual returns (bool) { return isRegistered(scannerId) && _getDisableFlags(scannerId) == 0 && _isStakedOverMin(scannerId); } /** * @notice Public method to enable a scanner, if caller has permission. Scanner must be staked over minimum defined * for the scanner's chainId. * @param scannerId ERC1155 token id of the scanner. * @param permission the caller claims to have. */ function enableScanner(uint256 scannerId, Permission permission) public virtual { if (!_isStakedOverMin(scannerId)) revert StakedUnderMinimum(scannerId); if (!_hasPermission(scannerId, permission)) revert DoesNotHavePermission(_msgSender(), uint8(permission), scannerId); _enable(scannerId, permission, true); } /** * @notice Public method to disable a scanner, if caller has permission. * @param scannerId ERC1155 token id of the scanner. * @param permission the caller claims to have. */ function disableScanner(uint256 scannerId, Permission permission) public virtual { if (!_hasPermission(scannerId, permission)) revert DoesNotHavePermission(_msgSender(), uint8(permission), scannerId); _enable(scannerId, permission, false); } /** * @notice Method that does permission checks. * @dev AccessManager is not used since the permission is specific for scannerId * @param scannerId ERC1155 token id of the scanner. * @param permission the caller claims to have. * @return true if (ADMIN and _msgSender() has SCANNER_ADMIN_ROLE), if _msgSender() is the scanner itself, its owner * or manager for each respective permission, false otherwise. */ function _hasPermission(uint256 scannerId, Permission permission) internal view returns (bool) { if (permission == Permission.ADMIN) { return hasRole(SCANNER_ADMIN_ROLE, _msgSender()); } if (permission == Permission.SELF) { return uint256(uint160(_msgSender())) == scannerId; } if (permission == Permission.OWNER) { return _msgSender() == ownerOf(scannerId); } if (permission == Permission.MANAGER) { return isManager(scannerId, _msgSender()); } return false; } /** * @notice Internal method to enable a scanner. * @dev will trigger _before and _after enable hooks within the inheritance tree. * @param scannerId ERC1155 token id of the scanner. * @param permission the caller claims to have. * @param enable true for enabling, false for disabling */ function _enable(uint256 scannerId, Permission permission, bool enable) internal { _beforeScannerEnable(scannerId, permission, enable); _scannerEnable(scannerId, permission, enable); _afterScannerEnable(scannerId, permission, enable); } /** * Get the disabled flags for an agentId. Permission (uint8) is used for indexing, so we don't * need to loop. * If not disabled, all flags will be 0 * @param scannerId ERC1155 token id of the scanner. * @return uint256 containing the byte flags. */ function _getDisableFlags(uint256 scannerId) internal view returns (uint256) { return _disabled[scannerId]._data[0]; } /** * @notice Hook _before scanner enable * @dev does nothing in this contract * @param scannerId ERC1155 token id of the scanner. * @param permission the sender claims to have to enable the agent. * @param value true if enabling, false if disabling. */ function _beforeScannerEnable(uint256 scannerId, Permission permission, bool value) internal virtual { } /** * @notice Logic for enabling or disabling the scanner. * @dev sets the corresponding byte in _disabled bitmap for scannerId. Emits ScannerEnabled event. * @param scannerId ERC1155 token id of the scanner. * @param permission the sender claims to have to enable the agent. * @param value true if enabling, false if disabling. */ function _scannerEnable(uint256 scannerId, Permission permission, bool value) internal virtual { _disabled[scannerId].setTo(uint8(permission), !value); emit ScannerEnabled(scannerId, isEnabled(scannerId), permission, value); } /** * @notice Hook _after scanner enable * @dev emits Router hook. * @param scannerId ERC1155 token id of the scanner. * @param permission the sender claims to have to enable the agent. * @param value true if enabling, false if disabling. */ function _afterScannerEnable(uint256 scannerId, Permission permission, bool value) internal virtual { _emitHook(abi.encodeWithSignature("hook_afterScannerEnable(uint256,uint8,bool)", scannerId, uint8(permission), value)); } /** * Obligatory inheritance dismambiguation of ForwardedContext's _msgSender() * @return sender msg.sender if not a meta transaction, signer of forwarder metatx if it is. */ function _msgSender() internal view virtual override(ScannerRegistryCore) returns (address sender) { return super._msgSender(); } /** * Obligatory inheritance dismambiguation of ForwardedContext's _msgSender() * @return sender msg.data if not a meta transaction, forwarder data in metatx if it is. */ function _msgData() internal view virtual override(ScannerRegistryCore) returns (bytes calldata) { return super._msgData(); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "./ScannerRegistryCore.sol"; abstract contract ScannerRegistryMetadata is ScannerRegistryCore { struct ScannerMetadata { uint256 chainId; string metadata; } mapping(uint256 => ScannerMetadata) private _scannerMetadata; /** * @notice Gets all scanner properties. * @param scannerId ERC1155 token id of the scanner. * @return registered true if scanner exists. * @return owner address. * @return chainId the scanner is monitoring. * @return metadata IPFS pointer for the scanner's JSON metadata. */ function getScanner(uint256 scannerId) public view returns (bool registered, address owner, uint256 chainId, string memory metadata) { bool exists = _exists(scannerId); return ( exists, exists ? ownerOf(scannerId) : address(0), _scannerMetadata[scannerId].chainId, _scannerMetadata[scannerId].metadata ); } /** * @notice Gets scanner chain Ids. * @param scannerId ERC1155 token id of the scanner. * @return chainId the scanner is monitoring. */ function getScannerChainId(uint256 scannerId) public view returns (uint256) { return _scannerMetadata[scannerId].chainId; } /** * @dev checks the StakeThreshold for the chainId the scanner with id `subject` was registered to monitor. * @param subject ERC1155 token id of the scanner. * @return StakeThreshold registered for `chainId`, or StakeThreshold(0,0,false) if `chainId` not found. */ function _getStakeThreshold(uint256 subject) override virtual internal view returns(StakeThreshold memory) { return _stakeThresholds[getScannerChainId(subject)]; } /** * @notice internal logic for scanner update. * @dev adds metadata and chainId for that scanner * @param scannerId ERC1155 token id of the scanner. * @param chainId the scanner scans. * @param metadata IPFS pointer for the scanner's JSON metadata. */ function _scannerUpdate(uint256 scannerId, uint256 chainId, string calldata metadata) internal virtual override { super._scannerUpdate(scannerId, chainId, metadata); _scannerMetadata[scannerId] = ScannerMetadata({ chainId: chainId, metadata: metadata }); } uint256[49] private __gap; }
{ "optimizer": { "enabled": true, "runs": 999 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"Disabled","type":"error"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"InvalidId","type":"error"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"MissingRole","type":"error"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"UnsupportedInterface","type":"error"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAddressManager","type":"address"}],"name":"AccessManagerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"agentId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"scannerId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"enable","type":"bool"}],"name":"AlreadyLinked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"agentId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"scannerId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"enable","type":"bool"}],"name":"Link","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"router","type":"address"}],"name":"RouterUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"uint256","name":"scannerId","type":"uint256"},{"internalType":"uint256","name":"pos","type":"uint256"}],"name":"agentAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"}],"name":"agentHash","outputs":[{"internalType":"uint256","name":"length","type":"uint256"},{"internalType":"bytes32","name":"manifest","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"scannerId","type":"uint256"},{"internalType":"uint256","name":"pos","type":"uint256"}],"name":"agentRefAt","outputs":[{"internalType":"bool","name":"registered","type":"bool"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"agentId","type":"uint256"},{"internalType":"uint256","name":"agentVersion","type":"uint256"},{"internalType":"string","name":"metadata","type":"string"},{"internalType":"uint256[]","name":"chainIds","type":"uint256[]"},{"internalType":"bool","name":"enabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"agentRegistry","outputs":[{"internalType":"contract AgentRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"},{"internalType":"uint256","name":"scannerId","type":"uint256"}],"name":"areTheyLinked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"__manager","type":"address"},{"internalType":"address","name":"__router","type":"address"},{"internalType":"address","name":"__agents","type":"address"},{"internalType":"address","name":"__scanners","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"},{"internalType":"uint256","name":"scannerId","type":"uint256"}],"name":"link","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"scannerId","type":"uint256"}],"name":"numAgentsFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"}],"name":"numScannersFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"},{"internalType":"uint256","name":"pos","type":"uint256"}],"name":"scannerAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"scannerId","type":"uint256"}],"name":"scannerHash","outputs":[{"internalType":"uint256","name":"length","type":"uint256"},{"internalType":"bytes32","name":"manifest","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"},{"internalType":"uint256","name":"pos","type":"uint256"}],"name":"scannerRefAt","outputs":[{"internalType":"bool","name":"registered","type":"bool"},{"internalType":"uint256","name":"scannerId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"metadata","type":"string"},{"internalType":"bool","name":"enabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scannerRegistry","outputs":[{"internalType":"contract ScannerRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newManager","type":"address"}],"name":"setAccessManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAgentRegistry","type":"address"}],"name":"setAgentRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"ensRegistry","type":"address"},{"internalType":"string","name":"ensName","type":"string"}],"name":"setName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRouter","type":"address"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newScannerRegistry","type":"address"}],"name":"setScannerRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"},{"internalType":"uint256","name":"scannerId","type":"uint256"}],"name":"unlink","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60c06040523060a0523480156200001557600080fd5b50604051620030e4380380620030e4833981016040819052620000389162000105565b6001600160a01b038116608052600054610100900460ff16806200005f575060005460ff16155b620000c75760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b600054610100900460ff16158015620000ea576000805461ffff19166101011790555b8015620000fd576000805461ff00191690555b505062000137565b6000602082840312156200011857600080fd5b81516001600160a01b03811681146200013057600080fd5b9392505050565b60805160a051612f6b620001796000396000818161099e01528181610a2301528181610b4b0152610bd00152600081816103710152611ebe0152612f6b6000f3fe60806040526004361061018b5760003560e01c80635e9f88b1116100d6578063bd3c3a1a1161007f578063c958080411610059578063c958080414610504578063e47db78714610524578063f8c8765e1461054457600080fd5b8063bd3c3a1a146104a4578063c0d78655146104c4578063c2c2e46a146104e457600080fd5b80638b2e98d6116100b05780638b2e98d614610410578063ac9650d814610442578063b1774f9d1461046f57600080fd5b80635e9f88b1146103b15780636b254492146103d057806386cf48e7146103f057600080fd5b80633659cfe6116101385780634f1ef286116101125780634f1ef286146102eb57806354fd4d50146102fe578063572b6c051461035457600080fd5b80633659cfe61461028b5780633820d243146102ab5780633ce22acf146102cb57600080fd5b806328342ecf1161016957806328342ecf146102185780633121db1c1461023857806332dee2f61461025857600080fd5b80630c65b39d146101905780630d1cfcae146101b25780630d80a136146101ea575b600080fd5b34801561019c57600080fd5b506101b06101ab366004612529565b610564565b005b3480156101be57600080fd5b5061012d546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101f657600080fd5b5061020a610205366004612529565b610821565b6040519081526020016101e1565b34801561022457600080fd5b506101b0610233366004612560565b610843565b34801561024457600080fd5b506101b061025336600461257d565b610882565b34801561026457600080fd5b50610278610273366004612529565b6108cd565b6040516101e1979695949392919061265a565b34801561029757600080fd5b506101b06102a6366004612560565b610993565b3480156102b757600080fd5b5061020a6102c63660046126e4565b610b0f565b3480156102d757600080fd5b5061020a6102e6366004612529565b610b27565b6101b06102f936600461276c565b610b40565b34801561030a57600080fd5b506103476040518060400160405280600581526020017f302e312e3300000000000000000000000000000000000000000000000000000081525081565b6040516101e191906127ff565b34801561036057600080fd5b506103a161036f366004612560565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b60405190151581526020016101e1565b3480156103bd57600080fd5b5061012e546001600160a01b03166101cd565b3480156103dc57600080fd5b506101b06103eb366004612560565b610cad565b3480156103fc57600080fd5b506101b061040b366004612529565b610cec565b34801561041c57600080fd5b5061043061042b366004612529565b610f1c565b6040516101e196959493929190612812565b34801561044e57600080fd5b5061046261045d36600461285d565b610fdf565b6040516101e191906128d2565b34801561047b57600080fd5b5061048f61048a3660046126e4565b6110d4565b604080519283526020830191909152016101e1565b3480156104b057600080fd5b5061020a6104bf3660046126e4565b611365565b3480156104d057600080fd5b506101b06104df366004612560565b61137d565b3480156104f057600080fd5b5061048f6104ff3660046126e4565b61143a565b34801561051057600080fd5b506101b061051f366004612560565b6115b7565b34801561053057600080fd5b506103a161053f366004612529565b611675565b34801561055057600080fd5b506101b061055f366004612934565b6116ae565b7ffbd38eecf51668fdbc772b204dc63dd28c3a3cf32e3025f52a80aa807359f50c610596816105916117a9565b6117b8565b6105ec57806105a36117a9565b6040517f75000dc000000000000000000000000000000000000000000000000000000000815260048101929092526001600160a01b031660248201526044015b60405180910390fd5b61012d546040517f29a8791a000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b03909116906329a8791a9060240160206040518083038186803b15801561064a57600080fd5b505afa15801561065e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068291906129a5565b6106a1578260405163b087f9a560e01b81526004016105e391906129c0565b61012e546040517f579a6988000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b039091169063579a69889060240160206040518083038186803b1580156106ff57600080fd5b505afa158015610713573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073791906129a5565b610756578160405163b087f9a560e01b81526004016105e391906129f3565b600082815261012f6020526040902061076f9084611856565b1580610791575060008381526101306020526040902061078f9083611856565b155b156107e05760408051848152602081018490526000918101919091527f3b21ddc7f500e14ee79bd727bfda1b5800485bc299e0f5c9616a03c8b957a430906060015b60405180910390a1505050565b60408051848152602081018490526000918101919091527ff1b8cb2c3105270e747f9df25ec991871d6732bb7c7b86a088fe7d59c9272bbf906060016107d3565b60008281526101306020526040812061083a9083611862565b90505b92915050565b6000610851816105916117a9565b61085e57806105a36117a9565b5061012d80546001600160a01b0319166001600160a01b0392909216919091179055565b7f664245c7af190fec316596e8231f724e8171b1966cfcd124347ac5a66c34f64a6108af816105916117a9565b6108bc57806105a36117a9565b6108c784848461186e565b50505050565b60008060008060608060006108e28989610b27565b61012d546040517f1e4def83000000000000000000000000000000000000000000000000000000008152600481018390529196506001600160a01b031690631e4def839060240160006040518083038186803b15801561094157600080fd5b505afa158015610955573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261097d9190810190612ae7565b949e939d50989b50909950975090945092505050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610a215760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b60648201526084016105e3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610a7c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610ae75760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b60648201526084016105e3565b610af08161199d565b60408051600080825260208201909252610b0c918391906119d7565b50565b60008181526101306020526040812061083d90611b94565b600082815261012f6020526040812061083a9083611862565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610bce5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b60648201526084016105e3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610c297f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610c945760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b60648201526084016105e3565b610c9d8261199d565b610ca9828260016119d7565b5050565b6000610cbb816105916117a9565b610cc857806105a36117a9565b5061012e80546001600160a01b0319166001600160a01b0392909216919091179055565b7ffbd38eecf51668fdbc772b204dc63dd28c3a3cf32e3025f52a80aa807359f50c610d19816105916117a9565b610d2657806105a36117a9565b61012d546040516331e0c0d360e21b8152600481018590526001600160a01b039091169063c783034c9060240160206040518083038186803b158015610d6b57600080fd5b505afa158015610d7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da391906129a5565b610dc057604051631429691d60e01b81526004016105e390612b88565b61012e546040516331e0c0d360e21b8152600481018490526001600160a01b039091169063c783034c9060240160206040518083038186803b158015610e0557600080fd5b505afa158015610e19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3d91906129a5565b610e5a57604051631429691d60e01b81526004016105e390612bad565b600082815261012f60205260409020610e739084611b9e565b1580610e955750600083815261013060205260409020610e939083611b9e565b155b15610edb5760408051848152602081018490526001918101919091527f3b21ddc7f500e14ee79bd727bfda1b5800485bc299e0f5c9616a03c8b957a430906060016107d3565b60408051848152602081018490526001918101919091527ff1b8cb2c3105270e747f9df25ec991871d6732bb7c7b86a088fe7d59c9272bbf906060016107d3565b60008060008060606000610f308888610821565b61012e546040517f37fea0e0000000000000000000000000000000000000000000000000000000008152600481018390529196506001600160a01b0316906337fea0e09060240160006040518083038186803b158015610f8f57600080fd5b505afa158015610fa3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610fcb9190810190612bd4565b939c989b5091995097509590945092505050565b60608167ffffffffffffffff811115610ffa57610ffa6126fd565b60405190808252806020026020018201604052801561102d57816020015b60608152602001906001900390816110185790505b50905060005b828110156110cd5761109d3085858481811061105157611051612c50565b90506020028101906110639190612c66565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611baa92505050565b8282815181106110af576110af612c50565b602002602001018190525080806110c590612cca565b915050611033565b5092915050565b600081815261012f60205260408120819081906110f090611bcf565b90506000815167ffffffffffffffff81111561110e5761110e6126fd565b604051908082528060200260200182016040528015611137578160200160208202803683370190505b5090506000825167ffffffffffffffff811115611156576111566126fd565b60405190808252806020026020018201604052801561117f578160200160208202803683370190505b50905060005b835181101561132b5761012d5484516001600160a01b0390911690632de5aaf7908690849081106111b8576111b8612c50565b60200260200101516040518263ffffffff1660e01b81526004016111de91815260200190565b60006040518083038186803b1580156111f657600080fd5b505afa15801561120a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112329190810190612ce5565b505085519092508591508390811061124c5761124c612c50565b602090810291909101015261012d5484516001600160a01b039091169063c783034c9086908490811061128157611281612c50565b60200260200101516040518263ffffffff1660e01b81526004016112a791815260200190565b60206040518083038186803b1580156112bf57600080fd5b505afa1580156112d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f791906129a5565b82828151811061130957611309612c50565b911515602092830291909101909101528061132381612cca565b915050611185565b50825183838360405160200161134393929190612dd4565b6040516020818303038152906040528051906020012094509450505050915091565b600081815261012f6020526040812061083d90611b94565b600061138b816105916117a9565b61139857806105a36117a9565b6001600160a01b0382166113ef5760405163eac0d38960e01b815260206004820152600960248201527f6e6577526f75746572000000000000000000000000000000000000000000000060448201526064016105e3565b606580546001600160a01b0319166001600160a01b0384169081179091556040517f7aed1d3e8155a07ccf395e44ea3109a0e2d6c9b29bbbe9f142d9790596f4dc8090600090a25050565b6000818152610130602052604081208190819061145690611bcf565b90506000815167ffffffffffffffff811115611474576114746126fd565b60405190808252806020026020018201604052801561149d578160200160208202803683370190505b50905060005b82518110156115805761012e5483516001600160a01b039091169063c783034c908590849081106114d6576114d6612c50565b60200260200101516040518263ffffffff1660e01b81526004016114fc91815260200190565b60206040518083038186803b15801561151457600080fd5b505afa158015611528573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154c91906129a5565b82828151811061155e5761155e612c50565b911515602092830291909101909101528061157881612cca565b9150506114a3565b5081518282604051602001611596929190612df2565b60405160208183030381529060405280519060200120935093505050915091565b60006115c5816105916117a9565b6115d257806105a36117a9565b6115ec6001600160a01b038316637965db0b60e01b611be3565b61162a576040516301a1fdbb60e41b815260206004820152600e60248201526d125058d8d95cdcd0dbdb9d1c9bdb60921b60448201526064016105e3565b603380546001600160a01b0319166001600160a01b0384169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a25050565b600081815261012f6020526040812061168e9084611bff565b801561083a575060008381526101306020526040902061083a9083611bff565b600054610100900460ff16806116c7575060005460ff16155b61172a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105e3565b600054610100900460ff1615801561174c576000805461ffff19166101011790555b61175585611c17565b61175e84611d69565b61012d80546001600160a01b038086166001600160a01b03199283161790925561012e80549285169290911691909117905580156117a2576000805461ff00191690555b5050505050565b60006117b3611eba565b905090565b6033546040517f91d14854000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03838116602483015260009216906391d148549060440160206040518083038186803b15801561181e57600080fd5b505afa158015611832573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083a91906129a5565b600061083a8383611f1d565b600061083a8383612010565b6040517f02571be30000000000000000000000000000000000000000000000000000000081527f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e260048201526001600160a01b038416906302571be39060240160206040518083038186803b1580156118e657600080fd5b505afa1580156118fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191e9190612e01565b6001600160a01b031663c47f002783836040518363ffffffff1660e01b815260040161194b929190612e1e565b602060405180830381600087803b15801561196557600080fd5b505af1158015611979573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c79190612e4d565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e36119ca816105916117a9565b610ca957806105a36117a9565b6000611a0a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b9050611a158461203a565b600083511180611a225750815b15611a3357611a3184846120ef565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff166117a257805460ff191660011781556040516001600160a01b0383166024820152611ae090869060440160408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f3659cfe6000000000000000000000000000000000000000000000000000000001790526120ef565b50805460ff191681557f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b03838116911614611b8b5760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201527f757274686572207570677261646573000000000000000000000000000000000060648201526084016105e3565b6117a2856121da565b600061083d825490565b600061083a838361221a565b606061083a8383604051806060016040528060278152602001612f0f60279139612269565b60606000611bdc8361233d565b9392505050565b6000611bee83612399565b801561083a575061083a83836123e4565b6000818152600183016020526040812054151561083a565b600054610100900460ff1680611c30575060005460ff16155b611c935760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105e3565b600054610100900460ff16158015611cb5576000805461ffff19166101011790555b611ccf6001600160a01b038316637965db0b60e01b611be3565b611d0d576040516301a1fdbb60e41b815260206004820152600e60248201526d125058d8d95cdcd0dbdb9d1c9bdb60921b60448201526064016105e3565b603380546001600160a01b0319166001600160a01b0384169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a28015610ca9576000805461ff00191690555050565b600054610100900460ff1680611d82575060005460ff16155b611de55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105e3565b600054610100900460ff16158015611e07576000805461ffff19166101011790555b6001600160a01b038216611e5e5760405163eac0d38960e01b815260206004820152600660248201527f726f75746572000000000000000000000000000000000000000000000000000060448201526064016105e3565b606580546001600160a01b0319166001600160a01b0384169081179091556040517f7aed1d3e8155a07ccf395e44ea3109a0e2d6c9b29bbbe9f142d9790596f4dc8090600090a28015610ca9576000805461ff00191690555050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316331415611f1857600036611efb601482612e66565b611f0792369290612e7d565b611f1091612ea7565b60601c905090565b503390565b60008181526001830160205260408120548015612006576000611f41600183612e66565b8554909150600090611f5590600190612e66565b9050818114611fba576000866000018281548110611f7557611f75612c50565b9060005260206000200154905080876000018481548110611f9857611f98612c50565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611fcb57611fcb612edc565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061083d565b600091505061083d565b600082600001828154811061202757612027612c50565b9060005260206000200154905092915050565b803b6120ae5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016105e3565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b61214e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016105e3565b600080846001600160a01b0316846040516121699190612ef2565b600060405180830381855af49150503d80600081146121a4576040519150601f19603f3d011682016040523d82523d6000602084013e6121a9565b606091505b50915091506121d18282604051806060016040528060278152602001612f0f602791396124f0565b95945050505050565b6121e38161203a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60008181526001830160205260408120546122615750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561083d565b50600061083d565b6060833b6122c85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016105e3565b600080856001600160a01b0316856040516122e39190612ef2565b600060405180830381855af49150503d806000811461231e576040519150601f19603f3d011682016040523d82523d6000602084013e612323565b606091505b50915091506123338282866124f0565b9695505050505050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561238d57602002820191906000526020600020905b815481526020019060010190808311612379575b50505050509050919050565b60006123ac826301ffc9a760e01b6123e4565b801561083d57506123dd827fffffffff000000000000000000000000000000000000000000000000000000006123e4565b1592915050565b604080517fffffffff00000000000000000000000000000000000000000000000000000000831660248083019190915282518083039091018152604490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166301ffc9a760e01b179052905160009190829081906001600160a01b0387169061753090612478908690612ef2565b6000604051808303818686fa925050503d80600081146124b4576040519150601f19603f3d011682016040523d82523d6000602084013e6124b9565b606091505b50915091506020815110156124d4576000935050505061083d565b81801561233357508080602001905181019061233391906129a5565b606083156124ff575081611bdc565b82511561250f5782518084602001fd5b8160405162461bcd60e51b81526004016105e391906127ff565b6000806040838503121561253c57600080fd5b50508035926020909101359150565b6001600160a01b0381168114610b0c57600080fd5b60006020828403121561257257600080fd5b8135611bdc8161254b565b60008060006040848603121561259257600080fd5b833561259d8161254b565b9250602084013567ffffffffffffffff808211156125ba57600080fd5b818601915086601f8301126125ce57600080fd5b8135818111156125dd57600080fd5b8760208285010111156125ef57600080fd5b6020830194508093505050509250925092565b60005b8381101561261d578181015183820152602001612605565b838111156108c75750506000910152565b60008151808452612646816020860160208601612602565b601f01601f19169290920160200192915050565b8715158152600060206001600160a01b0389168184015287604084015286606084015260e0608084015261269160e084018761262e565b83810360a085015285518082528287019183019060005b818110156126c4578351835292840192918401916001016126a8565b505085151560c086015292506126d8915050565b98975050505050505050565b6000602082840312156126f657600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561273c5761273c6126fd565b604052919050565b600067ffffffffffffffff82111561275e5761275e6126fd565b50601f01601f191660200190565b6000806040838503121561277f57600080fd5b823561278a8161254b565b9150602083013567ffffffffffffffff8111156127a657600080fd5b8301601f810185136127b757600080fd5b80356127ca6127c582612744565b612713565b8181528660208385010111156127df57600080fd5b816020840160208301376000602083830101528093505050509250929050565b60208152600061083a602083018461262e565b86151581528560208201526001600160a01b038516604082015283606082015260c06080820152600061284860c083018561262e565b905082151560a0830152979650505050505050565b6000806020838503121561287057600080fd5b823567ffffffffffffffff8082111561288857600080fd5b818501915085601f83011261289c57600080fd5b8135818111156128ab57600080fd5b8660208260051b85010111156128c057600080fd5b60209290920196919550909350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b8281101561292757603f1988860301845261291585835161262e565b945092850192908501906001016128f9565b5092979650505050505050565b6000806000806080858703121561294a57600080fd5b84356129558161254b565b935060208501356129658161254b565b925060408501356129758161254b565b915060608501356129858161254b565b939692955090935050565b805180151581146129a057600080fd5b919050565b6000602082840312156129b757600080fd5b61083a82612990565b6040815260006129e56040830160058152641059d95b9d60da1b602082015260400190565b905082602083015292915050565b6040815260006129e560408301600781526629b1b0b73732b960c91b602082015260400190565b600082601f830112612a2b57600080fd5b8151612a396127c582612744565b818152846020838601011115612a4e57600080fd5b612a5f826020830160208701612602565b949350505050565b600082601f830112612a7857600080fd5b8151602067ffffffffffffffff821115612a9457612a946126fd565b8160051b612aa3828201612713565b9283528481018201928281019087851115612abd57600080fd5b83870192505b84831015612adc57825182529183019190830190612ac3565b979650505050505050565b60008060008060008060c08789031215612b0057600080fd5b612b0987612990565b95506020870151612b198161254b565b60408801516060890151919650945067ffffffffffffffff80821115612b3e57600080fd5b612b4a8a838b01612a1a565b94506080890151915080821115612b6057600080fd5b50612b6d89828a01612a67565b925050612b7c60a08801612990565b90509295509295509295565b60208152600061083d6020830160058152641059d95b9d60da1b602082015260400190565b60208152600061083d60208301600781526629b1b0b73732b960c91b602082015260400190565b600080600080600060a08688031215612bec57600080fd5b612bf586612990565b94506020860151612c058161254b565b60408701516060880151919550935067ffffffffffffffff811115612c2957600080fd5b612c3588828901612a1a565b925050612c4460808701612990565b90509295509295909350565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112612c7d57600080fd5b83018035915067ffffffffffffffff821115612c9857600080fd5b602001915036819003821315612cad57600080fd5b9250929050565b634e487b7160e01b600052601160045260246000fd5b6000600019821415612cde57612cde612cb4565b5060010190565b600080600080600060a08688031215612cfd57600080fd5b612d0686612990565b94506020860151612d168161254b565b60408701516060880151919550935067ffffffffffffffff80821115612d3b57600080fd5b612d4789838a01612a1a565b93506080880151915080821115612d5d57600080fd5b50612d6a88828901612a67565b9150509295509295909350565b60008151602080840160005b83811015612d9f57815187529582019590820190600101612d83565b509495945050505050565b60008151602080840160005b83811015612d9f578151151587529582019590820190600101612db6565b60006121d1612dec612de68488612d77565b86612d77565b84612daa565b6000612a5f612dec8386612d77565b600060208284031215612e1357600080fd5b8151611bdc8161254b565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b600060208284031215612e5f57600080fd5b5051919050565b600082821015612e7857612e78612cb4565b500390565b60008085851115612e8d57600080fd5b83861115612e9a57600080fd5b5050820193919092039150565b6bffffffffffffffffffffffff198135818116916014851015612ed45780818660140360031b1b83161692505b505092915050565b634e487b7160e01b600052603160045260246000fd5b60008251612f04818460208701612602565b919091019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d9eb15372744fe9a85161ad4aad161635b454ff34e463aa7bca827c6686bb56964736f6c63430008090033000000000000000000000000356a8ee5d3bcc183c2c7853f11d19f4c7622396f
Deployed Bytecode
0x60806040526004361061018b5760003560e01c80635e9f88b1116100d6578063bd3c3a1a1161007f578063c958080411610059578063c958080414610504578063e47db78714610524578063f8c8765e1461054457600080fd5b8063bd3c3a1a146104a4578063c0d78655146104c4578063c2c2e46a146104e457600080fd5b80638b2e98d6116100b05780638b2e98d614610410578063ac9650d814610442578063b1774f9d1461046f57600080fd5b80635e9f88b1146103b15780636b254492146103d057806386cf48e7146103f057600080fd5b80633659cfe6116101385780634f1ef286116101125780634f1ef286146102eb57806354fd4d50146102fe578063572b6c051461035457600080fd5b80633659cfe61461028b5780633820d243146102ab5780633ce22acf146102cb57600080fd5b806328342ecf1161016957806328342ecf146102185780633121db1c1461023857806332dee2f61461025857600080fd5b80630c65b39d146101905780630d1cfcae146101b25780630d80a136146101ea575b600080fd5b34801561019c57600080fd5b506101b06101ab366004612529565b610564565b005b3480156101be57600080fd5b5061012d546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101f657600080fd5b5061020a610205366004612529565b610821565b6040519081526020016101e1565b34801561022457600080fd5b506101b0610233366004612560565b610843565b34801561024457600080fd5b506101b061025336600461257d565b610882565b34801561026457600080fd5b50610278610273366004612529565b6108cd565b6040516101e1979695949392919061265a565b34801561029757600080fd5b506101b06102a6366004612560565b610993565b3480156102b757600080fd5b5061020a6102c63660046126e4565b610b0f565b3480156102d757600080fd5b5061020a6102e6366004612529565b610b27565b6101b06102f936600461276c565b610b40565b34801561030a57600080fd5b506103476040518060400160405280600581526020017f302e312e3300000000000000000000000000000000000000000000000000000081525081565b6040516101e191906127ff565b34801561036057600080fd5b506103a161036f366004612560565b7f000000000000000000000000356a8ee5d3bcc183c2c7853f11d19f4c7622396f6001600160a01b0390811691161490565b60405190151581526020016101e1565b3480156103bd57600080fd5b5061012e546001600160a01b03166101cd565b3480156103dc57600080fd5b506101b06103eb366004612560565b610cad565b3480156103fc57600080fd5b506101b061040b366004612529565b610cec565b34801561041c57600080fd5b5061043061042b366004612529565b610f1c565b6040516101e196959493929190612812565b34801561044e57600080fd5b5061046261045d36600461285d565b610fdf565b6040516101e191906128d2565b34801561047b57600080fd5b5061048f61048a3660046126e4565b6110d4565b604080519283526020830191909152016101e1565b3480156104b057600080fd5b5061020a6104bf3660046126e4565b611365565b3480156104d057600080fd5b506101b06104df366004612560565b61137d565b3480156104f057600080fd5b5061048f6104ff3660046126e4565b61143a565b34801561051057600080fd5b506101b061051f366004612560565b6115b7565b34801561053057600080fd5b506103a161053f366004612529565b611675565b34801561055057600080fd5b506101b061055f366004612934565b6116ae565b7ffbd38eecf51668fdbc772b204dc63dd28c3a3cf32e3025f52a80aa807359f50c610596816105916117a9565b6117b8565b6105ec57806105a36117a9565b6040517f75000dc000000000000000000000000000000000000000000000000000000000815260048101929092526001600160a01b031660248201526044015b60405180910390fd5b61012d546040517f29a8791a000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b03909116906329a8791a9060240160206040518083038186803b15801561064a57600080fd5b505afa15801561065e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068291906129a5565b6106a1578260405163b087f9a560e01b81526004016105e391906129c0565b61012e546040517f579a6988000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b039091169063579a69889060240160206040518083038186803b1580156106ff57600080fd5b505afa158015610713573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073791906129a5565b610756578160405163b087f9a560e01b81526004016105e391906129f3565b600082815261012f6020526040902061076f9084611856565b1580610791575060008381526101306020526040902061078f9083611856565b155b156107e05760408051848152602081018490526000918101919091527f3b21ddc7f500e14ee79bd727bfda1b5800485bc299e0f5c9616a03c8b957a430906060015b60405180910390a1505050565b60408051848152602081018490526000918101919091527ff1b8cb2c3105270e747f9df25ec991871d6732bb7c7b86a088fe7d59c9272bbf906060016107d3565b60008281526101306020526040812061083a9083611862565b90505b92915050565b6000610851816105916117a9565b61085e57806105a36117a9565b5061012d80546001600160a01b0319166001600160a01b0392909216919091179055565b7f664245c7af190fec316596e8231f724e8171b1966cfcd124347ac5a66c34f64a6108af816105916117a9565b6108bc57806105a36117a9565b6108c784848461186e565b50505050565b60008060008060608060006108e28989610b27565b61012d546040517f1e4def83000000000000000000000000000000000000000000000000000000008152600481018390529196506001600160a01b031690631e4def839060240160006040518083038186803b15801561094157600080fd5b505afa158015610955573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261097d9190810190612ae7565b949e939d50989b50909950975090945092505050565b306001600160a01b037f0000000000000000000000006fb6c250824b54599706b4b9c701cf1de8174ec5161415610a215760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b60648201526084016105e3565b7f0000000000000000000000006fb6c250824b54599706b4b9c701cf1de8174ec56001600160a01b0316610a7c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610ae75760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b60648201526084016105e3565b610af08161199d565b60408051600080825260208201909252610b0c918391906119d7565b50565b60008181526101306020526040812061083d90611b94565b600082815261012f6020526040812061083a9083611862565b306001600160a01b037f0000000000000000000000006fb6c250824b54599706b4b9c701cf1de8174ec5161415610bce5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b60648201526084016105e3565b7f0000000000000000000000006fb6c250824b54599706b4b9c701cf1de8174ec56001600160a01b0316610c297f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610c945760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b60648201526084016105e3565b610c9d8261199d565b610ca9828260016119d7565b5050565b6000610cbb816105916117a9565b610cc857806105a36117a9565b5061012e80546001600160a01b0319166001600160a01b0392909216919091179055565b7ffbd38eecf51668fdbc772b204dc63dd28c3a3cf32e3025f52a80aa807359f50c610d19816105916117a9565b610d2657806105a36117a9565b61012d546040516331e0c0d360e21b8152600481018590526001600160a01b039091169063c783034c9060240160206040518083038186803b158015610d6b57600080fd5b505afa158015610d7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da391906129a5565b610dc057604051631429691d60e01b81526004016105e390612b88565b61012e546040516331e0c0d360e21b8152600481018490526001600160a01b039091169063c783034c9060240160206040518083038186803b158015610e0557600080fd5b505afa158015610e19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3d91906129a5565b610e5a57604051631429691d60e01b81526004016105e390612bad565b600082815261012f60205260409020610e739084611b9e565b1580610e955750600083815261013060205260409020610e939083611b9e565b155b15610edb5760408051848152602081018490526001918101919091527f3b21ddc7f500e14ee79bd727bfda1b5800485bc299e0f5c9616a03c8b957a430906060016107d3565b60408051848152602081018490526001918101919091527ff1b8cb2c3105270e747f9df25ec991871d6732bb7c7b86a088fe7d59c9272bbf906060016107d3565b60008060008060606000610f308888610821565b61012e546040517f37fea0e0000000000000000000000000000000000000000000000000000000008152600481018390529196506001600160a01b0316906337fea0e09060240160006040518083038186803b158015610f8f57600080fd5b505afa158015610fa3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610fcb9190810190612bd4565b939c989b5091995097509590945092505050565b60608167ffffffffffffffff811115610ffa57610ffa6126fd565b60405190808252806020026020018201604052801561102d57816020015b60608152602001906001900390816110185790505b50905060005b828110156110cd5761109d3085858481811061105157611051612c50565b90506020028101906110639190612c66565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611baa92505050565b8282815181106110af576110af612c50565b602002602001018190525080806110c590612cca565b915050611033565b5092915050565b600081815261012f60205260408120819081906110f090611bcf565b90506000815167ffffffffffffffff81111561110e5761110e6126fd565b604051908082528060200260200182016040528015611137578160200160208202803683370190505b5090506000825167ffffffffffffffff811115611156576111566126fd565b60405190808252806020026020018201604052801561117f578160200160208202803683370190505b50905060005b835181101561132b5761012d5484516001600160a01b0390911690632de5aaf7908690849081106111b8576111b8612c50565b60200260200101516040518263ffffffff1660e01b81526004016111de91815260200190565b60006040518083038186803b1580156111f657600080fd5b505afa15801561120a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112329190810190612ce5565b505085519092508591508390811061124c5761124c612c50565b602090810291909101015261012d5484516001600160a01b039091169063c783034c9086908490811061128157611281612c50565b60200260200101516040518263ffffffff1660e01b81526004016112a791815260200190565b60206040518083038186803b1580156112bf57600080fd5b505afa1580156112d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f791906129a5565b82828151811061130957611309612c50565b911515602092830291909101909101528061132381612cca565b915050611185565b50825183838360405160200161134393929190612dd4565b6040516020818303038152906040528051906020012094509450505050915091565b600081815261012f6020526040812061083d90611b94565b600061138b816105916117a9565b61139857806105a36117a9565b6001600160a01b0382166113ef5760405163eac0d38960e01b815260206004820152600960248201527f6e6577526f75746572000000000000000000000000000000000000000000000060448201526064016105e3565b606580546001600160a01b0319166001600160a01b0384169081179091556040517f7aed1d3e8155a07ccf395e44ea3109a0e2d6c9b29bbbe9f142d9790596f4dc8090600090a25050565b6000818152610130602052604081208190819061145690611bcf565b90506000815167ffffffffffffffff811115611474576114746126fd565b60405190808252806020026020018201604052801561149d578160200160208202803683370190505b50905060005b82518110156115805761012e5483516001600160a01b039091169063c783034c908590849081106114d6576114d6612c50565b60200260200101516040518263ffffffff1660e01b81526004016114fc91815260200190565b60206040518083038186803b15801561151457600080fd5b505afa158015611528573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154c91906129a5565b82828151811061155e5761155e612c50565b911515602092830291909101909101528061157881612cca565b9150506114a3565b5081518282604051602001611596929190612df2565b60405160208183030381529060405280519060200120935093505050915091565b60006115c5816105916117a9565b6115d257806105a36117a9565b6115ec6001600160a01b038316637965db0b60e01b611be3565b61162a576040516301a1fdbb60e41b815260206004820152600e60248201526d125058d8d95cdcd0dbdb9d1c9bdb60921b60448201526064016105e3565b603380546001600160a01b0319166001600160a01b0384169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a25050565b600081815261012f6020526040812061168e9084611bff565b801561083a575060008381526101306020526040902061083a9083611bff565b600054610100900460ff16806116c7575060005460ff16155b61172a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105e3565b600054610100900460ff1615801561174c576000805461ffff19166101011790555b61175585611c17565b61175e84611d69565b61012d80546001600160a01b038086166001600160a01b03199283161790925561012e80549285169290911691909117905580156117a2576000805461ff00191690555b5050505050565b60006117b3611eba565b905090565b6033546040517f91d14854000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03838116602483015260009216906391d148549060440160206040518083038186803b15801561181e57600080fd5b505afa158015611832573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083a91906129a5565b600061083a8383611f1d565b600061083a8383612010565b6040517f02571be30000000000000000000000000000000000000000000000000000000081527f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e260048201526001600160a01b038416906302571be39060240160206040518083038186803b1580156118e657600080fd5b505afa1580156118fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191e9190612e01565b6001600160a01b031663c47f002783836040518363ffffffff1660e01b815260040161194b929190612e1e565b602060405180830381600087803b15801561196557600080fd5b505af1158015611979573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c79190612e4d565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e36119ca816105916117a9565b610ca957806105a36117a9565b6000611a0a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b9050611a158461203a565b600083511180611a225750815b15611a3357611a3184846120ef565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff166117a257805460ff191660011781556040516001600160a01b0383166024820152611ae090869060440160408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f3659cfe6000000000000000000000000000000000000000000000000000000001790526120ef565b50805460ff191681557f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b03838116911614611b8b5760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201527f757274686572207570677261646573000000000000000000000000000000000060648201526084016105e3565b6117a2856121da565b600061083d825490565b600061083a838361221a565b606061083a8383604051806060016040528060278152602001612f0f60279139612269565b60606000611bdc8361233d565b9392505050565b6000611bee83612399565b801561083a575061083a83836123e4565b6000818152600183016020526040812054151561083a565b600054610100900460ff1680611c30575060005460ff16155b611c935760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105e3565b600054610100900460ff16158015611cb5576000805461ffff19166101011790555b611ccf6001600160a01b038316637965db0b60e01b611be3565b611d0d576040516301a1fdbb60e41b815260206004820152600e60248201526d125058d8d95cdcd0dbdb9d1c9bdb60921b60448201526064016105e3565b603380546001600160a01b0319166001600160a01b0384169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a28015610ca9576000805461ff00191690555050565b600054610100900460ff1680611d82575060005460ff16155b611de55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105e3565b600054610100900460ff16158015611e07576000805461ffff19166101011790555b6001600160a01b038216611e5e5760405163eac0d38960e01b815260206004820152600660248201527f726f75746572000000000000000000000000000000000000000000000000000060448201526064016105e3565b606580546001600160a01b0319166001600160a01b0384169081179091556040517f7aed1d3e8155a07ccf395e44ea3109a0e2d6c9b29bbbe9f142d9790596f4dc8090600090a28015610ca9576000805461ff00191690555050565b60007f000000000000000000000000356a8ee5d3bcc183c2c7853f11d19f4c7622396f6001600160a01b0316331415611f1857600036611efb601482612e66565b611f0792369290612e7d565b611f1091612ea7565b60601c905090565b503390565b60008181526001830160205260408120548015612006576000611f41600183612e66565b8554909150600090611f5590600190612e66565b9050818114611fba576000866000018281548110611f7557611f75612c50565b9060005260206000200154905080876000018481548110611f9857611f98612c50565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611fcb57611fcb612edc565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061083d565b600091505061083d565b600082600001828154811061202757612027612c50565b9060005260206000200154905092915050565b803b6120ae5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016105e3565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b61214e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016105e3565b600080846001600160a01b0316846040516121699190612ef2565b600060405180830381855af49150503d80600081146121a4576040519150601f19603f3d011682016040523d82523d6000602084013e6121a9565b606091505b50915091506121d18282604051806060016040528060278152602001612f0f602791396124f0565b95945050505050565b6121e38161203a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60008181526001830160205260408120546122615750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561083d565b50600061083d565b6060833b6122c85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016105e3565b600080856001600160a01b0316856040516122e39190612ef2565b600060405180830381855af49150503d806000811461231e576040519150601f19603f3d011682016040523d82523d6000602084013e612323565b606091505b50915091506123338282866124f0565b9695505050505050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561238d57602002820191906000526020600020905b815481526020019060010190808311612379575b50505050509050919050565b60006123ac826301ffc9a760e01b6123e4565b801561083d57506123dd827fffffffff000000000000000000000000000000000000000000000000000000006123e4565b1592915050565b604080517fffffffff00000000000000000000000000000000000000000000000000000000831660248083019190915282518083039091018152604490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166301ffc9a760e01b179052905160009190829081906001600160a01b0387169061753090612478908690612ef2565b6000604051808303818686fa925050503d80600081146124b4576040519150601f19603f3d011682016040523d82523d6000602084013e6124b9565b606091505b50915091506020815110156124d4576000935050505061083d565b81801561233357508080602001905181019061233391906129a5565b606083156124ff575081611bdc565b82511561250f5782518084602001fd5b8160405162461bcd60e51b81526004016105e391906127ff565b6000806040838503121561253c57600080fd5b50508035926020909101359150565b6001600160a01b0381168114610b0c57600080fd5b60006020828403121561257257600080fd5b8135611bdc8161254b565b60008060006040848603121561259257600080fd5b833561259d8161254b565b9250602084013567ffffffffffffffff808211156125ba57600080fd5b818601915086601f8301126125ce57600080fd5b8135818111156125dd57600080fd5b8760208285010111156125ef57600080fd5b6020830194508093505050509250925092565b60005b8381101561261d578181015183820152602001612605565b838111156108c75750506000910152565b60008151808452612646816020860160208601612602565b601f01601f19169290920160200192915050565b8715158152600060206001600160a01b0389168184015287604084015286606084015260e0608084015261269160e084018761262e565b83810360a085015285518082528287019183019060005b818110156126c4578351835292840192918401916001016126a8565b505085151560c086015292506126d8915050565b98975050505050505050565b6000602082840312156126f657600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561273c5761273c6126fd565b604052919050565b600067ffffffffffffffff82111561275e5761275e6126fd565b50601f01601f191660200190565b6000806040838503121561277f57600080fd5b823561278a8161254b565b9150602083013567ffffffffffffffff8111156127a657600080fd5b8301601f810185136127b757600080fd5b80356127ca6127c582612744565b612713565b8181528660208385010111156127df57600080fd5b816020840160208301376000602083830101528093505050509250929050565b60208152600061083a602083018461262e565b86151581528560208201526001600160a01b038516604082015283606082015260c06080820152600061284860c083018561262e565b905082151560a0830152979650505050505050565b6000806020838503121561287057600080fd5b823567ffffffffffffffff8082111561288857600080fd5b818501915085601f83011261289c57600080fd5b8135818111156128ab57600080fd5b8660208260051b85010111156128c057600080fd5b60209290920196919550909350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b8281101561292757603f1988860301845261291585835161262e565b945092850192908501906001016128f9565b5092979650505050505050565b6000806000806080858703121561294a57600080fd5b84356129558161254b565b935060208501356129658161254b565b925060408501356129758161254b565b915060608501356129858161254b565b939692955090935050565b805180151581146129a057600080fd5b919050565b6000602082840312156129b757600080fd5b61083a82612990565b6040815260006129e56040830160058152641059d95b9d60da1b602082015260400190565b905082602083015292915050565b6040815260006129e560408301600781526629b1b0b73732b960c91b602082015260400190565b600082601f830112612a2b57600080fd5b8151612a396127c582612744565b818152846020838601011115612a4e57600080fd5b612a5f826020830160208701612602565b949350505050565b600082601f830112612a7857600080fd5b8151602067ffffffffffffffff821115612a9457612a946126fd565b8160051b612aa3828201612713565b9283528481018201928281019087851115612abd57600080fd5b83870192505b84831015612adc57825182529183019190830190612ac3565b979650505050505050565b60008060008060008060c08789031215612b0057600080fd5b612b0987612990565b95506020870151612b198161254b565b60408801516060890151919650945067ffffffffffffffff80821115612b3e57600080fd5b612b4a8a838b01612a1a565b94506080890151915080821115612b6057600080fd5b50612b6d89828a01612a67565b925050612b7c60a08801612990565b90509295509295509295565b60208152600061083d6020830160058152641059d95b9d60da1b602082015260400190565b60208152600061083d60208301600781526629b1b0b73732b960c91b602082015260400190565b600080600080600060a08688031215612bec57600080fd5b612bf586612990565b94506020860151612c058161254b565b60408701516060880151919550935067ffffffffffffffff811115612c2957600080fd5b612c3588828901612a1a565b925050612c4460808701612990565b90509295509295909350565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112612c7d57600080fd5b83018035915067ffffffffffffffff821115612c9857600080fd5b602001915036819003821315612cad57600080fd5b9250929050565b634e487b7160e01b600052601160045260246000fd5b6000600019821415612cde57612cde612cb4565b5060010190565b600080600080600060a08688031215612cfd57600080fd5b612d0686612990565b94506020860151612d168161254b565b60408701516060880151919550935067ffffffffffffffff80821115612d3b57600080fd5b612d4789838a01612a1a565b93506080880151915080821115612d5d57600080fd5b50612d6a88828901612a67565b9150509295509295909350565b60008151602080840160005b83811015612d9f57815187529582019590820190600101612d83565b509495945050505050565b60008151602080840160005b83811015612d9f578151151587529582019590820190600101612db6565b60006121d1612dec612de68488612d77565b86612d77565b84612daa565b6000612a5f612dec8386612d77565b600060208284031215612e1357600080fd5b8151611bdc8161254b565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b600060208284031215612e5f57600080fd5b5051919050565b600082821015612e7857612e78612cb4565b500390565b60008085851115612e8d57600080fd5b83861115612e9a57600080fd5b5050820193919092039150565b6bffffffffffffffffffffffff198135818116916014851015612ed45780818660140360031b1b83161692505b505092915050565b634e487b7160e01b600052603160045260246000fd5b60008251612f04818460208701612602565b919091019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d9eb15372744fe9a85161ad4aad161635b454ff34e463aa7bca827c6686bb56964736f6c63430008090033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000356a8ee5d3bcc183c2c7853f11d19f4c7622396f
-----Decoded View---------------
Arg [0] : forwarder (address): 0x356A8ee5D3bCc183c2c7853F11D19f4C7622396F
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000356a8ee5d3bcc183c2c7853f11d19f4c7622396f
Loading...
Loading
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.