diff --git a/.prettierrc b/.prettierrc index 963354f..32f2e64 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,8 @@ { - "printWidth": 120 + "printWidth": 120, + "tabWidth": 2, + "useTabs": false, + "singleQuote": false, + "bracketSpacing": false, + "explicitTypes": "always" } diff --git a/.solhint.json b/.solhint.json index 35b805c..20c93a8 100644 --- a/.solhint.json +++ b/.solhint.json @@ -38,7 +38,7 @@ "avoid-throw": "error", "avoid-tx-origin": "error", "check-send-result": "error", - "compiler-version": ["error", "0.8.23"], + "compiler-version": ["error", "0.8.19"], "func-visibility": ["error", {"ignoreConstructors": true}], "multiple-sends": "warn", "no-complex-fallback": "warn", diff --git a/build/contracts/NFTLock.json b/build/contracts/NFTLock.json new file mode 100644 index 0000000..f1283f3 --- /dev/null +++ b/build/contracts/NFTLock.json @@ -0,0 +1,601 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "NFTLock", + "sourceName": "contracts/game/NFTLock.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "_duration", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_verifier", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "duration", + "type": "uint256" + } + ], + "name": "DurationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenIds", + "type": "uint256[]" + } + ], + "name": "Lock", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isMint", + "type": "bool" + } + ], + "indexed": false, + "internalType": "struct NFTLock.NFTInfo[]", + "name": "nftList", + "type": "tuple[]" + } + ], + "name": "UnLock", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "VerifierUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "_CACHED_CHAIN_ID", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_CACHED_THIS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "nftList", + "type": "address[]" + } + ], + "name": "addSupportNftList", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "hash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "checkSigner", + "outputs": [], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "duration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "address", + "name": "_nft", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isMint", + "type": "bool" + } + ], + "internalType": "struct NFTLock.NFTInfo[]", + "name": "_ids", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "_contract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_signTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_saltNonce", + "type": "uint256" + } + ], + "name": "getMessageHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "tokenIds", + "type": "uint256[]" + } + ], + "name": "lock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "lockedNft", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "lockedNum", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "lockedOriginal", + "outputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC721Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nftAddress", + "type": "address" + } + ], + "name": "removeSupportNft", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nft", + "type": "address" + } + ], + "name": "supportNftList", + "outputs": [ + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isMint", + "type": "bool" + } + ], + "internalType": "struct NFTLock.NFTInfo[]", + "name": "nftList", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "signTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "unlockOrMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "valNew", + "type": "uint256" + } + ], + "name": "updateDuation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_verifier", + "type": "address" + } + ], + "name": "updateVerifier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "verifier", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x60c0346100f657601f61194e38819003918201601f19168301916001600160401b038311848410176100fb5780849260409485528339810103126100f65780516020909101516001600160a01b039182821682036100f6576000543360018060a01b0319821617600055604051933391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a360025561070860035560048054466080523060a0526001600160a81b03191660089290921b610100600160a81b031691909117905561183c908161011282396080518181816103660152610eec015260a05181818161038801526108160152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe608080604052600436101561001357600080fd5b60003560e01c9081630fb5a6b414610fa3575080631275029214610f64578063150b7a0214610f0f5780632b437d4814610ed45780632b7ac3f314610ea75780634d8d0ac714610e5f5780635671576114610e415780635c975abb14610e1e5780635fb110ca14610d955780636d04319414610d4d578063715018a614610cf4578063799048fa14610c675780637f9d309614610bdc5780638da5cb5b14610bb35780638e47f63f14610a3057806397fc007c14610961578063a063472414610910578063d13344c914610845578063da28b52714610800578063dbfaa5801461025f578063f2fde38b1461019b5763f36b61d31461011157600080fd5b346101965760e03660031901126101965761012a610fbe565b610132610fd4565b6044356001600160401b0381116101965736602382011215610196576101629036906024816004013591016110f0565b606435916001600160a01b03831683036101965760209361018e9360c4359360a4359360843593611727565b604051908152f35b600080fd5b34610196576020366003190112610196576101b4610fbe565b6101bc611193565b6001600160a01b0390811690811561020b57600054826001600160601b0360a01b821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346101965760a036600319011261019657610278610fbe565b6001600160401b03806024351161019657366023602435011215610196578060243560040135116101965736602480356004013560061b81350101116101965760843590808211610196573660238301121561019657816004013511610196573660248260040135830101116101965760ff6040518260040135602484018237602081846004013581016001815203019020541661078a576002546044350180604435116107745742116107095761032e6114d0565b610341606460243560040135111561145b565b6103d96103af61035c366024356004013560248035016110f0565b60643590604435907f0000000000000000000000000000000000000000000000000000000000000000907f0000000000000000000000000000000000000000000000000000000000000000908833611727565b6004805460081c6001600160a01b031691906103d39036908601356024870161104f565b916111eb565b60005b6024356004013581106104dd575060ff60405182600401356024840182376020818460040135810160018152030190205416156104ac575b50604051604081016064358252604060208301526024356004013590526060810190602480350160005b602435600401358110610483575033936001600160a01b0316927ff3d71d6c5e51ea460dbafab10ee101a0f4be26a888e6b04a5b636173d63b322292908190039150a3005b90926040806001928635815261049b602088016110e3565b15156020820152019401910161043e565b6020604051828193600401356024820183376004013581016001815203019020600160ff1982541617905581610414565b60206104f4826024356004013560248035016115b6565b013580151581036101965715610587576001600160a01b038316906105238160248035600481013591016115b6565b35823b15610196576000926044849260405195869384926340c10f1960e01b845233600485015260248401525af191821561057b576105679261056c575b5061149b565b6103dc565b61057590610fea565b84610561565b6040513d6000823e3d90fd5b6001600160a01b03831660009081526005602052604090206105b38260248035600481013591016115b6565b356000526020523360018060a01b0360406000205416036106d8576105e3816024356004013560248035016115b6565b35906001600160a01b0384163b15610196576040516323b872dd60e01b81523060048201523360248201526044810192909252600082606481836001600160a01b0389165af191821561057b57610567926106c9575b5060018060a01b038416600052600660205260406000203360005260205261067b6040600020610674836024356004013560248035016115b6565b35906115c6565b506001600160a01b03841660009081526005602052604090206106a88260248035600481013591016115b6565b3560005260205260406000206001600160601b0360a01b815416905561149b565b6106d290610fea565b84610639565b60405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b6044820152606490fd5b60405162461bcd60e51b815260206004820152603b60248201527f657870697265642c20706c656173652073656e6420616e6f746865722074726160448201527f6e73616374696f6e2077697468206e6577207369676e617475726500000000006064820152608490fd5b634e487b7160e01b600052601160045260246000fd5b60405162461bcd60e51b815260206004820152604260248201527f7369676e617475726520757365642e20706c656173652073656e6420616e6f7460448201527f686572207472616e73616374696f6e2077697468206e6577207369676e617475606482015261726560f01b608482015260a490fd5b34610196576000366003190112610196576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346101965760403660031901126101965761085e610fbe565b610866610fd4565b60018060a01b0380921660005260209160068352604060002091166000528152604060002060405190818382549182815201908192600052846000209060005b868282106108fc5786866108bc8288038361102e565b604051928392818401908285525180915260408401929160005b8281106108e557505050500390f35b8351855286955093810193928101926001016108d6565b8354855290930192600192830192016108a6565b3461019657604036600319011261019657610929610fbe565b610931610fd4565b9060018060a01b038091166000526006602052604060002091166000526020526020604060002054604051908152f35b346101965760203660031901126101965761097a610fbe565b610982611193565b6001600160a01b0381169081156109df5760048054610100600160a81b03191660089290921b610100600160a81b03169190911790557fd24015cc99cc1700cafca3042840a1d8ac1e3964fd2e0e37ea29c654056ee327600080a2005b60405162461bcd60e51b815260206004820152602360248201527f4e4654436c61696d65723a20616464726573732063616e206e6f74206265207a60448201526265726f60e81b6064820152608490fd5b3461019657604036600319011261019657610a49610fbe565b6024356001600160401b03811161019657610a689036906004016110b3565b610a739291926114d0565b610a80606482111561145b565b6001600160a01b039091169060005b818110610aeb5750604051602080825281018290526001600160fb1b038211610196577ffa4fcf9122678b647ff5d9f7e030079388041514b1b489b702346021b4e4344e9160051b8094604083013760408133958101030190a3005b610af68183866114aa565b3590833b15610196576040516323b872dd60e01b8152336004820152306024820152604481019290925260008260648183885af191821561057b57610b9f92610ba4575b50836000526020600581526040600020610b558386896114aa565b3560005281526040600020336001600160601b0360a01b825416179055846000526006815260406000209033600052526105616040600020610b988386896114aa565b359061152c565b610a8f565b610bad90610fea565b85610b3a565b34610196576000366003190112610196576000546040516001600160a01b039091168152602090f35b3461019657602036600319011261019657600435610bf8611193565b600354811115610c2d57806002557f91abcc2d6823e3a3f11d31b208dd3065d2c6a791f1c7c9fe96a42ce12897eac5600080a2005b60405162461bcd60e51b8152602060048201526012602482015271191d5c985d1a5bdb881d1bdbc81cda1bdc9d60721b6044820152606490fd5b3461019657602036600319011261019657610c80610fbe565b610c88611193565b6001600160a01b031660008181526007602052604090205460ff1615610cc0576000908152600760205260409020805460ff19169055005b60405162461bcd60e51b815260206004820152600c60248201526b63616e27742072656d6f766560a01b6044820152606490fd5b3461019657600036600319011261019657610d0d611193565b600080546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461019657606036600319011261019657610d66610fbe565b604435906001600160401b03821161019657610d89610d93923690600401611095565b90602435906111eb565b005b3461019657602080600319360112610196576004356001600160401b03811161019657610dc69036906004016110b3565b610dce611193565b60005b818110610dda57005b610de58183856114aa565b356001600160a01b038116919082900361019657610e1991600052600785526040600020600160ff1982541617905561149b565b610dd1565b3461019657600036600319011261019657602060ff600454166040519015158152f35b34610196576000366003190112610196576020600354604051908152f35b346101965760403660031901126101965760206001600160a01b0380610e83610fbe565b16600052600582526040600020602435600052825260406000205416604051908152f35b346101965760003660031901126101965760045460405160089190911c6001600160a01b03168152602090f35b346101965760003660031901126101965760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b3461019657608036600319011261019657610f28610fbe565b50610f31610fd4565b506064356001600160401b03811161019657610f51903690600401611095565b50604051630a85bd0160e11b8152602090f35b34610196576020366003190112610196576001600160a01b03610f85610fbe565b166000526007602052602060ff604060002054166040519015158152f35b34610196576000366003190112610196576020906002548152f35b600435906001600160a01b038216820361019657565b602435906001600160a01b038216820361019657565b6001600160401b038111610ffd57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117610ffd57604052565b90601f801991011681019081106001600160401b03821117610ffd57604052565b9291926001600160401b038211610ffd5760405191611078601f8201601f19166020018461102e565b829481845281830111610196578281602093846000960137010152565b9080601f83011215610196578160206110b09335910161104f565b90565b9181601f84011215610196578235916001600160401b038311610196576020808501948460051b01011161019657565b3590811515820361019657565b6001600160401b039392848311610ffd57604092835195602092611119848460051b018961102e565b8388848152019260061b85019481861161019657925b85841061113f5750505050505050565b868483031261019657865190878201908282108583111761117e578892879284528635815261116f8388016110e3565b8382015281520193019261112f565b60246000634e487b7160e01b81526041600452fd5b6000546001600160a01b031633036111a757565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b9061122d92611225917f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c600020611394565b92909261127a565b6001600160a01b0390811691160361124157565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c6964207369676e617475726560781b6044820152606490fd5b600581101561137e578061128b5750565b600181036112d85760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b600281036113255760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b60031461132e57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b9060418151146000146113c2576113be916020820151906060604084015193015160001a906113cc565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831161144f5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156114425781516001600160a01b0381161561143c579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b1561146257565b60405162461bcd60e51b8152602060048201526011602482015270746f6b656e49647320746f6f206d616e7960781b6044820152606490fd5b60001981146107745760010190565b91908110156114ba5760051b0190565b634e487b7160e01b600052603260045260246000fd5b60ff600454166114dc57565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b80548210156114ba5760005260206000200190600090565b919060018301600090828252806020526040822054156000146115b0578454946801000000000000000086101561159c578361158c611575886001604098999a01855584611514565b819391549060031b91821b91600019901b19161790565b9055549382526020522055600190565b634e487b7160e01b83526041600452602483fd5b50925050565b91908110156114ba5760061b0190565b906001820190600092818452826020526040842054908115156000146116af576000199180830181811161169b5782549084820191821161168757808203611652575b5050508054801561163e578201916116218383611514565b909182549160031b1b191690555582526020526040812055600190565b634e487b7160e01b86526031600452602486fd5b6116726116626115759386611514565b90549060031b1c92839286611514565b90558652846020526040862055388080611609565b634e487b7160e01b88526011600452602488fd5b634e487b7160e01b87526011600452602487fd5b5050505090565b80518210156114ba5760209160051b010190565b9081519160005b8381106116e2575050016000815290565b80602080928401015181850152016116d1565b61172590611717611711949360405195869360208501906116ca565b906116ca565b03601f19810184528361102e565b565b939695919490966040978851946001600160601b031980928160209960601b168989015260601b16603487015260601b166048850152605c840152607c830152609c820152609c815260c081018181106001600160401b03821117610ffd5785526000905b83518210156117f8576117ec6117c46117f2926117a985886116b6565b515190895191878301528682526117bf82611013565b6116f5565b846117cf85886116b6565b51015115159088519160f81b86830152600182526117bf82611013565b9161149b565b9061178c565b93945050905081519101209056fea2646970667358221220a9a53469c4b1432f9ddf9ae806bec7d819ee6cd7d600b0c9c5c578fc102eaf0a64736f6c63430008130033", + "deployedBytecode": "0x608080604052600436101561001357600080fd5b60003560e01c9081630fb5a6b414610fa3575080631275029214610f64578063150b7a0214610f0f5780632b437d4814610ed45780632b7ac3f314610ea75780634d8d0ac714610e5f5780635671576114610e415780635c975abb14610e1e5780635fb110ca14610d955780636d04319414610d4d578063715018a614610cf4578063799048fa14610c675780637f9d309614610bdc5780638da5cb5b14610bb35780638e47f63f14610a3057806397fc007c14610961578063a063472414610910578063d13344c914610845578063da28b52714610800578063dbfaa5801461025f578063f2fde38b1461019b5763f36b61d31461011157600080fd5b346101965760e03660031901126101965761012a610fbe565b610132610fd4565b6044356001600160401b0381116101965736602382011215610196576101629036906024816004013591016110f0565b606435916001600160a01b03831683036101965760209361018e9360c4359360a4359360843593611727565b604051908152f35b600080fd5b34610196576020366003190112610196576101b4610fbe565b6101bc611193565b6001600160a01b0390811690811561020b57600054826001600160601b0360a01b821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346101965760a036600319011261019657610278610fbe565b6001600160401b03806024351161019657366023602435011215610196578060243560040135116101965736602480356004013560061b81350101116101965760843590808211610196573660238301121561019657816004013511610196573660248260040135830101116101965760ff6040518260040135602484018237602081846004013581016001815203019020541661078a576002546044350180604435116107745742116107095761032e6114d0565b610341606460243560040135111561145b565b6103d96103af61035c366024356004013560248035016110f0565b60643590604435907f0000000000000000000000000000000000000000000000000000000000000000907f0000000000000000000000000000000000000000000000000000000000000000908833611727565b6004805460081c6001600160a01b031691906103d39036908601356024870161104f565b916111eb565b60005b6024356004013581106104dd575060ff60405182600401356024840182376020818460040135810160018152030190205416156104ac575b50604051604081016064358252604060208301526024356004013590526060810190602480350160005b602435600401358110610483575033936001600160a01b0316927ff3d71d6c5e51ea460dbafab10ee101a0f4be26a888e6b04a5b636173d63b322292908190039150a3005b90926040806001928635815261049b602088016110e3565b15156020820152019401910161043e565b6020604051828193600401356024820183376004013581016001815203019020600160ff1982541617905581610414565b60206104f4826024356004013560248035016115b6565b013580151581036101965715610587576001600160a01b038316906105238160248035600481013591016115b6565b35823b15610196576000926044849260405195869384926340c10f1960e01b845233600485015260248401525af191821561057b576105679261056c575b5061149b565b6103dc565b61057590610fea565b84610561565b6040513d6000823e3d90fd5b6001600160a01b03831660009081526005602052604090206105b38260248035600481013591016115b6565b356000526020523360018060a01b0360406000205416036106d8576105e3816024356004013560248035016115b6565b35906001600160a01b0384163b15610196576040516323b872dd60e01b81523060048201523360248201526044810192909252600082606481836001600160a01b0389165af191821561057b57610567926106c9575b5060018060a01b038416600052600660205260406000203360005260205261067b6040600020610674836024356004013560248035016115b6565b35906115c6565b506001600160a01b03841660009081526005602052604090206106a88260248035600481013591016115b6565b3560005260205260406000206001600160601b0360a01b815416905561149b565b6106d290610fea565b84610639565b60405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b6044820152606490fd5b60405162461bcd60e51b815260206004820152603b60248201527f657870697265642c20706c656173652073656e6420616e6f746865722074726160448201527f6e73616374696f6e2077697468206e6577207369676e617475726500000000006064820152608490fd5b634e487b7160e01b600052601160045260246000fd5b60405162461bcd60e51b815260206004820152604260248201527f7369676e617475726520757365642e20706c656173652073656e6420616e6f7460448201527f686572207472616e73616374696f6e2077697468206e6577207369676e617475606482015261726560f01b608482015260a490fd5b34610196576000366003190112610196576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346101965760403660031901126101965761085e610fbe565b610866610fd4565b60018060a01b0380921660005260209160068352604060002091166000528152604060002060405190818382549182815201908192600052846000209060005b868282106108fc5786866108bc8288038361102e565b604051928392818401908285525180915260408401929160005b8281106108e557505050500390f35b8351855286955093810193928101926001016108d6565b8354855290930192600192830192016108a6565b3461019657604036600319011261019657610929610fbe565b610931610fd4565b9060018060a01b038091166000526006602052604060002091166000526020526020604060002054604051908152f35b346101965760203660031901126101965761097a610fbe565b610982611193565b6001600160a01b0381169081156109df5760048054610100600160a81b03191660089290921b610100600160a81b03169190911790557fd24015cc99cc1700cafca3042840a1d8ac1e3964fd2e0e37ea29c654056ee327600080a2005b60405162461bcd60e51b815260206004820152602360248201527f4e4654436c61696d65723a20616464726573732063616e206e6f74206265207a60448201526265726f60e81b6064820152608490fd5b3461019657604036600319011261019657610a49610fbe565b6024356001600160401b03811161019657610a689036906004016110b3565b610a739291926114d0565b610a80606482111561145b565b6001600160a01b039091169060005b818110610aeb5750604051602080825281018290526001600160fb1b038211610196577ffa4fcf9122678b647ff5d9f7e030079388041514b1b489b702346021b4e4344e9160051b8094604083013760408133958101030190a3005b610af68183866114aa565b3590833b15610196576040516323b872dd60e01b8152336004820152306024820152604481019290925260008260648183885af191821561057b57610b9f92610ba4575b50836000526020600581526040600020610b558386896114aa565b3560005281526040600020336001600160601b0360a01b825416179055846000526006815260406000209033600052526105616040600020610b988386896114aa565b359061152c565b610a8f565b610bad90610fea565b85610b3a565b34610196576000366003190112610196576000546040516001600160a01b039091168152602090f35b3461019657602036600319011261019657600435610bf8611193565b600354811115610c2d57806002557f91abcc2d6823e3a3f11d31b208dd3065d2c6a791f1c7c9fe96a42ce12897eac5600080a2005b60405162461bcd60e51b8152602060048201526012602482015271191d5c985d1a5bdb881d1bdbc81cda1bdc9d60721b6044820152606490fd5b3461019657602036600319011261019657610c80610fbe565b610c88611193565b6001600160a01b031660008181526007602052604090205460ff1615610cc0576000908152600760205260409020805460ff19169055005b60405162461bcd60e51b815260206004820152600c60248201526b63616e27742072656d6f766560a01b6044820152606490fd5b3461019657600036600319011261019657610d0d611193565b600080546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461019657606036600319011261019657610d66610fbe565b604435906001600160401b03821161019657610d89610d93923690600401611095565b90602435906111eb565b005b3461019657602080600319360112610196576004356001600160401b03811161019657610dc69036906004016110b3565b610dce611193565b60005b818110610dda57005b610de58183856114aa565b356001600160a01b038116919082900361019657610e1991600052600785526040600020600160ff1982541617905561149b565b610dd1565b3461019657600036600319011261019657602060ff600454166040519015158152f35b34610196576000366003190112610196576020600354604051908152f35b346101965760403660031901126101965760206001600160a01b0380610e83610fbe565b16600052600582526040600020602435600052825260406000205416604051908152f35b346101965760003660031901126101965760045460405160089190911c6001600160a01b03168152602090f35b346101965760003660031901126101965760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b3461019657608036600319011261019657610f28610fbe565b50610f31610fd4565b506064356001600160401b03811161019657610f51903690600401611095565b50604051630a85bd0160e11b8152602090f35b34610196576020366003190112610196576001600160a01b03610f85610fbe565b166000526007602052602060ff604060002054166040519015158152f35b34610196576000366003190112610196576020906002548152f35b600435906001600160a01b038216820361019657565b602435906001600160a01b038216820361019657565b6001600160401b038111610ffd57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117610ffd57604052565b90601f801991011681019081106001600160401b03821117610ffd57604052565b9291926001600160401b038211610ffd5760405191611078601f8201601f19166020018461102e565b829481845281830111610196578281602093846000960137010152565b9080601f83011215610196578160206110b09335910161104f565b90565b9181601f84011215610196578235916001600160401b038311610196576020808501948460051b01011161019657565b3590811515820361019657565b6001600160401b039392848311610ffd57604092835195602092611119848460051b018961102e565b8388848152019260061b85019481861161019657925b85841061113f5750505050505050565b868483031261019657865190878201908282108583111761117e578892879284528635815261116f8388016110e3565b8382015281520193019261112f565b60246000634e487b7160e01b81526041600452fd5b6000546001600160a01b031633036111a757565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b9061122d92611225917f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c600020611394565b92909261127a565b6001600160a01b0390811691160361124157565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c6964207369676e617475726560781b6044820152606490fd5b600581101561137e578061128b5750565b600181036112d85760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b600281036113255760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b60031461132e57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b9060418151146000146113c2576113be916020820151906060604084015193015160001a906113cc565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831161144f5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156114425781516001600160a01b0381161561143c579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b1561146257565b60405162461bcd60e51b8152602060048201526011602482015270746f6b656e49647320746f6f206d616e7960781b6044820152606490fd5b60001981146107745760010190565b91908110156114ba5760051b0190565b634e487b7160e01b600052603260045260246000fd5b60ff600454166114dc57565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b80548210156114ba5760005260206000200190600090565b919060018301600090828252806020526040822054156000146115b0578454946801000000000000000086101561159c578361158c611575886001604098999a01855584611514565b819391549060031b91821b91600019901b19161790565b9055549382526020522055600190565b634e487b7160e01b83526041600452602483fd5b50925050565b91908110156114ba5760061b0190565b906001820190600092818452826020526040842054908115156000146116af576000199180830181811161169b5782549084820191821161168757808203611652575b5050508054801561163e578201916116218383611514565b909182549160031b1b191690555582526020526040812055600190565b634e487b7160e01b86526031600452602486fd5b6116726116626115759386611514565b90549060031b1c92839286611514565b90558652846020526040862055388080611609565b634e487b7160e01b88526011600452602488fd5b634e487b7160e01b87526011600452602487fd5b5050505090565b80518210156114ba5760209160051b010190565b9081519160005b8381106116e2575050016000815290565b80602080928401015181850152016116d1565b61172590611717611711949360405195869360208501906116ca565b906116ca565b03601f19810184528361102e565b565b939695919490966040978851946001600160601b031980928160209960601b168989015260601b16603487015260601b166048850152605c840152607c830152609c820152609c815260c081018181106001600160401b03821117610ffd5785526000905b83518210156117f8576117ec6117c46117f2926117a985886116b6565b515190895191878301528682526117bf82611013565b6116f5565b846117cf85886116b6565b51015115159088519160f81b86830152600182526117bf82611013565b9161149b565b9061178c565b93945050905081519101209056fea2646970667358221220a9a53469c4b1432f9ddf9ae806bec7d819ee6cd7d600b0c9c5c578fc102eaf0a64736f6c63430008130033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/contracts/activity/NFTClaimStage2.sol b/contracts/activity/NFTClaimStage2.sol index 3588d17..12c4796 100644 --- a/contracts/activity/NFTClaimStage2.sol +++ b/contracts/activity/NFTClaimStage2.sol @@ -9,117 +9,125 @@ import {HasSignature} from "../core/HasSignature.sol"; * Contract for the activity of NFT claim stage 2. */ interface IClaimAbleNFT { - function safeMint(address to, uint256 tokenID) external; + function safeMint(address to, uint256 tokenID) external; } contract NFTClaimStage2 is HasSignature, ReentrancyGuard { - struct MintConfig { - uint256 parse1MaxSupply; // max supply for phase1 - uint256 maxSupply; // max supply for phase2 - address currency; // token address which user must pay to mint - uint256 mintPrice; // in wei - address feeToAddress; // wallet address to receive mint fee + struct MintConfig { + uint256 parse1MaxSupply; // max supply for phase1 + uint256 maxSupply; // max supply for phase2 + address currency; // token address which user must pay to mint + uint256 mintPrice; // in wei + address feeToAddress; // wallet address to receive mint fee + } + // parse: 0: not open or end, 1: phase1, 2: phase2 + uint256 public mintParse = 0; + + uint256 public immutable _CACHED_CHAIN_ID; + address public immutable _CACHED_THIS; + address public immutable nftAddress; + + address public verifier; + MintConfig public mintConfig; + uint256 public parse1Count; + uint256 public totalCount; + + event NFTClaimed(address indexed nftAddress, address indexed to, uint256[] ids); + + event ParseUpdated(uint256 _parse); + event MintConfigUpdated(MintConfig config); + event VerifierUpdated(address indexed verifier); + + constructor(address _nftAddress, address _verifier, MintConfig memory _mintConfig) { + _CACHED_CHAIN_ID = block.chainid; + _CACHED_THIS = address(this); + nftAddress = _nftAddress; + verifier = _verifier; + mintConfig = _mintConfig; + } + + modifier whenNotPaused() { + require(mintParse > 0, "NFTClaimer: not begin or ended"); + _; + } + + function updateMintParse(uint256 _mintParse) external onlyOwner { + mintParse = _mintParse; + emit ParseUpdated(_mintParse); + } + + function updateMintConfig(MintConfig calldata config) external onlyOwner { + mintConfig = config; + emit MintConfigUpdated(config); + } + + /** + * @dev update verifier address + */ + function updateVerifier(address _verifier) external onlyOwner { + require(_verifier != address(0), "NFTClaimer: address can not be zero"); + verifier = _verifier; + emit VerifierUpdated(_verifier); + } + + /** + * @dev claim NFT + * Get whitelist signature from a third-party service, then call this method to claim NFT + * @param saltNonce nonce + * @param signature signature + */ + function claim( + uint256[] memory ids, + uint256 tokenAmount, + uint256 saltNonce, + bytes calldata signature + ) external nonReentrant whenNotPaused { + // get current parse; + uint256 count = ids.length; + require(count > 0, "NFTClaimer: ids length must be greater than 0"); + if (mintParse == 1) { + require(count <= mintConfig.parse1MaxSupply - parse1Count, "NFTClaimer: exceed parse 1 max supply"); + } else { + require(count <= mintConfig.maxSupply - totalCount, "NFTClaimer: exceed max supply"); } - // parse: 0: not open or end, 1: phase1, 2: phase2 - uint256 public mintParse = 0; - - uint256 public immutable _CACHED_CHAIN_ID; - address public immutable _CACHED_THIS; - address public immutable nftAddress; - - address public verifier; - MintConfig public mintConfig; - uint256 public parse1Count; - uint256 public totalCount; - - event NFTClaimed(address indexed nftAddress, address indexed to, uint256[] ids); - - event ParseUpdated(uint256 _parse); - event MintConfigUpdated(MintConfig config); - event VerifierUpdated(address indexed verifier); - - constructor(address _nftAddress, address _verifier, MintConfig memory _mintConfig) { - _CACHED_CHAIN_ID = block.chainid; - _CACHED_THIS = address(this); - nftAddress = _nftAddress; - verifier = _verifier; - mintConfig = _mintConfig; + require(tokenAmount >= mintConfig.mintPrice * count, "NFTClaimer: insufficient token amount"); + address to = _msgSender(); + bytes32 criteriaMessageHash = getMessageHash( + to, + nftAddress, + ids, + tokenAmount, + _CACHED_THIS, + _CACHED_CHAIN_ID, + saltNonce + ); + checkSigner(verifier, criteriaMessageHash, signature); + IERC20(mintConfig.currency).transferFrom(to, mintConfig.feeToAddress, tokenAmount); + for (uint256 i = 0; i < count; ++i) { + IClaimAbleNFT(nftAddress).safeMint(to, ids[i]); } - - modifier whenNotPaused() { - require(mintParse > 0, "NFTClaimer: not begin or ended"); - _; + // require(count > 2, "run to here"); + totalCount += count; + if (mintParse == 1) { + parse1Count += count; } + _useSignature(signature); + emit NFTClaimed(nftAddress, to, ids); + } - function updateMintParse(uint256 _mintParse) external onlyOwner { - mintParse = _mintParse; - emit ParseUpdated(_mintParse); - } - - function updateMintConfig(MintConfig calldata config) external onlyOwner { - mintConfig = config; - emit MintConfigUpdated(config); - } - - /** - * @dev update verifier address - */ - function updateVerifier(address _verifier) external onlyOwner { - require(_verifier != address(0), "NFTClaimer: address can not be zero"); - verifier = _verifier; - emit VerifierUpdated(_verifier); - } - - /** - * @dev claim NFT - * Get whitelist signature from a third-party service, then call this method to claim NFT - * @param saltNonce nonce - * @param signature signature - */ - function claim( - uint256[] memory ids, - uint256 tokenAmount, - uint256 saltNonce, - bytes calldata signature - ) external nonReentrant whenNotPaused { - // get current parse; - uint256 count = ids.length; - require(count > 0, "NFTClaimer: ids length must be greater than 0"); - if (mintParse == 1) { - require(count <= mintConfig.parse1MaxSupply - parse1Count, "NFTClaimer: exceed parse 1 max supply"); - } else { - require(count <= mintConfig.maxSupply - totalCount, "NFTClaimer: exceed max supply"); - } - require(tokenAmount >= mintConfig.mintPrice * count, "NFTClaimer: insufficient token amount"); - address to = _msgSender(); - bytes32 criteriaMessageHash = getMessageHash(to, nftAddress, ids, tokenAmount, _CACHED_THIS, _CACHED_CHAIN_ID, saltNonce); - checkSigner(verifier, criteriaMessageHash, signature); - IERC20(mintConfig.currency).transferFrom(to, mintConfig.feeToAddress, tokenAmount); - for (uint256 i = 0; i < count; ++i) { - IClaimAbleNFT(nftAddress).safeMint(to, ids[i]); - } - // require(count > 2, "run to here"); - totalCount += count; - if (mintParse == 1) { - parse1Count += count; - } - _useSignature(signature); - emit NFTClaimed(nftAddress, to, ids); - } - - function getMessageHash( - address _to, - address _address, - uint256[] memory _ids, - uint256 _tokenAmount, - address _contract, - uint256 _chainId, - uint256 _saltNonce - ) public pure returns (bytes32) { - bytes memory encoded = abi.encodePacked(_to, _address, _tokenAmount, _contract, _chainId, _saltNonce); - for (uint256 i = 0; i < _ids.length; ++i) { - encoded = bytes.concat(encoded, abi.encodePacked(_ids[i])); - } - return keccak256(encoded); + function getMessageHash( + address _to, + address _address, + uint256[] memory _ids, + uint256 _tokenAmount, + address _contract, + uint256 _chainId, + uint256 _saltNonce + ) public pure returns (bytes32) { + bytes memory encoded = abi.encodePacked(_to, _address, _tokenAmount, _contract, _chainId, _saltNonce); + for (uint256 i = 0; i < _ids.length; ++i) { + encoded = bytes.concat(encoded, abi.encodePacked(_ids[i])); } + return keccak256(encoded); + } } diff --git a/contracts/game/NFTLock.sol b/contracts/game/NFTLock.sol index f2e8823..0cafe7f 100644 --- a/contracts/game/NFTLock.sol +++ b/contracts/game/NFTLock.sol @@ -3,123 +3,122 @@ pragma solidity 0.8.19; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; -import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; -contract NFTLock is AccessControl, ERC721Holder { - using EnumerableSet for EnumerableSet.UintSet; +import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol"; +import {HasSignature} from "../core/HasSignature.sol"; +import {TimeChecker} from "../utils/TimeChecker.sol"; - mapping(address => mapping(uint256 => address)) lockedOriginal; - mapping(address => mapping(address => EnumerableSet.UintSet)) lockedRecords; - mapping(address => bool) supportNftList; - bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); - bytes32 public constant UNLOCK_ROLE = keccak256("UNLOCK_ROLE"); - bytes32 public constant RELEASE_ROLE = keccak256("RELEASE_ROLE"); - - event Lock(address indexed nft, address indexed user, uint256 indexed tokenId); - event UnLock(address indexed nft, address indexed user, uint256 indexed tokenId); - event BatchLock(address indexed nft, address indexed user, uint256[] tokenId); - event Release(address indexed nft, uint256[] tokenIds, string serverId); - - constructor() { - _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); - _setupRole(OPERATOR_ROLE, msg.sender); - _setupRole(UNLOCK_ROLE, msg.sender); - _setupRole(RELEASE_ROLE, msg.sender); - } - - function lock(address nft, uint256 tokenId) external { - require(supportNftList[nft], "can't lock this nft"); - IERC721(nft).transferFrom(msg.sender, address(this), tokenId); - lockedOriginal[nft][tokenId] = msg.sender; - lockedRecords[nft][msg.sender].add(tokenId); - emit Lock(nft, msg.sender, tokenId); - } - - function unlock(address nft, address to, uint256 tokenId) external onlyUnlocker { - IERC721(nft).transferFrom(address(this), to, tokenId); - lockedRecords[nft][lockedOriginal[nft][tokenId]].remove(tokenId); - delete lockedOriginal[nft][tokenId]; - emit UnLock(nft, to, tokenId); - } - - function batchLock(address nft, uint256[] calldata tokenIds) external { - require(tokenIds.length <= 100, "tokenIds too many"); - for (uint256 i = 0; i < tokenIds.length; i++) { - IERC721(nft).transferFrom(msg.sender, address(this), tokenIds[i]); - lockedOriginal[nft][tokenIds[i]] = msg.sender; - lockedRecords[nft][msg.sender].add(tokenIds[i]); - } - emit BatchLock(nft, msg.sender, tokenIds); - } - - function release(address nft, uint256[] calldata tokenIds, string calldata serverId) external onlyReleaser { - require(tokenIds.length <= 100, "tokenIds too many"); - for (uint256 i = 0; i < tokenIds.length; i++) { - IERC721(nft).transferFrom(msg.sender, address(this), tokenIds[i]); - lockedRecords[nft][msg.sender].add(tokenIds[i]); - } - emit Release(nft, tokenIds, serverId); - } - - function originalOwner(address token, uint256 tokenId) public view returns (address) { - return lockedOriginal[token][tokenId]; - } - - function lockedNum(address token, address user) public view returns (uint256) { - return lockedRecords[token][user].length(); - } - - function lockedNft(address token, address user) public view returns (uint256[] memory) { - return lockedRecords[token][user].values(); - } - - /** ------set------- **/ - function setOperatorRole(address to) external { - grantRole(OPERATOR_ROLE, to); - } - - function removeOperatorRole(address to) external { - revokeRole(OPERATOR_ROLE, to); - } - - function setReleaseRole(address to) external { - grantRole(RELEASE_ROLE, to); - } - - function removeReleaseRole(address to) external { - revokeRole(RELEASE_ROLE, to); - } - - function setUnlockRole(address to) external { - grantRole(UNLOCK_ROLE, to); - } - - function removeUnlockRole(address to) external { - revokeRole(UNLOCK_ROLE, to); - } - - function addSupportNftList(address[] calldata nftList) external onlyOperator { - for (uint256 i = 0; i < nftList.length; i++) { - supportNftList[nftList[i]] = true; - } - } - function removeSupportNft(address nftAddress) external onlyOperator { - require(supportNftList[nftAddress], "can't remove"); - delete supportNftList[nftAddress]; - } - - /** ------modifier------- **/ - modifier onlyOperator() { - require(hasRole(OPERATOR_ROLE, msg.sender), "not operator role"); - _; - } - - modifier onlyUnlocker() { - require(hasRole(UNLOCK_ROLE, msg.sender), "not unlocker role"); - _; - } - - modifier onlyReleaser() { - require(hasRole(RELEASE_ROLE, msg.sender), "not releaser role"); - _; - } +interface INFT { + function mint(address to, uint256 tokenID) external; + function transferFrom(address from, address to, uint256 tokenId) external; +} + +contract NFTLock is ERC721Holder, HasSignature, TimeChecker, Pausable { + using EnumerableSet for EnumerableSet.UintSet; + + uint256 public immutable _CACHED_CHAIN_ID; + address public immutable _CACHED_THIS; + address public verifier; + + struct NFTInfo { + uint256 tokenId; + bool isMint; + } + mapping(address nft => mapping(uint256 tokenId => address user)) public lockedOriginal; + mapping(address nft => mapping(address user => EnumerableSet.UintSet tokenIdSet)) private lockedRecords; + mapping(address nft => bool status) public supportNftList; + + event UnLock(address indexed nft, address indexed user, uint256 nonce, NFTInfo[] nftList); + event Lock(address indexed nft, address indexed user, uint256[] tokenIds); + event VerifierUpdated(address indexed verifier); + + constructor(uint256 _duration, address _verifier) TimeChecker(_duration) { + _CACHED_CHAIN_ID = block.chainid; + _CACHED_THIS = address(this); + verifier = _verifier; + } + + function lock(address nft, uint256[] calldata tokenIds) external whenNotPaused{ + require(tokenIds.length <= 100, "tokenIds too many"); + address to = _msgSender(); + for (uint256 i = 0; i < tokenIds.length; i++) { + INFT(nft).transferFrom(to, address(this), tokenIds[i]); + lockedOriginal[nft][tokenIds[i]] = to; + lockedRecords[nft][to].add(tokenIds[i]); + } + emit Lock(nft, to, tokenIds); + } + /** + * @dev unlock or mint nft + * if tokenId not exists, mint it + * if exists and user is owner, unlock it + */ + function unlockOrMint( + address nft, + NFTInfo[] calldata nftList, + uint256 signTime, + uint256 saltNonce, + bytes calldata signature + ) external signatureValid(signature) timeValid(signTime) whenNotPaused { + require(nftList.length <= 100, "tokenIds too many"); + address to = _msgSender(); + bytes32 messageHash = getMessageHash(to, nft, nftList, _CACHED_THIS, _CACHED_CHAIN_ID, signTime, saltNonce); + checkSigner(verifier, messageHash, signature); + for (uint256 i = 0; i < nftList.length; i++) { + if (nftList[i].isMint) { + INFT(nft).mint(to, nftList[i].tokenId); + } else { + require(lockedOriginal[nft][nftList[i].tokenId] == to, "not owner"); + INFT(nft).transferFrom(address(this), to, nftList[i].tokenId); + lockedRecords[nft][to].remove(nftList[i].tokenId); + delete lockedOriginal[nft][nftList[i].tokenId]; + } + } + _useSignature(signature); + emit UnLock(nft, to, saltNonce, nftList); + } + + /** ------get------- **/ + function lockedNum(address token, address user) public view returns (uint256) { + return lockedRecords[token][user].length(); + } + + function lockedNft(address token, address user) public view returns (uint256[] memory) { + return lockedRecords[token][user].values(); + } + + function addSupportNftList(address[] calldata nftList) external onlyOwner { + for (uint256 i = 0; i < nftList.length; i++) { + supportNftList[nftList[i]] = true; + } + } + function removeSupportNft(address nftAddress) external onlyOwner { + require(supportNftList[nftAddress], "can't remove"); + delete supportNftList[nftAddress]; + } + + /** + * @dev update verifier address + */ + function updateVerifier(address _verifier) external onlyOwner { + require(_verifier != address(0), "NFTClaimer: address can not be zero"); + verifier = _verifier; + emit VerifierUpdated(_verifier); + } + + function getMessageHash( + address _to, + address _nft, + NFTInfo[] memory _ids, + address _contract, + uint256 _chainId, + uint256 _signTime, + uint256 _saltNonce + ) public pure returns (bytes32) { + bytes memory encoded = abi.encodePacked(_to, _nft, _contract, _chainId, _signTime, _saltNonce); + for (uint256 i = 0; i < _ids.length; ++i) { + encoded = bytes.concat(encoded, abi.encodePacked(_ids[i].tokenId)); + encoded = bytes.concat(encoded, abi.encodePacked(_ids[i].isMint)); + } + return keccak256(encoded); + } } diff --git a/contracts/utils/TimeChecker.sol b/contracts/utils/TimeChecker.sol index d0cf9a4..b04093a 100644 --- a/contracts/utils/TimeChecker.sol +++ b/contracts/utils/TimeChecker.sol @@ -8,8 +8,8 @@ contract TimeChecker is Ownable { event DurationUpdated(uint256 indexed duration); - constructor() { - duration = 1 days; + constructor(uint256 _duration) { + duration = _duration; minDuration = 30 minutes; } diff --git a/deploy/4_deploy_nftlocker.ts b/deploy/4_deploy_nftlocker.ts new file mode 100644 index 0000000..984c34b --- /dev/null +++ b/deploy/4_deploy_nftlocker.ts @@ -0,0 +1,29 @@ +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { DeployFunction } from "hardhat-deploy/types"; +import { updateArray } from "../scripts/utils" + + +const deployNFTClaim: DeployFunction = + async function (hre: HardhatRuntimeEnvironment) { + const provider = hre.ethers.provider; + const from = await (await provider.getSigner()).getAddress(); + + const verifier = '0x50A8e60041A206AcaA5F844a1104896224be6F39' + const ret = await hre.deployments.deploy("NFTLock", { + from, + args: [3600, verifier], + log: true, + }); + console.log("==NFTLock addr=", ret.address); + updateArray({ + name: "NFTLock", + type: "logic", + json: "assets/contracts/NFTLock.json", + address: ret.address, + network: hre.network.name, + }); + }; + + deployNFTClaim.tags = ["NFTLock"]; + +export default deployNFTClaim; diff --git a/deployments/imtbl_test/NFTClaimStage2.json b/deployments/imtbl_test/NFTClaimStage2.json deleted file mode 100644 index 3a737e4..0000000 --- a/deployments/imtbl_test/NFTClaimStage2.json +++ /dev/null @@ -1,707 +0,0 @@ -{ - "address": "0xf45702180314187a3549FEDac3B78349b47ca6A0", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_nftAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "_verifier", - "type": "address" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "parse1MaxSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "maxSupply", - "type": "uint256" - }, - { - "internalType": "address", - "name": "currency", - "type": "address" - }, - { - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "feeToAddress", - "type": "address" - } - ], - "internalType": "struct NFTClaimStage2.MintConfig", - "name": "_mintConfig", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "parse1MaxSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "maxSupply", - "type": "uint256" - }, - { - "internalType": "address", - "name": "currency", - "type": "address" - }, - { - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "feeToAddress", - "type": "address" - } - ], - "indexed": false, - "internalType": "struct NFTClaimStage2.MintConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "MintConfigUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "nftAddress", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "ids", - "type": "uint256[]" - } - ], - "name": "NFTClaimed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "_parse", - "type": "uint256" - } - ], - "name": "ParseUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "verifier", - "type": "address" - } - ], - "name": "VerifierUpdated", - "type": "event" - }, - { - "inputs": [], - "name": "_CACHED_CHAIN_ID", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "_CACHED_THIS", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "signer", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "checkSigner", - "outputs": [], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256[]", - "name": "ids", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "tokenAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "saltNonce", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "claim", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "address", - "name": "_address", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "_ids", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "_tokenAmount", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_contract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_chainId", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_saltNonce", - "type": "uint256" - } - ], - "name": "getMessageHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "mintConfig", - "outputs": [ - { - "internalType": "uint256", - "name": "parse1MaxSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "maxSupply", - "type": "uint256" - }, - { - "internalType": "address", - "name": "currency", - "type": "address" - }, - { - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "feeToAddress", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "mintParse", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "nftAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "parse1Count", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "totalCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "parse1MaxSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "maxSupply", - "type": "uint256" - }, - { - "internalType": "address", - "name": "currency", - "type": "address" - }, - { - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "feeToAddress", - "type": "address" - } - ], - "internalType": "struct NFTClaimStage2.MintConfig", - "name": "config", - "type": "tuple" - } - ], - "name": "updateMintConfig", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_mintParse", - "type": "uint256" - } - ], - "name": "updateMintParse", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_verifier", - "type": "address" - } - ], - "name": "updateVerifier", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "verifier", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "transactionHash": "0xea03f21dadb9169c0fbfded92459c644a3ae9e046165e552167486826d79f019", - "receipt": { - "to": null, - "from": "0x50A8e60041A206AcaA5F844a1104896224be6F39", - "contractAddress": "0xf45702180314187a3549FEDac3B78349b47ca6A0", - "transactionIndex": 0, - "gasUsed": "1200979", - "logsBloom": "0x00000000000000000000000000100000000000000000000000800000000800000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000020000000000000000000000000000000000000020000000000000000000000000000", - "blockHash": "0x5bda0e7ce87f77b2dbe72c2dacff7354bb4ac101a9995fc34d438e8e873fed56", - "transactionHash": "0xea03f21dadb9169c0fbfded92459c644a3ae9e046165e552167486826d79f019", - "logs": [ - { - "transactionIndex": 0, - "blockNumber": 9037735, - "transactionHash": "0xea03f21dadb9169c0fbfded92459c644a3ae9e046165e552167486826d79f019", - "address": "0xf45702180314187a3549FEDac3B78349b47ca6A0", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000050a8e60041a206acaa5f844a1104896224be6f39" - ], - "data": "0x", - "logIndex": 0, - "blockHash": "0x5bda0e7ce87f77b2dbe72c2dacff7354bb4ac101a9995fc34d438e8e873fed56" - } - ], - "blockNumber": 9037735, - "cumulativeGasUsed": "1200979", - "status": 1, - "byzantium": true - }, - "args": [ - "0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D", - "0x5Ab03Aa79Ab91B7420b5CFF134a4188388888888", - [ - 1000, - 2000, - "0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D", - 100, - "0x5Ab03Aa79Ab91B7420b5CFF134a4188388888888" - ] - ], - "numDeployments": 1, - "solcInputHash": "83285a095786820eb6eda6277c7f120a", - "metadata": "{\"compiler\":{\"version\":\"0.8.19+commit.7dd6d404\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_nftAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_verifier\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"parse1MaxSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSupply\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"currency\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeToAddress\",\"type\":\"address\"}],\"internalType\":\"struct NFTClaimStage2.MintConfig\",\"name\":\"_mintConfig\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"parse1MaxSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSupply\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"currency\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeToAddress\",\"type\":\"address\"}],\"indexed\":false,\"internalType\":\"struct NFTClaimStage2.MintConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"MintConfigUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nftAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"NFTClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_parse\",\"type\":\"uint256\"}],\"name\":\"ParseUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"verifier\",\"type\":\"address\"}],\"name\":\"VerifierUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_CACHED_CHAIN_ID\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_CACHED_THIS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"checkSigner\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"saltNonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"_ids\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"_tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_contract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_chainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_saltNonce\",\"type\":\"uint256\"}],\"name\":\"getMessageHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mintConfig\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"parse1MaxSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSupply\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"currency\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeToAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mintParse\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nftAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"parse1Count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"parse1MaxSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSupply\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"currency\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeToAddress\",\"type\":\"address\"}],\"internalType\":\"struct NFTClaimStage2.MintConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"updateMintConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_mintParse\",\"type\":\"uint256\"}],\"name\":\"updateMintParse\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_verifier\",\"type\":\"address\"}],\"name\":\"updateVerifier\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"verifier\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"claim(uint256[],uint256,uint256,bytes)\":{\"details\":\"claim NFT Get whitelist signature from a third-party service, then call this method to claim NFT\",\"params\":{\"saltNonce\":\"nonce\",\"signature\":\"signature\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"updateVerifier(address)\":{\"details\":\"update verifier address\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/activity/NFTClaimStage2.sol\":\"NFTClaimStage2\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[],\"viaIR\":true},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xba43b97fba0d32eb4254f6a5a297b39a19a247082a02d6e69349e071e2946218\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n _nonReentrantBefore();\\n _;\\n _nonReentrantAfter();\\n }\\n\\n function _nonReentrantBefore() private {\\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n }\\n\\n function _nonReentrantAfter() private {\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Returns true if the reentrancy guard is currently set to \\\"entered\\\", which indicates there is a\\n * `nonReentrant` function in the call stack.\\n */\\n function _reentrancyGuardEntered() internal view returns (bool) {\\n return _status == _ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0xa535a5df777d44e945dd24aa43a11e44b024140fc340ad0dfe42acf4002aade1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x287b55befed2961a7eabd7d7b1b2839cbca8a5b80ef8dcbb25ed3d4c2002c305\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n function _contextSuffixLength() internal view virtual returns (uint256) {\\n return 0;\\n }\\n}\\n\",\"keccak256\":\"0xa92e4fa126feb6907daa0513ddd816b2eb91f30a808de54f63c17d0e162c3439\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/Math.sol\\\";\\nimport \\\"./math/SignedMath.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = Math.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\\n */\\n function toString(int256 value) internal pure returns (string memory) {\\n return string(abi.encodePacked(value < 0 ? \\\"-\\\" : \\\"\\\", toString(SignedMath.abs(value))));\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, Math.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n\\n /**\\n * @dev Returns true if the two strings are equal.\\n */\\n function equal(string memory a, string memory b) internal pure returns (bool) {\\n return keccak256(bytes(a)) == keccak256(bytes(b));\\n }\\n}\\n\",\"keccak256\":\"0x3088eb2868e8d13d89d16670b5f8612c4ab9ff8956272837d8e90106c59c14a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV // Deprecated in v4.8\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, \\\"\\\\x19Ethereum Signed Message:\\\\n32\\\")\\n mstore(0x1c, hash)\\n message := keccak256(0x00, 0x3c)\\n }\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, \\\"\\\\x19\\\\x01\\\")\\n mstore(add(ptr, 0x02), domainSeparator)\\n mstore(add(ptr, 0x22), structHash)\\n data := keccak256(ptr, 0x42)\\n }\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Data with intended validator, created from a\\n * `validator` and `data` according to the version 0 of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x00\\\", validator, data));\\n }\\n}\\n\",\"keccak256\":\"0x809bc3edb4bcbef8263fa616c1b60ee0004b50a8a1bfa164d8f57fd31f520c58\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1, \\\"Math: mulDiv overflow\\\");\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe4455ac1eb7fc497bb7402579e7b4d64d928b846fce7d2b6fde06d366f21c2b3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two signed numbers.\\n */\\n function min(int256 a, int256 b) internal pure returns (int256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two signed numbers without overflow.\\n * The result is rounded towards zero.\\n */\\n function average(int256 a, int256 b) internal pure returns (int256) {\\n // Formula from the book \\\"Hacker's Delight\\\"\\n int256 x = (a & b) + ((a ^ b) >> 1);\\n return x + (int256(uint256(x) >> 255) & (a ^ b));\\n }\\n\\n /**\\n * @dev Returns the absolute unsigned value of a signed value.\\n */\\n function abs(int256 n) internal pure returns (uint256) {\\n unchecked {\\n // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf92515413956f529d95977adc9b0567d583c6203fc31ab1c23824c35187e3ddc\",\"license\":\"MIT\"},\"contracts/activity/NFTClaimStage2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport {ReentrancyGuard} from \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {HasSignature} from \\\"../core/HasSignature.sol\\\";\\n\\n/**\\n * Contract for the activity of NFT claim stage 2.\\n */\\ninterface IClaimAbleNFT {\\n function safeMint(address to, uint256 tokenID) external;\\n}\\n\\ncontract NFTClaimStage2 is HasSignature, ReentrancyGuard {\\n struct MintConfig {\\n uint256 parse1MaxSupply; // max supply for phase1\\n uint256 maxSupply; // max supply for phase2\\n address currency; // token address which user must pay to mint\\n uint256 mintPrice; // in wei\\n address feeToAddress; // wallet address to receive mint fee\\n }\\n // parse: 0: not open or end, 1: phase1, 2: phase2\\n uint256 public mintParse = 0;\\n\\n uint256 public immutable _CACHED_CHAIN_ID;\\n address public immutable _CACHED_THIS;\\n address public immutable nftAddress;\\n\\n address public verifier;\\n MintConfig public mintConfig;\\n uint256 public parse1Count;\\n uint256 public totalCount;\\n\\n event NFTClaimed(address indexed nftAddress, address indexed to, uint256[] ids);\\n\\n event ParseUpdated(uint256 _parse);\\n event MintConfigUpdated(MintConfig config);\\n event VerifierUpdated(address indexed verifier);\\n\\n constructor(address _nftAddress, address _verifier, MintConfig memory _mintConfig) {\\n _CACHED_CHAIN_ID = block.chainid;\\n _CACHED_THIS = address(this);\\n nftAddress = _nftAddress;\\n verifier = _verifier;\\n mintConfig = _mintConfig;\\n }\\n\\n modifier whenNotPaused() {\\n require(mintParse > 0, \\\"NFTClaimer: not begin or ended\\\");\\n _;\\n }\\n\\n function updateMintParse(uint256 _mintParse) external onlyOwner {\\n mintParse = _mintParse;\\n emit ParseUpdated(_mintParse);\\n }\\n\\n function updateMintConfig(MintConfig calldata config) external onlyOwner {\\n mintConfig = config;\\n emit MintConfigUpdated(config);\\n }\\n\\n /**\\n * @dev update verifier address\\n */\\n function updateVerifier(address _verifier) external onlyOwner {\\n require(_verifier != address(0), \\\"NFTClaimer: address can not be zero\\\");\\n verifier = _verifier;\\n emit VerifierUpdated(_verifier);\\n }\\n\\n /**\\n * @dev claim NFT\\n * Get whitelist signature from a third-party service, then call this method to claim NFT\\n * @param saltNonce nonce\\n * @param signature signature\\n */\\n function claim(\\n uint256[] memory ids,\\n uint256 tokenAmount,\\n uint256 saltNonce,\\n bytes calldata signature\\n ) external nonReentrant whenNotPaused {\\n // get current parse;\\n uint256 count = ids.length;\\n require(count > 0, \\\"NFTClaimer: ids length must be greater than 0\\\");\\n if (mintParse == 1) {\\n require(count <= mintConfig.parse1MaxSupply - parse1Count, \\\"NFTClaimer: exceed parse 1 max supply\\\");\\n } else {\\n require(count <= mintConfig.maxSupply - totalCount, \\\"NFTClaimer: exceed max supply\\\");\\n }\\n require(tokenAmount >= mintConfig.mintPrice * count, \\\"NFTClaimer: insufficient token amount\\\");\\n address to = _msgSender();\\n bytes32 criteriaMessageHash = getMessageHash(to, nftAddress, ids, tokenAmount, _CACHED_THIS, _CACHED_CHAIN_ID, saltNonce);\\n checkSigner(verifier, criteriaMessageHash, signature);\\n IERC20(mintConfig.currency).transferFrom(to, mintConfig.feeToAddress, tokenAmount);\\n for (uint256 i = 0; i < count; ++i) {\\n IClaimAbleNFT(nftAddress).safeMint(to, ids[i]);\\n }\\n // require(count > 2, \\\"run to here\\\");\\n totalCount += count;\\n if (mintParse == 1) {\\n parse1Count += count;\\n }\\n _useSignature(signature);\\n emit NFTClaimed(nftAddress, to, ids);\\n }\\n\\n function getMessageHash(\\n address _to,\\n address _address,\\n uint256[] memory _ids,\\n uint256 _tokenAmount,\\n address _contract,\\n uint256 _chainId,\\n uint256 _saltNonce\\n ) public pure returns (bytes32) {\\n bytes memory encoded = abi.encodePacked(_to, _address, _tokenAmount, _contract, _chainId, _saltNonce);\\n for (uint256 i = 0; i < _ids.length; ++i) {\\n encoded = bytes.concat(encoded, abi.encodePacked(_ids[i]));\\n }\\n return keccak256(encoded);\\n }\\n}\\n\",\"keccak256\":\"0xdd0caf9f3633dfff1217e0e08adb0524cca73f86ef1d5f6af18efb4798a9125f\",\"license\":\"MIT\"},\"contracts/core/HasSignature.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\nimport {ECDSA} from \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport {Ownable} from \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\ncontract HasSignature is Ownable {\\n mapping(bytes signature => bool status) private _usedSignatures;\\n\\n function checkSigner(\\n address signer,\\n bytes32 hash,\\n bytes memory signature\\n ) public pure {\\n bytes32 ethSignedMessageHash = ECDSA.toEthSignedMessageHash(hash);\\n\\n address recovered = ECDSA.recover(ethSignedMessageHash, signature);\\n require(recovered == signer, \\\"invalid signature\\\");\\n }\\n\\n modifier signatureValid(bytes calldata signature) {\\n require(\\n !_usedSignatures[signature],\\n \\\"signature used. please send another transaction with new signature\\\"\\n );\\n _;\\n }\\n\\n function _useSignature(bytes calldata signature) internal {\\n if (!_usedSignatures[signature]) {\\n _usedSignatures[signature] = true;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1999478f082b3dac416b579ea9385736e3015aa27ac7173c67555e21426ede51\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60e034620001ad576001600160401b0390601f6200132138819003918201601f191683019291848411838510176200019757808392604095865283398101039060e08212620001ad576200005381620001b2565b9060a06200006460208301620001b2565b93603f190112620001ad5783519460a08601908111868210176200019757845283810151855260608101519160208601928352620000a560808301620001b2565b858701908152620000c560c060a08501519460608a0195865201620001b2565b93608088019485526000549760018060a01b03199733898b1617600055519860018060a01b039788958692833391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a360016002556000600355466080523060a05260c05216886004541617600455516005555160065551168460075416176007555160085551169060095416176009556111599081620001c882396080518181816104af0152610b20015260a05181818161020601526104d2015260c0518181816104850152610a930152f35b634e487b7160e01b600052604160045260246000fd5b600080fd5b51906001600160a01b0382168203620001ad5756fe6040608081526004908136101561001557600080fd5b600091823560e01c80630c8e867f14610b625780632352a4bc14610b435780632b437d4814610b085780632b7ac3f314610ae157806334eafb1114610ac25780635bf8633a14610a7e5780636170141e146109b75780636d04319414610958578063715018a6146108fe5780638d633d9a146103b25780638da5cb5b1461038a57806397fc007c146102d1578063a1d891f014610254578063d2fb3b5314610235578063da28b527146101f1578063e7cc7244146101a15763f2fde38b146100dc57600080fd5b3461019d57602036600319011261019d576100f5610bca565b906100fe610cc6565b6001600160a01b0391821692831561014b57505082546001600160a01b0319811683178455167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b906020608492519162461bcd60e51b8352820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152fd5b8280fd5b5050346101ed57816003193601126101ed5760a0906005549060065490600180851b03908160075416906008549260095416938151958652602086015284015260608301526080820152f35b5080fd5b5050346101ed57816003193601126101ed57517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5050346101ed57816003193601126101ed576020906003549051908152f35b5091346102ce5760e03660031901126102ce5761026f610bca565b92602435916001600160a01b03831683036102ce576044359067ffffffffffffffff82116102ce5750916102ac602095926102c794369101610c5f565b916102b5610baf565b9060c4359360a4359360643592610db2565b9051908152f35b80fd5b503461019d57602036600319011261019d576102eb610bca565b6102f3610cc6565b6001600160a01b031691821561033b575080546001600160a01b031916821790557fd24015cc99cc1700cafca3042840a1d8ac1e3964fd2e0e37ea29c654056ee3278280a280f35b906020608492519162461bcd60e51b8352820152602360248201527f4e4654436c61696d65723a20616464726573732063616e206e6f74206265207a60448201526265726f60e81b6064820152fd5b5050346101ed57816003193601126101ed57905490516001600160a01b039091168152602090f35b503461019d57608036600319011261019d5767ffffffffffffffff9181358381116108fa576103e49036908401610c5f565b91602480356064918235928784116108f657366023850112156108f65783850135948886116108f25782850194838736920101116108f25760028054146108b3576002805560035498891561087357885194851561081c5760019a8b036107c557610454600554600a5490610d1e565b8611610776575b6008548681029080820488149015171561076457811061071557918b979593916104f9999795938b7f00000000000000000000000000000000000000000000000000000000000000009460449c8d928335907f000000000000000000000000000000000000000000000000000000000000000090867f0000000000000000000000000000000000000000000000000000000000000000918b33610db2565b85546001600160a01b03949161051d91861690610517368f8f610c18565b91610eb3565b8360075416918460095416918d519485936323b872dd60e01b8552338a8601528b8501528301528160209e8f945af180156106ce576106da575b509089969594938e9b93928c91169b5b8d87831061064c575050505050505061058281600b54610d7a565b600b558860035414610637575b5060ff84518483823783818681018c815203019020541615610614575b50505090815191818084019181855286518093528401950191875b87838210610602575050505050807ff1a869817733568a4d9fdcfb9d02c2e19967dfa6635304703a7f6881b42853119133940390a360025580f35b845188529682019693820193016105c7565b8284519384928337810188815203019020805460ff1916861790553882816105ac565b61064390600a54610d7a565b600a553861058f565b829394959697989950916106609192610d50565b518c3b156101ed578c8683928d519485938492632851206560e21b8452338b8501528c8401525af180156106ce576106ab575b5061069d90610d41565b90899695949392918e610567565b8281116106bc57895261069d610693565b634e487b7160e01b8f5260418452858ffd5b8f8b51903d90823e3d90fd5b8a81813d831161070e575b6106ef8183610be0565b8101031261070a5751801515036107065738610557565b8d80fd5b8e80fd5b503d6106e5565b885162461bcd60e51b81526020818501526025818701527f4e4654436c61696d65723a20696e73756666696369656e7420746f6b656e20616044820152641b5bdd5b9d60da1b81860152608490fd5b634e487b7160e01b8d5260118452858dfd5b885162461bcd60e51b81526020818501526025818701527f4e4654436c61696d65723a206578636565642070617273652031206d617820736044820152647570706c7960d81b81860152608490fd5b6107d4600654600b5490610d1e565b86111561045b575050601d83602089519362461bcd60e51b85528401528201527f4e4654436c61696d65723a20657863656564206d617820737570706c790000006044820152fd5b885162461bcd60e51b8152602081850152602d818701527f4e4654436c61696d65723a20696473206c656e677468206d757374206265206760448201526c0726561746572207468616e203609c1b81860152608490fd5b50601e83602089519362461bcd60e51b85528401528201527f4e4654436c61696d65723a206e6f7420626567696e206f7220656e64656400006044820152fd5b601f83602089519362461bcd60e51b85528401528201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b8980fd5b8880fd5b8480fd5b83346102ce57806003193601126102ce57610917610cc6565b80546001600160a01b03198116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b8382346101ed5760603660031901126101ed57610973610bca565b60443567ffffffffffffffff81116109b357366023820112156109b3576109b0928160246109a693369301359101610c18565b9060243590610eb3565b80f35b8380fd5b503461019d5760a036600319011261019d576109d1610cc6565b3560058190556024356006819055916001600160a01b03604435818116939290849003610a7a576bffffffffffffffffffffffff60a01b93808560075416176007556064359182600855608435968488168098036108f6577fde378c2c4aad676b12eb56e70a7f6f7778724a466508402b6c49de56dc11ffb89760a0976009541617600955815195865260208601528401526060830152610a70610baf565b166080820152a180f35b8580fd5b5050346101ed57816003193601126101ed57517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5050346101ed57816003193601126101ed57602090600b549051908152f35b503461019d578260031936011261019d575490516001600160a01b03909116815260209150f35b5050346101ed57816003193601126101ed57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b5050346101ed57816003193601126101ed57602090600a549051908152f35b503461019d57602036600319011261019d577f5ca814e8750431ce4d53faa6b24fbf00f6b53f5918a00ab430c0473ba6263424916020913590610ba3610cc6565b8160035551908152a180f35b608435906001600160a01b0382168203610bc557565b600080fd5b600435906001600160a01b0382168203610bc557565b90601f8019910116810190811067ffffffffffffffff821117610c0257604052565b634e487b7160e01b600052604160045260246000fd5b92919267ffffffffffffffff8211610c025760405191610c42601f8201601f191660200184610be0565b829481845281830111610bc5578281602093846000960137010152565b9080601f83011215610bc55781359067ffffffffffffffff8211610c02578160051b60405193602093610c9485840187610be0565b85528380860192820101928311610bc5578301905b828210610cb7575050505090565b81358152908301908301610ca9565b6000546001600160a01b03163303610cda57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b91908203918211610d2b57565b634e487b7160e01b600052601160045260246000fd5b6000198114610d2b5760010190565b8051821015610d645760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b91908201809211610d2b57565b9081519160005b838110610d9f575050016000815290565b8060208092840101518185015201610d8e565b969590929193946040928351966bffffffffffffffffffffffff1991826060978160209d8a1b168d8c0152881b1660348a01526048890152851b166068870152607c860152609c850152609c845260c084019367ffffffffffffffff9481811086821117610c0257825260009384915b8151861015610ea257610e358683610d50565b518451908a8201528981528481019181831089841117610e8e578291610e70610e6a610e8293610e88968a528a840190610d87565b82610d87565b03605f1981018352603f190182610be0565b95610d41565b94610e22565b634e487b7160e01b85526041600452602485fd5b969795505050505050815191012090565b90610ef592610eed917f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002061105c565b929092610f42565b6001600160a01b03908116911603610f0957565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c6964207369676e617475726560781b6044820152606490fd5b60058110156110465780610f535750565b60018103610fa05760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b60028103610fed5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b600314610ff657565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b90604181511460001461108a57611086916020820151906060604084015193015160001a90611094565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116111175791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa1561110a5781516001600160a01b03811615611104579190565b50600190565b50604051903d90823e3d90fd5b5050505060009060039056fea264697066735822122081889ddc0c5fc274d1bb327097bf318b9488a8bb95b074b314f1ae08a81d00dd64736f6c63430008130033", - "deployedBytecode": "0x6040608081526004908136101561001557600080fd5b600091823560e01c80630c8e867f14610b625780632352a4bc14610b435780632b437d4814610b085780632b7ac3f314610ae157806334eafb1114610ac25780635bf8633a14610a7e5780636170141e146109b75780636d04319414610958578063715018a6146108fe5780638d633d9a146103b25780638da5cb5b1461038a57806397fc007c146102d1578063a1d891f014610254578063d2fb3b5314610235578063da28b527146101f1578063e7cc7244146101a15763f2fde38b146100dc57600080fd5b3461019d57602036600319011261019d576100f5610bca565b906100fe610cc6565b6001600160a01b0391821692831561014b57505082546001600160a01b0319811683178455167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b906020608492519162461bcd60e51b8352820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152fd5b8280fd5b5050346101ed57816003193601126101ed5760a0906005549060065490600180851b03908160075416906008549260095416938151958652602086015284015260608301526080820152f35b5080fd5b5050346101ed57816003193601126101ed57517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5050346101ed57816003193601126101ed576020906003549051908152f35b5091346102ce5760e03660031901126102ce5761026f610bca565b92602435916001600160a01b03831683036102ce576044359067ffffffffffffffff82116102ce5750916102ac602095926102c794369101610c5f565b916102b5610baf565b9060c4359360a4359360643592610db2565b9051908152f35b80fd5b503461019d57602036600319011261019d576102eb610bca565b6102f3610cc6565b6001600160a01b031691821561033b575080546001600160a01b031916821790557fd24015cc99cc1700cafca3042840a1d8ac1e3964fd2e0e37ea29c654056ee3278280a280f35b906020608492519162461bcd60e51b8352820152602360248201527f4e4654436c61696d65723a20616464726573732063616e206e6f74206265207a60448201526265726f60e81b6064820152fd5b5050346101ed57816003193601126101ed57905490516001600160a01b039091168152602090f35b503461019d57608036600319011261019d5767ffffffffffffffff9181358381116108fa576103e49036908401610c5f565b91602480356064918235928784116108f657366023850112156108f65783850135948886116108f25782850194838736920101116108f25760028054146108b3576002805560035498891561087357885194851561081c5760019a8b036107c557610454600554600a5490610d1e565b8611610776575b6008548681029080820488149015171561076457811061071557918b979593916104f9999795938b7f00000000000000000000000000000000000000000000000000000000000000009460449c8d928335907f000000000000000000000000000000000000000000000000000000000000000090867f0000000000000000000000000000000000000000000000000000000000000000918b33610db2565b85546001600160a01b03949161051d91861690610517368f8f610c18565b91610eb3565b8360075416918460095416918d519485936323b872dd60e01b8552338a8601528b8501528301528160209e8f945af180156106ce576106da575b509089969594938e9b93928c91169b5b8d87831061064c575050505050505061058281600b54610d7a565b600b558860035414610637575b5060ff84518483823783818681018c815203019020541615610614575b50505090815191818084019181855286518093528401950191875b87838210610602575050505050807ff1a869817733568a4d9fdcfb9d02c2e19967dfa6635304703a7f6881b42853119133940390a360025580f35b845188529682019693820193016105c7565b8284519384928337810188815203019020805460ff1916861790553882816105ac565b61064390600a54610d7a565b600a553861058f565b829394959697989950916106609192610d50565b518c3b156101ed578c8683928d519485938492632851206560e21b8452338b8501528c8401525af180156106ce576106ab575b5061069d90610d41565b90899695949392918e610567565b8281116106bc57895261069d610693565b634e487b7160e01b8f5260418452858ffd5b8f8b51903d90823e3d90fd5b8a81813d831161070e575b6106ef8183610be0565b8101031261070a5751801515036107065738610557565b8d80fd5b8e80fd5b503d6106e5565b885162461bcd60e51b81526020818501526025818701527f4e4654436c61696d65723a20696e73756666696369656e7420746f6b656e20616044820152641b5bdd5b9d60da1b81860152608490fd5b634e487b7160e01b8d5260118452858dfd5b885162461bcd60e51b81526020818501526025818701527f4e4654436c61696d65723a206578636565642070617273652031206d617820736044820152647570706c7960d81b81860152608490fd5b6107d4600654600b5490610d1e565b86111561045b575050601d83602089519362461bcd60e51b85528401528201527f4e4654436c61696d65723a20657863656564206d617820737570706c790000006044820152fd5b885162461bcd60e51b8152602081850152602d818701527f4e4654436c61696d65723a20696473206c656e677468206d757374206265206760448201526c0726561746572207468616e203609c1b81860152608490fd5b50601e83602089519362461bcd60e51b85528401528201527f4e4654436c61696d65723a206e6f7420626567696e206f7220656e64656400006044820152fd5b601f83602089519362461bcd60e51b85528401528201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b8980fd5b8880fd5b8480fd5b83346102ce57806003193601126102ce57610917610cc6565b80546001600160a01b03198116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b8382346101ed5760603660031901126101ed57610973610bca565b60443567ffffffffffffffff81116109b357366023820112156109b3576109b0928160246109a693369301359101610c18565b9060243590610eb3565b80f35b8380fd5b503461019d5760a036600319011261019d576109d1610cc6565b3560058190556024356006819055916001600160a01b03604435818116939290849003610a7a576bffffffffffffffffffffffff60a01b93808560075416176007556064359182600855608435968488168098036108f6577fde378c2c4aad676b12eb56e70a7f6f7778724a466508402b6c49de56dc11ffb89760a0976009541617600955815195865260208601528401526060830152610a70610baf565b166080820152a180f35b8580fd5b5050346101ed57816003193601126101ed57517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5050346101ed57816003193601126101ed57602090600b549051908152f35b503461019d578260031936011261019d575490516001600160a01b03909116815260209150f35b5050346101ed57816003193601126101ed57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b5050346101ed57816003193601126101ed57602090600a549051908152f35b503461019d57602036600319011261019d577f5ca814e8750431ce4d53faa6b24fbf00f6b53f5918a00ab430c0473ba6263424916020913590610ba3610cc6565b8160035551908152a180f35b608435906001600160a01b0382168203610bc557565b600080fd5b600435906001600160a01b0382168203610bc557565b90601f8019910116810190811067ffffffffffffffff821117610c0257604052565b634e487b7160e01b600052604160045260246000fd5b92919267ffffffffffffffff8211610c025760405191610c42601f8201601f191660200184610be0565b829481845281830111610bc5578281602093846000960137010152565b9080601f83011215610bc55781359067ffffffffffffffff8211610c02578160051b60405193602093610c9485840187610be0565b85528380860192820101928311610bc5578301905b828210610cb7575050505090565b81358152908301908301610ca9565b6000546001600160a01b03163303610cda57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b91908203918211610d2b57565b634e487b7160e01b600052601160045260246000fd5b6000198114610d2b5760010190565b8051821015610d645760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b91908201809211610d2b57565b9081519160005b838110610d9f575050016000815290565b8060208092840101518185015201610d8e565b969590929193946040928351966bffffffffffffffffffffffff1991826060978160209d8a1b168d8c0152881b1660348a01526048890152851b166068870152607c860152609c850152609c845260c084019367ffffffffffffffff9481811086821117610c0257825260009384915b8151861015610ea257610e358683610d50565b518451908a8201528981528481019181831089841117610e8e578291610e70610e6a610e8293610e88968a528a840190610d87565b82610d87565b03605f1981018352603f190182610be0565b95610d41565b94610e22565b634e487b7160e01b85526041600452602485fd5b969795505050505050815191012090565b90610ef592610eed917f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002061105c565b929092610f42565b6001600160a01b03908116911603610f0957565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c6964207369676e617475726560781b6044820152606490fd5b60058110156110465780610f535750565b60018103610fa05760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b60028103610fed5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b600314610ff657565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b90604181511460001461108a57611086916020820151906060604084015193015160001a90611094565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116111175791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa1561110a5781516001600160a01b03811615611104579190565b50600190565b50604051903d90823e3d90fd5b5050505060009060039056fea264697066735822122081889ddc0c5fc274d1bb327097bf318b9488a8bb95b074b314f1ae08a81d00dd64736f6c63430008130033", - "devdoc": { - "kind": "dev", - "methods": { - "claim(uint256[],uint256,uint256,bytes)": { - "details": "claim NFT Get whitelist signature from a third-party service, then call this method to claim NFT", - "params": { - "saltNonce": "nonce", - "signature": "signature" - } - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." - }, - "transferOwnership(address)": { - "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." - }, - "updateVerifier(address)": { - "details": "update verifier address" - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 7, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "_owner", - "offset": 0, - "slot": "0", - "type": "t_address" - }, - { - "astId": 2251, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "_usedSignatures", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_bytes_memory_ptr,t_bool)" - }, - { - "astId": 123, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "_status", - "offset": 0, - "slot": "2", - "type": "t_uint256" - }, - { - "astId": 1886, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "mintParse", - "offset": 0, - "slot": "3", - "type": "t_uint256" - }, - { - "astId": 1894, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "verifier", - "offset": 0, - "slot": "4", - "type": "t_address" - }, - { - "astId": 1897, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "mintConfig", - "offset": 0, - "slot": "5", - "type": "t_struct(MintConfig)1883_storage" - }, - { - "astId": 1899, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "parse1Count", - "offset": 0, - "slot": "10", - "type": "t_uint256" - }, - { - "astId": 1901, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "totalCount", - "offset": 0, - "slot": "11", - "type": "t_uint256" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_bytes_memory_ptr": { - "encoding": "bytes", - "label": "bytes", - "numberOfBytes": "32" - }, - "t_mapping(t_bytes_memory_ptr,t_bool)": { - "encoding": "mapping", - "key": "t_bytes_memory_ptr", - "label": "mapping(bytes => bool)", - "numberOfBytes": "32", - "value": "t_bool" - }, - "t_struct(MintConfig)1883_storage": { - "encoding": "inplace", - "label": "struct NFTClaimStage2.MintConfig", - "members": [ - { - "astId": 1874, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "parse1MaxSupply", - "offset": 0, - "slot": "0", - "type": "t_uint256" - }, - { - "astId": 1876, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "maxSupply", - "offset": 0, - "slot": "1", - "type": "t_uint256" - }, - { - "astId": 1878, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "currency", - "offset": 0, - "slot": "2", - "type": "t_address" - }, - { - "astId": 1880, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "mintPrice", - "offset": 0, - "slot": "3", - "type": "t_uint256" - }, - { - "astId": 1882, - "contract": "contracts/activity/NFTClaimStage2.sol:NFTClaimStage2", - "label": "feeToAddress", - "offset": 0, - "slot": "4", - "type": "t_address" - } - ], - "numberOfBytes": "160" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - } - } - } -} \ No newline at end of file diff --git a/deployments/imtbl_test/NFTLock.json b/deployments/imtbl_test/NFTLock.json new file mode 100644 index 0000000..edece77 --- /dev/null +++ b/deployments/imtbl_test/NFTLock.json @@ -0,0 +1,878 @@ +{ + "address": "0x59e751c2037B710090035B6ea928e0cce80aC03f", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "_duration", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_verifier", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "duration", + "type": "uint256" + } + ], + "name": "DurationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenIds", + "type": "uint256[]" + } + ], + "name": "Lock", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isMint", + "type": "bool" + } + ], + "indexed": false, + "internalType": "struct NFTLock.NFTInfo[]", + "name": "nftList", + "type": "tuple[]" + } + ], + "name": "UnLock", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "VerifierUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "_CACHED_CHAIN_ID", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_CACHED_THIS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "nftList", + "type": "address[]" + } + ], + "name": "addSupportNftList", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "hash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "checkSigner", + "outputs": [], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "duration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "address", + "name": "_nft", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isMint", + "type": "bool" + } + ], + "internalType": "struct NFTLock.NFTInfo[]", + "name": "_ids", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "_contract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_signTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_saltNonce", + "type": "uint256" + } + ], + "name": "getMessageHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "tokenIds", + "type": "uint256[]" + } + ], + "name": "lock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "lockedNft", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "lockedNum", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "lockedOriginal", + "outputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC721Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nftAddress", + "type": "address" + } + ], + "name": "removeSupportNft", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nft", + "type": "address" + } + ], + "name": "supportNftList", + "outputs": [ + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "nft", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isMint", + "type": "bool" + } + ], + "internalType": "struct NFTLock.NFTInfo[]", + "name": "nftList", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "signTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "unlockOrMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "valNew", + "type": "uint256" + } + ], + "name": "updateDuation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_verifier", + "type": "address" + } + ], + "name": "updateVerifier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "verifier", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x2dab31b430e9af9379c4ec21a536e467002381b9792564ec3426fd295efff3fd", + "receipt": { + "to": null, + "from": "0x50A8e60041A206AcaA5F844a1104896224be6F39", + "contractAddress": "0x59e751c2037B710090035B6ea928e0cce80aC03f", + "transactionIndex": 0, + "gasUsed": "1486639", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000800000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000008000000080000000000020000000000000000000000000000000000000020000000000000000000000000000", + "blockHash": "0x51596d0b27fb4ab27e65ecca8776dbb52e323c16551c68a073611ec819270c29", + "transactionHash": "0x2dab31b430e9af9379c4ec21a536e467002381b9792564ec3426fd295efff3fd", + "logs": [ + { + "transactionIndex": 0, + "blockNumber": 9201924, + "transactionHash": "0x2dab31b430e9af9379c4ec21a536e467002381b9792564ec3426fd295efff3fd", + "address": "0x59e751c2037B710090035B6ea928e0cce80aC03f", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000050a8e60041a206acaa5f844a1104896224be6f39" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x51596d0b27fb4ab27e65ecca8776dbb52e323c16551c68a073611ec819270c29" + } + ], + "blockNumber": 9201924, + "cumulativeGasUsed": "1486639", + "status": 1, + "byzantium": true + }, + "args": [ + 3600, + "0x50A8e60041A206AcaA5F844a1104896224be6F39" + ], + "numDeployments": 1, + "solcInputHash": "ad8f004b84327b38774492b05d6f1de8", + "metadata": "{\"compiler\":{\"version\":\"0.8.19+commit.7dd6d404\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_duration\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_verifier\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"duration\",\"type\":\"uint256\"}],\"name\":\"DurationUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nft\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"}],\"name\":\"Lock\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nft\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isMint\",\"type\":\"bool\"}],\"indexed\":false,\"internalType\":\"struct NFTLock.NFTInfo[]\",\"name\":\"nftList\",\"type\":\"tuple[]\"}],\"name\":\"UnLock\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"verifier\",\"type\":\"address\"}],\"name\":\"VerifierUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_CACHED_CHAIN_ID\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_CACHED_THIS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"nftList\",\"type\":\"address[]\"}],\"name\":\"addSupportNftList\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"checkSigner\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"duration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_nft\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isMint\",\"type\":\"bool\"}],\"internalType\":\"struct NFTLock.NFTInfo[]\",\"name\":\"_ids\",\"type\":\"tuple[]\"},{\"internalType\":\"address\",\"name\":\"_contract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_chainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_signTime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_saltNonce\",\"type\":\"uint256\"}],\"name\":\"getMessageHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nft\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"}],\"name\":\"lock\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"lockedNft\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"lockedNum\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nft\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"lockedOriginal\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nftAddress\",\"type\":\"address\"}],\"name\":\"removeSupportNft\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nft\",\"type\":\"address\"}],\"name\":\"supportNftList\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nft\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isMint\",\"type\":\"bool\"}],\"internalType\":\"struct NFTLock.NFTInfo[]\",\"name\":\"nftList\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"signTime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"saltNonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"unlockOrMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"valNew\",\"type\":\"uint256\"}],\"name\":\"updateDuation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_verifier\",\"type\":\"address\"}],\"name\":\"updateVerifier\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"verifier\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"Paused(address)\":{\"details\":\"Emitted when the pause is triggered by `account`.\"},\"Unpaused(address)\":{\"details\":\"Emitted when the pause is lifted by `account`.\"}},\"kind\":\"dev\",\"methods\":{\"onERC721Received(address,address,uint256,bytes)\":{\"details\":\"See {IERC721Receiver-onERC721Received}. Always returns `IERC721Receiver.onERC721Received.selector`.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"unlockOrMint(address,(uint256,bool)[],uint256,uint256,bytes)\":{\"details\":\"unlock or mint nft if tokenId not exists, mint it if exists and user is owner, unlock it\"},\"updateDuation(uint256)\":{\"details\":\"Change duration value\"},\"updateVerifier(address)\":{\"details\":\"update verifier address\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"lockedNum(address,address)\":{\"notice\":\"------get------- *\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/game/NFTLock.sol\":\"NFTLock\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[],\"viaIR\":true},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xba43b97fba0d32eb4254f6a5a297b39a19a247082a02d6e69349e071e2946218\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/Pausable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract Pausable is Context {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n constructor() {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n _requireNotPaused();\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n _requirePaused();\\n _;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n}\\n\",\"keccak256\":\"0x0849d93b16c9940beb286a7864ed02724b248b93e0d80ef6355af5ef15c64773\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x5bce51e11f7d194b79ea59fe00c9e8de9fa2c5530124960f29a24d4c740a3266\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/utils/ERC721Holder.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC721Receiver.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC721Receiver} interface.\\n *\\n * Accepts all token transfers.\\n * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.\\n */\\ncontract ERC721Holder is IERC721Receiver {\\n /**\\n * @dev See {IERC721Receiver-onERC721Received}.\\n *\\n * Always returns `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {\\n return this.onERC721Received.selector;\\n }\\n}\\n\",\"keccak256\":\"0x67ef46fef257faae47adb630aad49694dda0334e5f7a7c5fb386243b974886b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n function _contextSuffixLength() internal view virtual returns (uint256) {\\n return 0;\\n }\\n}\\n\",\"keccak256\":\"0xa92e4fa126feb6907daa0513ddd816b2eb91f30a808de54f63c17d0e162c3439\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/Math.sol\\\";\\nimport \\\"./math/SignedMath.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = Math.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\\n */\\n function toString(int256 value) internal pure returns (string memory) {\\n return string(abi.encodePacked(value < 0 ? \\\"-\\\" : \\\"\\\", toString(SignedMath.abs(value))));\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, Math.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n\\n /**\\n * @dev Returns true if the two strings are equal.\\n */\\n function equal(string memory a, string memory b) internal pure returns (bool) {\\n return keccak256(bytes(a)) == keccak256(bytes(b));\\n }\\n}\\n\",\"keccak256\":\"0x3088eb2868e8d13d89d16670b5f8612c4ab9ff8956272837d8e90106c59c14a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV // Deprecated in v4.8\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, \\\"\\\\x19Ethereum Signed Message:\\\\n32\\\")\\n mstore(0x1c, hash)\\n message := keccak256(0x00, 0x3c)\\n }\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, \\\"\\\\x19\\\\x01\\\")\\n mstore(add(ptr, 0x02), domainSeparator)\\n mstore(add(ptr, 0x22), structHash)\\n data := keccak256(ptr, 0x42)\\n }\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Data with intended validator, created from a\\n * `validator` and `data` according to the version 0 of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x00\\\", validator, data));\\n }\\n}\\n\",\"keccak256\":\"0x809bc3edb4bcbef8263fa616c1b60ee0004b50a8a1bfa164d8f57fd31f520c58\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1, \\\"Math: mulDiv overflow\\\");\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe4455ac1eb7fc497bb7402579e7b4d64d928b846fce7d2b6fde06d366f21c2b3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two signed numbers.\\n */\\n function min(int256 a, int256 b) internal pure returns (int256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two signed numbers without overflow.\\n * The result is rounded towards zero.\\n */\\n function average(int256 a, int256 b) internal pure returns (int256) {\\n // Formula from the book \\\"Hacker's Delight\\\"\\n int256 x = (a & b) + ((a ^ b) >> 1);\\n return x + (int256(uint256(x) >> 255) & (a ^ b));\\n }\\n\\n /**\\n * @dev Returns the absolute unsigned value of a signed value.\\n */\\n function abs(int256 n) internal pure returns (uint256) {\\n unchecked {\\n // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf92515413956f529d95977adc9b0567d583c6203fc31ab1c23824c35187e3ddc\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```solidity\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x9f4357008a8f7d8c8bf5d48902e789637538d8c016be5766610901b4bba81514\",\"license\":\"MIT\"},\"contracts/core/HasSignature.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\nimport {ECDSA} from \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport {Ownable} from \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\ncontract HasSignature is Ownable {\\n mapping(bytes signature => bool status) private _usedSignatures;\\n\\n function checkSigner(\\n address signer,\\n bytes32 hash,\\n bytes memory signature\\n ) public pure {\\n bytes32 ethSignedMessageHash = ECDSA.toEthSignedMessageHash(hash);\\n\\n address recovered = ECDSA.recover(ethSignedMessageHash, signature);\\n require(recovered == signer, \\\"invalid signature\\\");\\n }\\n\\n modifier signatureValid(bytes calldata signature) {\\n require(\\n !_usedSignatures[signature],\\n \\\"signature used. please send another transaction with new signature\\\"\\n );\\n _;\\n }\\n\\n function _useSignature(bytes calldata signature) internal {\\n if (!_usedSignatures[signature]) {\\n _usedSignatures[signature] = true;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1999478f082b3dac416b579ea9385736e3015aa27ac7173c67555e21426ede51\",\"license\":\"MIT\"},\"contracts/game/NFTLock.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\nimport {ERC721Holder} from \\\"@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol\\\";\\nimport {EnumerableSet} from \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport {Pausable} from \\\"@openzeppelin/contracts/security/Pausable.sol\\\";\\nimport {HasSignature} from \\\"../core/HasSignature.sol\\\";\\nimport {TimeChecker} from \\\"../utils/TimeChecker.sol\\\";\\n\\ninterface INFT {\\n function mint(address to, uint256 tokenID) external;\\n function transferFrom(address from, address to, uint256 tokenId) external;\\n}\\n\\ncontract NFTLock is ERC721Holder, HasSignature, TimeChecker, Pausable {\\n using EnumerableSet for EnumerableSet.UintSet;\\n\\n uint256 public immutable _CACHED_CHAIN_ID;\\n address public immutable _CACHED_THIS;\\n address public verifier;\\n\\n struct NFTInfo {\\n uint256 tokenId;\\n bool isMint;\\n }\\n mapping(address nft => mapping(uint256 tokenId => address user)) public lockedOriginal;\\n mapping(address nft => mapping(address user => EnumerableSet.UintSet tokenIdSet)) private lockedRecords;\\n mapping(address nft => bool status) public supportNftList;\\n\\n event UnLock(address indexed nft, address indexed user, uint256 nonce, NFTInfo[] nftList);\\n event Lock(address indexed nft, address indexed user, uint256[] tokenIds);\\n event VerifierUpdated(address indexed verifier);\\n\\n constructor(uint256 _duration, address _verifier) TimeChecker(_duration) {\\n _CACHED_CHAIN_ID = block.chainid;\\n _CACHED_THIS = address(this);\\n verifier = _verifier;\\n }\\n\\n function lock(address nft, uint256[] calldata tokenIds) external whenNotPaused{\\n require(tokenIds.length <= 100, \\\"tokenIds too many\\\");\\n address to = _msgSender();\\n for (uint256 i = 0; i < tokenIds.length; i++) {\\n INFT(nft).transferFrom(to, address(this), tokenIds[i]);\\n lockedOriginal[nft][tokenIds[i]] = to;\\n lockedRecords[nft][to].add(tokenIds[i]);\\n }\\n emit Lock(nft, to, tokenIds);\\n }\\n /**\\n * @dev unlock or mint nft\\n * if tokenId not exists, mint it\\n * if exists and user is owner, unlock it\\n */\\n function unlockOrMint(\\n address nft,\\n NFTInfo[] calldata nftList,\\n uint256 signTime,\\n uint256 saltNonce,\\n bytes calldata signature\\n ) external signatureValid(signature) timeValid(signTime) whenNotPaused {\\n require(nftList.length <= 100, \\\"tokenIds too many\\\");\\n address to = _msgSender();\\n bytes32 messageHash = getMessageHash(to, nft, nftList, _CACHED_THIS, _CACHED_CHAIN_ID, signTime, saltNonce);\\n checkSigner(verifier, messageHash, signature);\\n for (uint256 i = 0; i < nftList.length; i++) {\\n if (nftList[i].isMint) {\\n INFT(nft).mint(to, nftList[i].tokenId);\\n } else {\\n require(lockedOriginal[nft][nftList[i].tokenId] == to, \\\"not owner\\\");\\n INFT(nft).transferFrom(address(this), to, nftList[i].tokenId);\\n lockedRecords[nft][to].remove(nftList[i].tokenId);\\n delete lockedOriginal[nft][nftList[i].tokenId];\\n }\\n }\\n _useSignature(signature);\\n emit UnLock(nft, to, saltNonce, nftList);\\n }\\n\\n /** ------get------- **/\\n function lockedNum(address token, address user) public view returns (uint256) {\\n return lockedRecords[token][user].length();\\n }\\n\\n function lockedNft(address token, address user) public view returns (uint256[] memory) {\\n return lockedRecords[token][user].values();\\n }\\n\\n function addSupportNftList(address[] calldata nftList) external onlyOwner {\\n for (uint256 i = 0; i < nftList.length; i++) {\\n supportNftList[nftList[i]] = true;\\n }\\n }\\n function removeSupportNft(address nftAddress) external onlyOwner {\\n require(supportNftList[nftAddress], \\\"can't remove\\\");\\n delete supportNftList[nftAddress];\\n }\\n\\n /**\\n * @dev update verifier address\\n */\\n function updateVerifier(address _verifier) external onlyOwner {\\n require(_verifier != address(0), \\\"NFTClaimer: address can not be zero\\\");\\n verifier = _verifier;\\n emit VerifierUpdated(_verifier);\\n }\\n\\n function getMessageHash(\\n address _to,\\n address _nft,\\n NFTInfo[] memory _ids,\\n address _contract,\\n uint256 _chainId,\\n uint256 _signTime,\\n uint256 _saltNonce\\n ) public pure returns (bytes32) {\\n bytes memory encoded = abi.encodePacked(_to, _nft, _contract, _chainId, _signTime, _saltNonce);\\n for (uint256 i = 0; i < _ids.length; ++i) {\\n encoded = bytes.concat(encoded, abi.encodePacked(_ids[i].tokenId));\\n encoded = bytes.concat(encoded, abi.encodePacked(_ids[i].isMint));\\n }\\n return keccak256(encoded);\\n }\\n}\\n\",\"keccak256\":\"0x9e5757a5c0bd26614c67dec9f01b86fe0cb12b76bf17d49e3c6e33cf3fa74f91\",\"license\":\"MIT\"},\"contracts/utils/TimeChecker.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\nimport {Ownable} from \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\ncontract TimeChecker is Ownable {\\n uint256 public duration;\\n uint256 public minDuration;\\n\\n event DurationUpdated(uint256 indexed duration);\\n\\n constructor(uint256 _duration) {\\n duration = _duration;\\n minDuration = 30 minutes;\\n }\\n\\n /**\\n * @dev Check if the time is valid\\n */\\n modifier timeValid(uint256 time) {\\n require(\\n time + duration >= block.timestamp,\\n \\\"expired, please send another transaction with new signature\\\"\\n );\\n _;\\n }\\n\\n\\n /**\\n * @dev Change duration value\\n */\\n function updateDuation(uint256 valNew) external onlyOwner {\\n require(valNew > minDuration, \\\"duration too short\\\");\\n duration = valNew;\\n emit DurationUpdated(valNew);\\n }\\n}\\n\",\"keccak256\":\"0xeb1278f24da69d97bd3d0da549e0673fdfa0b319bf4ba2ed6b24fefa870f3af9\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60c0346100f657601f61194e38819003918201601f19168301916001600160401b038311848410176100fb5780849260409485528339810103126100f65780516020909101516001600160a01b039182821682036100f6576000543360018060a01b0319821617600055604051933391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a360025561070860035560048054466080523060a0526001600160a81b03191660089290921b610100600160a81b031691909117905561183c908161011282396080518181816103660152610eec015260a05181818161038801526108160152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe608080604052600436101561001357600080fd5b60003560e01c9081630fb5a6b414610fa3575080631275029214610f64578063150b7a0214610f0f5780632b437d4814610ed45780632b7ac3f314610ea75780634d8d0ac714610e5f5780635671576114610e415780635c975abb14610e1e5780635fb110ca14610d955780636d04319414610d4d578063715018a614610cf4578063799048fa14610c675780637f9d309614610bdc5780638da5cb5b14610bb35780638e47f63f14610a3057806397fc007c14610961578063a063472414610910578063d13344c914610845578063da28b52714610800578063dbfaa5801461025f578063f2fde38b1461019b5763f36b61d31461011157600080fd5b346101965760e03660031901126101965761012a610fbe565b610132610fd4565b6044356001600160401b0381116101965736602382011215610196576101629036906024816004013591016110f0565b606435916001600160a01b03831683036101965760209361018e9360c4359360a4359360843593611727565b604051908152f35b600080fd5b34610196576020366003190112610196576101b4610fbe565b6101bc611193565b6001600160a01b0390811690811561020b57600054826001600160601b0360a01b821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346101965760a036600319011261019657610278610fbe565b6001600160401b03806024351161019657366023602435011215610196578060243560040135116101965736602480356004013560061b81350101116101965760843590808211610196573660238301121561019657816004013511610196573660248260040135830101116101965760ff6040518260040135602484018237602081846004013581016001815203019020541661078a576002546044350180604435116107745742116107095761032e6114d0565b610341606460243560040135111561145b565b6103d96103af61035c366024356004013560248035016110f0565b60643590604435907f0000000000000000000000000000000000000000000000000000000000000000907f0000000000000000000000000000000000000000000000000000000000000000908833611727565b6004805460081c6001600160a01b031691906103d39036908601356024870161104f565b916111eb565b60005b6024356004013581106104dd575060ff60405182600401356024840182376020818460040135810160018152030190205416156104ac575b50604051604081016064358252604060208301526024356004013590526060810190602480350160005b602435600401358110610483575033936001600160a01b0316927ff3d71d6c5e51ea460dbafab10ee101a0f4be26a888e6b04a5b636173d63b322292908190039150a3005b90926040806001928635815261049b602088016110e3565b15156020820152019401910161043e565b6020604051828193600401356024820183376004013581016001815203019020600160ff1982541617905581610414565b60206104f4826024356004013560248035016115b6565b013580151581036101965715610587576001600160a01b038316906105238160248035600481013591016115b6565b35823b15610196576000926044849260405195869384926340c10f1960e01b845233600485015260248401525af191821561057b576105679261056c575b5061149b565b6103dc565b61057590610fea565b84610561565b6040513d6000823e3d90fd5b6001600160a01b03831660009081526005602052604090206105b38260248035600481013591016115b6565b356000526020523360018060a01b0360406000205416036106d8576105e3816024356004013560248035016115b6565b35906001600160a01b0384163b15610196576040516323b872dd60e01b81523060048201523360248201526044810192909252600082606481836001600160a01b0389165af191821561057b57610567926106c9575b5060018060a01b038416600052600660205260406000203360005260205261067b6040600020610674836024356004013560248035016115b6565b35906115c6565b506001600160a01b03841660009081526005602052604090206106a88260248035600481013591016115b6565b3560005260205260406000206001600160601b0360a01b815416905561149b565b6106d290610fea565b84610639565b60405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b6044820152606490fd5b60405162461bcd60e51b815260206004820152603b60248201527f657870697265642c20706c656173652073656e6420616e6f746865722074726160448201527f6e73616374696f6e2077697468206e6577207369676e617475726500000000006064820152608490fd5b634e487b7160e01b600052601160045260246000fd5b60405162461bcd60e51b815260206004820152604260248201527f7369676e617475726520757365642e20706c656173652073656e6420616e6f7460448201527f686572207472616e73616374696f6e2077697468206e6577207369676e617475606482015261726560f01b608482015260a490fd5b34610196576000366003190112610196576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346101965760403660031901126101965761085e610fbe565b610866610fd4565b60018060a01b0380921660005260209160068352604060002091166000528152604060002060405190818382549182815201908192600052846000209060005b868282106108fc5786866108bc8288038361102e565b604051928392818401908285525180915260408401929160005b8281106108e557505050500390f35b8351855286955093810193928101926001016108d6565b8354855290930192600192830192016108a6565b3461019657604036600319011261019657610929610fbe565b610931610fd4565b9060018060a01b038091166000526006602052604060002091166000526020526020604060002054604051908152f35b346101965760203660031901126101965761097a610fbe565b610982611193565b6001600160a01b0381169081156109df5760048054610100600160a81b03191660089290921b610100600160a81b03169190911790557fd24015cc99cc1700cafca3042840a1d8ac1e3964fd2e0e37ea29c654056ee327600080a2005b60405162461bcd60e51b815260206004820152602360248201527f4e4654436c61696d65723a20616464726573732063616e206e6f74206265207a60448201526265726f60e81b6064820152608490fd5b3461019657604036600319011261019657610a49610fbe565b6024356001600160401b03811161019657610a689036906004016110b3565b610a739291926114d0565b610a80606482111561145b565b6001600160a01b039091169060005b818110610aeb5750604051602080825281018290526001600160fb1b038211610196577ffa4fcf9122678b647ff5d9f7e030079388041514b1b489b702346021b4e4344e9160051b8094604083013760408133958101030190a3005b610af68183866114aa565b3590833b15610196576040516323b872dd60e01b8152336004820152306024820152604481019290925260008260648183885af191821561057b57610b9f92610ba4575b50836000526020600581526040600020610b558386896114aa565b3560005281526040600020336001600160601b0360a01b825416179055846000526006815260406000209033600052526105616040600020610b988386896114aa565b359061152c565b610a8f565b610bad90610fea565b85610b3a565b34610196576000366003190112610196576000546040516001600160a01b039091168152602090f35b3461019657602036600319011261019657600435610bf8611193565b600354811115610c2d57806002557f91abcc2d6823e3a3f11d31b208dd3065d2c6a791f1c7c9fe96a42ce12897eac5600080a2005b60405162461bcd60e51b8152602060048201526012602482015271191d5c985d1a5bdb881d1bdbc81cda1bdc9d60721b6044820152606490fd5b3461019657602036600319011261019657610c80610fbe565b610c88611193565b6001600160a01b031660008181526007602052604090205460ff1615610cc0576000908152600760205260409020805460ff19169055005b60405162461bcd60e51b815260206004820152600c60248201526b63616e27742072656d6f766560a01b6044820152606490fd5b3461019657600036600319011261019657610d0d611193565b600080546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461019657606036600319011261019657610d66610fbe565b604435906001600160401b03821161019657610d89610d93923690600401611095565b90602435906111eb565b005b3461019657602080600319360112610196576004356001600160401b03811161019657610dc69036906004016110b3565b610dce611193565b60005b818110610dda57005b610de58183856114aa565b356001600160a01b038116919082900361019657610e1991600052600785526040600020600160ff1982541617905561149b565b610dd1565b3461019657600036600319011261019657602060ff600454166040519015158152f35b34610196576000366003190112610196576020600354604051908152f35b346101965760403660031901126101965760206001600160a01b0380610e83610fbe565b16600052600582526040600020602435600052825260406000205416604051908152f35b346101965760003660031901126101965760045460405160089190911c6001600160a01b03168152602090f35b346101965760003660031901126101965760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b3461019657608036600319011261019657610f28610fbe565b50610f31610fd4565b506064356001600160401b03811161019657610f51903690600401611095565b50604051630a85bd0160e11b8152602090f35b34610196576020366003190112610196576001600160a01b03610f85610fbe565b166000526007602052602060ff604060002054166040519015158152f35b34610196576000366003190112610196576020906002548152f35b600435906001600160a01b038216820361019657565b602435906001600160a01b038216820361019657565b6001600160401b038111610ffd57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117610ffd57604052565b90601f801991011681019081106001600160401b03821117610ffd57604052565b9291926001600160401b038211610ffd5760405191611078601f8201601f19166020018461102e565b829481845281830111610196578281602093846000960137010152565b9080601f83011215610196578160206110b09335910161104f565b90565b9181601f84011215610196578235916001600160401b038311610196576020808501948460051b01011161019657565b3590811515820361019657565b6001600160401b039392848311610ffd57604092835195602092611119848460051b018961102e565b8388848152019260061b85019481861161019657925b85841061113f5750505050505050565b868483031261019657865190878201908282108583111761117e578892879284528635815261116f8388016110e3565b8382015281520193019261112f565b60246000634e487b7160e01b81526041600452fd5b6000546001600160a01b031633036111a757565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b9061122d92611225917f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c600020611394565b92909261127a565b6001600160a01b0390811691160361124157565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c6964207369676e617475726560781b6044820152606490fd5b600581101561137e578061128b5750565b600181036112d85760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b600281036113255760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b60031461132e57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b9060418151146000146113c2576113be916020820151906060604084015193015160001a906113cc565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831161144f5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156114425781516001600160a01b0381161561143c579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b1561146257565b60405162461bcd60e51b8152602060048201526011602482015270746f6b656e49647320746f6f206d616e7960781b6044820152606490fd5b60001981146107745760010190565b91908110156114ba5760051b0190565b634e487b7160e01b600052603260045260246000fd5b60ff600454166114dc57565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b80548210156114ba5760005260206000200190600090565b919060018301600090828252806020526040822054156000146115b0578454946801000000000000000086101561159c578361158c611575886001604098999a01855584611514565b819391549060031b91821b91600019901b19161790565b9055549382526020522055600190565b634e487b7160e01b83526041600452602483fd5b50925050565b91908110156114ba5760061b0190565b906001820190600092818452826020526040842054908115156000146116af576000199180830181811161169b5782549084820191821161168757808203611652575b5050508054801561163e578201916116218383611514565b909182549160031b1b191690555582526020526040812055600190565b634e487b7160e01b86526031600452602486fd5b6116726116626115759386611514565b90549060031b1c92839286611514565b90558652846020526040862055388080611609565b634e487b7160e01b88526011600452602488fd5b634e487b7160e01b87526011600452602487fd5b5050505090565b80518210156114ba5760209160051b010190565b9081519160005b8381106116e2575050016000815290565b80602080928401015181850152016116d1565b61172590611717611711949360405195869360208501906116ca565b906116ca565b03601f19810184528361102e565b565b939695919490966040978851946001600160601b031980928160209960601b168989015260601b16603487015260601b166048850152605c840152607c830152609c820152609c815260c081018181106001600160401b03821117610ffd5785526000905b83518210156117f8576117ec6117c46117f2926117a985886116b6565b515190895191878301528682526117bf82611013565b6116f5565b846117cf85886116b6565b51015115159088519160f81b86830152600182526117bf82611013565b9161149b565b9061178c565b93945050905081519101209056fea2646970667358221220a9a53469c4b1432f9ddf9ae806bec7d819ee6cd7d600b0c9c5c578fc102eaf0a64736f6c63430008130033", + "deployedBytecode": "0x608080604052600436101561001357600080fd5b60003560e01c9081630fb5a6b414610fa3575080631275029214610f64578063150b7a0214610f0f5780632b437d4814610ed45780632b7ac3f314610ea75780634d8d0ac714610e5f5780635671576114610e415780635c975abb14610e1e5780635fb110ca14610d955780636d04319414610d4d578063715018a614610cf4578063799048fa14610c675780637f9d309614610bdc5780638da5cb5b14610bb35780638e47f63f14610a3057806397fc007c14610961578063a063472414610910578063d13344c914610845578063da28b52714610800578063dbfaa5801461025f578063f2fde38b1461019b5763f36b61d31461011157600080fd5b346101965760e03660031901126101965761012a610fbe565b610132610fd4565b6044356001600160401b0381116101965736602382011215610196576101629036906024816004013591016110f0565b606435916001600160a01b03831683036101965760209361018e9360c4359360a4359360843593611727565b604051908152f35b600080fd5b34610196576020366003190112610196576101b4610fbe565b6101bc611193565b6001600160a01b0390811690811561020b57600054826001600160601b0360a01b821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346101965760a036600319011261019657610278610fbe565b6001600160401b03806024351161019657366023602435011215610196578060243560040135116101965736602480356004013560061b81350101116101965760843590808211610196573660238301121561019657816004013511610196573660248260040135830101116101965760ff6040518260040135602484018237602081846004013581016001815203019020541661078a576002546044350180604435116107745742116107095761032e6114d0565b610341606460243560040135111561145b565b6103d96103af61035c366024356004013560248035016110f0565b60643590604435907f0000000000000000000000000000000000000000000000000000000000000000907f0000000000000000000000000000000000000000000000000000000000000000908833611727565b6004805460081c6001600160a01b031691906103d39036908601356024870161104f565b916111eb565b60005b6024356004013581106104dd575060ff60405182600401356024840182376020818460040135810160018152030190205416156104ac575b50604051604081016064358252604060208301526024356004013590526060810190602480350160005b602435600401358110610483575033936001600160a01b0316927ff3d71d6c5e51ea460dbafab10ee101a0f4be26a888e6b04a5b636173d63b322292908190039150a3005b90926040806001928635815261049b602088016110e3565b15156020820152019401910161043e565b6020604051828193600401356024820183376004013581016001815203019020600160ff1982541617905581610414565b60206104f4826024356004013560248035016115b6565b013580151581036101965715610587576001600160a01b038316906105238160248035600481013591016115b6565b35823b15610196576000926044849260405195869384926340c10f1960e01b845233600485015260248401525af191821561057b576105679261056c575b5061149b565b6103dc565b61057590610fea565b84610561565b6040513d6000823e3d90fd5b6001600160a01b03831660009081526005602052604090206105b38260248035600481013591016115b6565b356000526020523360018060a01b0360406000205416036106d8576105e3816024356004013560248035016115b6565b35906001600160a01b0384163b15610196576040516323b872dd60e01b81523060048201523360248201526044810192909252600082606481836001600160a01b0389165af191821561057b57610567926106c9575b5060018060a01b038416600052600660205260406000203360005260205261067b6040600020610674836024356004013560248035016115b6565b35906115c6565b506001600160a01b03841660009081526005602052604090206106a88260248035600481013591016115b6565b3560005260205260406000206001600160601b0360a01b815416905561149b565b6106d290610fea565b84610639565b60405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b6044820152606490fd5b60405162461bcd60e51b815260206004820152603b60248201527f657870697265642c20706c656173652073656e6420616e6f746865722074726160448201527f6e73616374696f6e2077697468206e6577207369676e617475726500000000006064820152608490fd5b634e487b7160e01b600052601160045260246000fd5b60405162461bcd60e51b815260206004820152604260248201527f7369676e617475726520757365642e20706c656173652073656e6420616e6f7460448201527f686572207472616e73616374696f6e2077697468206e6577207369676e617475606482015261726560f01b608482015260a490fd5b34610196576000366003190112610196576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346101965760403660031901126101965761085e610fbe565b610866610fd4565b60018060a01b0380921660005260209160068352604060002091166000528152604060002060405190818382549182815201908192600052846000209060005b868282106108fc5786866108bc8288038361102e565b604051928392818401908285525180915260408401929160005b8281106108e557505050500390f35b8351855286955093810193928101926001016108d6565b8354855290930192600192830192016108a6565b3461019657604036600319011261019657610929610fbe565b610931610fd4565b9060018060a01b038091166000526006602052604060002091166000526020526020604060002054604051908152f35b346101965760203660031901126101965761097a610fbe565b610982611193565b6001600160a01b0381169081156109df5760048054610100600160a81b03191660089290921b610100600160a81b03169190911790557fd24015cc99cc1700cafca3042840a1d8ac1e3964fd2e0e37ea29c654056ee327600080a2005b60405162461bcd60e51b815260206004820152602360248201527f4e4654436c61696d65723a20616464726573732063616e206e6f74206265207a60448201526265726f60e81b6064820152608490fd5b3461019657604036600319011261019657610a49610fbe565b6024356001600160401b03811161019657610a689036906004016110b3565b610a739291926114d0565b610a80606482111561145b565b6001600160a01b039091169060005b818110610aeb5750604051602080825281018290526001600160fb1b038211610196577ffa4fcf9122678b647ff5d9f7e030079388041514b1b489b702346021b4e4344e9160051b8094604083013760408133958101030190a3005b610af68183866114aa565b3590833b15610196576040516323b872dd60e01b8152336004820152306024820152604481019290925260008260648183885af191821561057b57610b9f92610ba4575b50836000526020600581526040600020610b558386896114aa565b3560005281526040600020336001600160601b0360a01b825416179055846000526006815260406000209033600052526105616040600020610b988386896114aa565b359061152c565b610a8f565b610bad90610fea565b85610b3a565b34610196576000366003190112610196576000546040516001600160a01b039091168152602090f35b3461019657602036600319011261019657600435610bf8611193565b600354811115610c2d57806002557f91abcc2d6823e3a3f11d31b208dd3065d2c6a791f1c7c9fe96a42ce12897eac5600080a2005b60405162461bcd60e51b8152602060048201526012602482015271191d5c985d1a5bdb881d1bdbc81cda1bdc9d60721b6044820152606490fd5b3461019657602036600319011261019657610c80610fbe565b610c88611193565b6001600160a01b031660008181526007602052604090205460ff1615610cc0576000908152600760205260409020805460ff19169055005b60405162461bcd60e51b815260206004820152600c60248201526b63616e27742072656d6f766560a01b6044820152606490fd5b3461019657600036600319011261019657610d0d611193565b600080546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461019657606036600319011261019657610d66610fbe565b604435906001600160401b03821161019657610d89610d93923690600401611095565b90602435906111eb565b005b3461019657602080600319360112610196576004356001600160401b03811161019657610dc69036906004016110b3565b610dce611193565b60005b818110610dda57005b610de58183856114aa565b356001600160a01b038116919082900361019657610e1991600052600785526040600020600160ff1982541617905561149b565b610dd1565b3461019657600036600319011261019657602060ff600454166040519015158152f35b34610196576000366003190112610196576020600354604051908152f35b346101965760403660031901126101965760206001600160a01b0380610e83610fbe565b16600052600582526040600020602435600052825260406000205416604051908152f35b346101965760003660031901126101965760045460405160089190911c6001600160a01b03168152602090f35b346101965760003660031901126101965760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b3461019657608036600319011261019657610f28610fbe565b50610f31610fd4565b506064356001600160401b03811161019657610f51903690600401611095565b50604051630a85bd0160e11b8152602090f35b34610196576020366003190112610196576001600160a01b03610f85610fbe565b166000526007602052602060ff604060002054166040519015158152f35b34610196576000366003190112610196576020906002548152f35b600435906001600160a01b038216820361019657565b602435906001600160a01b038216820361019657565b6001600160401b038111610ffd57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117610ffd57604052565b90601f801991011681019081106001600160401b03821117610ffd57604052565b9291926001600160401b038211610ffd5760405191611078601f8201601f19166020018461102e565b829481845281830111610196578281602093846000960137010152565b9080601f83011215610196578160206110b09335910161104f565b90565b9181601f84011215610196578235916001600160401b038311610196576020808501948460051b01011161019657565b3590811515820361019657565b6001600160401b039392848311610ffd57604092835195602092611119848460051b018961102e565b8388848152019260061b85019481861161019657925b85841061113f5750505050505050565b868483031261019657865190878201908282108583111761117e578892879284528635815261116f8388016110e3565b8382015281520193019261112f565b60246000634e487b7160e01b81526041600452fd5b6000546001600160a01b031633036111a757565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b9061122d92611225917f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c600020611394565b92909261127a565b6001600160a01b0390811691160361124157565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c6964207369676e617475726560781b6044820152606490fd5b600581101561137e578061128b5750565b600181036112d85760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b600281036113255760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b60031461132e57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b9060418151146000146113c2576113be916020820151906060604084015193015160001a906113cc565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831161144f5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156114425781516001600160a01b0381161561143c579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b1561146257565b60405162461bcd60e51b8152602060048201526011602482015270746f6b656e49647320746f6f206d616e7960781b6044820152606490fd5b60001981146107745760010190565b91908110156114ba5760051b0190565b634e487b7160e01b600052603260045260246000fd5b60ff600454166114dc57565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b80548210156114ba5760005260206000200190600090565b919060018301600090828252806020526040822054156000146115b0578454946801000000000000000086101561159c578361158c611575886001604098999a01855584611514565b819391549060031b91821b91600019901b19161790565b9055549382526020522055600190565b634e487b7160e01b83526041600452602483fd5b50925050565b91908110156114ba5760061b0190565b906001820190600092818452826020526040842054908115156000146116af576000199180830181811161169b5782549084820191821161168757808203611652575b5050508054801561163e578201916116218383611514565b909182549160031b1b191690555582526020526040812055600190565b634e487b7160e01b86526031600452602486fd5b6116726116626115759386611514565b90549060031b1c92839286611514565b90558652846020526040862055388080611609565b634e487b7160e01b88526011600452602488fd5b634e487b7160e01b87526011600452602487fd5b5050505090565b80518210156114ba5760209160051b010190565b9081519160005b8381106116e2575050016000815290565b80602080928401015181850152016116d1565b61172590611717611711949360405195869360208501906116ca565b906116ca565b03601f19810184528361102e565b565b939695919490966040978851946001600160601b031980928160209960601b168989015260601b16603487015260601b166048850152605c840152607c830152609c820152609c815260c081018181106001600160401b03821117610ffd5785526000905b83518210156117f8576117ec6117c46117f2926117a985886116b6565b515190895191878301528682526117bf82611013565b6116f5565b846117cf85886116b6565b51015115159088519160f81b86830152600182526117bf82611013565b9161149b565b9061178c565b93945050905081519101209056fea2646970667358221220a9a53469c4b1432f9ddf9ae806bec7d819ee6cd7d600b0c9c5c578fc102eaf0a64736f6c63430008130033", + "devdoc": { + "events": { + "Paused(address)": { + "details": "Emitted when the pause is triggered by `account`." + }, + "Unpaused(address)": { + "details": "Emitted when the pause is lifted by `account`." + } + }, + "kind": "dev", + "methods": { + "onERC721Received(address,address,uint256,bytes)": { + "details": "See {IERC721Receiver-onERC721Received}. Always returns `IERC721Receiver.onERC721Received.selector`." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "unlockOrMint(address,(uint256,bool)[],uint256,uint256,bytes)": { + "details": "unlock or mint nft if tokenId not exists, mint it if exists and user is owner, unlock it" + }, + "updateDuation(uint256)": { + "details": "Change duration value" + }, + "updateVerifier(address)": { + "details": "update verifier address" + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "lockedNum(address,address)": { + "notice": "------get------- *" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 7, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 2614, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "_usedSignatures", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes_memory_ptr,t_bool)" + }, + { + "astId": 3234, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "duration", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 3236, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "minDuration", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 130, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "_paused", + "offset": 0, + "slot": "4", + "type": "t_bool" + }, + { + "astId": 2728, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "verifier", + "offset": 1, + "slot": "4", + "type": "t_address" + }, + { + "astId": 2739, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "lockedOriginal", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_address))" + }, + { + "astId": 2746, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "lockedRecords", + "offset": 0, + "slot": "6", + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(UintSet)2472_storage))" + }, + { + "astId": 2750, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "supportNftList", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_address,t_bool)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_bytes32)dyn_storage": { + "base": "t_bytes32", + "encoding": "dynamic_array", + "label": "bytes32[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_bytes_memory_ptr": { + "encoding": "bytes", + "label": "bytes", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_mapping(t_address,t_struct(UintSet)2472_storage))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => struct EnumerableSet.UintSet))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_struct(UintSet)2472_storage)" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_address))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(uint256 => address))", + "numberOfBytes": "32", + "value": "t_mapping(t_uint256,t_address)" + }, + "t_mapping(t_address,t_struct(UintSet)2472_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct EnumerableSet.UintSet)", + "numberOfBytes": "32", + "value": "t_struct(UintSet)2472_storage" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_bytes_memory_ptr,t_bool)": { + "encoding": "mapping", + "key": "t_bytes_memory_ptr", + "label": "mapping(bytes => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_uint256,t_address)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_struct(Set)2000_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 1995, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 1999, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_struct(UintSet)2472_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.UintSet", + "members": [ + { + "astId": 2471, + "contract": "contracts/game/NFTLock.sol:NFTLock", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)2000_storage" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/deployments/imtbl_test/solcInputs/83285a095786820eb6eda6277c7f120a.json b/deployments/imtbl_test/solcInputs/ad8f004b84327b38774492b05d6f1de8.json similarity index 52% rename from deployments/imtbl_test/solcInputs/83285a095786820eb6eda6277c7f120a.json rename to deployments/imtbl_test/solcInputs/ad8f004b84327b38774492b05d6f1de8.json index 9170564..37426d3 100644 --- a/deployments/imtbl_test/solcInputs/83285a095786820eb6eda6277c7f120a.json +++ b/deployments/imtbl_test/solcInputs/ad8f004b84327b38774492b05d6f1de8.json @@ -4,11 +4,17 @@ "@openzeppelin/contracts/access/Ownable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" }, - "@openzeppelin/contracts/security/ReentrancyGuard.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n}\n" + "@openzeppelin/contracts/security/Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n" + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/utils/ERC721Holder.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Receiver.sol\";\n\n/**\n * @dev Implementation of the {IERC721Receiver} interface.\n *\n * Accepts all token transfers.\n * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.\n */\ncontract ERC721Holder is IERC721Receiver {\n /**\n * @dev See {IERC721Receiver-onERC721Received}.\n *\n * Always returns `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {\n return this.onERC721Received.selector;\n }\n}\n" }, "@openzeppelin/contracts/utils/Context.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n" @@ -16,6 +22,9 @@ "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n รท 2 + 1, and for v in (302): v โˆˆ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\")\n mstore(0x1c, hash)\n message := keccak256(0x00, 0x3c)\n }\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, \"\\x19\\x01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n data := keccak256(ptr, 0x42)\n }\n }\n\n /**\n * @dev Returns an Ethereum Signed Data with intended validator, created from a\n * `validator` and `data` according to the version 0 of EIP-191.\n *\n * See {recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x00\", validator, data));\n }\n}\n" }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, "@openzeppelin/contracts/utils/math/Math.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1, \"Math: mulDiv overflow\");\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // โ†’ `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // โ†’ `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n" }, @@ -25,11 +34,17 @@ "@openzeppelin/contracts/utils/Strings.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toString(int256 value) internal pure returns (string memory) {\n return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value))));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" }, - "contracts/activity/NFTClaimStage2.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport {ReentrancyGuard} from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {HasSignature} from \"../core/HasSignature.sol\";\n\n/**\n * Contract for the activity of NFT claim stage 2.\n */\ninterface IClaimAbleNFT {\n function safeMint(address to, uint256 tokenID) external;\n}\n\ncontract NFTClaimStage2 is HasSignature, ReentrancyGuard {\n struct MintConfig {\n uint256 parse1MaxSupply; // max supply for phase1\n uint256 maxSupply; // max supply for phase2\n address currency; // token address which user must pay to mint\n uint256 mintPrice; // in wei\n address feeToAddress; // wallet address to receive mint fee\n }\n // parse: 0: not open or end, 1: phase1, 2: phase2\n uint256 public mintParse = 0;\n\n uint256 public immutable _CACHED_CHAIN_ID;\n address public immutable _CACHED_THIS;\n address public immutable nftAddress;\n\n address public verifier;\n MintConfig public mintConfig;\n uint256 public parse1Count;\n uint256 public totalCount;\n\n event NFTClaimed(address indexed nftAddress, address indexed to, uint256[] ids);\n\n event ParseUpdated(uint256 _parse);\n event MintConfigUpdated(MintConfig config);\n event VerifierUpdated(address indexed verifier);\n\n constructor(address _nftAddress, address _verifier, MintConfig memory _mintConfig) {\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_THIS = address(this);\n nftAddress = _nftAddress;\n verifier = _verifier;\n mintConfig = _mintConfig;\n }\n\n modifier whenNotPaused() {\n require(mintParse > 0, \"NFTClaimer: not begin or ended\");\n _;\n }\n\n function updateMintParse(uint256 _mintParse) external onlyOwner {\n mintParse = _mintParse;\n emit ParseUpdated(_mintParse);\n }\n\n function updateMintConfig(MintConfig calldata config) external onlyOwner {\n mintConfig = config;\n emit MintConfigUpdated(config);\n }\n\n /**\n * @dev update verifier address\n */\n function updateVerifier(address _verifier) external onlyOwner {\n require(_verifier != address(0), \"NFTClaimer: address can not be zero\");\n verifier = _verifier;\n emit VerifierUpdated(_verifier);\n }\n\n /**\n * @dev claim NFT\n * Get whitelist signature from a third-party service, then call this method to claim NFT\n * @param saltNonce nonce\n * @param signature signature\n */\n function claim(\n uint256[] memory ids,\n uint256 tokenAmount,\n uint256 saltNonce,\n bytes calldata signature\n ) external nonReentrant whenNotPaused {\n // get current parse;\n uint256 count = ids.length;\n require(count > 0, \"NFTClaimer: ids length must be greater than 0\");\n if (mintParse == 1) {\n require(count <= mintConfig.parse1MaxSupply - parse1Count, \"NFTClaimer: exceed parse 1 max supply\");\n } else {\n require(count <= mintConfig.maxSupply - totalCount, \"NFTClaimer: exceed max supply\");\n }\n require(tokenAmount >= mintConfig.mintPrice * count, \"NFTClaimer: insufficient token amount\");\n address to = _msgSender();\n bytes32 criteriaMessageHash = getMessageHash(to, nftAddress, ids, tokenAmount, _CACHED_THIS, _CACHED_CHAIN_ID, saltNonce);\n checkSigner(verifier, criteriaMessageHash, signature);\n IERC20(mintConfig.currency).transferFrom(to, mintConfig.feeToAddress, tokenAmount);\n for (uint256 i = 0; i < count; ++i) {\n IClaimAbleNFT(nftAddress).safeMint(to, ids[i]);\n }\n // require(count > 2, \"run to here\");\n totalCount += count;\n if (mintParse == 1) {\n parse1Count += count;\n }\n _useSignature(signature);\n emit NFTClaimed(nftAddress, to, ids);\n }\n\n function getMessageHash(\n address _to,\n address _address,\n uint256[] memory _ids,\n uint256 _tokenAmount,\n address _contract,\n uint256 _chainId,\n uint256 _saltNonce\n ) public pure returns (bytes32) {\n bytes memory encoded = abi.encodePacked(_to, _address, _tokenAmount, _contract, _chainId, _saltNonce);\n for (uint256 i = 0; i < _ids.length; ++i) {\n encoded = bytes.concat(encoded, abi.encodePacked(_ids[i]));\n }\n return keccak256(encoded);\n }\n}\n" + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" }, "contracts/core/HasSignature.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract HasSignature is Ownable {\n mapping(bytes signature => bool status) private _usedSignatures;\n\n function checkSigner(\n address signer,\n bytes32 hash,\n bytes memory signature\n ) public pure {\n bytes32 ethSignedMessageHash = ECDSA.toEthSignedMessageHash(hash);\n\n address recovered = ECDSA.recover(ethSignedMessageHash, signature);\n require(recovered == signer, \"invalid signature\");\n }\n\n modifier signatureValid(bytes calldata signature) {\n require(\n !_usedSignatures[signature],\n \"signature used. please send another transaction with new signature\"\n );\n _;\n }\n\n function _useSignature(bytes calldata signature) internal {\n if (!_usedSignatures[signature]) {\n _usedSignatures[signature] = true;\n }\n }\n}\n" + }, + "contracts/game/NFTLock.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {ERC721Holder} from \"@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol\";\nimport {EnumerableSet} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport {Pausable} from \"@openzeppelin/contracts/security/Pausable.sol\";\nimport {HasSignature} from \"../core/HasSignature.sol\";\nimport {TimeChecker} from \"../utils/TimeChecker.sol\";\n\ninterface INFT {\n function mint(address to, uint256 tokenID) external;\n function transferFrom(address from, address to, uint256 tokenId) external;\n}\n\ncontract NFTLock is ERC721Holder, HasSignature, TimeChecker, Pausable {\n using EnumerableSet for EnumerableSet.UintSet;\n\n uint256 public immutable _CACHED_CHAIN_ID;\n address public immutable _CACHED_THIS;\n address public verifier;\n\n struct NFTInfo {\n uint256 tokenId;\n bool isMint;\n }\n mapping(address nft => mapping(uint256 tokenId => address user)) public lockedOriginal;\n mapping(address nft => mapping(address user => EnumerableSet.UintSet tokenIdSet)) private lockedRecords;\n mapping(address nft => bool status) public supportNftList;\n\n event UnLock(address indexed nft, address indexed user, uint256 nonce, NFTInfo[] nftList);\n event Lock(address indexed nft, address indexed user, uint256[] tokenIds);\n event VerifierUpdated(address indexed verifier);\n\n constructor(uint256 _duration, address _verifier) TimeChecker(_duration) {\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_THIS = address(this);\n verifier = _verifier;\n }\n\n function lock(address nft, uint256[] calldata tokenIds) external whenNotPaused{\n require(tokenIds.length <= 100, \"tokenIds too many\");\n address to = _msgSender();\n for (uint256 i = 0; i < tokenIds.length; i++) {\n INFT(nft).transferFrom(to, address(this), tokenIds[i]);\n lockedOriginal[nft][tokenIds[i]] = to;\n lockedRecords[nft][to].add(tokenIds[i]);\n }\n emit Lock(nft, to, tokenIds);\n }\n /**\n * @dev unlock or mint nft\n * if tokenId not exists, mint it\n * if exists and user is owner, unlock it\n */\n function unlockOrMint(\n address nft,\n NFTInfo[] calldata nftList,\n uint256 signTime,\n uint256 saltNonce,\n bytes calldata signature\n ) external signatureValid(signature) timeValid(signTime) whenNotPaused {\n require(nftList.length <= 100, \"tokenIds too many\");\n address to = _msgSender();\n bytes32 messageHash = getMessageHash(to, nft, nftList, _CACHED_THIS, _CACHED_CHAIN_ID, signTime, saltNonce);\n checkSigner(verifier, messageHash, signature);\n for (uint256 i = 0; i < nftList.length; i++) {\n if (nftList[i].isMint) {\n INFT(nft).mint(to, nftList[i].tokenId);\n } else {\n require(lockedOriginal[nft][nftList[i].tokenId] == to, \"not owner\");\n INFT(nft).transferFrom(address(this), to, nftList[i].tokenId);\n lockedRecords[nft][to].remove(nftList[i].tokenId);\n delete lockedOriginal[nft][nftList[i].tokenId];\n }\n }\n _useSignature(signature);\n emit UnLock(nft, to, saltNonce, nftList);\n }\n\n /** ------get------- **/\n function lockedNum(address token, address user) public view returns (uint256) {\n return lockedRecords[token][user].length();\n }\n\n function lockedNft(address token, address user) public view returns (uint256[] memory) {\n return lockedRecords[token][user].values();\n }\n\n function addSupportNftList(address[] calldata nftList) external onlyOwner {\n for (uint256 i = 0; i < nftList.length; i++) {\n supportNftList[nftList[i]] = true;\n }\n }\n function removeSupportNft(address nftAddress) external onlyOwner {\n require(supportNftList[nftAddress], \"can't remove\");\n delete supportNftList[nftAddress];\n }\n\n /**\n * @dev update verifier address\n */\n function updateVerifier(address _verifier) external onlyOwner {\n require(_verifier != address(0), \"NFTClaimer: address can not be zero\");\n verifier = _verifier;\n emit VerifierUpdated(_verifier);\n }\n\n function getMessageHash(\n address _to,\n address _nft,\n NFTInfo[] memory _ids,\n address _contract,\n uint256 _chainId,\n uint256 _signTime,\n uint256 _saltNonce\n ) public pure returns (bytes32) {\n bytes memory encoded = abi.encodePacked(_to, _nft, _contract, _chainId, _signTime, _saltNonce);\n for (uint256 i = 0; i < _ids.length; ++i) {\n encoded = bytes.concat(encoded, abi.encodePacked(_ids[i].tokenId));\n encoded = bytes.concat(encoded, abi.encodePacked(_ids[i].isMint));\n }\n return keccak256(encoded);\n }\n}\n" + }, + "contracts/utils/TimeChecker.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract TimeChecker is Ownable {\n uint256 public duration;\n uint256 public minDuration;\n\n event DurationUpdated(uint256 indexed duration);\n\n constructor(uint256 _duration) {\n duration = _duration;\n minDuration = 30 minutes;\n }\n\n /**\n * @dev Check if the time is valid\n */\n modifier timeValid(uint256 time) {\n require(\n time + duration >= block.timestamp,\n \"expired, please send another transaction with new signature\"\n );\n _;\n }\n\n\n /**\n * @dev Change duration value\n */\n function updateDuation(uint256 valNew) external onlyOwner {\n require(valNew > minDuration, \"duration too short\");\n duration = valNew;\n emit DurationUpdated(valNew);\n }\n}\n" } }, "settings": { diff --git a/out/imtbl_test_dev.json b/out/imtbl_test_dev.json index 0360031..20a60da 100644 --- a/out/imtbl_test_dev.json +++ b/out/imtbl_test_dev.json @@ -16,5 +16,11 @@ "type": "logic", "json": "assets/contracts/NFTClaimStage2.json", "address": "0xf45702180314187a3549FEDac3B78349b47ca6A0" + }, + { + "name": "NFTLock", + "type": "logic", + "json": "assets/contracts/NFTLock.json", + "address": "0x59e751c2037B710090035B6ea928e0cce80aC03f" } ] \ No newline at end of file diff --git a/package.json b/package.json index 1d439be..d6e5603 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "deploy": "hardhat deploy --network imtbl_test", "deploy:nftclaim": "hardhat deploy --tags NFTClaimStage2 --network imtbl_test --reset", "deploy:nft": "hardhat deploy --tags CFNFTGame --network imtbl_test --reset", + "deploy:nftlock": "hardhat deploy --tags NFTLock --network imtbl_test --reset", "deploy:testtoken": "hardhat deploy --tags TestToken --network imtbl_test --reset", "solhint": "solhint --config ./.solhint.json" }, diff --git a/test/testNFTLocker.ts b/test/testNFTLocker.ts new file mode 100644 index 0000000..b634f58 --- /dev/null +++ b/test/testNFTLocker.ts @@ -0,0 +1,111 @@ +import { expect } from 'chai' +import hre from "hardhat"; +import { + getBytes, + solidityPackedKeccak256, +} from 'ethers' +import { + loadFixture, +} from "@nomicfoundation/hardhat-toolbox/network-helpers"; + +describe('NFTLock', function() { + async function deployOneContract() { + const [owner, otherAccount] = await hre.ethers.getSigners(); + const verifier = owner.address; + const OperatorAllowlist = await hre.ethers.getContractFactory("OperatorAllowlist"); + const operatorAllowlist = await OperatorAllowlist.deploy(owner.address); + + const CFNFTGame = await hre.ethers.getContractFactory("CFNFTGame"); + const nft = await CFNFTGame.deploy(owner.address, 'name', 'symbol', 'baseURI', 'contractURI', operatorAllowlist.target, owner.address, 5); + const nftAddress = nft.target; + const NFTLock = await hre.ethers.getContractFactory("NFTLock"); + + const nftLock = await NFTLock.deploy( 3600, verifier ); + await nft.grantMinterRole(nftLock.target) + await nft.grantMinterRole(owner.address) + await nftLock.addSupportNftList([nftAddress]); + await nft.mint(otherAccount.address, "1001"); + const chainId = hre.network.config.chainId + await operatorAllowlist.grantRegistrarRole(owner.address) + await operatorAllowlist.addAddressToAllowlist([nftLock.target]) + return { nftLock, owner, otherAccount, verifier, nftAddress, nft, chainId }; + } + describe("Deployment", function () { + it('should deploy NFTLock with the correct verifier', async function() { + const { nftLock, verifier } = await loadFixture(deployOneContract); + expect(await nftLock.verifier()).to.equal(verifier); + }); + it('should deploy NFTLock with the correct NFT address', async function() { + const { nftLock, nftAddress } = await loadFixture(deployOneContract); + expect(await nftLock.supportNftList(nftAddress)).to.equal(true); + }); + }) + + describe("Lock", function () { + it('should lock NFT', async function() { + const { nftLock, nft, otherAccount } = await loadFixture(deployOneContract); + const tokenId = "1001" + // @ts-ignore + await nft.connect(otherAccount).approve(nftLock.target, tokenId); + //@ts-ignore + await nftLock.connect(otherAccount).lock(nft.target, [tokenId]); + expect(await nft.balanceOf(nftLock.target)).to.equal(1); + expect(await nftLock.lockedOriginal(nft.target, tokenId)).to.equal(otherAccount.address); + expect(await nft.ownerOf(tokenId)).to.equal(nftLock.target); + }); + + + }) + + describe("UnLock", function () { + it('should unlock NFT from lock', async function() { + const { nftLock, nft, otherAccount, chainId, owner } = await loadFixture(deployOneContract); + const tokenId = '1001' + // @ts-ignore + await nft.connect(otherAccount).approve(nftLock.target, tokenId); + //@ts-ignore + await nftLock.connect(otherAccount).lock(nft.target, [tokenId]); + const nonce = (Math.random() * 1000) | 0; + const now = Date.now() / 1000 | 0; + let localMsgHash = solidityPackedKeccak256(["address", "address", "address", "uint256", "uint256", "uint256", "uint256", "bool"], + [otherAccount.address, nft.target, nftLock.target, chainId, now, nonce, tokenId, false]); + const signature = await owner.signMessage(getBytes(localMsgHash)); + //@ts-ignore + await nftLock.connect(otherAccount).unlockOrMint(nft.target, [[tokenId, false]], now, nonce, signature); + expect(await nft.ownerOf(tokenId)).to.equal(otherAccount.address); + }); + + it('should mint NFT from lock', async function() { + const { nftLock, nft, otherAccount, chainId, owner } = await loadFixture(deployOneContract); + const tokenId = '1002' + const isMint = true + + const nonce = (Math.random() * 1000) | 0; + const now = Date.now() / 1000 | 0; + let localMsgHash = solidityPackedKeccak256(["address", "address", "address", "uint256", "uint256", "uint256", "uint256", "bool"], + [otherAccount.address, nft.target, nftLock.target, chainId, now, nonce, tokenId, isMint]); + const signature = await owner.signMessage(getBytes(localMsgHash)); + //@ts-ignore + await nftLock.connect(otherAccount).unlockOrMint(nft.target, [[tokenId, isMint]], now, nonce, signature); + expect(await nft.ownerOf(tokenId)).to.equal(otherAccount.address); + }); + + it('should revert NFT mint for nft already minted', async function() { + const { nftLock, nft, otherAccount, chainId, owner } = await loadFixture(deployOneContract); + const tokenId = '1001' + const isMint = true + + const nonce = (Math.random() * 1000) | 0; + const now = Date.now() / 1000 | 0; + let localMsgHash = solidityPackedKeccak256(["address", "address", "address", "uint256", "uint256", "uint256", "uint256", "bool"], + [otherAccount.address, nft.target, nftLock.target, chainId, now, nonce, tokenId, isMint]); + const signature = await owner.signMessage(getBytes(localMsgHash)); + //@ts-ignore + await expect(nftLock.connect(otherAccount).unlockOrMint(nft.target, [[tokenId, isMint]], now, nonce, signature)).to.be.revertedWith( + "ERC721: token already minted" + ); + }); + }); + + +}) \ No newline at end of file