Transactions
Token Transfers
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Write Contract
- Contract name:
- PKPNFT
- Optimization enabled
- false
- Compiler version
- v0.8.17+commit.8df45f5f
- Verified at
- 2023-04-27T22:50:15.030821Z
contracts/lit-node/PKPNFT.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import { PubkeyRouter } from "./PubkeyRouter.sol"; import { PKPPermissions } from "./PKPPermissions.sol"; import { PKPNFTMetadata } from "./PKPNFTMetadata.sol"; import { ERC721Burnable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import { ERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import { IERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "hardhat/console.sol"; // TODO: tests for the mintGrantAndBurn function, withdraw function, some of the setters, transfer function, freeMint and freeMintGrantAndBurn /// @title Programmable Keypair NFT /// /// @dev This is the contract for the PKP NFTs /// /// Simply put, whomever owns a PKP NFT can ask that PKP to sign a message. /// The owner can also grant signing permissions to other eth addresses /// or lit actions contract PKPNFT is ERC721("Programmable Keypair", "PKP"), Ownable, ERC721Burnable, ERC721Enumerable, ReentrancyGuard { /* ========== STATE VARIABLES ========== */ PubkeyRouter public router; PKPPermissions public pkpPermissions; PKPNFTMetadata public pkpNftMetadata; uint256 public mintCost; address public freeMintSigner; // maps keytype to array of unminted routed token ids mapping(uint256 => uint256[]) public unmintedRoutedTokenIds; mapping(uint256 => bool) public redeemedFreeMintIds; /* ========== CONSTRUCTOR ========== */ constructor() { mintCost = 1; // 1 wei aka 0.000000000000000001 eth freeMintSigner = msg.sender; } /* ========== VIEWS ========== */ /// get the eth address for the keypair, as long as it's an ecdsa keypair function getEthAddress(uint256 tokenId) public view returns (address) { return router.getEthAddress(tokenId); } /// includes the 0x04 prefix so you can pass this directly to ethers.utils.computeAddress function getPubkey(uint256 tokenId) public view returns (bytes memory) { return router.getPubkey(tokenId); } /// throws if the sig is bad or msg doesn't match function freeMintSigTest( uint256 freeMintId, bytes32 msgHash, uint8 v, bytes32 r, bytes32 s ) public view { bytes32 expectedHash = prefixed( keccak256(abi.encodePacked(address(this), freeMintId)) ); require( expectedHash == msgHash, "The msgHash is not a hash of the tokenId. Explain yourself!" ); // make sure it was actually signed by freeMintSigner address recovered = ecrecover(msgHash, v, r, s); require( recovered == freeMintSigner, "This freeMint was not signed by freeMintSigner. How embarassing." ); // prevent reuse require( redeemedFreeMintIds[freeMintId] == false, "This free mint ID has already been redeemed" ); } function supportsInterface( bytes4 interfaceId ) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721).interfaceId; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable) { ERC721Enumerable._beforeTokenTransfer(from, to, tokenId); } function tokenURI( uint256 tokenId ) public view override returns (string memory) { console.log("getting token uri"); bytes memory pubKey = router.getPubkey(tokenId); console.log("got pubkey, getting eth address"); address ethAddress = router.getEthAddress(tokenId); console.log("calling tokenURI"); return pkpNftMetadata.tokenURI(tokenId, pubKey, ethAddress); } function getUnmintedRoutedTokenIdCount( uint256 keyType ) public view returns (uint256) { return unmintedRoutedTokenIds[keyType].length; } // Builds a prefixed hash to mimic the behavior of eth_sign. function prefixed(bytes32 hash) public pure returns (bytes32) { return keccak256( abi.encodePacked("\x19Ethereum Signed Message:\n32", hash) ); } function exists(uint256 tokenId) public view returns (bool) { return _exists(tokenId); } /* ========== MUTATIVE FUNCTIONS ========== */ function mintNext(uint256 keyType) public payable returns (uint256) { require(msg.value == mintCost, "You must pay exactly mint cost"); uint256 tokenId = _getNextTokenIdToMint(keyType); _mintWithoutValueCheck(tokenId, msg.sender); return tokenId; } function mintGrantAndBurnNext( uint256 keyType, bytes memory ipfsCID ) public payable returns (uint256) { require(msg.value == mintCost, "You must pay exactly mint cost"); uint256 tokenId = _getNextTokenIdToMint(keyType); _mintWithoutValueCheck(tokenId, address(this)); pkpPermissions.addPermittedAction(tokenId, ipfsCID, new uint256[](0)); _burn(tokenId); return tokenId; } function freeMintNext( uint256 keyType, uint256 freeMintId, bytes32 msgHash, uint8 v, bytes32 r, bytes32 s ) public returns (uint256) { uint256 tokenId = _getNextTokenIdToMint(keyType); freeMint(freeMintId, tokenId, msgHash, v, r, s); return tokenId; } function freeMintGrantAndBurnNext( uint256 keyType, uint256 freeMintId, bytes memory ipfsCID, bytes32 msgHash, uint8 v, bytes32 r, bytes32 s ) public returns (uint256) { uint256 tokenId = _getNextTokenIdToMint(keyType); freeMintGrantAndBurn(freeMintId, tokenId, ipfsCID, msgHash, v, r, s); return tokenId; } /// create a valid token for a given public key. function mintSpecific(uint256 tokenId) public onlyOwner { _mintWithoutValueCheck(tokenId, msg.sender); } /// mint a PKP, grant access to a Lit Action, and then burn the PKP /// this happens in a single txn, so it's provable that only that lit action /// has ever had access to use the PKP. /// this is useful in the context of something like a "prime number certification lit action" /// where you could just trust the sig that a number is prime. /// without this function, a user could mint a PKP, sign a bunch of junk, and then burn the /// PKP to make it looks like only the Lit Action can use it. function mintGrantAndBurnSpecific( uint256 tokenId, bytes memory ipfsCID ) public onlyOwner { _mintWithoutValueCheck(tokenId, address(this)); pkpPermissions.addPermittedAction(tokenId, ipfsCID, new uint256[](0)); _burn(tokenId); } function freeMint( uint256 freeMintId, uint256 tokenId, bytes32 msgHash, uint8 v, bytes32 r, bytes32 s ) internal { // this will panic if the sig is bad freeMintSigTest(freeMintId, msgHash, v, r, s); _mintWithoutValueCheck(tokenId, msg.sender); redeemedFreeMintIds[freeMintId] = true; } function freeMintGrantAndBurn( uint256 freeMintId, uint256 tokenId, bytes memory ipfsCID, bytes32 msgHash, uint8 v, bytes32 r, bytes32 s ) internal { // this will panic if the sig is bad freeMintSigTest(freeMintId, msgHash, v, r, s); _mintWithoutValueCheck(tokenId, address(this)); redeemedFreeMintIds[freeMintId] = true; pkpPermissions.addPermittedAction(tokenId, ipfsCID, new uint256[](0)); _burn(tokenId); } function _mintWithoutValueCheck(uint256 tokenId, address to) internal { require(router.isRouted(tokenId), "This PKP has not been routed yet"); if (to == address(this)) { // permit unsafe transfer only to this contract, because it's going to be burned _mint(to, tokenId); } else { _safeMint(to, tokenId); } emit PKPMinted(tokenId, getPubkey(tokenId)); } /// Take a tokenId off the stack function _getNextTokenIdToMint(uint256 keyType) internal returns (uint256) { require( unmintedRoutedTokenIds[keyType].length > 0, "There are no unminted routed token ids to mint" ); uint256 tokenId = unmintedRoutedTokenIds[keyType][ unmintedRoutedTokenIds[keyType].length - 1 ]; unmintedRoutedTokenIds[keyType].pop(); return tokenId; } function setRouterAddress(address routerAddress) public onlyOwner { router = PubkeyRouter(routerAddress); emit RouterAddressSet(routerAddress); } function setPkpNftMetadataAddress( address pkpNftMetadataAddress ) public onlyOwner { pkpNftMetadata = PKPNFTMetadata(pkpNftMetadataAddress); emit PkpNftMetadataAddressSet(pkpNftMetadataAddress); } function setPkpPermissionsAddress( address pkpPermissionsAddress ) public onlyOwner { pkpPermissions = PKPPermissions(pkpPermissionsAddress); emit PkpPermissionsAddressSet(pkpPermissionsAddress); } function setMintCost(uint256 newMintCost) public onlyOwner { mintCost = newMintCost; emit MintCostSet(newMintCost); } function setFreeMintSigner(address newFreeMintSigner) public onlyOwner { freeMintSigner = newFreeMintSigner; emit FreeMintSignerSet(newFreeMintSigner); } function withdraw() public onlyOwner nonReentrant { uint256 withdrawAmount = address(this).balance; (bool sent, ) = payable(msg.sender).call{ value: withdrawAmount }(""); require(sent); emit Withdrew(withdrawAmount); } /// Push a tokenId onto the stack function pkpRouted(uint256 tokenId, uint256 keyType) public { require( msg.sender == address(router), "Only the routing contract can call this function" ); unmintedRoutedTokenIds[keyType].push(tokenId); emit PkpRouted(tokenId, keyType); } /* ========== EVENTS ========== */ event RouterAddressSet(address indexed routerAddress); event PkpNftMetadataAddressSet(address indexed pkpNftMetadataAddress); event PkpPermissionsAddressSet(address indexed pkpPermissionsAddress); event MintCostSet(uint256 newMintCost); event FreeMintSignerSet(address indexed newFreeMintSigner); event Withdrew(uint256 amount); event PkpRouted(uint256 indexed tokenId, uint256 indexed keyType); event PKPMinted(uint256 indexed tokenId, bytes pubkey); }
@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
contracts/lit-node/PKPPermissions.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { BitMaps } from "@openzeppelin/contracts/utils/structs/BitMaps.sol"; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import { PKPNFT } from "./PKPNFT.sol"; import "solidity-bytes-utils/contracts/BytesLib.sol"; import "hardhat/console.sol"; contract PKPPermissions is Ownable { using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.Bytes32Set; using EnumerableSet for EnumerableSet.UintSet; using BytesLib for bytes; using BitMaps for BitMaps.BitMap; /* ========== STATE VARIABLES ========== */ PKPNFT public pkpNFT; enum AuthMethodType { NULLMETHOD, // 0 ADDRESS, // 1 ACTION, // 2 WEBAUTHN, // 3 DISCORD, // 4 GOOGLE, // 5 GOOGLE_JWT // 6 } struct AuthMethod { uint256 authMethodType; // 1 = address, 2 = action, 3 = WebAuthn, 4 = Discord, 5 = Google, 6 = Google JWT. Not doing this in an enum so that we can add more auth methods in the future without redeploying. bytes id; // the id of the auth method. For address, this is an eth address. For action, this is an IPFS CID. For WebAuthn, this is the credentialId. For Discord, this is the user's Discord ID. For Google, this is the user's Google ID. bytes userPubkey; // the user's pubkey. This is used for WebAuthn. } // map the keccack256(uncompressed pubkey) -> set of auth methods mapping(uint256 => EnumerableSet.UintSet) permittedAuthMethods; // map the keccack256(uncompressed pubkey) -> auth_method_id -> scope id mapping(uint256 => mapping(uint256 => BitMaps.BitMap)) permittedAuthMethodScopes; // map the keccack256(authMethodType, userId) -> the actual AuthMethod struct mapping(uint256 => AuthMethod) public authMethods; // map the AuthMethod hash to the pubkeys that it's allowed to sign for // this makes it possible to be given a discord id and then lookup all the pubkeys that are allowed to sign for that discord id mapping(uint256 => EnumerableSet.UintSet) authMethodToPkpIds; // map the keccack256(uncompressed pubkey) -> (group => merkle tree root hash) mapping(uint256 => mapping(uint256 => bytes32)) private _rootHashes; /* ========== CONSTRUCTOR ========== */ constructor(address _pkpNft) { pkpNFT = PKPNFT(_pkpNft); } /* ========== Modifier ========== */ modifier onlyPKPOwner(uint256 tokenId) { // check that user is allowed to set this address nftOwner = pkpNFT.ownerOf(tokenId); require(msg.sender == nftOwner, "Not PKP NFT owner"); _; } /* ========== VIEWS ========== */ /// get the eth address for the keypair, as long as it's an ecdsa keypair function getEthAddress(uint256 tokenId) public view returns (address) { return pkpNFT.getEthAddress(tokenId); } /// includes the 0x04 prefix so you can pass this directly to ethers.utils.computeAddress function getPubkey(uint256 tokenId) public view returns (bytes memory) { return pkpNFT.getPubkey(tokenId); } function getAuthMethodId( uint256 authMethodType, bytes memory id ) public pure returns (uint256) { return uint256(keccak256(abi.encode(authMethodType, id))); } /// get the user's pubkey given their authMethodType and userId function getUserPubkeyForAuthMethod( uint256 authMethodType, bytes calldata id ) external view returns (bytes memory) { uint256 authMethodId = getAuthMethodId(authMethodType, id); AuthMethod memory am = authMethods[authMethodId]; return am.userPubkey; } function getTokenIdsForAuthMethod( uint256 authMethodType, bytes calldata id ) external view returns (uint256[] memory) { uint256 authMethodId = getAuthMethodId(authMethodType, id); uint256 pkpIdsLength = authMethodToPkpIds[authMethodId].length(); uint256[] memory allPkpIds = new uint256[](pkpIdsLength); for (uint256 i = 0; i < pkpIdsLength; i++) { allPkpIds[i] = authMethodToPkpIds[authMethodId].at(i); } return allPkpIds; } function getPermittedAuthMethods( uint256 tokenId ) external view returns (AuthMethod[] memory) { uint256 permittedAuthMethodsLength = permittedAuthMethods[tokenId] .length(); AuthMethod[] memory allPermittedAuthMethods = new AuthMethod[]( permittedAuthMethodsLength ); for (uint256 i = 0; i < permittedAuthMethodsLength; i++) { uint256 authMethodHash = permittedAuthMethods[tokenId].at(i); allPermittedAuthMethods[i] = authMethods[authMethodHash]; } return allPermittedAuthMethods; } function getPermittedAuthMethodScopes( uint256 tokenId, uint256 authMethodType, bytes calldata id, uint256 maxScopeId ) public view returns (bool[] memory) { uint256 authMethodId = getAuthMethodId(authMethodType, id); BitMaps.BitMap storage permittedScopesBitMap = permittedAuthMethodScopes[tokenId][ authMethodId ]; bool[] memory allScopes = new bool[](maxScopeId); for (uint256 i = 0; i < maxScopeId; i++) { allScopes[i] = permittedScopesBitMap.get(i); } return allScopes; } function getPermittedActions( uint256 tokenId ) public view returns (bytes[] memory) { uint256 permittedAuthMethodsLength = permittedAuthMethods[tokenId] .length(); // count the number of auth methods that are actions uint256 permittedActionsLength = 0; for (uint256 i = 0; i < permittedAuthMethodsLength; i++) { uint256 authMethodHash = permittedAuthMethods[tokenId].at(i); AuthMethod memory am = authMethods[authMethodHash]; if (am.authMethodType == uint256(AuthMethodType.ACTION)) { permittedActionsLength++; } } bytes[] memory allPermittedActions = new bytes[]( permittedActionsLength ); uint256 permittedActionsIndex = 0; for (uint256 i = 0; i < permittedAuthMethodsLength; i++) { uint256 authMethodHash = permittedAuthMethods[tokenId].at(i); AuthMethod memory am = authMethods[authMethodHash]; if (am.authMethodType == uint256(AuthMethodType.ACTION)) { allPermittedActions[permittedActionsIndex] = am.id; permittedActionsIndex++; } } return allPermittedActions; } function getPermittedAddresses( uint256 tokenId ) public view returns (address[] memory) { uint256 permittedAuthMethodsLength = permittedAuthMethods[tokenId] .length(); // count the number of auth methods that are addresses uint256 permittedAddressLength = 0; for (uint256 i = 0; i < permittedAuthMethodsLength; i++) { uint256 authMethodHash = permittedAuthMethods[tokenId].at(i); AuthMethod memory am = authMethods[authMethodHash]; if (am.authMethodType == uint256(AuthMethodType.ADDRESS)) { permittedAddressLength++; } } bool tokenExists = pkpNFT.exists(tokenId); address[] memory allPermittedAddresses; uint256 permittedAddressIndex = 0; if (tokenExists) { // token is not burned, so add the owner address allPermittedAddresses = new address[](permittedAddressLength + 1); // always add nft owner in first slot address nftOwner = pkpNFT.ownerOf(tokenId); allPermittedAddresses[0] = nftOwner; permittedAddressIndex++; } else { // token is burned, so don't add the owner address allPermittedAddresses = new address[](permittedAddressLength); } for (uint256 i = 0; i < permittedAuthMethodsLength; i++) { uint256 authMethodHash = permittedAuthMethods[tokenId].at(i); AuthMethod memory am = authMethods[authMethodHash]; if (am.authMethodType == uint256(AuthMethodType.ADDRESS)) { address parsed; bytes memory id = am.id; // address was packed using abi.encodedPacked(address), so you need to pad left to get the correct bytes back assembly { parsed := div( mload(add(id, 32)), 0x1000000000000000000000000 ) } allPermittedAddresses[permittedAddressIndex] = parsed; permittedAddressIndex++; } } return allPermittedAddresses; } /// get if a user is permitted to use a given pubkey. returns true if it is permitted to use the pubkey in the permittedAuthMethods[tokenId] struct. function isPermittedAuthMethod( uint256 tokenId, uint256 authMethodType, bytes memory id ) public view returns (bool) { uint256 authMethodId = getAuthMethodId(authMethodType, id); bool permitted = permittedAuthMethods[tokenId].contains(authMethodId); if (!permitted) { return false; } return true; } function isPermittedAuthMethodScopePresent( uint256 tokenId, uint256 authMethodType, bytes calldata id, uint256 scopeId ) public view returns (bool) { uint256 authMethodId = getAuthMethodId(authMethodType, id); bool present = permittedAuthMethodScopes[tokenId][authMethodId].get( scopeId ); return present; } function isPermittedAction( uint256 tokenId, bytes calldata ipfsCID ) public view returns (bool) { return isPermittedAuthMethod( tokenId, uint256(AuthMethodType.ACTION), ipfsCID ); } function isPermittedAddress( uint256 tokenId, address user ) public view returns (bool) { return isPermittedAuthMethod( tokenId, uint256(AuthMethodType.ADDRESS), abi.encodePacked(user) ) || pkpNFT.ownerOf(tokenId) == user; } /* ========== MUTATIVE FUNCTIONS ========== */ /// Add a permitted auth method for a given pubkey function addPermittedAuthMethod( uint256 tokenId, AuthMethod memory authMethod, uint256[] calldata scopes ) public onlyPKPOwner(tokenId) { uint256 authMethodId = getAuthMethodId( authMethod.authMethodType, authMethod.id ); // we need to ensure that someone with the same auth method type and id can't add a different pubkey require( authMethods[authMethodId].userPubkey.length == 0 || keccak256(authMethods[authMethodId].userPubkey) == keccak256(authMethod.userPubkey), "Cannot add a different pubkey for the same auth method type and id" ); authMethods[authMethodId] = authMethod; EnumerableSet.UintSet storage newPermittedAuthMethods = permittedAuthMethods[tokenId]; newPermittedAuthMethods.add(authMethodId); EnumerableSet.UintSet storage newPkpIds = authMethodToPkpIds[ authMethodId ]; newPkpIds.add(tokenId); for (uint256 i = 0; i < scopes.length; i++) { uint256 scopeId = scopes[i]; permittedAuthMethodScopes[tokenId][authMethodId].set(scopeId); emit PermittedAuthMethodScopeAdded( tokenId, authMethodId, authMethod.id, scopeId ); } emit PermittedAuthMethodAdded( tokenId, authMethod.authMethodType, authMethod.id, authMethod.userPubkey ); } // Remove a permitted auth method for a given pubkey function removePermittedAuthMethod( uint256 tokenId, uint256 authMethodType, bytes memory id ) public onlyPKPOwner(tokenId) { uint256 authMethodId = getAuthMethodId(authMethodType, id); EnumerableSet.UintSet storage newPermittedAuthMethods = permittedAuthMethods[tokenId]; newPermittedAuthMethods.remove(authMethodId); EnumerableSet.UintSet storage newPkpIds = authMethodToPkpIds[ authMethodId ]; newPkpIds.remove(tokenId); emit PermittedAuthMethodRemoved(tokenId, authMethodId, id); } function addPermittedAuthMethodScope( uint256 tokenId, uint256 authMethodType, bytes calldata id, uint256 scopeId ) public onlyPKPOwner(tokenId) { uint256 authMethodId = getAuthMethodId(authMethodType, id); permittedAuthMethodScopes[tokenId][authMethodId].set(scopeId); emit PermittedAuthMethodScopeAdded(tokenId, authMethodId, id, scopeId); } function removePermittedAuthMethodScope( uint256 tokenId, uint256 authMethodType, bytes calldata id, uint256 scopeId ) public onlyPKPOwner(tokenId) { uint256 authMethodId = getAuthMethodId(authMethodType, id); permittedAuthMethodScopes[tokenId][authMethodId].unset(scopeId); emit PermittedAuthMethodScopeRemoved( tokenId, authMethodType, id, scopeId ); } /// Add a permitted action for a given pubkey function addPermittedAction( uint256 tokenId, bytes calldata ipfsCID, uint256[] calldata scopes ) public { addPermittedAuthMethod( tokenId, AuthMethod(uint256(AuthMethodType.ACTION), ipfsCID, ""), scopes ); } function removePermittedAction( uint256 tokenId, bytes calldata ipfsCID ) public { removePermittedAuthMethod( tokenId, uint256(AuthMethodType.ACTION), ipfsCID ); } function addPermittedAddress( uint256 tokenId, address user, uint256[] calldata scopes ) public { addPermittedAuthMethod( tokenId, AuthMethod( uint256(AuthMethodType.ADDRESS), abi.encodePacked(user), "" ), scopes ); } function removePermittedAddress(uint256 tokenId, address user) public { removePermittedAuthMethod( tokenId, uint256(AuthMethodType.ADDRESS), abi.encodePacked(user) ); } function setPkpNftAddress(address newPkpNftAddress) public onlyOwner { pkpNFT = PKPNFT(newPkpNftAddress); } /** * Update the root hash of the merkle tree representing off-chain states for the PKP */ function setRootHash( uint256 tokenId, uint256 group, bytes32 root ) public onlyPKPOwner(tokenId) { _rootHashes[tokenId][group] = root; emit RootHashUpdated(tokenId, group, root); } /** * Verify the given leaf existing in the merkle tree */ function verifyState( uint256 tokenId, uint256 group, bytes32[] memory proof, bytes32 leaf ) public view returns (bool) { bytes32 root = _rootHashes[tokenId][group]; if (root == bytes32(0)) return false; return MerkleProof.verify(proof, root, leaf); } /** * Verify the given leaves existing in the merkle tree */ function verifyStates( uint256 tokenId, uint256 group, bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) public view returns (bool) { bytes32 root = _rootHashes[tokenId][group]; if (root == bytes32(0)) return false; return MerkleProof.multiProofVerify(proof, proofFlags, root, leaves); } /* ========== EVENTS ========== */ event PermittedAuthMethodAdded( uint256 indexed tokenId, uint256 authMethodType, bytes id, bytes userPubkey ); event PermittedAuthMethodRemoved( uint256 indexed tokenId, uint256 authMethodType, bytes id ); event PermittedAuthMethodScopeAdded( uint256 indexed tokenId, uint256 authMethodType, bytes id, uint256 scopeId ); event PermittedAuthMethodScopeRemoved( uint256 indexed tokenId, uint256 authMethodType, bytes id, uint256 scopeId ); event RootHashUpdated( uint256 indexed tokenId, uint256 indexed group, bytes32 root ); }
@openzeppelin/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.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 AccessControl is Context, IAccessControl, ERC165 { 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(IAccessControl).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 ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.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()); } } }
@openzeppelin/contracts/utils/cryptography/ECDSA.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { 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); } }
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
solidity-bytes-utils/contracts/BytesLib.sol
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat( bytes memory _preBytes, bytes memory _postBytes ) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. )) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and( fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 ), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage( bytes storage _preBytes, bytes memory _postBytes ) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
@openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// 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 IERC721Receiver { /** * @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); }
@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../utils/Context.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { _spendAllowance(account, _msgSender(), amount); _burn(account, amount); } }
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
@openzeppelin/contracts/utils/cryptography/MerkleProof.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata( bytes32[] calldata proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`, * consuming from one or the other at each step according to the instructions given by * `proofFlags`. * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof} * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
contracts/lit-node/PKPNFTMetadata.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { Base64 } from "@openzeppelin/contracts/utils/Base64.sol"; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; import "hardhat/console.sol"; /// @title Programmable Keypair NFT Metadata /// /// @dev This is the contract for the PKP NFTs /// /// Simply put, whomever owns a PKP NFT can ask that PKP to sign a message. /// The owner can also grant signing permissions to other eth addresses /// or lit actions contract PKPNFTMetadata { using Strings for uint256; /* ========== STATE VARIABLES ========== */ /* ========== CONSTRUCTOR ========== */ constructor() {} /* ========== VIEWS ========== */ function bytesToHex( bytes memory buffer ) public pure returns (string memory) { // Fixed buffer size for hexadecimal convertion bytes memory converted = new bytes(buffer.length * 2); bytes memory _base = "0123456789abcdef"; for (uint256 i = 0; i < buffer.length; i++) { converted[i * 2] = _base[uint8(buffer[i]) / _base.length]; converted[i * 2 + 1] = _base[uint8(buffer[i]) % _base.length]; } return string(abi.encodePacked("0x", converted)); } function tokenURI( uint256 tokenId, bytes memory pubKey, address ethAddress ) public pure returns (string memory) { string memory svgData = "<svg xmlns='http://www.w3.org/2000/svg' width='1080' height='1080' fill='none' xmlns:v='https://vecta.io/nano'><path d='M363.076 392.227s-.977 18.524-36.874 78.947c-41.576 70.018-45.481 151.978-3.017 220.4 89.521 144.245 332.481 141.52 422.556.089 34.832-54.707 44.816-117.479 32.924-181.248 0 0-28.819-133.144-127.237-217.099 1.553 1.308 5.369 19.122 6.101 26.722 2.241 23.354.045 47.838-7.787 70.062-5.746 16.33-13.711 30.467-27.178 41.368 0-3.811-.954-10.635-.976-12.918-.644-46.508-18.659-89.582-48.011-125.743-25.647-31.552-60.812-53.089-97.84-68.932.931 3.191 2.662 16.419 2.906 19.033 1.908 21.958 2.263 52.713-.621 74.649s-7.832 33.878-14.554 54.441c-10.184 31.175-24.05 54.285-41.621 82.004-3.24 5.096-12.913 19.078-18.082 26.146 0 0-8.897-56.191-40.667-87.921h-.022z' fill='#000'/><path d='M562.5 27.28l410.279 236.874c13.923 8.039 22.5 22.895 22.5 38.971v473.75c0 16.076-8.577 30.932-22.5 38.971L562.5 1052.72c-13.923 8.04-31.077 8.04-45 0L107.221 815.846c-13.923-8.039-22.5-22.895-22.5-38.971v-473.75a45 45 0 0 1 22.5-38.971L517.5 27.28a45 45 0 0 1 45 0z' stroke='#000' stroke-width='24.75'/></svg>"; string memory pubkeyStr = bytesToHex(pubKey); // console.log("pubkeyStr"); // console.log(pubkeyStr); string memory ethAddressStr = Strings.toHexString(ethAddress); // console.log("ethAddressStr"); // console.log(ethAddressStr); string memory tokenIdStr = Strings.toString(tokenId); string memory json = Base64.encode( bytes( string( abi.encodePacked( '{"name": "Lit PKP #', tokenIdStr, '", "description": "This NFT entitles the holder to use a Lit Protocol PKP, and to grant access to other users and Lit Actions to use this PKP", "image_data": "', bytes(svgData), '","attributes": [{"trait_type": "Public Key", "value": "', pubkeyStr, '"}, {"trait_type": "ETH Wallet Address", "value": "', ethAddressStr, '"}, {"trait_type": "Token ID", "value": "', tokenIdStr, '"}]}' ) ) ) ); return string(abi.encodePacked("data:application/json;base64,", json)); } }
@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
@openzeppelin/contracts/token/ERC721/ERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
hardhat/console.sol
// SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int256 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int256)", p0)); } function logUint(uint256 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint256 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint256 p0, uint256 p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256)", p0, p1)); } function log(uint256 p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string)", p0, p1)); } function log(uint256 p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool)", p0, p1)); } function log(uint256 p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address)", p0, p1)); } function log(string memory p0, uint256 p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint256 p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint256 p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint256 p0, uint256 p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256)", p0, p1, p2)); } function log(uint256 p0, uint256 p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string)", p0, p1, p2)); } function log(uint256 p0, uint256 p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool)", p0, p1, p2)); } function log(uint256 p0, uint256 p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address)", p0, p1, p2)); } function log(uint256 p0, string memory p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256)", p0, p1, p2)); } function log(uint256 p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string)", p0, p1, p2)); } function log(uint256 p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool)", p0, p1, p2)); } function log(uint256 p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address)", p0, p1, p2)); } function log(uint256 p0, bool p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256)", p0, p1, p2)); } function log(uint256 p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string)", p0, p1, p2)); } function log(uint256 p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool)", p0, p1, p2)); } function log(uint256 p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address)", p0, p1, p2)); } function log(uint256 p0, address p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256)", p0, p1, p2)); } function log(uint256 p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string)", p0, p1, p2)); } function log(uint256 p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool)", p0, p1, p2)); } function log(uint256 p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address)", p0, p1, p2)); } function log(string memory p0, uint256 p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256)", p0, p1, p2)); } function log(string memory p0, uint256 p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string)", p0, p1, p2)); } function log(string memory p0, uint256 p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool)", p0, p1, p2)); } function log(string memory p0, uint256 p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint256 p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256)", p0, p1, p2)); } function log(bool p0, uint256 p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string)", p0, p1, p2)); } function log(bool p0, uint256 p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool)", p0, p1, p2)); } function log(bool p0, uint256 p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint256 p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256)", p0, p1, p2)); } function log(address p0, uint256 p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string)", p0, p1, p2)); } function log(address p0, uint256 p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool)", p0, p1, p2)); } function log(address p0, uint256 p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint256 p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,string)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,bool)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,address)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,string)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,bool)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,address)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,string)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,bool)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,address)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,string)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,bool)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,address)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,string)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,bool)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,address)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,string)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,bool)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,address)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,string)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,bool)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,address)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,string)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,bool)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,address)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,string)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,bool)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,address)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,string)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,bool)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,address)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,string)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,address)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,string)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,bool)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,address)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,string)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,bool)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,address)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,string)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,bool)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,address)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,string)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,bool)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,address)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,string)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,bool)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,uint256)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,string)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,address)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,uint256)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,uint256)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,uint256)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,uint256)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint256)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint256)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint256)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,uint256)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint256)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint256)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint256)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,uint256)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint256)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint256)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint256)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,uint256)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,string)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,bool)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,address)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,uint256)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,uint256)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,uint256)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,uint256)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint256)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint256)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint256)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,uint256)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint256)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint256)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint256)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,uint256)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint256)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint256)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint256)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,uint256)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,string)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,bool)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,address)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,uint256)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,string)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,address)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,uint256)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,uint256)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,string)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,uint256)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint256)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint256)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint256)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,uint256)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint256)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint256)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint256)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint256 p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,uint256)", p0, p1, p2, p3)); } function log(address p0, address p1, uint256 p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint256 p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint256 p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint256)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint256)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint256 p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint256)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } }
@openzeppelin/contracts/security/Pausable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
@openzeppelin/contracts/utils/Base64.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol) pragma solidity ^0.8.0; /** * @dev Provides a set of functions to operate with Base64 strings. * * _Available since v4.5._ */ library Base64 { /** * @dev Base64 Encoding/Decoding Table */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal pure returns (string memory) { /** * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol */ if (data.length == 0) return ""; // Loads the table into memory string memory table = _TABLE; // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter // and split into 4 numbers of 6 bits. // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up // - `data.length + 2` -> Round up // - `/ 3` -> Number of 3-bytes chunks // - `4 *` -> 4 characters for each chunk string memory result = new string(4 * ((data.length + 2) / 3)); /// @solidity memory-safe-assembly assembly { // Prepare the lookup table (skip the first "length" byte) let tablePtr := add(table, 1) // Prepare result pointer, jump over length let resultPtr := add(result, 32) // Run over the input, 3 bytes at a time for { let dataPtr := data let endPtr := add(data, mload(data)) } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 bytes (18 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F which is the number of // the previous character in the ASCII table prior to the Base64 Table // The result is then added to the table to get the character to write, // and finally write it in the result pointer but with a left shift // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1) // Advance } // When data `bytes` is not exactly 3 bytes long // it is padded with `=` characters at the end switch mod(mload(data), 3) case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) } case 2 { mstore8(sub(resultPtr, 1), 0x3d) } } return result; } }
contracts/lit-node/PubkeyRouter.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { PKPNFT } from "./PKPNFT.sol"; import { Staking } from "./Staking.sol"; import "solidity-bytes-utils/contracts/BytesLib.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "hardhat/console.sol"; // TODO: make the tests send PKPNFT into the constructor // TODO: test interaction between PKPNFT and this contract, like mint a keypair and see if you can access it // TODO: setRoutingData() for a batch of keys contract PubkeyRouter is AccessControl { using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.Bytes32Set; using EnumerableSet for EnumerableSet.UintSet; using BytesLib for bytes; /* ========== TYPE DEFINITIONS ========== */ bytes32 public constant ADMIN_ROLE = keccak256("ADMIN"); // 0xdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42 bytes32 public constant ROUTER_ROLE = keccak256("ROUTER"); // 0xeb4fd9f47c063b511700e1c8e94e2fa4088ffca1fdcef1e60edf1beecd1b2e64 /* ========== STATE VARIABLES ========== */ PKPNFT public pkpNFT; struct PubkeyRoutingData { bytes pubkey; address stakingContract; uint256 keyType; // 1 = BLS, 2 = ECDSA. Not doing this in an enum so we can add more keytypes in the future without redeploying. } struct Signature { bytes32 r; bytes32 s; uint8 v; } // map the keccack256(uncompressed pubkey) -> PubkeyRoutingData mapping(uint256 => PubkeyRoutingData) public pubkeys; // map the eth address to a pkp id mapping(address => uint256) public ethAddressToPkpId; /* ========== CONSTRUCTOR ========== */ constructor(address _pkpNft) { pkpNFT = PKPNFT(_pkpNft); _grantRole(ADMIN_ROLE, msg.sender); _grantRole(ROUTER_ROLE, msg.sender); _setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE); _setRoleAdmin(ROUTER_ROLE, ADMIN_ROLE); } /* ========== VIEWS ========== */ /// get the routing data for a given key hash function getRoutingData( uint256 tokenId ) external view returns (PubkeyRoutingData memory) { return pubkeys[tokenId]; } /// get if a given pubkey has routing data associated with it or not function isRouted(uint256 tokenId) public view returns (bool) { PubkeyRoutingData memory prd = pubkeys[tokenId]; return prd.pubkey.length != 0 && prd.keyType != 0 && prd.stakingContract != address(0); } /// get the eth address for the keypair, as long as it's an ecdsa keypair function getEthAddress(uint256 tokenId) public view returns (address) { // only return addresses for ECDSA keys so that people don't // send funds to a BLS key that would be irretrieveably lost if (pubkeys[tokenId].keyType != 2) { return address(0); } return deriveEthAddressFromPubkey(pubkeys[tokenId].pubkey); } /// includes the 0x04 prefix so you can pass this directly to ethers.utils.computeAddress function getPubkey(uint256 tokenId) public view returns (bytes memory) { return pubkeys[tokenId].pubkey; } function deriveEthAddressFromPubkey( bytes memory pubkey ) public pure returns (address) { // remove 0x04 prefix bytes32 hashed = keccak256(pubkey.slice(1, 64)); return address(uint160(uint256(hashed))); } /* ========== MUTATIVE FUNCTIONS ========== */ /// register a pubkey and routing data for a given key hash // the person asking the nodes to generate the keys will collect signatures from them and then call this function to route the key // FIXME this is vulnerable to passing the same signature in 10 times. we don't check that the sigs are unique, or that they're from independent nodes. // FIXME this is also vulnerable to an attack where someone sets up their own staking contract with a threshold of 1 and then goes around claiming tokenIds and filling them with junk. we probably need to verify that the staking contract is legit. i'm not sure how to do that though. like we can check various things from the staking contract, that the staked token is the real Lit token, and that the user has staked a significant amount. But how do we know that staking contract isn't a custom fork that lies about all that stuff? Maybe we need a mapping of valid staking contracts somewhere, and when we deploy a new one we add it manually. function setRoutingData( uint256 tokenId, bytes memory pubkey, address stakingContractAddress, uint256 keyType, Signature[] memory signatures ) public { require( hasRole(ROUTER_ROLE, msg.sender), "PubkeyRouter: must have router role" ); Staking stakingContract = Staking(stakingContractAddress); require( signatures.length == stakingContract.getValidatorsInCurrentEpochLength(), "PubkeyRouter: incorrect number of signatures" ); require( tokenId == uint256(keccak256(pubkey)), "tokenId does not match hashed pubkey" ); require( !isRouted(tokenId), "PubkeyRouter: pubkey already has routing data" ); // check the signatures for (uint256 i = 0; i < signatures.length; i++) { Signature memory sig = signatures[i]; address signer = ECDSA.recover( ECDSA.toEthSignedMessageHash(pubkey), sig.v, sig.r, sig.s ); // console.log("signer: "); // console.log(signer); require( stakingContract.isActiveValidatorByNodeAddress(signer), "PubkeyRouter: signer is not active validator" ); } pubkeys[tokenId].pubkey = pubkey; pubkeys[tokenId].stakingContract = stakingContractAddress; pubkeys[tokenId].keyType = keyType; if (keyType == 2) { address pkpAddress = deriveEthAddressFromPubkey(pubkey); ethAddressToPkpId[pkpAddress] = tokenId; } pkpNFT.pkpRouted(tokenId, keyType); emit PubkeyRoutingDataSet( tokenId, pubkey, stakingContractAddress, keyType ); } // a batch version of the above function function setRoutingDataBatch( uint256[] memory tokenIds, bytes[] memory _pubkeys, address stakingContract, uint256 keyType, Signature[][] memory signatures ) public { require( tokenIds.length == _pubkeys.length && tokenIds.length == signatures.length, "PubkeyRouter: incorrect number of arguments" ); for (uint256 i = 0; i < tokenIds.length; i++) { setRoutingData( tokenIds[i], _pubkeys[i], stakingContract, keyType, signatures[i] ); } } /// Set the pubkey and routing data for a given key hash // this is only used by an admin in case of emergency. can prob be removed. function setRoutingDataAsAdmin( uint256 tokenId, bytes memory pubkey, address stakingContract, uint256 keyType ) public { require( hasRole(ADMIN_ROLE, msg.sender), "PubkeyRouter: must have admin role" ); pubkeys[tokenId].pubkey = pubkey; pubkeys[tokenId].stakingContract = stakingContract; pubkeys[tokenId].keyType = keyType; if (keyType == 2) { address pkpAddress = deriveEthAddressFromPubkey(pubkey); ethAddressToPkpId[pkpAddress] = tokenId; } pkpNFT.pkpRouted(tokenId, keyType); emit PubkeyRoutingDataSet(tokenId, pubkey, stakingContract, keyType); } function setPkpNftAddress(address newPkpNftAddress) public { require( hasRole(ADMIN_ROLE, msg.sender), "PubkeyRouter: must have admin role" ); pkpNFT = PKPNFT(newPkpNftAddress); emit PkpNftAddressSet(newPkpNftAddress); } /* ========== EVENTS ========== */ event PubkeyRoutingDataSet( uint256 indexed tokenId, bytes pubkey, address stakingContract, uint256 keyType ); event PkpNftAddressSet(address newPkpNftAddress); }
@openzeppelin/contracts/utils/Address.sol
// 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 Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
contracts/lit-node/Staking.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import { ERC20Burnable } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import { Pausable } from "@openzeppelin/contracts/security/Pausable.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "hardhat/console.sol"; contract Staking is ReentrancyGuard, Pausable, Ownable { using EnumerableSet for EnumerableSet.AddressSet; /* ========== STATE VARIABLES ========== */ enum States { Active, NextValidatorSetLocked, ReadyForNextEpoch, Unlocked, Paused } // this enum is not used, and instead we use an integer so that // we can add more reasons after the contract is deployed. // This enum is kept in the comments here for reference. // enum KickReason { // NULLREASON, // 0 // UNRESPONSIVE, // 1 // BAD_ATTESTATION // 2 // } States public state = States.Active; ERC20Burnable public stakingToken; struct Epoch { uint256 epochLength; uint256 number; uint256 endBlock; // uint256 retries; // incremented upon failure to advance and subsequent unlock uint256 timeout; // timeout in blocks, where the nodes can be unlocked. } Epoch public epoch; uint256 public tokenRewardPerTokenPerEpoch; uint256 public minimumStake; uint256 public totalStaked; // tokens slashed when kicked uint256 public kickPenaltyPercent; EnumerableSet.AddressSet validatorsInCurrentEpoch; EnumerableSet.AddressSet validatorsInNextEpoch; EnumerableSet.AddressSet validatorsKickedFromNextEpoch; struct Validator { uint32 ip; uint128 ipv6; uint32 port; address nodeAddress; uint256 balance; uint256 reward; uint256 senderPubKey; uint256 receiverPubKey; } struct VoteToKickValidatorInNextEpoch { uint256 votes; mapping(address => bool) voted; } // list of all validators, even ones that are not in the current or next epoch // maps STAKER address to Validator struct mapping(address => Validator) public validators; // stakers join by staking, but nodes need to be able to vote to kick. // to avoid node operators having to run a hotwallet with their staking private key, // the node gets it's own private key that it can use to vote to kick, // or signal that the next epoch is ready. // this mapping lets you go from the nodeAddressto the stakingAddress. mapping(address => address) public nodeAddressToStakerAddress; // after the validator set is locked, nodes vote that they have successfully completed the PSS // operation. Once a threshold of nodes have voted that they are ready, then the epoch can advance mapping(address => bool) public readyForNextEpoch; // nodes can vote to kick another node. If a threshold of nodes vote to kick someone, they // are removed from the next validator set mapping(uint256 => mapping(address => VoteToKickValidatorInNextEpoch)) public votesToKickValidatorsInNextEpoch; // resolver contract address. the resolver contract is used to lookup other contract addresses. address public resolverContractAddress; /* ========== CONSTRUCTOR ========== */ constructor(address _stakingToken) { stakingToken = ERC20Burnable(_stakingToken); epoch = Epoch({ epochLength: 80, number: 1, endBlock: block.number + 1, retries: 0, timeout: 80 }); // 0.05 tokens per token staked meaning a 5% per epoch inflation rate tokenRewardPerTokenPerEpoch = (10 ** stakingToken.decimals()) / 20; // 1 token minimum stake minimumStake = 1 * (10 ** stakingToken.decimals()); kickPenaltyPercent = 0; } /* ========== VIEWS ========== */ function isActiveValidator(address account) external view returns (bool) { return validatorsInCurrentEpoch.contains(account); } function isActiveValidatorByNodeAddress( address account ) external view returns (bool) { return validatorsInCurrentEpoch.contains( nodeAddressToStakerAddress[account] ); } function rewardOf(address account) external view returns (uint256) { return validators[account].reward; } function balanceOf(address account) external view returns (uint256) { return validators[account].balance; } function getVotingStatusToKickValidator( uint256 epochNumber, address validatorStakerAddress, address voterStakerAddress ) external view returns (uint256, bool) { VoteToKickValidatorInNextEpoch storage votingStatus = votesToKickValidatorsInNextEpoch[ epochNumber ][validatorStakerAddress]; return (votingStatus.votes, votingStatus.voted[voterStakerAddress]); } function getValidatorsInCurrentEpoch() public view returns (address[] memory) { address[] memory values = new address[]( validatorsInCurrentEpoch.length() ); uint256 validatorLength = validatorsInCurrentEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { values[i] = validatorsInCurrentEpoch.at(i); } return values; } function getValidatorsInCurrentEpochLength() external view returns (uint256) { return validatorsInCurrentEpoch.length(); } function getValidatorsInNextEpoch() public view returns (address[] memory) { address[] memory values = new address[](validatorsInNextEpoch.length()); uint256 validatorLength = validatorsInNextEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { values[i] = validatorsInNextEpoch.at(i); } return values; } function getValidatorsStructs( address[] memory addresses ) public view returns (Validator[] memory) { Validator[] memory values = new Validator[](addresses.length); for (uint256 i = 0; i < addresses.length; i++) { values[i] = validators[addresses[i]]; } return values; } function getValidatorsStructsInCurrentEpoch() external view returns (Validator[] memory) { address[] memory addresses = getValidatorsInCurrentEpoch(); return getValidatorsStructs(addresses); } function getValidatorsStructsInNextEpoch() external view returns (Validator[] memory) { address[] memory addresses = getValidatorsInNextEpoch(); return getValidatorsStructs(addresses); } function isReadyForNextEpoch() public view returns (bool) { uint256 total = 0; uint256 validatorLength = validatorsInNextEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { if (readyForNextEpoch[validatorsInNextEpoch.at(i)]) { total++; } } if ((total >= validatorCountForConsensus())) { // 2/3 of validators must be ready return true; } return false; } function shouldKickValidator( address stakerAddress ) public view returns (bool) { VoteToKickValidatorInNextEpoch storage vk = votesToKickValidatorsInNextEpoch[epoch.number][ stakerAddress ]; if (vk.votes >= validatorCountForConsensus()) { // 2/3 of validators must vote return true; } return false; } // these could be checked with uint return value with the state getter, but included defensively in case more states are added. function validatorsInNextEpochAreLocked() public view returns (bool) { return state == States.NextValidatorSetLocked; } function validatorStateIsActive() public view returns (bool) { return state == States.Active; } function validatorStateIsUnlocked() public view returns (bool) { return state == States.Unlocked; } // currently set to 2/3. this could be changed to be configurable. function validatorCountForConsensus() public view returns (uint256) { if (validatorsInCurrentEpoch.length() <= 2) { return 1; } return (validatorsInCurrentEpoch.length() * 2) / 3; } /* ========== MUTATIVE FUNCTIONS ========== */ /// Lock in the validators for the next epoch function lockValidatorsForNextEpoch() public { require( block.number >= epoch.endBlock, "Enough blocks have not elapsed since the last epoch" ); require( state == States.Active || state == States.Unlocked, "Must be in active or unlocked state" ); state = States.NextValidatorSetLocked; emit StateChanged(state); } /// After proactive secret sharing is complete, the nodes may signal that they are ready for the next epoch. Note that this function is called by the node itself, and so msg.sender is the nodeAddress and not the stakerAddress. function signalReadyForNextEpoch() public { address stakerAddress = nodeAddressToStakerAddress[msg.sender]; require( state == States.NextValidatorSetLocked || state == States.ReadyForNextEpoch, "Must be in state NextValidatorSetLocked or ReadyForNextEpoch" ); // at the first epoch, validatorsInCurrentEpoch is empty if (epoch.number != 1) { require( validatorsInNextEpoch.contains(stakerAddress), "Validator is not in the next epoch" ); } readyForNextEpoch[stakerAddress] = true; emit ReadyForNextEpoch(stakerAddress); if (isReadyForNextEpoch()) { state = States.ReadyForNextEpoch; emit StateChanged(state); } } /// If the nodes fail to advance (e.g. because dkg failed), anyone can call to unlock and allow retry function unlockValidatorsForNextEpoch() public { // the deadline to advance is thus epoch.endBlock + epoch.timeout require( block.number >= epoch.endBlock + epoch.timeout, "Enough blocks have not elapsed since the last epoch" ); require( state == States.NextValidatorSetLocked, "Must be in NextValidatorSetLocked" ); uint256 validatorLength = validatorsInNextEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { readyForNextEpoch[validatorsInNextEpoch.at(i)] = false; } epoch.retries++; state = States.Unlocked; emit StateChanged(state); } /// Advance to the next Epoch. Rewards validators, adds the joiners, and removes the leavers function advanceEpoch() public { require( block.number >= epoch.endBlock, "Enough blocks have not elapsed since the last epoch" ); require( state == States.ReadyForNextEpoch, "Must be in ready for next epoch state" ); require( isReadyForNextEpoch() == true, "Not enough validators are ready for the next epoch" ); // reward the validators uint256 validatorLength = validatorsInCurrentEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { address validatorAddress = validatorsInCurrentEpoch.at(i); validators[validatorAddress].reward += (tokenRewardPerTokenPerEpoch * validators[validatorAddress].balance) / 10 ** stakingToken.decimals(); } // set the validators to the new validator set // ideally we could just do this: // validatorsInCurrentEpoch = validatorsInNextEpoch; // but solidity doesn't allow that, so we have to do it manually // clear out validators in current epoch while (validatorsInCurrentEpoch.length() > 0) { validatorsInCurrentEpoch.remove(validatorsInCurrentEpoch.at(0)); } // copy validators from next epoch to current epoch validatorLength = validatorsInNextEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { validatorsInCurrentEpoch.add(validatorsInNextEpoch.at(i)); // clear out readyForNextEpoch readyForNextEpoch[validatorsInNextEpoch.at(i)] = false; } epoch.number++; epoch.endBlock = block.number + epoch.epochLength; // not epoch.endBlock + state = States.Active; emit StateChanged(state); } /// Stake and request to join the validator set /// @param amount The amount of tokens to stake /// @param ip The IP address of the node /// @param port The port of the node function stakeAndJoin( uint256 amount, uint32 ip, uint128 ipv6, uint32 port, address nodeAddress, uint256 senderPubKey, uint256 receiverPubKey ) public whenNotPaused { stake(amount); requestToJoin( ip, ipv6, port, nodeAddress, senderPubKey, receiverPubKey ); } /// Stake tokens for a validator function stake(uint256 amount) public nonReentrant { require(amount > 0, "Cannot stake 0"); stakingToken.transferFrom(msg.sender, address(this), amount); validators[msg.sender].balance += amount; totalStaked += amount; emit Staked(msg.sender, amount); } function requestToJoin( uint32 ip, uint128 ipv6, uint32 port, address nodeAddress, uint256 senderPubKey, uint256 receiverPubKey ) public nonReentrant { uint256 amountStaked = validators[msg.sender].balance; require( amountStaked >= minimumStake, "Stake must be greater than or equal to minimumStake" ); require( state == States.Active || state == States.Unlocked || state == States.Paused, "Must be in Active or Unlocked state to request to join" ); // make sure they haven't been kicked require( validatorsKickedFromNextEpoch.contains(msg.sender) == false, "You cannot rejoin if you have been kicked until the next epoch" ); validators[msg.sender].ip = ip; validators[msg.sender].ipv6 = ipv6; validators[msg.sender].port = port; validators[msg.sender].nodeAddress = nodeAddress; validators[msg.sender].senderPubKey = senderPubKey; validators[msg.sender].receiverPubKey = receiverPubKey; nodeAddressToStakerAddress[nodeAddress] = msg.sender; validatorsInNextEpoch.add(msg.sender); emit RequestToJoin(msg.sender); } /// Withdraw staked tokens. This can only be done by users who are not active in the validator set. /// @param amount The amount of tokens to withdraw function withdraw(uint256 amount) public nonReentrant { require(amount > 0, "Cannot withdraw 0"); require( validatorsInCurrentEpoch.contains(msg.sender) == false, "Active validators cannot leave. Please use the leave() function and wait for the next epoch to leave" ); require( validators[msg.sender].balance >= amount, "Not enough tokens to withdraw" ); totalStaked = totalStaked - amount; validators[msg.sender].balance = validators[msg.sender].balance - amount; stakingToken.transfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } /// Request to leave in the next Epoch function requestToLeave() public nonReentrant { require( state == States.Active || state == States.Unlocked || state == States.Paused, "Must be in Active or Unlocked state to request to leave" ); if (validatorsInNextEpoch.contains(msg.sender)) { // remove them validatorsInNextEpoch.remove(msg.sender); } emit RequestToLeave(msg.sender); } /// Transfer any outstanding reward tokens function getReward() public nonReentrant { uint256 reward = validators[msg.sender].reward; if (reward > 0) { validators[msg.sender].reward = 0; stakingToken.transfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } /// Exit staking and get any outstanding rewards function exit() public { withdraw(validators[msg.sender].balance); getReward(); } /// If more than the threshold of validators vote to kick someone, kick them. /// It's expected that this will be called by the node directly, so msg.sender will be the nodeAddress function kickValidatorInNextEpoch( address validatorStakerAddress, uint256 reason, bytes calldata data ) public nonReentrant { address stakerAddressOfSender = nodeAddressToStakerAddress[msg.sender]; require( stakerAddressOfSender != address(0), "Could not map your nodeAddress to your stakerAddress" ); require( validatorsInNextEpoch.contains(stakerAddressOfSender), "You must be a validator in the next epoch to kick someone from the next epoch" ); require( votesToKickValidatorsInNextEpoch[epoch.number][ validatorStakerAddress ].voted[stakerAddressOfSender] == false, "You can only vote to kick someone once per epoch" ); // Vote to kick votesToKickValidatorsInNextEpoch[epoch.number][validatorStakerAddress] .votes++; votesToKickValidatorsInNextEpoch[epoch.number][validatorStakerAddress] .voted[stakerAddressOfSender] = true; if ( validatorsInNextEpoch.contains(validatorStakerAddress) && shouldKickValidator(validatorStakerAddress) ) { // remove from next validator set validatorsInNextEpoch.remove(validatorStakerAddress); // block them from rejoining the next epoch validatorsKickedFromNextEpoch.add(validatorStakerAddress); // slash the stake uint256 amountToBurn = (validators[validatorStakerAddress].balance * kickPenaltyPercent) / 100; validators[validatorStakerAddress].balance -= amountToBurn; totalStaked -= amountToBurn; stakingToken.burn(amountToBurn); // shame them with an event emit ValidatorKickedFromNextEpoch( validatorStakerAddress, amountToBurn ); } emit VotedToKickValidatorInNextEpoch( stakerAddressOfSender, validatorStakerAddress, reason, data ); } /// Set the IP and port of your node /// @param ip The ip address of your node /// @param port The port of your node function setIpPortNodeAddressAndCommunicationPubKeys( uint32 ip, uint128 ipv6, uint32 port, address nodeAddress, uint256 senderPubKey, uint256 receiverPubKey ) public { validators[msg.sender].ip = ip; validators[msg.sender].ipv6 = ipv6; validators[msg.sender].port = port; validators[msg.sender].nodeAddress = nodeAddress; validators[msg.sender].senderPubKey = senderPubKey; validators[msg.sender].receiverPubKey = receiverPubKey; } function setEpochLength(uint256 newEpochLength) public onlyOwner { epoch.epochLength = newEpochLength; emit EpochLengthSet(newEpochLength); } function setEpochTimeout(uint256 newEpochTimeout) public onlyOwner { epoch.timeout = newEpochTimeout; emit EpochTimeoutSet(newEpochTimeout); } function setStakingToken(address newStakingTokenAddress) public onlyOwner { stakingToken = ERC20Burnable(newStakingTokenAddress); emit StakingTokenSet(newStakingTokenAddress); } function setTokenRewardPerTokenPerEpoch( uint256 newTokenRewardPerTokenPerEpoch ) public onlyOwner { tokenRewardPerTokenPerEpoch = newTokenRewardPerTokenPerEpoch; emit TokenRewardPerTokenPerEpochSet(newTokenRewardPerTokenPerEpoch); } function setMinimumStake(uint256 newMinimumStake) public onlyOwner { minimumStake = newMinimumStake; emit MinimumStakeSet(newMinimumStake); } function setKickPenaltyPercent( uint256 newKickPenaltyPercent ) public onlyOwner { kickPenaltyPercent = newKickPenaltyPercent; emit KickPenaltyPercentSet(newKickPenaltyPercent); } function setResolverContractAddress( address newResolverContractAddress ) public onlyOwner { resolverContractAddress = newResolverContractAddress; emit ResolverContractAddressSet(newResolverContractAddress); } function setEpochState(States newState) public onlyOwner { state = newState; emit StateChanged(newState); } function pauseEpoch() public onlyOwner { state = States.Paused; emit StateChanged(States.Paused); } function adminKickValidatorInNextEpoch( address validatorStakerAddress ) public nonReentrant onlyOwner { // remove from next validator set validatorsInNextEpoch.remove(validatorStakerAddress); // block them from rejoining the next epoch validatorsKickedFromNextEpoch.add(validatorStakerAddress); emit ValidatorKickedFromNextEpoch(validatorStakerAddress, 0); } function adminSlashValidator( address validatorStakerAddress, uint256 amountToBurn ) public nonReentrant onlyOwner { validators[validatorStakerAddress].balance -= amountToBurn; totalStaked -= amountToBurn; stakingToken.burn(amountToBurn); emit ValidatorKickedFromNextEpoch(validatorStakerAddress, amountToBurn); } /* ========== EVENTS ========== */ event Staked(address indexed staker, uint256 amount); event Withdrawn(address indexed staker, uint256 amount); event RewardPaid(address indexed staker, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event RequestToJoin(address indexed staker); event RequestToLeave(address indexed staker); event Recovered(address token, uint256 amount); event ReadyForNextEpoch(address indexed staker); event StateChanged(States newState); event VotedToKickValidatorInNextEpoch( address indexed reporter, address indexed validatorStakerAddress, uint256 indexed reason, bytes data ); event ValidatorKickedFromNextEpoch( address indexed staker, uint256 amountBurned ); // onlyOwner events event EpochLengthSet(uint256 newEpochLength); event EpochTimeoutSet(uint256 newEpochTimeout); event StakingTokenSet(address newStakingTokenAddress); event TokenRewardPerTokenPerEpochSet( uint256 newTokenRewardPerTokenPerEpoch ); event MinimumStakeSet(uint256 newMinimumStake); event KickPenaltyPercentSet(uint256 newKickPenaltyPercent); event ResolverContractAddressSet(address newResolverContractAddress); }
@openzeppelin/contracts/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
@openzeppelin/contracts/utils/structs/EnumerableSet.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
@openzeppelin/contracts/security/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "../../../utils/Context.sol"; /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be burned (destroyed). */ abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _burn(tokenId); } }
@openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.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 ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
@openzeppelin/contracts/utils/structs/BitMaps.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/structs/BitMaps.sol) pragma solidity ^0.8.0; /** * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential. * Largelly inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. */ library BitMaps { struct BitMap { mapping(uint256 => uint256) _data; } /** * @dev Returns whether the bit at `index` is set. */ function get(BitMap storage bitmap, uint256 index) internal view returns (bool) { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); return bitmap._data[bucket] & mask != 0; } /** * @dev Sets the bit at `index` to the boolean `value`. */ function setTo( BitMap storage bitmap, uint256 index, bool value ) internal { if (value) { set(bitmap, index); } else { unset(bitmap, index); } } /** * @dev Sets the bit at `index`. */ function set(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] |= mask; } /** * @dev Unsets the bit at `index`. */ function unset(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] &= ~mask; } }
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
@openzeppelin/contracts/access/IAccessControl.sol
// 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 IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"approved","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"bool","name":"approved","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"FreeMintSignerSet","inputs":[{"type":"address","name":"newFreeMintSigner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"MintCostSet","inputs":[{"type":"uint256","name":"newMintCost","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PKPMinted","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"bytes","name":"pubkey","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"PkpNftMetadataAddressSet","inputs":[{"type":"address","name":"pkpNftMetadataAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PkpPermissionsAddressSet","inputs":[{"type":"address","name":"pkpPermissionsAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PkpRouted","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"uint256","name":"keyType","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"RouterAddressSet","inputs":[{"type":"address","name":"routerAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"Withdrew","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"approve","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"burn","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"exists","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"freeMintGrantAndBurnNext","inputs":[{"type":"uint256","name":"keyType","internalType":"uint256"},{"type":"uint256","name":"freeMintId","internalType":"uint256"},{"type":"bytes","name":"ipfsCID","internalType":"bytes"},{"type":"bytes32","name":"msgHash","internalType":"bytes32"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"freeMintNext","inputs":[{"type":"uint256","name":"keyType","internalType":"uint256"},{"type":"uint256","name":"freeMintId","internalType":"uint256"},{"type":"bytes32","name":"msgHash","internalType":"bytes32"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[],"name":"freeMintSigTest","inputs":[{"type":"uint256","name":"freeMintId","internalType":"uint256"},{"type":"bytes32","name":"msgHash","internalType":"bytes32"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"freeMintSigner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getApproved","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getEthAddress","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"getPubkey","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUnmintedRoutedTokenIdCount","inputs":[{"type":"uint256","name":"keyType","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedForAll","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"mintCost","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"mintGrantAndBurnNext","inputs":[{"type":"uint256","name":"keyType","internalType":"uint256"},{"type":"bytes","name":"ipfsCID","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"mintGrantAndBurnSpecific","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bytes","name":"ipfsCID","internalType":"bytes"}]},{"type":"function","stateMutability":"payable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"mintNext","inputs":[{"type":"uint256","name":"keyType","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"mintSpecific","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ownerOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract PKPNFTMetadata"}],"name":"pkpNftMetadata","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract PKPPermissions"}],"name":"pkpPermissions","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pkpRouted","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"keyType","internalType":"uint256"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"prefixed","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"redeemedFreeMintIds","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract PubkeyRouter"}],"name":"router","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setApprovalForAll","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"bool","name":"approved","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFreeMintSigner","inputs":[{"type":"address","name":"newFreeMintSigner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMintCost","inputs":[{"type":"uint256","name":"newMintCost","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPkpNftMetadataAddress","inputs":[{"type":"address","name":"pkpNftMetadataAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPkpPermissionsAddress","inputs":[{"type":"address","name":"pkpPermissionsAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRouterAddress","inputs":[{"type":"address","name":"routerAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenByIndex","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenOfOwnerByIndex","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"tokenURI","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"unmintedRoutedTokenIds","inputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[]}]
Contract Creation Code
0x60806040523480156200001157600080fd5b506040518060400160405280601481526020017f50726f6772616d6d61626c65204b6579706169720000000000000000000000008152506040518060400160405280600381526020017f504b50000000000000000000000000000000000000000000000000000000000081525081600090816200008f919062000463565b508060019081620000a1919062000463565b505050620000c4620000b86200011b60201b60201c565b6200012360201b60201c565b6001600b819055506001600f8190555033601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506200054a565b600033905090565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200026b57607f821691505b60208210810362000281576200028062000223565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620002eb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002ac565b620002f78683620002ac565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b6000620003446200033e62000338846200030f565b62000319565b6200030f565b9050919050565b6000819050919050565b620003608362000323565b620003786200036f826200034b565b848454620002b9565b825550505050565b600090565b6200038f62000380565b6200039c81848462000355565b505050565b5b81811015620003c457620003b860008262000385565b600181019050620003a2565b5050565b601f8211156200041357620003dd8162000287565b620003e8846200029c565b81016020851015620003f8578190505b6200041062000407856200029c565b830182620003a1565b50505b505050565b600082821c905092915050565b6000620004386000198460080262000418565b1980831691505092915050565b600062000453838362000425565b9150826002028217905092915050565b6200046e82620001e9565b67ffffffffffffffff8111156200048a5762000489620001f4565b5b62000496825462000252565b620004a3828285620003c8565b600060209050601f831160018114620004db5760008415620004c6578287015190505b620004d2858262000445565b86555062000542565b601f198416620004eb8662000287565b60005b828110156200051557848901518255600182019150602085019450602081019050620004ee565b8683101562000535578489015162000531601f89168262000425565b8355505b6001600288020188555050505b505050505050565b6155f1806200055a6000396000f3fe60806040526004361061027d5760003560e01c80636352211e1161014f578063b94a2102116100c1578063e985e9c51161007a578063e985e9c5146109fc578063ef6fd87814610a39578063f2fde38b14610a76578063f556aeb114610a9f578063f70e72ef14610ac8578063f887ea4014610b055761027d565b8063b94a2102146108c6578063bd4986a0146108f1578063bdb4b8481461092e578063c87b56dd14610959578063d343682614610996578063d7b0398b146109bf5761027d565b80638da5cb5b116101135780638da5cb5b146107c85780639388f12e146107f357806395d89b411461081e57806397016f3f14610849578063a22cb46514610874578063b88d4fde1461089d5761027d565b80636352211e146106de57806366a306d71461071b57806370a082311461074b578063715018a6146107885780638545f4ea1461079f5761027d565b80633ccfd60b116101f35780634f558e79116101ac5780634f558e79146105a55780634f6ccce7146105e257806356e3a1ae1461061f5780635c110a9c1461065c5780635d228b16146106855780635f49663c146106b55761027d565b80633ccfd60b146104ad57806341cb87fc146104c457806342842e0e146104ed57806342966c681461051657806342dd8fcb1461053f5780634c19eae61461057c5761027d565b806318160ddd1161024557806318160ddd1461038d5780631ea89a22146103b85780631f275713146103e157806323b872dd1461041e5780632f745c59146104475780633b189852146104845761027d565b806301ffc9a71461028257806306fdde03146102bf578063081812fc146102ea578063095ea7b3146103275780631582391c14610350575b600080fd5b34801561028e57600080fd5b506102a960048036038101906102a491906138b0565b610b30565b6040516102b691906138f8565b60405180910390f35b3480156102cb57600080fd5b506102d4610c6a565b6040516102e191906139a3565b60405180910390f35b3480156102f657600080fd5b50610311600480360381019061030c91906139fb565b610cfc565b60405161031e9190613a69565b60405180910390f35b34801561033357600080fd5b5061034e60048036038101906103499190613ab0565b610d42565b005b34801561035c57600080fd5b5061037760048036038101906103729190613b5f565b610e59565b6040516103849190613bfb565b60405180910390f35b34801561039957600080fd5b506103a2610e83565b6040516103af9190613bfb565b60405180910390f35b3480156103c457600080fd5b506103df60048036038101906103da9190613c16565b610e90565b005b3480156103ed57600080fd5b5061040860048036038101906104039190613c43565b610f1f565b6040516104159190613c7f565b60405180910390f35b34801561042a57600080fd5b5061044560048036038101906104409190613c9a565b610f4f565b005b34801561045357600080fd5b5061046e60048036038101906104699190613ab0565b610faf565b60405161047b9190613bfb565b60405180910390f35b34801561049057600080fd5b506104ab60048036038101906104a69190613c16565b611054565b005b3480156104b957600080fd5b506104c26110e3565b005b3480156104d057600080fd5b506104eb60048036038101906104e69190613c16565b6111f6565b005b3480156104f957600080fd5b50610514600480360381019061050f9190613c9a565b611285565b005b34801561052257600080fd5b5061053d600480360381019061053891906139fb565b6112a5565b005b34801561054b57600080fd5b50610566600480360381019061056191906139fb565b611301565b6040516105739190613bfb565b60405180910390f35b34801561058857600080fd5b506105a3600480360381019061059e9190613ced565b611321565b005b3480156105b157600080fd5b506105cc60048036038101906105c791906139fb565b6114eb565b6040516105d991906138f8565b60405180910390f35b3480156105ee57600080fd5b50610609600480360381019061060491906139fb565b6114fd565b6040516106169190613bfb565b60405180910390f35b34801561062b57600080fd5b50610646600480360381019061064191906139fb565b61156e565b60405161065391906138f8565b60405180910390f35b34801561066857600080fd5b50610683600480360381019061067e9190613d68565b61158e565b005b61069f600480360381019061069a91906139fb565b61168a565b6040516106ac9190613bfb565b60405180910390f35b3480156106c157600080fd5b506106dc60048036038101906106d79190613c16565b6116f0565b005b3480156106ea57600080fd5b50610705600480360381019061070091906139fb565b61177f565b6040516107129190613a69565b60405180910390f35b61073560048036038101906107309190613edd565b611830565b6040516107429190613bfb565b60405180910390f35b34801561075757600080fd5b50610772600480360381019061076d9190613c16565b61197a565b60405161077f9190613bfb565b60405180910390f35b34801561079457600080fd5b5061079d611a31565b005b3480156107ab57600080fd5b506107c660048036038101906107c191906139fb565b611a45565b005b3480156107d457600080fd5b506107dd611a8e565b6040516107ea9190613a69565b60405180910390f35b3480156107ff57600080fd5b50610808611ab8565b6040516108159190613f98565b60405180910390f35b34801561082a57600080fd5b50610833611ade565b60405161084091906139a3565b60405180910390f35b34801561085557600080fd5b5061085e611b70565b60405161086b9190613fd4565b60405180910390f35b34801561088057600080fd5b5061089b6004803603810190610896919061401b565b611b96565b005b3480156108a957600080fd5b506108c460048036038101906108bf919061405b565b611bac565b005b3480156108d257600080fd5b506108db611c0e565b6040516108e89190613a69565b60405180910390f35b3480156108fd57600080fd5b50610918600480360381019061091391906139fb565b611c34565b6040516109259190613a69565b60405180910390f35b34801561093a57600080fd5b50610943611cd9565b6040516109509190613bfb565b60405180910390f35b34801561096557600080fd5b50610980600480360381019061097b91906139fb565b611cdf565b60405161098d91906139a3565b60405180910390f35b3480156109a257600080fd5b506109bd60048036038101906109b891906139fb565b611f8e565b005b3480156109cb57600080fd5b506109e660048036038101906109e191906140de565b611fa3565b6040516109f39190613bfb565b60405180910390f35b348015610a0857600080fd5b50610a236004803603810190610a1e919061419c565b611fcf565b604051610a3091906138f8565b60405180910390f35b348015610a4557600080fd5b50610a606004803603810190610a5b91906139fb565b612063565b604051610a6d9190614231565b60405180910390f35b348015610a8257600080fd5b50610a9d6004803603810190610a989190613c16565b61210d565b005b348015610aab57600080fd5b50610ac66004803603810190610ac19190613edd565b612190565b005b348015610ad457600080fd5b50610aef6004803603810190610aea9190613d68565b612289565b604051610afc9190613bfb565b60405180910390f35b348015610b1157600080fd5b50610b1a6122ba565b604051610b279190614274565b60405180910390f35b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610bfb57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610c6357507f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b606060008054610c79906142be565b80601f0160208091040260200160405190810160405280929190818152602001828054610ca5906142be565b8015610cf25780601f10610cc757610100808354040283529160200191610cf2565b820191906000526020600020905b815481529060010190602001808311610cd557829003601f168201915b5050505050905090565b6000610d07826122e0565b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610d4d8261177f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610dbd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db490614361565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610ddc61232b565b73ffffffffffffffffffffffffffffffffffffffff161480610e0b5750610e0a81610e0561232b565b611fcf565b5b610e4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e41906143f3565b60405180910390fd5b610e548383612333565b505050565b600080610e65886123ec565b9050610e758782888888886124de565b809150509695505050505050565b6000600980549050905090565b610e98612529565b80600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f42d2ac2cd8a457cf976d513bacdc167baa2ff2cd2706c98d222bb035b89d496960405160405180910390a250565b600081604051602001610f32919061448b565b604051602081830303815290604052805190602001209050919050565b610f60610f5a61232b565b826125a7565b610f9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9690614523565b60405180910390fd5b610faa83838361263c565b505050565b6000610fba8361197a565b8210610ffb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ff2906145b5565b60405180910390fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b61105c612529565b80601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f65d3e06a561c77a07da59b8b2ca10214ae08fe21cc2953a90db0ac8b5b7c437160405160405180910390a250565b6110eb612529565b6002600b5403611130576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112790614621565b60405180910390fd5b6002600b81905550600047905060003373ffffffffffffffffffffffffffffffffffffffff168260405161116390614672565b60006040518083038185875af1925050503d80600081146111a0576040519150601f19603f3d011682016040523d82523d6000602084013e6111a5565b606091505b50509050806111b357600080fd5b7fb6b476da71cea8275cac6b1720c04966afaff5e637472cedb6cbd32c43a23251826040516111e29190613bfb565b60405180910390a150506001600b81905550565b6111fe612529565b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f8da1c48aefffe2a2520f3e707937e3254d532a0905d345e539532599d2a0564c60405160405180910390a250565b6112a083838360405180602001604052806000815250611bac565b505050565b6112b66112b061232b565b826125a7565b6112f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ec90614523565b60405180910390fd5b6112fe816128a2565b50565b600060116000838152602001908152602001600020805490509050919050565b600061135430876040516020016113399291906146f0565b60405160208183030381529060405280519060200120610f1f565b9050848114611398576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138f9061478e565b60405180910390fd5b6000600186868686604051600081526020016040526040516113bd94939291906147bd565b6020604051602081039080840390855afa1580156113df573d6000803e3d6000fd5b505050602060405103519050601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461147b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114729061489a565b60405180910390fd5b600015156012600089815260200190815260200160002060009054906101000a900460ff161515146114e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d99061492c565b60405180910390fd5b50505050505050565b60006114f6826129bf565b9050919050565b6000611507610e83565b8210611548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153f906149be565b60405180910390fd5b6009828154811061155c5761155b6149de565b5b90600052602060002001549050919050565b60126020528060005260406000206000915054906101000a900460ff1681565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461161e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161590614a7f565b60405180910390fd5b6011600082815260200190815260200160002082908060018154018082558091505060019003906000526020600020016000909190919091505580827f67c5bcaefda7c1381ded3fc61dbb8e693cef5b368cd356324bcc2b1aa791448c60405160405180910390a35050565b6000600f5434146116d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c790614aeb565b60405180910390fd5b60006116db836123ec565b90506116e78133612a2b565b80915050919050565b6116f8612529565b80600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f446c3422d569626abc16e1497dfa8270f1192bd56ea9ec8890b09705ddc275ad60405160405180910390a250565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611827576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161181e90614b57565b60405180910390fd5b80915050919050565b6000600f543414611876576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186d90614aeb565b60405180910390fd5b6000611881846123ec565b905061188d8130612a2b565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638a4315788285600067ffffffffffffffff8111156118e8576118e7613db2565b5b6040519080825280602002602001820160405280156119165781602001602082028036833780820191505090505b506040518463ffffffff1660e01b815260040161193593929190614c35565b600060405180830381600087803b15801561194f57600080fd5b505af1158015611963573d6000803e3d6000fd5b50505050611970816128a2565b8091505092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036119ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119e190614cec565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611a39612529565b611a436000612b97565b565b611a4d612529565b80600f819055507f653b8b44976b2e5c016e082d134653d04dea9dbef92055038cca38c93007035581604051611a839190613bfb565b60405180910390a150565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b606060018054611aed906142be565b80601f0160208091040260200160405190810160405280929190818152602001828054611b19906142be565b8015611b665780601f10611b3b57610100808354040283529160200191611b66565b820191906000526020600020905b815481529060010190602001808311611b4957829003601f168201915b5050505050905090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611ba8611ba161232b565b8383612c5d565b5050565b611bbd611bb761232b565b836125a7565b611bfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf390614523565b60405180910390fd5b611c0884848484612dc9565b50505050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bd4986a0836040518263ffffffff1660e01b8152600401611c919190613bfb565b602060405180830381865afa158015611cae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd29190614d21565b9050919050565b600f5481565b6060611d1f6040518060400160405280601181526020017f67657474696e6720746f6b656e20757269000000000000000000000000000000815250612e25565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ef6fd878846040518263ffffffff1660e01b8152600401611d7c9190613bfb565b600060405180830381865afa158015611d99573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611dc29190614dbe565b9050611e026040518060400160405280601f81526020017f676f74207075626b65792c2067657474696e6720657468206164647265737300815250612e25565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bd4986a0856040518263ffffffff1660e01b8152600401611e5f9190613bfb565b602060405180830381865afa158015611e7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea09190614d21565b9050611ee06040518060400160405280601081526020017f63616c6c696e6720746f6b656e55524900000000000000000000000000000000815250612e25565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663950462ee8584846040518463ffffffff1660e01b8152600401611f3f93929190614e07565b600060405180830381865afa158015611f5c573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611f859190614ee6565b92505050919050565b611f96612529565b611fa08133612a2b565b50565b600080611faf896123ec565b9050611fc088828989898989612ebe565b80915050979650505050505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6060600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ef6fd878836040518263ffffffff1660e01b81526004016120c09190613bfb565b600060405180830381865afa1580156120dd573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906121069190614dbe565b9050919050565b612115612529565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612184576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161217b90614fa1565b60405180910390fd5b61218d81612b97565b50565b612198612529565b6121a28230612a2b565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638a4315788383600067ffffffffffffffff8111156121fd576121fc613db2565b5b60405190808252806020026020018201604052801561222b5781602001602082028036833780820191505090505b506040518463ffffffff1660e01b815260040161224a93929190614c35565b600060405180830381600087803b15801561226457600080fd5b505af1158015612278573d6000803e3d6000fd5b50505050612285826128a2565b5050565b601160205281600052604060002081815481106122a557600080fd5b90600052602060002001600091509150505481565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6122e9816129bf565b612328576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161231f90614b57565b60405180910390fd5b50565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166123a68361177f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080601160008481526020019081526020016000208054905011612446576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161243d90615033565b60405180910390fd5b6000601160008481526020019081526020016000206001601160008681526020019081526020016000208054905061247e9190615082565b8154811061248f5761248e6149de565b5b90600052602060002001549050601160008481526020019081526020016000208054806124bf576124be6150b6565b5b6001900381819060005260206000200160009055905580915050919050565b6124eb8685858585611321565b6124f58533612a2b565b60016012600088815260200190815260200160002060006101000a81548160ff021916908315150217905550505050505050565b61253161232b565b73ffffffffffffffffffffffffffffffffffffffff1661254f611a8e565b73ffffffffffffffffffffffffffffffffffffffff16146125a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161259c90615131565b60405180910390fd5b565b6000806125b38361177f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806125f557506125f48185611fcf565b5b8061263357508373ffffffffffffffffffffffffffffffffffffffff1661261b84610cfc565b73ffffffffffffffffffffffffffffffffffffffff16145b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661265c8261177f565b73ffffffffffffffffffffffffffffffffffffffff16146126b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126a9906151c3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612721576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161271890615255565b60405180910390fd5b61272c838383612fed565b612737600082612333565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546127879190615082565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546127de9190615275565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461289d838383612ffd565b505050565b60006128ad8261177f565b90506128bb81600084612fed565b6128c6600083612333565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129169190615082565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46129bb81600084612ffd565b5050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166301c6d035836040518263ffffffff1660e01b8152600401612a869190613bfb565b602060405180830381865afa158015612aa3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ac791906152be565b612b06576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612afd90615337565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612b4857612b438183613002565b612b53565b612b5281836131db565b5b817f3b2cc0657d0387a736293d66389f78e4c8025e413c7a1ee67b7707d4418c46b8612b7e84612063565b604051612b8b9190614231565b60405180910390a25050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603612ccb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cc2906153a3565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051612dbc91906138f8565b60405180910390a3505050565b612dd484848461263c565b612de0848484846131f9565b612e1f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e1690615435565b60405180910390fd5b50505050565b612ebb81604051602401612e3991906139a3565b6040516020818303038152906040527f41304fac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613380565b50565b612ecb8785858585611321565b612ed58630612a2b565b60016012600089815260200190815260200160002060006101000a81548160ff021916908315150217905550600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638a4315788787600067ffffffffffffffff811115612f5c57612f5b613db2565b5b604051908082528060200260200182016040528015612f8a5781602001602082028036833780820191505090505b506040518463ffffffff1660e01b8152600401612fa993929190614c35565b600060405180830381600087803b158015612fc357600080fd5b505af1158015612fd7573d6000803e3d6000fd5b50505050612fe4866128a2565b50505050505050565b612ff88383836133a9565b505050565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613071576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613068906154a1565b60405180910390fd5b61307a816129bf565b156130ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130b19061550d565b60405180910390fd5b6130c660008383612fed565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546131169190615275565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46131d760008383612ffd565b5050565b6131f58282604051806020016040528060008152506134bb565b5050565b600061321a8473ffffffffffffffffffffffffffffffffffffffff16613516565b15613373578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261324361232b565b8786866040518563ffffffff1660e01b8152600401613265949392919061552d565b6020604051808303816000875af19250505080156132a157506040513d601f19601f8201168201806040525081019061329e919061558e565b60015b613323573d80600081146132d1576040519150601f19603f3d011682016040523d82523d6000602084013e6132d6565b606091505b50600081510361331b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161331290615435565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613378565b600190505b949350505050565b60008151905060006a636f6e736f6c652e6c6f679050602083016000808483855afa5050505050565b6133b4838383613539565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036133f6576133f18161353e565b613435565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614613434576134338382613587565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361347757613472816136f4565b6134b6565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146134b5576134b482826137c5565b5b5b505050565b6134c58383613002565b6134d260008484846131f9565b613511576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161350890615435565b60405180910390fd5b505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b505050565b600980549050600a600083815260200190815260200160002081905550600981908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016135948461197a565b61359e9190615082565b9050600060086000848152602001908152602001600020549050818114613683576000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816008600083815260200190815260200160002081905550505b6008600084815260200190815260200160002060009055600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016009805490506137089190615082565b90506000600a6000848152602001908152602001600020549050600060098381548110613738576137376149de565b5b90600052602060002001549050806009838154811061375a576137596149de565b5b906000526020600020018190555081600a600083815260200190815260200160002081905550600a60008581526020019081526020016000206000905560098054806137a9576137a86150b6565b5b6001900381819060005260206000200160009055905550505050565b60006137d08361197a565b905081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806008600084815260200190815260200160002081905550505050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61388d81613858565b811461389857600080fd5b50565b6000813590506138aa81613884565b92915050565b6000602082840312156138c6576138c561384e565b5b60006138d48482850161389b565b91505092915050565b60008115159050919050565b6138f2816138dd565b82525050565b600060208201905061390d60008301846138e9565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561394d578082015181840152602081019050613932565b60008484015250505050565b6000601f19601f8301169050919050565b600061397582613913565b61397f818561391e565b935061398f81856020860161392f565b61399881613959565b840191505092915050565b600060208201905081810360008301526139bd818461396a565b905092915050565b6000819050919050565b6139d8816139c5565b81146139e357600080fd5b50565b6000813590506139f5816139cf565b92915050565b600060208284031215613a1157613a1061384e565b5b6000613a1f848285016139e6565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613a5382613a28565b9050919050565b613a6381613a48565b82525050565b6000602082019050613a7e6000830184613a5a565b92915050565b613a8d81613a48565b8114613a9857600080fd5b50565b600081359050613aaa81613a84565b92915050565b60008060408385031215613ac757613ac661384e565b5b6000613ad585828601613a9b565b9250506020613ae6858286016139e6565b9150509250929050565b6000819050919050565b613b0381613af0565b8114613b0e57600080fd5b50565b600081359050613b2081613afa565b92915050565b600060ff82169050919050565b613b3c81613b26565b8114613b4757600080fd5b50565b600081359050613b5981613b33565b92915050565b60008060008060008060c08789031215613b7c57613b7b61384e565b5b6000613b8a89828a016139e6565b9650506020613b9b89828a016139e6565b9550506040613bac89828a01613b11565b9450506060613bbd89828a01613b4a565b9350506080613bce89828a01613b11565b92505060a0613bdf89828a01613b11565b9150509295509295509295565b613bf5816139c5565b82525050565b6000602082019050613c106000830184613bec565b92915050565b600060208284031215613c2c57613c2b61384e565b5b6000613c3a84828501613a9b565b91505092915050565b600060208284031215613c5957613c5861384e565b5b6000613c6784828501613b11565b91505092915050565b613c7981613af0565b82525050565b6000602082019050613c946000830184613c70565b92915050565b600080600060608486031215613cb357613cb261384e565b5b6000613cc186828701613a9b565b9350506020613cd286828701613a9b565b9250506040613ce3868287016139e6565b9150509250925092565b600080600080600060a08688031215613d0957613d0861384e565b5b6000613d17888289016139e6565b9550506020613d2888828901613b11565b9450506040613d3988828901613b4a565b9350506060613d4a88828901613b11565b9250506080613d5b88828901613b11565b9150509295509295909350565b60008060408385031215613d7f57613d7e61384e565b5b6000613d8d858286016139e6565b9250506020613d9e858286016139e6565b9150509250929050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b613dea82613959565b810181811067ffffffffffffffff82111715613e0957613e08613db2565b5b80604052505050565b6000613e1c613844565b9050613e288282613de1565b919050565b600067ffffffffffffffff821115613e4857613e47613db2565b5b613e5182613959565b9050602081019050919050565b82818337600083830152505050565b6000613e80613e7b84613e2d565b613e12565b905082815260208101848484011115613e9c57613e9b613dad565b5b613ea7848285613e5e565b509392505050565b600082601f830112613ec457613ec3613da8565b5b8135613ed4848260208601613e6d565b91505092915050565b60008060408385031215613ef457613ef361384e565b5b6000613f02858286016139e6565b925050602083013567ffffffffffffffff811115613f2357613f22613853565b5b613f2f85828601613eaf565b9150509250929050565b6000819050919050565b6000613f5e613f59613f5484613a28565b613f39565b613a28565b9050919050565b6000613f7082613f43565b9050919050565b6000613f8282613f65565b9050919050565b613f9281613f77565b82525050565b6000602082019050613fad6000830184613f89565b92915050565b6000613fbe82613f65565b9050919050565b613fce81613fb3565b82525050565b6000602082019050613fe96000830184613fc5565b92915050565b613ff8816138dd565b811461400357600080fd5b50565b60008135905061401581613fef565b92915050565b600080604083850312156140325761403161384e565b5b600061404085828601613a9b565b925050602061405185828601614006565b9150509250929050565b600080600080608085870312156140755761407461384e565b5b600061408387828801613a9b565b945050602061409487828801613a9b565b93505060406140a5878288016139e6565b925050606085013567ffffffffffffffff8111156140c6576140c5613853565b5b6140d287828801613eaf565b91505092959194509250565b600080600080600080600060e0888a0312156140fd576140fc61384e565b5b600061410b8a828b016139e6565b975050602061411c8a828b016139e6565b965050604088013567ffffffffffffffff81111561413d5761413c613853565b5b6141498a828b01613eaf565b955050606061415a8a828b01613b11565b945050608061416b8a828b01613b4a565b93505060a061417c8a828b01613b11565b92505060c061418d8a828b01613b11565b91505092959891949750929550565b600080604083850312156141b3576141b261384e565b5b60006141c185828601613a9b565b92505060206141d285828601613a9b565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000614203826141dc565b61420d81856141e7565b935061421d81856020860161392f565b61422681613959565b840191505092915050565b6000602082019050818103600083015261424b81846141f8565b905092915050565b600061425e82613f65565b9050919050565b61426e81614253565b82525050565b60006020820190506142896000830184614265565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806142d657607f821691505b6020821081036142e9576142e861428f565b5b50919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b600061434b60218361391e565b9150614356826142ef565b604082019050919050565b6000602082019050818103600083015261437a8161433e565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60008201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c0000602082015250565b60006143dd603e8361391e565b91506143e882614381565b604082019050919050565b6000602082019050818103600083015261440c816143d0565b9050919050565b600081905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b6000614454601c83614413565b915061445f8261441e565b601c82019050919050565b6000819050919050565b61448561448082613af0565b61446a565b82525050565b600061449682614447565b91506144a28284614474565b60208201915081905092915050565b7f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560008201527f72206e6f7220617070726f766564000000000000000000000000000000000000602082015250565b600061450d602e8361391e565b9150614518826144b1565b604082019050919050565b6000602082019050818103600083015261453c81614500565b9050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b600061459f602b8361391e565b91506145aa82614543565b604082019050919050565b600060208201905081810360008301526145ce81614592565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b600061460b601f8361391e565b9150614616826145d5565b602082019050919050565b6000602082019050818103600083015261463a816145fe565b9050919050565b600081905092915050565b50565b600061465c600083614641565b91506146678261464c565b600082019050919050565b600061467d8261464f565b9150819050919050565b60008160601b9050919050565b600061469f82614687565b9050919050565b60006146b182614694565b9050919050565b6146c96146c482613a48565b6146a6565b82525050565b6000819050919050565b6146ea6146e5826139c5565b6146cf565b82525050565b60006146fc82856146b8565b60148201915061470c82846146d9565b6020820191508190509392505050565b7f546865206d736748617368206973206e6f7420612068617368206f662074686560008201527f20746f6b656e49642e20204578706c61696e20796f757273656c662100000000602082015250565b6000614778603c8361391e565b91506147838261471c565b604082019050919050565b600060208201905081810360008301526147a78161476b565b9050919050565b6147b781613b26565b82525050565b60006080820190506147d26000830187613c70565b6147df60208301866147ae565b6147ec6040830185613c70565b6147f96060830184613c70565b95945050505050565b7f5468697320667265654d696e7420776173206e6f74207369676e65642062792060008201527f667265654d696e745369676e65722e2020486f7720656d626172617373696e6760208201527f2e00000000000000000000000000000000000000000000000000000000000000604082015250565b600061488460418361391e565b915061488f82614802565b606082019050919050565b600060208201905081810360008301526148b381614877565b9050919050565b7f546869732066726565206d696e742049442068617320616c726561647920626560008201527f656e2072656465656d6564000000000000000000000000000000000000000000602082015250565b6000614916602b8361391e565b9150614921826148ba565b604082019050919050565b6000602082019050818103600083015261494581614909565b9050919050565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b60006149a8602c8361391e565b91506149b38261494c565b604082019050919050565b600060208201905081810360008301526149d78161499b565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4f6e6c792074686520726f7574696e6720636f6e74726163742063616e20636160008201527f6c6c20746869732066756e6374696f6e00000000000000000000000000000000602082015250565b6000614a6960308361391e565b9150614a7482614a0d565b604082019050919050565b60006020820190508181036000830152614a9881614a5c565b9050919050565b7f596f75206d757374207061792065786163746c79206d696e7420636f73740000600082015250565b6000614ad5601e8361391e565b9150614ae082614a9f565b602082019050919050565b60006020820190508181036000830152614b0481614ac8565b9050919050565b7f4552433732313a20696e76616c696420746f6b656e2049440000000000000000600082015250565b6000614b4160188361391e565b9150614b4c82614b0b565b602082019050919050565b60006020820190508181036000830152614b7081614b34565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614bac816139c5565b82525050565b6000614bbe8383614ba3565b60208301905092915050565b6000602082019050919050565b6000614be282614b77565b614bec8185614b82565b9350614bf783614b93565b8060005b83811015614c28578151614c0f8882614bb2565b9750614c1a83614bca565b925050600181019050614bfb565b5085935050505092915050565b6000606082019050614c4a6000830186613bec565b8181036020830152614c5c81856141f8565b90508181036040830152614c708184614bd7565b9050949350505050565b7f4552433732313a2061646472657373207a65726f206973206e6f74206120766160008201527f6c6964206f776e65720000000000000000000000000000000000000000000000602082015250565b6000614cd660298361391e565b9150614ce182614c7a565b604082019050919050565b60006020820190508181036000830152614d0581614cc9565b9050919050565b600081519050614d1b81613a84565b92915050565b600060208284031215614d3757614d3661384e565b5b6000614d4584828501614d0c565b91505092915050565b6000614d61614d5c84613e2d565b613e12565b905082815260208101848484011115614d7d57614d7c613dad565b5b614d8884828561392f565b509392505050565b600082601f830112614da557614da4613da8565b5b8151614db5848260208601614d4e565b91505092915050565b600060208284031215614dd457614dd361384e565b5b600082015167ffffffffffffffff811115614df257614df1613853565b5b614dfe84828501614d90565b91505092915050565b6000606082019050614e1c6000830186613bec565b8181036020830152614e2e81856141f8565b9050614e3d6040830184613a5a565b949350505050565b600067ffffffffffffffff821115614e6057614e5f613db2565b5b614e6982613959565b9050602081019050919050565b6000614e89614e8484614e45565b613e12565b905082815260208101848484011115614ea557614ea4613dad565b5b614eb084828561392f565b509392505050565b600082601f830112614ecd57614ecc613da8565b5b8151614edd848260208601614e76565b91505092915050565b600060208284031215614efc57614efb61384e565b5b600082015167ffffffffffffffff811115614f1a57614f19613853565b5b614f2684828501614eb8565b91505092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614f8b60268361391e565b9150614f9682614f2f565b604082019050919050565b60006020820190508181036000830152614fba81614f7e565b9050919050565b7f546865726520617265206e6f20756e6d696e74656420726f7574656420746f6b60008201527f656e2069647320746f206d696e74000000000000000000000000000000000000602082015250565b600061501d602e8361391e565b915061502882614fc1565b604082019050919050565b6000602082019050818103600083015261504c81615010565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061508d826139c5565b9150615098836139c5565b92508282039050818111156150b0576150af615053565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061511b60208361391e565b9150615126826150e5565b602082019050919050565b6000602082019050818103600083015261514a8161510e565b9050919050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b60006151ad60258361391e565b91506151b882615151565b604082019050919050565b600060208201905081810360008301526151dc816151a0565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061523f60248361391e565b915061524a826151e3565b604082019050919050565b6000602082019050818103600083015261526e81615232565b9050919050565b6000615280826139c5565b915061528b836139c5565b92508282019050808211156152a3576152a2615053565b5b92915050565b6000815190506152b881613fef565b92915050565b6000602082840312156152d4576152d361384e565b5b60006152e2848285016152a9565b91505092915050565b7f5468697320504b5020686173206e6f74206265656e20726f7574656420796574600082015250565b600061532160208361391e565b915061532c826152eb565b602082019050919050565b6000602082019050818103600083015261535081615314565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b600061538d60198361391e565b915061539882615357565b602082019050919050565b600060208201905081810360008301526153bc81615380565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b600061541f60328361391e565b915061542a826153c3565b604082019050919050565b6000602082019050818103600083015261544e81615412565b9050919050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b600061548b60208361391e565b915061549682615455565b602082019050919050565b600060208201905081810360008301526154ba8161547e565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b60006154f7601c8361391e565b9150615502826154c1565b602082019050919050565b60006020820190508181036000830152615526816154ea565b9050919050565b60006080820190506155426000830187613a5a565b61554f6020830186613a5a565b61555c6040830185613bec565b818103606083015261556e81846141f8565b905095945050505050565b60008151905061558881613884565b92915050565b6000602082840312156155a4576155a361384e565b5b60006155b284828501615579565b9150509291505056fea2646970667358221220bd6bb2ed401a16bcfd00c782929a940c7d3ff9a77b1cf7a6d340282860df0f1264736f6c63430008110033
Deployed ByteCode
0x60806040526004361061027d5760003560e01c80636352211e1161014f578063b94a2102116100c1578063e985e9c51161007a578063e985e9c5146109fc578063ef6fd87814610a39578063f2fde38b14610a76578063f556aeb114610a9f578063f70e72ef14610ac8578063f887ea4014610b055761027d565b8063b94a2102146108c6578063bd4986a0146108f1578063bdb4b8481461092e578063c87b56dd14610959578063d343682614610996578063d7b0398b146109bf5761027d565b80638da5cb5b116101135780638da5cb5b146107c85780639388f12e146107f357806395d89b411461081e57806397016f3f14610849578063a22cb46514610874578063b88d4fde1461089d5761027d565b80636352211e146106de57806366a306d71461071b57806370a082311461074b578063715018a6146107885780638545f4ea1461079f5761027d565b80633ccfd60b116101f35780634f558e79116101ac5780634f558e79146105a55780634f6ccce7146105e257806356e3a1ae1461061f5780635c110a9c1461065c5780635d228b16146106855780635f49663c146106b55761027d565b80633ccfd60b146104ad57806341cb87fc146104c457806342842e0e146104ed57806342966c681461051657806342dd8fcb1461053f5780634c19eae61461057c5761027d565b806318160ddd1161024557806318160ddd1461038d5780631ea89a22146103b85780631f275713146103e157806323b872dd1461041e5780632f745c59146104475780633b189852146104845761027d565b806301ffc9a71461028257806306fdde03146102bf578063081812fc146102ea578063095ea7b3146103275780631582391c14610350575b600080fd5b34801561028e57600080fd5b506102a960048036038101906102a491906138b0565b610b30565b6040516102b691906138f8565b60405180910390f35b3480156102cb57600080fd5b506102d4610c6a565b6040516102e191906139a3565b60405180910390f35b3480156102f657600080fd5b50610311600480360381019061030c91906139fb565b610cfc565b60405161031e9190613a69565b60405180910390f35b34801561033357600080fd5b5061034e60048036038101906103499190613ab0565b610d42565b005b34801561035c57600080fd5b5061037760048036038101906103729190613b5f565b610e59565b6040516103849190613bfb565b60405180910390f35b34801561039957600080fd5b506103a2610e83565b6040516103af9190613bfb565b60405180910390f35b3480156103c457600080fd5b506103df60048036038101906103da9190613c16565b610e90565b005b3480156103ed57600080fd5b5061040860048036038101906104039190613c43565b610f1f565b6040516104159190613c7f565b60405180910390f35b34801561042a57600080fd5b5061044560048036038101906104409190613c9a565b610f4f565b005b34801561045357600080fd5b5061046e60048036038101906104699190613ab0565b610faf565b60405161047b9190613bfb565b60405180910390f35b34801561049057600080fd5b506104ab60048036038101906104a69190613c16565b611054565b005b3480156104b957600080fd5b506104c26110e3565b005b3480156104d057600080fd5b506104eb60048036038101906104e69190613c16565b6111f6565b005b3480156104f957600080fd5b50610514600480360381019061050f9190613c9a565b611285565b005b34801561052257600080fd5b5061053d600480360381019061053891906139fb565b6112a5565b005b34801561054b57600080fd5b50610566600480360381019061056191906139fb565b611301565b6040516105739190613bfb565b60405180910390f35b34801561058857600080fd5b506105a3600480360381019061059e9190613ced565b611321565b005b3480156105b157600080fd5b506105cc60048036038101906105c791906139fb565b6114eb565b6040516105d991906138f8565b60405180910390f35b3480156105ee57600080fd5b50610609600480360381019061060491906139fb565b6114fd565b6040516106169190613bfb565b60405180910390f35b34801561062b57600080fd5b50610646600480360381019061064191906139fb565b61156e565b60405161065391906138f8565b60405180910390f35b34801561066857600080fd5b50610683600480360381019061067e9190613d68565b61158e565b005b61069f600480360381019061069a91906139fb565b61168a565b6040516106ac9190613bfb565b60405180910390f35b3480156106c157600080fd5b506106dc60048036038101906106d79190613c16565b6116f0565b005b3480156106ea57600080fd5b50610705600480360381019061070091906139fb565b61177f565b6040516107129190613a69565b60405180910390f35b61073560048036038101906107309190613edd565b611830565b6040516107429190613bfb565b60405180910390f35b34801561075757600080fd5b50610772600480360381019061076d9190613c16565b61197a565b60405161077f9190613bfb565b60405180910390f35b34801561079457600080fd5b5061079d611a31565b005b3480156107ab57600080fd5b506107c660048036038101906107c191906139fb565b611a45565b005b3480156107d457600080fd5b506107dd611a8e565b6040516107ea9190613a69565b60405180910390f35b3480156107ff57600080fd5b50610808611ab8565b6040516108159190613f98565b60405180910390f35b34801561082a57600080fd5b50610833611ade565b60405161084091906139a3565b60405180910390f35b34801561085557600080fd5b5061085e611b70565b60405161086b9190613fd4565b60405180910390f35b34801561088057600080fd5b5061089b6004803603810190610896919061401b565b611b96565b005b3480156108a957600080fd5b506108c460048036038101906108bf919061405b565b611bac565b005b3480156108d257600080fd5b506108db611c0e565b6040516108e89190613a69565b60405180910390f35b3480156108fd57600080fd5b50610918600480360381019061091391906139fb565b611c34565b6040516109259190613a69565b60405180910390f35b34801561093a57600080fd5b50610943611cd9565b6040516109509190613bfb565b60405180910390f35b34801561096557600080fd5b50610980600480360381019061097b91906139fb565b611cdf565b60405161098d91906139a3565b60405180910390f35b3480156109a257600080fd5b506109bd60048036038101906109b891906139fb565b611f8e565b005b3480156109cb57600080fd5b506109e660048036038101906109e191906140de565b611fa3565b6040516109f39190613bfb565b60405180910390f35b348015610a0857600080fd5b50610a236004803603810190610a1e919061419c565b611fcf565b604051610a3091906138f8565b60405180910390f35b348015610a4557600080fd5b50610a606004803603810190610a5b91906139fb565b612063565b604051610a6d9190614231565b60405180910390f35b348015610a8257600080fd5b50610a9d6004803603810190610a989190613c16565b61210d565b005b348015610aab57600080fd5b50610ac66004803603810190610ac19190613edd565b612190565b005b348015610ad457600080fd5b50610aef6004803603810190610aea9190613d68565b612289565b604051610afc9190613bfb565b60405180910390f35b348015610b1157600080fd5b50610b1a6122ba565b604051610b279190614274565b60405180910390f35b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610bfb57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610c6357507f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b606060008054610c79906142be565b80601f0160208091040260200160405190810160405280929190818152602001828054610ca5906142be565b8015610cf25780601f10610cc757610100808354040283529160200191610cf2565b820191906000526020600020905b815481529060010190602001808311610cd557829003601f168201915b5050505050905090565b6000610d07826122e0565b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610d4d8261177f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610dbd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db490614361565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610ddc61232b565b73ffffffffffffffffffffffffffffffffffffffff161480610e0b5750610e0a81610e0561232b565b611fcf565b5b610e4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e41906143f3565b60405180910390fd5b610e548383612333565b505050565b600080610e65886123ec565b9050610e758782888888886124de565b809150509695505050505050565b6000600980549050905090565b610e98612529565b80600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f42d2ac2cd8a457cf976d513bacdc167baa2ff2cd2706c98d222bb035b89d496960405160405180910390a250565b600081604051602001610f32919061448b565b604051602081830303815290604052805190602001209050919050565b610f60610f5a61232b565b826125a7565b610f9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9690614523565b60405180910390fd5b610faa83838361263c565b505050565b6000610fba8361197a565b8210610ffb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ff2906145b5565b60405180910390fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b61105c612529565b80601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f65d3e06a561c77a07da59b8b2ca10214ae08fe21cc2953a90db0ac8b5b7c437160405160405180910390a250565b6110eb612529565b6002600b5403611130576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112790614621565b60405180910390fd5b6002600b81905550600047905060003373ffffffffffffffffffffffffffffffffffffffff168260405161116390614672565b60006040518083038185875af1925050503d80600081146111a0576040519150601f19603f3d011682016040523d82523d6000602084013e6111a5565b606091505b50509050806111b357600080fd5b7fb6b476da71cea8275cac6b1720c04966afaff5e637472cedb6cbd32c43a23251826040516111e29190613bfb565b60405180910390a150506001600b81905550565b6111fe612529565b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f8da1c48aefffe2a2520f3e707937e3254d532a0905d345e539532599d2a0564c60405160405180910390a250565b6112a083838360405180602001604052806000815250611bac565b505050565b6112b66112b061232b565b826125a7565b6112f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ec90614523565b60405180910390fd5b6112fe816128a2565b50565b600060116000838152602001908152602001600020805490509050919050565b600061135430876040516020016113399291906146f0565b60405160208183030381529060405280519060200120610f1f565b9050848114611398576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138f9061478e565b60405180910390fd5b6000600186868686604051600081526020016040526040516113bd94939291906147bd565b6020604051602081039080840390855afa1580156113df573d6000803e3d6000fd5b505050602060405103519050601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461147b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114729061489a565b60405180910390fd5b600015156012600089815260200190815260200160002060009054906101000a900460ff161515146114e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d99061492c565b60405180910390fd5b50505050505050565b60006114f6826129bf565b9050919050565b6000611507610e83565b8210611548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153f906149be565b60405180910390fd5b6009828154811061155c5761155b6149de565b5b90600052602060002001549050919050565b60126020528060005260406000206000915054906101000a900460ff1681565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461161e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161590614a7f565b60405180910390fd5b6011600082815260200190815260200160002082908060018154018082558091505060019003906000526020600020016000909190919091505580827f67c5bcaefda7c1381ded3fc61dbb8e693cef5b368cd356324bcc2b1aa791448c60405160405180910390a35050565b6000600f5434146116d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c790614aeb565b60405180910390fd5b60006116db836123ec565b90506116e78133612a2b565b80915050919050565b6116f8612529565b80600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f446c3422d569626abc16e1497dfa8270f1192bd56ea9ec8890b09705ddc275ad60405160405180910390a250565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611827576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161181e90614b57565b60405180910390fd5b80915050919050565b6000600f543414611876576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186d90614aeb565b60405180910390fd5b6000611881846123ec565b905061188d8130612a2b565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638a4315788285600067ffffffffffffffff8111156118e8576118e7613db2565b5b6040519080825280602002602001820160405280156119165781602001602082028036833780820191505090505b506040518463ffffffff1660e01b815260040161193593929190614c35565b600060405180830381600087803b15801561194f57600080fd5b505af1158015611963573d6000803e3d6000fd5b50505050611970816128a2565b8091505092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036119ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119e190614cec565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611a39612529565b611a436000612b97565b565b611a4d612529565b80600f819055507f653b8b44976b2e5c016e082d134653d04dea9dbef92055038cca38c93007035581604051611a839190613bfb565b60405180910390a150565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b606060018054611aed906142be565b80601f0160208091040260200160405190810160405280929190818152602001828054611b19906142be565b8015611b665780601f10611b3b57610100808354040283529160200191611b66565b820191906000526020600020905b815481529060010190602001808311611b4957829003601f168201915b5050505050905090565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611ba8611ba161232b565b8383612c5d565b5050565b611bbd611bb761232b565b836125a7565b611bfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf390614523565b60405180910390fd5b611c0884848484612dc9565b50505050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bd4986a0836040518263ffffffff1660e01b8152600401611c919190613bfb565b602060405180830381865afa158015611cae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd29190614d21565b9050919050565b600f5481565b6060611d1f6040518060400160405280601181526020017f67657474696e6720746f6b656e20757269000000000000000000000000000000815250612e25565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ef6fd878846040518263ffffffff1660e01b8152600401611d7c9190613bfb565b600060405180830381865afa158015611d99573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611dc29190614dbe565b9050611e026040518060400160405280601f81526020017f676f74207075626b65792c2067657474696e6720657468206164647265737300815250612e25565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bd4986a0856040518263ffffffff1660e01b8152600401611e5f9190613bfb565b602060405180830381865afa158015611e7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea09190614d21565b9050611ee06040518060400160405280601081526020017f63616c6c696e6720746f6b656e55524900000000000000000000000000000000815250612e25565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663950462ee8584846040518463ffffffff1660e01b8152600401611f3f93929190614e07565b600060405180830381865afa158015611f5c573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611f859190614ee6565b92505050919050565b611f96612529565b611fa08133612a2b565b50565b600080611faf896123ec565b9050611fc088828989898989612ebe565b80915050979650505050505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6060600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ef6fd878836040518263ffffffff1660e01b81526004016120c09190613bfb565b600060405180830381865afa1580156120dd573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906121069190614dbe565b9050919050565b612115612529565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612184576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161217b90614fa1565b60405180910390fd5b61218d81612b97565b50565b612198612529565b6121a28230612a2b565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638a4315788383600067ffffffffffffffff8111156121fd576121fc613db2565b5b60405190808252806020026020018201604052801561222b5781602001602082028036833780820191505090505b506040518463ffffffff1660e01b815260040161224a93929190614c35565b600060405180830381600087803b15801561226457600080fd5b505af1158015612278573d6000803e3d6000fd5b50505050612285826128a2565b5050565b601160205281600052604060002081815481106122a557600080fd5b90600052602060002001600091509150505481565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6122e9816129bf565b612328576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161231f90614b57565b60405180910390fd5b50565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166123a68361177f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080601160008481526020019081526020016000208054905011612446576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161243d90615033565b60405180910390fd5b6000601160008481526020019081526020016000206001601160008681526020019081526020016000208054905061247e9190615082565b8154811061248f5761248e6149de565b5b90600052602060002001549050601160008481526020019081526020016000208054806124bf576124be6150b6565b5b6001900381819060005260206000200160009055905580915050919050565b6124eb8685858585611321565b6124f58533612a2b565b60016012600088815260200190815260200160002060006101000a81548160ff021916908315150217905550505050505050565b61253161232b565b73ffffffffffffffffffffffffffffffffffffffff1661254f611a8e565b73ffffffffffffffffffffffffffffffffffffffff16146125a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161259c90615131565b60405180910390fd5b565b6000806125b38361177f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806125f557506125f48185611fcf565b5b8061263357508373ffffffffffffffffffffffffffffffffffffffff1661261b84610cfc565b73ffffffffffffffffffffffffffffffffffffffff16145b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661265c8261177f565b73ffffffffffffffffffffffffffffffffffffffff16146126b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126a9906151c3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612721576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161271890615255565b60405180910390fd5b61272c838383612fed565b612737600082612333565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546127879190615082565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546127de9190615275565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461289d838383612ffd565b505050565b60006128ad8261177f565b90506128bb81600084612fed565b6128c6600083612333565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129169190615082565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46129bb81600084612ffd565b5050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166301c6d035836040518263ffffffff1660e01b8152600401612a869190613bfb565b602060405180830381865afa158015612aa3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ac791906152be565b612b06576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612afd90615337565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612b4857612b438183613002565b612b53565b612b5281836131db565b5b817f3b2cc0657d0387a736293d66389f78e4c8025e413c7a1ee67b7707d4418c46b8612b7e84612063565b604051612b8b9190614231565b60405180910390a25050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603612ccb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cc2906153a3565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051612dbc91906138f8565b60405180910390a3505050565b612dd484848461263c565b612de0848484846131f9565b612e1f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e1690615435565b60405180910390fd5b50505050565b612ebb81604051602401612e3991906139a3565b6040516020818303038152906040527f41304fac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613380565b50565b612ecb8785858585611321565b612ed58630612a2b565b60016012600089815260200190815260200160002060006101000a81548160ff021916908315150217905550600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638a4315788787600067ffffffffffffffff811115612f5c57612f5b613db2565b5b604051908082528060200260200182016040528015612f8a5781602001602082028036833780820191505090505b506040518463ffffffff1660e01b8152600401612fa993929190614c35565b600060405180830381600087803b158015612fc357600080fd5b505af1158015612fd7573d6000803e3d6000fd5b50505050612fe4866128a2565b50505050505050565b612ff88383836133a9565b505050565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613071576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613068906154a1565b60405180910390fd5b61307a816129bf565b156130ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130b19061550d565b60405180910390fd5b6130c660008383612fed565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546131169190615275565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46131d760008383612ffd565b5050565b6131f58282604051806020016040528060008152506134bb565b5050565b600061321a8473ffffffffffffffffffffffffffffffffffffffff16613516565b15613373578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261324361232b565b8786866040518563ffffffff1660e01b8152600401613265949392919061552d565b6020604051808303816000875af19250505080156132a157506040513d601f19601f8201168201806040525081019061329e919061558e565b60015b613323573d80600081146132d1576040519150601f19603f3d011682016040523d82523d6000602084013e6132d6565b606091505b50600081510361331b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161331290615435565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613378565b600190505b949350505050565b60008151905060006a636f6e736f6c652e6c6f679050602083016000808483855afa5050505050565b6133b4838383613539565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036133f6576133f18161353e565b613435565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614613434576134338382613587565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361347757613472816136f4565b6134b6565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146134b5576134b482826137c5565b5b5b505050565b6134c58383613002565b6134d260008484846131f9565b613511576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161350890615435565b60405180910390fd5b505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b505050565b600980549050600a600083815260200190815260200160002081905550600981908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016135948461197a565b61359e9190615082565b9050600060086000848152602001908152602001600020549050818114613683576000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816008600083815260200190815260200160002081905550505b6008600084815260200190815260200160002060009055600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016009805490506137089190615082565b90506000600a6000848152602001908152602001600020549050600060098381548110613738576137376149de565b5b90600052602060002001549050806009838154811061375a576137596149de565b5b906000526020600020018190555081600a600083815260200190815260200160002081905550600a60008581526020019081526020016000206000905560098054806137a9576137a86150b6565b5b6001900381819060005260206000200160009055905550505050565b60006137d08361197a565b905081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806008600084815260200190815260200160002081905550505050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61388d81613858565b811461389857600080fd5b50565b6000813590506138aa81613884565b92915050565b6000602082840312156138c6576138c561384e565b5b60006138d48482850161389b565b91505092915050565b60008115159050919050565b6138f2816138dd565b82525050565b600060208201905061390d60008301846138e9565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561394d578082015181840152602081019050613932565b60008484015250505050565b6000601f19601f8301169050919050565b600061397582613913565b61397f818561391e565b935061398f81856020860161392f565b61399881613959565b840191505092915050565b600060208201905081810360008301526139bd818461396a565b905092915050565b6000819050919050565b6139d8816139c5565b81146139e357600080fd5b50565b6000813590506139f5816139cf565b92915050565b600060208284031215613a1157613a1061384e565b5b6000613a1f848285016139e6565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613a5382613a28565b9050919050565b613a6381613a48565b82525050565b6000602082019050613a7e6000830184613a5a565b92915050565b613a8d81613a48565b8114613a9857600080fd5b50565b600081359050613aaa81613a84565b92915050565b60008060408385031215613ac757613ac661384e565b5b6000613ad585828601613a9b565b9250506020613ae6858286016139e6565b9150509250929050565b6000819050919050565b613b0381613af0565b8114613b0e57600080fd5b50565b600081359050613b2081613afa565b92915050565b600060ff82169050919050565b613b3c81613b26565b8114613b4757600080fd5b50565b600081359050613b5981613b33565b92915050565b60008060008060008060c08789031215613b7c57613b7b61384e565b5b6000613b8a89828a016139e6565b9650506020613b9b89828a016139e6565b9550506040613bac89828a01613b11565b9450506060613bbd89828a01613b4a565b9350506080613bce89828a01613b11565b92505060a0613bdf89828a01613b11565b9150509295509295509295565b613bf5816139c5565b82525050565b6000602082019050613c106000830184613bec565b92915050565b600060208284031215613c2c57613c2b61384e565b5b6000613c3a84828501613a9b565b91505092915050565b600060208284031215613c5957613c5861384e565b5b6000613c6784828501613b11565b91505092915050565b613c7981613af0565b82525050565b6000602082019050613c946000830184613c70565b92915050565b600080600060608486031215613cb357613cb261384e565b5b6000613cc186828701613a9b565b9350506020613cd286828701613a9b565b9250506040613ce3868287016139e6565b9150509250925092565b600080600080600060a08688031215613d0957613d0861384e565b5b6000613d17888289016139e6565b9550506020613d2888828901613b11565b9450506040613d3988828901613b4a565b9350506060613d4a88828901613b11565b9250506080613d5b88828901613b11565b9150509295509295909350565b60008060408385031215613d7f57613d7e61384e565b5b6000613d8d858286016139e6565b9250506020613d9e858286016139e6565b9150509250929050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b613dea82613959565b810181811067ffffffffffffffff82111715613e0957613e08613db2565b5b80604052505050565b6000613e1c613844565b9050613e288282613de1565b919050565b600067ffffffffffffffff821115613e4857613e47613db2565b5b613e5182613959565b9050602081019050919050565b82818337600083830152505050565b6000613e80613e7b84613e2d565b613e12565b905082815260208101848484011115613e9c57613e9b613dad565b5b613ea7848285613e5e565b509392505050565b600082601f830112613ec457613ec3613da8565b5b8135613ed4848260208601613e6d565b91505092915050565b60008060408385031215613ef457613ef361384e565b5b6000613f02858286016139e6565b925050602083013567ffffffffffffffff811115613f2357613f22613853565b5b613f2f85828601613eaf565b9150509250929050565b6000819050919050565b6000613f5e613f59613f5484613a28565b613f39565b613a28565b9050919050565b6000613f7082613f43565b9050919050565b6000613f8282613f65565b9050919050565b613f9281613f77565b82525050565b6000602082019050613fad6000830184613f89565b92915050565b6000613fbe82613f65565b9050919050565b613fce81613fb3565b82525050565b6000602082019050613fe96000830184613fc5565b92915050565b613ff8816138dd565b811461400357600080fd5b50565b60008135905061401581613fef565b92915050565b600080604083850312156140325761403161384e565b5b600061404085828601613a9b565b925050602061405185828601614006565b9150509250929050565b600080600080608085870312156140755761407461384e565b5b600061408387828801613a9b565b945050602061409487828801613a9b565b93505060406140a5878288016139e6565b925050606085013567ffffffffffffffff8111156140c6576140c5613853565b5b6140d287828801613eaf565b91505092959194509250565b600080600080600080600060e0888a0312156140fd576140fc61384e565b5b600061410b8a828b016139e6565b975050602061411c8a828b016139e6565b965050604088013567ffffffffffffffff81111561413d5761413c613853565b5b6141498a828b01613eaf565b955050606061415a8a828b01613b11565b945050608061416b8a828b01613b4a565b93505060a061417c8a828b01613b11565b92505060c061418d8a828b01613b11565b91505092959891949750929550565b600080604083850312156141b3576141b261384e565b5b60006141c185828601613a9b565b92505060206141d285828601613a9b565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000614203826141dc565b61420d81856141e7565b935061421d81856020860161392f565b61422681613959565b840191505092915050565b6000602082019050818103600083015261424b81846141f8565b905092915050565b600061425e82613f65565b9050919050565b61426e81614253565b82525050565b60006020820190506142896000830184614265565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806142d657607f821691505b6020821081036142e9576142e861428f565b5b50919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b600061434b60218361391e565b9150614356826142ef565b604082019050919050565b6000602082019050818103600083015261437a8161433e565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60008201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c0000602082015250565b60006143dd603e8361391e565b91506143e882614381565b604082019050919050565b6000602082019050818103600083015261440c816143d0565b9050919050565b600081905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b6000614454601c83614413565b915061445f8261441e565b601c82019050919050565b6000819050919050565b61448561448082613af0565b61446a565b82525050565b600061449682614447565b91506144a28284614474565b60208201915081905092915050565b7f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560008201527f72206e6f7220617070726f766564000000000000000000000000000000000000602082015250565b600061450d602e8361391e565b9150614518826144b1565b604082019050919050565b6000602082019050818103600083015261453c81614500565b9050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b600061459f602b8361391e565b91506145aa82614543565b604082019050919050565b600060208201905081810360008301526145ce81614592565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b600061460b601f8361391e565b9150614616826145d5565b602082019050919050565b6000602082019050818103600083015261463a816145fe565b9050919050565b600081905092915050565b50565b600061465c600083614641565b91506146678261464c565b600082019050919050565b600061467d8261464f565b9150819050919050565b60008160601b9050919050565b600061469f82614687565b9050919050565b60006146b182614694565b9050919050565b6146c96146c482613a48565b6146a6565b82525050565b6000819050919050565b6146ea6146e5826139c5565b6146cf565b82525050565b60006146fc82856146b8565b60148201915061470c82846146d9565b6020820191508190509392505050565b7f546865206d736748617368206973206e6f7420612068617368206f662074686560008201527f20746f6b656e49642e20204578706c61696e20796f757273656c662100000000602082015250565b6000614778603c8361391e565b91506147838261471c565b604082019050919050565b600060208201905081810360008301526147a78161476b565b9050919050565b6147b781613b26565b82525050565b60006080820190506147d26000830187613c70565b6147df60208301866147ae565b6147ec6040830185613c70565b6147f96060830184613c70565b95945050505050565b7f5468697320667265654d696e7420776173206e6f74207369676e65642062792060008201527f667265654d696e745369676e65722e2020486f7720656d626172617373696e6760208201527f2e00000000000000000000000000000000000000000000000000000000000000604082015250565b600061488460418361391e565b915061488f82614802565b606082019050919050565b600060208201905081810360008301526148b381614877565b9050919050565b7f546869732066726565206d696e742049442068617320616c726561647920626560008201527f656e2072656465656d6564000000000000000000000000000000000000000000602082015250565b6000614916602b8361391e565b9150614921826148ba565b604082019050919050565b6000602082019050818103600083015261494581614909565b9050919050565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b60006149a8602c8361391e565b91506149b38261494c565b604082019050919050565b600060208201905081810360008301526149d78161499b565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4f6e6c792074686520726f7574696e6720636f6e74726163742063616e20636160008201527f6c6c20746869732066756e6374696f6e00000000000000000000000000000000602082015250565b6000614a6960308361391e565b9150614a7482614a0d565b604082019050919050565b60006020820190508181036000830152614a9881614a5c565b9050919050565b7f596f75206d757374207061792065786163746c79206d696e7420636f73740000600082015250565b6000614ad5601e8361391e565b9150614ae082614a9f565b602082019050919050565b60006020820190508181036000830152614b0481614ac8565b9050919050565b7f4552433732313a20696e76616c696420746f6b656e2049440000000000000000600082015250565b6000614b4160188361391e565b9150614b4c82614b0b565b602082019050919050565b60006020820190508181036000830152614b7081614b34565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614bac816139c5565b82525050565b6000614bbe8383614ba3565b60208301905092915050565b6000602082019050919050565b6000614be282614b77565b614bec8185614b82565b9350614bf783614b93565b8060005b83811015614c28578151614c0f8882614bb2565b9750614c1a83614bca565b925050600181019050614bfb565b5085935050505092915050565b6000606082019050614c4a6000830186613bec565b8181036020830152614c5c81856141f8565b90508181036040830152614c708184614bd7565b9050949350505050565b7f4552433732313a2061646472657373207a65726f206973206e6f74206120766160008201527f6c6964206f776e65720000000000000000000000000000000000000000000000602082015250565b6000614cd660298361391e565b9150614ce182614c7a565b604082019050919050565b60006020820190508181036000830152614d0581614cc9565b9050919050565b600081519050614d1b81613a84565b92915050565b600060208284031215614d3757614d3661384e565b5b6000614d4584828501614d0c565b91505092915050565b6000614d61614d5c84613e2d565b613e12565b905082815260208101848484011115614d7d57614d7c613dad565b5b614d8884828561392f565b509392505050565b600082601f830112614da557614da4613da8565b5b8151614db5848260208601614d4e565b91505092915050565b600060208284031215614dd457614dd361384e565b5b600082015167ffffffffffffffff811115614df257614df1613853565b5b614dfe84828501614d90565b91505092915050565b6000606082019050614e1c6000830186613bec565b8181036020830152614e2e81856141f8565b9050614e3d6040830184613a5a565b949350505050565b600067ffffffffffffffff821115614e6057614e5f613db2565b5b614e6982613959565b9050602081019050919050565b6000614e89614e8484614e45565b613e12565b905082815260208101848484011115614ea557614ea4613dad565b5b614eb084828561392f565b509392505050565b600082601f830112614ecd57614ecc613da8565b5b8151614edd848260208601614e76565b91505092915050565b600060208284031215614efc57614efb61384e565b5b600082015167ffffffffffffffff811115614f1a57614f19613853565b5b614f2684828501614eb8565b91505092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614f8b60268361391e565b9150614f9682614f2f565b604082019050919050565b60006020820190508181036000830152614fba81614f7e565b9050919050565b7f546865726520617265206e6f20756e6d696e74656420726f7574656420746f6b60008201527f656e2069647320746f206d696e74000000000000000000000000000000000000602082015250565b600061501d602e8361391e565b915061502882614fc1565b604082019050919050565b6000602082019050818103600083015261504c81615010565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061508d826139c5565b9150615098836139c5565b92508282039050818111156150b0576150af615053565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061511b60208361391e565b9150615126826150e5565b602082019050919050565b6000602082019050818103600083015261514a8161510e565b9050919050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b60006151ad60258361391e565b91506151b882615151565b604082019050919050565b600060208201905081810360008301526151dc816151a0565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061523f60248361391e565b915061524a826151e3565b604082019050919050565b6000602082019050818103600083015261526e81615232565b9050919050565b6000615280826139c5565b915061528b836139c5565b92508282019050808211156152a3576152a2615053565b5b92915050565b6000815190506152b881613fef565b92915050565b6000602082840312156152d4576152d361384e565b5b60006152e2848285016152a9565b91505092915050565b7f5468697320504b5020686173206e6f74206265656e20726f7574656420796574600082015250565b600061532160208361391e565b915061532c826152eb565b602082019050919050565b6000602082019050818103600083015261535081615314565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b600061538d60198361391e565b915061539882615357565b602082019050919050565b600060208201905081810360008301526153bc81615380565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b600061541f60328361391e565b915061542a826153c3565b604082019050919050565b6000602082019050818103600083015261544e81615412565b9050919050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b600061548b60208361391e565b915061549682615455565b602082019050919050565b600060208201905081810360008301526154ba8161547e565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b60006154f7601c8361391e565b9150615502826154c1565b602082019050919050565b60006020820190508181036000830152615526816154ea565b9050919050565b60006080820190506155426000830187613a5a565b61554f6020830186613a5a565b61555c6040830185613bec565b818103606083015261556e81846141f8565b905095945050505050565b60008151905061558881613884565b92915050565b6000602082840312156155a4576155a361384e565b5b60006155b284828501615579565b9150509291505056fea2646970667358221220bd6bb2ed401a16bcfd00c782929a940c7d3ff9a77b1cf7a6d340282860df0f1264736f6c63430008110033