Source Code
Overview
APE Balance
APE Value
$0.00Multichain Info
N/A
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 18435676 | 224 days ago | Contract Creation | 0 APE |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
GameRegistry
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.13;
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol';
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';
import '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@opengsn/contracts/src/interfaces/IERC2771Recipient.sol';
import {PAUSER_ROLE, VRF_SYSTEM_ROLE, DEPOSITOR_ROLE, MANAGER_ROLE, MINTER_ROLE, GAME_CURRENCY_CONTRACT_ROLE, GAME_NFT_CONTRACT_ROLE, GAME_ITEMS_CONTRACT_ROLE, GAME_LOGIC_CONTRACT_ROLE, TRUSTED_FORWARDER_ROLE, DEPLOYER_ROLE, TRUSTED_MULTICHAIN_ORACLE_ROLE} from './Constants.sol';
import './core/IGameRegistry.sol';
import {EntityLibrary} from './core/EntityLibrary.sol';
import {IComponent} from './core/components/IComponent.sol';
import {GUIDLibrary} from './core/GUIDLibrary.sol';
import {GuidCounterComponent, ID as GUID_COUNTER_COMPONENT_ID} from './generated/components/GuidCounterComponent.sol';
import {IMultichain1155} from './tokens/IMultichain1155.sol';
import {IMultichain721} from './tokens/IMultichain721.sol';
import {ChainIdComponent, ID as CHAIN_ID_COMPONENT_ID} from './generated/components/ChainIdComponent.sol';
import {ArchivedComponent, ID as ARCHIVED_COMPONENT_ID} from './generated/components/ArchivedComponent.sol';
// NOTE: Do NOT change ID if we wish to keep multi-chain GUID's in the same namespace
uint256 constant ID = uint256(keccak256('game.piratenation.gameregistry.v1'));
uint80 constant GUID_PREFIX = uint80(ID);
struct BatchComponentData {
uint256[] entities;
uint256[] componentIds;
bytes[] data;
}
/** @title Contract to track and limit access by accounts in the same block */
contract GameRegistry is
AccessControlUpgradeable,
OwnableUpgradeable,
PausableUpgradeable,
IERC2771Recipient,
IGameRegistry
{
/// @notice Block limit on transmitting a signed operator registration message
uint256 public constant OPERATOR_MESSAGE_BLOCK_LIMIT = 30; // 30 blocks
/// @notice Operator registration cooldown time in secons
uint256 public constant REGISTER_OPERATOR_COOLDOWN_LIMIT = 60 * 2; // 2 minutes
/** LIBRARY METHODS **/
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableSet for EnumerableSet.UintSet;
/** TYPES **/
/// @notice Player Account structure
struct PlayerAccount {
address playerAddress;
uint256 expiration;
}
/** MEMBERS **/
/// @notice Last time the player registered an operator wallet
mapping(address => uint256) public lastRegisterOperatorTime;
/// @notice System registry
mapping(uint256 => address) private _systemRegistry;
/// @notice Registry of current operator address to the player account
mapping(address => PlayerAccount) private _operatorToPlayerAccount;
/// @notice Registry of player account mapped to authorized operators
mapping(address => EnumerableSet.AddressSet) private _playerToOperatorAddresses;
/// @notice Map component id to its contract address
mapping(uint256 => address) _componentIdToAddress;
/// @notice Map component address to its ID
mapping(address => uint256) _componentAddressToId;
/// @notice GUID Counter
uint96 private _guidCounter;
/// @notice Map component ID to a map of the entities it stores
mapping(uint256 => EnumerableSet.UintSet) private _entityToComponents;
/// @notice Flag to check if the GUID counter has been set
bool private _guidCounterSet;
// @notice RequestID Mapping for cross-chain transfers
mapping(uint256 => bool) public requestIdProcessed;
/** EVENTS **/
/// @notice Emitted when an Operator address is registered
event OperatorRegistered(address player, address operator, uint256 expiration);
/// @notice Emitted when a System address is registered
event SystemRegistered(uint256 indexed id, address indexed systemAddress);
/// @notice Emitted when an Operator address is removed
event OperatorDeregistered(address operator, address player);
/// @notice Emitted when a component has been registered
event ComponentRegistered(uint256 indexed componentId, address indexed componentAddress);
/// @notice Emitted when a component value has been set
event ComponentValueSet(uint256 indexed componentId, uint256 indexed entity, bytes data);
/// @notice Emitted when a component value has been removed
event ComponentValueRemoved(uint256 indexed componentId, uint256 indexed entity);
/// @notice Emitted when a batch of component values has been set
event BatchComponentValueSet(uint256 indexed componentId, uint256[] entities, bytes[] data);
/// @notice Emitted when a batch of component values has been removed
event BatchComponentValueRemoved(uint256 indexed componentId, uint256[] entities);
/// @notice Emitted when a batch of component values has been set
event BatchMultiComponentValueSet(uint256[] componentIds, uint256[] entities, bytes[] data);
/// @notice Emitted when a batch of component values has been removed
event BatchMultiComponentValueRemoved(uint256[] componentIds, uint256[] entities);
/// @notice Emitted when a ComponentValueSet should be mirrored across chains
event PublishComponentValueSet(
uint256 indexed requestId,
uint256 indexed componentId,
uint256 indexed entity,
uint256 chainId,
uint256 requestTime,
bytes data
);
/// @notice Emitted when a BatchComponentValueSet should be mirrored across chains
event PublishBatchComponentValueSet(
uint256 indexed requestId,
uint256 indexed componentId,
uint256 chainId,
uint256 requestTime,
uint256[] entities,
bytes[] data
);
/// @notice Emitted when a BatchComponentValueSet should be mirrored across chains
event PublishBatchSetComponentValue(
uint256 indexed requestId,
uint256[] componentIds,
uint256[] entities,
uint256 fromChainId,
uint256 requestTime,
bytes[] data
);
/// @notice Emitted when a ComponentValueRemoved should be mirrored across chains
// TODO: Reenable when we're ready to support cross-chain removal
// event PublishComponentValueRemoved(
// uint256 indexed requestId,
// uint256 indexed componentId,
// uint256 indexed entity,
// uint256 chainId,
// uint256 requestTime
// );
/// @notice Emitted when a BatchComponentValueRemoved should be mirrored across chains
// TODO: Reenable when we're ready to support cross-chain removal
// event PublishBatchComponentValueRemoved(
// uint256 indexed requestId,
// uint256 indexed componentId,
// uint256 chainId,
// uint256 requestTime,
// uint256[] entities
// );
// 1155 Events
event Multichain1155TransferSingleSent(
uint256 requestId,
uint256 indexed systemId,
address indexed from,
address indexed to,
uint256 toChainId,
uint256 id,
uint256 amount
);
event Multichain1155TransferSingleReceived(
uint256 requestId,
uint256 indexed systemId,
address indexed from,
address indexed to,
uint256 fromChainId,
uint256 id,
uint256 amount
);
event Multichain1155TransferBatchSent(
uint256 requestId,
uint256 indexed systemId,
address indexed from,
address indexed to,
uint256 toChainId,
uint256[] ids,
uint256[] amounts
);
event Multichain1155TransferBatchReceived(
uint256 requestId,
uint256 indexed systemId,
address indexed from,
address indexed to,
uint256 fromChainId,
uint256[] ids,
uint256[] amounts
);
// 721 events
event Multichain721TransferSent(
uint256 requestId,
uint256 indexed systemId,
address indexed from,
address indexed to,
uint256 tokenId,
uint256 toChainId
);
event Multichain721TransferReceived(
uint256 requestId,
uint256 indexed systemId,
address indexed from,
address indexed to,
uint256 tokenId,
uint256 toChainId
);
/** ERRORS **/
/// @notice Invalid data count compared to number of entity count
error InvalidBatchData(uint256 entityCount, uint256 dataCount);
/// @notice Trying to access a component that hasn't been previously registered
error ComponentNotRegistered(address component);
/// @notice Trying to access a componentId that hasn't been previously registered
error ComponentIdNotRegistered(uint256 componentId);
/// @notice Operator
error InvalidOperatorAddress();
/// @notice Operator address must send transaction
error InvalidCaller();
/// @notice Player does not match signature
error PlayerSignerMismatch(address expected, address actual);
/// @notice Operator is registered to a different address, deregister first
error OperatorAlreadyRegistered();
/// @notice Invalid expiration timestamp provided
error InvalidExpirationTimestamp();
/// @notice Invalid block number (future block)
error InvalidBlockNumber();
/// @notice Invalid block number (expired)
error InvalidExpirationBlockNumber();
/// @notice Degregister request must come from player or operator
error InvalidDeregisterCaller();
/// @notice Operator has already expired
error OperatorExpired();
/// @notice Operator was not registered
error OperatorNotRegistered();
/// @notice Register operator in cooldown
error RegisterOperatorInCooldown();
/// @notice Not authorized to perform action
error MissingRole(address account, bytes32 expectedRole);
/// @notice Guid counter already set
error GuidCounterSet();
/// @notice Invalid System ID - The system ID must be registered.
error InvalidSystem(uint256 systemId);
/// @notice Invalid Chain ID - Must be processed on the correct Chain
error InvalidChain(uint256 chainId);
/// @notice Already Processed this request
error AlreadyProcessed(uint256 requestId);
/** SETUP **/
/**
* Initializer for this upgradeable contract
*/
function initialize(address admin) public initializer {
__AccessControl_init();
__Ownable_init();
__Pausable_init();
// Move ownership to deployer
_transferOwnership(admin);
// Give admin access role to owner
_setupRole(DEFAULT_ADMIN_ROLE, admin);
_setRoleAdmin(PAUSER_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(VRF_SYSTEM_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(DEPOSITOR_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(MINTER_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(MANAGER_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(DEPLOYER_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(GAME_NFT_CONTRACT_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(GAME_CURRENCY_CONTRACT_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(GAME_ITEMS_CONTRACT_ROLE, DEFAULT_ADMIN_ROLE);
_setRoleAdmin(GAME_LOGIC_CONTRACT_ROLE, DEFAULT_ADMIN_ROLE);
_pause();
}
/** EXTERNAL **/
/**
* @dev Set the GUID counter, should only be called once
*/
function setGuidCounter(uint96 guidValue) external onlyRole(MANAGER_ROLE) {
if (_guidCounterSet) {
revert GuidCounterSet();
}
_guidCounterSet = true;
_guidCounter = guidValue;
}
/**
* @dev Get the GUID counter value
*/
function getGuidCounter() external view returns (uint96) {
return _guidCounter;
}
/**
* Pause/Unpause the game and ALL the systems that utilize this game
*
* @param _paused Whether or pause or unpause
*/
function setPaused(bool _paused) external {
if (_msgSender() == owner() || hasRole(PAUSER_ROLE, _msgSender())) {
if (_paused) {
_pause();
} else {
_unpause();
}
} else {
revert MissingRole(_msgSender(), PAUSER_ROLE);
}
}
/**
* @inheritdoc IGameRegistry
*/
function paused() public view override(IGameRegistry, PausableUpgradeable) returns (bool) {
return PausableUpgradeable.paused();
}
/**
* @inheritdoc IGameRegistry
*/
function registerSystem(uint256 systemId, address systemAddress) external onlyRole(DEPLOYER_ROLE) {
_systemRegistry[systemId] = systemAddress;
emit SystemRegistered(systemId, systemAddress);
}
/**
* @inheritdoc IGameRegistry
*/
function getSystem(uint256 systemId) external view returns (address) {
return _systemRegistry[systemId];
}
/**
* @inheritdoc IGameRegistry
*/
function registerComponent(uint256 componentId, address componentAddress) public {
if (
hasAccessRole(GAME_LOGIC_CONTRACT_ROLE, _msgSender()) == false &&
hasAccessRole(MANAGER_ROLE, _msgSender()) == false &&
hasAccessRole(DEFAULT_ADMIN_ROLE, _msgSender()) == false
) {
revert MissingRole(_msgSender(), GAME_LOGIC_CONTRACT_ROLE);
}
_componentIdToAddress[componentId] = componentAddress;
_componentAddressToId[componentAddress] = componentId;
emit ComponentRegistered(componentId, componentAddress);
}
/**
* Gets a raw entity component value
* @param entity Entity to get value for
* @param componentId Component to get value from
*
* @return Bytes value of the entity component
*/
function getComponentValue(uint256 entity, uint256 componentId) external view returns (bytes memory) {
address componentAddress = _componentIdToAddress[componentId];
if (componentAddress == address(0)) {
revert ComponentNotRegistered(componentAddress);
}
return IComponent(componentAddress).getBytes(entity);
}
/**
* @inheritdoc IGameRegistry
* @dev Only registered components can call this function, otherwise it will revert
*/
function batchGetComponentValues(
uint256[] calldata entities,
uint256[] calldata componentIds
) external view returns (bytes[] memory values) {
values = new bytes[](entities.length);
for (uint256 i = 0; i < entities.length; i++) {
address componentAddress = _componentIdToAddress[componentIds[i]];
if (componentAddress == address(0)) {
revert ComponentNotRegistered(componentAddress);
}
values[i] = IComponent(componentAddress).getBytes(entities[i]);
}
}
/**
* @inheritdoc IGameRegistry
*/
function batchSetComponentValue(
uint256[] calldata entities,
uint256[] calldata componentIds,
bytes[] calldata values
) external override {
if (
hasAccessRole(GAME_LOGIC_CONTRACT_ROLE, _msgSender()) == false &&
hasAccessRole(MANAGER_ROLE, _msgSender()) == false &&
owner() != _msgSender()
) {
revert MissingRole(_msgSender(), GAME_LOGIC_CONTRACT_ROLE);
}
_batchSetComponentValue(entities, componentIds, values);
}
/**
* @inheritdoc IGameRegistry
*/
function batchPublishSetComponentValue(
uint256[] calldata entities,
uint256[] calldata componentIds,
bytes[] calldata values
) external override returns (uint256 requestId) {
if (
hasAccessRole(GAME_LOGIC_CONTRACT_ROLE, _msgSender()) == false &&
hasAccessRole(MANAGER_ROLE, _msgSender()) == false &&
owner() != _msgSender()
) {
revert MissingRole(_msgSender(), GAME_LOGIC_CONTRACT_ROLE);
}
_batchSetComponentValue(entities, componentIds, values);
requestId = _generateGUID();
emit PublishBatchSetComponentValue(requestId, componentIds, entities, block.chainid, block.timestamp, values);
return requestId;
}
/**
* @inheritdoc IGameRegistry
* @dev Only registered components can call this function, otherwise it will revert
*/
function registerComponentValueSet(uint256 entity, bytes calldata data) external virtual {
// Only registered components can call this function, if the component isn't register the event won't be emitted
uint256 componentId = _componentAddressToId[msg.sender];
if (componentId == 0) {
revert ComponentNotRegistered(msg.sender);
}
// Store reference of entity to component
_entityToComponents[entity].add(componentId);
emit ComponentValueSet(componentId, entity, data);
}
/**
* @inheritdoc IGameRegistry
* @dev Only registered components can call this function, otherwise it will revert
*/
function publishComponentValueSet(
uint256 componentId,
uint256 entity,
bytes calldata data
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) returns (uint256 requestId) {
if (_componentIdToAddress[componentId] == address(0)) {
revert ComponentIdNotRegistered(componentId);
}
requestId = _generateGUID();
emit PublishComponentValueSet(requestId, componentId, entity, block.chainid, block.timestamp, data);
}
/**
* @inheritdoc IGameRegistry
* @dev Only registered components can call this function, otherwise it will revert
*/
function batchRegisterComponentValueSet(uint256[] calldata entities, bytes[] calldata data) external virtual {
// Check to make sure the component is registered
uint256 componentId = _componentAddressToId[msg.sender];
if (componentId == 0) {
revert ComponentNotRegistered(msg.sender);
}
if (entities.length != data.length) {
revert InvalidBatchData(entities.length, data.length);
}
// Store references of entities to component
for (uint256 i = 0; i < entities.length; i++) {
_entityToComponents[entities[i]].add(componentId);
}
emit BatchComponentValueSet(componentId, entities, data);
}
/**
* @inheritdoc IGameRegistry
* @dev Only registered components can call this function, otherwise it will revert
*/
function batchPublishComponentValueSet(
uint256 componentId,
uint256[] calldata entities,
bytes[] calldata data
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) returns (uint256 requestId) {
if (_componentIdToAddress[componentId] == address(0)) {
revert ComponentIdNotRegistered(componentId);
}
// Check to make sure the component is registered
if (entities.length != data.length) {
revert InvalidBatchData(entities.length, data.length);
}
requestId = _generateGUID();
emit PublishBatchComponentValueSet(requestId, componentId, block.chainid, block.timestamp, entities, data);
}
/**
* @inheritdoc IGameRegistry
* @dev Only registered components can call this function, otherwise it will revert
*/
function registerComponentValueRemoved(uint256 entity) external virtual {
// Only registered components can call this function, if the component isn't register the event won't be emitted
uint256 componentId = _componentAddressToId[msg.sender];
if (componentId == 0) {
revert ComponentNotRegistered(msg.sender);
}
// Remove reference of entity to component
_entityToComponents[entity].remove(componentId);
emit ComponentValueRemoved(componentId, entity);
}
/**
* @inheritdoc IGameRegistry
* @dev Only registered components can call this function, otherwise it will revert
*/
function batchRegisterComponentValueRemoved(uint256[] calldata entities) external virtual {
uint256 componentId = _componentAddressToId[msg.sender];
if (componentId == 0) {
revert ComponentNotRegistered(msg.sender);
}
// Store references of entities to component
for (uint256 i = 0; i < entities.length; i++) {
_entityToComponents[entities[i]].remove(componentId);
}
emit BatchComponentValueRemoved(componentId, entities);
}
/**
* @notice Emits an event which oracles pick up to mint the item on another chian.
* @dev Only registered components can call this function, otherwise it will revert
*/
function sendMultichain1155TransferSingle(
uint256 systemId,
address from,
address to,
uint256 toChainId,
uint256 id,
uint256 amount
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (to == address(0)) {
return;
}
uint256 requestId = _generateGUID();
if (address(_systemRegistry[systemId]) != msg.sender) {
revert InvalidSystem(systemId);
}
emit Multichain1155TransferSingleSent(requestId, systemId, from, to, toChainId, id, amount);
}
/**
* @notice Emits an event which oracles pick up to mint the item on another chian.
* @dev Only registered components can call this function, otherwise it will revert
*/
function sendMultichain1155TransferBatch(
uint256 systemId,
address from,
address to,
uint256 toChainId,
uint256[] calldata ids,
uint256[] calldata amounts
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (to == address(0)) {
return;
}
uint256 requestId = _generateGUID();
if (address(_systemRegistry[systemId]) != msg.sender) {
revert InvalidSystem(systemId);
}
emit Multichain1155TransferBatchSent(requestId, systemId, from, to, toChainId, ids, amounts);
}
/**
* @notice Emits an event which oracles pick up to mint the item on another chian.
* @dev Only registered components can call this function, otherwise it will revert
*/
function sendMultichain721Transfer(
uint256 systemId,
address from,
address to,
uint256 tokenId,
uint256 toChainId
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (to == address(0)) {
return;
}
uint256 requestId = _generateGUID();
if (address(_systemRegistry[systemId]) != msg.sender) {
revert InvalidSystem(systemId);
}
emit Multichain721TransferSent(requestId, systemId, from, to, tokenId, toChainId);
}
/**
* @notice Delivers an item that has been transferred from another chain in the Multichain
* @dev Must be called by a trusted multichain
*/
function deliverMultichain1155TransferSingle(
uint256 requestId,
uint256 systemId,
address from,
address to,
uint256 fromChainId,
uint256 id,
uint256 amount
) external onlyRole(TRUSTED_MULTICHAIN_ORACLE_ROLE) {
_enforceChain(to);
//replay protection
_validateRequestId(requestId);
// mint items
if (_systemRegistry[systemId] == address(0)) {
revert InvalidSystem(systemId);
}
IMultichain1155 system = IMultichain1155(_systemRegistry[systemId]);
system.receivedMultichain1155TransferSingle(to, id, amount);
emit Multichain1155TransferSingleReceived(requestId, systemId, from, to, fromChainId, id, amount);
}
/**
* @notice Delivers an item that has been transferred from another chain in the Multichain
* @dev Must be called by a trusted multichain
*/
function deliverMultichain1155TransferBatch(
uint256 requestId,
uint256 systemId,
address from,
address to,
uint256 fromChainId,
uint256[] calldata ids,
uint256[] calldata amounts
) external onlyRole(TRUSTED_MULTICHAIN_ORACLE_ROLE) {
_enforceChain(to);
//replay protection
_validateRequestId(requestId);
// mint items
if (_systemRegistry[systemId] == address(0)) {
revert InvalidSystem(systemId);
}
IMultichain1155 system = IMultichain1155(_systemRegistry[systemId]);
system.receivedMultichain1155TransferBatch(to, ids, amounts);
emit Multichain1155TransferBatchReceived(requestId, systemId, from, to, fromChainId, ids, amounts);
}
/**
* @notice Delivers an item that has been transferred from another chain in the Multichain
* @dev Must be called by a trusted multichain
*/
function deliverMultichain721Transfer(
uint256 requestId,
uint256 systemId,
address from,
address to,
uint256 tokenId,
uint256 fromChainId,
BatchComponentData calldata componentData
) external onlyRole(TRUSTED_MULTICHAIN_ORACLE_ROLE) {
_enforceChain(to);
_validateRequestId(requestId);
if (_systemRegistry[systemId] == address(0)) {
revert InvalidSystem(systemId);
}
// mint items
IMultichain721 system = IMultichain721(_systemRegistry[systemId]);
system.receivedMultichain721Transfer(to, tokenId);
_batchSetComponentData(componentData);
emit Multichain721TransferReceived(requestId, systemId, from, to, tokenId, fromChainId);
}
/**
* @inheritdoc IGameRegistry
*/
function getComponent(uint256 componentId) external view returns (address) {
return _componentIdToAddress[componentId];
}
/**
* @inheritdoc IGameRegistry
*/
function getComponentIdFromAddress(address componentAddr) external view returns (uint256) {
return _componentAddressToId[componentAddr];
}
/**
* @inheritdoc IGameRegistry
*/
function getEntityHasComponent(uint256 entity, uint256 componentId) external view returns (bool) {
return _entityToComponents[entity].contains(componentId);
}
/**
* @inheritdoc IGameRegistry
*/
function batchGetEntitiesHasComponents(
uint256[] calldata entities,
uint256[] calldata componentIds
) external view returns (bool[] memory) {
bool[] memory results = new bool[](entities.length);
for (uint256 i = 0; i < entities.length; i++) {
results[i] = _entityToComponents[entities[i]].contains(componentIds[i]);
}
return results;
}
/**
* @inheritdoc IGameRegistry
*/
function getEntityComponents(uint256 entity) external view returns (uint256[] memory) {
return _entityToComponents[entity].values();
}
/**
* @dev Will filter out archived components and return only unarchived components
*/
function getUnarchivedEntityComponents(uint256 entity) external view returns (uint256[] memory) {
uint256[] memory componentIds = _entityToComponents[entity].values();
ArchivedComponent archivedComponent = ArchivedComponent(_componentIdToAddress[ARCHIVED_COMPONENT_ID]);
uint256[] memory unarchivedComponentIds = new uint256[](componentIds.length);
uint256 counter = 0;
for (uint256 i = 0; i < componentIds.length; i++) {
if (archivedComponent.getValue(componentIds[i])) {
continue;
}
unarchivedComponentIds[counter] = componentIds[i];
counter++;
}
assembly {
mstore(unarchivedComponentIds, counter)
}
return unarchivedComponentIds;
}
/**
* @inheritdoc IGameRegistry
*/
function getEntityComponentCount(uint256 entity) external view returns (uint256) {
return _entityToComponents[entity].length();
}
/**
* @inheritdoc IGameRegistry
*/
function generateGUIDDeprecated() external onlyRole(GAME_LOGIC_CONTRACT_ROLE) returns (uint256) {
_guidCounter++;
uint256 guidEntity = EntityLibrary.tokenToEntity(address(this), _guidCounter);
return guidEntity;
}
/**
* @inheritdoc IERC165
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(IERC165, AccessControlUpgradeable) returns (bool) {
return
interfaceId == type(IGameRegistry).interfaceId ||
interfaceId == type(IERC165).interfaceId ||
AccessControlUpgradeable.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasAccessRole(bytes32 role, address account) public view override returns (bool) {
return AccessControlUpgradeable.hasRole(role, account);
}
/**
* Returns the address of the account the operatorAddress is authorized to
*
* @param operatorAddress Address the sending controller
*/
function getPlayerAccount(address operatorAddress) external view returns (address) {
if (operatorAddress == address(0)) {
revert InvalidOperatorAddress();
}
PlayerAccount memory account = _operatorToPlayerAccount[operatorAddress];
address playerAddress = account.playerAddress;
if (playerAddress != address(0)) {
if (account.expiration < block.timestamp && account.expiration != 0) {
revert OperatorExpired();
}
} else {
return operatorAddress;
}
return playerAddress;
}
/**
* Called in order to retrieve message to sign to register an oeperator
*
* @param player address operator is being registered for
* @param operator address of operator being registered
* @param expiration block time for registration (or 0 for infinite)
* @param blockNumber the message was signed at
*/
function getOperatorAccountRegistrationMessageToSign(
address player,
address operator,
uint256 expiration,
uint256 blockNumber
) public pure returns (bytes memory) {
return
abi.encodePacked(
'Authorize operator account ',
Strings.toHexString(uint256(uint160(operator)), 20),
' to perform gameplay actions on behalf of player account ',
Strings.toHexString(uint256(uint160(player)), 20),
' with expiration ',
Strings.toString(expiration),
' signed at block ',
Strings.toString(blockNumber)
);
}
/**
* Called by an Operator Address with a signature from a Player Address authorizing it until a given expiration time
*
* @param signature from signer/player address authorizing operator until expiration time
* @param player address of player being registered
* @param operator address of operator being registered
* @param expiration block time for registration (or 0 for infinite)
* @param blockNumber the message was signed at
*/
function registerOperator(
bytes calldata signature,
address player,
address operator,
uint256 expiration,
uint256 blockNumber
) external whenNotPaused {
if (_msgSender() != operator) {
revert InvalidCaller();
}
if ((block.timestamp - lastRegisterOperatorTime[player]) < REGISTER_OPERATOR_COOLDOWN_LIMIT) {
revert RegisterOperatorInCooldown();
}
if (operator == player || operator == address(0)) {
revert InvalidOperatorAddress();
}
if (expiration < block.timestamp && expiration != 0) {
revert InvalidExpirationTimestamp();
}
// if (blockNumber > block.number) {
// revert InvalidBlockNumber();
// }
// if (block.number > blockNumber + OPERATOR_MESSAGE_BLOCK_LIMIT) {
// revert InvalidExpirationBlockNumber();
// }
PlayerAccount memory currentAccount = _operatorToPlayerAccount[operator];
if (currentAccount.playerAddress != address(0) && currentAccount.playerAddress != player) {
revert OperatorAlreadyRegistered();
}
bytes memory message = getOperatorAccountRegistrationMessageToSign(player, operator, expiration, blockNumber);
bytes32 digest = ECDSA.toEthSignedMessageHash(message);
address recoveredSigner = ECDSA.recover(digest, signature);
if (player != recoveredSigner) {
revert PlayerSignerMismatch(player, recoveredSigner);
}
_operatorToPlayerAccount[operator] = PlayerAccount({playerAddress: player, expiration: expiration});
_playerToOperatorAddresses[player].add(operator);
// Track cooldown timer
lastRegisterOperatorTime[player] = block.timestamp;
emit OperatorRegistered(player, operator, expiration);
}
/**
* Batch set operator accounts for players
* @param players addresses of players being registered
* @param operators addresses of operators being registered
* @param expirations block times for registration (or 0 for infinite)
*/
function registerOperatorBatch(
address[] calldata players,
address[] calldata operators,
uint256[] calldata expirations
) external whenNotPaused onlyRole(MANAGER_ROLE) {
if (players.length != operators.length || players.length != expirations.length) {
revert InvalidOperatorAddress();
}
for (uint256 i = 0; i < players.length; i++) {
if (operators[i] == players[i] || operators[i] == address(0)) {
revert InvalidOperatorAddress();
}
_operatorToPlayerAccount[operators[i]] = PlayerAccount({playerAddress: players[i], expiration: expirations[i]});
_playerToOperatorAddresses[players[i]].add(operators[i]);
// Track cooldown timer
lastRegisterOperatorTime[players[i]] = block.timestamp;
emit OperatorRegistered(players[i], operators[i], expirations[i]);
}
}
function deregisterOperatorBatch(address[] calldata operators) public whenNotPaused onlyRole(MANAGER_ROLE) {
for (uint256 i = 0; i < operators.length; i++) {
address playerAddress = _operatorToPlayerAccount[operators[i]].playerAddress;
// if (playerAddress == address(0)) {
// revert OperatorNotRegistered();
// }
delete _operatorToPlayerAccount[operators[i]];
_playerToOperatorAddresses[playerAddress].remove(operators[i]);
// if (operatorRemovedFromPlayer != true) {
// revert OperatorNotRegistered();
// }
emit OperatorDeregistered(operators[i], playerAddress);
}
}
/**
* Called by an Operator or Player to deregister an Operator account
*
* @param operatorToDeregister address of operator to deregister
*/
function deregisterOperator(address operatorToDeregister) external {
address playerAddress = _operatorToPlayerAccount[operatorToDeregister].playerAddress;
if (playerAddress == address(0)) {
revert OperatorNotRegistered();
}
if (operatorToDeregister != _msgSender() && playerAddress != _msgSender()) {
revert InvalidDeregisterCaller();
}
delete _operatorToPlayerAccount[operatorToDeregister];
bool operatorRemovedFromPlayer = _playerToOperatorAddresses[playerAddress].remove(operatorToDeregister);
if (operatorRemovedFromPlayer != true) {
revert OperatorNotRegistered();
}
emit OperatorDeregistered(operatorToDeregister, playerAddress);
}
/**
* Returns an array of registered Operators for a Player address
*
* @param player address to retrieve operators for
*/
function getRegisteredOperators(address player) external view returns (address[] memory) {
return _playerToOperatorAddresses[player].values();
}
/// @inheritdoc IERC2771Recipient
function isTrustedForwarder(address forwarder) public view virtual override returns (bool) {
return hasAccessRole(TRUSTED_FORWARDER_ROLE, forwarder);
}
/// @inheritdoc IERC2771Recipient
function _msgSender() internal view virtual override(ContextUpgradeable, IERC2771Recipient) returns (address ret) {
if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
assembly {
ret := shr(96, calldataload(sub(calldatasize(), 20)))
}
} else {
ret = msg.sender;
}
}
/// @inheritdoc IERC2771Recipient
function _msgData()
internal
view
virtual
override(ContextUpgradeable, IERC2771Recipient)
returns (bytes calldata ret)
{
if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
return msg.data[0:msg.data.length - 20];
} else {
return msg.data;
}
}
function _generateGUID() internal returns (uint256) {
GuidCounterComponent counter = GuidCounterComponent(_componentIdToAddress[GUID_COUNTER_COMPONENT_ID]);
// Increment guid counter
uint256 count = counter.getValue(GUID_PREFIX) + 1;
counter.setValue(GUID_PREFIX, count);
return GUIDLibrary.packGuid(GUID_PREFIX, count);
}
function _enforceChain(address to) internal view {
uint256 userToChainId = ChainIdComponent(_componentIdToAddress[CHAIN_ID_COMPONENT_ID]).getValue(
EntityLibrary.addressToEntity(to)
);
if (userToChainId != block.chainid) {
revert InvalidChain(userToChainId);
}
}
function _validateRequestId(uint256 requestId) internal {
if (requestIdProcessed[requestId]) {
revert AlreadyProcessed(requestId);
}
requestIdProcessed[requestId] = true;
}
function _batchSetComponentData(BatchComponentData calldata componentData) internal {
_batchSetComponentValue(componentData.entities, componentData.componentIds, componentData.data);
}
function _batchSetComponentValue(
uint256[] calldata entities,
uint256[] calldata componentIds,
bytes[] calldata values
) internal {
if (entities.length != values.length || entities.length != componentIds.length) {
revert InvalidBatchData(entities.length, values.length);
}
for (uint256 i = 0; i < entities.length; i++) {
address componentAddress = _componentIdToAddress[componentIds[i]];
if (componentAddress == address(0)) {
revert ComponentNotRegistered(componentAddress);
}
IComponent(componentAddress).setBytes(entities[i], values[i]);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
/**
* @title The ERC-2771 Recipient Base Abstract Class - Declarations
*
* @notice A contract must implement this interface in order to support relayed transaction.
*
* @notice It is recommended that your contract inherits from the ERC2771Recipient contract.
*/
abstract contract IERC2771Recipient {
/**
* :warning: **Warning** :warning: The Forwarder can have a full control over your Recipient. Only trust verified Forwarder.
* @param forwarder The address of the Forwarder contract that is being used.
* @return isTrustedForwarder `true` if the Forwarder is trusted to forward relayed transactions by this Recipient.
*/
function isTrustedForwarder(address forwarder) public virtual view returns(bool);
/**
* @notice Use this method the contract anywhere instead of msg.sender to support relayed transactions.
* @return sender The real sender of this call.
* For a call that came through the Forwarder the real sender is extracted from the last 20 bytes of the `msg.data`.
* Otherwise simply returns `msg.sender`.
*/
function _msgSender() internal virtual view returns (address);
/**
* @notice Use this method in the contract instead of `msg.data` when difference matters (hashing, signature, etc.)
* @return data The real `msg.data` of this call.
* For a call that came through the Forwarder, the real sender address was appended as the last 20 bytes
* of the `msg.data` - so this method will strip those 20 bytes off.
* Otherwise (if the call was made directly and not through the forwarder) simply returns `msg.data`.
*/
function _msgData() internal virtual view returns (bytes calldata);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
StringsUpgradeable.toHexString(account),
" is missing role ",
StringsUpgradeable.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @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 (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @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 proxied contracts do not make use of 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.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* 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 prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Internal function that returns the initialized version. Returns `_initialized`
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Internal function that returns the initialized version. Returns `_initializing`
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @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
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or 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 {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = MathUpgradeable.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, MathUpgradeable.log256(value) + 1);
}
}
/**
* @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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens 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 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
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.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position 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) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.9;
// Used for calculating decimal-point percentages (10000 = 100%)
uint256 constant PERCENTAGE_RANGE = 10000;
// Pauser Role - Can pause the game
bytes32 constant PAUSER_ROLE = keccak256('PAUSER_ROLE');
// Minter Role - Can mint items, NFTs, and ERC20 currency
bytes32 constant MINTER_ROLE = keccak256('MINTER_ROLE');
// Manager Role - Can manage the shop, loot tables, and other game data
bytes32 constant MANAGER_ROLE = keccak256('MANAGER_ROLE');
// Depoloyer Role - Can Deploy new Systems
bytes32 constant DEPLOYER_ROLE = keccak256('DEPLOYER_ROLE');
// Game Logic Contract - Contract that executes game logic and accesses other systems
bytes32 constant GAME_LOGIC_CONTRACT_ROLE = keccak256('GAME_LOGIC_CONTRACT_ROLE');
// Game Currency Contract - Allowlisted currency ERC20 contract
bytes32 constant GAME_CURRENCY_CONTRACT_ROLE = keccak256('GAME_CURRENCY_CONTRACT_ROLE');
// Game NFT Contract - Allowlisted game NFT ERC721 contract
bytes32 constant GAME_NFT_CONTRACT_ROLE = keccak256('GAME_NFT_CONTRACT_ROLE');
// Game Items Contract - Allowlist game items ERC1155 contract
bytes32 constant GAME_ITEMS_CONTRACT_ROLE = keccak256('GAME_ITEMS_CONTRACT_ROLE');
// Depositor role - used by Polygon bridge to mint on child chain
bytes32 constant DEPOSITOR_ROLE = keccak256('DEPOSITOR_ROLE');
// Randomizer role - Used by the randomizer contract to callback
bytes32 constant VRF_SYSTEM_ROLE = keccak256('VRF_SYSTEM_ROLE');
// VRF Consumer Contract - Contract that uses VRF to demonstrate randomness
bytes32 constant VRF_CONSUMER_ROLE = keccak256('VRF_CONSUMER_ROLE');
// Trusted forwarder role - Used by meta transactions to verify trusted forwader(s)
bytes32 constant TRUSTED_FORWARDER_ROLE = keccak256('TRUSTED_FORWARDER_ROLE');
// Trusted mirror role - Used by pirate mirroring
bytes32 constant TRUSTED_MIRROR_ROLE = keccak256('TRUSTED_MIRROR_ROLE');
// Trusted multichain oracle role - Used by multichain contracts
bytes32 constant TRUSTED_MULTICHAIN_ORACLE_ROLE = keccak256('TRUSTED_MULTICHAIN_ORACLE_ROLE');
// =====
// All of the possible traits in the system
// =====
/// @dev Trait that points to another token/template id
uint256 constant TEMPLATE_ID_TRAIT_ID = uint256(keccak256('template_id'));
// Generation of a token
uint256 constant GENERATION_TRAIT_ID = uint256(keccak256('generation'));
// XP for a token
uint256 constant XP_TRAIT_ID = uint256(keccak256('xp'));
// Current level of a token
uint256 constant LEVEL_TRAIT_ID = uint256(keccak256('level'));
// Whether or not a token is a pirate
uint256 constant IS_PIRATE_TRAIT_ID = uint256(keccak256('is_pirate'));
// Whether or not a token is a ship
uint256 constant IS_SHIP_TRAIT_ID = uint256(keccak256('is_ship'));
// Whether or not an item is equippable on ships
uint256 constant EQUIPMENT_TYPE_TRAIT_ID = uint256(keccak256('equipment_type'));
// Combat modifiers for items and tokens
uint256 constant COMBAT_MODIFIERS_TRAIT_ID = uint256(keccak256('combat_modifiers'));
// Animation URL for the token
uint256 constant ANIMATION_URL_TRAIT_ID = uint256(keccak256('animation_url'));
// Item slots
uint256 constant ITEM_SLOTS_TRAIT_ID = uint256(keccak256('item_slots'));
// Rank of the ship
uint256 constant SHIP_RANK_TRAIT_ID = uint256(keccak256('ship_rank'));
// Current Health trait
uint256 constant CURRENT_HEALTH_TRAIT_ID = uint256(keccak256('current_health'));
// Health trait
uint256 constant HEALTH_TRAIT_ID = uint256(keccak256('health'));
// Damage trait
uint256 constant DAMAGE_TRAIT_ID = uint256(keccak256('damage'));
// Speed trait
uint256 constant SPEED_TRAIT_ID = uint256(keccak256('speed'));
// Accuracy trait
uint256 constant ACCURACY_TRAIT_ID = uint256(keccak256('accuracy'));
// Evasion trait
uint256 constant EVASION_TRAIT_ID = uint256(keccak256('evasion'));
// Image hash of token's image, used for verifiable / fair drops
uint256 constant IMAGE_HASH_TRAIT_ID = uint256(keccak256('image_hash'));
// Name of a token
uint256 constant NAME_TRAIT_ID = uint256(keccak256('name_trait'));
// Description of a token
uint256 constant DESCRIPTION_TRAIT_ID = uint256(keccak256('description_trait'));
// General rarity for a token (corresponds to IGameRarity)
uint256 constant RARITY_TRAIT_ID = uint256(keccak256('rarity'));
// The character's affinity for a specific element
uint256 constant ELEMENTAL_AFFINITY_TRAIT_ID = uint256(keccak256('affinity_id'));
// The character's expertise value
uint256 constant EXPERTISE_TRAIT_ID = uint256(keccak256('expertise_id'));
// Expertise damage mod ID from SoT
uint256 constant EXPERTISE_DAMAGE_ID = uint256(keccak256('expertise.levelmultiplier.damage'));
// Expertise evasion mod ID from SoT
uint256 constant EXPERTISE_EVASION_ID = uint256(keccak256('expertise.levelmultiplier.evasion'));
// Expertise speed mod ID from SoT
uint256 constant EXPERTISE_SPEED_ID = uint256(keccak256('expertise.levelmultiplier.speed'));
// Expertise accuracy mod ID from SoT
uint256 constant EXPERTISE_ACCURACY_ID = uint256(keccak256('expertise.levelmultiplier.accuracy'));
// Expertise health mod ID from SoT
uint256 constant EXPERTISE_HEALTH_ID = uint256(keccak256('expertise.levelmultiplier.health'));
// Boss start time trait
uint256 constant BOSS_START_TIME_TRAIT_ID = uint256(keccak256('boss_start_time'));
// Boss end time trait
uint256 constant BOSS_END_TIME_TRAIT_ID = uint256(keccak256('boss_end_time'));
// Boss type trait
uint256 constant BOSS_TYPE_TRAIT_ID = uint256(keccak256('boss_type'));
// The character's dice rolls
uint256 constant DICE_ROLL_1_TRAIT_ID = uint256(keccak256('dice_roll_1'));
uint256 constant DICE_ROLL_2_TRAIT_ID = uint256(keccak256('dice_roll_2'));
// The character's star sign (astrology)
uint256 constant STAR_SIGN_TRAIT_ID = uint256(keccak256('star_sign'));
// Image for the token
uint256 constant IMAGE_TRAIT_ID = uint256(keccak256('image_trait'));
// How much energy the token provides if used
uint256 constant ENERGY_PROVIDED_TRAIT_ID = uint256(keccak256('energy_provided'));
// Whether a given token is soulbound, meaning it is unable to be transferred
uint256 constant SOULBOUND_TRAIT_ID = uint256(keccak256('soulbound'));
// ------
// Avatar Profile Picture related traits
// If an avatar is a 1 of 1, this is their only trait
uint256 constant PROFILE_IS_LEGENDARY_TRAIT_ID = uint256(keccak256('profile_is_legendary'));
// Avatar's archetype -- possible values: Human (including Druid, Mage, Berserker, Crusty), Robot, Animal, Zombie, Vampire, Ghost
uint256 constant PROFILE_CHARACTER_TYPE = uint256(keccak256('profile_character_type'));
// Avatar's profile picture's background image
uint256 constant PROFILE_BACKGROUND_TRAIT_ID = uint256(keccak256('profile_background'));
// Avatar's eye style
uint256 constant PROFILE_EYES_TRAIT_ID = uint256(keccak256('profile_eyes'));
// Avatar's facial hair type
uint256 constant PROFILE_FACIAL_HAIR_TRAIT_ID = uint256(keccak256('profile_facial_hair'));
// Avatar's hair style
uint256 constant PROFILE_HAIR_TRAIT_ID = uint256(keccak256('profile_hair'));
// Avatar's skin color
uint256 constant PROFILE_SKIN_TRAIT_ID = uint256(keccak256('profile_skin'));
// Avatar's coat color
uint256 constant PROFILE_COAT_TRAIT_ID = uint256(keccak256('profile_coat'));
// Avatar's earring(s) type
uint256 constant PROFILE_EARRING_TRAIT_ID = uint256(keccak256('profile_facial_hair'));
// Avatar's eye covering
uint256 constant PROFILE_EYE_COVERING_TRAIT_ID = uint256(keccak256('profile_eye_covering'));
// Avatar's headwear
uint256 constant PROFILE_HEADWEAR_TRAIT_ID = uint256(keccak256('profile_headwear'));
// Avatar's (Mages only) gem color
uint256 constant PROFILE_MAGE_GEM_TRAIT_ID = uint256(keccak256('profile_mage_gem'));
// ------
// Dungeon traits
// Whether this token template is a dungeon trigger
uint256 constant IS_DUNGEON_TRIGGER_TRAIT_ID = uint256(keccak256('is_dungeon_trigger'));
// Dungeon start time trait
uint256 constant DUNGEON_START_TIME_TRAIT_ID = uint256(keccak256('dungeon.start_time'));
// Dungeon end time trait
uint256 constant DUNGEON_END_TIME_TRAIT_ID = uint256(keccak256('dungeon.end_time'));
// Dungeon SoT map id trait
uint256 constant DUNGEON_MAP_TRAIT_ID = uint256(keccak256('dungeon.map_id'));
// Whether this token template is a mob
uint256 constant IS_MOB_TRAIT_ID = uint256(keccak256('is_mob'));
// ------
// Island traits
// Whether a game item is placeable on an island
uint256 constant IS_PLACEABLE_TRAIT_ID = uint256(keccak256('is_placeable'));
// ------
// Extra traits for component migration
// NOTE: CURRENTLY NOT USED IN CONTRACTS CODE
uint256 constant MODEL_GLTF_URL_TRAIT_ID = uint256(keccak256('model_gltf_url'));
uint256 constant PLACEABLE_CATEGORY_TRAIT_ID = uint256(keccak256('placeable_category'));
uint256 constant PLACEABLE_IS_BOTTOM_STACKABLE_TRAIT_ID = uint256(keccak256('placeable.is_bottom_stackable'));
uint256 constant PLACEABLE_IS_TOP_STACKABLE_TRAIT_ID = uint256(keccak256('placeable.is_top_stackable'));
uint256 constant PLACEABLE_TERRAIN_TRAIT_ID = uint256(keccak256('placeable.terrain'));
uint256 constant GLTF_SCALING_FACTOR_TRAIT_ID = uint256(keccak256('gltf_scaling_factor'));
uint256 constant SIZE_TRAIT_ID = uint256(keccak256('size'));// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import {IBaseStorageComponentV2} from "./IBaseStorageComponentV2.sol";
import "../GameRegistryConsumerV2.sol";
/**
* @title BaseStorageComponentV2
* @notice Base storage component class, version 2
*/
abstract contract BaseStorageComponentV2 is
IBaseStorageComponentV2,
GameRegistryConsumerV2
{
/// @notice Invalid data count compared to number of entity count
error InvalidBatchData(uint256 entityCount, uint256 valueCount);
/** SETUP **/
/**
* @param _gameRegistryAddress Address of the GameRegistry contract
* @param id ID of the component being created
*/
constructor(
address _gameRegistryAddress,
uint256 id
) GameRegistryConsumerV2(_gameRegistryAddress, id) {
// Do nothing
}
/** INTERNAL */
/**
* Use GameRegistry to trigger emit when setting
* @param entity Entity to set the value for.
* @param value Value to set for the given entity.
*/
function _emitSetBytes(
uint256 entity,
bytes memory value
) internal virtual {
// Emit global event
gameRegistry.registerComponentValueSet(entity, value);
}
/**
* Use GameRegistry to trigger emit when setting
* @param entities Array of entities to set values for.
* @param values Array of values to set for a given entity.
*/
function _emitBatchSetBytes(
uint256[] calldata entities,
bytes[] memory values
) internal virtual {
// Emit global event
gameRegistry.batchRegisterComponentValueSet(entities, values);
}
/**
* Use GameRegistry to trigger emit when removing
* @param entity Entity to remove from this component.
*/
function _emitRemoveBytes(uint256 entity) internal virtual {
// Emit global event
gameRegistry.registerComponentValueRemoved(entity);
}
/**
* Use GameRegistry to trigger emit when removing
* @param entities Array of entities to remove from this component.
*/
function _emitBatchRemoveBytes(
uint256[] calldata entities
) internal virtual {
// Emit global event
gameRegistry.batchRegisterComponentValueRemoved(entities);
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import {TypesLibrary} from "../TypesLibrary.sol";
interface IBaseStorageComponentV2 {
/** Return the keys and value types of the schema of this component. */
function getSchema()
external
pure
returns (
string[] memory keys,
TypesLibrary.SchemaValue[] memory values
);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import {TypesLibrary} from "../TypesLibrary.sol";
interface IComponent {
/**
* Sets the raw bytes value for this component
*
* @param entity Entity to set value for
* @param value Bytes encoded value for this component
*/
function setBytes(uint256 entity, bytes memory value) external;
/**
* Removes an entity from this component
* @param entity Entity to remove
*/
function remove(uint256 entity) external;
/**
* Whether or not the entity exists in this component
* @param entity Entity to check for
* @return true if the entity exists
*/
function has(uint256 entity) external view returns (bool);
/**
* @param entity Entity to retrieve value for
* @return The raw bytes value for the given entity in this component
*/
function getBytes(uint256 entity) external view returns (bytes memory);
/** Return the keys and value types of the schema of this component. */
function getSchema()
external
pure
returns (
string[] memory keys,
TypesLibrary.SchemaValue[] memory values
);
/**
* Sets the raw bytes value for this component in batches
*
* @param entities Entities to set values for
* @param values Bytes encoded values for this component
*/
function batchSetBytes(
uint256[] calldata entities,
bytes[] calldata values
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
uint256 constant MAX_UINT96 = 2 ** 96 - 1;
/** @title Entity related helpers **/
library EntityLibrary {
/** ERRORS **/
error TokenIdExceedsMaxValue(uint256 tokenId);
/** INTERNAL **/
/**
* @dev Note this function will require the tokenId is < uint96.MAX
* Unpacks a token address from a single uint256 which is the entity ID
*
* @return tokenAddress Address of the unpacked token
*/
function entityToAddress(
uint256 value
) internal pure returns (address tokenAddress) {
tokenAddress = address(uint160(value));
uint256 tokenId = uint256(value >> 160);
uint256 verify = (tokenId << 160) | uint160(tokenAddress);
require(verify == value);
}
/**
* Packs an address into a single uint256 entity
*
* @param addr Address to convert to entity
* @return Converted address to entity
*/
function addressToEntity(address addr) internal pure returns (uint256) {
return uint160(addr);
}
/**
* @dev Note this function will require the tokenId is < uint96.MAX
* Unpacks a token address and token id from a single uint256
*
* @return tokenAddress Address of the unpacked token
* @return tokenId Id of the unpacked token
*/
function entityToToken(
uint256 value
) internal pure returns (address tokenAddress, uint256 tokenId) {
tokenAddress = address(uint160(value));
tokenId = uint256(value >> 160);
uint256 verify = (tokenId << 160) | uint160(tokenAddress);
require(verify == value);
}
/**
* @dev Note this function will require the tokenId is < uint96.MAX
* Packs a token address and token id into a single uint256
*
* @param tokenAddress Address of the unpacked token
* @param tokenId Id of the unpacked token
* @return Token address and token id packed into single uint256
*/
function tokenToEntity(
address tokenAddress,
uint256 tokenId
) internal pure returns (uint256) {
if (tokenId > MAX_UINT96) {
revert TokenIdExceedsMaxValue(tokenId);
}
return (tokenId << 160) | uint160(tokenAddress);
}
/**
* @dev Pack an account and entity ID together and keccak256 hash them, then return the uint value of the hash
* @param account Account address
* @param entity Entity ID
* @return Uint256 value of the keccak256 hash
*/
function accountSubEntity(
address account,
uint256 entity
) internal pure returns (uint256) {
return uint256((keccak256(abi.encodePacked(account, entity))));
}
}// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@opengsn/contracts/src/interfaces/IERC2771Recipient.sol";
import {IGameRegistry} from "./IGameRegistry.sol";
import {ISystem} from "./ISystem.sol";
import {TRUSTED_FORWARDER_ROLE, MANAGER_ROLE} from "../Constants.sol";
/** @title Contract that lets a child contract access the GameRegistry contract */
contract GameRegistryConsumerV2 is ISystem, Ownable, IERC2771Recipient {
/// @notice Id for the system/component
uint256 private _id;
/// @notice Read access contract
IGameRegistry public gameRegistry;
/** ERRORS **/
/// @notice Not authorized to perform action
error MissingRole(address account, bytes32 expectedRole);
/** MODIFIERS **/
// Modifier to verify a user has the appropriate role to call a given function
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/** ERRORS **/
/// @notice gameRegistryAddress does not implement IGameRegistry
error InvalidGameRegistry();
/** SETUP **/
/** Sets the GameRegistry contract address for this contract */
constructor(address gameRegistryAddress, uint256 id) {
gameRegistry = IGameRegistry(gameRegistryAddress);
_id = id;
if (gameRegistryAddress == address(0)) {
revert InvalidGameRegistry();
}
}
/** EXTERNAL **/
/** @return ID for this system */
function getId() public view override returns (uint256) {
return _id;
}
/**
* Sets the GameRegistry contract address for this contract
*
* @param gameRegistryAddress Address for the GameRegistry contract
*/
function setGameRegistry(
address gameRegistryAddress
) external onlyRole(MANAGER_ROLE) {
gameRegistry = IGameRegistry(gameRegistryAddress);
if (gameRegistryAddress == address(0)) {
revert InvalidGameRegistry();
}
}
/** @return GameRegistry contract for this contract */
function getGameRegistry() external view returns (IGameRegistry) {
return gameRegistry;
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function _hasAccessRole(
bytes32 role,
address account
) internal view returns (bool) {
return gameRegistry.hasAccessRole(role, account);
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!gameRegistry.hasAccessRole(role, account)) {
revert MissingRole(account, role);
}
}
/**
* Returns the Player address for the Operator account
* @param operatorAccount address of the Operator account to retrieve the player for
*/
function _getPlayerAccount(
address operatorAccount
) internal view returns (address playerAccount) {
return gameRegistry.getPlayerAccount(operatorAccount);
}
/// @inheritdoc IERC2771Recipient
function isTrustedForwarder(
address forwarder
) public view virtual override returns (bool) {
return
address(gameRegistry) != address(0) &&
_hasAccessRole(TRUSTED_FORWARDER_ROLE, forwarder);
}
/** INTERNAL **/
/// @inheritdoc IERC2771Recipient
function _msgSender()
internal
view
virtual
override(Context, IERC2771Recipient)
returns (address ret)
{
if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
assembly {
ret := shr(96, calldataload(sub(calldatasize(), 20)))
}
} else {
ret = msg.sender;
}
}
/// @inheritdoc IERC2771Recipient
function _msgData()
internal
view
virtual
override(Context, IERC2771Recipient)
returns (bytes calldata ret)
{
if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
return msg.data[0:msg.data.length - 20];
} else {
return msg.data;
}
}
}// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/utils/Strings.sol";
import {IGameRegistry} from "./IGameRegistry.sol";
import {CounterComponent, Layout as CounterLayout, ID as COUNTER_COMPONENT_ID} from "../generated/components/CounterComponent.sol";
import {GuidCounterComponent, ID as GUID_COUNTER_COMPONENT_ID} from "../generated/components/GuidCounterComponent.sol";
string constant GUID_PREFIX = "game.piratenation.guid.";
/// @notice Error thrown when the counter is too large to fit in 144 bits
error CounterOverflow(uint256 counter);
/// @notice Error thrown when the chain ID is too large to fit in 32 bits
error ChainIdOverflow(uint256 chainId);
/// @notice Error thrown when the prefix is too large to fit in 80 bits
error PrefixOverflow(uint256 prefix);
/**
* Common helper functions for dealing with GUIDS
*/
library GUIDLibrary {
/**
* @dev DEPRECATED: Increments the counter for a given key and returns a new GUID
* @dev WARNING: Does NOT generated cross-chain safe guids
* @param gameRegistry Address of the Counter component
* @param key A prefix to namespace the GUID and prevent collisions
*/
function guidV1(
IGameRegistry gameRegistry,
string memory key
) internal returns (uint256) {
string memory prefix = string.concat(GUID_PREFIX, key);
uint256 entity = uint256(keccak256(abi.encodePacked(prefix)));
CounterComponent counterComponent = CounterComponent(
gameRegistry.getComponent(COUNTER_COMPONENT_ID)
);
// Increment counter
uint256 ct = counterComponent.getValue(entity) + 1;
counterComponent.setValue(entity, ct);
// Return new guid
return
uint256(
keccak256(
abi.encodePacked(
string.concat(prefix, ".", Strings.toString(ct))
)
)
);
}
/**
* Increments the counter for a given prefix and returns a new multi-chain safe GUID
* @param gameRegistry Address of the GuidCounter component
* @param prefix A prefix to namespace the GUID and prevent collisions
*/
function guid(
IGameRegistry gameRegistry,
uint80 prefix
) internal returns (uint256) {
GuidCounterComponent counter = GuidCounterComponent(
gameRegistry.getComponent(GUID_COUNTER_COMPONENT_ID)
);
// Increment guid counter
uint256 count = counter.getValue(prefix) + 1;
counter.setValue(prefix, count);
return packGuid(prefix, count);
}
/**
* Packs prefix and counter into a multi-chain safe GUID
* @param prefix A prefix to namespace the GUID and prevent collisions
* @param counter A counter to increment the GUID
*/
function packGuid(
uint80 prefix,
uint256 counter
) internal view returns (uint256) {
if (block.chainid > type(uint32).max) {
revert ChainIdOverflow(block.chainid);
}
if (prefix > type(uint80).max) {
revert PrefixOverflow(prefix);
}
if (counter > type(uint144).max) {
revert CounterOverflow(counter);
}
// Pack into a uint256:
// - Chain ID in the highest 32 bits
// - Prefix in the next 80 bits (10 characters)
// - Counter in the lowest 144 bits
return
(uint256(block.chainid) << 224) |
(uint256(prefix) << 144) |
counter;
}
}// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
// @title Interface the game's ACL / Management Layer
interface IGameRegistry is IERC165 {
/**
* @dev Returns `true` if `account` has been granted `role`.
* @param role The role to query
* @param account The address to query
*/
function hasAccessRole(
bytes32 role,
address account
) external view returns (bool);
/**
* @return Whether or not the registry is paused
*/
function paused() external view returns (bool);
/**
* Registers a system by id
*
* @param systemId Id of the system
* @param systemAddress Address of the system contract
*/
function registerSystem(uint256 systemId, address systemAddress) external;
/**
* @param systemId Id of the system
* @return System based on an id
*/
function getSystem(uint256 systemId) external view returns (address);
/**
* Registers a component using an id and contract address
* @param componentId Id of the component to register
* @param componentAddress Address of the component contract
*/
function registerComponent(
uint256 componentId,
address componentAddress
) external;
/**
* @param componentId Id of the component
* @return A component's contract address given its ID
*/
function getComponent(uint256 componentId) external view returns (address);
/**
* @param componentAddr Address of the component contract
* @return A component's id given its contract address
*/
function getComponentIdFromAddress(
address componentAddr
) external view returns (uint256);
/**
* @param entity Entity to check
* @param componentId Component to check
* @return Boolean indicating if entity belongs to component
*/
function getEntityHasComponent(
uint256 entity,
uint256 componentId
) external view returns (bool);
/**
* @return Boolean array indicating if entity belongs to component
* @param entities Entities to check
* @param componentIds Components to check
*/
function batchGetEntitiesHasComponents(
uint256[] calldata entities,
uint256[] calldata componentIds
) external view returns (bool[] memory);
/**
* Sets multiple component values at once
* @param entities Entities to set values for
* @param componentIds Component to set value on
* @param values Values to set
*/
function batchSetComponentValue(
uint256[] calldata entities,
uint256[] calldata componentIds,
bytes[] calldata values
) external;
/**
* Sets multiple component values at once and emits a publish event (for cross-chain)
* @param entities Entities to set values for
* @param componentIds Component to set value on
* @param values Values to set
*/
function batchPublishSetComponentValue(
uint256[] calldata entities,
uint256[] calldata componentIds,
bytes[] calldata values
) external returns (uint256 requestId);
/**
* @param componentId Id of the component
* @return Entire array of components belonging an entity
*
* 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 getEntityComponents(
uint256 componentId
) external view returns (uint256[] memory);
/**
* @param componentId Id of the component
* @return Number of components belonging to an entity
*/
function getEntityComponentCount(
uint256 componentId
) external view returns (uint256);
/**
* Gets multiple component values at once
* @param entities Entities to get values for
* @param componentIds Component to get value from
*/
function batchGetComponentValues(
uint256[] calldata entities,
uint256[] calldata componentIds
) external view returns (bytes[] memory values);
/**
* Register a component value update.
* Emits the `ComponentValueSet` event for clients to reconstruct the state.
* @param entity Entity to update
* @param data Data to update
*/
function registerComponentValueSet(
uint256 entity,
bytes calldata data
) external;
/**
* Emit a component value update across chains.
* Emits the `PublishComponentValueSet` event for cross-chain clients to reconstruct the state.
* @param entity Entity to update
* @param data Data to update
*/
function publishComponentValueSet(
uint256 componentId,
uint256 entity,
bytes calldata data
) external returns (uint256);
/**
* Register a component batch value update.
* Emits the `ComponentBatchValueSet` event for clients to reconstruct the state.
* @param entities Entities to update
* @param data Data to update
*/
function batchRegisterComponentValueSet(
uint256[] calldata entities,
bytes[] calldata data
) external;
/**
* Emit a component batch value update across chains.
* Emits the `PublishComponentBatchValueSet` event for cross-chain clients to reconstruct the state.
* @param entities Entities to update
* @param data Data to update
*/
function batchPublishComponentValueSet(
uint256 componentId,
uint256[] calldata entities,
bytes[] calldata data
) external returns (uint256);
/**
* Register a component value removal.
* Emits the `ComponentValueRemoved` event for clients to reconstruct the state.
*/
function registerComponentValueRemoved(uint256 entity) external;
/**
* Emit a component value removal across chains.
* Emits the `PublishComponentValueRemoved` event for cross-chain clients to reconstruct the state.
*/
// TODO: Reenable when we're ready to support cross-chain removal
// function publishComponentValueRemoved(
// uint256 componentId,
// uint256 entity
// ) external returns (uint256);
/**
* Register a component batch value removal.
* Emits the `ComponentBatchValueRemoved` event for clients to reconstruct the state.
* @param entities Entities to update
*/
function batchRegisterComponentValueRemoved(
uint256[] calldata entities
) external;
/**
* Emit a component batch value removal across chains.
* Emits the `PublishComponentBatchValueRemoved` event for cross-chain clients to reconstruct the state.
* @param entities Entities to update
*/
// TODO: Reenable when we're ready to support cross-chain removal
// function batchPublishComponentValueRemoved(
// uint256 componentId,
// uint256[] calldata entities
// ) external returns (uint256);
/**
* DEPRECATED: Generate a new general-purpose entity GUID
*/
function generateGUIDDeprecated() external returns (uint256);
/**
*
* @param operatorAddress Address of the Operator account
* @return Authorized Player account for an address
*/
function getPlayerAccount(
address operatorAddress
) external view returns (address);
/**
* @notice Sends a transfer to another chain in the multichain
* @param systemId Id of the 1155 System (Must implement IMultichain1155)
* @param from From address of the user sending the token
* @param to To address of the user receiving the token
* @param toChainId Chain ID of the receiving chain
* @param id Array of token IDs to send
* @param amount Array of token amounts to send
*/
function sendMultichain1155TransferSingle(
uint256 systemId,
address from,
address to,
uint256 toChainId,
uint256 id,
uint256 amount
) external;
/**
* @notice Sends a transfer to another chain in the multichain
* @param systemId Id of the 1155 System (Must implement IMultichain1155)
* @param from From address of the user sending the token
* @param to To address of the user receiving the token
* @param toChainId Chain ID of the receiving chain
* @param ids Array of token IDs to send
* @param amounts Array of token amounts to send
*/
function sendMultichain1155TransferBatch(
uint256 systemId,
address from,
address to,
uint256 toChainId,
uint256[] calldata ids,
uint256[] calldata amounts
) external;
/**
* @notice Sends a transfer to another chain in the multichain
* @param systemId Id of the 1155 System (Must implement Multichain721)
* @param from From address of the user sending the token
* @param to To address of the user receiving the token
* @param tokenId the tokenId being transferred
* @param toChainId Chain ID of the receiving chain
*/
function sendMultichain721Transfer(
uint256 systemId,
address from,
address to,
uint256 tokenId,
uint256 toChainId
) external;
}// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* Defines a system the game engine
*/
interface ISystem {
/** @return The ID for the system. Ex: a uint256 casted keccak256 hash */
function getId() external view returns (uint256);
}// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.9;
/**
* Enum of supported schema types
* Note: This is pulled directly from MUD (mud.dev) to maintain compatibility
*/
library TypesLibrary {
enum SchemaValue {
BOOL,
INT8,
INT16,
INT32,
INT64,
INT128,
INT256,
INT,
UINT8,
UINT16,
UINT32,
UINT64,
UINT128,
UINT256,
BYTES,
STRING,
ADDRESS,
BYTES4,
BOOL_ARRAY,
INT8_ARRAY,
INT16_ARRAY,
INT32_ARRAY,
INT64_ARRAY,
INT128_ARRAY,
INT256_ARRAY,
INT_ARRAY,
UINT8_ARRAY,
UINT16_ARRAY,
UINT32_ARRAY,
UINT64_ARRAY,
UINT128_ARRAY,
UINT256_ARRAY,
BYTES_ARRAY,
STRING_ARRAY,
ADDRESS_ARRAY
}
}// SPDX-License-Identifier: MIT
// Auto-generated using Mage CLI codegen (v1) - DO NOT EDIT
pragma solidity ^0.8.13;
import {TypesLibrary} from "../../core/TypesLibrary.sol";
import {BaseStorageComponentV2, IBaseStorageComponentV2} from "../../core/components/BaseStorageComponentV2.sol";
import {GAME_LOGIC_CONTRACT_ROLE} from "../../Constants.sol";
uint256 constant ID = uint256(keccak256("core.mage.archivedcomponent.v1"));
struct Layout {
bool value;
}
library ArchivedComponentStorage {
bytes32 internal constant STORAGE_SLOT = bytes32(ID);
// Declare struct for mapping entity to struct
struct InternalLayout {
mapping(uint256 => Layout) entityIdToStruct;
}
function layout() internal pure returns (InternalLayout storage dataStruct) {
bytes32 position = STORAGE_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
dataStruct.slot := position
}
}
}
/**
* @title ArchivedComponent
* @dev maps entity id → boolean if an entity is archived or not
*/
contract ArchivedComponent is BaseStorageComponentV2 {
/** SETUP **/
/** Sets the GameRegistry contract address for this contract */
constructor(
address gameRegistryAddress
) BaseStorageComponentV2(gameRegistryAddress, ID) {
// Do nothing
}
/**
* @inheritdoc IBaseStorageComponentV2
*/
function getSchema()
public
pure
override
returns (string[] memory keys, TypesLibrary.SchemaValue[] memory values)
{
keys = new string[](1);
values = new TypesLibrary.SchemaValue[](1);
// Whether the entity is archived or not
keys[0] = "value";
values[0] = TypesLibrary.SchemaValue.BOOL;
}
/**
* Sets the typed value for this component
*
* @param entity Entity to get value for
* @param value Layout to set for the given entity
*/
function setLayoutValue(
uint256 entity,
Layout calldata value
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
_setValue(entity, value);
}
/**
* Sets the native value for this component
*
* @param entity Entity to get value for
* @param value Whether the entity is archived or not
*/
function setValue(
uint256 entity,
bool value
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
_setValue(entity, Layout(value));
}
/**
* Batch sets the typed value for this component
*
* @param entities Entity to batch set values for
* @param values Layout to set for the given entities
*/
function batchSetValue(
uint256[] calldata entities,
Layout[] calldata values
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (entities.length != values.length) {
revert InvalidBatchData(entities.length, values.length);
}
// Set the values in storage
bytes[] memory encodedValues = new bytes[](entities.length);
for (uint256 i = 0; i < entities.length; i++) {
_setValueToStorage(entities[i], values[i]);
encodedValues[i] = _getEncodedValues(values[i]);
}
// ABI Encode all native types of the struct
_emitBatchSetBytes(entities, encodedValues);
}
/**
* Returns the typed value for this component
*
* @param entity Entity to get value for
* @return value Layout value for the given entity
*/
function getLayoutValue(
uint256 entity
) external view virtual returns (Layout memory value) {
// Get the struct from storage
value = ArchivedComponentStorage.layout().entityIdToStruct[entity];
}
/**
* Returns the native values for this component
*
* @param entity Entity to get value for
* @return value Whether the entity is archived or not
*/
function getValue(
uint256 entity
)
external
view
virtual
returns (
bool value
)
{
if (has(entity)) {
Layout memory s = ArchivedComponentStorage.layout().entityIdToStruct[entity];
(value) = abi.decode(
_getEncodedValues(s),
(bool)
);
}
}
/**
* Returns an array of byte values for each field of this component.
*
* @param entity Entity to build array of byte values for.
*/
function getByteValues(
uint256 entity
) external view virtual returns (bytes[] memory values) {
// Get the struct from storage
Layout storage s = ArchivedComponentStorage
.layout()
.entityIdToStruct[entity];
// ABI Encode all fields of the struct and add to values array
values = new bytes[](1);
values[0] = abi.encode(s.value);
}
/**
* Returns the bytes value for this component
*
* @param entity Entity to get value for
*/
function getBytes(
uint256 entity
) external view returns (bytes memory value) {
Layout memory s = ArchivedComponentStorage.layout().entityIdToStruct[entity];
value = _getEncodedValues(s);
}
/**
* Sets the value of this component using a byte array
*
* @param entity Entity to set value for
*/
function setBytes(
uint256 entity,
bytes calldata value
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
Layout memory s = ArchivedComponentStorage.layout().entityIdToStruct[entity];
(s.value) = abi.decode(value, (bool));
_setValueToStorage(entity, s);
// ABI Encode all native types of the struct
_emitSetBytes(
entity,
value
);
}
/**
* Sets bytes data in batch format
*
* @param entities Entities to set value for
* @param values Bytes values to set for the given entities
*/
function batchSetBytes(
uint256[] calldata entities,
bytes[] calldata values
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (entities.length != values.length) {
revert InvalidBatchData(entities.length, values.length);
}
for (uint256 i = 0; i < entities.length; i++) {
Layout memory s = ArchivedComponentStorage.layout().entityIdToStruct[entities[i]];
(s.value) = abi.decode(values[i], (bool));
_setValueToStorage(entities[i], s);
}
// ABI Encode all native types of the struct
_emitBatchSetBytes(
entities,
values
);
}
/**
* Remove the given entity from this component.
*
* @param entity Entity to remove from this component.
*/
function remove(uint256 entity) public virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
// Remove the entity from the component
delete ArchivedComponentStorage.layout().entityIdToStruct[entity];
_emitRemoveBytes(entity);
}
/**
* Batch remove the given entities from this component.
*
* @param entities Entities to remove from this component.
*/
function batchRemove(uint256[] calldata entities) public virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
// Remove the entities from the component
for (uint256 i = 0; i < entities.length; i++) {
delete ArchivedComponentStorage.layout().entityIdToStruct[
entities[i]
];
}
_emitBatchRemoveBytes(entities);
}
/**
* Check whether the given entity has a value in this component.
*
* @param entity Entity to check whether it has a value in this component for.
*/
function has(uint256 entity) public view virtual returns (bool) {
return gameRegistry.getEntityHasComponent(entity, ID);
}
/** INTERNAL **/
function _setValueToStorage(
uint256 entity,
Layout memory value
) internal {
Layout storage s = ArchivedComponentStorage
.layout()
.entityIdToStruct[entity];
s.value = value.value;
}
function _setValue(
uint256 entity,
Layout memory value
) internal {
_setValueToStorage(entity, value);
// ABI Encode all native types of the struct
_emitSetBytes(
entity,
abi.encode(value.value)
);
}
function _getEncodedValues(
Layout memory value
) internal pure returns (bytes memory) {
return
abi.encode(
value.value
);
}
}// SPDX-License-Identifier: MIT
// Auto-generated using Mage CLI codegen (v1) - DO NOT EDIT
pragma solidity ^0.8.13;
import {TypesLibrary} from "../../core/TypesLibrary.sol";
import {BaseStorageComponentV2, IBaseStorageComponentV2} from "../../core/components/BaseStorageComponentV2.sol";
import {GAME_LOGIC_CONTRACT_ROLE} from "../../Constants.sol";
uint256 constant ID = uint256(keccak256("core.mage.chainidcomponent.v1"));
struct Layout {
uint256 value;
}
library ChainIdComponentStorage {
bytes32 internal constant STORAGE_SLOT = bytes32(ID);
// Declare struct for mapping entity to struct
struct InternalLayout {
mapping(uint256 => Layout) entityIdToStruct;
}
function layout() internal pure returns (InternalLayout storage dataStruct) {
bytes32 position = STORAGE_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
dataStruct.slot := position
}
}
}
/**
* @title ChainIdComponent
* @dev This component stores the chain ID for an entity
*/
contract ChainIdComponent is BaseStorageComponentV2 {
/** SETUP **/
/** Sets the GameRegistry contract address for this contract */
constructor(
address gameRegistryAddress
) BaseStorageComponentV2(gameRegistryAddress, ID) {
// Do nothing
}
/**
* @inheritdoc IBaseStorageComponentV2
*/
function getSchema()
public
pure
override
returns (string[] memory keys, TypesLibrary.SchemaValue[] memory values)
{
keys = new string[](1);
values = new TypesLibrary.SchemaValue[](1);
// The home chain ID for entity
keys[0] = "value";
values[0] = TypesLibrary.SchemaValue.UINT256;
}
/**
* Sets the typed value for this component
*
* @param entity Entity to get value for
* @param value Layout to set for the given entity
*/
function setLayoutValue(
uint256 entity,
Layout calldata value
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
_setValue(entity, value);
}
/**
* Sets the native value for this component
*
* @param entity Entity to get value for
* @param value The home chain ID for entity
*/
function setValue(
uint256 entity,
uint256 value
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
_setValue(entity, Layout(value));
}
/**
* Batch sets the typed value for this component
*
* @param entities Entity to batch set values for
* @param values Layout to set for the given entities
*/
function batchSetValue(
uint256[] calldata entities,
Layout[] calldata values
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (entities.length != values.length) {
revert InvalidBatchData(entities.length, values.length);
}
// Set the values in storage
bytes[] memory encodedValues = new bytes[](entities.length);
for (uint256 i = 0; i < entities.length; i++) {
_setValueToStorage(entities[i], values[i]);
encodedValues[i] = _getEncodedValues(values[i]);
}
// ABI Encode all native types of the struct
_emitBatchSetBytes(entities, encodedValues);
}
/**
* Returns the typed value for this component
*
* @param entity Entity to get value for
* @return value Layout value for the given entity
*/
function getLayoutValue(
uint256 entity
) external view virtual returns (Layout memory value) {
// Get the struct from storage
value = ChainIdComponentStorage.layout().entityIdToStruct[entity];
}
/**
* Returns the native values for this component
*
* @param entity Entity to get value for
* @return value The home chain ID for entity
*/
function getValue(
uint256 entity
)
external
view
virtual
returns (
uint256 value
)
{
if (has(entity)) {
Layout memory s = ChainIdComponentStorage.layout().entityIdToStruct[entity];
(value) = abi.decode(
_getEncodedValues(s),
(uint256)
);
}
}
/**
* Returns an array of byte values for each field of this component.
*
* @param entity Entity to build array of byte values for.
*/
function getByteValues(
uint256 entity
) external view virtual returns (bytes[] memory values) {
// Get the struct from storage
Layout storage s = ChainIdComponentStorage
.layout()
.entityIdToStruct[entity];
// ABI Encode all fields of the struct and add to values array
values = new bytes[](1);
values[0] = abi.encode(s.value);
}
/**
* Returns the bytes value for this component
*
* @param entity Entity to get value for
*/
function getBytes(
uint256 entity
) external view returns (bytes memory value) {
Layout memory s = ChainIdComponentStorage.layout().entityIdToStruct[entity];
value = _getEncodedValues(s);
}
/**
* Sets the value of this component using a byte array
*
* @param entity Entity to set value for
*/
function setBytes(
uint256 entity,
bytes calldata value
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
Layout memory s = ChainIdComponentStorage.layout().entityIdToStruct[entity];
(s.value) = abi.decode(value, (uint256));
_setValueToStorage(entity, s);
// ABI Encode all native types of the struct
_emitSetBytes(
entity,
value
);
}
/**
* Sets bytes data in batch format
*
* @param entities Entities to set value for
* @param values Bytes values to set for the given entities
*/
function batchSetBytes(
uint256[] calldata entities,
bytes[] calldata values
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (entities.length != values.length) {
revert InvalidBatchData(entities.length, values.length);
}
for (uint256 i = 0; i < entities.length; i++) {
Layout memory s = ChainIdComponentStorage.layout().entityIdToStruct[entities[i]];
(s.value) = abi.decode(values[i], (uint256));
_setValueToStorage(entities[i], s);
}
// ABI Encode all native types of the struct
_emitBatchSetBytes(
entities,
values
);
}
/**
* Remove the given entity from this component.
*
* @param entity Entity to remove from this component.
*/
function remove(uint256 entity) public virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
// Remove the entity from the component
delete ChainIdComponentStorage.layout().entityIdToStruct[entity];
_emitRemoveBytes(entity);
}
/**
* Batch remove the given entities from this component.
*
* @param entities Entities to remove from this component.
*/
function batchRemove(uint256[] calldata entities) public virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
// Remove the entities from the component
for (uint256 i = 0; i < entities.length; i++) {
delete ChainIdComponentStorage.layout().entityIdToStruct[
entities[i]
];
}
_emitBatchRemoveBytes(entities);
}
/**
* Check whether the given entity has a value in this component.
*
* @param entity Entity to check whether it has a value in this component for.
*/
function has(uint256 entity) public view virtual returns (bool) {
return gameRegistry.getEntityHasComponent(entity, ID);
}
/** INTERNAL **/
function _setValueToStorage(
uint256 entity,
Layout memory value
) internal {
Layout storage s = ChainIdComponentStorage
.layout()
.entityIdToStruct[entity];
s.value = value.value;
}
function _setValue(
uint256 entity,
Layout memory value
) internal {
_setValueToStorage(entity, value);
// ABI Encode all native types of the struct
_emitSetBytes(
entity,
abi.encode(value.value)
);
}
function _getEncodedValues(
Layout memory value
) internal pure returns (bytes memory) {
return
abi.encode(
value.value
);
}
}// SPDX-License-Identifier: MIT
// Auto-generated using Mage CLI codegen (v1) - DO NOT EDIT
pragma solidity ^0.8.13;
import {TypesLibrary} from "../../core/TypesLibrary.sol";
import {BaseStorageComponentV2, IBaseStorageComponentV2} from "../../core/components/BaseStorageComponentV2.sol";
import {GAME_LOGIC_CONTRACT_ROLE} from "../../Constants.sol";
uint256 constant ID = uint256(keccak256("core.mage.countercomponent.v1"));
struct Layout {
uint256 counts;
}
library CounterComponentStorage {
bytes32 internal constant STORAGE_SLOT = bytes32(ID);
// Declare struct for mapping entity to struct
struct InternalLayout {
mapping(uint256 => Layout) entityIdToStruct;
}
function layout() internal pure returns (InternalLayout storage dataStruct) {
bytes32 position = STORAGE_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
dataStruct.slot := position
}
}
}
/**
* @title CounterComponent
* @dev A generic uneditable counter
*/
contract CounterComponent is BaseStorageComponentV2 {
/** SETUP **/
/** Sets the GameRegistry contract address for this contract */
constructor(
address gameRegistryAddress
) BaseStorageComponentV2(gameRegistryAddress, ID) {
// Do nothing
}
/**
* @inheritdoc IBaseStorageComponentV2
*/
function getSchema()
public
pure
override
returns (string[] memory keys, TypesLibrary.SchemaValue[] memory values)
{
keys = new string[](1);
values = new TypesLibrary.SchemaValue[](1);
// Counter tracking total counts
keys[0] = "counts";
values[0] = TypesLibrary.SchemaValue.UINT256;
}
/**
* Sets the typed value for this component
*
* @param entity Entity to get value for
* @param value Layout to set for the given entity
*/
function setLayoutValue(
uint256 entity,
Layout calldata value
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
_setValue(entity, value);
}
/**
* Sets the native value for this component
*
* @param entity Entity to get value for
* @param counts Counter tracking total counts
*/
function setValue(
uint256 entity,
uint256 counts
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
_setValue(entity, Layout(counts));
}
/**
* Batch sets the typed value for this component
*
* @param entities Entity to batch set values for
* @param values Layout to set for the given entities
*/
function batchSetValue(
uint256[] calldata entities,
Layout[] calldata values
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (entities.length != values.length) {
revert InvalidBatchData(entities.length, values.length);
}
// Set the values in storage
bytes[] memory encodedValues = new bytes[](entities.length);
for (uint256 i = 0; i < entities.length; i++) {
_setValueToStorage(entities[i], values[i]);
encodedValues[i] = _getEncodedValues(values[i]);
}
// ABI Encode all native types of the struct
_emitBatchSetBytes(entities, encodedValues);
}
/**
* Returns the typed value for this component
*
* @param entity Entity to get value for
* @return value Layout value for the given entity
*/
function getLayoutValue(
uint256 entity
) external view virtual returns (Layout memory value) {
// Get the struct from storage
value = CounterComponentStorage.layout().entityIdToStruct[entity];
}
/**
* Returns the native values for this component
*
* @param entity Entity to get value for
* @return counts Counter tracking total counts
*/
function getValue(
uint256 entity
)
external
view
virtual
returns (
uint256 counts
)
{
if (has(entity)) {
Layout memory s = CounterComponentStorage.layout().entityIdToStruct[entity];
(counts) = abi.decode(
_getEncodedValues(s),
(uint256)
);
}
}
/**
* Returns an array of byte values for each field of this component.
*
* @param entity Entity to build array of byte values for.
*/
function getByteValues(
uint256 entity
) external view virtual returns (bytes[] memory values) {
// Get the struct from storage
Layout storage s = CounterComponentStorage
.layout()
.entityIdToStruct[entity];
// ABI Encode all fields of the struct and add to values array
values = new bytes[](1);
values[0] = abi.encode(s.counts);
}
/**
* Returns the bytes value for this component
*
* @param entity Entity to get value for
*/
function getBytes(
uint256 entity
) external view returns (bytes memory value) {
Layout memory s = CounterComponentStorage.layout().entityIdToStruct[entity];
value = _getEncodedValues(s);
}
/**
* Sets the value of this component using a byte array
*
* @param entity Entity to set value for
*/
function setBytes(
uint256 entity,
bytes calldata value
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
Layout memory s = CounterComponentStorage.layout().entityIdToStruct[entity];
(s.counts) = abi.decode(value, (uint256));
_setValueToStorage(entity, s);
// ABI Encode all native types of the struct
_emitSetBytes(
entity,
value
);
}
/**
* Sets bytes data in batch format
*
* @param entities Entities to set value for
* @param values Bytes values to set for the given entities
*/
function batchSetBytes(
uint256[] calldata entities,
bytes[] calldata values
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (entities.length != values.length) {
revert InvalidBatchData(entities.length, values.length);
}
for (uint256 i = 0; i < entities.length; i++) {
Layout memory s = CounterComponentStorage.layout().entityIdToStruct[entities[i]];
(s.counts) = abi.decode(values[i], (uint256));
_setValueToStorage(entities[i], s);
}
// ABI Encode all native types of the struct
_emitBatchSetBytes(
entities,
values
);
}
/**
* Remove the given entity from this component.
*
* @param entity Entity to remove from this component.
*/
function remove(uint256 entity) public virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
// Remove the entity from the component
delete CounterComponentStorage.layout().entityIdToStruct[entity];
_emitRemoveBytes(entity);
}
/**
* Batch remove the given entities from this component.
*
* @param entities Entities to remove from this component.
*/
function batchRemove(uint256[] calldata entities) public virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
// Remove the entities from the component
for (uint256 i = 0; i < entities.length; i++) {
delete CounterComponentStorage.layout().entityIdToStruct[
entities[i]
];
}
_emitBatchRemoveBytes(entities);
}
/**
* Check whether the given entity has a value in this component.
*
* @param entity Entity to check whether it has a value in this component for.
*/
function has(uint256 entity) public view virtual returns (bool) {
return gameRegistry.getEntityHasComponent(entity, ID);
}
/** INTERNAL **/
function _setValueToStorage(
uint256 entity,
Layout memory value
) internal {
Layout storage s = CounterComponentStorage
.layout()
.entityIdToStruct[entity];
s.counts = value.counts;
}
function _setValue(
uint256 entity,
Layout memory value
) internal {
_setValueToStorage(entity, value);
// ABI Encode all native types of the struct
_emitSetBytes(
entity,
abi.encode(value.counts)
);
}
function _getEncodedValues(
Layout memory value
) internal pure returns (bytes memory) {
return
abi.encode(
value.counts
);
}
}// SPDX-License-Identifier: MIT
// Auto-generated using Mage CLI codegen (v1) - DO NOT EDIT
pragma solidity ^0.8.13;
import {TypesLibrary} from "../../core/TypesLibrary.sol";
import {BaseStorageComponentV2, IBaseStorageComponentV2} from "../../core/components/BaseStorageComponentV2.sol";
import {GAME_LOGIC_CONTRACT_ROLE} from "../../Constants.sol";
uint256 constant ID = uint256(keccak256("core.mage.guidcountercomponent.v1"));
struct Layout {
uint256 value;
}
library GuidCounterComponentStorage {
bytes32 internal constant STORAGE_SLOT = bytes32(ID);
// Declare struct for mapping entity to struct
struct InternalLayout {
mapping(uint256 => Layout) entityIdToStruct;
}
function layout() internal pure returns (InternalLayout storage dataStruct) {
bytes32 position = STORAGE_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
dataStruct.slot := position
}
}
}
/**
* @title GuidCounterComponent
* @dev An uneditable counter specifically for universal guids
*/
contract GuidCounterComponent is BaseStorageComponentV2 {
/** SETUP **/
/** Sets the GameRegistry contract address for this contract */
constructor(
address gameRegistryAddress
) BaseStorageComponentV2(gameRegistryAddress, ID) {
// Do nothing
}
/**
* @inheritdoc IBaseStorageComponentV2
*/
function getSchema()
public
pure
override
returns (string[] memory keys, TypesLibrary.SchemaValue[] memory values)
{
keys = new string[](1);
values = new TypesLibrary.SchemaValue[](1);
// Counter tracking total counts
keys[0] = "value";
values[0] = TypesLibrary.SchemaValue.UINT256;
}
/**
* Sets the typed value for this component
*
* @param entity Entity to get value for
* @param value Layout to set for the given entity
*/
function setLayoutValue(
uint256 entity,
Layout calldata value
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
_setValue(entity, value);
}
/**
* Sets the native value for this component
*
* @param entity Entity to get value for
* @param value Counter tracking total counts
*/
function setValue(
uint256 entity,
uint256 value
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
_setValue(entity, Layout(value));
}
/**
* Batch sets the typed value for this component
*
* @param entities Entity to batch set values for
* @param values Layout to set for the given entities
*/
function batchSetValue(
uint256[] calldata entities,
Layout[] calldata values
) external virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (entities.length != values.length) {
revert InvalidBatchData(entities.length, values.length);
}
// Set the values in storage
bytes[] memory encodedValues = new bytes[](entities.length);
for (uint256 i = 0; i < entities.length; i++) {
_setValueToStorage(entities[i], values[i]);
encodedValues[i] = _getEncodedValues(values[i]);
}
// ABI Encode all native types of the struct
_emitBatchSetBytes(entities, encodedValues);
}
/**
* Returns the typed value for this component
*
* @param entity Entity to get value for
* @return value Layout value for the given entity
*/
function getLayoutValue(
uint256 entity
) external view virtual returns (Layout memory value) {
// Get the struct from storage
value = GuidCounterComponentStorage.layout().entityIdToStruct[entity];
}
/**
* Returns the native values for this component
*
* @param entity Entity to get value for
* @return value Counter tracking total counts
*/
function getValue(
uint256 entity
)
external
view
virtual
returns (
uint256 value
)
{
if (has(entity)) {
Layout memory s = GuidCounterComponentStorage.layout().entityIdToStruct[entity];
(value) = abi.decode(
_getEncodedValues(s),
(uint256)
);
}
}
/**
* Returns an array of byte values for each field of this component.
*
* @param entity Entity to build array of byte values for.
*/
function getByteValues(
uint256 entity
) external view virtual returns (bytes[] memory values) {
// Get the struct from storage
Layout storage s = GuidCounterComponentStorage
.layout()
.entityIdToStruct[entity];
// ABI Encode all fields of the struct and add to values array
values = new bytes[](1);
values[0] = abi.encode(s.value);
}
/**
* Returns the bytes value for this component
*
* @param entity Entity to get value for
*/
function getBytes(
uint256 entity
) external view returns (bytes memory value) {
Layout memory s = GuidCounterComponentStorage.layout().entityIdToStruct[entity];
value = _getEncodedValues(s);
}
/**
* Sets the value of this component using a byte array
*
* @param entity Entity to set value for
*/
function setBytes(
uint256 entity,
bytes calldata value
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
Layout memory s = GuidCounterComponentStorage.layout().entityIdToStruct[entity];
(s.value) = abi.decode(value, (uint256));
_setValueToStorage(entity, s);
// ABI Encode all native types of the struct
_emitSetBytes(
entity,
value
);
}
/**
* Sets bytes data in batch format
*
* @param entities Entities to set value for
* @param values Bytes values to set for the given entities
*/
function batchSetBytes(
uint256[] calldata entities,
bytes[] calldata values
) external onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
if (entities.length != values.length) {
revert InvalidBatchData(entities.length, values.length);
}
for (uint256 i = 0; i < entities.length; i++) {
Layout memory s = GuidCounterComponentStorage.layout().entityIdToStruct[entities[i]];
(s.value) = abi.decode(values[i], (uint256));
_setValueToStorage(entities[i], s);
}
// ABI Encode all native types of the struct
_emitBatchSetBytes(
entities,
values
);
}
/**
* Remove the given entity from this component.
*
* @param entity Entity to remove from this component.
*/
function remove(uint256 entity) public virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
// Remove the entity from the component
delete GuidCounterComponentStorage.layout().entityIdToStruct[entity];
_emitRemoveBytes(entity);
}
/**
* Batch remove the given entities from this component.
*
* @param entities Entities to remove from this component.
*/
function batchRemove(uint256[] calldata entities) public virtual onlyRole(GAME_LOGIC_CONTRACT_ROLE) {
// Remove the entities from the component
for (uint256 i = 0; i < entities.length; i++) {
delete GuidCounterComponentStorage.layout().entityIdToStruct[
entities[i]
];
}
_emitBatchRemoveBytes(entities);
}
/**
* Check whether the given entity has a value in this component.
*
* @param entity Entity to check whether it has a value in this component for.
*/
function has(uint256 entity) public view virtual returns (bool) {
return gameRegistry.getEntityHasComponent(entity, ID);
}
/** INTERNAL **/
function _setValueToStorage(
uint256 entity,
Layout memory value
) internal {
Layout storage s = GuidCounterComponentStorage
.layout()
.entityIdToStruct[entity];
s.value = value.value;
}
function _setValue(
uint256 entity,
Layout memory value
) internal {
_setValueToStorage(entity, value);
// ABI Encode all native types of the struct
_emitSetBytes(
entity,
abi.encode(value.value)
);
}
function _getEncodedValues(
Layout memory value
) internal pure returns (bytes memory) {
return
abi.encode(
value.value
);
}
}// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.13;
interface IMultichain1155 {
/**
* A contract that implements this interface is capable of receiving Multichain1155 transfers
* This function should mint the item appropriately
* This will be called AFTER generic checks have been made such as
* - Validating to address is on this chain
* - Ensuring replay attacks are prevented
* @param to address of user recieving the item
* @param id ids of the items to mint
* @param amount amount of the items to mint
*/
function receivedMultichain1155TransferSingle(
address to,
uint256 id,
uint256 amount
) external;
/**
* A contract that implements this interface is capable of receiving Multichain1155 transfers
* This function should mint the item appropriately
* This will be called AFTER generic checks have been made such as
* - Validating to address is on this chain
* - Ensuring replay attacks are prevented
* @param to address of user recieving the item
* @param ids ids of the items to mint
* @param amounts amount of the items to mint
*/
function receivedMultichain1155TransferBatch(
address to,
uint256[] calldata ids,
uint256[] calldata amounts
) external;
}// SPDX-License-Identifier: MIT LICENSE
pragma solidity ^0.8.13;
interface IMultichain721 {
/**
* A contract that implements this interface is capable of receiving Multichain721 transfers
* This functiog the item
* @param tokenId id of the items to mintn should mint the item appropriately
* This will be called AFTER generic checks have been made such as
* - Validating to address is on this chain
* - Ensuring replay attacks are prevented
* @param to address of user recievin
*/
function receivedMultichain721Transfer(
address to,
uint256 tokenId
) external;
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"AlreadyProcessed","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"ChainIdOverflow","type":"error"},{"inputs":[{"internalType":"uint256","name":"componentId","type":"uint256"}],"name":"ComponentIdNotRegistered","type":"error"},{"inputs":[{"internalType":"address","name":"component","type":"address"}],"name":"ComponentNotRegistered","type":"error"},{"inputs":[{"internalType":"uint256","name":"counter","type":"uint256"}],"name":"CounterOverflow","type":"error"},{"inputs":[],"name":"GuidCounterSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"entityCount","type":"uint256"},{"internalType":"uint256","name":"dataCount","type":"uint256"}],"name":"InvalidBatchData","type":"error"},{"inputs":[],"name":"InvalidBlockNumber","type":"error"},{"inputs":[],"name":"InvalidCaller","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InvalidChain","type":"error"},{"inputs":[],"name":"InvalidDeregisterCaller","type":"error"},{"inputs":[],"name":"InvalidExpirationBlockNumber","type":"error"},{"inputs":[],"name":"InvalidExpirationTimestamp","type":"error"},{"inputs":[],"name":"InvalidOperatorAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"systemId","type":"uint256"}],"name":"InvalidSystem","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"expectedRole","type":"bytes32"}],"name":"MissingRole","type":"error"},{"inputs":[],"name":"OperatorAlreadyRegistered","type":"error"},{"inputs":[],"name":"OperatorExpired","type":"error"},{"inputs":[],"name":"OperatorNotRegistered","type":"error"},{"inputs":[{"internalType":"address","name":"expected","type":"address"},{"internalType":"address","name":"actual","type":"address"}],"name":"PlayerSignerMismatch","type":"error"},{"inputs":[{"internalType":"uint256","name":"prefix","type":"uint256"}],"name":"PrefixOverflow","type":"error"},{"inputs":[],"name":"RegisterOperatorInCooldown","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenIdExceedsMaxValue","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"componentId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"entities","type":"uint256[]"}],"name":"BatchComponentValueRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"componentId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"indexed":false,"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"BatchComponentValueSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"componentIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"entities","type":"uint256[]"}],"name":"BatchMultiComponentValueRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"componentIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"indexed":false,"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"BatchMultiComponentValueSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"componentId","type":"uint256"},{"indexed":true,"internalType":"address","name":"componentAddress","type":"address"}],"name":"ComponentRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"componentId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"entity","type":"uint256"}],"name":"ComponentValueRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"componentId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"entity","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"ComponentValueSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"systemId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromChainId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"Multichain1155TransferBatchReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"systemId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"toChainId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"Multichain1155TransferBatchSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"systemId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Multichain1155TransferSingleReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"systemId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"toChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Multichain1155TransferSingleSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"systemId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toChainId","type":"uint256"}],"name":"Multichain721TransferReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"systemId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toChainId","type":"uint256"}],"name":"Multichain721TransferSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"player","type":"address"}],"name":"OperatorDeregistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint256","name":"expiration","type":"uint256"}],"name":"OperatorRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"componentId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"requestTime","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"indexed":false,"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"PublishBatchComponentValueSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"componentIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"fromChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"requestTime","type":"uint256"},{"indexed":false,"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"PublishBatchSetComponentValue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"componentId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"entity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"requestTime","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"PublishComponentValueSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"systemAddress","type":"address"}],"name":"SystemRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_MESSAGE_BLOCK_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REGISTER_OPERATOR_COOLDOWN_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"internalType":"uint256[]","name":"componentIds","type":"uint256[]"}],"name":"batchGetComponentValues","outputs":[{"internalType":"bytes[]","name":"values","type":"bytes[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"internalType":"uint256[]","name":"componentIds","type":"uint256[]"}],"name":"batchGetEntitiesHasComponents","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"componentId","type":"uint256"},{"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"batchPublishComponentValueSet","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"internalType":"uint256[]","name":"componentIds","type":"uint256[]"},{"internalType":"bytes[]","name":"values","type":"bytes[]"}],"name":"batchPublishSetComponentValue","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"entities","type":"uint256[]"}],"name":"batchRegisterComponentValueRemoved","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"batchRegisterComponentValueSet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"internalType":"uint256[]","name":"componentIds","type":"uint256[]"},{"internalType":"bytes[]","name":"values","type":"bytes[]"}],"name":"batchSetComponentValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"systemId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"fromChainId","type":"uint256"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"deliverMultichain1155TransferBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"systemId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"fromChainId","type":"uint256"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deliverMultichain1155TransferSingle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"systemId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"fromChainId","type":"uint256"},{"components":[{"internalType":"uint256[]","name":"entities","type":"uint256[]"},{"internalType":"uint256[]","name":"componentIds","type":"uint256[]"},{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"internalType":"struct BatchComponentData","name":"componentData","type":"tuple"}],"name":"deliverMultichain721Transfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operatorToDeregister","type":"address"}],"name":"deregisterOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"operators","type":"address[]"}],"name":"deregisterOperatorBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"generateGUIDDeprecated","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"componentId","type":"uint256"}],"name":"getComponent","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"componentAddr","type":"address"}],"name":"getComponentIdFromAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"entity","type":"uint256"},{"internalType":"uint256","name":"componentId","type":"uint256"}],"name":"getComponentValue","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"entity","type":"uint256"}],"name":"getEntityComponentCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"entity","type":"uint256"}],"name":"getEntityComponents","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"entity","type":"uint256"},{"internalType":"uint256","name":"componentId","type":"uint256"}],"name":"getEntityHasComponent","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGuidCounter","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getOperatorAccountRegistrationMessageToSign","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"operatorAddress","type":"address"}],"name":"getPlayerAccount","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"}],"name":"getRegisteredOperators","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"systemId","type":"uint256"}],"name":"getSystem","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"entity","type":"uint256"}],"name":"getUnarchivedEntityComponents","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasAccessRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","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":"address","name":"","type":"address"}],"name":"lastRegisterOperatorTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"componentId","type":"uint256"},{"internalType":"uint256","name":"entity","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"publishComponentValueSet","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"componentId","type":"uint256"},{"internalType":"address","name":"componentAddress","type":"address"}],"name":"registerComponent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"entity","type":"uint256"}],"name":"registerComponentValueRemoved","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"entity","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"registerComponentValueSet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"address","name":"player","type":"address"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"registerOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"players","type":"address[]"},{"internalType":"address[]","name":"operators","type":"address[]"},{"internalType":"uint256[]","name":"expirations","type":"uint256[]"}],"name":"registerOperatorBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"systemId","type":"uint256"},{"internalType":"address","name":"systemAddress","type":"address"}],"name":"registerSystem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"requestIdProcessed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"systemId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"toChainId","type":"uint256"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"sendMultichain1155TransferBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"systemId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"toChainId","type":"uint256"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sendMultichain1155TransferSingle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"systemId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"toChainId","type":"uint256"}],"name":"sendMultichain721Transfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint96","name":"guidValue","type":"uint96"}],"name":"setGuidCounter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6080604052348015600f57600080fd5b506150068061001f6000396000f3fe608060405234801561001057600080fd5b506004361061035d5760003560e01c80635c8cd1da116101d3578063b69ec14f11610104578063d671c721116100a2578063e21592de1161007c578063e21592de146107d2578063e6ce49b0146107e5578063ee86385014610805578063f2fde38b1461081857600080fd5b8063d671c72114610799578063d8cf98ca146107ac578063e13e02ae146107bf57600080fd5b8063c4d66de8116100de578063c4d66de81461074d578063cf38bcec14610760578063cfd3c57f14610773578063d547741f1461078657600080fd5b8063b69ec14f14610707578063ba64197814610727578063c36dd7ea1461073a57600080fd5b80638b3d31901161017157806393f7cc991161014b57806393f7cc99146106af5780639f54f545146106c2578063a217fddf146106ec578063a55cce99146106f457600080fd5b80638b3d3190146106785780638da5cb5b1461068b57806391d148541461069c57600080fd5b80636e0e51d6116101ad5780636e0e51d614610637578063715018a61461064a57806384db946514610652578063868b4ea31461066557600080fd5b80635c8cd1da146106145780635c975abb146106275780635eb328e81461062f57600080fd5b80632e9e37da116102ad57806347c32fc91161024b5780634f27da18116102255780634f27da181461058f57806353e41c1e146105d0578063552b6cbd146105f9578063572b6c051461060157600080fd5b806347c32fc91461053c5780634b84859e1461055c5780634b9b233d1461056f57600080fd5b80633632e55d116102875780633632e55d146104e757806336568abe1461050357806338b34ce2146105165780633e2b47311461052957600080fd5b80632e9e37da146104a15780632f2ff15d146104b4578063306b8fdb146104c757600080fd5b80632078e59f1161031a57806323b73080116102f457806323b730801461043f578063248a9ca31461044757806328895a651461046a5780632a07379f1461047d57600080fd5b80632078e59f146103f8578063209e1d1f1461040b578063236856301461042c57600080fd5b806301ffc9a71461036257806307000fa31461038a5780630de3b7b51461039f5780631548a8de146103b257806316c38b3c146103d25780631aa49f0a146103e5575b600080fd5b610375610370366004613f17565b61082b565b60405190151581526020015b60405180910390f35b61039d610398366004613f5d565b610871565b005b61039d6103ad366004613fbe565b6109cb565b6103c56103c0366004613fd7565b610a4a565b6040516103819190614069565b61039d6103e036600461408a565b610ab2565b61039d6103f33660046140eb565b610b72565b61039d610406366004614192565b610c43565b61041e610419366004613fbe565b610fa3565b604051908152602001610381565b61039d61043a366004614235565b610fbb565b61041e607881565b61041e610455366004613fbe565b60009081526065602052604090206001015490565b61039d610478366004614276565b611081565b61037561048b366004613fbe565b6101046020526000908152604090205460ff1681565b61039d6104af366004614301565b6111c3565b61039d6104c2366004614301565b611247565b6104da6104d5366004613fbe565b611271565b604051610381919061432d565b610101546040516001600160601b039091168152602001610381565b61039d610511366004614301565b61141d565b61039d610524366004614370565b6114ab565b6104da610537366004613fbe565b6115fb565b61054f61054a366004614423565b611616565b6040516103819190614492565b61039d61056a366004614235565b611791565b61058261057d3660046144f7565b611925565b6040516103819190614512565b6105b861059d366004613fbe565b600090815260ff60205260409020546001600160a01b031690565b6040516001600160a01b039091168152602001610381565b6105b86105de366004613fbe565b600090815260fc60205260409020546001600160a01b031690565b61041e601e81565b61037561060f3660046144f7565b611949565b61039d610622366004614301565b611975565b610375611a77565b61041e611a8a565b61039d610645366004614423565b611af9565b61039d611bef565b61039d610660366004614553565b611c03565b61039d6106733660046145e2565b611cce565b61039d610686366004614658565b611fb4565b6097546001600160a01b03166105b8565b6103756106aa366004614301565b612087565b6105b86106bd3660046144f7565b6120b2565b61041e6106d03660046144f7565b6001600160a01b03166000908152610100602052604090205490565b61041e600081565b6103756107023660046146b0565b612161565b61071a610715366004614423565b61217a565b60405161038191906146d2565b61039d610735366004614192565b612257565b610375610748366004614301565b6122e6565b61039d61075b3660046144f7565b6122f2565b61041e61076e366004614192565b6125b9565b61039d61078136600461470c565b6126a4565b61039d610794366004614301565b612733565b61041e6107a7366004614757565b612758565b61039d6107ba3660046144f7565b6127fd565b61039d6107cd36600461479d565b612949565b6103c56107e03660046146b0565b6129be565b61041e6107f33660046144f7565b60fb6020526000908152604090205481565b61041e6108133660046147c6565b612a77565b61039d6108263660046144f7565b612b4a565b60006001600160e01b03198216630f8c34d960e21b148061085c57506001600160e01b031982166301ffc9a760e01b145b8061086b575061086b82612bc0565b92915050565b7f455d2a126e5e85ea9f46f822a38d5695336cd3a8180a3a74ea4601221f9ed98761089b81612bf5565b6108a485612c06565b6108ad88612cf5565b600087815260fc60205260409020546001600160a01b03166108ea5760405163393f13e760e01b8152600481018890526024015b60405180910390fd5b600087815260fc60205260409081902054905163a514d6ff60e01b81526001600160a01b038781166004830152602482018690526044820185905290911690819063a514d6ff90606401600060405180830381600087803b15801561094e57600080fd5b505af1158015610962573d6000803e3d6000fd5b5050604080518c815260208101899052908101879052606081018690526001600160a01b03808a1693508a1691508a907fbbc2c05b9ccfe02f6e3b80f1a5a22a06ad7f0f20c4ea818e9dae43b9240f0644906080015b60405180910390a4505050505050505050565b3360009081526101006020526040812054908190036109ff57604051632939675d60e01b81523360048201526024016108e1565b600082815261010260205260409020610a189082612d45565b50604051829082907f8989859870cc0d47cc5f8909459290e411f855f5535f7dbfaf1038cf40fccc0e90600090a35050565b6060610a60846001600160a01b03166014612d51565b610a74866001600160a01b03166014612d51565b610a7d85612eec565b610a8685612eec565b604051602001610a999493929190614843565b6040516020818303038152906040529050949350505050565b6097546001600160a01b0316610ac6612f7e565b6001600160a01b03161480610b025750610b027f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a6106aa612f7e565b15610b20578015610b1857610b15612fac565b50565b610b15613007565b610b28612f7e565b60405162b0d32560e11b81526001600160a01b0390911660048201527f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a60248201526044016108e1565b600080516020614fb1833981519152610b8a81612bf5565b6001600160a01b03871615610c38576000610ba3613042565b60008b815260fc60205260409020549091506001600160a01b03163314610be05760405163393f13e760e01b8152600481018b90526024016108e1565b876001600160a01b0316896001600160a01b03168b7fa2d715629f9034d65861900d057bee4ffbe715c0b061eca73a32225091eba73a848b8b8b8b8b604051610c2e9695949392919061498a565b60405180910390a4505b505050505050505050565b610c4b6131ab565b600080516020614f91833981519152610c6381612bf5565b8584141580610c725750858214155b15610c905760405163eb32d3bf60e01b815260040160405180910390fd5b60005b86811015610f9957878782818110610cad57610cad6149ca565b9050602002016020810190610cc291906144f7565b6001600160a01b0316868683818110610cdd57610cdd6149ca565b9050602002016020810190610cf291906144f7565b6001600160a01b03161480610d3657506000868683818110610d1657610d166149ca565b9050602002016020810190610d2b91906144f7565b6001600160a01b0316145b15610d545760405163eb32d3bf60e01b815260040160405180910390fd5b6040518060400160405280898984818110610d7157610d716149ca565b9050602002016020810190610d8691906144f7565b6001600160a01b03168152602001858584818110610da657610da66149ca565b9050602002013581525060fd6000888885818110610dc657610dc66149ca565b9050602002016020810190610ddb91906144f7565b6001600160a01b0390811682526020808301939093526040909101600020835181546001600160a01b0319169216919091178155910151600190910155610e8c868683818110610e2d57610e2d6149ca565b9050602002016020810190610e4291906144f7565b60fe60008b8b86818110610e5857610e586149ca565b9050602002016020810190610e6d91906144f7565b6001600160a01b031681526020810191909152604001600020906131f3565b504260fb60008a8a85818110610ea457610ea46149ca565b9050602002016020810190610eb991906144f7565b6001600160a01b031681526020810191909152604001600020557fdcb4af7d57cc106724f816a55242fbe9d45d800af6a574cb2814d7adf23e4940888883818110610f0657610f066149ca565b9050602002016020810190610f1b91906144f7565b878784818110610f2d57610f2d6149ca565b9050602002016020810190610f4291906144f7565b868685818110610f5457610f546149ca565b90506020020135604051610f89939291906001600160a01b039384168152919092166020820152604081019190915260600190565b60405180910390a1600101610c93565b5050505050505050565b60008181526101026020526040812061086b90613208565b336000908152610100602052604081205490819003610fef57604051632939675d60e01b81523360048201526024016108e1565b60005b8281101561104157611038826101026000878786818110611015576110156149ca565b905060200201358152602001908152602001600020612d4590919063ffffffff16565b50600101610ff2565b50807fe25d213f62bc7c4e937e89492babb3d2720fa992806de157203dfbf8e631a04284846040516110749291906149e0565b60405180910390a2505050565b7f455d2a126e5e85ea9f46f822a38d5695336cd3a8180a3a74ea4601221f9ed9876110ab81612bf5565b6110b485612c06565b6110bd88612cf5565b600087815260fc60205260409020546001600160a01b03166110f55760405163393f13e760e01b8152600481018890526024016108e1565b600087815260fc6020526040908190205490516331ff46bd60e11b81526001600160a01b038781166004830152602482018790529091169081906363fe8d7a90604401600060405180830381600087803b15801561115257600080fd5b505af1158015611166573d6000803e3d6000fd5b5050505061117383613212565b604080518a8152602081018790529081018590526001600160a01b0380881691908916908a907fb316fa5abbed8c6419c8559a4ee6369b7ec8fff26ea1d1c3d54ec5efedd1225a906060016109b8565b7ffc425f2263d0df187444b70e47283d622c70181c5baebb1306a01edba1ce184c6111ed81612bf5565b600083815260fc602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051909185917f4ad49251ddae0b218995a7fd001ab79155bdbb25933c94a417e2d67103cfe3499190a3505050565b60008281526065602052604090206001015461126281612bf5565b61126c838361323e565b505050565b6000818152610102602052604081206060919061128d906132c5565b7f6f6904abf86d9d6d5114fd2ba5c3020cff3fb91d7ec4594f71ef6b5ff6bb3e49600090815260ff6020527f5f23ddf214f07432adde492f045b7ea97a86cf90f50f14f22ae77d3bf437c9ee5482519293506001600160a01b0316916001600160401b03811115611300576113006149f4565b604051908082528060200260200182016040528015611329578160200160208202803683370190505b5090506000805b845181101561141257836001600160a01b0316630ff4c91686838151811061135a5761135a6149ca565b60200260200101516040518263ffffffff1660e01b815260040161138091815260200190565b602060405180830381865afa15801561139d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113c19190614a0a565b61140a578481815181106113d7576113d76149ca565b60200260200101518383815181106113f1576113f16149ca565b60209081029190910101528161140681614a3d565b9250505b600101611330565b508152949350505050565b611425612f7e565b6001600160a01b0316816001600160a01b03161461149d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016108e1565b6114a782826132d2565b5050565b7f455d2a126e5e85ea9f46f822a38d5695336cd3a8180a3a74ea4601221f9ed9876114d581612bf5565b6114de87612c06565b6114e78a612cf5565b600089815260fc60205260409020546001600160a01b031661151f5760405163393f13e760e01b8152600481018a90526024016108e1565b600089815260fc602052604090819020549051632c9ee17760e21b81526001600160a01b0390911690819063b27b85dc90611566908b908a908a908a908a90600401614a56565b600060405180830381600087803b15801561158057600080fd5b505af1158015611594573d6000803e3d6000fd5b50505050876001600160a01b0316896001600160a01b03168b7f187fe03859dbfadac49b3639bdca667cd35ee572856cdc74f634ea56843e607e8e8b8b8b8b8b6040516115e69695949392919061498a565b60405180910390a45050505050505050505050565b60008181526101026020526040902060609061086b906132c5565b6060836001600160401b03811115611630576116306149f4565b60405190808252806020026020018201604052801561166357816020015b606081526020019060019003908161164e5790505b50905060005b8481101561178857600060ff6000868685818110611689576116896149ca565b60209081029290920135835250810191909152604001600020546001600160a01b03169050806116d757604051632939675d60e01b81526001600160a01b03821660048201526024016108e1565b806001600160a01b03166357bc2ef38888858181106116f8576116f86149ca565b905060200201356040518263ffffffff1660e01b815260040161171d91815260200190565b600060405180830381865afa15801561173a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526117629190810190614a9a565b838381518110611774576117746149ca565b602090810291909101015250600101611669565b50949350505050565b6117996131ab565b600080516020614f918339815191526117b181612bf5565b60005b8281101561191f57600060fd60008686858181106117d4576117d46149ca565b90506020020160208101906117e991906144f7565b6001600160a01b0390811682526020820192909252604001600090812054909116915060fd90868685818110611821576118216149ca565b905060200201602081019061183691906144f7565b6001600160a01b031681526020810191909152604001600090812080546001600160a01b0319168155600101556118ab858584818110611878576118786149ca565b905060200201602081019061188d91906144f7565b6001600160a01b038316600090815260fe6020526040902090613357565b507f31e0adfec71bccee37b6e83a90c2fedb17d8f1693fee863c4771e7bfe2aed5808585848181106118df576118df6149ca565b90506020020160208101906118f491906144f7565b604080516001600160a01b03928316815291841660208301520160405180910390a1506001016117b4565b50505050565b6001600160a01b038116600090815260fe6020526040902060609061086b906132c5565b600061086b7fd3df22cd6a774f62b0ae21ffd602cc92e7f3390518eee8b33307fc70380da7d2836122e6565b61198f600080516020614fb1833981519152610748612f7e565b1580156119b357506119b1600080516020614f91833981519152610748612f7e565b155b80156119c957506119c76000610748612f7e565b155b15611a0e576119d6612f7e565b60405162b0d32560e11b81526001600160a01b039091166004820152600080516020614fb183398151915260248201526044016108e1565b600082815260ff6020908152604080832080546001600160a01b0319166001600160a01b03861690811790915580845261010090925280832085905551909184917fe065b93b78fd9ec871610269cc875e4f300f3cf0ed219355a75c09ffdc72c1859190a35050565b6000611a8560c95460ff1690565b905090565b6000600080516020614fb1833981519152611aa481612bf5565b61010180546001600160601b0316906000611abe83614b4c565b82546101009290920a6001600160601b038181021990931691831602179091556101015460009250611af29130911661336c565b9250505090565b336000908152610100602052604081205490819003611b2d57604051632939675d60e01b81523360048201526024016108e1565b838214611b5757604051635095ab9d60e11b815260048101859052602481018390526044016108e1565b60005b84811015611ba957611ba0826101026000898986818110611b7d57611b7d6149ca565b9050602002013581526020019081526020016000206133b090919063ffffffff16565b50600101611b5a565b50807f82efdbd4005a1d1eb82fddd472f42232c242d2ad44b9a242ba765e816f23cbce86868686604051611be09493929190614c39565b60405180910390a25050505050565b611bf76133bc565b611c016000613435565b565b600080516020614fb1833981519152611c1b81612bf5565b6001600160a01b03841615611cc6576000611c34613042565b600088815260fc60205260409020549091506001600160a01b03163314611c715760405163393f13e760e01b8152600481018890526024016108e1565b60408051828152602081018690529081018490526001600160a01b03808716919088169089907f1d9aaee2c014ed511e93b0e1289132b78abaf5ff3b3915f9a7aec2876531a00c9060600160405180910390a4505b505050505050565b611cd66131ab565b826001600160a01b0316611ce8612f7e565b6001600160a01b031614611d0f576040516348f5c3ed60e01b815260040160405180910390fd5b6001600160a01b038416600090815260fb6020526040902054607890611d359042614c6b565b1015611d5457604051633026d65960e11b815260040160405180910390fd5b836001600160a01b0316836001600160a01b03161480611d7b57506001600160a01b038316155b15611d995760405163eb32d3bf60e01b815260040160405180910390fd5b4282108015611da757508115155b15611dc557604051631b437f1160e11b815260040160405180910390fd5b6001600160a01b03808416600090815260fd602090815260409182902082518084019093528054909316808352600190930154908201529015801590611e215750846001600160a01b031681600001516001600160a01b031614155b15611e3f576040516342ee68b560e01b815260040160405180910390fd5b6000611e4d86868686610a4a565b90506000611e5a82613487565b90506000611e9e828b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506134c292505050565b9050806001600160a01b0316886001600160a01b031614611ee557604051639be21ff160e01b81526001600160a01b03808a166004830152821660248201526044016108e1565b6040805180820182526001600160a01b038a811680835260208084018b81528c8416600090815260fd8352868120955186546001600160a01b031916951694909417855551600190940193909355815260fe90915220611f4590886131f3565b506001600160a01b03888116600081815260fb60209081526040918290204290558151928352928a16928201929092529081018790527fdcb4af7d57cc106724f816a55242fbe9d45d800af6a574cb2814d7adf23e49409060600160405180910390a150505050505050505050565b600080516020614fb1833981519152611fcc81612bf5565b6001600160a01b0385161561207e576000611fe5613042565b600089815260fc60205260409020549091506001600160a01b031633146120225760405163393f13e760e01b8152600481018990526024016108e1565b6040805182815260208101879052908101859052606081018490526001600160a01b0380881691908916908a907fe0226f66a5bd2706623f73806e7eb62f852960f4713e38d6084b01290d6678169060800160405180910390a4505b50505050505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006001600160a01b0382166120db5760405163eb32d3bf60e01b815260040160405180910390fd5b6001600160a01b03808316600090815260fd602090815260409182902082518084019093528054909316808352600190930154908201529080156121525742826020015110801561212f5750602082015115155b1561214d5760405163b2861d8f60e01b815260040160405180910390fd5b61215a565b509192915050565b9392505050565b60008281526101026020526040812061215a90836134e6565b60606000846001600160401b03811115612196576121966149f4565b6040519080825280602002602001820160405280156121bf578160200160208202803683370190505b50905060005b8581101561224d576122238585838181106121e2576121e26149ca565b9050602002013561010260008a8a86818110612200576122006149ca565b9050602002013581526020019081526020016000206134e690919063ffffffff16565b828281518110612235576122356149ca565b911515602092830291909101909101526001016121c5565b5095945050505050565b612271600080516020614fb1833981519152610748612f7e565b1580156122955750612293600080516020614f91833981519152610748612f7e565b155b80156122cb57506122a4612f7e565b6001600160a01b03166122bf6097546001600160a01b031690565b6001600160a01b031614155b156122d8576119d6612f7e565b611cc68686868686866134fe565b600061215a8383612087565b600054610100900460ff16158080156123125750600054600160ff909116105b8061232c5750303b15801561232c575060005460ff166001145b61238f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016108e1565b6000805460ff1916600117905580156123b2576000805461ff0019166101001790555b6123ba61364f565b6123c2613676565b6123ca6136a5565b6123d382613435565b6123de6000836136d4565b6124097f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a60006136de565b6124347fea835c7d72284b79a066e6c72c2ec0626564e721352a92b0f8d5f16cb009fdd660006136de565b61245f7f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a960006136de565b61248a7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a660006136de565b6124a3600080516020614f9183398151915260006136de565b6124ce7ffc425f2263d0df187444b70e47283d622c70181c5baebb1306a01edba1ce184c60006136de565b6124f97f5a0afddc7ecb0deaa549d40e18566f1c87c8ed09187b6915eaf44079f37e2aca60006136de565b6125247fdef43b3901ce74522c0564b6b61fb50e09ecc39765fd64702dad6f2446fc4b6360006136de565b61254f7ff7b302cb700b7a54f3e005e07d62e8f53814068ec358c9a9e3f0423fa744c6a760006136de565b612568600080516020614fb183398151915260006136de565b612570612fac565b80156114a7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b60006125d5600080516020614fb1833981519152610748612f7e565b1580156125f957506125f7600080516020614f91833981519152610748612f7e565b155b801561262f5750612608612f7e565b6001600160a01b03166126236097546001600160a01b031690565b6001600160a01b031614155b1561263c576119d6612f7e565b61264a8787878787876134fe565b612652613042565b9050807f84cb1eedfefdbdc180ee81820e256e281ad4aeef64fc39f0b359f385534a3c4f86868a8a46428a8a604051612692989796959493929190614c7e565b60405180910390a29695505050505050565b3360009081526101006020526040812054908190036126d857604051632939675d60e01b81523360048201526024016108e1565b6000848152610102602052604090206126f190826133b0565b5083817f6837901feacdbb2b5f689b180c02268b287523b334088077ba4c35daf4fe34a88585604051612725929190614cd5565b60405180910390a350505050565b60008281526065602052604090206001015461274e81612bf5565b61126c83836132d2565b6000600080516020614fb183398151915261277281612bf5565b600086815260ff60205260409020546001600160a01b03166127aa5760405163563bbb7760e11b8152600481018790526024016108e1565b6127b2613042565b91508486837f58eb7fdba04a3157c5464689ccf75a24765262e09ce90b3c6c5c03f2299aa318464289896040516127ec9493929190614ce9565b60405180910390a450949350505050565b6001600160a01b03808216600090815260fd60205260409020541680612836576040516325ec6c1f60e01b815260040160405180910390fd5b61283e612f7e565b6001600160a01b0316826001600160a01b0316141580156128785750612862612f7e565b6001600160a01b0316816001600160a01b031614155b156128965760405163361140f160e21b815260040160405180910390fd5b6001600160a01b03808316600090815260fd6020908152604080832080546001600160a01b0319168155600101839055928416825260fe90529081206128dc9084613357565b9050600181151514612901576040516325ec6c1f60e01b815260040160405180910390fd5b604080516001600160a01b038086168252841660208201527f31e0adfec71bccee37b6e83a90c2fedb17d8f1693fee863c4771e7bfe2aed580910160405180910390a1505050565b600080516020614f9183398151915261296181612bf5565b6101035460ff161561298657604051630db4e05360e21b815260040160405180910390fd5b50610103805460ff1916600117905561010180546001600160601b039092166bffffffffffffffffffffffff19909216919091179055565b600081815260ff60205260409020546060906001600160a01b031680612a0257604051632939675d60e01b81526001600160a01b03821660048201526024016108e1565b6040516357bc2ef360e01b8152600481018590526001600160a01b038216906357bc2ef390602401600060405180830381865afa158015612a47573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612a6f9190810190614a9a565b949350505050565b6000600080516020614fb1833981519152612a9181612bf5565b600087815260ff60205260409020546001600160a01b0316612ac95760405163563bbb7760e11b8152600481018890526024016108e1565b848314612af357604051635095ab9d60e11b815260048101869052602481018490526044016108e1565b612afb613042565b915086827f5dd9f2865acd7453c002f561361db29d62d00f13b37f508d085a51d10248ec0b46428a8a8a8a604051612b3896959493929190614d13565b60405180910390a35095945050505050565b612b526133bc565b6001600160a01b038116612bb75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108e1565b610b1581613435565b60006001600160e01b03198216637965db0b60e01b148061086b57506301ffc9a760e01b6001600160e01b031983161461086b565b610b1581612c01612f7e565b613729565b7f690f6f6afcfb5c8f87210087be9555decb669a5a5a6d12111f620ca044144c3e600090815260ff6020527f82d63b350eafefeb8f4c7183a150a8f3b98db6d3d9cb91528652ef104b3c2d33546001600160a01b0316630ff4c916612c71846001600160a01b031690565b6040518263ffffffff1660e01b8152600401612c8f91815260200190565b602060405180830381865afa158015612cac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cd09190614d46565b90504681146114a757604051630baaab1160e11b8152600481018290526024016108e1565b6000818152610104602052604090205460ff1615612d2957604051635ad313b960e01b8152600481018290526024016108e1565b600090815261010460205260409020805460ff19166001179055565b600061215a8383613782565b60606000612d60836002614d5f565b612d6b906002614d76565b6001600160401b03811115612d8257612d826149f4565b6040519080825280601f01601f191660200182016040528015612dac576020820181803683370190505b509050600360fc1b81600081518110612dc757612dc76149ca565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612df657612df66149ca565b60200101906001600160f81b031916908160001a9053506000612e1a846002614d5f565b612e25906001614d76565b90505b6001811115612e9d576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612e5957612e596149ca565b1a60f81b828281518110612e6f57612e6f6149ca565b60200101906001600160f81b031916908160001a90535060049490941c93612e9681614d89565b9050612e28565b50831561215a5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016108e1565b60606000612ef983613875565b60010190506000816001600160401b03811115612f1857612f186149f4565b6040519080825280601f01601f191660200182016040528015612f42576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084612f4c57509392505050565b600060143610801590612f955750612f9533611949565b15612fa7575060131936013560601c90565b503390565b612fb46131ab565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612fea612f7e565b6040516001600160a01b03909116815260200160405180910390a1565b61300f61394d565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612fea612f7e565b7fe3bfd6d54b84ccae00cc6cad7783a88be07b38aacd8ade36a87a216bbfed6039600090815260ff6020527f30104a02363e5c98ba717549f6c9fbda80dd783fbe95f052dd2bbb597ed89d91546040516307fa648b60e11b81526994e155dc6bbc332671c360048201526001600160a01b039091169082908290630ff4c91690602401602060405180830381865afa1580156130e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131069190614d46565b613111906001614d76565b604051637b8d56e360e01b81526994e155dc6bbc332671c36004820152602481018290529091506001600160a01b03831690637b8d56e390604401600060405180830381600087803b15801561316657600080fd5b505af115801561317a573d6000803e3d6000fd5b50505050611af27f0541bbed38c2d1fed84a55280fba44929bc1fae876f694e155dc6bbc332671c360001c82613998565b6131b3611a77565b15611c015760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016108e1565b600061215a836001600160a01b038416613a51565b600061086b825490565b610b1561321f8280614da0565b61322c6020850185614da0565b6132396040870187614da0565b6134fe565b6132488282612087565b6114a75760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055613281612f7e565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6060600061215a83613aa0565b6132dc8282612087565b156114a75760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19169055613313612f7e565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600061215a836001600160a01b038416613782565b60006001600160601b038211156133995760405163515c8e4560e11b8152600481018390526024016108e1565b5060a081901b6001600160a01b0383161792915050565b600061215a8383613a51565b6133c4612f7e565b6001600160a01b03166133df6097546001600160a01b031690565b6001600160a01b031614611c015760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108e1565b609780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006134938251612eec565b826040516020016134a5929190614de9565b604051602081830303815290604052805190602001209050919050565b60008060006134d18585613afc565b915091506134de81613b41565b509392505050565b6000818152600183016020526040812054151561215a565b848114158061350d5750848314155b1561353557604051635095ab9d60e11b815260048101869052602481018290526044016108e1565b60005b8581101561207e57600060ff6000878785818110613558576135586149ca565b60209081029290920135835250810191909152604001600020546001600160a01b03169050806135a657604051632939675d60e01b81526001600160a01b03821660048201526024016108e1565b806001600160a01b031663011827fd8989858181106135c7576135c76149ca565b905060200201358686868181106135e0576135e06149ca565b90506020028101906135f29190614e44565b6040518463ffffffff1660e01b815260040161361093929190614e8a565b600060405180830381600087803b15801561362a57600080fd5b505af115801561363e573d6000803e3d6000fd5b505060019093019250613538915050565b600054610100900460ff16611c015760405162461bcd60e51b81526004016108e190614ea4565b600054610100900460ff1661369d5760405162461bcd60e51b81526004016108e190614ea4565b611c01613c8b565b600054610100900460ff166136cc5760405162461bcd60e51b81526004016108e190614ea4565b611c01613cc2565b6114a7828261323e565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6137338282612087565b6114a75761374081613cf5565b61374b836020613d07565b60405160200161375c929190614eef565b60408051601f198184030181529082905262461bcd60e51b82526108e191600401614069565b6000818152600183016020526040812054801561386b5760006137a6600183614c6b565b85549091506000906137ba90600190614c6b565b905081811461381f5760008660000182815481106137da576137da6149ca565b90600052602060002001549050808760000184815481106137fd576137fd6149ca565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061383057613830614f64565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061086b565b600091505061086b565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106138b45772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106138e0576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106138fe57662386f26fc10000830492506010015b6305f5e1008310613916576305f5e100830492506008015b612710831061392a57612710830492506004015b6064831061393c576064830492506002015b600a831061086b5760010192915050565b613955611a77565b611c015760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016108e1565b600063ffffffff4611156139c15760405163e44bb42560e01b81524660048201526024016108e1565b69ffffffffffffffffffff83811611156139fc57604051631c12f49d60e01b815269ffffffffffffffffffff841660048201526024016108e1565b71ffffffffffffffffffffffffffffffffffff821115613a32576040516331e597c760e01b8152600481018390526024016108e1565b5060909190911b69ffffffffffffffffffff60901b164660e01b171790565b6000818152600183016020526040812054613a985750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561086b565b50600061086b565b606081600001805480602002602001604051908101604052809291908181526020018280548015613af057602002820191906000526020600020905b815481526020019060010190808311613adc575b50505050509050919050565b6000808251604103613b325760208301516040840151606085015160001a613b2687828585613e53565b94509450505050613b3a565b506000905060025b9250929050565b6000816004811115613b5557613b55614f7a565b03613b5d5750565b6001816004811115613b7157613b71614f7a565b03613bbe5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016108e1565b6002816004811115613bd257613bd2614f7a565b03613c1f5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016108e1565b6003816004811115613c3357613c33614f7a565b03610b155760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016108e1565b600054610100900460ff16613cb25760405162461bcd60e51b81526004016108e190614ea4565b611c01613cbd612f7e565b613435565b600054610100900460ff16613ce95760405162461bcd60e51b81526004016108e190614ea4565b60c9805460ff19169055565b606061086b6001600160a01b03831660145b60606000613d16836002614d5f565b613d21906002614d76565b6001600160401b03811115613d3857613d386149f4565b6040519080825280601f01601f191660200182016040528015613d62576020820181803683370190505b509050600360fc1b81600081518110613d7d57613d7d6149ca565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613dac57613dac6149ca565b60200101906001600160f81b031916908160001a9053506000613dd0846002614d5f565b613ddb906001614d76565b90505b6001811115612e9d576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613e0f57613e0f6149ca565b1a60f81b828281518110613e2557613e256149ca565b60200101906001600160f81b031916908160001a90535060049490941c93613e4c81614d89565b9050613dde565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613e8a5750600090506003613f0e565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613ede573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613f0757600060019250925050613f0e565b9150600090505b94509492505050565b600060208284031215613f2957600080fd5b81356001600160e01b03198116811461215a57600080fd5b80356001600160a01b0381168114613f5857600080fd5b919050565b600080600080600080600060e0888a031215613f7857600080fd5b8735965060208801359550613f8f60408901613f41565b9450613f9d60608901613f41565b9699959850939660808101359560a0820135955060c0909101359350915050565b600060208284031215613fd057600080fd5b5035919050565b60008060008060808587031215613fed57600080fd5b613ff685613f41565b935061400460208601613f41565b93969395505050506040820135916060013590565b60005b8381101561403457818101518382015260200161401c565b50506000910152565b60008151808452614055816020860160208601614019565b601f01601f19169290920160200192915050565b60208152600061215a602083018461403d565b8015158114610b1557600080fd5b60006020828403121561409c57600080fd5b813561215a8161407c565b60008083601f8401126140b957600080fd5b5081356001600160401b038111156140d057600080fd5b6020830191508360208260051b8501011115613b3a57600080fd5b60008060008060008060008060c0898b03121561410757600080fd5b8835975061411760208a01613f41565b965061412560408a01613f41565b95506060890135945060808901356001600160401b0381111561414757600080fd5b6141538b828c016140a7565b90955093505060a08901356001600160401b0381111561417257600080fd5b61417e8b828c016140a7565b999c989b5096995094979396929594505050565b600080600080600080606087890312156141ab57600080fd5b86356001600160401b038111156141c157600080fd5b6141cd89828a016140a7565b90975095505060208701356001600160401b038111156141ec57600080fd5b6141f889828a016140a7565b90955093505060408701356001600160401b0381111561421757600080fd5b61422389828a016140a7565b979a9699509497509295939492505050565b6000806020838503121561424857600080fd5b82356001600160401b0381111561425e57600080fd5b61426a858286016140a7565b90969095509350505050565b600080600080600080600060e0888a03121561429157600080fd5b87359650602088013595506142a860408901613f41565b94506142b660608901613f41565b93506080880135925060a0880135915060c08801356001600160401b038111156142df57600080fd5b88016060818b0312156142f157600080fd5b8091505092959891949750929550565b6000806040838503121561431457600080fd5b8235915061432460208401613f41565b90509250929050565b602080825282518282018190526000918401906040840190835b81811015614365578351835260209384019390920191600101614347565b509095945050505050565b600080600080600080600080600060e08a8c03121561438e57600080fd5b8935985060208a013597506143a560408b01613f41565b96506143b360608b01613f41565b955060808a0135945060a08a01356001600160401b038111156143d557600080fd5b6143e18c828d016140a7565b90955093505060c08a01356001600160401b0381111561440057600080fd5b61440c8c828d016140a7565b915080935050809150509295985092959850929598565b6000806000806040858703121561443957600080fd5b84356001600160401b0381111561444f57600080fd5b61445b878288016140a7565b90955093505060208501356001600160401b0381111561447a57600080fd5b614486878288016140a7565b95989497509550505050565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b828110156144eb57603f198786030184526144d685835161403d565b945060209384019391909101906001016144ba565b50929695505050505050565b60006020828403121561450957600080fd5b61215a82613f41565b602080825282518282018190526000918401906040840190835b818110156143655783516001600160a01b031683526020938401939092019160010161452c565b600080600080600060a0868803121561456b57600080fd5b8535945061457b60208701613f41565b935061458960408701613f41565b94979396509394606081013594506080013592915050565b60008083601f8401126145b357600080fd5b5081356001600160401b038111156145ca57600080fd5b602083019150836020828501011115613b3a57600080fd5b60008060008060008060a087890312156145fb57600080fd5b86356001600160401b0381111561461157600080fd5b61461d89828a016145a1565b9097509550614630905060208801613f41565b935061463e60408801613f41565b959894975092956060810135946080909101359350915050565b60008060008060008060c0878903121561467157600080fd5b8635955061468160208801613f41565b945061468f60408801613f41565b959894975094956060810135955060808101359460a0909101359350915050565b600080604083850312156146c357600080fd5b50508035926020909101359150565b602080825282518282018190526000918401906040840190835b8181101561436557835115158352602093840193909201916001016146ec565b60008060006040848603121561472157600080fd5b8335925060208401356001600160401b0381111561473e57600080fd5b61474a868287016145a1565b9497909650939450505050565b6000806000806060858703121561476d57600080fd5b843593506020850135925060408501356001600160401b0381111561479157600080fd5b614486878288016145a1565b6000602082840312156147af57600080fd5b81356001600160601b038116811461215a57600080fd5b6000806000806000606086880312156147de57600080fd5b8535945060208601356001600160401b038111156147fb57600080fd5b614807888289016140a7565b90955093505060408601356001600160401b0381111561482657600080fd5b614832888289016140a7565b969995985093965092949392505050565b7f417574686f72697a65206f70657261746f72206163636f756e7420000000000081526000855161487b81601b850160208a01614019565b7f20746f20706572666f726d2067616d65706c617920616374696f6e73206f6e20601b918401918201527f626568616c66206f6620706c61796572206163636f756e742000000000000000603b82015285516148de816054840160208a01614019565b601b81830101915050700103bb4ba341032bc3834b930ba34b7b71607d1b6039820152845161491481604a840160208901614019565b6039818301019150507001039b4b3b732b21030ba10313637b1b59607d1b6011820152835161494a816022840160208801614019565b016022019695505050505050565b81835260006001600160fb1b0383111561497157600080fd5b8260051b80836020870137939093016020019392505050565b8681528560208201526080604082015260006149aa608083018688614958565b82810360608401526149bd818587614958565b9998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b602081526000612a6f602083018486614958565b634e487b7160e01b600052604160045260246000fd5b600060208284031215614a1c57600080fd5b815161215a8161407c565b634e487b7160e01b600052601160045260246000fd5b600060018201614a4f57614a4f614a27565b5060010190565b6001600160a01b0386168152606060208201819052600090614a7b9083018688614958565b8281036040840152614a8e818587614958565b98975050505050505050565b600060208284031215614aac57600080fd5b81516001600160401b03811115614ac257600080fd5b8201601f81018413614ad357600080fd5b80516001600160401b03811115614aec57614aec6149f4565b604051601f8201601f19908116603f011681016001600160401b0381118282101715614b1a57614b1a6149f4565b604052818152828201602001861015614b3257600080fd5b614b43826020830160208601614019565b95945050505050565b60006001600160601b0382166001600160601b038103614b6e57614b6e614a27565b60010192915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008383855260208501945060208460051b8201018360005b86811015614c2d57838303601f19018852813536879003601e19018112614bdf57600080fd5b86016020810190356001600160401b03811115614bfb57600080fd5b803603821315614c0a57600080fd5b614c15858284614b77565b60209a8b019a90955093909301925050600101614bb9565b50909695505050505050565b604081526000614c4d604083018688614958565b8281036020840152614c60818587614ba0565b979650505050505050565b8181038181111561086b5761086b614a27565b60a081526000614c9260a083018a8c614958565b8281036020840152614ca581898b614958565b90508660408401528560608401528281036080840152614cc6818587614ba0565b9b9a5050505050505050505050565b602081526000612a6f602083018486614b77565b848152836020820152606060408201526000614d09606083018486614b77565b9695505050505050565b868152856020820152608060408201526000614d33608083018688614958565b82810360608401526149bd818587614ba0565b600060208284031215614d5857600080fd5b5051919050565b808202811582820484141761086b5761086b614a27565b8082018082111561086b5761086b614a27565b600081614d9857614d98614a27565b506000190190565b6000808335601e19843603018112614db757600080fd5b8301803591506001600160401b03821115614dd157600080fd5b6020019150600581901b3603821315613b3a57600080fd5b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351614e2181601a850160208801614019565b835190830190614e3881601a840160208801614019565b01601a01949350505050565b6000808335601e19843603018112614e5b57600080fd5b8301803591506001600160401b03821115614e7557600080fd5b602001915036819003821315613b3a57600080fd5b838152604060208201526000614b43604083018486614b77565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351614f27816017850160208801614019565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351614f58816028840160208801614019565b01602801949350505050565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052602160045260246000fdfe241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08d3dc2a3a14cbd0cdbf3069fc3927e48506f271b9dda2c21625b93e6a99d3eb53a2646970667358221220625c52ae65b7fb5888e93d51730f37276c4650b64e4dc7631376f4e70187828564736f6c634300081a0033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061035d5760003560e01c80635c8cd1da116101d3578063b69ec14f11610104578063d671c721116100a2578063e21592de1161007c578063e21592de146107d2578063e6ce49b0146107e5578063ee86385014610805578063f2fde38b1461081857600080fd5b8063d671c72114610799578063d8cf98ca146107ac578063e13e02ae146107bf57600080fd5b8063c4d66de8116100de578063c4d66de81461074d578063cf38bcec14610760578063cfd3c57f14610773578063d547741f1461078657600080fd5b8063b69ec14f14610707578063ba64197814610727578063c36dd7ea1461073a57600080fd5b80638b3d31901161017157806393f7cc991161014b57806393f7cc99146106af5780639f54f545146106c2578063a217fddf146106ec578063a55cce99146106f457600080fd5b80638b3d3190146106785780638da5cb5b1461068b57806391d148541461069c57600080fd5b80636e0e51d6116101ad5780636e0e51d614610637578063715018a61461064a57806384db946514610652578063868b4ea31461066557600080fd5b80635c8cd1da146106145780635c975abb146106275780635eb328e81461062f57600080fd5b80632e9e37da116102ad57806347c32fc91161024b5780634f27da18116102255780634f27da181461058f57806353e41c1e146105d0578063552b6cbd146105f9578063572b6c051461060157600080fd5b806347c32fc91461053c5780634b84859e1461055c5780634b9b233d1461056f57600080fd5b80633632e55d116102875780633632e55d146104e757806336568abe1461050357806338b34ce2146105165780633e2b47311461052957600080fd5b80632e9e37da146104a15780632f2ff15d146104b4578063306b8fdb146104c757600080fd5b80632078e59f1161031a57806323b73080116102f457806323b730801461043f578063248a9ca31461044757806328895a651461046a5780632a07379f1461047d57600080fd5b80632078e59f146103f8578063209e1d1f1461040b578063236856301461042c57600080fd5b806301ffc9a71461036257806307000fa31461038a5780630de3b7b51461039f5780631548a8de146103b257806316c38b3c146103d25780631aa49f0a146103e5575b600080fd5b610375610370366004613f17565b61082b565b60405190151581526020015b60405180910390f35b61039d610398366004613f5d565b610871565b005b61039d6103ad366004613fbe565b6109cb565b6103c56103c0366004613fd7565b610a4a565b6040516103819190614069565b61039d6103e036600461408a565b610ab2565b61039d6103f33660046140eb565b610b72565b61039d610406366004614192565b610c43565b61041e610419366004613fbe565b610fa3565b604051908152602001610381565b61039d61043a366004614235565b610fbb565b61041e607881565b61041e610455366004613fbe565b60009081526065602052604090206001015490565b61039d610478366004614276565b611081565b61037561048b366004613fbe565b6101046020526000908152604090205460ff1681565b61039d6104af366004614301565b6111c3565b61039d6104c2366004614301565b611247565b6104da6104d5366004613fbe565b611271565b604051610381919061432d565b610101546040516001600160601b039091168152602001610381565b61039d610511366004614301565b61141d565b61039d610524366004614370565b6114ab565b6104da610537366004613fbe565b6115fb565b61054f61054a366004614423565b611616565b6040516103819190614492565b61039d61056a366004614235565b611791565b61058261057d3660046144f7565b611925565b6040516103819190614512565b6105b861059d366004613fbe565b600090815260ff60205260409020546001600160a01b031690565b6040516001600160a01b039091168152602001610381565b6105b86105de366004613fbe565b600090815260fc60205260409020546001600160a01b031690565b61041e601e81565b61037561060f3660046144f7565b611949565b61039d610622366004614301565b611975565b610375611a77565b61041e611a8a565b61039d610645366004614423565b611af9565b61039d611bef565b61039d610660366004614553565b611c03565b61039d6106733660046145e2565b611cce565b61039d610686366004614658565b611fb4565b6097546001600160a01b03166105b8565b6103756106aa366004614301565b612087565b6105b86106bd3660046144f7565b6120b2565b61041e6106d03660046144f7565b6001600160a01b03166000908152610100602052604090205490565b61041e600081565b6103756107023660046146b0565b612161565b61071a610715366004614423565b61217a565b60405161038191906146d2565b61039d610735366004614192565b612257565b610375610748366004614301565b6122e6565b61039d61075b3660046144f7565b6122f2565b61041e61076e366004614192565b6125b9565b61039d61078136600461470c565b6126a4565b61039d610794366004614301565b612733565b61041e6107a7366004614757565b612758565b61039d6107ba3660046144f7565b6127fd565b61039d6107cd36600461479d565b612949565b6103c56107e03660046146b0565b6129be565b61041e6107f33660046144f7565b60fb6020526000908152604090205481565b61041e6108133660046147c6565b612a77565b61039d6108263660046144f7565b612b4a565b60006001600160e01b03198216630f8c34d960e21b148061085c57506001600160e01b031982166301ffc9a760e01b145b8061086b575061086b82612bc0565b92915050565b7f455d2a126e5e85ea9f46f822a38d5695336cd3a8180a3a74ea4601221f9ed98761089b81612bf5565b6108a485612c06565b6108ad88612cf5565b600087815260fc60205260409020546001600160a01b03166108ea5760405163393f13e760e01b8152600481018890526024015b60405180910390fd5b600087815260fc60205260409081902054905163a514d6ff60e01b81526001600160a01b038781166004830152602482018690526044820185905290911690819063a514d6ff90606401600060405180830381600087803b15801561094e57600080fd5b505af1158015610962573d6000803e3d6000fd5b5050604080518c815260208101899052908101879052606081018690526001600160a01b03808a1693508a1691508a907fbbc2c05b9ccfe02f6e3b80f1a5a22a06ad7f0f20c4ea818e9dae43b9240f0644906080015b60405180910390a4505050505050505050565b3360009081526101006020526040812054908190036109ff57604051632939675d60e01b81523360048201526024016108e1565b600082815261010260205260409020610a189082612d45565b50604051829082907f8989859870cc0d47cc5f8909459290e411f855f5535f7dbfaf1038cf40fccc0e90600090a35050565b6060610a60846001600160a01b03166014612d51565b610a74866001600160a01b03166014612d51565b610a7d85612eec565b610a8685612eec565b604051602001610a999493929190614843565b6040516020818303038152906040529050949350505050565b6097546001600160a01b0316610ac6612f7e565b6001600160a01b03161480610b025750610b027f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a6106aa612f7e565b15610b20578015610b1857610b15612fac565b50565b610b15613007565b610b28612f7e565b60405162b0d32560e11b81526001600160a01b0390911660048201527f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a60248201526044016108e1565b600080516020614fb1833981519152610b8a81612bf5565b6001600160a01b03871615610c38576000610ba3613042565b60008b815260fc60205260409020549091506001600160a01b03163314610be05760405163393f13e760e01b8152600481018b90526024016108e1565b876001600160a01b0316896001600160a01b03168b7fa2d715629f9034d65861900d057bee4ffbe715c0b061eca73a32225091eba73a848b8b8b8b8b604051610c2e9695949392919061498a565b60405180910390a4505b505050505050505050565b610c4b6131ab565b600080516020614f91833981519152610c6381612bf5565b8584141580610c725750858214155b15610c905760405163eb32d3bf60e01b815260040160405180910390fd5b60005b86811015610f9957878782818110610cad57610cad6149ca565b9050602002016020810190610cc291906144f7565b6001600160a01b0316868683818110610cdd57610cdd6149ca565b9050602002016020810190610cf291906144f7565b6001600160a01b03161480610d3657506000868683818110610d1657610d166149ca565b9050602002016020810190610d2b91906144f7565b6001600160a01b0316145b15610d545760405163eb32d3bf60e01b815260040160405180910390fd5b6040518060400160405280898984818110610d7157610d716149ca565b9050602002016020810190610d8691906144f7565b6001600160a01b03168152602001858584818110610da657610da66149ca565b9050602002013581525060fd6000888885818110610dc657610dc66149ca565b9050602002016020810190610ddb91906144f7565b6001600160a01b0390811682526020808301939093526040909101600020835181546001600160a01b0319169216919091178155910151600190910155610e8c868683818110610e2d57610e2d6149ca565b9050602002016020810190610e4291906144f7565b60fe60008b8b86818110610e5857610e586149ca565b9050602002016020810190610e6d91906144f7565b6001600160a01b031681526020810191909152604001600020906131f3565b504260fb60008a8a85818110610ea457610ea46149ca565b9050602002016020810190610eb991906144f7565b6001600160a01b031681526020810191909152604001600020557fdcb4af7d57cc106724f816a55242fbe9d45d800af6a574cb2814d7adf23e4940888883818110610f0657610f066149ca565b9050602002016020810190610f1b91906144f7565b878784818110610f2d57610f2d6149ca565b9050602002016020810190610f4291906144f7565b868685818110610f5457610f546149ca565b90506020020135604051610f89939291906001600160a01b039384168152919092166020820152604081019190915260600190565b60405180910390a1600101610c93565b5050505050505050565b60008181526101026020526040812061086b90613208565b336000908152610100602052604081205490819003610fef57604051632939675d60e01b81523360048201526024016108e1565b60005b8281101561104157611038826101026000878786818110611015576110156149ca565b905060200201358152602001908152602001600020612d4590919063ffffffff16565b50600101610ff2565b50807fe25d213f62bc7c4e937e89492babb3d2720fa992806de157203dfbf8e631a04284846040516110749291906149e0565b60405180910390a2505050565b7f455d2a126e5e85ea9f46f822a38d5695336cd3a8180a3a74ea4601221f9ed9876110ab81612bf5565b6110b485612c06565b6110bd88612cf5565b600087815260fc60205260409020546001600160a01b03166110f55760405163393f13e760e01b8152600481018890526024016108e1565b600087815260fc6020526040908190205490516331ff46bd60e11b81526001600160a01b038781166004830152602482018790529091169081906363fe8d7a90604401600060405180830381600087803b15801561115257600080fd5b505af1158015611166573d6000803e3d6000fd5b5050505061117383613212565b604080518a8152602081018790529081018590526001600160a01b0380881691908916908a907fb316fa5abbed8c6419c8559a4ee6369b7ec8fff26ea1d1c3d54ec5efedd1225a906060016109b8565b7ffc425f2263d0df187444b70e47283d622c70181c5baebb1306a01edba1ce184c6111ed81612bf5565b600083815260fc602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051909185917f4ad49251ddae0b218995a7fd001ab79155bdbb25933c94a417e2d67103cfe3499190a3505050565b60008281526065602052604090206001015461126281612bf5565b61126c838361323e565b505050565b6000818152610102602052604081206060919061128d906132c5565b7f6f6904abf86d9d6d5114fd2ba5c3020cff3fb91d7ec4594f71ef6b5ff6bb3e49600090815260ff6020527f5f23ddf214f07432adde492f045b7ea97a86cf90f50f14f22ae77d3bf437c9ee5482519293506001600160a01b0316916001600160401b03811115611300576113006149f4565b604051908082528060200260200182016040528015611329578160200160208202803683370190505b5090506000805b845181101561141257836001600160a01b0316630ff4c91686838151811061135a5761135a6149ca565b60200260200101516040518263ffffffff1660e01b815260040161138091815260200190565b602060405180830381865afa15801561139d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113c19190614a0a565b61140a578481815181106113d7576113d76149ca565b60200260200101518383815181106113f1576113f16149ca565b60209081029190910101528161140681614a3d565b9250505b600101611330565b508152949350505050565b611425612f7e565b6001600160a01b0316816001600160a01b03161461149d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016108e1565b6114a782826132d2565b5050565b7f455d2a126e5e85ea9f46f822a38d5695336cd3a8180a3a74ea4601221f9ed9876114d581612bf5565b6114de87612c06565b6114e78a612cf5565b600089815260fc60205260409020546001600160a01b031661151f5760405163393f13e760e01b8152600481018a90526024016108e1565b600089815260fc602052604090819020549051632c9ee17760e21b81526001600160a01b0390911690819063b27b85dc90611566908b908a908a908a908a90600401614a56565b600060405180830381600087803b15801561158057600080fd5b505af1158015611594573d6000803e3d6000fd5b50505050876001600160a01b0316896001600160a01b03168b7f187fe03859dbfadac49b3639bdca667cd35ee572856cdc74f634ea56843e607e8e8b8b8b8b8b6040516115e69695949392919061498a565b60405180910390a45050505050505050505050565b60008181526101026020526040902060609061086b906132c5565b6060836001600160401b03811115611630576116306149f4565b60405190808252806020026020018201604052801561166357816020015b606081526020019060019003908161164e5790505b50905060005b8481101561178857600060ff6000868685818110611689576116896149ca565b60209081029290920135835250810191909152604001600020546001600160a01b03169050806116d757604051632939675d60e01b81526001600160a01b03821660048201526024016108e1565b806001600160a01b03166357bc2ef38888858181106116f8576116f86149ca565b905060200201356040518263ffffffff1660e01b815260040161171d91815260200190565b600060405180830381865afa15801561173a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526117629190810190614a9a565b838381518110611774576117746149ca565b602090810291909101015250600101611669565b50949350505050565b6117996131ab565b600080516020614f918339815191526117b181612bf5565b60005b8281101561191f57600060fd60008686858181106117d4576117d46149ca565b90506020020160208101906117e991906144f7565b6001600160a01b0390811682526020820192909252604001600090812054909116915060fd90868685818110611821576118216149ca565b905060200201602081019061183691906144f7565b6001600160a01b031681526020810191909152604001600090812080546001600160a01b0319168155600101556118ab858584818110611878576118786149ca565b905060200201602081019061188d91906144f7565b6001600160a01b038316600090815260fe6020526040902090613357565b507f31e0adfec71bccee37b6e83a90c2fedb17d8f1693fee863c4771e7bfe2aed5808585848181106118df576118df6149ca565b90506020020160208101906118f491906144f7565b604080516001600160a01b03928316815291841660208301520160405180910390a1506001016117b4565b50505050565b6001600160a01b038116600090815260fe6020526040902060609061086b906132c5565b600061086b7fd3df22cd6a774f62b0ae21ffd602cc92e7f3390518eee8b33307fc70380da7d2836122e6565b61198f600080516020614fb1833981519152610748612f7e565b1580156119b357506119b1600080516020614f91833981519152610748612f7e565b155b80156119c957506119c76000610748612f7e565b155b15611a0e576119d6612f7e565b60405162b0d32560e11b81526001600160a01b039091166004820152600080516020614fb183398151915260248201526044016108e1565b600082815260ff6020908152604080832080546001600160a01b0319166001600160a01b03861690811790915580845261010090925280832085905551909184917fe065b93b78fd9ec871610269cc875e4f300f3cf0ed219355a75c09ffdc72c1859190a35050565b6000611a8560c95460ff1690565b905090565b6000600080516020614fb1833981519152611aa481612bf5565b61010180546001600160601b0316906000611abe83614b4c565b82546101009290920a6001600160601b038181021990931691831602179091556101015460009250611af29130911661336c565b9250505090565b336000908152610100602052604081205490819003611b2d57604051632939675d60e01b81523360048201526024016108e1565b838214611b5757604051635095ab9d60e11b815260048101859052602481018390526044016108e1565b60005b84811015611ba957611ba0826101026000898986818110611b7d57611b7d6149ca565b9050602002013581526020019081526020016000206133b090919063ffffffff16565b50600101611b5a565b50807f82efdbd4005a1d1eb82fddd472f42232c242d2ad44b9a242ba765e816f23cbce86868686604051611be09493929190614c39565b60405180910390a25050505050565b611bf76133bc565b611c016000613435565b565b600080516020614fb1833981519152611c1b81612bf5565b6001600160a01b03841615611cc6576000611c34613042565b600088815260fc60205260409020549091506001600160a01b03163314611c715760405163393f13e760e01b8152600481018890526024016108e1565b60408051828152602081018690529081018490526001600160a01b03808716919088169089907f1d9aaee2c014ed511e93b0e1289132b78abaf5ff3b3915f9a7aec2876531a00c9060600160405180910390a4505b505050505050565b611cd66131ab565b826001600160a01b0316611ce8612f7e565b6001600160a01b031614611d0f576040516348f5c3ed60e01b815260040160405180910390fd5b6001600160a01b038416600090815260fb6020526040902054607890611d359042614c6b565b1015611d5457604051633026d65960e11b815260040160405180910390fd5b836001600160a01b0316836001600160a01b03161480611d7b57506001600160a01b038316155b15611d995760405163eb32d3bf60e01b815260040160405180910390fd5b4282108015611da757508115155b15611dc557604051631b437f1160e11b815260040160405180910390fd5b6001600160a01b03808416600090815260fd602090815260409182902082518084019093528054909316808352600190930154908201529015801590611e215750846001600160a01b031681600001516001600160a01b031614155b15611e3f576040516342ee68b560e01b815260040160405180910390fd5b6000611e4d86868686610a4a565b90506000611e5a82613487565b90506000611e9e828b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506134c292505050565b9050806001600160a01b0316886001600160a01b031614611ee557604051639be21ff160e01b81526001600160a01b03808a166004830152821660248201526044016108e1565b6040805180820182526001600160a01b038a811680835260208084018b81528c8416600090815260fd8352868120955186546001600160a01b031916951694909417855551600190940193909355815260fe90915220611f4590886131f3565b506001600160a01b03888116600081815260fb60209081526040918290204290558151928352928a16928201929092529081018790527fdcb4af7d57cc106724f816a55242fbe9d45d800af6a574cb2814d7adf23e49409060600160405180910390a150505050505050505050565b600080516020614fb1833981519152611fcc81612bf5565b6001600160a01b0385161561207e576000611fe5613042565b600089815260fc60205260409020549091506001600160a01b031633146120225760405163393f13e760e01b8152600481018990526024016108e1565b6040805182815260208101879052908101859052606081018490526001600160a01b0380881691908916908a907fe0226f66a5bd2706623f73806e7eb62f852960f4713e38d6084b01290d6678169060800160405180910390a4505b50505050505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006001600160a01b0382166120db5760405163eb32d3bf60e01b815260040160405180910390fd5b6001600160a01b03808316600090815260fd602090815260409182902082518084019093528054909316808352600190930154908201529080156121525742826020015110801561212f5750602082015115155b1561214d5760405163b2861d8f60e01b815260040160405180910390fd5b61215a565b509192915050565b9392505050565b60008281526101026020526040812061215a90836134e6565b60606000846001600160401b03811115612196576121966149f4565b6040519080825280602002602001820160405280156121bf578160200160208202803683370190505b50905060005b8581101561224d576122238585838181106121e2576121e26149ca565b9050602002013561010260008a8a86818110612200576122006149ca565b9050602002013581526020019081526020016000206134e690919063ffffffff16565b828281518110612235576122356149ca565b911515602092830291909101909101526001016121c5565b5095945050505050565b612271600080516020614fb1833981519152610748612f7e565b1580156122955750612293600080516020614f91833981519152610748612f7e565b155b80156122cb57506122a4612f7e565b6001600160a01b03166122bf6097546001600160a01b031690565b6001600160a01b031614155b156122d8576119d6612f7e565b611cc68686868686866134fe565b600061215a8383612087565b600054610100900460ff16158080156123125750600054600160ff909116105b8061232c5750303b15801561232c575060005460ff166001145b61238f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016108e1565b6000805460ff1916600117905580156123b2576000805461ff0019166101001790555b6123ba61364f565b6123c2613676565b6123ca6136a5565b6123d382613435565b6123de6000836136d4565b6124097f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a60006136de565b6124347fea835c7d72284b79a066e6c72c2ec0626564e721352a92b0f8d5f16cb009fdd660006136de565b61245f7f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a960006136de565b61248a7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a660006136de565b6124a3600080516020614f9183398151915260006136de565b6124ce7ffc425f2263d0df187444b70e47283d622c70181c5baebb1306a01edba1ce184c60006136de565b6124f97f5a0afddc7ecb0deaa549d40e18566f1c87c8ed09187b6915eaf44079f37e2aca60006136de565b6125247fdef43b3901ce74522c0564b6b61fb50e09ecc39765fd64702dad6f2446fc4b6360006136de565b61254f7ff7b302cb700b7a54f3e005e07d62e8f53814068ec358c9a9e3f0423fa744c6a760006136de565b612568600080516020614fb183398151915260006136de565b612570612fac565b80156114a7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b60006125d5600080516020614fb1833981519152610748612f7e565b1580156125f957506125f7600080516020614f91833981519152610748612f7e565b155b801561262f5750612608612f7e565b6001600160a01b03166126236097546001600160a01b031690565b6001600160a01b031614155b1561263c576119d6612f7e565b61264a8787878787876134fe565b612652613042565b9050807f84cb1eedfefdbdc180ee81820e256e281ad4aeef64fc39f0b359f385534a3c4f86868a8a46428a8a604051612692989796959493929190614c7e565b60405180910390a29695505050505050565b3360009081526101006020526040812054908190036126d857604051632939675d60e01b81523360048201526024016108e1565b6000848152610102602052604090206126f190826133b0565b5083817f6837901feacdbb2b5f689b180c02268b287523b334088077ba4c35daf4fe34a88585604051612725929190614cd5565b60405180910390a350505050565b60008281526065602052604090206001015461274e81612bf5565b61126c83836132d2565b6000600080516020614fb183398151915261277281612bf5565b600086815260ff60205260409020546001600160a01b03166127aa5760405163563bbb7760e11b8152600481018790526024016108e1565b6127b2613042565b91508486837f58eb7fdba04a3157c5464689ccf75a24765262e09ce90b3c6c5c03f2299aa318464289896040516127ec9493929190614ce9565b60405180910390a450949350505050565b6001600160a01b03808216600090815260fd60205260409020541680612836576040516325ec6c1f60e01b815260040160405180910390fd5b61283e612f7e565b6001600160a01b0316826001600160a01b0316141580156128785750612862612f7e565b6001600160a01b0316816001600160a01b031614155b156128965760405163361140f160e21b815260040160405180910390fd5b6001600160a01b03808316600090815260fd6020908152604080832080546001600160a01b0319168155600101839055928416825260fe90529081206128dc9084613357565b9050600181151514612901576040516325ec6c1f60e01b815260040160405180910390fd5b604080516001600160a01b038086168252841660208201527f31e0adfec71bccee37b6e83a90c2fedb17d8f1693fee863c4771e7bfe2aed580910160405180910390a1505050565b600080516020614f9183398151915261296181612bf5565b6101035460ff161561298657604051630db4e05360e21b815260040160405180910390fd5b50610103805460ff1916600117905561010180546001600160601b039092166bffffffffffffffffffffffff19909216919091179055565b600081815260ff60205260409020546060906001600160a01b031680612a0257604051632939675d60e01b81526001600160a01b03821660048201526024016108e1565b6040516357bc2ef360e01b8152600481018590526001600160a01b038216906357bc2ef390602401600060405180830381865afa158015612a47573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612a6f9190810190614a9a565b949350505050565b6000600080516020614fb1833981519152612a9181612bf5565b600087815260ff60205260409020546001600160a01b0316612ac95760405163563bbb7760e11b8152600481018890526024016108e1565b848314612af357604051635095ab9d60e11b815260048101869052602481018490526044016108e1565b612afb613042565b915086827f5dd9f2865acd7453c002f561361db29d62d00f13b37f508d085a51d10248ec0b46428a8a8a8a604051612b3896959493929190614d13565b60405180910390a35095945050505050565b612b526133bc565b6001600160a01b038116612bb75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108e1565b610b1581613435565b60006001600160e01b03198216637965db0b60e01b148061086b57506301ffc9a760e01b6001600160e01b031983161461086b565b610b1581612c01612f7e565b613729565b7f690f6f6afcfb5c8f87210087be9555decb669a5a5a6d12111f620ca044144c3e600090815260ff6020527f82d63b350eafefeb8f4c7183a150a8f3b98db6d3d9cb91528652ef104b3c2d33546001600160a01b0316630ff4c916612c71846001600160a01b031690565b6040518263ffffffff1660e01b8152600401612c8f91815260200190565b602060405180830381865afa158015612cac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cd09190614d46565b90504681146114a757604051630baaab1160e11b8152600481018290526024016108e1565b6000818152610104602052604090205460ff1615612d2957604051635ad313b960e01b8152600481018290526024016108e1565b600090815261010460205260409020805460ff19166001179055565b600061215a8383613782565b60606000612d60836002614d5f565b612d6b906002614d76565b6001600160401b03811115612d8257612d826149f4565b6040519080825280601f01601f191660200182016040528015612dac576020820181803683370190505b509050600360fc1b81600081518110612dc757612dc76149ca565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612df657612df66149ca565b60200101906001600160f81b031916908160001a9053506000612e1a846002614d5f565b612e25906001614d76565b90505b6001811115612e9d576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612e5957612e596149ca565b1a60f81b828281518110612e6f57612e6f6149ca565b60200101906001600160f81b031916908160001a90535060049490941c93612e9681614d89565b9050612e28565b50831561215a5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016108e1565b60606000612ef983613875565b60010190506000816001600160401b03811115612f1857612f186149f4565b6040519080825280601f01601f191660200182016040528015612f42576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084612f4c57509392505050565b600060143610801590612f955750612f9533611949565b15612fa7575060131936013560601c90565b503390565b612fb46131ab565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612fea612f7e565b6040516001600160a01b03909116815260200160405180910390a1565b61300f61394d565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612fea612f7e565b7fe3bfd6d54b84ccae00cc6cad7783a88be07b38aacd8ade36a87a216bbfed6039600090815260ff6020527f30104a02363e5c98ba717549f6c9fbda80dd783fbe95f052dd2bbb597ed89d91546040516307fa648b60e11b81526994e155dc6bbc332671c360048201526001600160a01b039091169082908290630ff4c91690602401602060405180830381865afa1580156130e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131069190614d46565b613111906001614d76565b604051637b8d56e360e01b81526994e155dc6bbc332671c36004820152602481018290529091506001600160a01b03831690637b8d56e390604401600060405180830381600087803b15801561316657600080fd5b505af115801561317a573d6000803e3d6000fd5b50505050611af27f0541bbed38c2d1fed84a55280fba44929bc1fae876f694e155dc6bbc332671c360001c82613998565b6131b3611a77565b15611c015760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016108e1565b600061215a836001600160a01b038416613a51565b600061086b825490565b610b1561321f8280614da0565b61322c6020850185614da0565b6132396040870187614da0565b6134fe565b6132488282612087565b6114a75760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055613281612f7e565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6060600061215a83613aa0565b6132dc8282612087565b156114a75760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19169055613313612f7e565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600061215a836001600160a01b038416613782565b60006001600160601b038211156133995760405163515c8e4560e11b8152600481018390526024016108e1565b5060a081901b6001600160a01b0383161792915050565b600061215a8383613a51565b6133c4612f7e565b6001600160a01b03166133df6097546001600160a01b031690565b6001600160a01b031614611c015760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108e1565b609780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006134938251612eec565b826040516020016134a5929190614de9565b604051602081830303815290604052805190602001209050919050565b60008060006134d18585613afc565b915091506134de81613b41565b509392505050565b6000818152600183016020526040812054151561215a565b848114158061350d5750848314155b1561353557604051635095ab9d60e11b815260048101869052602481018290526044016108e1565b60005b8581101561207e57600060ff6000878785818110613558576135586149ca565b60209081029290920135835250810191909152604001600020546001600160a01b03169050806135a657604051632939675d60e01b81526001600160a01b03821660048201526024016108e1565b806001600160a01b031663011827fd8989858181106135c7576135c76149ca565b905060200201358686868181106135e0576135e06149ca565b90506020028101906135f29190614e44565b6040518463ffffffff1660e01b815260040161361093929190614e8a565b600060405180830381600087803b15801561362a57600080fd5b505af115801561363e573d6000803e3d6000fd5b505060019093019250613538915050565b600054610100900460ff16611c015760405162461bcd60e51b81526004016108e190614ea4565b600054610100900460ff1661369d5760405162461bcd60e51b81526004016108e190614ea4565b611c01613c8b565b600054610100900460ff166136cc5760405162461bcd60e51b81526004016108e190614ea4565b611c01613cc2565b6114a7828261323e565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6137338282612087565b6114a75761374081613cf5565b61374b836020613d07565b60405160200161375c929190614eef565b60408051601f198184030181529082905262461bcd60e51b82526108e191600401614069565b6000818152600183016020526040812054801561386b5760006137a6600183614c6b565b85549091506000906137ba90600190614c6b565b905081811461381f5760008660000182815481106137da576137da6149ca565b90600052602060002001549050808760000184815481106137fd576137fd6149ca565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061383057613830614f64565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061086b565b600091505061086b565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106138b45772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106138e0576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106138fe57662386f26fc10000830492506010015b6305f5e1008310613916576305f5e100830492506008015b612710831061392a57612710830492506004015b6064831061393c576064830492506002015b600a831061086b5760010192915050565b613955611a77565b611c015760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016108e1565b600063ffffffff4611156139c15760405163e44bb42560e01b81524660048201526024016108e1565b69ffffffffffffffffffff83811611156139fc57604051631c12f49d60e01b815269ffffffffffffffffffff841660048201526024016108e1565b71ffffffffffffffffffffffffffffffffffff821115613a32576040516331e597c760e01b8152600481018390526024016108e1565b5060909190911b69ffffffffffffffffffff60901b164660e01b171790565b6000818152600183016020526040812054613a985750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561086b565b50600061086b565b606081600001805480602002602001604051908101604052809291908181526020018280548015613af057602002820191906000526020600020905b815481526020019060010190808311613adc575b50505050509050919050565b6000808251604103613b325760208301516040840151606085015160001a613b2687828585613e53565b94509450505050613b3a565b506000905060025b9250929050565b6000816004811115613b5557613b55614f7a565b03613b5d5750565b6001816004811115613b7157613b71614f7a565b03613bbe5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016108e1565b6002816004811115613bd257613bd2614f7a565b03613c1f5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016108e1565b6003816004811115613c3357613c33614f7a565b03610b155760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016108e1565b600054610100900460ff16613cb25760405162461bcd60e51b81526004016108e190614ea4565b611c01613cbd612f7e565b613435565b600054610100900460ff16613ce95760405162461bcd60e51b81526004016108e190614ea4565b60c9805460ff19169055565b606061086b6001600160a01b03831660145b60606000613d16836002614d5f565b613d21906002614d76565b6001600160401b03811115613d3857613d386149f4565b6040519080825280601f01601f191660200182016040528015613d62576020820181803683370190505b509050600360fc1b81600081518110613d7d57613d7d6149ca565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613dac57613dac6149ca565b60200101906001600160f81b031916908160001a9053506000613dd0846002614d5f565b613ddb906001614d76565b90505b6001811115612e9d576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613e0f57613e0f6149ca565b1a60f81b828281518110613e2557613e256149ca565b60200101906001600160f81b031916908160001a90535060049490941c93613e4c81614d89565b9050613dde565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613e8a5750600090506003613f0e565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613ede573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613f0757600060019250925050613f0e565b9150600090505b94509492505050565b600060208284031215613f2957600080fd5b81356001600160e01b03198116811461215a57600080fd5b80356001600160a01b0381168114613f5857600080fd5b919050565b600080600080600080600060e0888a031215613f7857600080fd5b8735965060208801359550613f8f60408901613f41565b9450613f9d60608901613f41565b9699959850939660808101359560a0820135955060c0909101359350915050565b600060208284031215613fd057600080fd5b5035919050565b60008060008060808587031215613fed57600080fd5b613ff685613f41565b935061400460208601613f41565b93969395505050506040820135916060013590565b60005b8381101561403457818101518382015260200161401c565b50506000910152565b60008151808452614055816020860160208601614019565b601f01601f19169290920160200192915050565b60208152600061215a602083018461403d565b8015158114610b1557600080fd5b60006020828403121561409c57600080fd5b813561215a8161407c565b60008083601f8401126140b957600080fd5b5081356001600160401b038111156140d057600080fd5b6020830191508360208260051b8501011115613b3a57600080fd5b60008060008060008060008060c0898b03121561410757600080fd5b8835975061411760208a01613f41565b965061412560408a01613f41565b95506060890135945060808901356001600160401b0381111561414757600080fd5b6141538b828c016140a7565b90955093505060a08901356001600160401b0381111561417257600080fd5b61417e8b828c016140a7565b999c989b5096995094979396929594505050565b600080600080600080606087890312156141ab57600080fd5b86356001600160401b038111156141c157600080fd5b6141cd89828a016140a7565b90975095505060208701356001600160401b038111156141ec57600080fd5b6141f889828a016140a7565b90955093505060408701356001600160401b0381111561421757600080fd5b61422389828a016140a7565b979a9699509497509295939492505050565b6000806020838503121561424857600080fd5b82356001600160401b0381111561425e57600080fd5b61426a858286016140a7565b90969095509350505050565b600080600080600080600060e0888a03121561429157600080fd5b87359650602088013595506142a860408901613f41565b94506142b660608901613f41565b93506080880135925060a0880135915060c08801356001600160401b038111156142df57600080fd5b88016060818b0312156142f157600080fd5b8091505092959891949750929550565b6000806040838503121561431457600080fd5b8235915061432460208401613f41565b90509250929050565b602080825282518282018190526000918401906040840190835b81811015614365578351835260209384019390920191600101614347565b509095945050505050565b600080600080600080600080600060e08a8c03121561438e57600080fd5b8935985060208a013597506143a560408b01613f41565b96506143b360608b01613f41565b955060808a0135945060a08a01356001600160401b038111156143d557600080fd5b6143e18c828d016140a7565b90955093505060c08a01356001600160401b0381111561440057600080fd5b61440c8c828d016140a7565b915080935050809150509295985092959850929598565b6000806000806040858703121561443957600080fd5b84356001600160401b0381111561444f57600080fd5b61445b878288016140a7565b90955093505060208501356001600160401b0381111561447a57600080fd5b614486878288016140a7565b95989497509550505050565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b828110156144eb57603f198786030184526144d685835161403d565b945060209384019391909101906001016144ba565b50929695505050505050565b60006020828403121561450957600080fd5b61215a82613f41565b602080825282518282018190526000918401906040840190835b818110156143655783516001600160a01b031683526020938401939092019160010161452c565b600080600080600060a0868803121561456b57600080fd5b8535945061457b60208701613f41565b935061458960408701613f41565b94979396509394606081013594506080013592915050565b60008083601f8401126145b357600080fd5b5081356001600160401b038111156145ca57600080fd5b602083019150836020828501011115613b3a57600080fd5b60008060008060008060a087890312156145fb57600080fd5b86356001600160401b0381111561461157600080fd5b61461d89828a016145a1565b9097509550614630905060208801613f41565b935061463e60408801613f41565b959894975092956060810135946080909101359350915050565b60008060008060008060c0878903121561467157600080fd5b8635955061468160208801613f41565b945061468f60408801613f41565b959894975094956060810135955060808101359460a0909101359350915050565b600080604083850312156146c357600080fd5b50508035926020909101359150565b602080825282518282018190526000918401906040840190835b8181101561436557835115158352602093840193909201916001016146ec565b60008060006040848603121561472157600080fd5b8335925060208401356001600160401b0381111561473e57600080fd5b61474a868287016145a1565b9497909650939450505050565b6000806000806060858703121561476d57600080fd5b843593506020850135925060408501356001600160401b0381111561479157600080fd5b614486878288016145a1565b6000602082840312156147af57600080fd5b81356001600160601b038116811461215a57600080fd5b6000806000806000606086880312156147de57600080fd5b8535945060208601356001600160401b038111156147fb57600080fd5b614807888289016140a7565b90955093505060408601356001600160401b0381111561482657600080fd5b614832888289016140a7565b969995985093965092949392505050565b7f417574686f72697a65206f70657261746f72206163636f756e7420000000000081526000855161487b81601b850160208a01614019565b7f20746f20706572666f726d2067616d65706c617920616374696f6e73206f6e20601b918401918201527f626568616c66206f6620706c61796572206163636f756e742000000000000000603b82015285516148de816054840160208a01614019565b601b81830101915050700103bb4ba341032bc3834b930ba34b7b71607d1b6039820152845161491481604a840160208901614019565b6039818301019150507001039b4b3b732b21030ba10313637b1b59607d1b6011820152835161494a816022840160208801614019565b016022019695505050505050565b81835260006001600160fb1b0383111561497157600080fd5b8260051b80836020870137939093016020019392505050565b8681528560208201526080604082015260006149aa608083018688614958565b82810360608401526149bd818587614958565b9998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b602081526000612a6f602083018486614958565b634e487b7160e01b600052604160045260246000fd5b600060208284031215614a1c57600080fd5b815161215a8161407c565b634e487b7160e01b600052601160045260246000fd5b600060018201614a4f57614a4f614a27565b5060010190565b6001600160a01b0386168152606060208201819052600090614a7b9083018688614958565b8281036040840152614a8e818587614958565b98975050505050505050565b600060208284031215614aac57600080fd5b81516001600160401b03811115614ac257600080fd5b8201601f81018413614ad357600080fd5b80516001600160401b03811115614aec57614aec6149f4565b604051601f8201601f19908116603f011681016001600160401b0381118282101715614b1a57614b1a6149f4565b604052818152828201602001861015614b3257600080fd5b614b43826020830160208601614019565b95945050505050565b60006001600160601b0382166001600160601b038103614b6e57614b6e614a27565b60010192915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008383855260208501945060208460051b8201018360005b86811015614c2d57838303601f19018852813536879003601e19018112614bdf57600080fd5b86016020810190356001600160401b03811115614bfb57600080fd5b803603821315614c0a57600080fd5b614c15858284614b77565b60209a8b019a90955093909301925050600101614bb9565b50909695505050505050565b604081526000614c4d604083018688614958565b8281036020840152614c60818587614ba0565b979650505050505050565b8181038181111561086b5761086b614a27565b60a081526000614c9260a083018a8c614958565b8281036020840152614ca581898b614958565b90508660408401528560608401528281036080840152614cc6818587614ba0565b9b9a5050505050505050505050565b602081526000612a6f602083018486614b77565b848152836020820152606060408201526000614d09606083018486614b77565b9695505050505050565b868152856020820152608060408201526000614d33608083018688614958565b82810360608401526149bd818587614ba0565b600060208284031215614d5857600080fd5b5051919050565b808202811582820484141761086b5761086b614a27565b8082018082111561086b5761086b614a27565b600081614d9857614d98614a27565b506000190190565b6000808335601e19843603018112614db757600080fd5b8301803591506001600160401b03821115614dd157600080fd5b6020019150600581901b3603821315613b3a57600080fd5b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351614e2181601a850160208801614019565b835190830190614e3881601a840160208801614019565b01601a01949350505050565b6000808335601e19843603018112614e5b57600080fd5b8301803591506001600160401b03821115614e7557600080fd5b602001915036819003821315613b3a57600080fd5b838152604060208201526000614b43604083018486614b77565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351614f27816017850160208801614019565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351614f58816028840160208801614019565b01602801949350505050565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052602160045260246000fdfe241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08d3dc2a3a14cbd0cdbf3069fc3927e48506f271b9dda2c21625b93e6a99d3eb53a2646970667358221220625c52ae65b7fb5888e93d51730f37276c4650b64e4dc7631376f4e70187828564736f6c634300081a0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.