Contract Overview
Balance:
0 CELO
CELO Value:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x69dc855a38de1c6d865f0e2fce6c010f82241cb3c3184f53e7ca68440efa09ed | 0x60806040 | 14252587 | 314 days 3 hrs ago | 0x246a13358fb27523642d86367a51c2aeb137ac6c | IN | Create: PublicLock | 0 CELO | 0.0026288125 |
[ Download CSV Export ]
Contract Name:
PublicLock
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 80 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '@openzeppelin/contracts-upgradeable/utils/introspection/ERC165StorageUpgradeable.sol'; import './mixins/MixinDisable.sol'; import './mixins/MixinERC721Enumerable.sol'; import './mixins/MixinFunds.sol'; import './mixins/MixinGrantKeys.sol'; import './mixins/MixinKeys.sol'; import './mixins/MixinLockCore.sol'; import './mixins/MixinLockMetadata.sol'; import './mixins/MixinPurchase.sol'; import './mixins/MixinRefunds.sol'; import './mixins/MixinTransfer.sol'; import './mixins/MixinRoles.sol'; import './mixins/MixinConvenienceOwnable.sol'; /** * @title The Lock contract * @author Julien Genestoux (unlock-protocol.com) * @dev ERC165 allows our contract to be queried to determine whether it implements a given interface. * Every ERC-721 compliant contract must implement the ERC165 interface. * https://eips.ethereum.org/EIPS/eip-721 */ contract PublicLock is Initializable, ERC165StorageUpgradeable, MixinRoles, MixinFunds, MixinDisable, MixinLockCore, MixinKeys, MixinLockMetadata, MixinERC721Enumerable, MixinGrantKeys, MixinPurchase, MixinTransfer, MixinRefunds, MixinConvenienceOwnable { function initialize( address payable _lockCreator, uint _expirationDuration, address _tokenAddress, uint _keyPrice, uint _maxNumberOfKeys, string calldata _lockName ) public initializer() { MixinFunds._initializeMixinFunds(_tokenAddress); MixinLockCore._initializeMixinLockCore(_lockCreator, _expirationDuration, _keyPrice, _maxNumberOfKeys); MixinLockMetadata._initializeMixinLockMetadata(_lockName); MixinERC721Enumerable._initializeMixinERC721Enumerable(); MixinRefunds._initializeMixinRefunds(); MixinRoles._initializeMixinRoles(_lockCreator); MixinConvenienceOwnable._initializeMixinConvenienceOwnable(_lockCreator); // registering the interface for erc721 with ERC165.sol using // the ID specified in the standard: https://eips.ethereum.org/EIPS/eip-721 _registerInterface(0x80ac58cd); } /** * @notice Allow the contract to accept tips in ETH sent directly to the contract. * @dev This is okay to use even if the lock is priced in ERC-20 tokens */ receive() external payable {} /** Overrides */ function supportsInterface(bytes4 interfaceId) public view virtual override( MixinERC721Enumerable, MixinLockMetadata, AccessControlUpgradeable, ERC165StorageUpgradeable ) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ 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. * * `initializer` is equivalent to `reinitializer(1)`, so 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. * * 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. */ 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. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol) pragma solidity ^0.8.0; import "./ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Storage based implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165StorageUpgradeable is Initializable, ERC165Upgradeable { function __ERC165Storage_init() internal onlyInitializing { } function __ERC165Storage_init_unchained() internal onlyInitializing { } /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } /** * @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 pragma solidity ^0.8.0; /** * The ability to disable locks has been removed on v10 to decrease contract code size. * Disabling locks can be achieved by setting `setMaxNumberOfKeys` to `totalSupply` * and expire all existing keys. * @dev the variables are kept to prevent conflicts in storage layout during upgrades */ contract MixinDisable { bool isAlive; uint256[1000] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './MixinKeys.sol'; import './MixinLockCore.sol'; import './MixinErrors.sol'; import '@openzeppelin/contracts-upgradeable/utils/introspection/ERC165StorageUpgradeable.sol'; /** * @title Implements the ERC-721 Enumerable extension. */ contract MixinERC721Enumerable is ERC165StorageUpgradeable, MixinErrors, MixinLockCore, // Implements totalSupply MixinKeys { function _initializeMixinERC721Enumerable() internal { /** * register the supported interface to conform to ERC721Enumerable via ERC165 * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ _registerInterface(0x780e9d63); } /// @notice Enumerate valid NFTs /// @dev Throws if `_index` >= `totalSupply()`. /// @param _index A counter less than `totalSupply()` /// @return The token identifier for the `_index`th NFT, /// (sort order not specified) function tokenByIndex( uint256 _index ) public view returns (uint256) { if(_index >= _totalSupply) { revert OUT_OF_RANGE(); } return _index; } function supportsInterface(bytes4 interfaceId) public view virtual override( AccessControlUpgradeable, ERC165StorageUpgradeable ) returns (bool) { return super.supportsInterface(interfaceId); } uint256[1000] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './MixinErrors.sol'; import '@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol'; import '@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol'; /** * @title An implementation of the money related functions. * @author HardlyDifficult (unlock-protocol.com) */ contract MixinFunds is MixinErrors { using AddressUpgradeable for address payable; using SafeERC20Upgradeable for IERC20Upgradeable; /** * The token-type that this Lock is priced in. If 0, then use ETH, else this is * a ERC20 token address. */ address public tokenAddress; function _initializeMixinFunds( address _tokenAddress ) internal { _isValidToken(_tokenAddress); tokenAddress = _tokenAddress; } function _isValidToken( address _tokenAddress ) internal view { if( _tokenAddress != address(0) && IERC20Upgradeable(_tokenAddress).totalSupply() < 0 ) { revert INVALID_TOKEN(); } } /** * Transfers funds from the contract to the account provided. * * Security: be wary of re-entrancy when calling this function. */ function _transfer( address _tokenAddress, address payable _to, uint _amount ) internal { if(_amount > 0) { if(_tokenAddress == address(0)) { // https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/ _to.sendValue(_amount); } else { IERC20Upgradeable token = IERC20Upgradeable(_tokenAddress); token.safeTransfer(_to, _amount); } } } uint256[1000] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './MixinKeys.sol'; import './MixinRoles.sol'; import './MixinErrors.sol'; /** * @title Mixin allowing the Lock owner to grant / gift keys to users. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinGrantKeys is MixinErrors, MixinRoles, MixinKeys { /** * Allows the Lock owner to give a collection of users a key with no charge. * Each key may be assigned a different expiration date. */ function grantKeys( address[] calldata _recipients, uint[] calldata _expirationTimestamps, address[] calldata _keyManagers ) external returns (uint[] memory) { _lockIsUpToDate(); if(!isKeyGranter(msg.sender) && !isLockManager(msg.sender)) { revert ONLY_LOCK_MANAGER_OR_KEY_GRANTER(); } uint[] memory tokenIds = new uint[](_recipients.length); for(uint i = 0; i < _recipients.length; i++) { // an event is triggered tokenIds[i] = _createNewKey( _recipients[i], _keyManagers[i], _expirationTimestamps[i] ); } return tokenIds; } /** * Allows the Lock owner or key granter to extend an existing keys with no charge. This is the "renewal" equivalent of `grantKeys`. * @param _tokenId The id of the token to extend * @param _duration The duration in secondes to add ot the key * @dev set `_duration` to 0 to use the default duration of the lock */ function grantKeyExtension(uint _tokenId, uint _duration) external { _lockIsUpToDate(); _isKey(_tokenId); if(!isKeyGranter(msg.sender) && !isLockManager(msg.sender)) { revert ONLY_LOCK_MANAGER_OR_KEY_GRANTER(); } _extendKey(_tokenId, _duration); } uint256[1000] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './MixinLockCore.sol'; import './MixinErrors.sol'; /** * @title Mixin for managing `Key` data, as well as the * Approval related functions needed to meet the ERC721 * standard. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinKeys is MixinErrors, MixinLockCore { // The struct for a key struct Key { uint tokenId; uint expirationTimestamp; } // Emitted when the Lock owner expires a user's Key event ExpireKey(uint indexed tokenId); // Emitted when the expiration of a key is modified event ExpirationChanged( uint indexed _tokenId, uint _amount, bool _timeAdded ); // fire when a key is extended event KeyExtended( uint indexed tokenId, uint newTimestamp ); event KeyManagerChanged(uint indexed _tokenId, address indexed _newManager); event KeysMigrated( uint updatedRecordsCount ); // Deprecated: don't use this anymore as we know enable multiple keys per owner. mapping (address => Key) internal keyByOwner; // Each tokenId can have at most exactly one owner at a time. // Returns address(0) if the token does not exist mapping (uint => address) internal _ownerOf; // Keep track of the total number of unique owners for this lock (both expired and valid). // This may be larger than totalSupply uint public numberOfOwners; // A given key has both an owner and a manager. // If keyManager == address(0) then the key owner is also the manager // Each key can have at most 1 keyManager. mapping (uint => address) public keyManagerOf; // Keeping track of approved transfers // This is a mapping of addresses which have approved // the transfer of a key to another address where their key can be transferred // Note: the approver may actually NOT have a key... and there can only // be a single approved address mapping (uint => address) internal approved; // Keeping track of approved operators for a given Key manager. // This approves a given operator for all keys managed by the calling "keyManager" // The caller may not currently be the keyManager for ANY keys. // These approvals are never reset/revoked automatically, unlike "approved", // which is reset on transfer. mapping (address => mapping (address => bool)) internal managerToOperatorApproved; // store all keys: tokenId => token mapping(uint256 => Key) internal _keys; // store ownership: owner => array of tokens owned by that owner mapping(address => mapping(uint256 => uint256)) private _ownedKeyIds; // store indexes: owner => list of tokenIds mapping(uint256 => uint256) private _ownedKeysIndex; // Mapping owner address to token count mapping(address => uint256) private _balances; /** * Ensure that the caller is the keyManager of the key * or that the caller has been approved * for ownership of that key * @dev This is a modifier */ function _onlyKeyManagerOrApproved( uint _tokenId ) internal view { address realKeyOwner = keyManagerOf[_tokenId] == address(0) ? _ownerOf[_tokenId] : keyManagerOf[_tokenId]; if( !_isKeyManager(_tokenId, msg.sender) && approved[_tokenId] != msg.sender && !isApprovedForAll(realKeyOwner, msg.sender) ) { revert ONLY_KEY_MANAGER_OR_APPROVED(); } } /** * Check if a key is expired or not * @dev This is a modifier */ function _isValidKey( uint _tokenId ) internal view { if(!isValidKey(_tokenId)) { revert KEY_NOT_VALID(); } } /** * Check if a key actually exists * @dev This is a modifier */ function _isKey( uint _tokenId ) internal view { if(_keys[_tokenId].expirationTimestamp == 0) { revert NO_SUCH_KEY(); } } /** * Deactivate an existing key * @param _tokenId the id of token to burn * @notice the key will be expired and ownership records will be destroyed */ function burn(uint _tokenId) public { _isKey(_tokenId); _onlyKeyManagerOrApproved(_tokenId); emit Transfer(_ownerOf[_tokenId], address(0), _tokenId); // delete ownership and expire key _cancelKey(_tokenId); } /** * Migrate data from the previous single owner => key mapping to * the new data structure w multiple tokens. * No data migration needed for v10 > v11 */ function migrate(bytes calldata) virtual public { schemaVersion = publicLockVersion(); } /** * Set the schema version to the latest * @notice only lock manager call call this */ function updateSchemaVersion() public { _onlyLockManager(); schemaVersion = publicLockVersion(); } /** * Returns the id of a key for a specific owner at a specific index * @notice Enumerate keys assigned to an owner * @dev Throws if `_index` >= `balanceOf(_keyOwner)` or if * `_keyOwner` is the zero address, representing invalid keys. * @param _keyOwner address of the owner * @param _index position index in the array of all keys - less than `balanceOf(_keyOwner)` * @return The token identifier for the `_index`th key assigned to `_keyOwner`, * (sort order not specified) * NB: name kept to be ERC721 compatible */ function tokenOfOwnerByIndex( address _keyOwner, uint256 _index ) public view returns (uint256) { if(_index >= totalKeys(_keyOwner)) { revert OUT_OF_RANGE(); } return _ownedKeyIds[_keyOwner][_index]; } /** * Create a new key with a new tokenId and store it * */ function _createNewKey( address _recipient, address _keyManager, uint expirationTimestamp ) internal returns (uint tokenId) { if(_recipient == address(0)) { revert INVALID_ADDRESS(); } // We increment the tokenId counter _totalSupply++; tokenId = _totalSupply; // create the key _keys[tokenId] = Key(tokenId, expirationTimestamp); // increase total number of unique owners if(totalKeys(_recipient) == 0 ) { numberOfOwners++; } // store ownership _createOwnershipRecord(tokenId, _recipient); // set key manager _setKeyManagerOf(tokenId, _keyManager); // trigger event emit Transfer( address(0), // This is a creation. _recipient, tokenId ); } function _extendKey( uint _tokenId, uint _duration ) internal returns ( uint newTimestamp ) { uint expirationTimestamp = _keys[_tokenId].expirationTimestamp; // prevent extending a valid non-expiring key if(expirationTimestamp == type(uint).max){ revert CANT_EXTEND_NON_EXPIRING_KEY(); } // if non-expiring but not valid then extend uint duration = _duration == 0 ? expirationDuration : _duration; if(duration == type(uint).max) { newTimestamp = type(uint).max; } else { if (expirationTimestamp > block.timestamp) { // extends a valid key newTimestamp = expirationTimestamp + duration; } else { // renew an expired or cancelled key newTimestamp = block.timestamp + duration; } } _keys[_tokenId].expirationTimestamp = newTimestamp; emit KeyExtended(_tokenId, newTimestamp); } /** * Record ownership info and udpate balance for new owner * @param _tokenId the id of the token to cancel * @param _recipient the address of the new owner */ function _createOwnershipRecord( uint _tokenId, address _recipient ) internal { uint length = balanceOf(_recipient); // make sure address does not have more keys than allowed if(length >= _maxKeysPerAddress) { revert MAX_KEYS_REACHED(); } // record new owner _ownedKeysIndex[_tokenId] = length; _ownedKeyIds[_recipient][length] = _tokenId; // update ownership mapping _ownerOf[_tokenId] = _recipient; _balances[_recipient] += 1; } /** * Merge existing keys * @param _tokenIdFrom the id of the token to substract time from * @param _tokenIdTo the id of the destination token to add time * @param _amount the amount of time to transfer (in seconds) */ function mergeKeys( uint _tokenIdFrom, uint _tokenIdTo, uint _amount ) public { // checks _isKey(_tokenIdFrom); _isValidKey(_tokenIdFrom); _onlyKeyManagerOrApproved(_tokenIdFrom); _isKey(_tokenIdTo); // make sure there is enough time remaining if( _amount > keyExpirationTimestampFor(_tokenIdFrom) - block.timestamp ) { revert NOT_ENOUGH_TIME(); } // deduct time from parent key _timeMachine(_tokenIdFrom, _amount, false); // add time to destination key _timeMachine(_tokenIdTo, _amount, true); } /** * Delete ownership info and udpate balance for previous owner * @param _tokenId the id of the token to cancel */ function _deleteOwnershipRecord( uint _tokenId ) internal { // get owner address previousOwner = _ownerOf[_tokenId]; // delete previous ownership uint lastTokenIndex = balanceOf(previousOwner) - 1; uint index = _ownedKeysIndex[_tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (index != lastTokenIndex) { uint256 lastTokenId = _ownedKeyIds[previousOwner][lastTokenIndex]; _ownedKeyIds[previousOwner][index] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedKeysIndex[lastTokenId] = index; // Update the moved token's index } // Deletes the contents at the last position of the array delete _ownedKeyIds[previousOwner][lastTokenIndex]; // remove from owner count if thats the only key if(totalKeys(previousOwner) == 1 ) { numberOfOwners--; } // update balance _balances[previousOwner] -= 1; } /** * Delete ownership info about a key and expire the key * @param _tokenId the id of the token to cancel * @notice this won't 'burn' the token, as it would still exist in the record */ function _cancelKey( uint _tokenId ) internal { // Deletes the contents at the last position of the array _deleteOwnershipRecord(_tokenId); // expire the key _keys[_tokenId].expirationTimestamp = block.timestamp; // delete previous owner _ownerOf[_tokenId] = address(0); } /** * @return The number of keys owned by `_keyOwner` (expired or not) */ function totalKeys( address _keyOwner ) public view returns (uint) { if(_keyOwner == address(0)) { revert INVALID_ADDRESS(); } return _balances[_keyOwner]; } /** * In the specific case of a Lock, `balanceOf` returns only the tokens with a valid expiration timerange * @return balance The number of valid keys owned by `_keyOwner` */ function balanceOf( address _keyOwner ) public view returns (uint balance) { uint length = totalKeys(_keyOwner); for (uint i = 0; i < length; i++) { if(isValidKey(tokenOfOwnerByIndex(_keyOwner, i))) { balance++; } } } /** * Check if a certain key is valid * @param _tokenId the id of the key to check validity * @notice this makes use of the onValidKeyHook if it is set */ function isValidKey( uint _tokenId ) public view returns (bool) { bool isValid = _keys[_tokenId].expirationTimestamp > block.timestamp; return isValid; } /** * Checks if the user has at least one non-expired key. * @param _keyOwner the */ function getHasValidKey( address _keyOwner ) public view returns (bool isValid) { uint length = balanceOf(_keyOwner); if(length > 0) { for (uint i = 0; i < length; i++) { if(isValidKey(tokenOfOwnerByIndex(_keyOwner, i))) { return true; // stop looping at the first valid key } } } // use hook if it exists if(address(onValidKeyHook) != address(0)) { isValid = onValidKeyHook.hasValidKey( address(this), _keyOwner, 0, // no timestamp needed (we use tokenId) isValid ); } return isValid; } /** * Returns the key's ExpirationTimestamp field for a given token. * @param _tokenId the tokenId of the key * @dev Returns 0 if the owner has never owned a key for this lock */ function keyExpirationTimestampFor( uint _tokenId ) public view returns (uint) { return _keys[_tokenId].expirationTimestamp; } /** * Returns the owner of a given tokenId * @param _tokenId the id of the token * @return the address of the owner */ function ownerOf( uint _tokenId ) public view returns(address) { return _ownerOf[_tokenId]; } /** * @notice Public function for setting the manager for a given key * @param _tokenId The id of the key to assign rights for * @param _keyManager the address with the manager's rights for the given key. * Setting _keyManager to address(0) means the keyOwner is also the keyManager */ function setKeyManagerOf( uint _tokenId, address _keyManager ) public { _isKey(_tokenId); if( // is already key manager !_isKeyManager(_tokenId, msg.sender) // is lock manager && !isLockManager(msg.sender) ) { revert UNAUTHORIZED_KEY_MANAGER_UPDATE(); } _setKeyManagerOf(_tokenId, _keyManager); } function _setKeyManagerOf( uint _tokenId, address _keyManager ) internal { if(keyManagerOf[_tokenId] != _keyManager) { keyManagerOf[_tokenId] = _keyManager; _clearApproval(_tokenId); emit KeyManagerChanged(_tokenId, _keyManager); } } /** * This approves _approved to get ownership of _tokenId. * Note: that since this is used for both purchase and transfer approvals * the approved token may not exist. */ function approve( address _approved, uint _tokenId ) public { _onlyKeyManagerOrApproved(_tokenId); if(msg.sender == _approved) { revert CANNOT_APPROVE_SELF(); } approved[_tokenId] = _approved; emit Approval(_ownerOf[_tokenId], _approved, _tokenId); } /** * @notice Get the approved address for a single NFT * @dev Throws if `_tokenId` is not a valid NFT. * @param _tokenId The NFT to find the approved address for * @return The approved address for this NFT, or the zero address if there is none */ function getApproved( uint _tokenId ) public view returns (address) { _isKey(_tokenId); address approvedRecipient = approved[_tokenId]; return approvedRecipient; } /** * @dev Tells whether an operator is approved by a given keyManager * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view returns (bool) { return managerToOperatorApproved[_owner][_operator]; } /** * Returns true if _keyManager is explicitly set as key manager, or if the * address is the owner but no km is set. * identified by _tokenId */ function _isKeyManager( uint _tokenId, address _keyManager ) internal view returns (bool) { if( // is explicitely a key manager keyManagerOf[_tokenId] == _keyManager || ( // is owner and no key manager is set ownerOf(_tokenId) == _keyManager) && keyManagerOf[_tokenId] == address(0) ) { return true; } else { return false; } } /** * @notice Modify the expirationTimestamp of a key * by a given amount. * @param _tokenId The ID of the key to modify. * @param _deltaT The amount of time in seconds by which * to modify the keys expirationTimestamp * @param _addTime Choose whether to increase or decrease * expirationTimestamp (false == decrease, true == increase) * @dev Throws if owner does not have a valid key. */ function _timeMachine( uint _tokenId, uint256 _deltaT, bool _addTime ) internal { _isKey(_tokenId); uint formerTimestamp = _keys[_tokenId].expirationTimestamp; if(_addTime) { if(formerTimestamp > block.timestamp) { // append to valid key _keys[_tokenId].expirationTimestamp = formerTimestamp + _deltaT; } else { // add from now if key is expired _keys[_tokenId].expirationTimestamp = block.timestamp + _deltaT; } } else { _keys[_tokenId].expirationTimestamp = formerTimestamp - _deltaT; } emit ExpirationChanged(_tokenId, _deltaT, _addTime); } /** * @dev Function to clear current approval of a given token ID * @param _tokenId uint256 ID of the token to be transferred */ function _clearApproval( uint256 _tokenId ) internal { if (approved[_tokenId] != address(0)) { approved[_tokenId] = address(0); } } /** * @notice Change the maximum number of keys the lock can edit * @param _maxNumberOfKeys uint the maximum number of keys * @dev Can't be smaller than the existing supply */ function setMaxNumberOfKeys (uint _maxNumberOfKeys) external { _onlyLockManager(); if (_maxNumberOfKeys < _totalSupply) { revert CANT_BE_SMALLER_THAN_SUPPLY(); } maxNumberOfKeys = _maxNumberOfKeys; } /** * A function to change the default duration of each key in the lock * @notice keys previously bought are unaffected by this change (i.e. * existing keys timestamps are not recalculated/updated) * @param _newExpirationDuration the new amount of time for each key purchased * or type(uint).max for a non-expiring key */ function setExpirationDuration(uint _newExpirationDuration) external { _onlyLockManager(); expirationDuration = _newExpirationDuration; } /** * Set the maximum number of keys a specific address can use * @param _maxKeys the maximum amount of key a user can own */ function setMaxKeysPerAddress(uint _maxKeys) external { _onlyLockManager(); if(_maxKeys == 0) { revert NULL_VALUE(); } _maxKeysPerAddress = _maxKeys; } /** * @return the maximum number of key allowed for a single address */ function maxKeysPerAddress() external view returns (uint) { return _maxKeysPerAddress; } // decrease 1000 to 996 when adding new tokens/owners mappings in v10 uint256[996] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // import '@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol'; import './MixinDisable.sol'; import './MixinRoles.sol'; import './MixinErrors.sol'; import '../interfaces/IUnlock.sol'; import './MixinFunds.sol'; import '../interfaces/hooks/ILockKeyCancelHook.sol'; import '../interfaces/hooks/ILockKeyPurchaseHook.sol'; import '../interfaces/hooks/ILockValidKeyHook.sol'; import '../interfaces/hooks/ILockTokenURIHook.sol'; import '../interfaces/hooks/ILockKeyTransferHook.sol'; /** * @title Mixin for core lock data and functions. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinLockCore is MixinRoles, MixinFunds, MixinDisable { using AddressUpgradeable for address; event Withdrawal( address indexed sender, address indexed tokenAddress, address indexed beneficiary, uint amount ); event PricingChanged( uint oldKeyPrice, uint keyPrice, address oldTokenAddress, address tokenAddress ); /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); // Unlock Protocol address // TODO: should we make that private/internal? IUnlock public unlockProtocol; // Duration in seconds for which the keys are valid, after creation // should we take a smaller type use less gas? uint public expirationDuration; // price in wei of the next key // TODO: allow support for a keyPriceCalculator which could set prices dynamically uint public keyPrice; // Max number of keys sold if the keyReleaseMechanism is public uint public maxNumberOfKeys; // A count of how many new key purchases there have been uint internal _totalSupply; // The account which will receive funds on withdrawal address payable public beneficiary; // The denominator component for values specified in basis points. uint internal constant BASIS_POINTS_DEN = 10000; // lock hooks ILockKeyPurchaseHook public onKeyPurchaseHook; ILockKeyCancelHook public onKeyCancelHook; ILockValidKeyHook public onValidKeyHook; ILockTokenURIHook public onTokenURIHook; // use to check data version (added to v10) uint public schemaVersion; // keep track of how many key a single address can use (added to v10) uint internal _maxKeysPerAddress; // one more hook (added to v11) ILockKeyTransferHook public onKeyTransferHook; // modifier to check if data has been upgraded function _lockIsUpToDate() internal view { if(schemaVersion != publicLockVersion()) { revert MIGRATION_REQUIRED(); } } // modifier function _onlyLockManagerOrBeneficiary() internal view { if(!isLockManager(msg.sender) && msg.sender != beneficiary) { revert ONLY_LOCK_MANAGER_OR_BENEFICIARY(); } } function _initializeMixinLockCore( address payable _beneficiary, uint _expirationDuration, uint _keyPrice, uint _maxNumberOfKeys ) internal { unlockProtocol = IUnlock(msg.sender); // Make sure we link back to Unlock's smart contract. beneficiary = _beneficiary; expirationDuration = _expirationDuration; keyPrice = _keyPrice; maxNumberOfKeys = _maxNumberOfKeys; // update only when initialized schemaVersion = publicLockVersion(); // only a single key per address is allowed by default _maxKeysPerAddress = 1; } // The version number of the current implementation on this network function publicLockVersion( ) public pure returns (uint16) { return 11; } /** * @dev Called by owner to withdraw all funds from the lock and send them to the `beneficiary`. * @param _tokenAddress specifies the token address to withdraw or 0 for ETH. This is usually * the same as `tokenAddress` in MixinFunds. * @param _amount specifies the max amount to withdraw, which may be reduced when * considering the available balance. Set to 0 or MAX_UINT to withdraw everything. */ function withdraw( address _tokenAddress, uint _amount ) external { _onlyLockManagerOrBeneficiary(); // get balance uint balance; if(_tokenAddress == address(0)) { balance = address(this).balance; } else { balance = IERC20Upgradeable(_tokenAddress).balanceOf(address(this)); } uint amount; if(_amount == 0 || _amount > balance) { if(balance <= 0) { revert NOT_ENOUGH_FUNDS(); } amount = balance; } else { amount = _amount; } emit Withdrawal(msg.sender, _tokenAddress, beneficiary, amount); // Security: re-entrancy not a risk as this is the last line of an external function _transfer(_tokenAddress, beneficiary, amount); } /** * A function which lets the owner of the lock change the pricing for future purchases. * This consists of 2 parts: The token address and the price in the given token. * In order to set the token to ETH, use 0 for the token Address. */ function updateKeyPricing( uint _keyPrice, address _tokenAddress ) external { _onlyLockManager(); _isValidToken(_tokenAddress); uint oldKeyPrice = keyPrice; address oldTokenAddress = tokenAddress; keyPrice = _keyPrice; tokenAddress = _tokenAddress; emit PricingChanged(oldKeyPrice, keyPrice, oldTokenAddress, tokenAddress); } /** * A function which lets the owner of the lock update the beneficiary account, * which receives funds on withdrawal. */ function updateBeneficiary( address payable _beneficiary ) external { _onlyLockManagerOrBeneficiary(); if(_beneficiary == address(0)) { revert INVALID_ADDRESS(); } beneficiary = _beneficiary; } /** * @notice Allows a lock manager to add or remove an event hook */ function setEventHooks( address _onKeyPurchaseHook, address _onKeyCancelHook, address _onValidKeyHook, address _onTokenURIHook, address _onKeyTransferHook ) external { _onlyLockManager(); if(_onKeyPurchaseHook != address(0) && !_onKeyPurchaseHook.isContract()) { revert INVALID_HOOK(0); } if(_onKeyCancelHook != address(0) && !_onKeyCancelHook.isContract()) { revert INVALID_HOOK(1); } if(_onValidKeyHook != address(0) && !_onValidKeyHook.isContract()) { revert INVALID_HOOK(2); } if(_onTokenURIHook != address(0) && !_onTokenURIHook.isContract()) { revert INVALID_HOOK(3); } if(_onKeyTransferHook != address(0) && !_onKeyTransferHook.isContract()) { revert INVALID_HOOK(4); } onKeyPurchaseHook = ILockKeyPurchaseHook(_onKeyPurchaseHook); onKeyCancelHook = ILockKeyCancelHook(_onKeyCancelHook); onTokenURIHook = ILockTokenURIHook(_onTokenURIHook); onValidKeyHook = ILockValidKeyHook(_onValidKeyHook); onKeyTransferHook = ILockKeyTransferHook(_onKeyTransferHook); } function totalSupply() public view returns(uint256) { return _totalSupply; } /** * @notice An ERC-20 style approval, allowing the spender to transfer funds directly from this lock. */ function approveBeneficiary( address _spender, uint _amount ) public returns (bool) { _onlyLockManagerOrBeneficiary(); return IERC20Upgradeable(tokenAddress).approve(_spender, _amount); } // decreased from 1000 to 998 when adding `schemaVersion` and `maxKeysPerAddress` in v10 // decreased from 998 to 997 when adding `onKeyTransferHook` in v11 uint256[997] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts-upgradeable/utils/introspection/ERC165StorageUpgradeable.sol'; // import '@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol'; import '../UnlockUtils.sol'; import './MixinKeys.sol'; import './MixinLockCore.sol'; import './MixinRoles.sol'; /** * @title Mixin for metadata about the Lock. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinLockMetadata is ERC165StorageUpgradeable, MixinRoles, MixinLockCore, MixinKeys { using UnlockUtils for uint; using UnlockUtils for address; using UnlockUtils for string; /// A descriptive name for a collection of NFTs in this contract.Defaults to "Unlock-Protocol" but is settable by lock owner string public name; /// An abbreviated name for NFTs in this contract. Defaults to "KEY" but is settable by lock owner string private lockSymbol; // the base Token URI for this Lock. If not set by lock owner, the global URI stored in Unlock is used. string private baseTokenURI; event NewLockSymbol( string symbol ); function _initializeMixinLockMetadata( string calldata _lockName ) internal { ERC165StorageUpgradeable.__ERC165Storage_init(); name = _lockName; // registering the optional erc721 metadata interface with ERC165.sol using // the ID specified in the standard: https://eips.ethereum.org/EIPS/eip-721 _registerInterface(0x5b5e139f); } /** * Allows the Lock owner to assign a descriptive name for this Lock. */ function updateLockName( string calldata _lockName ) external { _onlyLockManager(); name = _lockName; } /** * Allows the Lock owner to assign a Symbol for this Lock. */ function updateLockSymbol( string calldata _lockSymbol ) external { _onlyLockManager(); lockSymbol = _lockSymbol; emit NewLockSymbol(_lockSymbol); } /** * @dev Gets the token symbol * @return string representing the token name */ function symbol() external view returns(string memory) { if(bytes(lockSymbol).length == 0) { return unlockProtocol.globalTokenSymbol(); } else { return lockSymbol; } } /** * Allows the Lock owner to update the baseTokenURI for this Lock. */ function setBaseTokenURI( string calldata _baseTokenURI ) external { _onlyLockManager(); baseTokenURI = _baseTokenURI; } /** @notice A distinct Uniform Resource Identifier (URI) for a given asset. * @param _tokenId The iD of the token for which we want to retrieve the URI. * If 0 is passed here, we just return the appropriate baseTokenURI. * If a custom URI has been set we don't return the lock address. * It may be included in the custom baseTokenURI if needed. * @dev URIs are defined in RFC 3986. The URI may point to a JSON file * that conforms to the "ERC721 Metadata JSON Schema". * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ function tokenURI( uint256 _tokenId ) external view returns(string memory) { string memory URI; string memory tokenId; string memory lockAddress = address(this).address2Str(); string memory seperator; if(_tokenId != 0) { tokenId = _tokenId.uint2Str(); } else { tokenId = ''; } if(address(onTokenURIHook) != address(0)) { uint expirationTimestamp = keyExpirationTimestampFor(_tokenId); return onTokenURIHook.tokenURI( address(this), msg.sender, ownerOf(_tokenId), _tokenId, expirationTimestamp ); } if(bytes(baseTokenURI).length == 0) { URI = unlockProtocol.globalBaseTokenURI(); seperator = '/'; } else { URI = baseTokenURI; seperator = ''; lockAddress = ''; } return URI.strConcat( lockAddress, seperator, tokenId ); } function supportsInterface(bytes4 interfaceId) public view virtual override( AccessControlUpgradeable, ERC165StorageUpgradeable ) returns (bool) { return super.supportsInterface(interfaceId); } uint256[1000] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './MixinDisable.sol'; import './MixinKeys.sol'; import './MixinLockCore.sol'; import './MixinFunds.sol'; import './MixinErrors.sol'; /** * @title Mixin for the purchase-related functions. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinPurchase is MixinErrors, MixinFunds, MixinDisable, MixinLockCore, MixinKeys { event GasRefunded(address indexed receiver, uint refundedAmount, address tokenAddress); event UnlockCallFailed(address indexed lockAddress, address unlockAddress); // default to 0 uint256 internal _gasRefundValue; // Keep track of ERC20 price when purchased mapping(uint256 => uint256) internal _originalPrices; // Keep track of duration when purchased mapping(uint256 => uint256) internal _originalDurations; // keep track of token pricing when purchased mapping(uint256 => address) internal _originalTokens; mapping(address => uint) public referrerFees; /** * @dev Set the value/price to be refunded to the sender on purchase */ function setGasRefundValue(uint256 _refundValue) external { _onlyLockManager(); _gasRefundValue = _refundValue; } /** * @dev Returns value/price to be refunded to the sender on purchase */ function gasRefundValue() external view returns (uint256 _refundValue) { return _gasRefundValue; } /** * Set a specific percentage of the keyPrice to be sent to the referrer while purchasing, * extending or renewing a key * @param _referrer the address of the referrer. If set to the 0x address, any referrer will receive the fee. * @param _feeBasisPoint the percentage of the price to be used for this * specific referrer (in basic points) * @notice to send a fixed percentage of the key price to all referrers, sett a percentage to `address(0)` */ function setReferrerFee(address _referrer, uint _feeBasisPoint) public { _onlyLockManager(); referrerFees[_referrer] = _feeBasisPoint; } /** @dev internal function to execute the payments to referrers if any is set */ function _payReferrer (address _referrer) internal { // get default value uint basisPointsToPay = referrerFees[address(0)]; // get value for the referrer if(referrerFees[_referrer] != 0) { basisPointsToPay = referrerFees[_referrer]; } // pay the referrer if necessary if (basisPointsToPay != 0) { _transfer( tokenAddress, payable(_referrer), keyPrice * basisPointsToPay / BASIS_POINTS_DEN ); } } /** * @dev Helper to communicate with Unlock (record GNP and mint UDT tokens) */ function _recordKeyPurchase (uint _keyPrice, address _referrer) internal { // make sure unlock is a contract, and we catch possible reverts if (address(unlockProtocol).code.length > 0) { // call Unlock contract to record GNP // the function is capped by gas to prevent running out of gas try unlockProtocol.recordKeyPurchase{gas: 300000}(_keyPrice, _referrer) {} catch { // emit missing unlock emit UnlockCallFailed(address(this), address(unlockProtocol)); } } else { // emit missing unlock emit UnlockCallFailed(address(this), address(unlockProtocol)); } } /** * @dev Purchase function * @param _values array of tokens amount to pay for this purchase >= the current keyPrice - any applicable discount * (_values is ignored when using ETH) * @param _recipients array of addresses of the recipients of the purchased key * @param _referrers array of addresses of the users making the referral * @param _keyManagers optional array of addresses to grant managing rights to a specific address on creation * @param _data arbitrary data populated by the front-end which initiated the sale * @notice when called for an existing and non-expired key, the `_keyManager` param will be ignored * @dev Setting _value to keyPrice exactly doubles as a security feature. That way if the lock owner increases the * price while my transaction is pending I can't be charged more than I expected (only applicable to ERC-20 when more * than keyPrice is approved for spending). */ function purchase( uint256[] memory _values, address[] memory _recipients, address[] memory _referrers, address[] memory _keyManagers, bytes[] calldata _data ) external payable returns (uint[] memory) { _lockIsUpToDate(); if(_totalSupply + _recipients.length > maxNumberOfKeys) { revert LOCK_SOLD_OUT(); } if( (_recipients.length != _referrers.length) || (_recipients.length != _keyManagers.length) ) { revert INVALID_LENGTH(); } uint totalPriceToPay; uint tokenId; uint[] memory tokenIds = new uint[](_recipients.length); for (uint256 i = 0; i < _recipients.length; i++) { // check recipient address address _recipient = _recipients[i]; // check for a non-expiring key if (expirationDuration == type(uint).max) { // create a new key tokenId = _createNewKey( _recipient, _keyManagers[i], type(uint).max ); } else { tokenId = _createNewKey( _recipient, _keyManagers[i], block.timestamp + expirationDuration ); } // price uint inMemoryKeyPrice = purchasePriceFor(_recipient, _referrers[i], _data[i]); totalPriceToPay = totalPriceToPay + inMemoryKeyPrice; // store values at purchase time _originalPrices[tokenId] = inMemoryKeyPrice; _originalDurations[tokenId] = expirationDuration; _originalTokens[tokenId] = tokenAddress; // store tokenIds tokenIds[i] = tokenId; if(tokenAddress != address(0) && _values[i] < inMemoryKeyPrice) { revert INSUFFICIENT_ERC20_VALUE(); } // store in unlock _recordKeyPurchase(inMemoryKeyPrice, _referrers[i]); // fire hook uint pricePaid = tokenAddress == address(0) ? msg.value : _values[i]; if(address(onKeyPurchaseHook) != address(0)) { onKeyPurchaseHook.onKeyPurchase( msg.sender, _recipient, _referrers[i], _data[i], inMemoryKeyPrice, pricePaid ); } } // transfer the ERC20 tokens if(tokenAddress != address(0)) { IERC20Upgradeable token = IERC20Upgradeable(tokenAddress); token.transferFrom(msg.sender, address(this), totalPriceToPay); } else if(msg.value < totalPriceToPay) { // We explicitly allow for greater amounts of ETH or tokens to allow 'donations' revert INSUFFICIENT_VALUE(); } // refund gas _refundGas(); // send what is due to referrers for (uint256 i = 0; i < _referrers.length; i++) { _payReferrer(_referrers[i]); } return tokenIds; } /** * @dev Extend function * @param _value the number of tokens to pay for this purchase >= the current keyPrice - any applicable discount * (_value is ignored when using ETH) * @param _tokenId id of the key to extend * @param _referrer address of the user making the referral * @param _data arbitrary data populated by the front-end which initiated the sale * @dev Throws if lock is disabled or key does not exist for _recipient. Throws if _recipient == address(0). */ function extend( uint _value, uint _tokenId, address _referrer, bytes calldata _data ) public payable { _lockIsUpToDate(); _isKey(_tokenId); // extend key duration _extendKey(_tokenId, 0); // transfer the tokens uint inMemoryKeyPrice = purchasePriceFor(ownerOf(_tokenId), _referrer, _data); // process in unlock _recordKeyPurchase(inMemoryKeyPrice, _referrer); if(tokenAddress != address(0)) { if(_value < inMemoryKeyPrice) { revert INSUFFICIENT_ERC20_VALUE(); } IERC20Upgradeable token = IERC20Upgradeable(tokenAddress); token.transferFrom(msg.sender, address(this), inMemoryKeyPrice); } else if(msg.value < inMemoryKeyPrice) { // We explicitly allow for greater amounts of ETH or tokens to allow 'donations' revert INSUFFICIENT_VALUE(); } // if params have changed, then update them if(_originalPrices[_tokenId] != inMemoryKeyPrice) { _originalPrices[_tokenId] = inMemoryKeyPrice; } if(_originalDurations[_tokenId] != expirationDuration) { _originalDurations[_tokenId] = expirationDuration; } if(_originalTokens[_tokenId] != tokenAddress) { _originalTokens[_tokenId] = tokenAddress; } // refund gas (if applicable) _refundGas(); // send what is due to referrer _payReferrer(_referrer); } /** * Renew a given token * @notice only works for non-free, expiring, ERC20 locks * @param _tokenId the ID fo the token to renew * @param _referrer the address of the person to be granted UDT */ function renewMembershipFor( uint _tokenId, address _referrer ) public { _lockIsUpToDate(); _isKey(_tokenId); // check the lock if(_originalDurations[_tokenId] == type(uint).max || tokenAddress == address(0)) { revert NON_RENEWABLE_LOCK(); } // make sure duration and pricing havent changed uint keyPrice = purchasePriceFor(ownerOf(_tokenId), _referrer, ''); if( _originalPrices[_tokenId] != keyPrice || _originalDurations[_tokenId] != expirationDuration || _originalTokens[_tokenId] != tokenAddress ) { revert LOCK_HAS_CHANGED(); } // make sure key is ready for renewal if(isValidKey(_tokenId)) { revert NOT_READY_FOR_RENEWAL(); } // extend key duration _extendKey(_tokenId, 0); // store in unlock _recordKeyPurchase(keyPrice, _referrer); // transfer the tokens IERC20Upgradeable token = IERC20Upgradeable(tokenAddress); token.transferFrom(ownerOf(_tokenId), address(this), keyPrice); // refund gas if applicable _refundGas(); // send what is due to referrer _payReferrer(_referrer); } /** * @notice returns the minimum price paid for a purchase with these params. * @dev minKeyPrice considers any discount from Unlock or the OnKeyPurchase hook */ function purchasePriceFor( address _recipient, address _referrer, bytes memory _data ) public view returns (uint minKeyPrice) { if(address(onKeyPurchaseHook) != address(0)) { minKeyPrice = onKeyPurchaseHook.keyPurchasePrice(msg.sender, _recipient, _referrer, _data); } else { minKeyPrice = keyPrice; } } /** * Refund the specified gas amount and emit an event * @notice this does sth only if `_gasRefundValue` is non-null */ function _refundGas() internal { if (_gasRefundValue != 0) { if(tokenAddress != address(0)) { IERC20Upgradeable token = IERC20Upgradeable(tokenAddress); // send tokens to refun gas token.transfer(msg.sender, _gasRefundValue); } else { (bool success, ) = msg.sender.call{value: _gasRefundValue}(""); if(!success) { revert GAS_REFUND_FAILED(); } } emit GasRefunded(msg.sender, _gasRefundValue, tokenAddress); } } // decreased from 1000 to 997 when added mappings for initial purchases pricing and duration on v10 // decreased from 997 to 996 when added the `referrerFees` mapping on v11 uint256[996] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './MixinKeys.sol'; import './MixinLockCore.sol'; import './MixinRoles.sol'; import './MixinFunds.sol'; import './MixinPurchase.sol'; contract MixinRefunds is MixinRoles, MixinFunds, MixinLockCore, MixinKeys, MixinPurchase { // CancelAndRefund will return funds based on time remaining minus this penalty. // This is calculated as `proRatedRefund * refundPenaltyBasisPoints / BASIS_POINTS_DEN`. uint public refundPenaltyBasisPoints; uint public freeTrialLength; event CancelKey( uint indexed tokenId, address indexed owner, address indexed sendTo, uint refund ); event RefundPenaltyChanged( uint freeTrialLength, uint refundPenaltyBasisPoints ); function _initializeMixinRefunds() internal { // default to 10% refundPenaltyBasisPoints = 1000; } /** * @dev Invoked by the lock owner to destroy the user's key and perform a refund and cancellation * of the key * @param _tokenId The id of the key to expire * @param _amount The amount to refund */ function expireAndRefundFor( uint _tokenId, uint _amount ) external { _isKey(_tokenId); _isValidKey(_tokenId); _onlyLockManager(); _cancelAndRefund(_tokenId, _amount); } /** * @dev Destroys the key and sends a refund based on the amount of time remaining. * @param _tokenId The id of the key to cancel. */ function cancelAndRefund(uint _tokenId) external { _isKey(_tokenId); _isValidKey(_tokenId); _onlyKeyManagerOrApproved(_tokenId); uint refund = getCancelAndRefundValue(_tokenId); _cancelAndRefund(_tokenId, refund); } /** * Allow the owner to change the refund penalty. */ function updateRefundPenalty( uint _freeTrialLength, uint _refundPenaltyBasisPoints ) external { _onlyLockManager(); emit RefundPenaltyChanged( _freeTrialLength, _refundPenaltyBasisPoints ); freeTrialLength = _freeTrialLength; refundPenaltyBasisPoints = _refundPenaltyBasisPoints; } /** * @dev cancels the key for the given keyOwner and sends the refund to the msg.sender. * @notice this deletes ownership info and expire the key, but doesnt 'burn' it */ function _cancelAndRefund( uint _tokenId, uint refund ) internal { address payable keyOwner = payable(ownerOf(_tokenId)); // delete ownership info and expire the key _cancelKey(_tokenId); // emit event emit CancelKey(_tokenId, keyOwner, msg.sender, refund); if (refund > 0) { _transfer(tokenAddress, keyOwner, refund); } // make future reccuring transactions impossible _originalDurations[_tokenId] = 0; _originalPrices[_tokenId] = 0; // inform the hook if there is one registered if(address(onKeyCancelHook) != address(0)) { onKeyCancelHook.onKeyCancel(msg.sender, keyOwner, refund); } } /** * @dev Determines how much of a refund a key would be worth if a cancelAndRefund * is issued now. * @param _tokenId the key to check the refund value for. * @notice due to the time required to mine a tx, the actual refund amount will be lower * than what the user reads from this call. */ function getCancelAndRefundValue( uint _tokenId ) public view returns (uint refund) { _isValidKey(_tokenId); // return entire purchased price if key is non-expiring if(expirationDuration == type(uint).max) { return keyPrice; } // substract free trial value uint timeRemaining = keyExpirationTimestampFor(_tokenId) - block.timestamp; if(timeRemaining + freeTrialLength >= expirationDuration) { refund = keyPrice; } else { refund = keyPrice * timeRemaining / expirationDuration; } // Apply the penalty if this is not a free trial if(freeTrialLength == 0 || timeRemaining + freeTrialLength < expirationDuration) { uint penalty = keyPrice * refundPenaltyBasisPoints / BASIS_POINTS_DEN; if (refund > penalty) { refund -= penalty; } else { refund = 0; } } } uint256[1000] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './MixinRoles.sol'; import './MixinDisable.sol'; import './MixinKeys.sol'; import './MixinFunds.sol'; import './MixinLockCore.sol'; import './MixinPurchase.sol'; import './MixinErrors.sol'; import '@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol'; /** * @title Mixin for the transfer-related functions needed to meet the ERC721 * standard. * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinTransfer is MixinErrors, MixinRoles, MixinFunds, MixinLockCore, MixinKeys, MixinPurchase { using AddressUpgradeable for address; event TransferFeeChanged( uint transferFeeBasisPoints ); // 0x150b7a02 == bytes4(keccak256('onERC721Received(address,address,uint256,bytes)')) bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // The fee relative to keyPrice to charge when transfering a Key to another account // (potentially on a 0x marketplace). // This is calculated as `keyPrice * transferFeeBasisPoints / BASIS_POINTS_DEN`. uint public transferFeeBasisPoints; /** * @notice Allows the key owner to safely transfer a portion of the remaining time * from their key to a new key * @param _tokenIdFrom the key to share * @param _to The recipient of the shared time * @param _timeShared The amount of time shared */ function shareKey( address _to, uint _tokenIdFrom, uint _timeShared ) public { _lockIsUpToDate(); if(maxNumberOfKeys <= _totalSupply) { revert LOCK_SOLD_OUT(); } _onlyKeyManagerOrApproved(_tokenIdFrom); _isValidKey(_tokenIdFrom); if(transferFeeBasisPoints >= BASIS_POINTS_DEN) { revert KEY_TRANSFERS_DISABLED(); } address keyOwner = _ownerOf[_tokenIdFrom]; // store time to be added uint time; // get the remaining time for the origin key uint timeRemaining = keyExpirationTimestampFor(_tokenIdFrom) - block.timestamp; // get the transfer fee based on amount of time wanted share uint fee = getTransferFee(_tokenIdFrom, _timeShared); uint timePlusFee = _timeShared + fee; // ensure that we don't try to share too much if(timePlusFee < timeRemaining) { // now we can safely set the time time = _timeShared; // deduct time from parent key, including transfer fee _timeMachine(_tokenIdFrom, timePlusFee, false); } else { // we have to recalculate the fee here fee = getTransferFee(_tokenIdFrom, timeRemaining); time = timeRemaining - fee; _keys[_tokenIdFrom].expirationTimestamp = block.timestamp; // Effectively expiring the key emit ExpireKey(_tokenIdFrom); } // create new key uint tokenIdTo = _createNewKey( _to, address(0), block.timestamp + time ); // trigger event emit Transfer( keyOwner, _to, tokenIdTo ); if(!_checkOnERC721Received(keyOwner, _to, tokenIdTo, '')) { revert NON_COMPLIANT_ERC721_RECEIVER(); } } /** * an ERC721-like function to transfer a token from one account to another * @param _from the owner of token to transfer * @param _recipient the address that will receive the token * @param _tokenId the id of the token * @notice requirements: if the caller is not `from`, it must be approved to move this token by * either {approve} or {setApprovalForAll}. * The key manager will be reset to address zero after the transfer */ function transferFrom( address _from, address _recipient, uint _tokenId ) public { _isValidKey(_tokenId); _onlyKeyManagerOrApproved(_tokenId); // reset key manager to address zero keyManagerOf[_tokenId] = address(0); _transferFrom(_from, _recipient, _tokenId); } /** * Lending a key allows you to transfer the token while retaining the * ownerships right by setting yourself as a key manager first * @param _from the owner of token to transfer * @param _recipient the address that will receive the token * @param _tokenId the id of the token * @notice This function can only called by 1) the key owner when no key manager is set or 2) the key manager. * After calling the function, the `_recipient` will be the new owner, and the sender of the tx * will become the key manager. */ function lendKey( address _from, address _recipient, uint _tokenId ) public { // make sure caller is either owner or key manager if(!_isKeyManager(_tokenId, msg.sender)) { revert UNAUTHORIZED(); } // transfer key ownership to lender _transferFrom(_from, _recipient, _tokenId); // set key owner as key manager keyManagerOf[_tokenId] = msg.sender; } /** * Unlend is called when you have lent a key and want to claim its full ownership back * @param _recipient the address that will receive the token ownership * @param _tokenId the id of the token * @notice Only the key manager of the token can call this function */ function unlendKey( address _recipient, uint _tokenId ) public { _isValidKey(_tokenId); if(msg.sender != keyManagerOf[_tokenId]) { revert UNAUTHORIZED(); } _transferFrom(ownerOf(_tokenId), _recipient, _tokenId); } /** * This functions contains the logic to transfer a token * from an account to another */ function _transferFrom( address _from, address _recipient, uint _tokenId ) private { _isValidKey(_tokenId); // incorrect _from field if (ownerOf(_tokenId) != _from) { revert UNAUTHORIZED(); } if(transferFeeBasisPoints >= BASIS_POINTS_DEN) { revert KEY_TRANSFERS_DISABLED(); } if(_recipient == address(0)) { revert INVALID_ADDRESS(); } if(_from == _recipient) { revert TRANSFER_TO_SELF(); } // subtract the fee from the senders key before the transfer _timeMachine(_tokenId, getTransferFee(_tokenId, 0), false); // transfer a token Key storage key = _keys[_tokenId]; // update expiration key.expirationTimestamp = keyExpirationTimestampFor(_tokenId); // increase total number of unique owners if(balanceOf(_recipient) == 0 ) { numberOfOwners++; } // delete token from previous owner _deleteOwnershipRecord(_tokenId); // record new owner _createOwnershipRecord(_tokenId, _recipient); // clear any previous approvals _clearApproval(_tokenId); // make future reccuring transactions impossible _originalDurations[_tokenId] = 0; _originalPrices[_tokenId] = 0; // trigger event emit Transfer( _from, _recipient, _tokenId ); // fire hook if it exists if(address(onKeyTransferHook) != address(0)) { onKeyTransferHook.onKeyTransfer( address(this), _tokenId, msg.sender, // operator _from, _recipient, key.expirationTimestamp ); } } /** * @notice An ERC-20 style transfer. * @param _tokenId the Id of the token to send * @param _to the destination address * @param _valueBasisPoint a percentage (expressed as basis points) of the time to be transferred * @return success bool success/failure of the transfer */ function transfer( uint _tokenId, address _to, uint _valueBasisPoint ) public returns (bool success) { _isValidKey(_tokenId); uint timeShared = ( keyExpirationTimestampFor(_tokenId) - block.timestamp ) * _valueBasisPoint / BASIS_POINTS_DEN; shareKey( _to, _tokenId, timeShared); return true; } /** * @notice Transfers the ownership of an NFT from one address to another address * @dev This works identically to the other function with an extra data parameter, * except this function just sets data to '' * @param _from The current owner of the NFT * @param _to The new owner * @param _tokenId The NFT to transfer */ function safeTransferFrom( address _from, address _to, uint _tokenId ) public { safeTransferFrom(_from, _to, _tokenId, ''); } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set * @notice disabled when transfers are disabled */ function setApprovalForAll( address _to, bool _approved ) public { if(_to == msg.sender) { revert CANNOT_APPROVE_SELF(); } if(transferFeeBasisPoints >= BASIS_POINTS_DEN) { revert KEY_TRANSFERS_DISABLED(); } managerToOperatorApproved[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @notice Transfers the ownership of an NFT from one address to another address. * When transfer is complete, this functions * checks if `_to` is a smart contract (code size > 0). If so, it calls * `onERC721Received` on `_to` and throws if the return value is not * `bytes4(keccak256('onERC721Received(address,address,uint,bytes)'))`. * @param _from The current owner of the NFT * @param _to The new owner * @param _tokenId The NFT to transfer * @param _data Additional data with no specified format, sent in call to `_to` */ function safeTransferFrom( address _from, address _to, uint _tokenId, bytes memory _data ) public { transferFrom(_from, _to, _tokenId); if(!_checkOnERC721Received(_from, _to, _tokenId, _data)) { revert NON_COMPLIANT_ERC721_RECEIVER(); } } /** * Allow the Lock owner to change the transfer fee. */ function updateTransferFee( uint _transferFeeBasisPoints ) external { _onlyLockManager(); emit TransferFeeChanged( _transferFeeBasisPoints ); transferFeeBasisPoints = _transferFeeBasisPoints; } /** * Determines how much of a fee would need to be paid in order to * transfer to another account. This is pro-rated so the fee goes * down overtime. * @dev Throws if _tokenId is not have a valid key * @param _tokenId The id of the key check the transfer fee for. * @param _time The amount of time to calculate the fee for. * @return The transfer fee in seconds. */ function getTransferFee( uint _tokenId, uint _time ) public view returns (uint) { _isKey(_tokenId); uint expirationTimestamp = keyExpirationTimestampFor(_tokenId); if(expirationTimestamp < block.timestamp) { return 0; } else { uint timeToTransfer; if(_time == 0) { timeToTransfer = expirationTimestamp - block.timestamp; } else { timeToTransfer = _time; } return timeToTransfer * transferFeeBasisPoints / BASIS_POINTS_DEN; } } /** * @dev Internal function to invoke `onERC721Received` on a target address * The call is not executed if the target address is not a contract * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) internal returns (bool) { if (!to.isContract()) { return true; } bytes4 retval = IERC721ReceiverUpgradeable(to).onERC721Received( msg.sender, from, tokenId, _data); return (retval == _ERC721_RECEIVED); } uint256[1000] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // This contract mostly follows the pattern established by openzeppelin in // openzeppelin/contracts-ethereum-package/contracts/access/roles import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol'; import './MixinErrors.sol'; contract MixinRoles is AccessControlUpgradeable, MixinErrors { // roles bytes32 public constant LOCK_MANAGER_ROLE = keccak256("LOCK_MANAGER"); bytes32 public constant KEY_GRANTER_ROLE = keccak256("KEY_GRANTER"); // events event LockManagerAdded(address indexed account); event LockManagerRemoved(address indexed account); event KeyGranterAdded(address indexed account); event KeyGranterRemoved(address indexed account); // initializer function _initializeMixinRoles(address sender) internal { // for admin mamangers to add other lock admins _setRoleAdmin(LOCK_MANAGER_ROLE, LOCK_MANAGER_ROLE); // for lock managers to add/remove key granters _setRoleAdmin(KEY_GRANTER_ROLE, LOCK_MANAGER_ROLE); if (!isLockManager(sender)) { _setupRole(LOCK_MANAGER_ROLE, sender); } if (!isKeyGranter(sender)) { _setupRole(KEY_GRANTER_ROLE, sender); } } // modifiers function _onlyLockManager() internal view { if(!hasRole(LOCK_MANAGER_ROLE, msg.sender)) { revert ONLY_LOCK_MANAGER(); } } // lock manager functions function isLockManager(address account) public view returns (bool) { return hasRole(LOCK_MANAGER_ROLE, account); } function addLockManager(address account) public { _onlyLockManager(); grantRole(LOCK_MANAGER_ROLE, account); emit LockManagerAdded(account); } function renounceLockManager() public { renounceRole(LOCK_MANAGER_ROLE, msg.sender); emit LockManagerRemoved(msg.sender); } // key granter functions function isKeyGranter(address account) public view returns (bool) { return hasRole(KEY_GRANTER_ROLE, account); } function addKeyGranter(address account) public { _onlyLockManager(); grantRole(KEY_GRANTER_ROLE, account); emit KeyGranterAdded(account); } function revokeKeyGranter(address _granter) public { _onlyLockManager(); revokeRole(KEY_GRANTER_ROLE, _granter); emit KeyGranterRemoved(_granter); } uint256[1000] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './MixinLockCore.sol'; import './MixinErrors.sol'; /** * @title Mixin to add support for `ownable()` * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinConvenienceOwnable is MixinErrors, MixinLockCore { // used for `owner()`convenience helper address private _convenienceOwner; // events event OwnershipTransferred(address previousOwner, address newOwner); function _initializeMixinConvenienceOwnable(address _sender) internal { _convenienceOwner = _sender; } /** `owner()` is provided as an helper to mimick the `Ownable` contract ABI. * The `Ownable` logic is used by many 3rd party services to determine * contract ownership - e.g. who is allowed to edit metadata on Opensea. * * @notice This logic is NOT used internally by the Unlock Protocol and is made * available only as a convenience helper. */ function owner() public view returns (address) { return _convenienceOwner; } /** Setter for the `owner` convenience helper (see `owner()` docstring for more). * @notice This logic is NOT used internally by the Unlock Protocol ans is made * available only as a convenience helper. * @param account address returned by the `owner()` helper */ function setOwner(address account) public { _onlyLockManager(); if(account == address(0)) { revert OWNER_CANT_BE_ADDRESS_ZERO(); } address _previousOwner = _convenienceOwner; _convenienceOwner = account; emit OwnershipTransferred(_previousOwner, account); } function isOwner(address account) public view returns (bool) { return _convenienceOwner == account; } uint256[1000] private __safe_upgrade_gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @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/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 pragma solidity ^0.8.0; /** * @title List of all error messages * (replace string errors message to save on contract size) */ contract MixinErrors { // generic error OUT_OF_RANGE(); error NULL_VALUE(); error INVALID_ADDRESS(); error INVALID_TOKEN(); error INVALID_LENGTH(); error UNAUTHORIZED(); // erc 721 error NON_COMPLIANT_ERC721_RECEIVER(); // roles error ONLY_LOCK_MANAGER_OR_KEY_GRANTER(); error ONLY_KEY_MANAGER_OR_APPROVED(); error UNAUTHORIZED_KEY_MANAGER_UPDATE(); error ONLY_LOCK_MANAGER_OR_BENEFICIARY(); error ONLY_LOCK_MANAGER(); // single key status error KEY_NOT_VALID(); error NO_SUCH_KEY(); // single key operations error CANT_EXTEND_NON_EXPIRING_KEY(); error NOT_ENOUGH_TIME(); error NOT_ENOUGH_FUNDS(); // migration & data schema error SCHEMA_VERSION_NOT_CORRECT(); error MIGRATION_REQUIRED(); // lock status/settings error OWNER_CANT_BE_ADDRESS_ZERO(); error MAX_KEYS_REACHED(); error KEY_TRANSFERS_DISABLED(); error CANT_BE_SMALLER_THAN_SUPPLY(); // transfers and approvals error TRANSFER_TO_SELF(); error CANNOT_APPROVE_SELF(); // keys management error LOCK_SOLD_OUT(); // purchase error INSUFFICIENT_ERC20_VALUE(); error INSUFFICIENT_VALUE(); // renewals error NON_RENEWABLE_LOCK(); error LOCK_HAS_CHANGED(); error NOT_READY_FOR_RENEWAL(); // gas refund error GAS_REFUND_FAILED(); // hooks // NB: `hookIndex` designed the index of hook address in the params of `setEventHooks` error INVALID_HOOK(uint8 hookIndex); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.17 <0.9.0; /** * @title The Unlock Interface **/ interface IUnlock { // Use initialize instead of a constructor to support proxies(for upgradeability via zos). function initialize(address _unlockOwner) external; /** * @dev deploy a ProxyAdmin contract used to upgrade locks */ function initializeProxyAdmin() external; // store contract proxy admin address function proxyAdminAddress() external view; /** * @notice Create lock (legacy) * This deploys a lock for a creator. It also keeps track of the deployed lock. * @param _expirationDuration the duration of the lock (pass 0 for unlimited duration) * @param _tokenAddress set to the ERC20 token address, or 0 for ETH. * @param _keyPrice the price of each key * @param _maxNumberOfKeys the maximum nimbers of keys to be edited * @param _lockName the name of the lock * param _salt [deprec] -- kept only for backwards copatibility * This may be implemented as a sequence ID or with RNG. It's used with `create2` * to know the lock's address before the transaction is mined. * @dev internally call `createUpgradeableLock` */ function createLock( uint _expirationDuration, address _tokenAddress, uint _keyPrice, uint _maxNumberOfKeys, string calldata _lockName, bytes12 // _salt ) external returns(address); /** * @notice Create lock (default) * This deploys a lock for a creator. It also keeps track of the deployed lock. * @param data bytes containing the call to initialize the lock template * @dev this call is passed as encoded function - for instance: * bytes memory data = abi.encodeWithSignature( * 'initialize(address,uint256,address,uint256,uint256,string)', * msg.sender, * _expirationDuration, * _tokenAddress, * _keyPrice, * _maxNumberOfKeys, * _lockName * ); * @return address of the create lock */ function createUpgradeableLock( bytes memory data ) external returns(address); /** * Create an upgradeable lock using a specific PublicLock version * @param data bytes containing the call to initialize the lock template * (refer to createUpgradeableLock for more details) * @param _lockVersion the version of the lock to use */ function createUpgradeableLockAtVersion( bytes memory data, uint16 _lockVersion ) external returns (address); /** * @notice Upgrade a lock to a specific version * @dev only available for publicLockVersion > 10 (proxyAdmin /required) * @param lockAddress the existing lock address * @param version the version number you are targeting * Likely implemented with OpenZeppelin TransparentProxy contract */ function upgradeLock( address payable lockAddress, uint16 version ) external returns(address); /** * This function keeps track of the added GDP, as well as grants of discount tokens * to the referrer, if applicable. * The number of discount tokens granted is based on the value of the referal, * the current growth rate and the lock's discount token distribution rate * This function is invoked by a previously deployed lock only. */ function recordKeyPurchase( uint _value, address _referrer // solhint-disable-line no-unused-vars ) external; /** * @notice [DEPRECATED] Call to this function has been removed from PublicLock > v9. * @dev [DEPRECATED] Kept for backwards compatibility * This function will keep track of consumed discounts by a given user. * It will also grant discount tokens to the creator who is granting the discount based on the * amount of discount and compensation rate. * This function is invoked by a previously deployed lock only. */ function recordConsumedDiscount( uint _discount, uint _tokens // solhint-disable-line no-unused-vars ) external; /** * @notice [DEPRECATED] Call to this function has been removed from PublicLock > v9. * @dev [DEPRECATED] Kept for backwards compatibility * This function returns the discount available for a user, when purchasing a * a key from a lock. * This does not modify the state. It returns both the discount and the number of tokens * consumed to grant that discount. */ function computeAvailableDiscountFor( address _purchaser, // solhint-disable-line no-unused-vars uint _keyPrice // solhint-disable-line no-unused-vars ) external view returns(uint discount, uint tokens); // Function to read the globalTokenURI field. function globalBaseTokenURI() external view returns(string memory); /** * @dev Redundant with globalBaseTokenURI() for backwards compatibility with v3 & v4 locks. */ function getGlobalBaseTokenURI() external view returns (string memory); // Function to read the globalTokenSymbol field. function globalTokenSymbol() external view returns(string memory); // Function to read the chainId field. function chainId() external view returns(uint); /** * @dev Redundant with globalTokenSymbol() for backwards compatibility with v3 & v4 locks. */ function getGlobalTokenSymbol() external view returns (string memory); /** * @notice Allows the owner to update configuration variables */ function configUnlock( address _udt, address _weth, uint _estimatedGasForPurchase, string calldata _symbol, string calldata _URI, uint _chainId ) external; /** * @notice Add a PublicLock template to be used for future calls to `createLock`. * @dev This is used to upgrade conytract per version number */ function addLockTemplate(address impl, uint16 version) external; // match lock templates addresses with version numbers function publicLockImpls(uint16 _version) external view; // match version numbers with lock templates addresses function publicLockVersions(address _impl) external view; // the latest existing lock template version function publicLockLatestVersion() external view; /** * @notice Upgrade the PublicLock template used for future calls to `createLock`. * @dev This will initialize the template and revokeOwnership. */ function setLockTemplate( address payable _publicLockAddress ) external; // Allows the owner to change the value tracking variables as needed. function resetTrackedValue( uint _grossNetworkProduct, uint _totalDiscountGranted ) external; function grossNetworkProduct() external view returns(uint); function totalDiscountGranted() external view returns(uint); function locks(address) external view returns(bool deployed, uint totalSales, uint yieldedDiscountTokens); // The address of the public lock template, used when `createLock` is called function publicLockAddress() external view returns(address); // Map token address to exchange contract address if the token is supported // Used for GDP calculations function uniswapOracles(address) external view returns(address); // The WETH token address, used for value calculations function weth() external view returns(address); // The UDT token address, used to mint tokens on referral function udt() external view returns(address); // The approx amount of gas required to purchase a key function estimatedGasForPurchase() external view returns(uint); /** * Helper to get the network mining basefee as introduced in EIP-1559 * @dev this helper can be wrapped in try/catch statement to avoid * revert in networks where EIP-1559 is not implemented */ function networkBaseFee() external view returns (uint); // The version number of the current Unlock implementation on this network function unlockVersion() external pure returns(uint16); /** * @notice allows the owner to set the oracle address to use for value conversions * setting the _oracleAddress to address(0) removes support for the token * @dev This will also call update to ensure at least one datapoint has been recorded. */ function setOracle( address _tokenAddress, address _oracleAddress ) external; // Initialize the Ownable contract, granting contract ownership to the specified sender function __initializeOwnable(address sender) external; /** * @dev Returns true if the caller is the current owner. */ function isOwner() external view returns(bool); /** * @dev Returns the address of the current owner. */ function owner() external view returns(address); /** * @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() external; /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.17 <0.9.0; /** * @notice Functions to be implemented by a keyCancelHook. * @dev Lock hooks are configured by calling `setEventHooks` on the lock. */ interface ILockKeyCancelHook { /** * @notice If the lock owner has registered an implementer * then this hook is called with every key cancel. * @param operator the msg.sender issuing the cancel * @param to the account which had the key canceled * @param refund the amount sent to the `to` account (ETH or a ERC-20 token) */ function onKeyCancel( address operator, address to, uint256 refund ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.17 <0.9.0; /** * @notice Functions to be implemented by a keyPurchaseHook. * @dev Lock hooks are configured by calling `setEventHooks` on the lock. */ interface ILockKeyPurchaseHook { /** * @notice Used to determine the purchase price before issueing a transaction. * This allows the hook to offer a discount on purchases. * This may revert to prevent a purchase. * @param from the msg.sender making the purchase * @param recipient the account which will be granted a key * @param referrer the account which referred this key sale * @param data arbitrary data populated by the front-end which initiated the sale * @return minKeyPrice the minimum value/price required to purchase a key with these settings * @dev the lock's address is the `msg.sender` when this function is called via * the lock's `purchasePriceFor` function */ function keyPurchasePrice( address from, address recipient, address referrer, bytes calldata data ) external view returns (uint minKeyPrice); /** * @notice If the lock owner has registered an implementer then this hook * is called with every key sold. * @param from the msg.sender making the purchase * @param recipient the account which will be granted a key * @param referrer the account which referred this key sale * @param data arbitrary data populated by the front-end which initiated the sale * @param minKeyPrice the price including any discount granted from calling this * hook's `keyPurchasePrice` function * @param pricePaid the value/pricePaid included with the purchase transaction * @dev the lock's address is the `msg.sender` when this function is called */ function onKeyPurchase( address from, address recipient, address referrer, bytes calldata data, uint minKeyPrice, uint pricePaid ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.17 <0.9.0; /** * @notice Functions to be implemented by a hasValidKey Hook. * @dev Lock hooks are configured by calling `setEventHooks` on the lock. */ interface ILockValidKeyHook { /** * @notice If the lock owner has registered an implementer then this hook * is called every time balanceOf is called * @param lockAddress the address of the current lock * @param keyOwner the potential owner of the key for which we are retrieving the `balanceof` * @param expirationTimestamp the key expiration timestamp */ function hasValidKey( address lockAddress, address keyOwner, uint256 expirationTimestamp, bool isValidKey ) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.17 <0.9.0; /** * @notice Functions to be implemented by a tokenURIHook. * @dev Lock hooks are configured by calling `setEventHooks` on the lock. */ interface ILockTokenURIHook { /** * @notice If the lock owner has registered an implementer * then this hook is called every time `tokenURI()` is called * @param lockAddress the address of the lock * @param operator the msg.sender issuing the call * @param owner the owner of the key for which we are retrieving the `tokenUri` * @param keyId the id (tokenId) of the key (if applicable) * @param expirationTimestamp the key expiration timestamp * @return the tokenURI */ function tokenURI( address lockAddress, address operator, address owner, uint256 keyId, uint expirationTimestamp ) external view returns(string memory); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.17 <0.9.0; /** * @notice Functions to be implemented by a hasValidKey Hook. * @dev Lock hooks are configured by calling `setEventHooks` on the lock. */ interface ILockKeyTransferHook { /** * @notice If the lock owner has registered an implementer then this hook * is called every time balanceOf is called * @param lockAddress the address of the current lock * @param tokenId the Id of the transferred key * @param operator who initiated the transfer * @param from the previous owner of transferred key * @param from the previous owner of transferred key * @param to the new owner of the key * @param expirationTimestamp the key expiration timestamp (after transfer) */ function onKeyTransfer( address lockAddress, uint tokenId, address operator, address from, address to, uint expirationTimestamp ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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 (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_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) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @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.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.17 <=0.8.13; // This contract provides some utility methods for use with the unlock protocol smart contracts. // Borrowed from: // https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol#L943 library UnlockUtils { function strConcat( string memory _a, string memory _b, string memory _c, string memory _d ) internal pure returns (string memory _concatenatedString) { return string(abi.encodePacked(_a, _b, _c, _d)); } function uint2Str( uint _i ) internal pure returns (string memory _uintAsString) { // make a copy of the param to avoid security/no-assign-params error uint c = _i; if (_i == 0) { return '0'; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len; while (c != 0) { k = k-1; uint8 temp = (48 + uint8(c - c / 10 * 10)); bytes1 b1 = bytes1(temp); bstr[k] = b1; c /= 10; } return string(bstr); } function address2Str( address _addr ) internal pure returns(string memory) { bytes32 value = bytes32(uint256(uint160(_addr))); bytes memory alphabet = '0123456789abcdef'; bytes memory str = new bytes(42); str[0] = '0'; str[1] = 'x'; for (uint i = 0; i < 20; i++) { str[2+i*2] = alphabet[uint8(value[i + 12] >> 4)]; str[3+i*2] = alphabet[uint8(value[i + 12] & 0x0f)]; } return string(str); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
{ "optimizer": { "enabled": true, "runs": 80 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[],"name":"CANNOT_APPROVE_SELF","type":"error"},{"inputs":[],"name":"CANT_BE_SMALLER_THAN_SUPPLY","type":"error"},{"inputs":[],"name":"CANT_EXTEND_NON_EXPIRING_KEY","type":"error"},{"inputs":[],"name":"GAS_REFUND_FAILED","type":"error"},{"inputs":[],"name":"INSUFFICIENT_ERC20_VALUE","type":"error"},{"inputs":[],"name":"INSUFFICIENT_VALUE","type":"error"},{"inputs":[],"name":"INVALID_ADDRESS","type":"error"},{"inputs":[{"internalType":"uint8","name":"hookIndex","type":"uint8"}],"name":"INVALID_HOOK","type":"error"},{"inputs":[],"name":"INVALID_LENGTH","type":"error"},{"inputs":[],"name":"INVALID_TOKEN","type":"error"},{"inputs":[],"name":"KEY_NOT_VALID","type":"error"},{"inputs":[],"name":"KEY_TRANSFERS_DISABLED","type":"error"},{"inputs":[],"name":"LOCK_HAS_CHANGED","type":"error"},{"inputs":[],"name":"LOCK_SOLD_OUT","type":"error"},{"inputs":[],"name":"MAX_KEYS_REACHED","type":"error"},{"inputs":[],"name":"MIGRATION_REQUIRED","type":"error"},{"inputs":[],"name":"NON_COMPLIANT_ERC721_RECEIVER","type":"error"},{"inputs":[],"name":"NON_RENEWABLE_LOCK","type":"error"},{"inputs":[],"name":"NOT_ENOUGH_FUNDS","type":"error"},{"inputs":[],"name":"NOT_ENOUGH_TIME","type":"error"},{"inputs":[],"name":"NOT_READY_FOR_RENEWAL","type":"error"},{"inputs":[],"name":"NO_SUCH_KEY","type":"error"},{"inputs":[],"name":"NULL_VALUE","type":"error"},{"inputs":[],"name":"ONLY_KEY_MANAGER_OR_APPROVED","type":"error"},{"inputs":[],"name":"ONLY_LOCK_MANAGER","type":"error"},{"inputs":[],"name":"ONLY_LOCK_MANAGER_OR_BENEFICIARY","type":"error"},{"inputs":[],"name":"ONLY_LOCK_MANAGER_OR_KEY_GRANTER","type":"error"},{"inputs":[],"name":"OUT_OF_RANGE","type":"error"},{"inputs":[],"name":"OWNER_CANT_BE_ADDRESS_ZERO","type":"error"},{"inputs":[],"name":"SCHEMA_VERSION_NOT_CORRECT","type":"error"},{"inputs":[],"name":"TRANSFER_TO_SELF","type":"error"},{"inputs":[],"name":"UNAUTHORIZED","type":"error"},{"inputs":[],"name":"UNAUTHORIZED_KEY_MANAGER_UPDATE","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"sendTo","type":"address"},{"indexed":false,"internalType":"uint256","name":"refund","type":"uint256"}],"name":"CancelKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"_timeAdded","type":"bool"}],"name":"ExpirationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ExpireKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"refundedAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"}],"name":"GasRefunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTimestamp","type":"uint256"}],"name":"KeyExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"KeyGranterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"KeyGranterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_newManager","type":"address"}],"name":"KeyManagerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"updatedRecordsCount","type":"uint256"}],"name":"KeysMigrated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"LockManagerAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"LockManagerRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"symbol","type":"string"}],"name":"NewLockSymbol","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldKeyPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"keyPrice","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldTokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"}],"name":"PricingChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"freeTrialLength","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"refundPenaltyBasisPoints","type":"uint256"}],"name":"RefundPenaltyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"transferFeeBasisPoints","type":"uint256"}],"name":"TransferFeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lockAddress","type":"address"},{"indexed":false,"internalType":"address","name":"unlockAddress","type":"address"}],"name":"UnlockCallFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"KEY_GRANTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LOCK_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addKeyGranter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addLockManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_approved","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"approveBeneficiary","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beneficiary","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelAndRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"expirationDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"expireAndRefundFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_referrer","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"extend","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"freeTrialLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasRefundValue","outputs":[{"internalType":"uint256","name":"_refundValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getCancelAndRefundValue","outputs":[{"internalType":"uint256","name":"refund","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"getHasValidKey","outputs":[{"internalType":"bool","name":"isValid","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_time","type":"uint256"}],"name":"getTransferFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"grantKeyExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_recipients","type":"address[]"},{"internalType":"uint256[]","name":"_expirationTimestamps","type":"uint256[]"},{"internalType":"address[]","name":"_keyManagers","type":"address[]"}],"name":"grantKeys","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_lockCreator","type":"address"},{"internalType":"uint256","name":"_expirationDuration","type":"uint256"},{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_keyPrice","type":"uint256"},{"internalType":"uint256","name":"_maxNumberOfKeys","type":"uint256"},{"internalType":"string","name":"_lockName","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isKeyGranter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isLockManager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"isValidKey","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"keyExpirationTimestampFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"keyManagerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"keyPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"lendKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxKeysPerAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxNumberOfKeys","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenIdFrom","type":"uint256"},{"internalType":"uint256","name":"_tokenIdTo","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mergeKeys","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numberOfOwners","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onKeyCancelHook","outputs":[{"internalType":"contract ILockKeyCancelHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onKeyPurchaseHook","outputs":[{"internalType":"contract ILockKeyPurchaseHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onKeyTransferHook","outputs":[{"internalType":"contract ILockKeyTransferHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onTokenURIHook","outputs":[{"internalType":"contract ILockTokenURIHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onValidKeyHook","outputs":[{"internalType":"contract ILockValidKeyHook","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"publicLockVersion","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_values","type":"uint256[]"},{"internalType":"address[]","name":"_recipients","type":"address[]"},{"internalType":"address[]","name":"_referrers","type":"address[]"},{"internalType":"address[]","name":"_keyManagers","type":"address[]"},{"internalType":"bytes[]","name":"_data","type":"bytes[]"}],"name":"purchase","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"address","name":"_referrer","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"purchasePriceFor","outputs":[{"internalType":"uint256","name":"minKeyPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"referrerFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refundPenaltyBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"renewMembershipFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceLockManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_granter","type":"address"}],"name":"revokeKeyGranter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"schemaVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"bool","name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_baseTokenURI","type":"string"}],"name":"setBaseTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_onKeyPurchaseHook","type":"address"},{"internalType":"address","name":"_onKeyCancelHook","type":"address"},{"internalType":"address","name":"_onValidKeyHook","type":"address"},{"internalType":"address","name":"_onTokenURIHook","type":"address"},{"internalType":"address","name":"_onKeyTransferHook","type":"address"}],"name":"setEventHooks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newExpirationDuration","type":"uint256"}],"name":"setExpirationDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_refundValue","type":"uint256"}],"name":"setGasRefundValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_keyManager","type":"address"}],"name":"setKeyManagerOf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxKeys","type":"uint256"}],"name":"setMaxKeysPerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxNumberOfKeys","type":"uint256"}],"name":"setMaxNumberOfKeys","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referrer","type":"address"},{"internalType":"uint256","name":"_feeBasisPoint","type":"uint256"}],"name":"setReferrerFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenIdFrom","type":"uint256"},{"internalType":"uint256","name":"_timeShared","type":"uint256"}],"name":"shareKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"totalKeys","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_valueBasisPoint","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"transferFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"unlendKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unlockProtocol","outputs":[{"internalType":"contract IUnlock","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_beneficiary","type":"address"}],"name":"updateBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_keyPrice","type":"uint256"},{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"updateKeyPricing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_lockName","type":"string"}],"name":"updateLockName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_lockSymbol","type":"string"}],"name":"updateLockSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_freeTrialLength","type":"uint256"},{"internalType":"uint256","name":"_refundPenaltyBasisPoints","type":"uint256"}],"name":"updateRefundPenalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateSchemaVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_transferFeeBasisPoints","type":"uint256"}],"name":"updateTransferFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
608060405234801561001057600080fd5b50615e2380620000216000396000f3fe6080604052600436106104d65760003560e01c8063626485a311610287578063a375cb0511610165578063d32bfb6c116100cc578063f0ba604011610085578063f0ba604014610fe2578063f12c6b6e14610ff7578063f32e8b2414611017578063f3fef3a31461102c578063f5766b391461104c578063f8548e361461106c57600080fd5b8063d32bfb6c14610f39578063d52e4a1014610f59578063d547741f14610f6f578063d813cc1914610f8f578063debe2b0d14610fa2578063e985e9c514610fc257600080fd5b8063b88d4fde1161011e578063b88d4fde14610e6f578063bf4a927014610e8f578063c23135dd14610eaf578063c87b56dd14610edd578063d1bbd49c14610efd578063d250348514610f1957600080fd5b8063a375cb0514610da5578063a98d362314610dbc578063aae4b8f714610def578063b11d7ec114610e0f578063b1a3b25d14610e2f578063b585a6d514610e4f57600080fd5b80638577a6d51161020957806393fd1844116101c257806393fd184414610d0357806395d89b4114610d1a5780639d76ea5814610d2f578063a217fddf14610d50578063a22cb46514610d65578063a2e4cd2e14610d8557600080fd5b80638577a6d514610c3d5780638932a90d14610c5d5780638ca2fbad14610c825780638da5cb5b14610ca457806391d1485414610cc357806392ac98a514610ce357600080fd5b8063626485a314610ae55780636352211e14610b055780636d8ea5b414610b255780636eadde4314610b4557806370a0823114610b6557806374b6c10614610b85578063782a4ade14610b9c5780637ec2a72414610bbc578063812eecd414610bdd57806381a3c94314610bfd5780638505fe9514610c1d57600080fd5b80632f745c59116103b457806342966c681161033657806354b249fb116102ef57806354b249fb14610a27578063550ef3a814610a58578063558b71e914610a78578063564aa99d14610a9857806356e0d51f14610ab85780636207a8da14610acf57600080fd5b806342966c68146109595780634cd38c1d146109795780634d025fed146109995780634e2ce6d3146109d05780634f6ccce7146109e757806352b0f63814610a0757600080fd5b80632f745c59146107f757806330176e131461081757806331159a1714610837578063338189971461085757806336568abe14610877578063389f07e81461089757806338af3eed146108b85780633916c781146108d957806339f46986146108f9578063407dc5891461091957806342842e0e1461093957600080fd5b806313af403511610458578063248a9ca311610411578063248a9ca31461071557806326e9ca07146107455780632af9162a146107665780632d33dd5b146107865780632f2ff15d146107a75780632f54bf6e146107c757600080fd5b806313af40351461066557806318160ddd14610685578063183767da1461069b578063217751bc146106b257806323100509146106d357806323b872dd146106f557600080fd5b806301ffc9a7146104e2578063068208cd1461051757806306fdde0314610539578063081812fc1461055b578063095ea7b314610588578063097ba333146105a85780630aaffd2a146105d65780630c2db8d1146105f65780630f15023b1461061657806310e569731461063757806311a4c03a1461064e57600080fd5b366104dd57005b600080fd5b3480156104ee57600080fd5b506105026104fd366004615076565b61108c565b60405190151581526020015b60405180910390f35b34801561052357600080fd5b50610537610532366004615093565b61109d565b005b34801561054557600080fd5b5061054e61111c565b60405161050e9190615117565b34801561056757600080fd5b5061057b61057636600461512a565b6111ab565b60405161050e9190615143565b34801561059457600080fd5b506105376105a336600461516c565b6111d3565b3480156105b457600080fd5b506105c86105c336600461525b565b61126e565b60405190815260200161050e565b3480156105e257600080fd5b506105376105f13660046152bc565b61130f565b34801561060257600080fd5b506105376106113660046152d9565b611361565b34801561062257600080fd5b50610c835461057b906001600160a01b031681565b34801561064357600080fd5b506105c8610c855481565b34801561065a57600080fd5b506105c8610c845481565b34801561067157600080fd5b506105376106803660046152bc565b6113b6565b34801561069157600080fd5b50610c87546105c8565b3480156106a757600080fd5b506105c86124075481565b3480156106be57600080fd5b50610c8a5461057b906001600160a01b031681565b3480156106df57600080fd5b506105c8600080516020615d8e83398151915281565b34801561070157600080fd5b506105376107103660046152d9565b611448565b34801561072157600080fd5b506105c861073036600461512a565b60009081526097602052604090206001015490565b34801561075157600080fd5b50610c8b5461057b906001600160a01b031681565b34801561077257600080fd5b506105376107813660046152bc565b611482565b34801561079257600080fd5b50610c895461057b906001600160a01b031681565b3480156107b357600080fd5b506105376107c236600461531a565b6114d9565b3480156107d357600080fd5b506105026107e23660046152bc565b612bda546001600160a01b0390811691161490565b34801561080357600080fd5b506105c861081236600461516c565b6114fe565b34801561082357600080fd5b50610537610832366004615392565b611552565b34801561084357600080fd5b5061053761085236600461512a565b611567565b61086a610865366004615504565b611596565b60405161050e91906155db565b34801561088357600080fd5b5061053761089236600461531a565b611a7c565b3480156108a357600080fd5b50610c8f5461057b906001600160a01b031681565b3480156108c457600080fd5b50610c885461057b906001600160a01b031681565b3480156108e557600080fd5b506105376108f436600461561f565b611aff565b34801561090557600080fd5b50610537610914366004615690565b611cd3565b34801561092557600080fd5b5061053761093436600461516c565b611d21565b34801561094557600080fd5b506105376109543660046152d9565b611d75565b34801561096557600080fd5b5061053761097436600461512a565b611d90565b34801561098557600080fd5b50610537610994366004615690565b611de1565b3480156109a557600080fd5b5061057b6109b436600461512a565b611078602052600090815260409020546001600160a01b031681565b3480156109dc57600080fd5b506105c8610c8d5481565b3480156109f357600080fd5b506105c8610a0236600461512a565b611e36565b348015610a1357600080fd5b50610502610a223660046152bc565b611e5f565b348015610a3357600080fd5b506105c8610a4236600461512a565b600090815261107b602052604090206001015490565b348015610a6457600080fd5b50610537610a73366004615392565b611e79565b348015610a8457600080fd5b50610537610a93366004615690565b611e8e565b348015610aa457600080fd5b50610537610ab33660046152bc565b611eb2565b348015610ac457600080fd5b506105c86127f05481565b348015610adb57600080fd5b5061201e546105c8565b348015610af157600080fd5b50610537610b0036600461512a565b611f09565b348015610b1157600080fd5b5061057b610b2036600461512a565b611f17565b348015610b3157600080fd5b50610502610b403660046152bc565b611f33565b348015610b5157600080fd5b50610537610b603660046156b2565b612021565b348015610b7157600080fd5b506105c8610b803660046152bc565b6121dd565b348015610b9157600080fd5b506105c8610c865481565b348015610ba857600080fd5b50610537610bb7366004615392565b61222f565b348015610bc857600080fd5b50610c8c5461057b906001600160a01b031681565b348015610be957600080fd5b506105c8610bf83660046152bc565b612276565b348015610c0957600080fd5b5061086a610c18366004615737565b6122bc565b348015610c2957600080fd5b50610537610c3836600461531a565b6123fb565b348015610c4957600080fd5b50610537610c5836600461512a565b6125d2565b348015610c6957600080fd5b50610537610c78366004615392565b5050600b610c8d55565b348015610c8e57600080fd5b506105c8600080516020615dce83398151915281565b348015610cb057600080fd5b50612bda546001600160a01b031661057b565b348015610ccf57600080fd5b50610502610cde36600461531a565b612613565b348015610cef57600080fd5b506105c8610cfe36600461512a565b61263e565b348015610d0f57600080fd5b506105c86110775481565b348015610d2657600080fd5b5061054e61272b565b348015610d3b57600080fd5b506104b15461057b906001600160a01b031681565b348015610d5c57600080fd5b506105c8600081565b348015610d7157600080fd5b50610537610d803660046157bf565b612856565b348015610d9157600080fd5b50610537610da036600461531a565b612911565b348015610db157600080fd5b506105c86127f15481565b348015610dc857600080fd5b50610502610dd736600461512a565b600090815261107b6020526040902060010154421090565b348015610dfb57600080fd5b50610502610e0a3660046152bc565b61299f565b348015610e1b57600080fd5b50610537610e2a36600461531a565b6129b9565b348015610e3b57600080fd5b506105c8610e4a366004615690565b612a07565b348015610e5b57600080fd5b50610502610e6a36600461516c565b612a7a565b348015610e7b57600080fd5b50610537610e8a3660046157ed565b612afa565b348015610e9b57600080fd5b50610537610eaa36600461512a565b612b2e565b348015610ebb57600080fd5b506105c8610eca3660046152bc565b6120226020526000908152604090205481565b348015610ee957600080fd5b5061054e610ef836600461512a565b612b60565b348015610f0957600080fd5b50604051600b815260200161050e565b348015610f2557600080fd5b50610537610f343660046152bc565b612df2565b348015610f4557600080fd5b50610537610f5436600461512a565b612e49565b348015610f6557600080fd5b50610c8e546105c8565b348015610f7b57600080fd5b50610537610f8a36600461531a565b612e7b565b610537610f9d366004615858565b612ea0565b348015610fae57600080fd5b50610537610fbd36600461516c565b6130b0565b348015610fce57600080fd5b50610502610fdd3660046158c1565b6130d5565b348015610fee57600080fd5b50610537613104565b34801561100357600080fd5b506105376110123660046158ef565b613149565b34801561102357600080fd5b50610537613305565b34801561103857600080fd5b5061053761104736600461516c565b613315565b34801561105857600080fd5b5061053761106736600461512a565b613443565b34801561107857600080fd5b50610502611087366004615924565b613451565b6000611097826134b3565b92915050565b6110a6836134be565b6110af836134f0565b6110b883613522565b6110c1826134be565b600083815261107b60205260409020600101546110df904290615961565b8111156110ff576040516310e88eed60e31b815260040160405180910390fd5b61110b838260006135da565b611117828260016135da565b505050565b611463805461112a90615978565b80601f016020809104026020016040519081016040528092919081815260200182805461115690615978565b80156111a35780601f10611178576101008083540402835291602001916111a3565b820191906000526020600020905b81548152906001019060200180831161118657829003601f168201915b505050505081565b60006111b6826134be565b50600090815261107960205260409020546001600160a01b031690565b6111dc81613522565b6001600160a01b038216330361120557604051637899146560e11b815260040160405180910390fd5b60008181526110796020908152604080832080546001600160a01b0319166001600160a01b03878116918217909255611076909352818420549151859492909116917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a45050565b610c89546000906001600160a01b03161561130257610c895460405163221c1fd160e01b81526001600160a01b039091169063221c1fd1906112ba9033908890889088906004016159ac565b602060405180830381865afa1580156112d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fb91906159e0565b9050611308565b50610c85545b9392505050565b611317613690565b6001600160a01b03811661133e57604051635963709b60e01b815260040160405180910390fd5b610c8880546001600160a01b0319166001600160a01b0392909216919091179055565b61136b81336136d2565b6113885760405163075fd2b160e01b815260040160405180910390fd5b61139383838361374a565b60009081526110786020526040902080546001600160a01b031916331790555050565b6113be61394d565b6001600160a01b0381166113e5576040516330c6e09f60e21b815260040160405180910390fd5b612bda80546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091015b60405180910390a15050565b611451816134f0565b61145a81613522565b60008181526110786020526040902080546001600160a01b031916905561111783838361374a565b61148a61394d565b6114a2600080516020615d8e83398151915282612e7b565b6040516001600160a01b038216907f766f6199fea59554b9ff688e413302b9200f85d74811c053c12d945ac6d8dd7a90600090a250565b6000828152609760205260409020600101546114f481613982565b611117838361398c565b600061150983612276565b821061152857604051630471175760e11b815260040160405180910390fd5b506001600160a01b0391909116600090815261107c60209081526040808320938352929052205490565b61155a61394d565b6111176114658383614fd0565b61156f61394d565b806000036115905760405163e03b033d60e01b815260040160405180910390fd5b610c8e55565b60606115a0613a12565b610c86548651610c87546115b491906159f9565b11156115d3576040516331af695160e01b815260040160405180910390fd5b845186511415806115e657508351865114155b15611604576040516376b3b52560e11b815260040160405180910390fd5b600080600088516001600160401b0381111561162257611622615198565b60405190808252806020026020018201604052801561164b578160200160208202803683370190505b50905060005b89518110156119715760008a828151811061166e5761166e615a11565b60200260200101519050600019610c8454036116b1576116aa818a848151811061169a5761169a615a11565b6020026020010151600019613a36565b93506116e6565b6116e3818a84815181106116c7576116c7615a11565b6020026020010151610c8454426116de91906159f9565b613a36565b93505b6000611764828c85815181106116fe576116fe615a11565b60200260200101518b8b8781811061171857611718615a11565b905060200281019061172a9190615a27565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061126e92505050565b905061177081876159f9565b600086815261201f60209081526040808320859055610c84546120208352818420556104b15461202190925290912080546001600160a01b0319166001600160a01b03909216919091179055845190965085908590859081106117d5576117d5615a11565b60209081029190910101526104b1546001600160a01b0316158015906118135750808d848151811061180957611809615a11565b6020026020010151105b15611831576040516330005fb160e21b815260040160405180910390fd5b611854818c858151811061184757611847615a11565b6020026020010151613b11565b6104b1546000906001600160a01b031615611888578d848151811061187b5761187b615a11565b602002602001015161188a565b345b610c89549091506001600160a01b03161561195b57610c8960009054906101000a90046001600160a01b03166001600160a01b0316639849965733858f88815181106118d8576118d8615a11565b60200260200101518e8e8a8181106118f2576118f2615a11565b90506020028101906119049190615a27565b88886040518863ffffffff1660e01b81526004016119289796959493929190615a96565b600060405180830381600087803b15801561194257600080fd5b505af1158015611956573d6000803e3d6000fd5b505050505b505050808061196990615ae1565b915050611651565b506104b1546001600160a01b031615611a05576104b1546040516323b872dd60e01b81526001600160a01b039091169081906323b872dd906119bb90339030908990600401615afa565b6020604051808303816000875af11580156119da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119fe9190615b1e565b5050611a26565b82341015611a26576040516306c3cddf60e41b815260040160405180910390fd5b611a2e613c16565b60005b8851811015611a6e57611a5c898281518110611a4f57611a4f615a11565b6020026020010151613d6d565b80611a6681615ae1565b915050611a31565b509998505050505050505050565b6001600160a01b0381163314611af15760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b611afb8282613e06565b5050565b611b0761394d565b6001600160a01b03851615801590611b2e5750611b2c856001600160a01b0316613e6d565b155b15611b4f57604051636788e02b60e01b815260006004820152602401611ae8565b6001600160a01b03841615801590611b765750611b74846001600160a01b0316613e6d565b155b15611b9757604051636788e02b60e01b815260016004820152602401611ae8565b6001600160a01b03831615801590611bbe5750611bbc836001600160a01b0316613e6d565b155b15611bdf57604051636788e02b60e01b815260026004820152602401611ae8565b6001600160a01b03821615801590611c065750611c04826001600160a01b0316613e6d565b155b15611c2757604051636788e02b60e01b815260036004820152602401611ae8565b6001600160a01b03811615801590611c4e5750611c4c816001600160a01b0316613e6d565b155b15611c6e57604051636788e02b60e01b8152600481810152602401611ae8565b610c8980546001600160a01b03199081166001600160a01b0397881617909155610c8a8054821695871695909517909455610c8c8054851692861692909217909155610c8b8054841692851692909217909155610c8f80549092169216919091179055565b611cdb61394d565b60408051838152602081018390527fd6867bc538320e67d7bdc35860c27c08486eb490b4fd9b820fff18fb28381d3c910160405180910390a16127f1919091556127f055565b611d2a816134f0565b600081815261107860205260409020546001600160a01b03163314611d625760405163075fd2b160e01b815260040160405180910390fd5b611afb611d6e82611f17565b838361374a565b61111783838360405180602001604052806000815250612afa565b611d99816134be565b611da281613522565b600081815261107660205260408082205490518392916001600160a01b031690600080516020615dae833981519152908390a4611dde81613e7c565b50565b611de9613a12565b611df2826134be565b611dfb33611e5f565b158015611e0e5750611e0c3361299f565b155b15611e2c57604051631798fedb60e01b815260040160405180910390fd5b6111178282613eb6565b6000610c87548210611e5b57604051630471175760e11b815260040160405180910390fd5b5090565b6000611097600080516020615d8e83398151915283612613565b611e8161394d565b6111176114638383614fd0565b611e97826134be565b611ea0826134f0565b611ea861394d565b611afb8282613f92565b611eba61394d565b611ed2600080516020615d8e833981519152826114d9565b6040516001600160a01b038216907f684f8a71407db0c334454ebe9c9b288549317893a20b10dc779ec5c118dcd12190600090a250565b611f1161394d565b610c8455565b600090815261107660205260409020546001600160a01b031690565b600080611f3f836121dd565b90508015611f825760005b81811015611f8057611f5f610dd785836114fe565b15611f6e575060019392505050565b80611f7881615ae1565b915050611f4a565b505b610c8b546001600160a01b03161561201b57610c8b546040516370b6638f60e11b81523060048201526001600160a01b0385811660248301526000604483015284151560648301529091169063e16cc71e90608401602060405180830381865afa158015611ff4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120189190615b1e565b91505b50919050565b600054610100900460ff16158080156120415750600054600160ff909116105b80612062575061205030613e6d565b158015612062575060005460ff166001145b6120c55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401611ae8565b6000805460ff1916600117905580156120e8576000805461ff0019166101001790555b6120f1866140b0565b610c838054336001600160a01b031991821617909155610c8880549091166001600160a01b038a16179055610c84879055610c85859055610c86849055600b610c8d556001610c8e5561214483836140dc565b61214c614102565b6121586103e86127f055565b61216188614112565b612bda80546001600160a01b0319166001600160a01b038a1617905561218d6380ac58cd60e01b61419a565b80156121d3576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b6000806121e983612276565b905060005b8181101561222857612203610dd785836114fe565b15612216578261221281615ae1565b9350505b8061222081615ae1565b9150506121ee565b5050919050565b61223761394d565b6122446114648383614fd0565b507f8868e22e84ebf32da89b2ebcb0ac642816304ea3863b257f240df9098719cb97828260405161143c929190615b3b565b60006001600160a01b03821661229f57604051635963709b60e01b815260040160405180910390fd5b506001600160a01b0316600090815261107e602052604090205490565b60606122c6613a12565b6122cf33611e5f565b1580156122e257506122e03361299f565b155b1561230057604051631798fedb60e01b815260040160405180910390fd5b6000866001600160401b0381111561231a5761231a615198565b604051908082528060200260200182016040528015612343578160200160208202803683370190505b50905060005b878110156123ef576123c089898381811061236657612366615a11565b905060200201602081019061237b91906152bc565b86868481811061238d5761238d615a11565b90506020020160208101906123a291906152bc565b8989858181106123b4576123b4615a11565b90506020020135613a36565b8282815181106123d2576123d2615a11565b6020908102919091010152806123e781615ae1565b915050612349565b50979650505050505050565b612403613a12565b61240c826134be565b60008281526120206020526040902054600019148061243557506104b1546001600160a01b0316155b1561245357604051636cd40e1160e11b815260040160405180910390fd5b600061247761246184611f17565b836040518060200160405280600081525061126e565b600084815261201f6020526040902054909150811415806124aa5750610c84546000848152612020602052604090205414155b806124d457506104b154600084815261202160205260409020546001600160a01b03908116911614155b156124f25760405163986739e760e01b815260040160405180910390fd5b600083815261107b6020526040902060010154421015612525576040516360d8ec3360e11b815260040160405180910390fd5b612530836000613eb6565b5061253b8183613b11565b6104b1546001600160a01b0316806323b872dd61255786611f17565b30856040518463ffffffff1660e01b815260040161257793929190615afa565b6020604051808303816000875af1158015612596573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ba9190615b1e565b506125c3613c16565b6125cc83613d6d565b50505050565b6125da61394d565b6040518181527f0496ed1e61eb69727f9659a8e859288db4758ffb1f744d1c1424634f90a257f49060200160405180910390a161240755565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000612649826134f0565b600019610c84540361265e575050610c855490565b600082815261107b602052604081206001015461267c904290615961565b9050610c84546127f1548261269191906159f9565b106126a157610c855491506126c1565b610c845481610c85546126b49190615b4f565b6126be9190615b6e565b91505b6127f15415806126e05750610c84546127f1546126de90836159f9565b105b1561201b5760006127106127f054610c85546126fc9190615b4f565b6127069190615b6e565b9050808311156127215761271a8184615961565b9250612228565b5060009392505050565b6060611464805461273b90615978565b90506000036127c557610c8360009054906101000a90046001600160a01b03166001600160a01b031663cec410526040518163ffffffff1660e01b8152600401600060405180830381865afa158015612798573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526127c09190810190615b90565b905090565b61146480546127d390615978565b80601f01602080910402602001604051908101604052809291908181526020018280546127ff90615978565b801561284c5780601f106128215761010080835404028352916020019161284c565b820191906000526020600020905b81548152906001019060200180831161282f57829003601f168201915b5050505050905090565b336001600160a01b0383160361287f57604051637899146560e11b815260040160405180910390fd5b61271061240754106128a4576040516323f21a3d60e21b815260040160405180910390fd5b33600081815261107a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61291961394d565b61292281614219565b610c8580546104b18054928590556001600160a01b031983166001600160a01b0385811691821790925560408051848152602081018890529290941693820184905260608201529091907f3615065ccf48367ac483ac86701248e2e5ff55bdd9be845007d34a3b68d719d49060800160405180910390a150505050565b6000611097600080516020615dce83398151915283612613565b6129c2826134be565b6129cc82336136d2565b1580156129df57506129dd3361299f565b155b156129fd5760405163866c2fa760e01b815260040160405180910390fd5b611afb82826142b0565b6000612a12836134be565b600083815261107b602052604090206001015442811015612a37576000915050611097565b600083600003612a5257612a4b4283615961565b9050612a55565b50825b6127106124075482612a679190615b4f565b612a719190615b6e565b92505050611097565b6000612a84613690565b6104b15460405163095ea7b360e01b81526001600160a01b039091169063095ea7b390612ab79086908690600401615c06565b6020604051808303816000875af1158015612ad6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113089190615b1e565b612b05848484611448565b612b118484848461433d565b6125cc576040516303f8ea1560e41b815260040160405180910390fd5b612b3661394d565b610c8754811015612b5a57604051631d00cd6b60e01b815260040160405180910390fd5b610c8655565b606080806000612b6f306143f4565b905060608515612b8957612b82866145df565b9250612b9c565b6040518060200160405280600081525092505b610c8c546001600160a01b031615612c7357600086815261107b6020526040902060010154610c8c546001600160a01b031663988b93ad3033612bde8b611f17565b60405160e085901b6001600160e01b03191681526001600160a01b03938416600482015291831660248301529091166044820152606481018a90526084810184905260a401600060405180830381865afa158015612c40573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612c689190810190615b90565b979650505050505050565b6114658054612c8190615978565b9050600003612d2957610c8360009054906101000a90046001600160a01b03166001600160a01b031663a998e9fb6040518163ffffffff1660e01b8152600401600060405180830381865afa158015612cde573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612d069190810190615b90565b9350604051806040016040528060018152602001602f60f81b8152509050612ddc565b6114658054612d3790615978565b80601f0160208091040260200160405190810160405280929190818152602001828054612d6390615978565b8015612db05780601f10612d8557610100808354040283529160200191612db0565b820191906000526020600020905b815481529060010190602001808311612d9357829003601f168201915b505050505093506040518060200160405280600081525090506040518060200160405280600081525091505b612de88483838661470f565b9695505050505050565b612dfa61394d565b612e12600080516020615dce833981519152826114d9565b6040516001600160a01b038216907f91d5c045d5bd98bf59a379b259ebca05b93bf79af1845fdf87e3172385d4c7f790600090a250565b612e52816134be565b612e5b816134f0565b612e6481613522565b6000612e6f8261263e565b9050611afb8282613f92565b600082815260976020526040902060010154612e9681613982565b6111178383613e06565b612ea8613a12565b612eb1846134be565b612ebc846000613eb6565b506000612f08612ecb86611f17565b8585858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061126e92505050565b9050612f148185613b11565b6104b1546001600160a01b031615612fc85780861015612f47576040516330005fb160e21b815260040160405180910390fd5b6104b1546040516323b872dd60e01b81526001600160a01b039091169081906323b872dd90612f7e90339030908790600401615afa565b6020604051808303816000875af1158015612f9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc19190615b1e565b5050612fe9565b80341015612fe9576040516306c3cddf60e41b815260040160405180910390fd5b600085815261201f6020526040902054811461301257600085815261201f602052604090208190555b610c8454600086815261202060205260409020541461304057610c8454600086815261202060205260409020555b6104b154600086815261202160205260409020546001600160a01b03908116911614613097576104b15460008681526120216020526040902080546001600160a01b0319166001600160a01b039092169190911790555b61309f613c16565b6130a884613d6d565b505050505050565b6130b861394d565b6001600160a01b0390911660009081526120226020526040902055565b6001600160a01b03918216600090815261107a6020908152604080832093909416825291909152205460ff1690565b61311c600080516020615dce83398151915233611a7c565b60405133907f42885193b8178d25fca25a38e6fcc93918501e91be06d85e0c8afb3bad95238090600090a2565b613151613a12565b610c8754610c865411613177576040516331af695160e01b815260040160405180910390fd5b61318082613522565b613189826134f0565b61271061240754106131ae576040516323f21a3d60e21b815260040160405180910390fd5b600082815261107660205260408120546001600160a01b03169080426131e486600090815261107b602052604090206001015490565b6131ee9190615961565b905060006131fc8686612a07565b9050600061320a82876159f9565b90508281101561322857859350613223878260006135da565b613280565b6132328784612a07565b915061323e8284615961565b600088815261107b6020526040808220426001909101555191955088917f59f2fe866dd27a1c2d34115520888c3150365cbc931aab97fa88c4b9ab40b7959190a25b600061329189826116de88426159f9565b905080896001600160a01b0316876001600160a01b0316600080516020615dae83398151915260405160405180910390a46132dd868a836040518060200160405280600081525061433d565b6132fa576040516303f8ea1560e41b815260040160405180910390fd5b505050505050505050565b61330d61394d565b600b610c8d55565b61331d613690565b60006001600160a01b0383166133345750476133a4565b6040516370a0823160e01b81526001600160a01b038416906370a0823190613360903090600401615143565b602060405180830381865afa15801561337d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133a191906159e0565b90505b60008215806133b257508183115b156133df57600082116133d8576040516303e09bb960e31b815260040160405180910390fd5b50806133e2565b50815b610c88546040518281526001600160a01b039182169186169033907f342e7ff505a8a0364cd0dc2ff195c315e43bce86b204846ecd36913e117b109e9060200160405180910390a4610c88546125cc9085906001600160a01b031683614741565b61344b61394d565b61201e55565b600061345c846134f0565b6000612710834261347d88600090815261107b602052604090206001015490565b6134879190615961565b6134919190615b4f565b61349b9190615b6e565b90506134a8848683613149565b506001949350505050565b60006110978261477d565b600081815261107b60205260408120600101549003611dde576040516378fe247360e01b815260040160405180910390fd5b600081815261107b60205260409020600101544210611dde576040516306cfa7d760e11b815260040160405180910390fd5b600081815261107860205260408120546001600160a01b03161561355e57600082815261107860205260409020546001600160a01b0316613578565b600082815261107660205260409020546001600160a01b03165b905061358482336136d2565b1580156135a95750600082815261107960205260409020546001600160a01b03163314155b80156135bc57506135ba81336130d5565b155b15611afb5760405163e17c6d4560e01b815260040160405180910390fd5b6135e3836134be565b600083815261107b6020526040902060010154811561363057428111156136265761360e83826159f9565b600085815261107b602052604090206001015561364e565b61360e83426159f9565b61363a8382615961565b600085815261107b60205260409020600101555b60408051848152831515602082015285917fe9408df99703ae33a9d01185bcad328ea8683fb1f920da9c30959c192f21b5b3910160405180910390a250505050565b6136993361299f565b1580156136b25750610c88546001600160a01b03163314155b156136d05760405163c8f9577160e01b815260040160405180910390fd5b565b600082815261107860205260408120546001600160a01b03838116911614806137355750816001600160a01b031661370984611f17565b6001600160a01b03161480156137355750600083815261107860205260409020546001600160a01b0316155b1561374257506001611097565b506000611097565b613753816134f0565b826001600160a01b031661376682611f17565b6001600160a01b03161461378d5760405163075fd2b160e01b815260040160405180910390fd5b61271061240754106137b2576040516323f21a3d60e21b815260040160405180910390fd5b6001600160a01b0382166137d957604051635963709b60e01b815260040160405180910390fd5b816001600160a01b0316836001600160a01b03160361380b57604051633fbd1a4960e01b815260040160405180910390fd5b6138218161381a836000612a07565b60006135da565b600081815261107b60205260409020613839836121dd565b60000361385757611077805490600061385183615ae1565b91905055505b61386082614788565b61386a828461488e565b61387382614933565b60008281526120206020908152604080832083905561201f9091528082208290555183916001600160a01b038087169290881691600080516020615dae83398151915291a4610c8f546001600160a01b0316156125cc57610c8f5460018201546040516375b37aef60e01b8152306004820152602481018590523360448201526001600160a01b038781166064830152868116608483015260a48201929092529116906375b37aef9060c401600060405180830381600087803b15801561393957600080fd5b505af11580156121d3573d6000803e3d6000fd5b613965600080516020615dce83398151915233612613565b6136d057604051632386d63160e21b815260040160405180910390fd5b611dde8133614970565b6139968282612613565b611afb5760008281526097602090815260408083206001600160a01b03851684529091529020805460ff191660011790556139ce3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610c8d54600b146136d0576040516302eae03b60e61b815260040160405180910390fd5b60006001600160a01b038416613a5f57604051635963709b60e01b815260040160405180910390fd5b610c878054906000613a7083615ae1565b9091555050610c87546040805180820182528281526020808201868152600085815261107b9092529290209051815590516001909101559050613ab284612276565b600003613ad0576110778054906000613aca83615ae1565b91905055505b613ada818561488e565b613ae481846142b0565b60405181906001600160a01b03861690600090600080516020615dae833981519152908290a49392505050565b610c83546001600160a01b03163b15613bd857610c835460405163939d9f1f60e01b8152600481018490526001600160a01b0383811660248301529091169063939d9f1f90620493e090604401600060405180830381600088803b158015613b7857600080fd5b5087f193505050508015613b8a575060015b611afb57610c835460405130917f6b18946261693dfd6c760d986b28ad2238b5b0267f8e5b6bc40a2f998e2f20ac91613bcc916001600160a01b031690615143565b60405180910390a25050565b610c835460405130917f6b18946261693dfd6c760d986b28ad2238b5b0267f8e5b6bc40a2f998e2f20ac91613bcc916001600160a01b031690615143565b61201e54156136d0576104b1546001600160a01b031615613cb2576104b15461201e5460405163a9059cbb60e01b81526001600160a01b0390921691829163a9059cbb91613c68913391600401615c06565b6020604051808303816000875af1158015613c87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cab9190615b1e565b5050613d1f565b61201e5460405160009133918381818185875af1925050503d8060008114613cf6576040519150601f19603f3d011682016040523d82523d6000602084013e613cfb565b606091505b5050905080613d1d5760405163045ed26b60e11b815260040160405180910390fd5b505b61201e546104b154604080519283526001600160a01b03909116602083015233917f522a883b471164223f18b50f326da8671372b64b4792eac0e63d447e714c3e3b910160405180910390a2565b6120226020527fbed07da93ba22716a54f603f075ff3d6567a94916ac6d58738883fb4a4b47ea6546001600160a01b0382166000908152604090205415613dca57506001600160a01b038116600090815261202260205260409020545b8015611afb576104b154610c8554611afb916001600160a01b031690849061271090613df7908690615b4f565b613e019190615b6e565b614741565b613e108282612613565b15611afb5760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b03163b151590565b613e8581614788565b600090815261107b6020908152604080832042600190910155611076909152902080546001600160a01b0319169055565b600082815261107b60205260408120600190810154908101613eeb57604051630fed19c160e11b815260040160405180910390fd5b60008315613ef95783613efe565b610c84545b90506000198103613f13576000199250613f39565b42821115613f2c57613f2581836159f9565b9250613f39565b613f3681426159f9565b92505b600085815261107b6020526040908190206001018490555185907f3ca112768ff7861e008ace1c11570c52e404c043e585545b5957a1e20961dde390613f829086815260200190565b60405180910390a2505092915050565b6000613f9d83611f17565b9050613fa883613e7c565b336001600160a01b0316816001600160a01b0316847f0a7068a9989857441c039a14a42b67ed71dd1fcfe5a9b17cc87b252e47bce52885604051613fee91815260200190565b60405180910390a48115614014576104b154614014906001600160a01b03168284614741565b60008381526120206020908152604080832083905561201f909152812055610c8a546001600160a01b03161561111757610c8a5460405163b499b6c560e01b81526001600160a01b039091169063b499b6c59061407990339085908790600401615afa565b600060405180830381600087803b15801561409357600080fd5b505af11580156140a7573d6000803e3d6000fd5b50505050505050565b6140b981614219565b6104b180546001600160a01b0319166001600160a01b0392909216919091179055565b6140e46149d4565b6140f16114638383614fd0565b50611afb635b5e139f60e01b61419a565b6136d063780e9d6360e01b61419a565b61412a600080516020615dce83398151915280614a3f565b614150600080516020615d8e833981519152600080516020615dce833981519152614a3f565b6141598161299f565b61417557614175600080516020615dce83398151915282614a8a565b61417e81611e5f565b611dde57611dde600080516020615d8e83398151915282614a8a565b6001600160e01b031980821690036141f45760405162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e74657266616365206964000000006044820152606401611ae8565b6001600160e01b0319166000908152606560205260409020805460ff19166001179055565b6001600160a01b0381161580159061429257506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561426c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061429091906159e0565b105b15611dde5760405163684cae7960e11b815260040160405180910390fd5b600082815261107860205260409020546001600160a01b03828116911614611afb5760008281526110786020526040902080546001600160a01b0319166001600160a01b03831617905561430382614933565b6040516001600160a01b0382169083907f9d2895c45a420624de863a2f437b022d879f457bf7a829044055a10c5a6fd5e390600090a35050565b6000614351846001600160a01b0316613e6d565b61435d575060016143ec565b604051630a85bd0160e11b81526000906001600160a01b0386169063150b7a02906143929033908a9089908990600401615c1f565b6020604051808303816000875af11580156143b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143d59190615c52565b6001600160e01b031916630a85bd0160e11b149150505b949350505050565b604080518082018252601081526f181899199a1a9b1b9c1cb0b131b232b360811b60208201528151602a80825260608281019094526001600160a01b0385169291600091602082018180368337019050509050600360fc1b8160008151811061445f5761445f615a11565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061448e5761448e615a11565b60200101906001600160f81b031916908160001a90535060005b60148110156145d657826004856144c084600c6159f9565b602081106144d0576144d0615a11565b1a60f81b6001600160f81b031916901c60f81c60ff16815181106144f6576144f6615a11565b01602001516001600160f81b03191682614511836002615b4f565b61451c9060026159f9565b8151811061452c5761452c615a11565b60200101906001600160f81b031916908160001a905350828461455083600c6159f9565b6020811061456057614560615a11565b825191901a600f1690811061457757614577615a11565b01602001516001600160f81b03191682614592836002615b4f565b61459d9060036159f9565b815181106145ad576145ad615a11565b60200101906001600160f81b031916908160001a905350806145ce81615ae1565b9150506144a8565b50949350505050565b606081600081900361460a5750506040805180820190915260018152600360fc1b6020820152919050565b8260005b8115614634578061461e81615ae1565b915061462d9050600a83615b6e565b915061460e565b6000816001600160401b0381111561464e5761464e615198565b6040519080825280601f01601f191660200182016040528015614678576020820181803683370190505b509050815b84156147055761468e600182615961565b9050600061469d600a87615b6e565b6146a890600a615b4f565b6146b29087615961565b6146bd906030615c6f565b905060008160f81b9050808484815181106146da576146da615a11565b60200101906001600160f81b031916908160001a9053506146fc600a88615b6e565b9650505061467d565b5095945050505050565b6060848484846040516020016147289493929190615c94565b6040516020818303038152906040529050949350505050565b8015611117576001600160a01b038316614768576111176001600160a01b03831682614a94565b826125cc6001600160a01b0382168484614baa565b600061109782614c00565b600081815261107660205260408120546001600160a01b03169060016147ad836121dd565b6147b79190615961565b600084815261107d602052604090205490915080821461480d576001600160a01b038316600090815261107c60209081526040808320858452825280832054848452818420819055835261107d90915290208190555b6001600160a01b038316600090815261107c6020908152604080832085845290915281205561483b83612276565b60010361485957611077805490600061485383615ceb565b91905055505b6001600160a01b038316600090815261107e60205260408120805460019290614883908490615961565b909155505050505050565b6000614899826121dd565b9050610c8e5481106148be57604051630bf6c32360e11b815260040160405180910390fd5b600083815261107d602090815260408083208490556001600160a01b03851680845261107c83528184208585528352818420879055868452611076835281842080546001600160a01b03191682179055835261107e90915281208054600192906149299084906159f9565b9091555050505050565b600081815261107960205260409020546001600160a01b031615611dde5760009081526110796020526040902080546001600160a01b0319169055565b61497a8282612613565b611afb57614992816001600160a01b03166014614c25565b61499d836020614c25565b6040516020016149ae929190615d02565b60408051601f198184030181529082905262461bcd60e51b8252611ae891600401615117565b600054610100900460ff166136d05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401611ae8565b600082815260976020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b611afb828261398c565b80471015614ae45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401611ae8565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114614b31576040519150601f19603f3d011682016040523d82523d6000602084013e614b36565b606091505b50509050806111175760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b6064820152608401611ae8565b6111178363a9059cbb60e01b8484604051602401614bc9929190615c06565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152614dc0565b60006001600160e01b03198216637965db0b60e01b1480611097575061109782614e92565b60606000614c34836002615b4f565b614c3f9060026159f9565b6001600160401b03811115614c5657614c56615198565b6040519080825280601f01601f191660200182016040528015614c80576020820181803683370190505b509050600360fc1b81600081518110614c9b57614c9b615a11565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110614cca57614cca615a11565b60200101906001600160f81b031916908160001a9053506000614cee846002615b4f565b614cf99060016159f9565b90505b6001811115614d71576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110614d2d57614d2d615a11565b1a60f81b828281518110614d4357614d43615a11565b60200101906001600160f81b031916908160001a90535060049490941c93614d6a81615ceb565b9050614cfc565b5083156113085760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611ae8565b6000614e15826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614ece9092919063ffffffff16565b8051909150156111175780806020019051810190614e339190615b1e565b6111175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611ae8565b60006301ffc9a760e01b6001600160e01b0319831614806110975750506001600160e01b03191660009081526065602052604090205460ff1690565b60606143ec848460008585614ee285613e6d565b614f2e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611ae8565b600080866001600160a01b03168587604051614f4a9190615d71565b60006040518083038185875af1925050503d8060008114614f87576040519150601f19603f3d011682016040523d82523d6000602084013e614f8c565b606091505b5091509150612c6882828660608315614fa6575081611308565b825115614fb65782518084602001fd5b8160405162461bcd60e51b8152600401611ae89190615117565b828054614fdc90615978565b90600052602060002090601f016020900481019282614ffe5760008555615044565b82601f106150175782800160ff19823516178555615044565b82800160010185558215615044579182015b82811115615044578235825591602001919060010190615029565b50611e5b9291505b80821115611e5b576000815560010161504c565b6001600160e01b031981168114611dde57600080fd5b60006020828403121561508857600080fd5b813561130881615060565b6000806000606084860312156150a857600080fd5b505081359360208301359350604090920135919050565b60005b838110156150da5781810151838201526020016150c2565b838111156125cc5750506000910152565b600081518084526151038160208601602086016150bf565b601f01601f19169290920160200192915050565b60208152600061130860208301846150eb565b60006020828403121561513c57600080fd5b5035919050565b6001600160a01b0391909116815260200190565b6001600160a01b0381168114611dde57600080fd5b6000806040838503121561517f57600080fd5b823561518a81615157565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156151d6576151d6615198565b604052919050565b60006001600160401b038211156151f7576151f7615198565b50601f01601f191660200190565b600082601f83011261521657600080fd5b8135615229615224826151de565b6151ae565b81815284602083860101111561523e57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561527057600080fd5b833561527b81615157565b9250602084013561528b81615157565b915060408401356001600160401b038111156152a657600080fd5b6152b286828701615205565b9150509250925092565b6000602082840312156152ce57600080fd5b813561130881615157565b6000806000606084860312156152ee57600080fd5b83356152f981615157565b9250602084013561530981615157565b929592945050506040919091013590565b6000806040838503121561532d57600080fd5b82359150602083013561533f81615157565b809150509250929050565b60008083601f84011261535c57600080fd5b5081356001600160401b0381111561537357600080fd5b60208301915083602082850101111561538b57600080fd5b9250929050565b600080602083850312156153a557600080fd5b82356001600160401b038111156153bb57600080fd5b6153c78582860161534a565b90969095509350505050565b60006001600160401b038211156153ec576153ec615198565b5060051b60200190565b600082601f83011261540757600080fd5b81356020615417615224836153d3565b82815260059290921b8401810191818101908684111561543657600080fd5b8286015b84811015615451578035835291830191830161543a565b509695505050505050565b600082601f83011261546d57600080fd5b8135602061547d615224836153d3565b82815260059290921b8401810191818101908684111561549c57600080fd5b8286015b848110156154515780356154b381615157565b83529183019183016154a0565b60008083601f8401126154d257600080fd5b5081356001600160401b038111156154e957600080fd5b6020830191508360208260051b850101111561538b57600080fd5b60008060008060008060a0878903121561551d57600080fd5b86356001600160401b038082111561553457600080fd5b6155408a838b016153f6565b9750602089013591508082111561555657600080fd5b6155628a838b0161545c565b9650604089013591508082111561557857600080fd5b6155848a838b0161545c565b9550606089013591508082111561559a57600080fd5b6155a68a838b0161545c565b945060808901359150808211156155bc57600080fd5b506155c989828a016154c0565b979a9699509497509295939492505050565b6020808252825182820181905260009190848201906040850190845b81811015615613578351835292840192918401916001016155f7565b50909695505050505050565b600080600080600060a0868803121561563757600080fd5b853561564281615157565b9450602086013561565281615157565b9350604086013561566281615157565b9250606086013561567281615157565b9150608086013561568281615157565b809150509295509295909350565b600080604083850312156156a357600080fd5b50508035926020909101359150565b600080600080600080600060c0888a0312156156cd57600080fd5b87356156d881615157565b96506020880135955060408801356156ef81615157565b9450606088013593506080880135925060a08801356001600160401b0381111561571857600080fd5b6157248a828b0161534a565b989b979a50959850939692959293505050565b6000806000806000806060878903121561575057600080fd5b86356001600160401b038082111561576757600080fd5b6157738a838b016154c0565b9098509650602089013591508082111561578c57600080fd5b6157988a838b016154c0565b909650945060408901359150808211156155bc57600080fd5b8015158114611dde57600080fd5b600080604083850312156157d257600080fd5b82356157dd81615157565b9150602083013561533f816157b1565b6000806000806080858703121561580357600080fd5b843561580e81615157565b9350602085013561581e81615157565b92506040850135915060608501356001600160401b0381111561584057600080fd5b61584c87828801615205565b91505092959194509250565b60008060008060006080868803121561587057600080fd5b8535945060208601359350604086013561588981615157565b925060608601356001600160401b038111156158a457600080fd5b6158b08882890161534a565b969995985093965092949392505050565b600080604083850312156158d457600080fd5b82356158df81615157565b9150602083013561533f81615157565b60008060006060848603121561590457600080fd5b833561590f81615157565b95602085013595506040909401359392505050565b60008060006060848603121561593957600080fd5b83359250602084013561530981615157565b634e487b7160e01b600052601160045260246000fd5b6000828210156159735761597361594b565b500390565b600181811c9082168061598c57607f821691505b60208210810361201b57634e487b7160e01b600052602260045260246000fd5b6001600160a01b038581168252848116602083015283166040820152608060608201819052600090612de8908301846150eb565b6000602082840312156159f257600080fd5b5051919050565b60008219821115615a0c57615a0c61594b565b500190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112615a3e57600080fd5b8301803591506001600160401b03821115615a5857600080fd5b60200191503681900382131561538b57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b03888116825287811660208301528616604082015260c060608201819052600090615acb9083018688615a6d565b60808301949094525060a0015295945050505050565b600060018201615af357615af361594b565b5060010190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b600060208284031215615b3057600080fd5b8151611308816157b1565b6020815260006143ec602083018486615a6d565b6000816000190483118215151615615b6957615b6961594b565b500290565b600082615b8b57634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215615ba257600080fd5b81516001600160401b03811115615bb857600080fd5b8201601f81018413615bc957600080fd5b8051615bd7615224826151de565b818152856020838501011115615bec57600080fd5b615bfd8260208301602086016150bf565b95945050505050565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612de8908301846150eb565b600060208284031215615c6457600080fd5b815161130881615060565b600060ff821660ff84168060ff03821115615c8c57615c8c61594b565b019392505050565b60008551615ca6818460208a016150bf565b855190830190615cba818360208a016150bf565b8551910190615ccd8183602089016150bf565b8451910190615ce08183602088016150bf565b019695505050505050565b600081615cfa57615cfa61594b565b506000190190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351615d348160178501602088016150bf565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615d658160288401602088016150bf565b01602801949350505050565b60008251615d838184602087016150bf565b919091019291505056feb309c40027c81d382c3b58d8de24207a34b27e1db369b1434e4a11311f154b5eddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efb89cdd26cddd51301940bf2715f765b626b8a5a9e2681ac62dc83cc2db2530c0a26469706673582212208dad5b7a364207d18f4ee6cef163f158be06a05e0e1129716ed1bbcd5f4e206764736f6c634300080d0033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.