Contract Overview
Balance:
0 FTM
FTM Value:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0xbdf4aaf0c3ef0f344800a5b5ccc0b23aa562fa03d44620efa35b6cc3da6fdde3 | 0x60a08060 | 57705468 | 7 days 7 hrs ago | PaintSwap Finance: Deployer | IN | Create: Players | 0 FTM | 0.2528468 |
[ Download CSV Export ]
Latest 1 internal transaction
Parent Txn Hash | Block | From | To | Value | |||
---|---|---|---|---|---|---|---|
0xbdf4aaf0c3ef0f344800a5b5ccc0b23aa562fa03d44620efa35b6cc3da6fdde3 | 57705468 | 7 days 7 hrs ago | PaintSwap Finance: Deployer | Contract Creation | 0 FTM |
[ Download CSV Export ]
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
Players
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 999999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {UnsafeMath} from '../UnsafeMath.sol'; using UnsafeMath for uint256; type U256 is uint256; using { add as +, sub as -, mul as *, div as /, neq as !=, eq as ==, lt as <, lte as <=, gt as >, gte as >= } for U256 global; function add(U256 _u256, U256 _addend) pure returns (U256) { return U256.wrap(U256.unwrap(_u256).add(U256.unwrap(_addend))); } function sub(U256 _u256, U256 _subtrahend) pure returns (U256) { return U256.wrap(U256.unwrap(_u256).sub(U256.unwrap(_subtrahend))); } function mul(U256 _u256, U256 _multiplier) pure returns (U256) { return U256.wrap(U256.unwrap(_u256).mul(U256.unwrap(_multiplier))); } function div(U256 _u256, U256 _divisor) pure returns (U256) { return U256.wrap(U256.unwrap(_u256).div(U256.unwrap(_divisor))); } function neq(U256 _u256, U256 _bounds) pure returns (bool) { return U256.unwrap(_u256) != U256.unwrap(_bounds); } function eq(U256 _u256, U256 _bounds) pure returns (bool) { return U256.unwrap(_u256) == U256.unwrap(_bounds); } function lt(U256 _u256, U256 _bounds) pure returns (bool) { return U256.unwrap(_u256) < U256.unwrap(_bounds); } function lte(U256 _u256, U256 _bounds) pure returns (bool) { return U256.unwrap(_u256) <= U256.unwrap(_bounds); } function gt(U256 _u256, U256 _bounds) pure returns (bool) { return U256.unwrap(_u256) > U256.unwrap(_bounds); } function gte(U256 _u256, U256 _bounds) pure returns (bool) { return U256.unwrap(_u256) >= U256.unwrap(_bounds); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // solhint-disable func-name-mixedcase library UnsafeMath { // UINT256 function add(uint256 _uint256, uint256 _addend) internal pure returns (uint256) { unchecked { return _uint256 + _addend; } } function sub(uint256 _uint256, uint256 _subtrahend) internal pure returns (uint256) { unchecked { return _uint256 - _subtrahend; } } function mul(uint256 a, uint256 _multiplier) internal pure returns (uint256) { unchecked { return a * _multiplier; } } function div(uint256 _uint256, uint256 _divisor) internal pure returns (uint256) { unchecked { uint256 result; // solhint-disable-next-line no-inline-assembly assembly { result := div(_uint256, _divisor) } return result; } } function inc(uint256 _uint256) internal pure returns (uint256) { unchecked { return ++_uint256; } } function dec(uint256 _uint256) internal pure returns (uint256) { unchecked { return --_uint256; } } // INT256 function add(int256 _int256, int256 _addend) internal pure returns (int256) { unchecked { return _int256 + _addend; } } function sub(int256 _int256, int256 _subtrahend) internal pure returns (int256) { unchecked { return _int256 - _subtrahend; } } function mul(int256 _int256, int256 _multiplier) internal pure returns (int256) { unchecked { return _int256 * _multiplier; } } function div(int256 _int256, int256 _divisor) internal pure returns (int256) { unchecked { int256 result; // solhint-disable-next-line no-inline-assembly assembly { result := sdiv(_int256, _divisor) } return result; } } function inc(int256 _int256) internal pure returns (int256) { unchecked { return ++_int256; } } function dec(int256 _int256) internal pure returns (int256) { unchecked { return --_int256; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {UnsafeMath} from './UnsafeMath.sol'; import {U256} from './types/U256.sol'; library UnsafeU256 { using UnsafeMath for uint256; function asU256(int256 _i256) internal pure returns (U256) { return U256.wrap(uint256(_i256)); } function asU256(uint256 _u256) internal pure returns (U256) { return U256.wrap(_u256); } function asUint256(U256 _u256) internal pure returns (uint256) { return U256.unwrap(_u256); } function asUint128(U256 _u256) internal pure returns (uint128) { return uint128(U256.unwrap(_u256)); } function asUint64(U256 _u256) internal pure returns (uint64) { return uint64(U256.unwrap(_u256)); } function asUint32(U256 _u256) internal pure returns (uint32) { return uint32(U256.unwrap(_u256)); } function asUint16(U256 _u256) internal pure returns (uint16) { return uint16(U256.unwrap(_u256)); } function asUint8(U256 _u256) internal pure returns (uint8) { return uint8(U256.unwrap(_u256)); } function asInt256(U256 _u256) internal pure returns (int256) { return int256(U256.unwrap(_u256)); } function asInt128(U256 _u256) internal pure returns (int128) { return int128(int256(U256.unwrap(_u256))); } function asInt64(U256 _u256) internal pure returns (int64) { return int64(int256(U256.unwrap(_u256))); } function asInt32(U256 _u256) internal pure returns (int32) { return int32(int256(U256.unwrap(_u256))); } function asInt16(U256 _u256) internal pure returns (int16) { return int16(int256(U256.unwrap(_u256))); } function asInt8(U256 _u256) internal pure returns (int8) { return int8(int256(U256.unwrap(_u256))); } function inc(U256 _u256) internal pure returns (U256) { return U256.wrap(U256.unwrap(_u256).inc()); } function dec(U256 _u256) internal pure returns (U256) { return U256.wrap(U256.unwrap(_u256).dec()); } function add(U256 _u256, uint256 _addend) internal pure returns (U256) { return U256.wrap(U256.unwrap(_u256).add(_addend)); } function sub(U256 _u256, uint256 _subtrahend) internal pure returns (U256) { return U256.wrap(U256.unwrap(_u256).sub(_subtrahend)); } function mul(U256 _u256, uint256 _multiplier) internal pure returns (U256) { return U256.wrap(U256.unwrap(_u256).mul(_multiplier)); } function div(U256 _u256, uint256 _divisor) internal pure returns (U256) { return U256.wrap(U256.unwrap(_u256).div(_divisor)); } function neq(U256 _u256, uint256 _value) internal pure returns (bool) { return U256.unwrap(_u256) != _value; } function eq(U256 _u256, uint256 _value) internal pure returns (bool) { return U256.unwrap(_u256) == _value; } function gt(U256 _u256, uint256 _value) internal pure returns (bool) { return U256.unwrap(_u256) > _value; } function gte(U256 _u256, uint256 _value) internal pure returns (bool) { return U256.unwrap(_u256) >= _value; } function lt(U256 _u256, uint256 _value) internal pure returns (bool) { return U256.unwrap(_u256) < _value; } function lte(U256 _u256, uint256 _value) internal pure returns (bool) { return U256.unwrap(_u256) <= _value; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface VRFCoordinatorV2Interface { /** * @notice Get configuration relevant for making requests * @return minimumRequestConfirmations global min for request confirmations * @return maxGasLimit global max for request gas limit * @return s_provingKeyHashes list of registered key hashes */ function getRequestConfig() external view returns ( uint16, uint32, bytes32[] memory ); /** * @notice Request a set of random words. * @param keyHash - Corresponds to a particular oracle job which uses * that key for generating the VRF proof. Different keyHash's have different gas price * ceilings, so you can select a specific one to bound your maximum per request cost. * @param subId - The ID of the VRF subscription. Must be funded * with the minimum subscription balance required for the selected keyHash. * @param minimumRequestConfirmations - How many blocks you'd like the * oracle to wait before responding to the request. See SECURITY CONSIDERATIONS * for why you may want to request more. The acceptable range is * [minimumRequestBlockConfirmations, 200]. * @param callbackGasLimit - How much gas you'd like to receive in your * fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords * may be slightly less than this amount because of gas used calling the function * (argument decoding etc.), so you may need to request slightly more than you expect * to have inside fulfillRandomWords. The acceptable range is * [0, maxGasLimit] * @param numWords - The number of uint256 random values you'd like to receive * in your fulfillRandomWords callback. Note these numbers are expanded in a * secure way by the VRFCoordinator from a single random value supplied by the oracle. * @return requestId - A unique identifier of the request. Can be used to match * a request to a response in fulfillRandomWords. */ function requestRandomWords( bytes32 keyHash, uint64 subId, uint16 minimumRequestConfirmations, uint32 callbackGasLimit, uint32 numWords ) external returns (uint256 requestId); /** * @notice Create a VRF subscription. * @return subId - A unique subscription id. * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. * @dev Note to fund the subscription, use transferAndCall. For example * @dev LINKTOKEN.transferAndCall( * @dev address(COORDINATOR), * @dev amount, * @dev abi.encode(subId)); */ function createSubscription() external returns (uint64 subId); /** * @notice Get a VRF subscription. * @param subId - ID of the subscription * @return balance - LINK balance of the subscription in juels. * @return reqCount - number of requests for this subscription, determines fee tier. * @return owner - owner of the subscription. * @return consumers - list of consumer address which are able to use this subscription. */ function getSubscription(uint64 subId) external view returns ( uint96 balance, uint64 reqCount, address owner, address[] memory consumers ); /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @param newOwner - proposed new owner of the subscription */ function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external; /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @dev will revert if original owner of subId has * not requested that msg.sender become the new owner. */ function acceptSubscriptionOwnerTransfer(uint64 subId) external; /** * @notice Add a consumer to a VRF subscription. * @param subId - ID of the subscription * @param consumer - New consumer which can use the subscription */ function addConsumer(uint64 subId, address consumer) external; /** * @notice Remove a consumer from a VRF subscription. * @param subId - ID of the subscription * @param consumer - Consumer to remove from the subscription */ function removeConsumer(uint64 subId, address consumer) external; /** * @notice Cancel a subscription * @param subId - ID of the subscription * @param to - Where to send the remaining LINK to */ function cancelSubscription(uint64 subId, address to) external; /* * @notice Check to see if there exists a request commitment consumers * for all consumers and keyhashes for a given sub. * @param subId - ID of the subscription * @return true if there exists at least one unfulfilled request for the subscription, false * otherwise. */ function pendingRequestExists(uint64 subId) external view returns (bool); }
// 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.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } /** * @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 (last updated v4.8.1) (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 Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @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 (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @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) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155Upgradeable.sol"; import "./IERC1155ReceiverUpgradeable.sol"; import "./extensions/IERC1155MetadataURIUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable { using AddressUpgradeable for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ function __ERC1155_init(string memory uri_) internal onlyInitializing { __ERC1155_init_unchained(uri_); } function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC1155Upgradeable).interfaceId || interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } /** * @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[47] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155Upgradeable.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// 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.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); }
// 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 (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(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 (last updated v4.7.0) (utils/Base64.sol) pragma solidity ^0.8.0; /** * @dev Provides a set of functions to operate with Base64 strings. * * _Available since v4.5._ */ library Base64 { /** * @dev Base64 Encoding/Decoding Table */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal pure returns (string memory) { /** * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol */ if (data.length == 0) return ""; // Loads the table into memory string memory table = _TABLE; // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter // and split into 4 numbers of 6 bits. // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up // - `data.length + 2` -> Round up // - `/ 3` -> Number of 3-bytes chunks // - `4 *` -> 4 characters for each chunk string memory result = new string(4 * ((data.length + 2) / 3)); /// @solidity memory-safe-assembly assembly { // Prepare the lookup table (skip the first "length" byte) let tablePtr := add(table, 1) // Prepare result pointer, jump over length let resultPtr := add(result, 32) // Run over the input, 3 bytes at a time for { let dataPtr := data let endPtr := add(data, mload(data)) } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 bytes (18 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F which is the number of // the previous character in the ASCII table prior to the Base64 Table // The result is then added to the table to get the character to write, // and finally write it in the result pointer but with a left shift // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1) // Advance } // When data `bytes` is not exactly 3 bytes long // it is padded with `=` characters at the end switch mod(mload(data), 3) case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) } case 2 { mstore8(sub(resultPtr, 1), 0x3d) } } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata( bytes32[] calldata proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// 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.5.0) (utils/Multicall.sol) pragma solidity ^0.8.0; import "./Address.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ abstract contract Multicall { /** * @dev Receives and executes a batch of function calls on this contract. */ function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionDelegateCall(address(this), data[i]); } return results; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (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 pragma solidity ^0.8.19; import {Skill, Attire, CombatStyle} from "./players.sol"; enum ActionQueueStatus { NONE, APPEND, KEEP_LAST_IN_PROGRESS } // This is effectively a ratio to produce 1 of outputTokenId. // Fixed based available actions that can be undertaken for an action struct ActionChoice { Skill skill; uint32 minXP; uint32 diff; uint32 rate; // rate of output produced per hour (base 100) 2 decimals uint16 xpPerHour; uint16 inputTokenId1; uint8 num1; uint16 inputTokenId2; uint8 num2; uint16 inputTokenId3; uint8 num3; uint16 outputTokenId; // Always num of 1 uint8 outputNum; // Not used yet } // The user chooses these struct QueuedAction { // Keep this first Attire attire; uint16 actionId; uint16 regenerateId; // Food (combat), maybe something for non-combat later uint16 choiceId; // Melee/Arrow/Magic (combat), logs, ore (non-combat) uint16 choiceId1; // Reserved (TBD) uint16 choiceId2; // Reserved (TBD) uint16 rightHandEquipmentTokenId; // Axe/Sword/bow, can be empty uint16 leftHandEquipmentTokenId; // Shield, can be empty uint24 timespan; // How long to queue the action for CombatStyle combatStyle; // specific style of combat, can also be used uint40 startTime; // Filled in by the function bool isValid; // If we still have the item, TODO: Not used yet // bool reusePrev; // If true, then the previous queued action attire is reused? // 9 bytes left } struct ActionInfo { Skill skill; bool isAvailable; bool isDynamic; bool actionChoiceRequired; // If true, then the user must choose an action choice uint16 xpPerHour; uint16 numSpawn; // Mostly for combat, capped respawn rate for xp/drops uint32 minXP; uint16 handItemTokenIdRangeMin; // Inclusive uint16 handItemTokenIdRangeMax; // Inclusive }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; uint16 constant NONE = 0; // 1 - 255 (head) uint16 constant HEAD_BASE = 1; uint16 constant BRONZE_HELMET = HEAD_BASE; uint16 constant IRON_HELMET = HEAD_BASE + 1; uint16 constant MITHRIL_HELMET = HEAD_BASE + 2; uint16 constant ADAMANTINE_HELMET = HEAD_BASE + 3; uint16 constant RUNITE_HELMET = HEAD_BASE + 4; uint16 constant TITANIUM_HELMET = HEAD_BASE + 5; uint16 constant ORICHALCUM_HELMET = HEAD_BASE + 6; uint16 constant NATUOW_HOOD = HEAD_BASE + 7; uint16 constant BAT_WING_HAT = HEAD_BASE + 8; uint16 constant NATURE_MASK = HEAD_BASE + 9; uint16 constant APPRENTICE_HAT = HEAD_BASE + 10; uint16 constant MAGE_HOOD = HEAD_BASE + 11; uint16 constant SORCERER_HAT = HEAD_BASE + 12; uint16 constant SEERS_HOOD = HEAD_BASE + 13; uint16 constant SHAMAN_HOOD = HEAD_BASE + 14; uint16 constant MASTER_HAT = HEAD_BASE + 15; uint16 constant HEAD_MAX = HEAD_BASE + 254; // Inclusive // 257 - 511 (neck) uint16 constant NECK_BASE = 257; uint16 constant SAPPHIRE_AMULET = NECK_BASE; uint16 constant EMERALD_AMULET = NECK_BASE + 1; uint16 constant RUBY_AMULET = NECK_BASE + 2; uint16 constant AMETHYST_AMULET = NECK_BASE + 3; uint16 constant DIAMOND_AMULET = NECK_BASE + 4; uint16 constant DRAGONSTONE_AMULET = NECK_BASE + 5; uint16 constant NECK_MAX = NECK_BASE + 254; // 513 - 767 (body) uint16 constant BODY_BASE = 513; uint16 constant BRONZE_ARMOR = BODY_BASE; uint16 constant IRON_ARMOR = BODY_BASE + 1; uint16 constant MITHRIL_ARMOR = BODY_BASE + 2; uint16 constant ADAMANTINE_ARMOR = BODY_BASE + 3; uint16 constant RUNITE_ARMOR = BODY_BASE + 4; uint16 constant TITANIUM_ARMOR = BODY_BASE + 5; uint16 constant ORICHALCUM_ARMOR = BODY_BASE + 6; uint16 constant NATUOW_BODY = BODY_BASE + 7; uint16 constant BAT_WING_BODY = BODY_BASE + 8; uint16 constant NATURE_BODY = BODY_BASE + 9; uint16 constant APPRENTICE_BODY = BODY_BASE + 10; uint16 constant MAGE_BODY = BODY_BASE + 11; uint16 constant SORCERER_BODY = BODY_BASE + 12; uint16 constant SEERS_BODY = BODY_BASE + 13; uint16 constant SHAMAN_BODY = BODY_BASE + 14; uint16 constant MASTER_BODY = BODY_BASE + 15; uint16 constant BODY_MAX = BODY_BASE + 254; // 769 - 1023 (arms) uint16 constant ARMS_BASE = 769; uint16 constant BRONZE_GAUNTLETS = ARMS_BASE; uint16 constant IRON_GAUNTLETS = ARMS_BASE + 1; uint16 constant MITHRIL_GAUNTLETS = ARMS_BASE + 2; uint16 constant ADAMANTINE_GAUNTLETS = ARMS_BASE + 3; uint16 constant RUNITE_GAUNTLETS = ARMS_BASE + 4; uint16 constant TITANIUM_GAUNTLETS = ARMS_BASE + 5; uint16 constant ORICHALCUM_GAUNTLETS = ARMS_BASE + 6; uint16 constant NATUOW_BRACERS = ARMS_BASE + 7; uint16 constant BAT_WING_BRACERS = ARMS_BASE + 8; uint16 constant NATURE_BRACERS = ARMS_BASE + 9; uint16 constant APPRENTICE_GAUNTLETS = ARMS_BASE + 10; uint16 constant MAGE_BRACERS = ARMS_BASE + 11; uint16 constant SORCERER_GAUNTLETS = ARMS_BASE + 12; uint16 constant SEERS_BRACERS = ARMS_BASE + 13; uint16 constant SHAMAN_GAUNTLETS = ARMS_BASE + 14; uint16 constant MASTER_BRACERS = ARMS_BASE + 15; uint16 constant ARMS_MAX = ARMS_BASE + 254; // 1025 - 1279 (legs) uint16 constant LEGS_BASE = 1025; uint16 constant BRONZE_TASSETS = LEGS_BASE; uint16 constant IRON_TASSETS = LEGS_BASE + 1; uint16 constant MITHRIL_TASSETS = LEGS_BASE + 2; uint16 constant ADAMANTINE_TASSETS = LEGS_BASE + 3; uint16 constant RUNITE_TASSETS = LEGS_BASE + 4; uint16 constant TITANIUM_TASSETS = LEGS_BASE + 5; uint16 constant ORICHALCUM_TASSETS = LEGS_BASE + 6; uint16 constant NATUOW_TASSETS = LEGS_BASE + 7; uint16 constant BAT_WING_TROUSERS = LEGS_BASE + 8; uint16 constant NATURE_TROUSERS = LEGS_BASE + 9; uint16 constant APPRENTICE_TROUSERS = LEGS_BASE + 10; uint16 constant MAGE_TROUSERS = LEGS_BASE + 11; uint16 constant SORCERER_TROUSERS = LEGS_BASE + 12; uint16 constant SEERS_TROUSERS = LEGS_BASE + 13; uint16 constant SHAMAN_TROUSERS = LEGS_BASE + 14; uint16 constant MASTER_TROUSERS = LEGS_BASE + 15; uint16 constant LEGS_MAX = LEGS_BASE + 254; // 1281 - 1535 (boots) uint16 constant BOOTS_BASE = 1281; uint16 constant BRONZE_BOOTS = BOOTS_BASE; uint16 constant IRON_BOOTS = BOOTS_BASE + 1; uint16 constant MITHRIL_BOOTS = BOOTS_BASE + 2; uint16 constant ADAMANTINE_BOOTS = BOOTS_BASE + 3; uint16 constant RUNITE_BOOTS = BOOTS_BASE + 4; uint16 constant TITANIUM_BOOTS = BOOTS_BASE + 5; uint16 constant ORICHALCUM_BOOTS = BOOTS_BASE + 6; uint16 constant NATUOW_BOOTS = BOOTS_BASE + 7; uint16 constant BAT_WING_BOOTS = BOOTS_BASE + 8; uint16 constant NATURE_BOOTS = BOOTS_BASE + 9; uint16 constant APPRENTICE_BOOTS = BOOTS_BASE + 10; uint16 constant MAGE_BOOTS = BOOTS_BASE + 11; uint16 constant SORCERER_BOOTS = BOOTS_BASE + 12; uint16 constant SEERS_BOOTS = BOOTS_BASE + 13; uint16 constant SHAMAN_BOOTS = BOOTS_BASE + 14; uint16 constant MASTER_BOOTS = BOOTS_BASE + 15; uint16 constant BOOTS_MAX = BOOTS_BASE + 254; // 1536 - 1791 spare(1) // 1792 - 2047 spare(2) // Combat (right arm) (2048 - 2303) uint16 constant COMBAT_BASE = 2048; // Melee uint16 constant SWORD_BASE = COMBAT_BASE; uint16 constant BRONZE_SWORD = SWORD_BASE; uint16 constant IRON_SWORD = COMBAT_BASE + 1; uint16 constant MITHRIL_SWORD = COMBAT_BASE + 2; uint16 constant ADAMANTINE_SWORD = COMBAT_BASE + 3; uint16 constant RUNITE_SWORD = COMBAT_BASE + 4; uint16 constant TITANIUM_SWORD = COMBAT_BASE + 5; uint16 constant ORICHALCUM_SWORD = COMBAT_BASE + 6; uint16 constant SWORD_MAX = SWORD_BASE + 49; // Magic uint16 constant STAFF_BASE = COMBAT_BASE + 50; uint16 constant TOTEM_STAFF = STAFF_BASE; uint16 constant SAPPHIRE_STAFF = STAFF_BASE + 1; uint16 constant EMERALD_STAFF = STAFF_BASE + 2; uint16 constant RUBY_STAFF = STAFF_BASE + 3; uint16 constant AMETHYST_STAFF = STAFF_BASE + 4; uint16 constant DIAMOND_STAFF = STAFF_BASE + 5; uint16 constant DRAGONSTONE_STAFF = STAFF_BASE + 6; uint16 constant STAFF_MAX = STAFF_BASE + 49; // Ranged uint16 constant BOW_BASE = COMBAT_BASE + 100; uint16 constant BOW_MAX = BOW_BASE + 49; // Shields (left arm) uint16 constant SHIELD_BASE = COMBAT_BASE + 150; uint16 constant BRONZE_SHIELD = SHIELD_BASE; uint16 constant IRON_SHIELD = SHIELD_BASE + 1; uint16 constant MITHRIL_SHIELD = SHIELD_BASE + 2; uint16 constant ADAMANTINE_SHIELD = SHIELD_BASE + 3; uint16 constant RUNITE_SHIELD = SHIELD_BASE + 4; uint16 constant TITANIUM_SHIELD = SHIELD_BASE + 5; uint16 constant ORICHALCUM_SHIELD = SHIELD_BASE + 6; uint16 constant SHIELD_MAX = SHIELD_BASE + 49; uint16 constant COMBAT_MAX = COMBAT_BASE + 255; // Mining (2560 - 2815) uint16 constant MINING_BASE = 2560; uint16 constant BRONZE_PICKAXE = MINING_BASE; uint16 constant IRON_PICKAXE = MINING_BASE + 1; uint16 constant MITHRIL_PICKAXE = MINING_BASE + 2; uint16 constant ADAMANTINE_PICKAXE = MINING_BASE + 3; uint16 constant RUNITE_PICKAXE = MINING_BASE + 4; uint16 constant TITANIUM_PICKAXE = MINING_BASE + 5; uint16 constant ORICHALCUM_PICKAXE = MINING_BASE + 6; uint16 constant MINING_MAX = MINING_BASE + 255; // Woodcutting (2816 - 3071) uint16 constant WOODCUTTING_BASE = 2816; uint16 constant BRONZE_AXE = WOODCUTTING_BASE; uint16 constant IRON_AXE = WOODCUTTING_BASE + 1; uint16 constant MITHRIL_AXE = WOODCUTTING_BASE + 2; uint16 constant ADAMANTINE_AXE = WOODCUTTING_BASE + 3; uint16 constant RUNITE_AXE = WOODCUTTING_BASE + 4; uint16 constant TITANIUM_AXE = WOODCUTTING_BASE + 5; uint16 constant ORICHALCUM_AXE = WOODCUTTING_BASE + 6; uint16 constant WOODCUTTING_MAX = WOODCUTTING_BASE + 255; // Fishing (3072 - 3327) uint16 constant FISHING_BASE = 3072; uint16 constant NET_STICK = FISHING_BASE; uint16 constant MEDIUM_NET = FISHING_BASE + 1; uint16 constant WOOD_FISHING_ROD = FISHING_BASE + 2; uint16 constant TITANIUM_FISHING_ROD = FISHING_BASE + 3; uint16 constant HARPOON = FISHING_BASE + 4; uint16 constant LARGE_NET = FISHING_BASE + 5; uint16 constant MAGIC_NET = FISHING_BASE + 6; uint16 constant CAGE = FISHING_BASE + 7; uint16 constant FISHING_MAX = FISHING_BASE + 255; // Firemaking (3328 - 3583) uint16 constant FIRE_BASE = 3328; uint16 constant MAGIC_FIRE_STARTER = FIRE_BASE; uint16 constant FIRE_MAX = FIRE_BASE + 255; // Smithing (none needed) // Crafting (none needed) // Cooking (none needed) // 10000+ it'a all other items // Bars uint16 constant BAR_BASE = 10240; // (256 * 40) uint16 constant BRONZE_BAR = BAR_BASE; uint16 constant IRON_BAR = BAR_BASE + 1; uint16 constant MITHRIL_BAR = BAR_BASE + 2; uint16 constant ADAMANTINE_BAR = BAR_BASE + 3; uint16 constant RUNITE_BAR = BAR_BASE + 4; uint16 constant TITANIUM_BAR = BAR_BASE + 5; uint16 constant ORICHALCUM_BAR = BAR_BASE + 6; uint16 constant BAR_MAX = BAR_BASE + 255; // Logs uint16 constant LOG_BASE = 10496; uint16 constant LOG = LOG_BASE; uint16 constant OAK_LOG = LOG_BASE + 1; uint16 constant WILLOW_LOG = LOG_BASE + 2; uint16 constant MAPLE_LOG = LOG_BASE + 3; uint16 constant REDWOOD_LOG = LOG_BASE + 4; uint16 constant MAGICAL_LOG = LOG_BASE + 5; uint16 constant ASH_LOG = LOG_BASE + 6; uint16 constant ENCHANTED_LOG = LOG_BASE + 7; uint16 constant LIVING_LOG = LOG_BASE + 8; uint16 constant LOG_MAX = LOG_BASE + 255; // Fish uint16 constant RAW_FISH_BASE = 10752; uint16 constant RAW_MINNUS = RAW_FISH_BASE; uint16 constant RAW_BLEKK = RAW_FISH_BASE + 1; uint16 constant RAW_SKRIMP = RAW_FISH_BASE + 2; uint16 constant RAW_FEOLA = RAW_FISH_BASE + 3; uint16 constant RAW_ANCHO = RAW_FISH_BASE + 4; uint16 constant RAW_TROUT = RAW_FISH_BASE + 5; uint16 constant RAW_ROJJA = RAW_FISH_BASE + 6; uint16 constant RAW_BOWFISH = RAW_FISH_BASE + 7; uint16 constant RAW_GOLDFISH = RAW_FISH_BASE + 8; uint16 constant RAW_MYSTY_BLUE = RAW_FISH_BASE + 9; uint16 constant RAW_FLITFISH = RAW_FISH_BASE + 10; uint16 constant RAW_RAZORFISH = RAW_FISH_BASE + 11; uint16 constant RAW_QUAFFER = RAW_FISH_BASE + 12; uint16 constant RAW_ROXA = RAW_FISH_BASE + 13; uint16 constant RAW_AZACUDDA = RAW_FISH_BASE + 14; uint16 constant RAW_STONECLAW = RAW_FISH_BASE + 15; uint16 constant RAW_CRUSKAN = RAW_FISH_BASE + 16; uint16 constant RAW_CHODFISH = RAW_FISH_BASE + 17; uint16 constant RAW_DOUBTFISH = RAW_FISH_BASE + 18; uint16 constant RAW_ROSEFIN = RAW_FISH_BASE + 19; uint16 constant RAW_SPHINX_FISH = RAW_FISH_BASE + 20; uint16 constant RAW_SHAW = RAW_FISH_BASE + 21; uint16 constant RAW_VANISHING_PERCH = RAW_FISH_BASE + 22; uint16 constant RAW_VIPER_BASS = RAW_FISH_BASE + 23; uint16 constant RAW_WATER_SERPENT = RAW_FISH_BASE + 24; uint16 constant RAW_WHISKFIN = RAW_FISH_BASE + 25; uint16 constant RAW_MHARA = RAW_FISH_BASE + 26; uint16 constant RAW_GRAN_SQUIN = RAW_FISH_BASE + 27; uint16 constant RAW_LANCER = RAW_FISH_BASE + 28; uint16 constant RAW_OCTACLE = RAW_FISH_BASE + 29; uint16 constant RAW_DRAGONFISH = RAW_FISH_BASE + 30; uint16 constant RAW_YERESPATUM = RAW_FISH_BASE + 31; uint16 constant RAW_FISH_MAX = RAW_FISH_BASE + 255; // Cooked fish uint16 constant COOKED_FISH_BASE = 11008; uint16 constant COOKED_MINNUS = COOKED_FISH_BASE; uint16 constant COOKED_BLEKK = COOKED_FISH_BASE + 1; uint16 constant COOKED_SKRIMP = COOKED_FISH_BASE + 2; uint16 constant COOKED_FEOLA = COOKED_FISH_BASE + 3; uint16 constant COOKED_ANCHO = COOKED_FISH_BASE + 4; uint16 constant COOKED_TROUT = COOKED_FISH_BASE + 5; uint16 constant COOKED_ROJJA = COOKED_FISH_BASE + 6; uint16 constant COOKED_BOWFISH = COOKED_FISH_BASE + 7; uint16 constant COOKED_GOLDFISH = COOKED_FISH_BASE + 8; uint16 constant COOKED_MYSTY_BLUE = COOKED_FISH_BASE + 9; uint16 constant COOKED_FLITFISH = COOKED_FISH_BASE + 10; uint16 constant COOKED_RAZORFISH = COOKED_FISH_BASE + 11; uint16 constant COOKED_QUAFFER = COOKED_FISH_BASE + 12; uint16 constant COOKED_ROXA = COOKED_FISH_BASE + 13; uint16 constant COOKED_AZACUDDA = COOKED_FISH_BASE + 14; uint16 constant COOKED_STONECLAW = COOKED_FISH_BASE + 15; uint16 constant COOKED_CRUSKAN = COOKED_FISH_BASE + 16; uint16 constant COOKED_CHODFISH = COOKED_FISH_BASE + 17; uint16 constant COOKED_DOUBTFISH = COOKED_FISH_BASE + 18; uint16 constant COOKED_ROSEFIN = COOKED_FISH_BASE + 19; uint16 constant COOKED_SPHINX_FISH = COOKED_FISH_BASE + 20; uint16 constant COOKED_SHAW = COOKED_FISH_BASE + 21; uint16 constant COOKED_VANISHING_PERCH = COOKED_FISH_BASE + 22; uint16 constant COOKED_VIPER_BASS = COOKED_FISH_BASE + 23; uint16 constant COOKED_WATER_SERPENT = COOKED_FISH_BASE + 24; uint16 constant COOKED_WHISKFIN = COOKED_FISH_BASE + 25; uint16 constant COOKED_MHARA = COOKED_FISH_BASE + 26; uint16 constant COOKED_GRAN_SQUIN = COOKED_FISH_BASE + 27; uint16 constant COOKED_LANCER = COOKED_FISH_BASE + 28; uint16 constant COOKED_OCTACLE = COOKED_FISH_BASE + 29; uint16 constant COOKED_DRAGONFISH = COOKED_FISH_BASE + 30; uint16 constant COOKED_YERESPATUM = COOKED_FISH_BASE + 31; uint16 constant COOKED_FISH_MAX = COOKED_FISH_BASE + 255; // Farming uint16 constant FARMING_BASE = 11264; uint16 constant BONEMEAL = FARMING_BASE; uint16 constant FARMING_MAX = FARMING_BASE + 255; // Mining uint16 constant ORE_BASE = 11520; uint16 constant COPPER_ORE = ORE_BASE; uint16 constant TIN_ORE = ORE_BASE + 1; uint16 constant IRON_ORE = ORE_BASE + 2; uint16 constant SAPPHIRE = ORE_BASE + 3; uint16 constant COAL_ORE = ORE_BASE + 4; uint16 constant EMERALD = ORE_BASE + 5; uint16 constant MITHRIL_ORE = ORE_BASE + 6; uint16 constant RUBY = ORE_BASE + 7; uint16 constant ADAMANTINE_ORE = ORE_BASE + 8; uint16 constant AMETHYST = ORE_BASE + 9; uint16 constant DIAMOND = ORE_BASE + 10; uint16 constant RUNITE_ORE = ORE_BASE + 11; uint16 constant DRAGONSTONE = ORE_BASE + 12; uint16 constant TITANIUM_ORE = ORE_BASE + 13; uint16 constant ORICHALCUM_ORE = ORE_BASE + 14; uint16 constant ORE_MAX = ORE_BASE + 255; // Arrows uint16 constant ARROW_BASE = 11776; uint16 constant BRONZE_ARROW = ARROW_BASE; uint16 constant ARROW_MAX = ARROW_BASE + 255; // Scrolls uint16 constant SCROLL_BASE = 12032; uint16 constant SHADOW_SCROLL = SCROLL_BASE; uint16 constant NATURE_SCROLL = SCROLL_BASE + 1; uint16 constant AQUA_SCROLL = SCROLL_BASE + 2; uint16 constant HELL_SCROLL = SCROLL_BASE + 3; uint16 constant AIR_SCROLL = SCROLL_BASE + 4; uint16 constant BARRAGE_SCROLL = SCROLL_BASE + 5; uint16 constant FREEZE_SCROLL = SCROLL_BASE + 6; uint16 constant ANCIENT_SCROLL = SCROLL_BASE + 7; uint16 constant SCROLL_MAX = SCROLL_BASE + 255; // Free interval uint16 constant NOT_USED_BASE = 12544; uint16 constant NOT_USED_MAX = 12799; // Boosts uint16 constant BOOST_BASE = 12800; uint16 constant COMBAT_BOOST = BOOST_BASE; uint16 constant XP_BOOST = BOOST_BASE + 1; uint16 constant GATHERING_BOOST = BOOST_BASE + 2; uint16 constant SKILL_BOOST = BOOST_BASE + 3; uint16 constant ABSENCE_BOOST = BOOST_BASE + 4; uint16 constant PRAY_TO_THE_BEARDIE = BOOST_BASE + 5; uint16 constant GO_OUTSIDE = BOOST_BASE + 6; uint16 constant RAINING_RARES = BOOST_BASE + 7; uint16 constant BOOST_MAX = 13055; // MISC uint16 constant MISC_BASE = 65535; uint16 constant MYSTERY_BOX = MISC_BASE; uint16 constant RAID_PASS = MISC_BASE - 1; uint16 constant NATUOW_HIDE = MISC_BASE - 2; uint16 constant NATUOW_LEATHER = MISC_BASE - 3; uint16 constant SMALL_BONE = MISC_BASE - 4; uint16 constant MEDIUM_BONE = MISC_BASE - 5; uint16 constant LARGE_BONE = MISC_BASE - 6; uint16 constant DRAGON_BONE = MISC_BASE - 7; uint16 constant DRAGON_TEETH = MISC_BASE - 8; uint16 constant DRAGON_SCALE = MISC_BASE - 9; uint16 constant POISON = MISC_BASE - 10; uint16 constant STRING = MISC_BASE - 11; uint16 constant ROPE = MISC_BASE - 12; uint16 constant LEAF_FRAGMENTS = MISC_BASE - 13; uint16 constant VENOM_POUCH = MISC_BASE - 14; uint16 constant BAT_WING = MISC_BASE - 15; uint16 constant BAT_WING_PATCH = MISC_BASE - 16; uint16 constant THREAD_NEEDLE = MISC_BASE - 17; uint16 constant LOSSUTH_TEETH = MISC_BASE - 18; uint16 constant LOSSUTH_SCALE = MISC_BASE - 19; uint16 constant FEATHER = MISC_BASE - 20; uint16 constant QUARTZ_INFUSED_FEATHER = MISC_BASE - 21; uint16 constant BARK_CHUNK = MISC_BASE - 22; uint16 constant APPRENTICE_FABRIC = MISC_BASE - 23; uint16 constant MAGE_FABRIC = MISC_BASE - 24; uint16 constant SORCERER_FABRIC = MISC_BASE - 25; uint16 constant SEERS_FABRIC = MISC_BASE - 26; uint16 constant SHAMAN_FABRIC = MISC_BASE - 27; uint16 constant MASTER_FABRIC = MISC_BASE - 28; uint16 constant DRAGON_KEY = MISC_BASE - 29; uint16 constant BONE_KEY = MISC_BASE - 30; uint16 constant NATURE_KEY = MISC_BASE - 31; uint16 constant AQUA_KEY = MISC_BASE - 32; uint16 constant BLUECANAR = MISC_BASE - 33; uint16 constant ANURGAT = MISC_BASE - 34; uint16 constant RUFARUM = MISC_BASE - 35; uint16 constant WHITE_DEATH_SPORE = MISC_BASE - 36; uint16 constant ENCHANTED_ACORN = MISC_BASE - 37; uint16 constant ACORN_PATCH = MISC_BASE - 38; uint16 constant MISC_MIN = 32768;
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {QueuedAction} from "./actions.sol"; // 3 bytes for each level. 0x000000 is the first level, 0x000054 is the second, etc. bytes constant XP_BYTES = hex"0000000000540000AE00010E0001760001E600025E0002DE0003680003FD00049B0005460005FC0006C0000792000873000964000A66000B7B000CA4000DE1000F360010A20012290013CB00158B00176B00196E001B94001DE200205A0022FF0025D50028DD002C1E002F99003354003752003B9A004030004519004A5C004FFF005609005C81006370006ADD0072D1007B57008479008E420098BE00A3F900B00200BCE700CAB800D98600E96300FA62010C9901201D013506014B6F016373017D2E0198C101B64E01D5F801F7E6021C4302433B026CFD0299BE02C9B302FD1803342B036F3203AE7303F23D043AE30488BE04DC2F05359B05957005FC24066A3606E02D075E9907E61608774C0912EB09B9B40A6C740B2C060BF9560CD5610DC1340EBDF30FCCD410EF24"; enum EquipPosition { NONE, // Used as a sentinel value HEAD, NECK, BODY, ARMS, LEGS, BOOTS, SPARE1, SPARE2, LEFT_HAND, RIGHT_HAND, BOTH_HANDS, ARROW_SATCHEL, MAGIC_BAG, FOOD, AUX, // wood, seeds etc.. BOOST_VIAL, NO_POSITION } // Equipment (leave at the bottom to allow for further ones) struct Attire { uint16 head; // tokenId for the head (1 - 255) uint16 neck; // tokenId for the neck (256 - 511) (256 * i -> 256 * (i + 1)) uint16 body; uint16 arms; uint16 legs; uint16 boots; uint16 ring; uint16 reserved1; uint128 queueId; // Just here for packing purposes } struct CombatStats { // From skill points int16 melee; int16 magic; int16 range; int16 health; // These include equipment int16 meleeDefence; int16 magicDefence; int16 rangeDefence; } struct Player { // Combat levels, (Cached from skill points so this doesn't need to be calculated every combat) int16 melee; int16 magic; int16 range; int16 defence; int16 health; uint8 version; // This is used in case we want to do some migration of old characters, like halt them at level 30 from gaining XP uint160 totalXP; // TODO: Can be up to 7 QueuedAction[] actionQueue; } enum BoostType { NONE, ANY_XP, COMBAT_XP, NON_COMBAT_XP, GATHERING, ABSENCE } enum CombatStyle { NONE, MELEE, RANGE, MAGIC, MELEE_DEFENCE, RANGE_DEFENCE, MAGIC_DEFENCE } struct Equipment { uint16 itemTokenId; uint24 amount; } // For optimization purposes this contains a few data items, and everything except combat stats (although it could fit?) struct Item { EquipPosition equipPosition; // Can it be transferred? bool isTransferable; // Food uint16 healthRestored; // Boost vial BoostType boostType; uint16 boostValue; // Varies, could be the % increase uint24 boostDuration; // How long the effect of the boost last // Combat stats int16 melee; int16 magic; int16 range; int16 meleeDefence; int16 magicDefence; int16 rangeDefence; int16 health; // Minimum requirements in this skill to use this item (can be NONE) Skill skill; uint32 minXP; // Noncombat skill Skill skill1; int16 skillDiff1; } struct PlayerBoostInfo { uint40 startTime; uint24 duration; uint16 val; uint16 itemTokenId; // Get the effect of it BoostType boostType; } enum Skill { NONE, COMBAT, // This is a helper which incorporates all combat skills, attack <-> magic, defence, health etc MELEE, RANGE, MAGIC, DEFENCE, HEALTH, MINING, WOODCUTTING, FISHING, SMITHING, THIEVING, CRAFTING, COOKING, FIREMAKING } struct AvatarInfo { bytes32 name; string description; string imageURI; Skill[2] startSkills; // Can be NONE }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {Equipment} from "./players.sol"; // Loot struct ActionReward { uint16 itemTokenId; uint24 rate; // num per hour, base 100 (2 decimals) or percentage chance } struct PendingRandomReward { uint16 actionId; uint128 queueId; uint40 timestamp; uint24 elapsedTime; } struct ActionRewards { uint16 guaranteedRewardTokenId1; uint24 guaranteedRewardRate1; // num per hour, base 100 (2 decimals) uint16 guaranteedRewardTokenId2; uint24 guaranteedRewardRate2; uint16 guaranteedRewardTokenId3; uint24 guaranteedRewardRate3; // Random chance rewards uint16 randomRewardTokenId1; uint16 randomRewardChance1; // out of 65335 uint16 randomRewardTokenId2; uint16 randomRewardChance2; uint16 randomRewardTokenId3; uint16 randomRewardChance3; uint16 randomRewardTokenId4; uint16 randomRewardChance4; } // This is only for viewing so doesn't need to be optimized struct PendingOutput { Equipment[] consumed; Equipment[] produced; Equipment[] producedPastRandomRewards; Equipment[] producedXPRewards; bool died; } struct PendingFlags { bool includeLoot; // Guaranteed loot from actions, and random loot if claiming quite late bool includePastRandomRewards; // This is random loot from previous actions bool includeXPRewards; // Passing any xp thresholds gives you extra rewards } struct XPThresholdReward { uint32 xpThreshold; Equipment[] rewards; } uint constant MAX_GUARANTEED_REWARDS_PER_ACTION = 3; uint constant MAX_RANDOM_REWARDS_PER_ACTION = 4; uint constant MAX_REWARDS_PER_ACTION = MAX_GUARANTEED_REWARDS_PER_ACTION + MAX_RANDOM_REWARDS_PER_ACTION; uint constant MAX_CONSUMED_PER_ACTION = 3;
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IBrushToken is IERC20 { function burn(uint256 _amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {Skill} from "../globals/players.sol"; interface IPlayers { function clearEverythingBeforeTokenTransfer(address from, uint tokenId) external; function getURI( uint playerId, bytes32 name, bytes32 avatarName, string calldata avatarDescription, string calldata imageURI ) external view returns (string memory); function mintBatch(address to, uint[] calldata ids, uint256[] calldata amounts) external; function itemBeforeTokenTransfer(address from, uint[] calldata tokenIds, uint256[] calldata amounts) external; function mintedPlayer(address from, uint playerId, Skill[2] calldata startSkills, bool makeActive) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {ERC1155Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {Multicall} from "@openzeppelin/contracts/utils/Multicall.sol"; import {IERC2981, IERC165} from "@openzeppelin/contracts/interfaces/IERC2981.sol"; import {UnsafeMath, UnsafeU256, U256} from "@0xdoublesharp/unsafe-math/contracts/UnsafeU256.sol"; import {IBrushToken} from "./interfaces/IBrushToken.sol"; import {IPlayers} from "./interfaces/IPlayers.sol"; import {World} from "./World.sol"; // solhint-disable-next-line no-global-import import "./globals/players.sol"; // solhint-disable-next-line no-global-import import "./globals/items.sol"; // The NFT contract contains data related to the items and who owns them contract ItemNFT is ERC1155Upgradeable, UUPSUpgradeable, OwnableUpgradeable, IERC2981, Multicall { using UnsafeMath for uint256; using UnsafeU256 for U256; event AddItem(Item item, uint16 tokenId); event AddItems(Item[] items, uint16[] tokenIds); event EditItem(Item item, uint16 tokenId); error IdTooHigh(); error ItemNotTransferable(); error InvalidChainId(); error InvalidTokenId(); error ItemAlreadyExists(); error ItemDoesNotExist(); error EquipmentPositionShouldNotChange(); error OnlyForHardhat(); error NotAllowedHardhat(); error ERC1155ReceiverNotApproved(); error NotPlayersOrShop(); // Input only struct NonCombatStats { Skill skill; int16 diff; } // Contains everything you need to create an item struct InputItem { CombatStats combatStats; NonCombatStats nonCombatStats; uint16 tokenId; EquipPosition equipPosition; // Can it be transferred? bool isTransferable; // Minimum requirements in this skill Skill skill; uint32 minXP; // Food uint16 healthRestored; // Boost BoostType boostType; uint16 boostValue; // Varies, could be the % increase uint24 boostDuration; // How long the effect of the boost vial last // uri string metadataURI; } World public world; string private baseURI; // How many of this item exist mapping(uint itemId => uint amount) public itemBalances; address public players; address public shop; // Royalties uint public royaltyFee; address public royaltyReceiver; uint public uniqueItems; // unique number of items mapping(uint itemId => string tokenURI) private tokenURIs; mapping(uint itemId => CombatStats combatStats) public combatStats; mapping(uint itemId => Item) public items; modifier onlyPlayersOrShop() { if (msg.sender != players && msg.sender != shop) { revert NotPlayersOrShop(); } _; } /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize(World _world, address _shop, address _royaltyReceiver) public initializer { __ERC1155_init(""); __Ownable_init(); __UUPSUpgradeable_init(); world = _world; shop = _shop; baseURI = "ipfs://"; royaltyFee = 250; // 2.5% royaltyReceiver = _royaltyReceiver; } function _mintItem(address _to, uint _tokenId, uint256 _amount) internal { if (_tokenId >= type(uint16).max) { revert IdTooHigh(); } // require(_exists(_tokenId)); uint existingBalance = itemBalances[_tokenId]; if (existingBalance == 0) { uniqueItems = uniqueItems.inc(); } itemBalances[_tokenId] = existingBalance + _amount; _mint(_to, uint(_tokenId), _amount, ""); } function _mintBatchItems(address _to, uint[] calldata _tokenIds, uint[] calldata _amounts) internal { U256 numNewItems; U256 tokenIdsLength = U256.wrap(_tokenIds.length); for (U256 iter; iter < tokenIdsLength; iter = iter.inc()) { uint i = iter.asUint256(); uint tokenId = _tokenIds[i]; if (tokenId >= type(uint16).max) { revert IdTooHigh(); } // require(_exists(_tokenIds[i])); uint existingBalance = itemBalances[tokenId]; if (existingBalance == 0) { // Brand new item numNewItems = numNewItems.inc(); } itemBalances[tokenId] = existingBalance + _amounts[i]; } if (numNewItems.neq(0)) { uniqueItems += numNewItems.asUint256(); } _mintBatch(_to, _tokenIds, _amounts, ""); } function mint(address _to, uint _tokenId, uint256 _amount) external onlyPlayersOrShop { _mintItem(_to, _tokenId, _amount); } // Can't use Item[] array unfortunately so they don't support array casts function mintBatch(address _to, uint[] calldata _ids, uint256[] calldata _amounts) external onlyPlayersOrShop { _mintBatchItems(_to, _ids, _amounts); } function uri(uint256 _tokenId) public view virtual override returns (string memory) { if (!_exists(_tokenId)) { revert ItemDoesNotExist(); } return string(abi.encodePacked(baseURI, tokenURIs[_tokenId])); } function _exists(uint _tokenId) private view returns (bool) { return items[_tokenId].equipPosition != EquipPosition.NONE; } function _getItem(uint _tokenId) private view returns (Item memory) { if (!_exists(_tokenId)) { revert ItemDoesNotExist(); } return items[_tokenId]; } function getItem(uint16 _tokenId) external view returns (Item memory) { return _getItem(_tokenId); } function getMinRequirement(uint16 _tokenId) public view returns (Skill, uint32) { return (items[_tokenId].skill, items[_tokenId].minXP); } function getEquipPosition(uint16 _tokenId) public view returns (EquipPosition) { if (!_exists(_tokenId)) { revert ItemDoesNotExist(); } return items[_tokenId].equipPosition; } function getMinRequirements( uint16[] calldata _tokenIds ) external view returns (Skill[] memory skills, uint32[] memory minXPs) { skills = new Skill[](_tokenIds.length); minXPs = new uint32[](_tokenIds.length); U256 tokenIdsLength = U256.wrap(_tokenIds.length); for (U256 iter; iter < tokenIdsLength; iter = iter.inc()) { uint i = iter.asUint256(); (skills[i], minXPs[i]) = getMinRequirement(_tokenIds[i]); } } function getItems(uint16[] calldata _tokenIds) external view returns (Item[] memory _items) { U256 tokenIdsLength = U256.wrap(_tokenIds.length); _items = new Item[](tokenIdsLength.asUint256()); for (U256 iter; iter < tokenIdsLength; iter = iter.inc()) { uint i = iter.asUint256(); _items[i] = _getItem(_tokenIds[i]); } } function getEquipPositions( uint16[] calldata _tokenIds ) external view returns (EquipPosition[] memory equipPositions) { U256 tokenIdsLength = U256.wrap(_tokenIds.length); equipPositions = new EquipPosition[](tokenIdsLength.asUint256()); for (U256 iter; iter < tokenIdsLength; iter = iter.inc()) { uint i = iter.asUint256(); equipPositions[i] = getEquipPosition(_tokenIds[i]); } } // If an item is burnt, remove it from the total function _removeAnyBurntFromTotal(uint[] memory _ids, uint[] memory _amounts) private { U256 iter = U256.wrap(_ids.length); while (iter.neq(0)) { iter = iter.dec(); uint i = iter.asUint256(); itemBalances[_ids[i]] -= _amounts[i]; } } function _checkIsTransferable(uint[] memory _ids) private view { U256 iter = U256.wrap(_ids.length); while (iter.neq(0)) { iter = iter.dec(); uint i = iter.asUint256(); if (_exists(_ids[i]) && !items[_ids[i]].isTransferable) { revert ItemNotTransferable(); } } } function _beforeTokenTransfer( address /*_operator*/, address _from, address _to, uint[] memory _ids, uint[] memory _amounts, bytes memory /*_data*/ ) internal virtual override { if (_from == address(0) || _amounts.length == 0 || _from == _to) { // When minting or self sending, then no further processing is required return; } bool isBurnt = _to == address(0) || _to == 0x000000000000000000000000000000000000dEaD; if (isBurnt) { _removeAnyBurntFromTotal(_ids, _amounts); } else { _checkIsTransferable(_ids); } if (players != address(0)) { IPlayers(players).itemBeforeTokenTransfer(_from, _ids, _amounts); } else { if (block.chainid != 31337) { revert InvalidChainId(); } } } /** * @dev See {IERC1155-balanceOfBatch}. This implementation is not standard ERC1155, it's optimized for the single account case */ function balanceOfs(address _account, uint16[] memory _ids) external view returns (uint256[] memory batchBalances) { U256 iter = U256.wrap(_ids.length); batchBalances = new uint256[](iter.asUint256()); while (iter.neq(0)) { iter = iter.dec(); uint i = iter.asUint256(); batchBalances[i] = balanceOf(_account, _ids[i]); } } function burn(address _from, uint _tokenId, uint _quantity) external { if ( _from != _msgSender() && !isApprovedForAll(_from, _msgSender()) && players != _msgSender() && shop != _msgSender() ) { revert ERC1155ReceiverNotApproved(); } _burn(_from, _tokenId, _quantity); } function _setItem(InputItem calldata _item) private returns (Item storage item) { if (_item.tokenId == 0) { revert InvalidTokenId(); } bool hasCombat; CombatStats calldata _combatStats = _item.combatStats; assembly ("memory-safe") { hasCombat := not(iszero(_combatStats)) } item = items[_item.tokenId]; item.equipPosition = _item.equipPosition; item.isTransferable = _item.isTransferable; if (hasCombat) { // Combat stats item.melee = int8(_item.combatStats.melee); item.magic = int8(_item.combatStats.magic); item.range = int8(_item.combatStats.range); item.meleeDefence = int8(_item.combatStats.meleeDefence); item.magicDefence = int8(_item.combatStats.magicDefence); item.rangeDefence = int8(_item.combatStats.rangeDefence); item.health = int8(_item.combatStats.health); } item.skill1 = _item.nonCombatStats.skill; item.skillDiff1 = _item.nonCombatStats.diff; if (_item.healthRestored != 0) { item.healthRestored = _item.healthRestored; } if (_item.boostType != BoostType.NONE) { item.boostType = _item.boostType; item.boostValue = _item.boostValue; item.boostDuration = _item.boostDuration; } item.minXP = _item.minXP; item.skill = _item.skill; tokenURIs[_item.tokenId] = _item.metadataURI; } function royaltyInfo( uint256 /*_tokenId*/, uint256 _salePrice ) external view override returns (address receiver, uint256 royaltyAmount) { uint256 amount = (_salePrice * royaltyFee) / 10000; return (royaltyReceiver, amount); } function supportsInterface(bytes4 interfaceId) public view override(IERC165, ERC1155Upgradeable) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } function setRoyaltyReceiver(address _receiver) external onlyOwner { royaltyReceiver = _receiver; } // Or make it constants and redeploy the contracts function addItem(InputItem calldata _inputItem) external onlyOwner { if (_exists(_inputItem.tokenId)) { revert ItemAlreadyExists(); } Item storage item = _setItem(_inputItem); emit AddItem(item, _inputItem.tokenId); } function addItems(InputItem[] calldata _inputItems) external onlyOwner { U256 iter = U256.wrap(_inputItems.length); Item[] memory _items = new Item[](iter.asUint256()); uint16[] memory tokenIds = new uint16[](iter.asUint256()); while (iter.neq(0)) { iter = iter.dec(); uint i = iter.asUint256(); if (_exists(_inputItems[i].tokenId)) { revert ItemAlreadyExists(); } _items[i] = _setItem(_inputItems[i]); tokenIds[i] = _inputItems[i].tokenId; } emit AddItems(_items, tokenIds); } function editItem(InputItem calldata _inputItem) external onlyOwner { if (!_exists(_inputItem.tokenId)) { revert ItemDoesNotExist(); } if (items[_inputItem.tokenId].equipPosition != _inputItem.equipPosition) { revert EquipmentPositionShouldNotChange(); } Item storage item = _setItem(_inputItem); emit EditItem(item, _inputItem.tokenId); } function setPlayers(address _players) external onlyOwner { players = _players; } function setBaseURI(string calldata _baseURI) external onlyOwner { _setURI(_baseURI); } // solhint-disable-next-line no-empty-blocks function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} modifier isHardhat() { if (block.chainid != 31337) { revert OnlyForHardhat(); } _; } modifier isNotHardhat() { if (block.chainid == 31337) { revert NotAllowedHardhat(); } _; } // TODO: Remove in live version!! Just using it for live testing atm function testMint(address _to, uint _tokenId, uint _amount) external isNotHardhat { _mintItem(_to, _tokenId, _amount); } function testMints(address _to, uint[] calldata _tokenIds, uint[] calldata _amounts) external isNotHardhat { _mintBatchItems(_to, _tokenIds, _amounts); } // These are just to make tests easier to run by allowing arbitrary minting function testOnlyMint(address _to, uint _tokenId, uint _amount) external isHardhat { _mintItem(_to, _tokenId, _amount); } function testOnlyMints(address _to, uint[] calldata _tokenIds, uint[] calldata _amounts) external isHardhat { _mintBatchItems(_to, _tokenIds, _amounts); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {ERC1155Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import {Multicall} from "@openzeppelin/contracts/utils/Multicall.sol"; import {IERC2981, IERC165} from "@openzeppelin/contracts/interfaces/IERC2981.sol"; import {UnsafeU256, U256} from "@0xdoublesharp/unsafe-math/contracts/UnsafeU256.sol"; import {IBrushToken} from "./interfaces/IBrushToken.sol"; import {IPlayers} from "./interfaces/IPlayers.sol"; // solhint-disable-next-line no-global-import import "./globals/items.sol"; // solhint-disable-next-line no-global-import import "./globals/players.sol"; // Each NFT represents a player. This contract deals with the NFTs, and the Players contract deals with the player data contract PlayerNFT is ERC1155Upgradeable, UUPSUpgradeable, OwnableUpgradeable, IERC2981, Multicall { using UnsafeU256 for U256; event NewPlayer(uint playerId, uint avatarId, bytes20 name); event EditPlayer(uint playerId, bytes20 newName); event SetAvatar(uint avatarId, AvatarInfo avatarInfo); event SetAvatars(uint startAvatarId, AvatarInfo[] avatarInfos); error NotOwner(); error AvatarNotExists(); error NotPlayers(); error NameCannotBeEmpty(); error NameAlreadyExists(); error MintedMoreThanAllowed(); error NotInWhitelist(); error ERC1155Metadata_URIQueryForNonexistentToken(); error ERC1155BurnForbidden(); uint public nextPlayerId; mapping(uint avatarId => AvatarInfo avatarInfo) public avatars; string public imageBaseUri; mapping(uint playerId => uint avatar) public playerIdToAvatar; mapping(uint playerId => bytes32 name) public names; mapping(bytes name => bool exists) public lowercaseNames; IBrushToken public brush; IPlayers public players; address public pool; uint public editNameCost; uint public royaltyFee; address public royaltyReceiver; bytes32 public merkleRoot; // For airdrop mapping(address whitelistedUser => uint amount) public numMintedFromWhitelist; uint public constant MAX_ALPHA_WHITELIST = 2; modifier isOwnerOfPlayer(uint playerId) { if (balanceOf(msg.sender, playerId) != 1) { revert NotOwner(); } _; } modifier onlyPlayers() { if (msg.sender != address(players)) { revert NotPlayers(); } _; } /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize( IBrushToken _brush, address _pool, address _royaltyReceiver, uint _editNameCost, string calldata _imageBaseUri ) public initializer { __ERC1155_init(""); __Ownable_init(); __UUPSUpgradeable_init(); brush = _brush; nextPlayerId = 1; imageBaseUri = _imageBaseUri; pool = _pool; editNameCost = _editNameCost; royaltyFee = 250; // 2.5% royaltyReceiver = _royaltyReceiver; } function _mintStartingItems() private { // Give the player some starting items uint[] memory itemNFTs = new uint[](5); itemNFTs[0] = BRONZE_SWORD; itemNFTs[1] = BRONZE_AXE; itemNFTs[2] = MAGIC_FIRE_STARTER; itemNFTs[3] = NET_STICK; itemNFTs[4] = BRONZE_PICKAXE; uint[] memory quantities = new uint[](5); quantities[0] = 1; quantities[1] = 1; quantities[2] = 1; quantities[3] = 1; quantities[4] = 1; players.mintBatch(msg.sender, itemNFTs, quantities); } function _setName(uint _playerId, bytes20 _name) private { if (uint160(_name) == 0) { revert NameCannotBeEmpty(); } names[_playerId] = _name; bytes memory lowercaseName = _toLower(_name); if (lowercaseNames[lowercaseName]) { revert NameAlreadyExists(); } lowercaseNames[lowercaseName] = true; } // Minting whitelist for the alpha function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner { merkleRoot = _merkleRoot; } function checkInWhitelist(bytes32[] calldata _proof) public view returns (bool whitelisted) { bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); return MerkleProof.verify(_proof, merkleRoot, leaf); } function _mintPlayer(uint _avatarId, bytes32 _name, bool _makeActive) private { address from = msg.sender; uint playerId = nextPlayerId++; emit NewPlayer(playerId, _avatarId, bytes20(_name)); _mint(from, playerId, 1, ""); _setName(playerId, bytes20(_name)); players.mintedPlayer(from, playerId, avatars[_avatarId].startSkills, _makeActive); _mintStartingItems(); _setTokenIdToAvatar(playerId, _avatarId); } function mintWhitelist(uint _avatarId, bytes32 _name, bool _makeActive, bytes32[] calldata _proof) external { if (!checkInWhitelist(_proof)) { revert NotInWhitelist(); } ++numMintedFromWhitelist[msg.sender]; if (numMintedFromWhitelist[msg.sender] > MAX_ALPHA_WHITELIST) { revert MintedMoreThanAllowed(); } _mintPlayer(_avatarId, _name, _makeActive); } // Costs nothing to mint, only gas function mint(uint _avatarId, bytes32 _name, bool _makeActive) external { _mintPlayer(_avatarId, _name, _makeActive); } function _setTokenIdToAvatar(uint _playerId, uint _avatarId) private { if (bytes(avatars[_avatarId].description).length == 0) { revert AvatarNotExists(); } playerIdToAvatar[_playerId] = _avatarId; } function uri(uint256 _playerId) public view virtual override returns (string memory) { if (!_exists(_playerId)) { revert ERC1155Metadata_URIQueryForNonexistentToken(); } AvatarInfo storage avatarInfo = avatars[playerIdToAvatar[_playerId]]; string memory imageURI = string(abi.encodePacked(imageBaseUri, avatarInfo.imageURI)); return players.getURI(_playerId, names[_playerId], avatarInfo.name, avatarInfo.description, imageURI); } function _beforeTokenTransfer( address /*operator*/, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory /*data*/ ) internal virtual override { if (from == address(0) || amounts.length == 0 || from == to) { return; } U256 iter = U256.wrap(ids.length); while (iter.neq(0)) { iter = iter.dec(); uint i = iter.asUint256(); uint playerId = ids[i]; players.clearEverythingBeforeTokenTransfer(from, playerId); } } /** * @dev Returns whether `playerId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * */ function _exists(uint256 _playerId) private view returns (bool) { return playerIdToAvatar[_playerId] != 0; } function editName(uint _playerId, bytes32 _newName) external isOwnerOfPlayer(_playerId) { uint brushCost = editNameCost; // Pay brush.transferFrom(msg.sender, address(this), brushCost); // Send half to the pool (currently shop) brush.transferFrom(msg.sender, pool, brushCost - (brushCost / 2)); // Burn the other half brush.burn(brushCost / 2); // Delete old name bytes32 oldName = names[_playerId]; delete names[_playerId]; bytes memory oldLowercaseName = _toLower(oldName); delete lowercaseNames[oldLowercaseName]; _setName(_playerId, bytes20(_newName)); emit EditPlayer(_playerId, bytes20(_newName)); } /** * @dev See {IERC1155-balanceOfBatch}. This implementation is not standard ERC1155, it's optimized for the single account case */ function balanceOfs(address _account, uint16[] memory _ids) external view returns (uint256[] memory batchBalances) { U256 iter = U256.wrap(_ids.length); batchBalances = new uint256[](iter.asUint256()); while (iter.neq(0)) { iter = iter.dec(); uint i = iter.asUint256(); batchBalances[i] = balanceOf(_account, _ids[i]); } } function _toLower(bytes32 _name) private pure returns (bytes memory) { bytes memory lowerName = bytes(abi.encodePacked(_name)); U256 iter = U256.wrap(lowerName.length); while (iter.neq(0)) { iter = iter.dec(); uint i = iter.asUint256(); if ((uint8(lowerName[i]) >= 65) && (uint8(lowerName[i]) <= 90)) { // So we add 32 to make it lowercase lowerName[i] = bytes1(uint8(lowerName[i]) + 32); } } return lowerName; } function burn(address _from, uint _playerId) external { if (_from != _msgSender() && !isApprovedForAll(_from, _msgSender())) { revert ERC1155BurnForbidden(); } _burn(_from, _playerId, 1); } function royaltyInfo( uint256 /*_tokenId*/, uint256 _salePrice ) external view override returns (address receiver, uint256 royaltyAmount) { uint256 amount = (_salePrice * royaltyFee) / 10000; return (royaltyReceiver, amount); } function supportsInterface(bytes4 interfaceId) public view override(IERC165, ERC1155Upgradeable) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } function setRoyaltyReceiver(address _receiver) external onlyOwner { royaltyReceiver = _receiver; } function setAvatar(uint _avatarId, AvatarInfo calldata _avatarInfo) external onlyOwner { avatars[_avatarId] = _avatarInfo; emit SetAvatar(_avatarId, _avatarInfo); } function setAvatars(uint _startAvatarId, AvatarInfo[] calldata _avatarInfos) external onlyOwner { U256 iter = U256.wrap(_avatarInfos.length); while (iter.neq(0)) { iter = iter.dec(); uint i = iter.asUint256(); avatars[_startAvatarId + i] = _avatarInfos[i]; } emit SetAvatars(_startAvatarId, _avatarInfos); } function setImageBaseUri(string calldata _imageBaseUri) external onlyOwner { _setURI(_imageBaseUri); } function setPlayers(IPlayers _players) external onlyOwner { players = _players; } function setEditNameCost(uint _editNameCost) external onlyOwner { editNameCost = _editNameCost; } // solhint-disable-next-line no-empty-blocks function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {Base64} from "@openzeppelin/contracts/utils/Base64.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {UnsafeU256, U256} from "@0xdoublesharp/unsafe-math/contracts/UnsafeU256.sol"; import {ItemNFT} from "../ItemNFT.sol"; import {World} from "../World.sol"; // solhint-disable-next-line no-global-import import "../globals/players.sol"; // solhint-disable-next-line no-global-import import "../globals/actions.sol"; // solhint-disable-next-line no-global-import import "../globals/items.sol"; library PlayerLibrary { using Strings for uint32; using Strings for bytes32; using UnsafeU256 for U256; // Show all the player stats, return metadata json function uri( bytes32 name, mapping(Skill skill => uint32 xp) storage xp, bytes32 avatarName, string calldata avatarDescription, string calldata imageURI ) external view returns (string memory) { string memory attributes = string( abi.encodePacked( _getTraitStringJSON("Avatar", avatarName), ",", _getTraitNumberJSON("Melee", getLevel(xp[Skill.MELEE])), ",", _getTraitNumberJSON("Magic", getLevel(xp[Skill.MAGIC])), ",", _getTraitNumberJSON("Defence", getLevel(xp[Skill.DEFENCE])), ",", _getTraitNumberJSON("Health", getLevel(xp[Skill.HEALTH])), ",", _getTraitNumberJSON("Mining", getLevel(xp[Skill.MINING])), ",", _getTraitNumberJSON("WoodCutting", getLevel(xp[Skill.WOODCUTTING])), ",", _getTraitNumberJSON("Fishing", getLevel(xp[Skill.FISHING])), ",", _getTraitNumberJSON("Smithing", getLevel(xp[Skill.SMITHING])), ",", _getTraitNumberJSON("Thieving", getLevel(xp[Skill.THIEVING])), ",", _getTraitNumberJSON("Crafting", getLevel(xp[Skill.CRAFTING])), ",", _getTraitNumberJSON("Cooking", getLevel(xp[Skill.COOKING])), ",", _getTraitNumberJSON("FireMaking", getLevel(xp[Skill.FIREMAKING])) ) ); string memory json = Base64.encode( abi.encodePacked( '{"name":"', _trimBytes32(name), '","description":"', avatarDescription, '","attributes":[', attributes, '],"image":"', imageURI, '"}' ) ); return string(abi.encodePacked("data:application/json;base64,", json)); } function _trimBytes32(bytes32 _bytes32) private pure returns (bytes memory _bytes) { U256 _len; while (_len.lt(32)) { if (_bytes32[_len.asUint256()] == 0) { break; } _len = _len.inc(); } _bytes = abi.encodePacked(_bytes32); assembly ("memory-safe") { mstore(_bytes, _len) } } function _getTraitStringJSON(string memory traitType, bytes32 value) private pure returns (bytes memory) { return abi.encodePacked(_getTraitTypeJSON(traitType), '"', _trimBytes32(value), '"}'); } function _getTraitNumberJSON(string memory traitType, uint32 value) private pure returns (bytes memory) { return abi.encodePacked(_getTraitTypeJSON(traitType), value.toString(), "}"); } function _getTraitTypeJSON(string memory traitType) private pure returns (bytes memory) { return abi.encodePacked('{"trait_type":"', traitType, '","value":'); } // Index not level, add one after (check for > max) function getLevel(uint256 _xp) public pure returns (uint16) { U256 low; U256 high = U256.wrap(XP_BYTES.length).div(3); while (low < high) { U256 mid = (low + high).div(2); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) if (_getXP(mid.asUint256()) > _xp) { high = mid; } else { low = mid.inc(); } } if (low.neq(0)) { return low.asUint16(); } else { return 1; } } function _getXP(uint256 _index) private pure returns (uint24) { uint256 index = _index * 3; return uint24(XP_BYTES[index] | (bytes3(XP_BYTES[index + 1]) >> 8) | (bytes3(XP_BYTES[index + 2]) >> 16)); } function foodConsumedView( address _from, QueuedAction storage queuedAction, uint _combatElapsedTime, ItemNFT _itemNFT, CombatStats memory _combatStats, CombatStats memory _enemyCombatStats, uint128 _alphaCombat, uint128 _betaCombat ) external view returns (uint24 foodConsumed, bool died) { uint32 totalHealthLost = _dmg( _enemyCombatStats.melee, _combatStats.meleeDefence, _alphaCombat, _betaCombat, _combatElapsedTime ); totalHealthLost += _dmg( _enemyCombatStats.magic, _combatStats.magicDefence, _alphaCombat, _betaCombat, _combatElapsedTime ); if (int32(totalHealthLost) > _combatStats.health) { // Take away our health points from the total dealt totalHealthLost -= uint16(int16(_max(0, _combatStats.health))); } else { totalHealthLost = 0; } // totalHealthLost += _dmg(_enemyCombatStats.range, _combatStats.rangeDefence, _alphaCombat, _betaCombat, _combatElapsedTime); uint healthRestored; if (queuedAction.regenerateId != NONE) { Item memory item = _itemNFT.getItem(queuedAction.regenerateId); healthRestored = item.healthRestored; } if (healthRestored == 0 || totalHealthLost <= 0) { // No food attached or didn't lose any health died = totalHealthLost != 0; } else { // Round up foodConsumed = uint24( uint32(totalHealthLost) / healthRestored + (uint32(totalHealthLost) % healthRestored == 0 ? 0 : 1) ); uint balance = _itemNFT.balanceOf(_from, queuedAction.regenerateId); died = foodConsumed > balance; if (died) { foodConsumed = uint16(balance); } } } function _getMaxRequiredRatio( address _from, ActionChoice memory _actionChoice, uint24 _numConsumed, ItemNFT _itemNFT ) private view returns (uint maxRequiredRatio) { maxRequiredRatio = _numConsumed; if (_numConsumed != 0) { if (_actionChoice.inputTokenId1 != 0) { maxRequiredRatio = _getMaxRequiredRatioPartial( _from, _actionChoice.inputTokenId1, _actionChoice.num1, _numConsumed, maxRequiredRatio, _itemNFT ); } if (_actionChoice.inputTokenId2 != 0) { maxRequiredRatio = _getMaxRequiredRatioPartial( _from, _actionChoice.inputTokenId2, _actionChoice.num2, _numConsumed, maxRequiredRatio, _itemNFT ); } if (_actionChoice.inputTokenId3 != 0) { maxRequiredRatio = _getMaxRequiredRatioPartial( _from, _actionChoice.inputTokenId3, _actionChoice.num3, _numConsumed, maxRequiredRatio, _itemNFT ); } } } function _getMaxRequiredRatioPartial( address _from, uint16 _inputTokenId, uint16 _num, uint24 _numConsumed, uint _maxRequiredRatio, ItemNFT _itemNFT ) private view returns (uint maxRequiredRatio) { uint balance = _itemNFT.balanceOf(_from, _inputTokenId); uint tempMaxRequiredRatio = _maxRequiredRatio; if (_numConsumed > balance / _num) { tempMaxRequiredRatio = balance / _num; } // Could be the first time if (tempMaxRequiredRatio < _maxRequiredRatio || _maxRequiredRatio == _numConsumed) { maxRequiredRatio = tempMaxRequiredRatio; } } function _max(int256 a, int256 b) private pure returns (int256) { return a > b ? a : b; } function _dmg( int16 attack, int16 defence, uint128 _alphaCombat, uint128 _betaCombat, uint _elapsedTime ) private pure returns (uint32) { return uint32( int32( (_max(1, attack * int128(_alphaCombat) + (attack - defence) * int128(_betaCombat)) * int32(int(_elapsedTime))) / 60 ) ); } function getCombatAdjustedElapsedTimes( address _from, ItemNFT _itemNFT, World _world, uint _elapsedTime, ActionChoice memory _actionChoice, QueuedAction memory _queuedAction, CombatStats memory _combatStats, CombatStats memory _enemyCombatStats, uint128 _alphaCombat, uint128 _betaCombat ) external view returns (uint xpElapsedTime, uint combatElapsedTime, uint16 numConsumed) { // Update these as necessary xpElapsedTime = _elapsedTime; combatElapsedTime = _elapsedTime; // Figure out how much food should be consumed. // This is based on the damage done from battling uint numSpawnedPerHour = _world.getNumSpawn(_queuedAction.actionId); uint maxHealthEnemy = (numSpawnedPerHour * _elapsedTime * uint16(_enemyCombatStats.health)) / 3600; if (maxHealthEnemy != 0) { uint32 totalHealthDealt; if (_actionChoice.skill == Skill.MELEE) { totalHealthDealt = _dmg( _combatStats.melee, _enemyCombatStats.meleeDefence, _alphaCombat, _betaCombat, _elapsedTime ); } else if (_actionChoice.skill == Skill.MAGIC) { _combatStats.magic += int16(int32(_actionChoice.diff)); // Extra magic damage totalHealthDealt = _dmg( _combatStats.magic, _enemyCombatStats.magicDefence, _alphaCombat, _betaCombat, _elapsedTime ); } else if (_actionChoice.skill == Skill.RANGE) { // Add later // _combatStats.range += int16(int32(_actionChoice.diff)); // Extra magic damage // totalHealthDealt = _dmg(_combatStats.range, _enemyCombatStats.rangeDefence, _alphaCombat, _betaCombat, _elapsedTime); } // Work out the ratio of health dealt to the max health they have if (uint32(totalHealthDealt) > maxHealthEnemy) { // We killed them all, but figure out how long it took combatElapsedTime = (_elapsedTime * uint32(totalHealthDealt)) / maxHealthEnemy; // Use this to work out how much food, arrows & spells to consume if (combatElapsedTime > _elapsedTime) { combatElapsedTime = _elapsedTime; } } else if (uint32(totalHealthDealt) < maxHealthEnemy) { // We didn't kill them all so they don't get the full rewards/xp // This correct? xpElapsedTime = (_elapsedTime * uint32(totalHealthDealt)) / maxHealthEnemy; } // Check the max that can be used numConsumed = uint16((combatElapsedTime * _actionChoice.rate) / (3600 * 100)); if (numConsumed != 0) { // This checks the balances uint maxRequiredRatio = _getMaxRequiredRatio(_from, _actionChoice, numConsumed, _itemNFT); if (numConsumed > maxRequiredRatio) { numConsumed = uint16(maxRequiredRatio); if (numConsumed > 0) { // Work out what the actual elapsedTime should really be because they didn't have enough equipped to gain all the XP xpElapsedTime = (combatElapsedTime * maxRequiredRatio) / numConsumed; } else { xpElapsedTime = 0; } } } } else { xpElapsedTime = 0; } } function getNonCombatAdjustedElapsedTime( address _from, ItemNFT _itemNFT, uint _elapsedTime, ActionChoice memory _actionChoice ) external view returns (uint xpElapsedTime, uint24 numConsumed) { // Update these as necessary xpElapsedTime = _elapsedTime; // Check the max that can be used numConsumed = uint24((_elapsedTime * _actionChoice.rate) / (3600 * 100)); // This checks the balances uint maxRequiredRatio = _getMaxRequiredRatio(_from, _actionChoice, numConsumed, _itemNFT); if (numConsumed > maxRequiredRatio) { numConsumed = uint24(maxRequiredRatio); if (numConsumed > 0) { // Work out what the actual elapsedTime should really be because they didn't have enough equipped to gain all the XP xpElapsedTime = (_elapsedTime * maxRequiredRatio) / numConsumed; } else { xpElapsedTime = 0; } } } function _isCombat(CombatStyle _combatStyle) private pure returns (bool) { return _combatStyle != CombatStyle.NONE; } function extraXPFromBoost( bool _isCombatSkill, uint _actionStartTime, uint _elapsedTime, uint16 _xpPerHour, PlayerBoostInfo storage activeBoost ) public view returns (uint32 boostPointsAccrued) { if (activeBoost.itemTokenId != NONE && activeBoost.startTime < block.timestamp) { // A boost is active if ( (_isCombatSkill && activeBoost.boostType == BoostType.COMBAT_XP) || (!_isCombatSkill && activeBoost.boostType == BoostType.NON_COMBAT_XP) ) { uint boostedTime; // Correct skill for the boost if (_actionStartTime + _elapsedTime < activeBoost.startTime + activeBoost.duration) { // Consume it all boostedTime = _elapsedTime; } else { boostedTime = activeBoost.duration; } boostPointsAccrued = uint32((boostedTime * _xpPerHour * activeBoost.val) / (3600 * 100)); } } } function extraBoostFromFullEquipment( Skill _skill, uint16[] memory itemTokenIds, uint[] memory balances ) external pure returns (uint extraBoost) { if (itemTokenIds.length == 5) { if (_skill == Skill.THIEVING) { if ( itemTokenIds[0] == NATUOW_HOOD && balances[0] != 0 && // head itemTokenIds[1] == NATUOW_BODY && balances[1] != 0 && // body itemTokenIds[2] == NATUOW_BRACERS && balances[2] != 0 && // arms itemTokenIds[3] == NATUOW_TASSETS && balances[3] != 0 && // legs itemTokenIds[4] == NATUOW_BOOTS && balances[4] != 0 // boots ) { extraBoost = 3; // % } } else if (_skill == Skill.WOODCUTTING) { if ( itemTokenIds[0] == NATURE_MASK && balances[0] != 0 && // head itemTokenIds[1] == NATURE_BODY && balances[1] != 0 && // body itemTokenIds[2] == NATURE_BRACERS && balances[2] != 0 && // arms itemTokenIds[3] == NATURE_TROUSERS && balances[3] != 0 && // legs itemTokenIds[4] == NATURE_BOOTS && balances[4] != 0 // boots ) { extraBoost = 3; // % } } else if (_skill == Skill.CRAFTING) { if ( itemTokenIds[0] == BAT_WING_HAT && balances[0] != 0 && // head itemTokenIds[1] == BAT_WING_BODY && balances[1] != 0 && // body itemTokenIds[2] == BAT_WING_BRACERS && balances[2] != 0 && // arms itemTokenIds[3] == BAT_WING_TROUSERS && balances[3] != 0 && // legs itemTokenIds[4] == BAT_WING_BOOTS && balances[4] != 0 // boots ) { extraBoost = 3; // % } } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {Multicall} from "@openzeppelin/contracts/utils/Multicall.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import {UnsafeU256, U256} from "@0xdoublesharp/unsafe-math/contracts/UnsafeU256.sol"; import {World} from "../World.sol"; import {ItemNFT} from "../ItemNFT.sol"; import {PlayerNFT} from "../PlayerNFT.sol"; import {PlayersBase} from "./PlayersBase.sol"; import {PlayerLibrary} from "./PlayerLibrary.sol"; import {IPlayers} from "../interfaces/IPlayers.sol"; // solhint-disable-next-line no-global-import import "../globals/players.sol"; // solhint-disable-next-line no-global-import import "../globals/items.sol"; // solhint-disable-next-line no-global-import import "../globals/actions.sol"; // solhint-disable-next-line no-global-import import "../globals/rewards.sol"; // External view functions that are in other implementation files interface PlayersDelegateView { function pendingRewardsImpl( address _owner, uint _playerId, PendingFlags memory _flags ) external view returns (PendingOutput memory pendingOutput); } // Functions to help with delegatecall selectors interface IPlayerDelegate { function startActions( uint _playerId, QueuedAction[] memory _queuedActions, uint16 _boostItemTokenId, ActionQueueStatus _queueStatus ) external; } contract Players is OwnableUpgradeable, UUPSUpgradeable, ReentrancyGuardUpgradeable, PlayersBase, Multicall, IPlayers { using UnsafeU256 for U256; error InvalidSelector(); error XPThresholdNotFound(); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); _checkStartSlot(); } function initialize( ItemNFT _itemNFT, PlayerNFT _playerNFT, World _world, address _implQueueActions, address _implProcessActions, address _implRewards ) public initializer { __Ownable_init(); __UUPSUpgradeable_init(); __ReentrancyGuard_init(); itemNFT = _itemNFT; playerNFT = _playerNFT; world = _world; implQueueActions = _implQueueActions; implProcessActions = _implProcessActions; implRewards = _implRewards; nextQueueId = 1; alphaCombat = 1; betaCombat = 1; } function startAction( uint _playerId, QueuedAction calldata _queuedAction, ActionQueueStatus _queueStatus ) external isOwnerOfPlayerAndActive(_playerId) nonReentrant { QueuedAction[] memory queuedActions = new QueuedAction[](1); queuedActions[0] = _queuedAction; _startActions(_playerId, queuedActions, NONE, _queueStatus); } // Queue them up (Skill X for some amount of time, Skill Y for some amount of time, SKill Z for some amount of time) function startActions( uint _playerId, QueuedAction[] calldata _queuedActions, uint16 _boostItemTokenId, ActionQueueStatus _queueStatus ) external isOwnerOfPlayerAndActive(_playerId) nonReentrant { _startActions(_playerId, _queuedActions, _boostItemTokenId, _queueStatus); } function processActions(uint _playerId) external isOwnerOfPlayerAndActive(_playerId) nonReentrant { QueuedAction[] memory remainingSkillQueue = _processActions(msg.sender, _playerId); _setActionQueue(msg.sender, _playerId, remainingSkillQueue); } function claimRandomRewards(uint _playerId) external nonReentrant { _claimRandomRewards(_playerId); } function consumeBoost( uint _playerId, uint16 _itemTokenId, uint40 _startTime ) external isOwnerOfPlayerAndActive(_playerId) nonReentrant { _delegatecall( implQueueActions, abi.encodeWithSignature("consumeBoost(uint256,uint16,uint40)", _playerId, _itemTokenId, _startTime) ); } function unequipBoostVial(uint _playerId) external isOwnerOfPlayerAndActive(_playerId) nonReentrant { if (activeBoosts[_playerId].boostType == BoostType.NONE) { revert NoActiveBoost(); } if (activeBoosts[_playerId].startTime > block.timestamp) { revert BoostTimeAlreadyStarted(); } address from = msg.sender; itemNFT.mint(from, activeBoosts[_playerId].itemTokenId, 1); emit UnconsumeBoostVial(from, _playerId); } function getPendingRandomRewards(uint _playerId) external view returns (PendingRandomReward[] memory) { return pendingRandomRewards[_playerId]; } function getActionQueue(uint _playerId) external view returns (QueuedAction[] memory) { return players[_playerId].actionQueue; } function actionQueueLength(uint _playerId) external view returns (uint256) { return players[_playerId].actionQueue.length; } function mintBatch(address _to, uint[] calldata _ids, uint256[] calldata _amounts) external override onlyPlayerNFT { itemNFT.mintBatch(_to, _ids, _amounts); } function setSpeedMultiplier(uint _playerId, uint16 multiplier) external { // Disable for production code speedMultiplier[_playerId] = multiplier; } function getURI( uint _playerId, bytes32 _name, bytes32 _avatarName, string calldata _avatarDescription, string calldata imageURI ) external view override returns (string memory) { return PlayerLibrary.uri(_name, xp[_playerId], _avatarName, _avatarDescription, imageURI); } // Callback after minting a player. If they aren't the active player then set it. function mintedPlayer( address _from, uint _playerId, Skill[2] calldata _startSkills, bool _makeActive ) external override onlyPlayerNFT { if (_makeActive) { _setActivePlayer(_from, _playerId); } Player storage player = players[_playerId]; player.health = 1; player.melee = 1; player.magic = 1; player.range = 1; player.defence = 1; player.totalXP = uint160(startXP); uint length = _startSkills[1] != Skill.NONE ? 2 : 1; uint32 xpEach = uint32(startXP / length); for (uint i = 0; i < length; i++) { Skill skill = _startSkills[i]; int16 level = int16(PlayerLibrary.getLevel(xpEach)); if (skill == Skill.HEALTH) { player.health = level; } else if (skill == Skill.MELEE) { player.melee = level; } else if (skill == Skill.MAGIC) { player.magic = level; } else if (skill == Skill.RANGE) { player.range = level; } else if (skill == Skill.DEFENCE) { player.defence = level; } _updateXP(_from, _playerId, skill, xpEach); } } function clearEverything(uint _playerId) external isOwnerOfPlayerAndActive(_playerId) nonReentrant { _clearEverything(msg.sender, _playerId); } function clearEverythingBeforeTokenTransfer(address _from, uint _playerId) external override onlyPlayerNFT { _clearEverything(_from, _playerId); } function itemBeforeTokenTransfer( address _from, uint[] calldata /*_itemTokenIds*/, uint[] calldata /*_amounts*/ ) external view onlyItemNFT { uint playerId = activePlayer[_from]; if (playerId == 0) { return; } // TODO: Check if the player is currently using any of the items, and record all which are 0 and left/right arm items // emit QueuedActionValid(true/false) } // Consumes all the actions in the queue up to this time. // Unequips everything which is just emitting an event // Mints the boost vial if it hasn't been consumed at all yet // Removes all the actions from the queue function _clearEverything(address _from, uint _playerId) private { _processActions(_from, _playerId); emit ClearAll(_from, _playerId); _clearActionQueue(_from, _playerId); // Can re-mint boost if it hasn't been consumed at all yet if (activeBoosts[_playerId].boostType != BoostType.NONE && activeBoosts[_playerId].startTime < block.timestamp) { uint itemTokenId = activeBoosts[_playerId].itemTokenId; delete activeBoosts[_playerId]; itemNFT.mint(_from, itemTokenId, 1); } } function _clearActionQueue(address _from, uint _playerId) private { QueuedAction[] memory queuedActions; _setActionQueue(_from, _playerId, queuedActions); } function _setActionQueue(address _from, uint _playerId, QueuedAction[] memory _queuedActions) private { Player storage player = players[_playerId]; player.actionQueue = _queuedActions; emit SetActionQueue(_from, _playerId, player.actionQueue); } function _startActions( uint _playerId, QueuedAction[] memory _queuedActions, uint16 _boostItemTokenId, ActionQueueStatus _queueStatus ) private { _delegatecall( implQueueActions, abi.encodeWithSelector( IPlayerDelegate.startActions.selector, _playerId, _queuedActions, _boostItemTokenId, _queueStatus ) ); } function _setActivePlayer(address _from, uint _playerId) private { uint existingActivePlayer = activePlayer[_from]; // All attire and actions can be made for this player activePlayer[_from] = _playerId; if (existingActivePlayer != 0) { // If there is an existing active player, unequip all items _clearEverything(_from, existingActivePlayer); } emit SetActivePlayer(_from, existingActivePlayer, _playerId); } function setActivePlayer(uint _playerId) external isOwnerOfPlayer(_playerId) { _setActivePlayer(msg.sender, _playerId); } function pendingRewards( address _owner, uint _playerId, PendingFlags memory _flags ) external view returns (PendingOutput memory pendingOutput) { // Staticcall into ourselves and hit the fallback. This is done so that pendingRewards can be exposed on the json abi. bytes memory data = _staticcall( address(this), abi.encodeWithSelector(PlayersDelegateView.pendingRewardsImpl.selector, _owner, _playerId, _flags) ); return abi.decode(data, (PendingOutput)); } function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} function setImpls(address _implQueueActions, address _implProcessActions, address _implRewards) external onlyOwner { implQueueActions = _implQueueActions; implProcessActions = _implProcessActions; implRewards = _implRewards; } function _addXPThresholdReward(XPThresholdReward calldata _xpThresholdReward) private { // Check that it is part of the hexBytes uint16 index = _findBaseXPThreshold(_xpThresholdReward.xpThreshold); uint32 xpThreshold = _getXPReward(index); if (_xpThresholdReward.xpThreshold != xpThreshold) { revert XPThresholdNotFound(); } xpRewardThresholds[_xpThresholdReward.xpThreshold] = _xpThresholdReward.rewards; emit AdminAddThresholdReward(_xpThresholdReward); } function addXPThresholdReward(XPThresholdReward calldata _xpThresholdReward) external onlyOwner { _addXPThresholdReward(_xpThresholdReward); } function addXPThresholdRewards(XPThresholdReward[] calldata _xpThresholdRewards) external onlyOwner { U256 iter = U256.wrap(_xpThresholdRewards.length); while (iter.neq(0)) { iter = iter.dec(); _addXPThresholdReward(_xpThresholdRewards[iter.asUint256()]); } } function setDailyRewardsEnabled(bool _dailyRewardsEnabled) external onlyOwner { dailyRewardsEnabled = _dailyRewardsEnabled; } function testOnlyModifyLevel(uint _playerId, Skill _skill, uint32 _xp) external onlyOwner { xp[_playerId][_skill] = _xp; } // For the various view functions that require delegatecall fallback() external { bytes4 selector = bytes4(msg.data); address implementation; if (selector == PlayersDelegateView.pendingRewardsImpl.selector) { implementation = implRewards; } else { revert InvalidSelector(); } assembly ("memory-safe") { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {UnsafeU256, U256} from "@0xdoublesharp/unsafe-math/contracts/UnsafeU256.sol"; import {World} from "../World.sol"; import {ItemNFT} from "../ItemNFT.sol"; import {PlayerNFT} from "../PlayerNFT.sol"; import {PlayerLibrary} from "./PlayerLibrary.sol"; // solhint-disable-next-line no-global-import import "../globals/players.sol"; // solhint-disable-next-line no-global-import import "../globals/items.sol"; // solhint-disable-next-line no-global-import import "../globals/rewards.sol"; abstract contract PlayersBase { using UnsafeU256 for U256; event ClearAll(address from, uint playerId); event AddXP(address from, uint playerId, Skill skill, uint32 points); event SetActionQueue(address from, uint playerId, QueuedAction[] queuedActions); event ConsumeBoostVial(address from, uint playerId, PlayerBoostInfo playerBoostInfo); event UnconsumeBoostVial(address from, uint playerId); event SetActivePlayer(address account, uint oldPlayerId, uint newPlayerId); event AddPendingRandomReward(address from, uint playerId, uint queueId, uint timestamp, uint elapsed); event PendingRandomRewardsClaimed(address from, uint playerId, uint numRemoved); event AdminAddThresholdReward(XPThresholdReward xpThresholdReward); // For logging event Died(address from, uint playerId, uint128 queueId); event Rewards(address from, uint playerId, uint128 queueId, uint[] itemTokenIds, uint[] amounts); event Reward(address from, uint playerId, uint128 queueId, uint16 itemTokenId, uint amount); event Consume(address from, uint playerId, uint128 queueId, uint16 itemTokenId, uint amount); event ActionFinished(address from, uint playerId, uint128 queueId); event ActionPartiallyFinished(address from, uint playerId, uint128 queueId, uint elapsedTime); event ActionAborted(address from, uint playerId, uint128 queueId); event ClaimedXPThresholdRewards(address from, uint playerId, uint[] itemTokenIds, uint[] amounts); event LevelUp(address from, uint playerId, Skill skill, uint32 level); error SkillsArrayZero(); error NotOwner(); error NotActive(); error EquipSameItem(); error NotEquipped(); error ArgumentLengthMismatch(); error NotPlayerNFT(); error NotItemNFT(); error ActionNotAvailable(); error UnsupportedAttire(); error InvalidArmEquipment(uint16 itemTokenId); error DoNotHaveEnoughQuantityToEquipToAction(); error NoActiveBoost(); error BoostTimeAlreadyStarted(); error TooManyActionsQueued(); error TooManyActionsQueuedSomeAlreadyExist(); error ActionTimespanExceedsMaxTime(); error ActionTimespanZero(); error ActionMinimumXPNotReached(); error ActionChoiceMinimumXPNotReached(); error ItemMinimumXPNotReached(); error AttireMinimumXPNotReached(); error ConsumeableMinimumXPNotReached(); error InvalidStartSlot(); error NoItemBalance(uint16 itemTokenId); error CannotEquipTwoHandedAndOtherEquipment(); error IncorrectRightHandEquipment(uint16 equippedItemTokenId); error IncorrectLeftHandEquipment(uint16 equippedItemTokenId); error IncorrectEquippedItem(); error NotABoostVial(); error StartTimeTooFarInTheFuture(); error UnsupportedRegenerateItem(); error InvalidCombatStyle(); error InvalidSkill(); error ActionChoiceIdRequired(); error InvalidEquipPosition(); error ItemDoesNotExist(); uint32 public constant MAX_TIME = 1 days; uint public constant startXP = 374; uint internal startSlot; // Keep as the first non-constant state variable mapping(uint playerId => uint multiplier) internal speedMultiplier; // 0 or 1 is diabled, for testing only mapping(address user => uint playerId) internal activePlayer; mapping(uint playerId => PlayerBoostInfo boostInfo) public activeBoosts; uint64 internal nextQueueId; // Global queued action id World internal world; mapping(uint playerId => mapping(Skill skill => uint32 xp)) public xp; mapping(uint playerId => Player player) public players; ItemNFT internal itemNFT; PlayerNFT internal playerNFT; mapping(uint playerId => PendingRandomReward[] pendingRandomRewards) internal pendingRandomRewards; // queue, will be sorted by timestamp // Constants for the damage formula uint128 alphaCombat; uint128 betaCombat; // First 7 bytes are whether that day has been claimed (Can be extended to 30 days), the last 2 bytes is the current checkpoint number (whether it needs clearing) mapping(uint playerId => bytes32) dailyRewardMasks; // 4 bytes for each threshold, starts at 500 xp in decimal bytes constant xpRewardBytes = hex"00000000000001F4000003E8000009C40000138800002710000075300000C350000186A00001D4C0000493E0000557300007A120000927C0000B71B0"; mapping(uint xp => Equipment[] equipments) xpRewardThresholds; // Thresholds and all items rewarded for it bool dailyRewardsEnabled; address implQueueActions; address implProcessActions; address implRewards; address reserved1; modifier isOwnerOfPlayer(uint playerId) { if (playerNFT.balanceOf(msg.sender, playerId) != 1) { revert NotOwner(); } _; } modifier isOwnerOfPlayerAndActive(uint _playerId) { if (playerNFT.balanceOf(msg.sender, _playerId) != 1) { revert NotOwner(); } if (activePlayer[msg.sender] != _playerId) { revert NotActive(); } _; } modifier onlyPlayerNFT() { if (msg.sender != address(playerNFT)) { revert NotPlayerNFT(); } _; } modifier onlyItemNFT() { if (msg.sender != address(itemNFT)) { revert NotItemNFT(); } _; } function _extraXPFromBoost( uint _playerId, bool _isCombatSkill, uint _actionStartTime, uint _elapsedTime, uint16 _xpPerHour ) internal view returns (uint32 boostPointsAccrued) { return PlayerLibrary.extraXPFromBoost( _isCombatSkill, _actionStartTime, _elapsedTime, _xpPerHour, activeBoosts[_playerId] ); } function _extraXPFromFullEquipment( address _from, Attire storage _attire, Skill _skill, uint _elapsedTime, uint16 _xpPerHour ) internal view returns (uint32 extraPointsAccrued) { if (_skill == Skill.THIEVING || _skill == Skill.CRAFTING || _skill == Skill.WOODCUTTING) { // Check if they have the full equipment set, if so they can get some bonus bool skipNeck = true; (uint16[] memory itemTokenIds, uint[] memory balances) = _getAttireWithBalance(_from, _attire, skipNeck); uint extraBoost = PlayerLibrary.extraBoostFromFullEquipment(_skill, itemTokenIds, balances); if (extraBoost != 0) { extraPointsAccrued = uint32((_elapsedTime * _xpPerHour * extraBoost) / (3600 * 100)); } } } function _getPointsAccrued( address _from, uint _playerId, QueuedAction storage _queuedAction, Skill _skill, uint _xpElapsedTime ) internal view returns (uint32 pointsAccrued) { bool _isCombatSkill = _isCombatStyle(_queuedAction.combatStyle); uint16 xpPerHour = world.getXPPerHour(_queuedAction.actionId, _isCombatSkill ? NONE : _queuedAction.choiceId); pointsAccrued = uint32((_xpElapsedTime * xpPerHour) / 3600); pointsAccrued += _extraXPFromBoost(_playerId, _isCombatSkill, _queuedAction.startTime, _xpElapsedTime, xpPerHour); pointsAccrued += _extraXPFromFullEquipment(_from, _queuedAction.attire, _skill, _xpElapsedTime, xpPerHour); } function _updateXP(address _from, uint _playerId, Skill _skill, uint32 _pointsAccrued) internal { uint32 oldPoints = xp[_playerId][_skill]; uint32 newPoints = oldPoints + _pointsAccrued; xp[_playerId][_skill] = newPoints; emit AddXP(_from, _playerId, _skill, _pointsAccrued); uint16 oldLevel = PlayerLibrary.getLevel(oldPoints); uint16 newLevel = PlayerLibrary.getLevel(newPoints); // Update the player's level if (newLevel > oldLevel) { emit LevelUp(_from, _playerId, _skill, newLevel); } } function _updateStatsFromHandEquipment( address _from, uint16[2] memory _handEquipmentTokenIds, CombatStats memory _combatStats, bool _isCombat ) internal view returns (bool missingRequiredHandEquipment) { U256 iter = U256.wrap(_handEquipmentTokenIds.length); while (iter.neq(0)) { iter = iter.dec(); uint16 i = iter.asUint16(); uint16 handEquipmentTokenId = _handEquipmentTokenIds[i]; if (handEquipmentTokenId != NONE) { uint256 balance = itemNFT.balanceOf(_from, handEquipmentTokenId); if (balance == 0) { // Assume that if the player doesn't have the non-combat item that this action cannot be done if (!_isCombat) { missingRequiredHandEquipment = true; } } else if (_isCombat) { // Update the combat stats Item memory item = itemNFT.getItem(handEquipmentTokenId); _updateCombatStatsFromItem(_combatStats, item); } } } } function _isCombatStyle(CombatStyle _combatStyle) internal pure returns (bool) { return _combatStyle != CombatStyle.NONE; } function _getElapsedTime( uint _playerId, uint _skillEndTime, QueuedAction storage _queuedAction ) internal view returns (uint elapsedTime) { uint _speedMultiplier = speedMultiplier[_playerId]; bool consumeAll = _skillEndTime <= block.timestamp; if (consumeAll) { // Fully consume this skill elapsedTime = _queuedAction.timespan; } else if (block.timestamp > _queuedAction.startTime) { // partially consume elapsedTime = block.timestamp - _queuedAction.startTime; uint modifiedElapsedTime = _speedMultiplier > 1 ? uint(elapsedTime) * _speedMultiplier : elapsedTime; // Up to timespan if (modifiedElapsedTime > _queuedAction.timespan) { elapsedTime = _queuedAction.timespan; } } } function _getAttireWithBalance( address _from, Attire storage _attire, bool _skipNeck ) internal view returns (uint16[] memory itemTokenIds, uint[] memory balances) { uint attireLength; itemTokenIds = new uint16[](8); if (_attire.head != NONE) { itemTokenIds[attireLength++] = _attire.head; } if (_attire.neck != NONE && !_skipNeck) { itemTokenIds[attireLength++] = _attire.neck; } if (_attire.body != NONE) { itemTokenIds[attireLength++] = _attire.body; } if (_attire.arms != NONE) { itemTokenIds[attireLength++] = _attire.arms; } if (_attire.legs != NONE) { itemTokenIds[attireLength++] = _attire.legs; } if (_attire.boots != NONE) { itemTokenIds[attireLength++] = _attire.boots; } assembly ("memory-safe") { mstore(itemTokenIds, attireLength) } if (attireLength != 0) { balances = itemNFT.balanceOfs(_from, itemTokenIds); } } function _updateCombatStats(address _from, CombatStats memory _stats, Attire storage _attire) internal view { bool skipNeck; (uint16[] memory itemTokenIds, uint[] memory balances) = _getAttireWithBalance(_from, _attire, skipNeck); if (itemTokenIds.length != 0) { Item[] memory items = itemNFT.getItems(itemTokenIds); U256 iter = U256.wrap(items.length); while (iter.neq(0)) { iter = iter.dec(); uint i = iter.asUint256(); if (balances[i] != 0) { _updateCombatStatsFromItem(_stats, items[i]); } } } } function _updateCombatStatsFromItem(CombatStats memory _combatStats, Item memory _item) private pure { if (_item.melee != 0) { _combatStats.melee += _item.melee; } if (_item.magic != 0) { _combatStats.magic += _item.magic; } if (_item.range != 0) { _combatStats.range += _item.range; } if (_item.meleeDefence != 0) { _combatStats.meleeDefence += _item.meleeDefence; } if (_item.magicDefence != 0) { _combatStats.magicDefence += _item.magicDefence; } if (_item.rangeDefence != 0) { _combatStats.rangeDefence += _item.rangeDefence; } if (_item.health != 0) { _combatStats.health += _item.health; } } function _getCachedCombatStats(Player storage _player) internal view returns (CombatStats memory combatStats) { combatStats.melee = _player.melee; combatStats.magic = _player.magic; // combatStats.range = _player.range; combatStats.health = _player.health; combatStats.meleeDefence = _player.defence; combatStats.magicDefence = _player.defence; // combatStats.rangeDefence = _player.defence; } function _processActions(address _from, uint _playerId) internal returns (QueuedAction[] memory remainingSkills) { bytes memory data = _delegatecall( implProcessActions, abi.encodeWithSignature("processActions(address,uint256)", _from, _playerId) ); return abi.decode(data, (QueuedAction[])); } // Index not level, add one after (check for > max) function _findBaseXPThreshold(uint256 _xp) internal pure returns (uint16) { U256 low; U256 high = U256.wrap(xpRewardBytes.length).div(4); while (low < high) { U256 mid = (low + high).div(2); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // Math.average rounds down (it does integer division with truncation). if (_getXPReward(mid.asUint256()) > _xp) { high = mid; } else { low = mid.inc(); } } if (low.neq(0)) { return low.dec().asUint16(); } else { return 0; } } function _getXPReward(uint256 _index) internal pure returns (uint32) { U256 index = U256.wrap(_index).mul(4); return uint32( xpRewardBytes[index.asUint256()] | (bytes4(xpRewardBytes[index.add(1).asUint256()]) >> 8) | (bytes4(xpRewardBytes[index.add(2).asUint256()]) >> 16) | (bytes4(xpRewardBytes[index.add(3).asUint256()]) >> 24) ); } function _claimRandomRewards(uint _playerId) internal { _delegatecall(implRewards, abi.encodeWithSignature("claimRandomRewards(uint256)", _playerId)); } function _checkStartSlot() internal pure { uint expectedStartSlotNumber = 251; // From the various slot arrays expected in the base classes uint slot; assembly ("memory-safe") { slot := startSlot.slot } if (slot != expectedStartSlotNumber) { revert InvalidStartSlot(); } } function _delegatecall(address target, bytes memory data) internal returns (bytes memory returndata) { bool success; (success, returndata) = target.delegatecall(data); if (!success) { if (returndata.length == 0) revert(); assembly ("memory-safe") { revert(add(32, returndata), mload(returndata)) } } } function _staticcall(address target, bytes memory data) internal view returns (bytes memory returndata) { bool success; (success, returndata) = target.staticcall(data); if (!success) { if (returndata.length == 0) revert(); assembly ("memory-safe") { revert(add(32, returndata), mload(returndata)) } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * ***************************************************************************** * @dev PURPOSE * * @dev Reggie the Random Oracle (not his real job) wants to provide randomness * @dev to Vera the verifier in such a way that Vera can be sure he's not * @dev making his output up to suit himself. Reggie provides Vera a public key * @dev to which he knows the secret key. Each time Vera provides a seed to * @dev Reggie, he gives back a value which is computed completely * @dev deterministically from the seed and the secret key. * * @dev Reggie provides a proof by which Vera can verify that the output was * @dev correctly computed once Reggie tells it to her, but without that proof, * @dev the output is indistinguishable to her from a uniform random sample * @dev from the output space. * * @dev The purpose of this contract is to make it easy for unrelated contracts * @dev to talk to Vera the verifier about the work Reggie is doing, to provide * @dev simple access to a verifiable source of randomness. It ensures 2 things: * @dev 1. The fulfillment came from the VRFCoordinator * @dev 2. The consumer contract implements fulfillRandomWords. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBase, and can * @dev initialize VRFConsumerBase's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumer { * @dev constructor(<other arguments>, address _vrfCoordinator, address _link) * @dev VRFConsumerBase(_vrfCoordinator) public { * @dev <initialization with other arguments goes here> * @dev } * @dev } * * @dev The oracle will have given you an ID for the VRF keypair they have * @dev committed to (let's call it keyHash). Create subscription, fund it * @dev and your consumer contract as a consumer of it (see VRFCoordinatorInterface * @dev subscription management functions). * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations, * @dev callbackGasLimit, numWords), * @dev see (VRFCoordinatorInterface for a description of the arguments). * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomWords method. * * @dev The randomness argument to fulfillRandomWords is a set of random words * @dev generated from your requestId and the blockHash of the request. * * @dev If your contract could have concurrent requests open, you can use the * @dev requestId returned from requestRandomWords to track which response is associated * @dev with which randomness request. * @dev See "SECURITY CONSIDERATIONS" for principles to keep in mind, * @dev if your contract could have multiple requests in flight simultaneously. * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. * * ***************************************************************************** * @dev SECURITY CONSIDERATIONS * * @dev A method with the ability to call your fulfillRandomness method directly * @dev could spoof a VRF response with any random value, so it's critical that * @dev it cannot be directly called by anything other than this base contract * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method). * * @dev For your users to trust that your contract's random behavior is free * @dev from malicious interference, it's best if you can write it so that all * @dev behaviors implied by a VRF response are executed *during* your * @dev fulfillRandomness method. If your contract must store the response (or * @dev anything derived from it) and use it later, you must ensure that any * @dev user-significant behavior which depends on that stored value cannot be * @dev manipulated by a subsequent VRF request. * * @dev Similarly, both miners and the VRF oracle itself have some influence * @dev over the order in which VRF responses appear on the blockchain, so if * @dev your contract could have multiple VRF requests in flight simultaneously, * @dev you must ensure that the order in which the VRF responses arrive cannot * @dev be used to manipulate your contract's user-significant behavior. * * @dev Since the block hash of the block which contains the requestRandomness * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful * @dev miner could, in principle, fork the blockchain to evict the block * @dev containing the request, forcing the request to be included in a * @dev different block with a different hash, and therefore a different input * @dev to the VRF. However, such an attack would incur a substantial economic * @dev cost. This cost scales with the number of blocks the VRF oracle waits * @dev until it calls responds to a request. It is for this reason that * @dev that you can signal to an oracle you'd like them to wait longer before * @dev responding to the request (however this is not enforced in the contract * @dev and so remains effective only in the case of unmodified oracle software). */ abstract contract VRFConsumerBaseV2Upgradeable is Initializable { error OnlyCoordinatorCanFulfill(address have, address want); address private vrfCoordinator; /** * @dev Initializes the contract setting the deployer as the initial owner. */ // solhint-disable-next-line func-name-mixedcase function __VRFConsumerBaseV2_init(address _vrfCoordinator) internal onlyInitializing { vrfCoordinator = _vrfCoordinator; } /** * @notice fulfillRandomness handles the VRF response. Your contract must * @notice implement it. See "SECURITY CONSIDERATIONS" above for important * @notice principles to keep in mind when implementing your fulfillRandomness * @notice method. * * @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomWords the VRF output expanded to the requested number of words */ function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual; // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external { if (msg.sender != vrfCoordinator) { revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator); } fulfillRandomWords(requestId, randomWords); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {VRFCoordinatorV2Interface} from "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {Multicall} from "@openzeppelin/contracts/utils/Multicall.sol"; import {UnsafeU256, U256} from "@0xdoublesharp/unsafe-math/contracts/UnsafeU256.sol"; import {VRFConsumerBaseV2Upgradeable} from "./VRFConsumerBaseV2Upgradeable.sol"; // solhint-disable-next-line no-global-import import "./globals/players.sol"; // solhint-disable-next-line no-global-import import "./globals/actions.sol"; // solhint-disable-next-line no-global-import import "./globals/items.sol"; // solhint-disable-next-line no-global-import import "./globals/rewards.sol"; // Fantom VRF // VRF 0xd5D517aBE5cF79B7e95eC98dB0f0277788aFF634 // LINK token 0x6F43FF82CCA38001B6699a8AC47A2d0E66939407 // PREMIUM 0.0005 LINK contract World is VRFConsumerBaseV2Upgradeable, UUPSUpgradeable, OwnableUpgradeable, Multicall { using UnsafeU256 for U256; event RequestSent(uint256 requestId, uint32 numWords); event RequestFulfilled(uint256 requestId, uint256 randomWord); event AddAction(Action action); event EditAction(Action action); event SetAvailableAction(uint16 actionId, bool available); event AddDynamicActions(uint16[] actionIds); event RemoveDynamicActions(uint16[] actionIds); event AddActionChoice(uint16 actionId, uint16 actionChoiceId, ActionChoice choice); event AddActionChoices(uint16 actionId, uint16[] actionChoiceIds, ActionChoice[] choices); event NewDailyRewards(Equipment[8] dailyRewards); error SeedCannotBeUpdatedYet(); error CanOnlyRequestAfterTheNextCheckpoint(); error RequestAlreadyFulfilled(); error NoValidSeed(); error CanOnlyRequestAfter1DayHasPassed(); error ActionIdZeroNotAllowed(); error MinCannotBeGreaterThanMax(); error DynamicActionsCannotBeAdded(); error ActionAlreadyExists(); error ActionDoesNotExist(); error ActionChoiceIdZeroNotAllowed(); error OnlySupportingMax1Output(); error DynamicActionsCannotBeSet(); error LengthMismatch(); error NoActionChoices(); error ActionChoiceAlreadyExists(); // This is only used as an input arg struct Action { uint16 actionId; ActionInfo info; ActionReward[] guaranteedRewards; ActionReward[] randomRewards; CombatStats combatStats; } // solhint-disable-next-line var-name-mixedcase VRFCoordinatorV2Interface public COORDINATOR; // Your subscription ID. uint64 public subscriptionId; // Past request ids uint[] public requestIds; // Each one is a seed for a day mapping(uint requestId => uint randomWord) public randomWords; uint40 public lastSeedUpdatedTime; uint40 public startTime; uint40 public nextCheckpoint; // The gas lane to use, which specifies the maximum gas price to bump to. // For a list of available gas lanes on each network, this is 10000gwei // see https://docs.chain.link/docs/vrf/v2/subscription/supported-networks/#configurations bytes32 public constant KEY_HASH = 0x5881eea62f9876043df723cf89f0c2bb6f950da25e9dfe66995c24f919c8f8ab; uint32 public constant CALLBACK_GAS_LIMIT = 100000; // The default is 3, but you can set this higher. uint16 public constant REQUEST_CONFIRMATIONS = 1; // For this example, retrieve 1 random value in one request. // Cannot exceed VRFCoordinatorV2.MAX_NUM_WORDS. uint32 public constant NUM_WORDS = 1; uint32 public constant MIN_SEED_UPDATE_TIME = 1 days; uint32 public constant MIN_DYNAMIC_ACTION_UPDATE_TIME = 1 days; mapping(uint actionId => ActionInfo actionInfo) public actions; uint16[] private lastAddedDynamicActions; uint public lastDynamicUpdatedTime; bytes32 public dailyRewards; // Effectively stores Equipment[8] which is packed, first 7 are daily, last one is weekly reward mapping(uint actionId => mapping(uint16 choiceId => ActionChoice actionChoice)) private actionChoices; mapping(uint actionId => CombatStats combatStats) private actionCombatStats; mapping(uint actionId => ActionRewards actionRewards) private actionRewards; /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize(VRFCoordinatorV2Interface _coordinator, uint64 _subscriptionId) public initializer { __VRFConsumerBaseV2_init(address(_coordinator)); __Ownable_init(); __UUPSUpgradeable_init(); COORDINATOR = _coordinator; subscriptionId = _subscriptionId; startTime = uint40((block.timestamp / MIN_SEED_UPDATE_TIME) * MIN_SEED_UPDATE_TIME); // Floor to the nearest day 00:00 UTC lastSeedUpdatedTime = startTime; nextCheckpoint = uint40((block.timestamp - 4 days) / 1 weeks) * 1 weeks + 4 days + 1 weeks; // Issue new daily rewards Equipment[8] memory rewards = [ Equipment(COPPER_ORE, 100), Equipment(COAL_ORE, 200), Equipment(RUBY, 100), Equipment(MITHRIL_BAR, 200), Equipment(COOKED_BOWFISH, 100), Equipment(LEAF_FRAGMENTS, 20), Equipment(HELL_SCROLL, 300), Equipment(XP_BOOST, 1) ]; _storeDailyRewards(rewards); emit NewDailyRewards(rewards); } function _getDailyReward(uint256 _day) private view returns (Equipment memory equipment) { bytes32 rewardItemTokenId = (dailyRewards & ((bytes32(hex"ffff0000") >> (_day * 32)))) >> ((7 - _day) * 32 + 16); bytes32 rewardAmount = (dailyRewards & ((bytes32(hex"0000ffff") >> (_day * 32)))) >> ((7 - _day) * 32); assembly ("memory-safe") { mstore(equipment, rewardItemTokenId) mstore(add(equipment, 32), rewardAmount) } } function _getUpdatedDailyReward( uint _index, Equipment memory _equipment, bytes32 _rewards ) private pure returns (bytes32) { bytes32 rewardItemTokenId; bytes32 rewardAmount; assembly ("memory-safe") { rewardItemTokenId := mload(_equipment) rewardAmount := mload(add(_equipment, 32)) } _rewards = _rewards | (rewardItemTokenId << ((7 - _index) * 32 + 16)); _rewards = _rewards | (rewardAmount << ((7 - _index) * 32)); return _rewards; } function _storeDailyRewards(Equipment[8] memory equipments) private { bytes32 rewards; for (uint i = 0; i < equipments.length; ++i) { rewards = _getUpdatedDailyReward(i, equipments[i], rewards); } dailyRewards = rewards; } function requestSeedUpdate() external returns (uint256 requestId) { // Last one has not been fulfilled yet if (requestIds.length != 0 && randomWords[requestIds[requestIds.length - 1]] == 0) { revert SeedCannotBeUpdatedYet(); } if (lastSeedUpdatedTime + MIN_SEED_UPDATE_TIME > block.timestamp) { revert CanOnlyRequestAfterTheNextCheckpoint(); } // Will revert if subscription is not set and funded. requestId = COORDINATOR.requestRandomWords( KEY_HASH, subscriptionId, REQUEST_CONFIRMATIONS, CALLBACK_GAS_LIMIT, NUM_WORDS ); requestIds.push(requestId); lastSeedUpdatedTime += MIN_SEED_UPDATE_TIME; emit RequestSent(requestId, NUM_WORDS); return requestId; } function fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal override { // require(_requestId == requestIds[requestIds.length - 1], "request not found"); if (randomWords[_requestId] != 0) { revert RequestAlreadyFulfilled(); } uint random = _randomWords[0]; if (random == 0) { // Not sure if 0 can be selected, but in case use previous block hash as pseudo random number random = uint(blockhash(block.number - 1)); } randomWords[_requestId] = random; emit RequestFulfilled(_requestId, random); // Are we at the threshold for a new week if (nextCheckpoint <= ((block.timestamp) / 1 days) * 1 days) { // Issue new daily rewards based on the new seed (TODO) Equipment[8] memory rewards = [ Equipment(COPPER_ORE, 100), Equipment(COAL_ORE, 200), Equipment(RUBY, 100), Equipment(MITHRIL_BAR, 200), Equipment(COOKED_BOWFISH, 100), Equipment(LEAF_FRAGMENTS, 20), Equipment(HELL_SCROLL, 300), Equipment(XP_BOOST, 1) ]; _storeDailyRewards(rewards); emit NewDailyRewards(rewards); nextCheckpoint = uint40((block.timestamp - 4 days) / 1 weeks) * 1 weeks + 4 days + 1 weeks; } } function getDailyReward() external view returns (Equipment memory equipment) { uint checkpoint = ((block.timestamp - 4 days) / 1 weeks) * 1 weeks + 4 days; uint day = ((block.timestamp / 1 days) * 1 days - checkpoint) / 1 days; equipment = _getDailyReward(day); } function getWeeklyReward() external view returns (Equipment memory equipment) { equipment = _getDailyReward(7); } function _getSeed(uint _timestamp) private view returns (uint) { uint offset = (_timestamp - startTime) / MIN_SEED_UPDATE_TIME; if (requestIds.length <= offset) { return 0; } return randomWords[requestIds[offset]]; } function hasSeed(uint _timestamp) external view returns (bool) { return _getSeed(_timestamp) != 0; } function getSeed(uint _timestamp) public view returns (uint seed) { seed = _getSeed(_timestamp); if (seed == 0) { revert NoValidSeed(); } } // Can be called by anyone as long as over 1 day has passed since the last call function updateDynamicActions() external { if ((lastDynamicUpdatedTime + MIN_DYNAMIC_ACTION_UPDATE_TIME) > block.timestamp) { revert CanOnlyRequestAfter1DayHasPassed(); } emit RemoveDynamicActions(lastAddedDynamicActions); // These are no longer available as existing actions U256 iter = U256.wrap(lastAddedDynamicActions.length); while (iter.neq(0)) { iter = iter.dec(); actions[lastAddedDynamicActions[iter.asUint256()]].isAvailable = false; } delete lastAddedDynamicActions; uint seed = getSeed(block.timestamp); uint16[] memory actionIdsToAdd = new uint16[](1); if (seed % 2 == 0) { // If it's even do X actionIdsToAdd[0] = 1; // ? } else { actionIdsToAdd[0] = 2; // ? } lastAddedDynamicActions = actionIdsToAdd; iter = U256.wrap(actionIdsToAdd.length); while (iter.neq(0)) { iter = iter.dec(); actions[actionIdsToAdd[iter.asUint256()]].isAvailable = true; } lastDynamicUpdatedTime = block.timestamp; emit AddDynamicActions(actionIdsToAdd); } function getSkill(uint _actionId) external view returns (Skill) { return actions[_actionId].skill; } function getActionRewards(uint _actionId) external view returns (ActionRewards memory) { return actionRewards[_actionId]; } function getPermissibleItemsForAction( uint _actionId ) external view returns ( uint16 handItemTokenIdRangeMin, uint16 handItemTokenIdRangeMax, bool actionChoiceRequired, Skill skill, uint32 minXP, bool actionAvailable ) { ActionInfo storage actionInfo = actions[_actionId]; return ( actionInfo.handItemTokenIdRangeMin, actionInfo.handItemTokenIdRangeMax, actionInfo.actionChoiceRequired, actionInfo.skill, actionInfo.minXP, actionInfo.isAvailable ); } function getXPPerHour(uint16 _actionId, uint16 _actionChoiceId) external view returns (uint16 xpPerHour) { return _actionChoiceId != 0 ? actionChoices[_actionId][_actionChoiceId].xpPerHour : actions[_actionId].xpPerHour; } function getNumSpawn(uint16 _actionId) external view returns (uint numSpawn) { return actions[_actionId].numSpawn; } function getCombatStats(uint16 _actionId) external view returns (CombatStats memory stats) { stats = actionCombatStats[_actionId]; } function getActionChoice(uint16 _actionId, uint16 _choiceId) external view returns (ActionChoice memory) { return actionChoices[_actionId][_choiceId]; } function _setAction(Action calldata _action) private { if (_action.actionId == 0) { revert ActionIdZeroNotAllowed(); } if (_action.info.handItemTokenIdRangeMin > _action.info.handItemTokenIdRangeMax) { revert MinCannotBeGreaterThanMax(); } actions[_action.actionId] = _action.info; // Set the rewards ActionRewards storage actionReward = actionRewards[_action.actionId]; _setActionGuaranteedRewards(_action, actionReward); // Now do the same for randomRewards _setActionRandomRewards(_action, actionReward); if (_action.info.skill == Skill.COMBAT) { actionCombatStats[_action.actionId] = _action.combatStats; } } function _setActionGuaranteedRewards(Action calldata _action, ActionRewards storage actionReward) private { if (_action.guaranteedRewards.length != 0) { actionReward.guaranteedRewardTokenId1 = _action.guaranteedRewards[0].itemTokenId; actionReward.guaranteedRewardRate1 = _action.guaranteedRewards[0].rate; } if (_action.guaranteedRewards.length > 1) { actionReward.guaranteedRewardTokenId2 = _action.guaranteedRewards[1].itemTokenId; actionReward.guaranteedRewardRate2 = _action.guaranteedRewards[1].rate; } if (_action.guaranteedRewards.length > 2) { actionReward.guaranteedRewardTokenId3 = _action.guaranteedRewards[2].itemTokenId; actionReward.guaranteedRewardRate3 = _action.guaranteedRewards[2].rate; } } function _setActionRandomRewards(Action calldata _action, ActionRewards storage actionReward) private { if (_action.randomRewards.length != 0) { actionReward.randomRewardTokenId1 = _action.randomRewards[0].itemTokenId; actionReward.randomRewardChance1 = uint16(_action.randomRewards[0].rate); } if (_action.randomRewards.length > 1) { actionReward.randomRewardTokenId2 = _action.randomRewards[1].itemTokenId; actionReward.randomRewardChance2 = uint16(_action.randomRewards[1].rate); } if (_action.randomRewards.length > 2) { actionReward.randomRewardTokenId3 = _action.randomRewards[2].itemTokenId; actionReward.randomRewardChance3 = uint16(_action.randomRewards[2].rate); } if (_action.randomRewards.length > 3) { actionReward.randomRewardTokenId4 = _action.randomRewards[3].itemTokenId; actionReward.randomRewardChance4 = uint16(_action.randomRewards[3].rate); } } function _addAction(Action calldata _action) private { if (_action.info.isDynamic) { revert DynamicActionsCannotBeAdded(); } if (actions[_action.actionId].skill != Skill.NONE) { revert ActionAlreadyExists(); } _setAction(_action); emit AddAction(_action); } function addActions(Action[] calldata _actions) external onlyOwner { U256 iter = U256.wrap(_actions.length); while (iter.neq(0)) { iter = iter.dec(); uint16 i = iter.asUint16(); _addAction(_actions[i]); } } function addAction(Action calldata _action) external onlyOwner { _addAction(_action); } function editAction(Action calldata _action) external onlyOwner { if (actions[_action.actionId].skill == Skill.NONE) { revert ActionDoesNotExist(); } _setAction(_action); emit EditAction(_action); } function _addActionChoice(uint16 _actionId, uint16 _actionChoiceId, ActionChoice calldata _actionChoice) private { if (_actionChoiceId == 0) { revert ActionChoiceIdZeroNotAllowed(); } if (_actionChoice.outputTokenId != 0 && _actionChoice.outputNum != 1) { revert OnlySupportingMax1Output(); } if (actionChoices[_actionId][_actionChoiceId].skill != Skill.NONE) { revert ActionChoiceAlreadyExists(); } actionChoices[_actionId][_actionChoiceId] = _actionChoice; } // actionId of 0 means it is not tied to a specific action function addActionChoice( uint16 _actionId, uint16 _actionChoiceId, ActionChoice calldata _actionChoice ) external onlyOwner { _addActionChoice(_actionId, _actionChoiceId, _actionChoice); emit AddActionChoice(_actionId, _actionChoiceId, _actionChoice); } function addActionChoices( uint16 _actionId, uint16[] calldata _actionChoiceIds, ActionChoice[] calldata _actionChoices ) external onlyOwner { if (_actionChoiceIds.length != _actionChoices.length) { revert LengthMismatch(); } U256 iter = U256.wrap(_actionChoices.length); if (iter.eq(0)) { revert NoActionChoices(); } while (iter.neq(0)) { iter = iter.dec(); uint16 i = iter.asUint16(); _addActionChoice(_actionId, _actionChoiceIds[i], _actionChoices[i]); } emit AddActionChoices(_actionId, _actionChoiceIds, _actionChoices); } function addBulkActionChoices( uint16[] calldata _actionIds, uint16[][] calldata _actionChoiceIds, ActionChoice[][] calldata _actionChoices ) external onlyOwner { U256 iter = U256.wrap(0); if (_actionIds.length != _actionChoices.length) { revert LengthMismatch(); } if (_actionIds.length == 0) { revert NoActionChoices(); } while (iter.lt(_actionIds.length)) { uint16 i = iter.asUint16(); uint16 actionId = _actionIds[i]; emit AddActionChoices(actionId, _actionChoiceIds[i], _actionChoices[i]); U256 iter2 = U256.wrap(0); if (_actionChoiceIds[i].length != _actionChoices[i].length) { revert LengthMismatch(); } while (iter2.lt(_actionChoices[i].length)) { uint16 j = iter2.asUint16(); _addActionChoice(actionId, _actionChoiceIds[i][j], _actionChoices[i][j]); iter2 = iter2.inc(); } iter = iter.inc(); } } function setAvailable(uint16 _actionId, bool _isAvailable) external onlyOwner { if (actions[_actionId].skill == Skill.NONE) { revert ActionDoesNotExist(); } if (actions[_actionId].isDynamic) { revert DynamicActionsCannotBeSet(); } actions[_actionId].isAvailable = _isAvailable; emit SetAvailableAction(_actionId, _isAvailable); } // solhint-disable-next-line no-empty-blocks function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} }
{ "optimizer": { "enabled": true, "runs": 999999, "details": { "yul": true } }, "viaIR": true, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": { "contracts/Players/PlayerLibrary.sol": { "PlayerLibrary": "0xaaececb8429c524420820cf8d610d7a49dc887d2" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ActionChoiceIdRequired","type":"error"},{"inputs":[],"name":"ActionChoiceMinimumXPNotReached","type":"error"},{"inputs":[],"name":"ActionMinimumXPNotReached","type":"error"},{"inputs":[],"name":"ActionNotAvailable","type":"error"},{"inputs":[],"name":"ActionTimespanExceedsMaxTime","type":"error"},{"inputs":[],"name":"ActionTimespanZero","type":"error"},{"inputs":[],"name":"ArgumentLengthMismatch","type":"error"},{"inputs":[],"name":"AttireMinimumXPNotReached","type":"error"},{"inputs":[],"name":"BoostTimeAlreadyStarted","type":"error"},{"inputs":[],"name":"CannotEquipTwoHandedAndOtherEquipment","type":"error"},{"inputs":[],"name":"ConsumeableMinimumXPNotReached","type":"error"},{"inputs":[],"name":"DoNotHaveEnoughQuantityToEquipToAction","type":"error"},{"inputs":[],"name":"EquipSameItem","type":"error"},{"inputs":[],"name":"IncorrectEquippedItem","type":"error"},{"inputs":[{"internalType":"uint16","name":"equippedItemTokenId","type":"uint16"}],"name":"IncorrectLeftHandEquipment","type":"error"},{"inputs":[{"internalType":"uint16","name":"equippedItemTokenId","type":"uint16"}],"name":"IncorrectRightHandEquipment","type":"error"},{"inputs":[{"internalType":"uint16","name":"itemTokenId","type":"uint16"}],"name":"InvalidArmEquipment","type":"error"},{"inputs":[],"name":"InvalidCombatStyle","type":"error"},{"inputs":[],"name":"InvalidEquipPosition","type":"error"},{"inputs":[],"name":"InvalidSelector","type":"error"},{"inputs":[],"name":"InvalidSkill","type":"error"},{"inputs":[],"name":"InvalidStartSlot","type":"error"},{"inputs":[],"name":"ItemDoesNotExist","type":"error"},{"inputs":[],"name":"ItemMinimumXPNotReached","type":"error"},{"inputs":[],"name":"NoActiveBoost","type":"error"},{"inputs":[{"internalType":"uint16","name":"itemTokenId","type":"uint16"}],"name":"NoItemBalance","type":"error"},{"inputs":[],"name":"NotABoostVial","type":"error"},{"inputs":[],"name":"NotActive","type":"error"},{"inputs":[],"name":"NotEquipped","type":"error"},{"inputs":[],"name":"NotItemNFT","type":"error"},{"inputs":[],"name":"NotOwner","type":"error"},{"inputs":[],"name":"NotPlayerNFT","type":"error"},{"inputs":[],"name":"SkillsArrayZero","type":"error"},{"inputs":[],"name":"StartTimeTooFarInTheFuture","type":"error"},{"inputs":[],"name":"TooManyActionsQueued","type":"error"},{"inputs":[],"name":"TooManyActionsQueuedSomeAlreadyExist","type":"error"},{"inputs":[],"name":"UnsupportedAttire","type":"error"},{"inputs":[],"name":"UnsupportedRegenerateItem","type":"error"},{"inputs":[],"name":"XPThresholdNotFound","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"queueId","type":"uint128"}],"name":"ActionAborted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"queueId","type":"uint128"}],"name":"ActionFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"queueId","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"elapsedTime","type":"uint256"}],"name":"ActionPartiallyFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"queueId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"elapsed","type":"uint256"}],"name":"AddPendingRandomReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"enum Skill","name":"skill","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"points","type":"uint32"}],"name":"AddXP","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint32","name":"xpThreshold","type":"uint32"},{"components":[{"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"internalType":"uint24","name":"amount","type":"uint24"}],"internalType":"struct Equipment[]","name":"rewards","type":"tuple[]"}],"indexed":false,"internalType":"struct XPThresholdReward","name":"xpThresholdReward","type":"tuple"}],"name":"AdminAddThresholdReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"itemTokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"ClaimedXPThresholdRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"}],"name":"ClearAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"queueId","type":"uint128"},{"indexed":false,"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Consume","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"components":[{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"uint24","name":"duration","type":"uint24"},{"internalType":"uint16","name":"val","type":"uint16"},{"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"internalType":"enum BoostType","name":"boostType","type":"uint8"}],"indexed":false,"internalType":"struct PlayerBoostInfo","name":"playerBoostInfo","type":"tuple"}],"name":"ConsumeBoostVial","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"queueId","type":"uint128"}],"name":"Died","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"enum Skill","name":"skill","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"level","type":"uint32"}],"name":"LevelUp","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":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numRemoved","type":"uint256"}],"name":"PendingRandomRewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"queueId","type":"uint128"},{"indexed":false,"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Reward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"queueId","type":"uint128"},{"indexed":false,"internalType":"uint256[]","name":"itemTokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"Rewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"},{"components":[{"components":[{"internalType":"uint16","name":"head","type":"uint16"},{"internalType":"uint16","name":"neck","type":"uint16"},{"internalType":"uint16","name":"body","type":"uint16"},{"internalType":"uint16","name":"arms","type":"uint16"},{"internalType":"uint16","name":"legs","type":"uint16"},{"internalType":"uint16","name":"boots","type":"uint16"},{"internalType":"uint16","name":"ring","type":"uint16"},{"internalType":"uint16","name":"reserved1","type":"uint16"},{"internalType":"uint128","name":"queueId","type":"uint128"}],"internalType":"struct Attire","name":"attire","type":"tuple"},{"internalType":"uint16","name":"actionId","type":"uint16"},{"internalType":"uint16","name":"regenerateId","type":"uint16"},{"internalType":"uint16","name":"choiceId","type":"uint16"},{"internalType":"uint16","name":"choiceId1","type":"uint16"},{"internalType":"uint16","name":"choiceId2","type":"uint16"},{"internalType":"uint16","name":"rightHandEquipmentTokenId","type":"uint16"},{"internalType":"uint16","name":"leftHandEquipmentTokenId","type":"uint16"},{"internalType":"uint24","name":"timespan","type":"uint24"},{"internalType":"enum CombatStyle","name":"combatStyle","type":"uint8"},{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"bool","name":"isValid","type":"bool"}],"indexed":false,"internalType":"struct QueuedAction[]","name":"queuedActions","type":"tuple[]"}],"name":"SetActionQueue","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldPlayerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newPlayerId","type":"uint256"}],"name":"SetActivePlayer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"playerId","type":"uint256"}],"name":"UnconsumeBoostVial","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"MAX_TIME","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"}],"name":"actionQueueLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"playerId","type":"uint256"}],"name":"activeBoosts","outputs":[{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"uint24","name":"duration","type":"uint24"},{"internalType":"uint16","name":"val","type":"uint16"},{"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"internalType":"enum BoostType","name":"boostType","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"xpThreshold","type":"uint32"},{"components":[{"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"internalType":"uint24","name":"amount","type":"uint24"}],"internalType":"struct Equipment[]","name":"rewards","type":"tuple[]"}],"internalType":"struct XPThresholdReward","name":"_xpThresholdReward","type":"tuple"}],"name":"addXPThresholdReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"xpThreshold","type":"uint32"},{"components":[{"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"internalType":"uint24","name":"amount","type":"uint24"}],"internalType":"struct Equipment[]","name":"rewards","type":"tuple[]"}],"internalType":"struct XPThresholdReward[]","name":"_xpThresholdRewards","type":"tuple[]"}],"name":"addXPThresholdRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"}],"name":"claimRandomRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"}],"name":"clearEverything","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_playerId","type":"uint256"}],"name":"clearEverythingBeforeTokenTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"},{"internalType":"uint16","name":"_itemTokenId","type":"uint16"},{"internalType":"uint40","name":"_startTime","type":"uint40"}],"name":"consumeBoost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"}],"name":"getActionQueue","outputs":[{"components":[{"components":[{"internalType":"uint16","name":"head","type":"uint16"},{"internalType":"uint16","name":"neck","type":"uint16"},{"internalType":"uint16","name":"body","type":"uint16"},{"internalType":"uint16","name":"arms","type":"uint16"},{"internalType":"uint16","name":"legs","type":"uint16"},{"internalType":"uint16","name":"boots","type":"uint16"},{"internalType":"uint16","name":"ring","type":"uint16"},{"internalType":"uint16","name":"reserved1","type":"uint16"},{"internalType":"uint128","name":"queueId","type":"uint128"}],"internalType":"struct Attire","name":"attire","type":"tuple"},{"internalType":"uint16","name":"actionId","type":"uint16"},{"internalType":"uint16","name":"regenerateId","type":"uint16"},{"internalType":"uint16","name":"choiceId","type":"uint16"},{"internalType":"uint16","name":"choiceId1","type":"uint16"},{"internalType":"uint16","name":"choiceId2","type":"uint16"},{"internalType":"uint16","name":"rightHandEquipmentTokenId","type":"uint16"},{"internalType":"uint16","name":"leftHandEquipmentTokenId","type":"uint16"},{"internalType":"uint24","name":"timespan","type":"uint24"},{"internalType":"enum CombatStyle","name":"combatStyle","type":"uint8"},{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"bool","name":"isValid","type":"bool"}],"internalType":"struct QueuedAction[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"}],"name":"getPendingRandomRewards","outputs":[{"components":[{"internalType":"uint16","name":"actionId","type":"uint16"},{"internalType":"uint128","name":"queueId","type":"uint128"},{"internalType":"uint40","name":"timestamp","type":"uint40"},{"internalType":"uint24","name":"elapsedTime","type":"uint24"}],"internalType":"struct PendingRandomReward[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"},{"internalType":"bytes32","name":"_name","type":"bytes32"},{"internalType":"bytes32","name":"_avatarName","type":"bytes32"},{"internalType":"string","name":"_avatarDescription","type":"string"},{"internalType":"string","name":"imageURI","type":"string"}],"name":"getURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ItemNFT","name":"_itemNFT","type":"address"},{"internalType":"contract PlayerNFT","name":"_playerNFT","type":"address"},{"internalType":"contract World","name":"_world","type":"address"},{"internalType":"address","name":"_implQueueActions","type":"address"},{"internalType":"address","name":"_implProcessActions","type":"address"},{"internalType":"address","name":"_implRewards","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"name":"itemBeforeTokenTransfer","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"mintBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_playerId","type":"uint256"},{"internalType":"enum Skill[2]","name":"_startSkills","type":"uint8[2]"},{"internalType":"bool","name":"_makeActive","type":"bool"}],"name":"mintedPlayer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_playerId","type":"uint256"},{"components":[{"internalType":"bool","name":"includeLoot","type":"bool"},{"internalType":"bool","name":"includePastRandomRewards","type":"bool"},{"internalType":"bool","name":"includeXPRewards","type":"bool"}],"internalType":"struct PendingFlags","name":"_flags","type":"tuple"}],"name":"pendingRewards","outputs":[{"components":[{"components":[{"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"internalType":"uint24","name":"amount","type":"uint24"}],"internalType":"struct Equipment[]","name":"consumed","type":"tuple[]"},{"components":[{"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"internalType":"uint24","name":"amount","type":"uint24"}],"internalType":"struct Equipment[]","name":"produced","type":"tuple[]"},{"components":[{"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"internalType":"uint24","name":"amount","type":"uint24"}],"internalType":"struct Equipment[]","name":"producedPastRandomRewards","type":"tuple[]"},{"components":[{"internalType":"uint16","name":"itemTokenId","type":"uint16"},{"internalType":"uint24","name":"amount","type":"uint24"}],"internalType":"struct Equipment[]","name":"producedXPRewards","type":"tuple[]"},{"internalType":"bool","name":"died","type":"bool"}],"internalType":"struct PendingOutput","name":"pendingOutput","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"playerId","type":"uint256"}],"name":"players","outputs":[{"internalType":"int16","name":"melee","type":"int16"},{"internalType":"int16","name":"magic","type":"int16"},{"internalType":"int16","name":"range","type":"int16"},{"internalType":"int16","name":"defence","type":"int16"},{"internalType":"int16","name":"health","type":"int16"},{"internalType":"uint8","name":"version","type":"uint8"},{"internalType":"uint160","name":"totalXP","type":"uint160"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"}],"name":"processActions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"}],"name":"setActivePlayer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_dailyRewardsEnabled","type":"bool"}],"name":"setDailyRewardsEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_implQueueActions","type":"address"},{"internalType":"address","name":"_implProcessActions","type":"address"},{"internalType":"address","name":"_implRewards","type":"address"}],"name":"setImpls","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"},{"internalType":"uint16","name":"multiplier","type":"uint16"}],"name":"setSpeedMultiplier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"},{"components":[{"components":[{"internalType":"uint16","name":"head","type":"uint16"},{"internalType":"uint16","name":"neck","type":"uint16"},{"internalType":"uint16","name":"body","type":"uint16"},{"internalType":"uint16","name":"arms","type":"uint16"},{"internalType":"uint16","name":"legs","type":"uint16"},{"internalType":"uint16","name":"boots","type":"uint16"},{"internalType":"uint16","name":"ring","type":"uint16"},{"internalType":"uint16","name":"reserved1","type":"uint16"},{"internalType":"uint128","name":"queueId","type":"uint128"}],"internalType":"struct Attire","name":"attire","type":"tuple"},{"internalType":"uint16","name":"actionId","type":"uint16"},{"internalType":"uint16","name":"regenerateId","type":"uint16"},{"internalType":"uint16","name":"choiceId","type":"uint16"},{"internalType":"uint16","name":"choiceId1","type":"uint16"},{"internalType":"uint16","name":"choiceId2","type":"uint16"},{"internalType":"uint16","name":"rightHandEquipmentTokenId","type":"uint16"},{"internalType":"uint16","name":"leftHandEquipmentTokenId","type":"uint16"},{"internalType":"uint24","name":"timespan","type":"uint24"},{"internalType":"enum CombatStyle","name":"combatStyle","type":"uint8"},{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"bool","name":"isValid","type":"bool"}],"internalType":"struct QueuedAction","name":"_queuedAction","type":"tuple"},{"internalType":"enum ActionQueueStatus","name":"_queueStatus","type":"uint8"}],"name":"startAction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"},{"components":[{"components":[{"internalType":"uint16","name":"head","type":"uint16"},{"internalType":"uint16","name":"neck","type":"uint16"},{"internalType":"uint16","name":"body","type":"uint16"},{"internalType":"uint16","name":"arms","type":"uint16"},{"internalType":"uint16","name":"legs","type":"uint16"},{"internalType":"uint16","name":"boots","type":"uint16"},{"internalType":"uint16","name":"ring","type":"uint16"},{"internalType":"uint16","name":"reserved1","type":"uint16"},{"internalType":"uint128","name":"queueId","type":"uint128"}],"internalType":"struct Attire","name":"attire","type":"tuple"},{"internalType":"uint16","name":"actionId","type":"uint16"},{"internalType":"uint16","name":"regenerateId","type":"uint16"},{"internalType":"uint16","name":"choiceId","type":"uint16"},{"internalType":"uint16","name":"choiceId1","type":"uint16"},{"internalType":"uint16","name":"choiceId2","type":"uint16"},{"internalType":"uint16","name":"rightHandEquipmentTokenId","type":"uint16"},{"internalType":"uint16","name":"leftHandEquipmentTokenId","type":"uint16"},{"internalType":"uint24","name":"timespan","type":"uint24"},{"internalType":"enum CombatStyle","name":"combatStyle","type":"uint8"},{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"bool","name":"isValid","type":"bool"}],"internalType":"struct QueuedAction[]","name":"_queuedActions","type":"tuple[]"},{"internalType":"uint16","name":"_boostItemTokenId","type":"uint16"},{"internalType":"enum ActionQueueStatus","name":"_queueStatus","type":"uint8"}],"name":"startActions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startXP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"},{"internalType":"enum Skill","name":"_skill","type":"uint8"},{"internalType":"uint32","name":"_xp","type":"uint32"}],"name":"testOnlyModifyLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_playerId","type":"uint256"}],"name":"unequipBoostVial","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"playerId","type":"uint256"},{"internalType":"enum Skill","name":"skill","type":"uint8"}],"name":"xp","outputs":[{"internalType":"uint32","name":"xp","type":"uint32"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a08060405234620000e157306080526000549060ff8260081c166200008f575060ff8082161062000053575b604051615aa29081620000e78239608051818181612d0a01528181612f8501526132fa0152f35b60ff90811916176000557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160ff8152a1386200002c565b62461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608490fd5b600080fdfe608080604052600436109081156100ef575b50346100ea577f871f86220000000000000000000000000000000000000000000000000000000090600035907fffffffff000000000000000000000000000000000000000000000000000000008281809416926100d5575b505016036100ab5760008073ffffffffffffffffffffffffffffffffffffffff61010a5416368280378136915af43d6000803e156100a6573d6000f35b3d6000fd5b60046040517f7352d91c000000000000000000000000000000000000000000000000000000008152fd5b908092503660040360031b1b16168138610069565b600080fd5b600090813560e01c90816302f0b787146139cf575080631962e12c146138d157806325533ee11461373a578063267b80e3146136d6578063269499841461369a57806328809d5a1461365f5780633659cfe6146132a95780634f1ef28614612f075780634f24bc1414612e905780634f491a8a14612e2c578063524b049414612dde57806352d1902d14612cc457806367691a9614612acb578063715018a614612a2d57806371854d54146125c15780637384aacf146121db578063791af2c1146121765780638da5cb5b14612124578063974d13ff14611df55780639a63ca5814611d035780639a768dcf14611c6f578063ac9650d814611a8a578063b23013bb146112d3578063b96103601461123a578063bb5625941461115a578063bba9042d1461109f578063c0dd14b014610dd7578063cc2a9a5b14610a7e578063ccda394714610a32578063d81d0a1514610916578063dee935b51461075c578063f2fde38b14610673578063f4c41276146104f9578063f71d96cb14610451578063f9658e5d146102ef5763ffb9f26d0361001157346102ec57610292366144a2565b5050505073ffffffffffffffffffffffffffffffffffffffff610102541633036102c2576102bf90614c15565b80f35b60046040517fa59c884c000000000000000000000000000000000000000000000000000000008152fd5b80fd5b50346102ec576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261044d57610103546040517efdd58e000000000000000000000000000000000000000000000000000000008152336004808301919091523560248201819052929182908290604490829073ffffffffffffffffffffffffffffffffffffffff165afa8015610442578490610414575b60019150036103ea5760fd9033845252806040832054036103c0576103b8906103b2614b1b565b33614c42565b600160c95580f35b60046040517f80cb55e2000000000000000000000000000000000000000000000000000000008152fd5b60046040517f30cd7471000000000000000000000000000000000000000000000000000000008152fd5b508181813d831161043b575b61042a81836141ab565b810103126100ea576001905161038b565b503d610420565b6040513d86823e3d90fd5b5080fd5b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57604060e0916004358152610101602052205473ffffffffffffffffffffffffffffffffffffffff604051918060010b83528060101c60010b60208401528060201c60010b60408401528060301c60010b60608401528060401c60010b608084015260ff8160501c1660a084015260581c1660c0820152f35b50346102ec5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec5760043561053461425d565b906044359064ffffffffff82168092036100ea57610103546040517efdd58e000000000000000000000000000000000000000000000000000000008152336004820152602481018390526020939173ffffffffffffffffffffffffffffffffffffffff919085908290604490829086165afa801561066857879061063a575b60019150036103ea5733865260fd8452826040872054036103c0576106319461ffff916105de614b1b565b6101085460081c16937ff4c412760000000000000000000000000000000000000000000000000000000060405196870152602486015216604484015260648301526064825261062c8261415f565b615a3e565b50600160c95580f35b508481813d8311610661575b61065081836141ab565b810103126100ea57600190516105b3565b503d610646565b6040513d89823e3d90fd5b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec576106ab61404c565b6106b361455b565b73ffffffffffffffffffffffffffffffffffffffff8116156106d8576102bf906145da565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b50346102ec577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc60a08136011261044d5767ffffffffffffffff90606435828111610912576107af90369060040161452d565b939091608435848111610901579482916107d16108499697369060040161452d565b96909160043585526020976101008952604086209361083a604051998a9788977f7e50b36a00000000000000000000000000000000000000000000000000000000895260243560048a01526024890152604435604489015260a0606489015260a4880191614bc7565b92858403016084860152614bc7565b038173aaececb8429c524420820cf8d610d7a49dc887d25af493841561090557819461088b575b50505061088760405192828493845283019061445f565b0390f35b90919293503d8083853e61089f81856141ab565b8301928481850312610901578051918211610901570182601f8201121561044d578051916108cc836141ec565b936108da60405195866141ab565b8385528584840101116102ec5750906108f89184808501910161443c565b90828080610870565b8280fd5b50604051903d90823e3d90fd5b8380fd5b50346102ec57610925366144a2565b91909373ffffffffffffffffffffffffffffffffffffffff8061010354163303610a0857869581610102541692833b15610a04576109d888969287936109a86040519a8b998a9889977fd81d0a15000000000000000000000000000000000000000000000000000000008952166004880152606060248801526064870191614b8a565b917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc858403016044860152614b8a565b03925af180156109f9576109e95750f35b6109f29061417b565b6102ec5780f35b6040513d84823e3d90fd5b8780fd5b60046040517f3434655b000000000000000000000000000000000000000000000000000000008152fd5b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec576001604060209260043581526101018452200154604051908152f35b50346102ec5760c07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec5760043573ffffffffffffffffffffffffffffffffffffffff90818116809103610901576024359180831680930361091257604435908082168203610dd35760643581811681036100ea576084358281168091036100ea5760a4359283168093036100ea57865460ff94858260081c161596878098610dc7575b8015610db1575b15610d2d576001957fffffffff0000000000000000000000000000000000000000000000000000000094848a8d8a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007bffffffffffffffffffffffffffffffffffffffff00000000000000009916179055610cff575b50610bbd898d5460081c16610bb881614a80565b614a80565b610bc6336145da565b8b549a610be48a8d60081c16610bdb81614a80565b610bb881614a80565b8860c9557fffffffffffffffffffffffff00000000000000000000000000000000000000009361010290858254161790556101039084825416179055885496610108907fffffffffffffffffffffff0000000000000000000000000000000000000000ff74ffffffffffffffffffffffffffffffffffffffff0083549260081b169116179055610109908382541617905561010a9182541617905560401b1691161717905561010570010000000000000000000000000000000184825416179055610cad575080f35b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1681557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a180f35b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016610101178c558c610ba4565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152fd5b50303b158015610b2e5750600187841614610b2e565b50600187841610610b27565b8480fd5b50346102ec576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261044d576004359073ffffffffffffffffffffffffffffffffffffffff908161010354168160405180927efdd58e0000000000000000000000000000000000000000000000000000000082528180610e838933600484016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03915afa8015611094578590611066575b60019150036103ea5733845260fd8152826040852054036103c057610eb7614b1b565b82845260fe815260ff604085205460601c166006811015611039571561100f5782845260fe815264ffffffffff6040852054164210610fe55760fe84926101025416918484525261ffff604083205460501c1690803b15610901576064839260405194859384927f156e29f60000000000000000000000000000000000000000000000000000000084523360048501526024840152600160448401525af18015610fda57610fa3575b506040805133815260208101929092527fc58f58d43fda8aed0f30e7d44ea0d54e5e9e3561da1b4442b98a8c26ea562b559190819081015b0390a1600160c95580f35b7fc58f58d43fda8aed0f30e7d44ea0d54e5e9e3561da1b4442b98a8c26ea562b559192610fd2610f989261417b565b929150610f60565b6040513d85823e3d90fd5b60046040517f6d7fe907000000000000000000000000000000000000000000000000000000008152fd5b60046040517fbc1c8856000000000000000000000000000000000000000000000000000000008152fd5b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526021600452fd5b508181813d831161108d575b61107c81836141ab565b81010312610dd35760019051610e94565b503d611072565b6040513d87823e3d90fd5b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57600435815260fe602052604081205460ff8160601c166040519164ffffffffff8116835262ffffff8160281c16602084015261ffff90818160401c16604085015260501c166060830152600681101561112d5760a092506080820152f35b6024837f4e487b710000000000000000000000000000000000000000000000000000000081526021600452fd5b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57610103546040517efdd58e000000000000000000000000000000000000000000000000000000008152336004808301919091523560248201819052916020908290604490829073ffffffffffffffffffffffffffffffffffffffff165afa8015610fda578390611208575b60019150036103ea576102bf90336151f8565b506020813d8211611232575b81611221602093836141ab565b8101031261090157600190516111f5565b3d9150611214565b50346102ec5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57602435600f81101561044d576044359063ffffffff8216809203610901576112a89061129461455b565b6004358452610100602052604084206140af565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000082541617905580f35b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57610103546040517efdd58e00000000000000000000000000000000000000000000000000000000815233600480830191909152356024820152906020908290604490829073ffffffffffffffffffffffffffffffffffffffff165afa80156109f9578290611a57575b60019150036103ea5733815260fd6020526004356040822054036103c057611392614b1b565b61139e600435336155d0565b60043582526101016020526001604083200190805190680100000000000000008211611a2a57825482845580831061196b575b50602001908284526020842084925b82841061157557858560405190606082013383526004356020840152606060408401528154809152608083019184526020842090845b81811061144c57857fa1b500ba45168a135422ed2fa8193eaebee56674894c4032eeb12b1cb23763b086860387a1600160c95580f35b9091926002610280600192865461ffff8116825261ffff8160101c16602083015261ffff8160201c16604083015261ffff8160301c16606083015261ffff8160401c16608083015261ffff8160501c1660a083015261ffff8160601c1660c083015261ffff8160701c1660e083015260801c6101008201528387015461ffff811661012083015261ffff8160101c1661014083015261ffff8160201c1661016083015261ffff8160301c1661018083015261ffff8160401c166101a083015261ffff8160501c166101c083015261ffff8160601c166101e083015262ffffff8160701c1661020083015260ff9061154c6102208401838360881c1661427d565b609081901c64ffffffffff1661024084015260b81c161515610260820152019401929101611416565b80516117986fffffffffffffffffffffffffffffffff610100835161ffff8151167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008854161787556115ff61ffff60208301511688907fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff63ffff000083549260101b169116179055565b604081015187547fffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffff1660209190911b65ffff0000000016178755606081015187547fffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffffffff1660309190911b67ffff00000000000016178755608081015187547fffffffffffffffffffffffffffffffffffffffffffff0000ffffffffffffffff1660409190911b69ffff00000000000000001617875560a081015187547fffffffffffffffffffffffffffffffffffffffff0000ffffffffffffffffffff1660509190911b6bffff000000000000000000001617875560c081015187547fffffffffffffffffffffffffffffffffffff0000ffffffffffffffffffffffff1660609190911b6dffff0000000000000000000000001617875560e0810151875492909101516dffffffffffffffffffffffffffff90921660709190911b6fffff00000000000000000000000000001617911660801b7fffffffffffffffffffffffffffffffff0000000000000000000000000000000016178455565b602081810151600185018054604080860151606080880151608089015160a08a015160c08b015160e08c01517fffffffffffffffffffffffffffffffffffff000000000000000000000000000090981661ffff909a169990991763ffff000060109690961b959095169490941765ffff000000009290991b919091169790971760309790971b67ffff0000000000001696909617911b69ffff0000000000000000161760509390931b6bffff0000000000000000000016929092179190921b6dffff0000000000000000000000001617905561010081015190600184015461012082015190600782101561193e5792826001959271ff00000000000000000000000000000000006002967fffffffffffffffff00000000000000000000ffffffffffffffffffffffffffff70ffffff000000000000000000000000000077ff000000000000000000000000000000000000000000000061016076ffffffffff00000000000000000000000000000000000061014060209c015160901b16970151151560b81b169660701b169116179160881b1617171784860155019201930192906113e0565b60248a7f4e487b710000000000000000000000000000000000000000000000000000000081526021600452fd5b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80821682036119fd57831683036119d057838552602085209060011b8101908360011b015b8181106119be57506113d1565b808660029255866001820155016119b1565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024847f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b506020813d602011611a82575b81611a71602093836141ab565b8101031261044d576001905161136c565b3d9150611a64565b50346102ec576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261044d5767ffffffffffffffff6004358181116109125790611ade8492369060040161407e565b9091611ae98261493b565b92611af760405194856141ab565b8284527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0611b248461493b565b01855b818110611c60575050845b838110611bb7575050505060405191838301848452825180915260408401948060408360051b870101940192955b828710611b6d5785850386f35b909192938280611ba7837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08a60019603018652885161445f565b9601920196019592919092611b60565b8060059796971b8201357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe183360301811215610a0457820190813591848311611c5c5787018236038113611c5c57611c17611c3991611c54943691614226565b8980611c21614879565b928b81519101305af4611c32614849565b90306149ff565b611c4382886149eb565b52611c4e81876149eb565b50614953565b959495611b32565b8880fd5b60608682018901528701611b27565b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57611ca7614b1b565b61063173ffffffffffffffffffffffffffffffffffffffff61010a5416604051907f9a768dcf00000000000000000000000000000000000000000000000000000000602083015260043560248301526024825261062c8261418f565b50346102ec5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57611d3b61404c565b6024359073ffffffffffffffffffffffffffffffffffffffff908183168093036109125760443591821680920361091257611d7461455b565b610108907fffffffffffffffffffffff0000000000000000000000000000000000000000ff74ffffffffffffffffffffffffffffffffffffffff0083549260081b1691161790557fffffffffffffffffffffffff000000000000000000000000000000000000000091610109908382541617905561010a9182541617905580f35b50346102ec5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57611e2d61404c565b90606091827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc36011261044d576040519067ffffffffffffffff90848301828111848210176120f7576040526044358015158103610dd3578352606435928315158403610dd357602093848201908152611ea561406f565b9060408301918252866080604051611ebc8161415f565b8a81528a898201528a60408201528a8082015201526040519273ffffffffffffffffffffffffffffffffffffffff878501957f871f862200000000000000000000000000000000000000000000000000000000875216602485015260243560448501525115156064840152511515608483015251151560a482015260a4815260e08101818110848211176120ca57604052518491829190305afa92611f5f614849565b93156120bb578351840194838601948481880312610901578481015190848211610912579060a091018097031261044d5760405194611f9d8661415f565b84870151848111610912578186611fb6928a0101615285565b86526040870151848111610912578186611fd2928a0101615285565b9385870194855282880151818111610dd3578287611ff2928b0101615285565b936040880194855260808901519182116102ec5750926120ae949261208c61205861203860a061202b61209d978c839f9b8c0101615285565b98858d01998a5201615355565b9860808b01998a526040519b8c9b828d5251918c015260c08b01906143f4565b9451947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe095868b83030160408c01526143f4565b9151908489840301908901526143f4565b9151908583030160808601526143f4565b9051151560a08301520390f35b838381519283156102ec575001fd5b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b50346102ec57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57602073ffffffffffffffffffffffffffffffffffffffff60335416604051908152f35b50346102ec5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec576121ae61404c565b73ffffffffffffffffffffffffffffffffffffffff61010354163303610a08576102bf9060243590614c42565b50346102ec576080807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261044d576004359060243567ffffffffffffffff808211610dd35736602383011215610dd3578160040135908111610dd357610280906024828202840101933685116125bd576044359361ffff8516809503610a0457606435936003851015611c5c57610103546040517efdd58e000000000000000000000000000000000000000000000000000000008152336004820152602481018a905260209873ffffffffffffffffffffffffffffffffffffffff9490929091908a908290604490829089165afa80156125b2578c90612580575b60019150036103ea57338b5260fd89528960408c2054036103c0576122fc614b1b565b6123058661493b565b9561231360405197886141ab565b86526024018886015b8282106123b2578b6106317f7384aacf000000000000000000000000000000000000000000000000000000008d61062c8e8e8e61237b8f8f8f6101085460081c1697604051998a978801526024870152604486015260a485019061428a565b9160648401526084830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018452836141ab565b81360384811261257c57604051916123c9836140f6565b610120809212612578578b604051926123e184614142565b6123ea8661426e565b84526123f782870161426e565b828501526124076040870161426e565b604085015260609361241a85880161426e565b858201526124298b880161426e565b8b82015260a09261243b84890161426e565b8483015260c09061244d828a0161426e565b8284015261245d60e08a0161426e565b60e084015261010092838a01356fffffffffffffffffffffffffffffffff8116810361256f57848201528852612494848a0161426e565b90880152610140936124a7858a0161426e565b6040890152610160966124bb888b0161426e565b908901526124cc6101808a0161426e565b8d8901526124dd6101a08a0161426e565b908801526124ee6101c0890161426e565b908701526124ff6101e0880161426e565b60e08701526125116102008801614b0b565b9086015261022086013590600782101561256a578501526102408501359064ffffffffff82168203612566578401526102608401359283151584036125625786938d9382015281520191019061231c565b8e80fd5b8f80fd5b508f80fd5b50505050508f80fd5b8d80fd5b8c80fd5b508981813d83116125ab575b61259681836141ab565b810103126125a757600190516122d9565b8b80fd5b503d61258c565b6040513d8e823e3d90fd5b8680fd5b50346102ec576102c07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec576004357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc36016102808112610901576102a43591600383101561091257610103546040517efdd58e0000000000000000000000000000000000000000000000000000000081523360048201526024810183905273ffffffffffffffffffffffffffffffffffffffff93916020919082908290604490829089165afa80156106685787906129ff575b60019150036103ea5733865260fd8152826040872054036103c0576126bd614b1b565b604051946040860186811067ffffffffffffffff8211176129d2576040526001865281875b818110612935575050604051926126f8846140f6565b610120809112610a045760405161270e81614142565b61ffff6024358181168103612931578252604435818116810361293157858301526064358181168103612931576040830152608435818116810361293157606083015260a435818116810361293157608083015260c43581811681036129315760a083015260e43581811681036129315760c08301526101043581811681036129315760e083015261012435916fffffffffffffffffffffffffffffffff83168303612931576101009283820152865261014435818116810361293157858701526101643581811681036129315760408701526101843581811681036129315760608701526101a43581811681036129315760808701526101c43581811681036129315760a08701526101e43581811681036129315760c087015261020435908116810361292d5760e0860152610224359062ffffff8216820361292d5785015261024435906007821015611c5c578401526102643564ffffffffff81168103610a0457610140840152610284358015158103610a0457610631967f7384aacf0000000000000000000000000000000000000000000000000000000096856128f59361016061062c9801526128c2836149af565b526128cc826149af565b506101085460081c169560405197889586015260248501526080604485015260a484019061428a565b908760648401526084830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018452836141ab565b8980fd5b8a80fd5b604051612941816140f6565b8960405161294e81614142565b8181528185820152816040820152816060818184015281608081818601528160a09181838801528160c09581878a01528160e08a015261010098828a8201528b52818d8c01528160408c01528a01528801528601528401528160e084015282015289610120820152896101408201528961016082015282828a0101520182906126e2565b6024887f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b508181813d8311612a26575b612a1581836141ab565b810103126125bd576001905161269a565b503d612a0b565b50346102ec57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57612a6461455b565b8073ffffffffffffffffffffffffffffffffffffffff6033547fffffffffffffffffffffffff00000000000000000000000000000000000000008116603355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57600435815261010160205260016040822001908154612b198161493b565b91612b2760405193846141ab565b81835260208301938152602081209080945b838610612b5657604051602080825281906108879082018861428a565b604051612b62816140f6565b604051612b6e81614142565b845461ffff8116825261ffff8160101c16602083015261ffff8160201c16604083015261ffff8160301c16606083015261ffff8160401c16608083015261ffff8160501c1660a083015261ffff8160601c1660c083015261ffff8160701c1660e083015260801c6101008201528152600184015461ffff8116602083015261ffff8160101c16604083015261ffff8160201c16606083015261ffff8160301c16608083015261ffff8160401c1660a083015261ffff8160501c1660c083015261ffff8160601c1660e083015262ffffff8160701c1661010083015260ff90818160881c166007811015612c9757926020926001959260029561012084015264ffffffffff8160901c1661014084015260b81c161515610160820152815201930195019491612b39565b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526021600452fd5b50346102ec57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec5773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163003612d5a5760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152fd5b50346102ec5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec5761ffff612e1961425d565b16600435825260fc602052604082205580f35b50346102ec577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc60208136011261044d576004359067ffffffffffffffff821161090157604090823603011261044d576102bf90612e8861455b565b600401615373565b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec5760043580151580910361044d57612ed561455b565b6101089060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00835416911617905580f35b5060407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57612f3a61404c565b60243567ffffffffffffffff8111610901573660238201121561090157612f6b903690602481600401359101614226565b9073ffffffffffffffffffffffffffffffffffffffff91827f00000000000000000000000000000000000000000000000000000000000000001692612fb284301415614647565b612fe17f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9482865416146146d2565b612fe961455b565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561301f5750506102bf915061475d565b82919216604051937f52d1902d0000000000000000000000000000000000000000000000000000000085526020948581600481865afa87918161327a575b506130e657608486604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152fd5b94929394036131f6576130f88361475d565b604051907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8680a28351158015906131ee575b613137575b5050505080f35b823b1561316e5750828492839261316495519201905af4613156614849565b61315e614879565b916148d8565b5081808080613130565b6084917f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152fd5b50600161312b565b608482604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152fd5b9091508681813d83116132a2575b61329281836141ab565b81010312610a045751908861305d565b503d613288565b50346102ec576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261044d576132e261404c565b73ffffffffffffffffffffffffffffffffffffffff807f00000000000000000000000000000000000000000000000000000000000000001661332681301415614647565b6133557f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9183835416146146d2565b61335d61455b565b604051908482019282841067ffffffffffffffff851117613632578360405286835260ff7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd914354166000146133b957505050506102bf915061475d565b8416906040517f52d1902d0000000000000000000000000000000000000000000000000000000081528681600481865afa889181613603575b5061347b57608487604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152fd5b9591929394950361357f5761348f8561475d565b604051917fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8780a2825115801590613578575b6134cf575b505050505080f35b843b156134f75750506134ec928492839251915af4613156614849565b5081808080806134c7565b608492507f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152fd5b50856134c2565b608490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152fd5b9091508781813d831161362b575b61361b81836141ab565b81010312611c5c575190896133f2565b503d613611565b6024877f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b50346102ec57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec5760206040516101768152f35b50346102ec57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec576020604051620151808152f35b50346102ec5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec57602435600f81101561044d5761373063ffffffff91604060209460043581526101008652206140af565b5416604051908152f35b50346102ec57602090817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec5790600435825261010481526040822080546137868161493b565b9061379460405192836141ab565b8082528382018093865284862086915b83831061382857505050506040519280840191818552518092526040840192945b8281106137d25784840385f35b8551805161ffff168552808301516fffffffffffffffffffffffffffffffff168584015260408082015164ffffffffff169086015260609081015162ffffff1690850152948101946080909301926001016137c5565b60409796949597516080810181811067ffffffffffffffff8211176138a4576001928392889260405262ffffff865461ffff811683526fffffffffffffffffffffffffffffffff8160101c168584015264ffffffffff8160901c16604084015260b81c16606082015281520192019201919096949395966137a4565b6024897f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b50346102ec5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102ec5760043567ffffffffffffffff811161044d5761392190369060040161407e565b61392961455b565b80805b613934578380f35b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0180828110156139a25760051b8301357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc184360301811215610dd35761399d82918501615373565b61392c565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b90503461044d5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261044d57613a0861404c565b903660841161090157613a1961406f565b73ffffffffffffffffffffffffffffffffffffffff9182610103541633036140245750614013575b602435835261010160205260408320906c017600000100010001000100017fff0000000000000000000000000000000000000000ff00000000000000000000835416178255606435600f811015610dd3571561400b576002925b60ff841615613fde57845b60ff85168110613ab4578580f35b6002811015613fb157600f8160051b604401351015613fad576040517f86481d4000000000000000000000000000000000000000000000000000000000815263ffffffff60ff87166101760416600482015260208160248173aaececb8429c524420820cf8d610d7a49dc887d25af4908115610668578791613f73575b5060068260051b6044013514600014613e4c577fffffffffffffffffffffffffffffffffffffffffffff0000ffffffffffffffff69ffff000000000000000086549260401b1691161784555b602435865261010060205263ffffffff613ba18260051b60440135604089206140af565b54169063ffffffff8060ff88166101760416830111613e1f576024358752610100602052613bd98160051b60440135604089206140af565b63ffffffff8060ff891661017604168401167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000008254161790557f89f3ec706f434c8d4bb9a155c44936315486da1dccd6059f0be44ac12bf85e23608060405186861681526024356020820152613c59604082018560051b604401356155c3565b63ffffffff60ff8a1661017604166060820152a16040517f86481d4000000000000000000000000000000000000000000000000000000000815282600482015260208160248173aaececb8429c524420820cf8d610d7a49dc887d25af4908115613dda578891613de5575b5063ffffffff604051937f86481d400000000000000000000000000000000000000000000000000000000085528160ff8a1661017604160116600484015260208360248173aaececb8429c524420820cf8d610d7a49dc887d25af48015613dda578890613d9f575b613d45935061ffff80911691168111613d4a5750614953565b613aa6565b60807f89632861622337d5d45747367af7784ce107d58a750a8d4cd862d69a0ad60c7a916040519087871682526024356020830152613d93604083018660051b604401356155c3565b6060820152a187611c4e565b506020833d602011613dd2575b81613db9602093836141ab565b81010312610a0457613dcd613d4593614c06565b613d2c565b3d9150613dac565b6040513d8a823e3d90fd5b90506020813d602011613e17575b81613e00602093836141ab565b81010312610a0457613e1190614c06565b88613cc4565b3d9150613df3565b6024877f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b60028260051b6044013514600014613e8e5761ffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000855416178455613b7d565b60048260051b6044013514600014613ed7577fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff63ffff000086549260101b169116178455613b7d565b60038260051b6044013514600014613f22577fffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffff65ffff0000000086549260201b169116178455613b7d565b600582811b6044013514613f37575b50613b7d565b7fffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffffffff67ffff00000000000086549260301b16911617845586613f31565b90506020813d602011613fa5575b81613f8e602093836141ab565b810103126125bd57613f9f90614c06565b87613b31565b3d9150613f81565b8580fd5b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526012600452fd5b600192613a9b565b61401f602435836151f8565b613a41565b807f3434655b0000000000000000000000000000000000000000000000000000000060049252fd5b6004359073ffffffffffffffffffffffffffffffffffffffff821682036100ea57565b6084359081151582036100ea57565b9181601f840112156100ea5782359167ffffffffffffffff83116100ea576020808501948460051b0101116100ea57565b90600f8110156140c757600052602052604060002090565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b610180810190811067ffffffffffffffff82111761411357604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610120810190811067ffffffffffffffff82111761411357604052565b60a0810190811067ffffffffffffffff82111761411357604052565b67ffffffffffffffff811161411357604052565b6060810190811067ffffffffffffffff82111761411357604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761411357604052565b67ffffffffffffffff811161411357601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b929192614232826141ec565b9161424060405193846141ab565b8294818452818301116100ea578281602093846000960137010152565b6024359061ffff821682036100ea57565b359061ffff821682036100ea57565b9060078210156140c75752565b906020808351928381520192019060005b8181106142a85750505090565b909192602061028060019286516fffffffffffffffffffffffffffffffff610100825161ffff815116855261ffff87820151168786015261ffff604082015116604086015261ffff606082015116606086015261ffff608082015116608086015261ffff60a08201511660a086015261ffff60c08201511660c086015261ffff60e08201511660e086015201511661010083015261ffff848201511661012083015261ffff60408201511690610140918284015264ffffffffff61ffff60608301511692610160938486015261ffff60808401511661018086015261ffff60a0840151166101a086015261ffff60c0840151166101c086015261ffff60e0840151166101e086015262ffffff610100840151166102008601526143d561012084015161022087019061427d565b820151166102408401520151151561026082015201940192910161429b565b90815180825260208080930193019160005b828110614414575050505090565b8351805161ffff16865282015162ffffff168583015260409094019392810192600101614406565b60005b83811061444f5750506000910152565b818101518382015260200161443f565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f60209361449b8151809281875287808801910161443c565b0116010190565b9060607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8301126100ea5760043573ffffffffffffffffffffffffffffffffffffffff811681036100ea579167ffffffffffffffff916024358381116100ea578261450f9160040161407e565b939093926044359182116100ea576145299160040161407e565b9091565b9181601f840112156100ea5782359167ffffffffffffffff83116100ea57602083818601950101116100ea57565b73ffffffffffffffffffffffffffffffffffffffff60335416330361457c57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b6033549073ffffffffffffffffffffffffffffffffffffffff80911691827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617603355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b1561464e57565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152fd5b156146d957565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152fd5b803b156147c55773ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc91167fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152fd5b3d15614874573d9061485a826141ec565b9161486860405193846141ab565b82523d6000602084013e565b606090565b604051906148868261418f565b602782527f206661696c6564000000000000000000000000000000000000000000000000006040837f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c60208201520152565b909190156148e4575090565b905b8051909190156148f95750805190602001fd5b614937906040519182917f08c379a000000000000000000000000000000000000000000000000000000000835260206004840152602483019061445f565b0390fd5b67ffffffffffffffff81116141135760051b60200190565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146149805760010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8051156149bc5760200190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b80518210156149bc5760209160051b010190565b91929015614a7a5750815115614a13575090565b3b15614a1c5790565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b826148e6565b15614a8757565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152fd5b359062ffffff821682036100ea57565b600260c95414614b2c57600260c955565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b90918281527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83116100ea5760209260051b809284830137010190565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0938186528686013760008582860101520116010190565b519061ffff821682036100ea57565b73ffffffffffffffffffffffffffffffffffffffff1660005260fd60205260406000205415614c4057565b565b90614c4d81836155d0565b506040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527ffc2f5ae4520dc883b2fc0c292fa6c1ea67824aa32b11c2dda6a2c93c9c0ea1629190a180600052610101602052600160406000200190606051680100000000000000008111614113578254818455808210615191575b506080908360005260206000206000925b828410614f615750505050604051606081019273ffffffffffffffffffffffffffffffffffffffff80951693848352836020840152606060408401528154809152608083019160005260206000209060005b818110614e385750505090807fa1b500ba45168a135422ed2fa8193eaebee56674894c4032eeb12b1cb23763b0920390a18060005260fe60205260ff60406000205460601c1660068110156140c757151580614e1a575b614d8c57505050565b60005260fe602052604060002091600061ffff845460501c169355610102541691823b156100ea5760646000928360405195869485937f156e29f600000000000000000000000000000000000000000000000000000000855260048501526024840152600160448401525af18015614e0e57614e055750565b614c409061417b565b6040513d6000823e3d90fd5b508060005260fe60205264ffffffffff604060002054164211614d83565b9091926002610280600192865461ffff8116825261ffff8160101c16602083015261ffff8160201c16604083015261ffff8160301c16606083015261ffff8160401c16608083015261ffff8160501c1660a083015261ffff8160601c1660c083015261ffff8160701c1660e083015260801c6101008201528387015461ffff811661012083015261ffff8160101c1661014083015261ffff8160201c1661016083015261ffff8160301c1661018083015261ffff8160401c166101a083015261ffff8160501c166101c083015261ffff8160601c166101e083015262ffffff8160701c1661020083015260ff90614f386102208401838360881c1661427d565b609081901c64ffffffffff1661024084015260b81c161515610260820152019401929101614d2c565b805190614fec6fffffffffffffffffffffffffffffffff610100845161ffff8151167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008854161787556115ff61ffff60208301511688907fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff63ffff000083549260101b169116179055565b60208281015160018501805460408087015160608089015160808a015160a08b015160c08c015160e08d01517fffffffffffffffffffffffffffffffffffff000000000000000000000000000090981661ffff909a169990991763ffff000060109690961b959095169490941765ffff000000009290991b919091169790971760309790971b67ffff0000000000001696909617911b69ffff0000000000000000161760509390931b6bffff0000000000000000000016929092179190921b6dffff00000000000000000000000016179055610100820151906001840154906101208401519260078410156140c7578460029471ff00000000000000000000000000000000006020957fffffffffffffffff00000000000000000000ffffffffffffffffffffffffffff70ffffff000000000000000000000000000077ff000000000000000000000000000000000000000000000061016076ffffffffff00000000000000000000000000000000000061014060019e015160901b16970151151560b81b169660701b169116179160881b161717178486015501920193019290614cda565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80821682036149805782168203614980578360005260206000209060011b8101908260011b015b8181106151e65750614cc9565b600080825560018201556002016151d9565b6060907f922ab96a540d8cab2685d9b7e034fe17b7c3cd29ac8e00f75b9361c0fce38be09273ffffffffffffffffffffffffffffffffffffffff8216918260005260fd60205260406000209082825492558180615265575b505060405192835260208301526040820152a1565b61526e91614c42565b3881615250565b519062ffffff821682036100ea57565b81601f820112156100ea5780519061529c8261493b565b926040926152ac845195866141ab565b808552602091828087019260061b850101938185116100ea578301915b8483106152d95750505050505090565b85838303126100ea578551908682019082821067ffffffffffffffff8311176153275787928692845261530b86614c06565b8152615318838701615275565b838201528152019201916152c9565b602460007f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b519081151582036100ea57565b3563ffffffff811681036100ea5790565b61ffff63ffffffff615398826153928361538c87615362565b166158c2565b16615952565b81806153a386615362565b92169116036155995760209182840135937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1813603018512156100ea578481019384359267ffffffffffffffff958685116100ea578201928460061b360384136100ea578561541182615362565b16936000948552610107845260409586862091680100000000000000008211613632578254828455808310615574575b5091865284862086925b82841061550f575050505084519783895260608901968235908116809103613fad57848a015201948286359601968611610912578560061b3603871361091257878501859052859052608087019594939291905b8483106154d55750505050505090807f6f133c32ed6c05d7adbc26b93f09b49249333400b93e2d113435ccb7cf3c56ea920390a1565b9091929394958480600192846154ea8b61426e565b16815262ffffff6154fc878c01614b0b565b168187015201970195949301919061549f565b8035868116809103611c5c578254908883013562ffffff811681036129315792600193928c927fffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000064ffffff0000879660101b169216171785550192019301929061544b565b8388528287892091820191015b81811061558e5750615441565b888155600101615581565b60046040517f1c54a972000000000000000000000000000000000000000000000000000000008152fd5b90600f8210156140c75752565b61010954604080517f7f3be3f00000000000000000000000000000000000000000000000000000000060208083019190915273ffffffffffffffffffffffffffffffffffffffff9485166024830152604480830196909652948152909261563d921661062c6064836141ab565b80518101928084019181818603126100ea57818101519067ffffffffffffffff82116100ea570182603f820112156100ea57818101519361567d8561493b565b9561568a825197886141ab565b85875283870192826102808098028201019586116100ea578201925b8584106156b7575050505050505090565b84848303018781126100ea578351916156cf836140f6565b6101208092126100ea578451926156e584614142565b6156ee87614c06565b84526156fb888801614c06565b8885015261570a868801614c06565b8685015260609261571c848901614c06565b84860152608061572d818a01614c06565b8187015260a061573e818b01614c06565b8188015260c061574f818c01614c06565b8189015260e091615761838d01614c06565b838a015261010093848d0151996fffffffffffffffffffffffffffffffff8b168b036100ea576101808f8f909b8f6157bd9d6157cd9f956157d7968c8201528d526157ad8c8501614c06565b908d01526101409d8e8401614c06565b908c01526101609d8e8301614c06565b908b015201614c06565b908701526157e86101a08d01614c06565b908601526157f96101c08c01614c06565b9085015261580a6101e08b01614c06565b9084015261581b6102008a01615275565b908301526102208801519060078210156100ea578201526102408701519364ffffffffff851685036100ea578a94899483015261585b6102608901615355565b908201528152019301926156a6565b604051906158778261418f565b603c82527e0186a00001d4c0000493e0000557300007a120000927c0000b71b0000000006040837901f4000003e8000009c40000138800002710000075300000c35060208201520152565b6000906158cd61586a565b5160021c5b808310615910575050801561590a577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0161ffff1690565b50600090565b600190808401821c918363ffffffff61592885615952565b1611156159365750506158d2565b9190935001916158d2565b9081518110156149bc570160200190565b60021b7cff00000000000000000000000000000000000000000000000000000000615a327fff000000000000000000000000000000000000000000000000000000000000006159a8846159a361586a565b615941565b51167eff0000000000000000000000000000000000000000000000000000000000006159df6159d561586a565b6001870190615941565b5160081c16177dff0000000000000000000000000000000000000000000000000000000000615a19615a0f61586a565b6002870190615941565b5160101c1617926003615a2a61586a565b910190615941565b5160181c161760e01c90565b6000918291602082519201905af490615a55614849565b9115615a5d57565b5080519081156100ea57602001fdfea2646970667358221220cfb8ead53d08452b4efb9bb370ef76277c5f15d92c0a7ea740bf0728a459fb4f64736f6c63430008130033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Validator ID :
0 FTM
Amount Staked
0
Amount Delegated
0
Staking Total
0
Staking Start Epoch
0
Staking Start Time
0
Proof of Importance
0
Origination Score
0
Validation Score
0
Active
0
Online
0
Downtime
0 s
Address | Amount | claimed Rewards | Created On Epoch | Created On |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.