diff --git a/.openzeppelin/unknown-534351.json b/.openzeppelin/unknown-534351.json new file mode 100644 index 0000000..4370fdb --- /dev/null +++ b/.openzeppelin/unknown-534351.json @@ -0,0 +1,284 @@ +{ + "manifestVersion": "3.2", + "proxies": [ + { + "address": "0x5E6275fcF1a40CDD9A98F4bb106546626c62Cc1C", + "txHash": "0x3392f916db47e252cfcd26fda23abefcc7d8f854281c01937c2c9c96084140f9", + "kind": "transparent" + }, + { + "address": "0x1951a98a3989DA97a019E54c533B17538284C911", + "txHash": "0xef3857e4145334df109f2f0470c36821a07ad408751562bca75b89ffb9c31450", + "kind": "transparent" + }, + { + "address": "0x1de22a1395774c3ff6068b48E0452D5CD9cD067e", + "txHash": "0x6a1eed5ec3f33e7a2868fe41f409f9ab144d9fcbe44becd66eaf60ec36b78c66", + "kind": "transparent" + } + ], + "impls": { + "3bf7bb368c7220231dba6c0a3d92bd61d9082882a54f0c4c7e44d495f099172d": { + "address": "0xdE75f41A64701160482f26C8fadD745e455990BA", + "txHash": "0xd4c88d47d628cf25841fda234fb3a753fbc50c6aa3f69ffe6db30352f48985ae", + "layout": { + "solcVersion": "0.8.4", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:40" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "accessRegistry", + "offset": 0, + "slot": "101", + "type": "t_address", + "contract": "PaymentConfigRegistry", + "src": "contracts/payment/PaymentConfigRegistry.sol:21" + }, + { + "label": "authorizedSigner", + "offset": 0, + "slot": "102", + "type": "t_address", + "contract": "PaymentConfigRegistry", + "src": "contracts/payment/PaymentConfigRegistry.sol:22" + }, + { + "label": "feePPM", + "offset": 0, + "slot": "103", + "type": "t_uint256", + "contract": "PaymentConfigRegistry", + "src": "contracts/payment/PaymentConfigRegistry.sol:23" + }, + { + "label": "__gap", + "offset": 0, + "slot": "104", + "type": "t_array(t_uint256)20_storage", + "contract": "PaymentConfigRegistry", + "src": "contracts/payment/PaymentConfigRegistry.sol:24" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)20_storage": { + "label": "uint256[20]", + "numberOfBytes": "640" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + }, + "namespaces": {} + } + }, + "4c4e2f108a6dc9ff4bf3e23194d239343dc14798fb81d3af86b2ae2c62a0c651": { + "address": "0x97F1A187A64b8B1D01039757E635258dFD444681", + "txHash": "0xde8363032d4ccfeb077aa5b7d012cd0392fcdf94aa181e24a9e201fa7136313d", + "layout": { + "solcVersion": "0.8.4", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:40" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "configRegistry", + "offset": 0, + "slot": "101", + "type": "t_address", + "contract": "LemonadeRelayPayment", + "src": "contracts/payment/relay/LemonadeRelayPayment.sol:40" + }, + { + "label": "payments", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_bytes32,t_struct(Payment)24796_storage)", + "contract": "LemonadeRelayPayment", + "src": "contracts/payment/relay/LemonadeRelayPayment.sol:41" + }, + { + "label": "splitters", + "offset": 0, + "slot": "103", + "type": "t_mapping(t_address,t_bool)", + "contract": "LemonadeRelayPayment", + "src": "contracts/payment/relay/LemonadeRelayPayment.sol:42" + }, + { + "label": "__gap", + "offset": 0, + "slot": "104", + "type": "t_array(t_uint256)20_storage", + "contract": "LemonadeRelayPayment", + "src": "contracts/payment/relay/LemonadeRelayPayment.sol:43" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)20_storage": { + "label": "uint256[20]", + "numberOfBytes": "640" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_struct(Payment)24796_storage)": { + "label": "mapping(bytes32 => struct LemonadeRelayPayment.Payment)", + "numberOfBytes": "32" + }, + "t_struct(Payment)24796_storage": { + "label": "struct LemonadeRelayPayment.Payment", + "members": [ + { + "label": "guest", + "type": "t_address", + "offset": 0, + "slot": "0" + }, + { + "label": "currency", + "type": "t_address", + "offset": 0, + "slot": "1" + }, + { + "label": "amount", + "type": "t_uint256", + "offset": 0, + "slot": "2" + } + ], + "numberOfBytes": "96" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + }, + "namespaces": {} + } + } + } +} diff --git a/.openzeppelin/unknown-534352.json b/.openzeppelin/unknown-534352.json new file mode 100644 index 0000000..9ae9309 --- /dev/null +++ b/.openzeppelin/unknown-534352.json @@ -0,0 +1,284 @@ +{ + "manifestVersion": "3.2", + "proxies": [ + { + "address": "0x0face3fDBE5cCad109C97fE4131a1f69Ccf45e6e", + "txHash": "0x74cb670e8e5ae225b8cd7fa08899d59f420e0e65a04e1c0e6336adbed9a496af", + "kind": "transparent" + }, + { + "address": "0x8F06e23108403707d3F3D5630486693DFB826A6b", + "txHash": "0x50e5445155408278c2bded267b3e75268244ec9272c1e26d71aa4b7ce76ccd67", + "kind": "transparent" + }, + { + "address": "0xb10d362D99F29FcaA1D0a4091d6878b806F93383", + "txHash": "0x2515f9d8038cd0d9bae9de5bfff384331c73b3c735c813ddf0c01130f73a965b", + "kind": "transparent" + } + ], + "impls": { + "3bf7bb368c7220231dba6c0a3d92bd61d9082882a54f0c4c7e44d495f099172d": { + "address": "0x6065a5ec435854187b0b3225336b4FAdc1d01ce5", + "txHash": "0x8ee0abbfdddfc55214c24a6917d03aa355619d03198905759e6fef6c8ecf727f", + "layout": { + "solcVersion": "0.8.4", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:40" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "accessRegistry", + "offset": 0, + "slot": "101", + "type": "t_address", + "contract": "PaymentConfigRegistry", + "src": "contracts/payment/PaymentConfigRegistry.sol:21" + }, + { + "label": "authorizedSigner", + "offset": 0, + "slot": "102", + "type": "t_address", + "contract": "PaymentConfigRegistry", + "src": "contracts/payment/PaymentConfigRegistry.sol:22" + }, + { + "label": "feePPM", + "offset": 0, + "slot": "103", + "type": "t_uint256", + "contract": "PaymentConfigRegistry", + "src": "contracts/payment/PaymentConfigRegistry.sol:23" + }, + { + "label": "__gap", + "offset": 0, + "slot": "104", + "type": "t_array(t_uint256)20_storage", + "contract": "PaymentConfigRegistry", + "src": "contracts/payment/PaymentConfigRegistry.sol:24" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)20_storage": { + "label": "uint256[20]", + "numberOfBytes": "640" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + }, + "namespaces": {} + } + }, + "4c4e2f108a6dc9ff4bf3e23194d239343dc14798fb81d3af86b2ae2c62a0c651": { + "address": "0x9fAa5494298205c9E81aEB4aA9bE99c45D4CE6e5", + "txHash": "0xb2fdee2a2ebae18d2fa4ae8ad23f7a120c533457fd1dfcd63ef674cf55f88887", + "layout": { + "solcVersion": "0.8.4", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:40" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "configRegistry", + "offset": 0, + "slot": "101", + "type": "t_address", + "contract": "LemonadeRelayPayment", + "src": "contracts/payment/relay/LemonadeRelayPayment.sol:40" + }, + { + "label": "payments", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_bytes32,t_struct(Payment)24796_storage)", + "contract": "LemonadeRelayPayment", + "src": "contracts/payment/relay/LemonadeRelayPayment.sol:41" + }, + { + "label": "splitters", + "offset": 0, + "slot": "103", + "type": "t_mapping(t_address,t_bool)", + "contract": "LemonadeRelayPayment", + "src": "contracts/payment/relay/LemonadeRelayPayment.sol:42" + }, + { + "label": "__gap", + "offset": 0, + "slot": "104", + "type": "t_array(t_uint256)20_storage", + "contract": "LemonadeRelayPayment", + "src": "contracts/payment/relay/LemonadeRelayPayment.sol:43" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)20_storage": { + "label": "uint256[20]", + "numberOfBytes": "640" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_struct(Payment)24796_storage)": { + "label": "mapping(bytes32 => struct LemonadeRelayPayment.Payment)", + "numberOfBytes": "32" + }, + "t_struct(Payment)24796_storage": { + "label": "struct LemonadeRelayPayment.Payment", + "members": [ + { + "label": "guest", + "type": "t_address", + "offset": 0, + "slot": "0" + }, + { + "label": "currency", + "type": "t_address", + "offset": 0, + "slot": "1" + }, + { + "label": "amount", + "type": "t_uint256", + "offset": 0, + "slot": "2" + } + ], + "numberOfBytes": "96" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + }, + "namespaces": {} + } + } + } +} diff --git a/deploy/scroll-sepolia/AccessRegistry.ts b/deploy/scroll-sepolia/AccessRegistry.ts new file mode 100644 index 0000000..31bd441 --- /dev/null +++ b/deploy/scroll-sepolia/AccessRegistry.ts @@ -0,0 +1,7 @@ +import { deployFunction } from "../../services/AccessRegistry"; + +export default deployFunction([ + { role: 'TRUSTED_CLAIMER_ROLE', account: '0xB25D3d684EAB618B51eE8A3127FBacA6224DaFA9', grant: true }, + { role: 'TRUSTED_OPERATOR_ROLE', account: '0xB25D3d684EAB618B51eE8A3127FBacA6224DaFA9', grant: true }, + { role: 'PAYMENT_ADMIN_ROLE', account: '0xE88616aB140F29f310E98DD720bcEC8be5D5AC5C', grant: true }, +]); diff --git a/deploy/scroll/AccessRegistry.ts b/deploy/scroll/AccessRegistry.ts new file mode 100644 index 0000000..40ccc81 --- /dev/null +++ b/deploy/scroll/AccessRegistry.ts @@ -0,0 +1,7 @@ +import { deployFunction } from "../../services/AccessRegistry"; + +export default deployFunction([ + { role: 'TRUSTED_CLAIMER_ROLE', account: '0xB25D3d684EAB618B51eE8A3127FBacA6224DaFA9', grant: true }, + { role: 'TRUSTED_OPERATOR_ROLE', account: '0xB25D3d684EAB618B51eE8A3127FBacA6224DaFA9', grant: true }, + { role: 'PAYMENT_ADMIN_ROLE', account: '0x6950Af4b7815c15073066C7540b1c64Fa7Be97F1', grant: true }, +]); diff --git a/deployments/scroll-sepolia/.chainId b/deployments/scroll-sepolia/.chainId new file mode 100644 index 0000000..b4c1846 --- /dev/null +++ b/deployments/scroll-sepolia/.chainId @@ -0,0 +1 @@ +534351 \ No newline at end of file diff --git a/deployments/scroll-sepolia/AccessRegistry.json b/deployments/scroll-sepolia/AccessRegistry.json new file mode 100644 index 0000000..4df491e --- /dev/null +++ b/deployments/scroll-sepolia/AccessRegistry.json @@ -0,0 +1,467 @@ +{ + "address": "0x8a945454478f73d586c9B9ebf6b694f925E4d462", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getRoleMember", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleMemberCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xdb53a9ef53a15c4f1403510cf5ab35d08a4c762d069680a866354543c4930500", + "receipt": { + "to": null, + "from": "0xf4a5990Ab778A2c760Be43f3380725BFC4D78b14", + "contractAddress": "0x8a945454478f73d586c9B9ebf6b694f925E4d462", + "transactionIndex": 1, + "gasUsed": "738540", + "logsBloom": "0x00000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000020000000000001000000800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000020000000000001000000000000000000000000000000000000000000000000000000000000100000000000020000000000000000000000000000000000000000800008000000000000000000000", + "blockHash": "0xcabe1c50684e9f2fd3dc58e66c5a9e41813722894628f64f033df9acafa1b16a", + "transactionHash": "0xdb53a9ef53a15c4f1403510cf5ab35d08a4c762d069680a866354543c4930500", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 5334823, + "transactionHash": "0xdb53a9ef53a15c4f1403510cf5ab35d08a4c762d069680a866354543c4930500", + "address": "0x8a945454478f73d586c9B9ebf6b694f925E4d462", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000f4a5990ab778a2c760be43f3380725bfc4d78b14", + "0x000000000000000000000000f4a5990ab778a2c760be43f3380725bfc4d78b14" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xcabe1c50684e9f2fd3dc58e66c5a9e41813722894628f64f033df9acafa1b16a" + } + ], + "blockNumber": 5334823, + "cumulativeGasUsed": "759540", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "fccf71bfc76cbdc7bd823fe97c30d41c", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/AccessRegistry.sol\":\"AccessRegistry\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControl.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\nimport \\\"../utils/Strings.sol\\\";\\nimport \\\"../utils/introspection/ERC165.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```solidity\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```solidity\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\\n * to enforce additional security measures for this role.\\n */\\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n Strings.toHexString(account),\\n \\\" is missing role \\\",\\n Strings.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * May emit a {RoleGranted} event.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0dd6e52cb394d7f5abe5dca2d4908a6be40417914720932de757de34a99ab87f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/AccessControlEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControlEnumerable.sol\\\";\\nimport \\\"./AccessControl.sol\\\";\\nimport \\\"../utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\\n */\\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns one of the accounts that have `role`. `index` must be a\\n * value between 0 and {getRoleMemberCount}, non-inclusive.\\n *\\n * Role bearers are not sorted in any particular way, and their ordering may\\n * change at any point.\\n *\\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\\n * you perform all queries on the same block. See the following\\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\\n * for more information.\\n */\\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\\n return _roleMembers[role].at(index);\\n }\\n\\n /**\\n * @dev Returns the number of accounts that have `role`. Can be used\\n * together with {getRoleMember} to enumerate all bearers of a role.\\n */\\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\\n return _roleMembers[role].length();\\n }\\n\\n /**\\n * @dev Overload {_grantRole} to track enumerable memberships\\n */\\n function _grantRole(bytes32 role, address account) internal virtual override {\\n super._grantRole(role, account);\\n _roleMembers[role].add(account);\\n }\\n\\n /**\\n * @dev Overload {_revokeRole} to track enumerable memberships\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual override {\\n super._revokeRole(role, account);\\n _roleMembers[role].remove(account);\\n }\\n}\\n\",\"keccak256\":\"0x13f5e15f2a0650c0b6aaee2ef19e89eaf4870d6e79662d572a393334c1397247\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControlEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControl.sol\\\";\\n\\n/**\\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\\n */\\ninterface IAccessControlEnumerable is IAccessControl {\\n /**\\n * @dev Returns one of the accounts that have `role`. `index` must be a\\n * value between 0 and {getRoleMemberCount}, non-inclusive.\\n *\\n * Role bearers are not sorted in any particular way, and their ordering may\\n * change at any point.\\n *\\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\\n * you perform all queries on the same block. See the following\\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\\n * for more information.\\n */\\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\\n\\n /**\\n * @dev Returns the number of accounts that have `role`. Can be used\\n * together with {getRoleMember} to enumerate all bearers of a role.\\n */\\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xba4459ab871dfa300f5212c6c30178b63898c03533a1ede28436f11546626676\",\"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/introspection/ERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165 is IERC165 {\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0xd10975de010d89fd1c78dc5e8a9a7e7f496198085c151648f20cba166b32582b\",\"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/AccessRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControlEnumerable.sol\\\";\\n\\ncontract AccessRegistry is AccessControlEnumerable {\\n constructor() {\\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\\n }\\n}\\n\",\"keccak256\":\"0x30e4846797d261dded6b67dd219d08c982a3f585950325733a8ce1c937451c9e\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061001c600033610021565b610177565b61002b828261002f565b5050565b610043828261006c60201b6102e11760201c565b600082815260016020908152604090912061006791839061036561010a821b17901c565b505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661002b576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556100c63390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061011f836001600160a01b038416610128565b90505b92915050565b600081815260018301602052604081205461016f57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610122565b506000610122565b610aa5806101866000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c80639010d07c116100665780639010d07c1461011957806391d1485414610144578063a217fddf14610157578063ca15c8731461015f578063d547741f1461017257600080fd5b806301ffc9a714610098578063248a9ca3146100c05780632f2ff15d146100f157806336568abe14610106575b600080fd5b6100ab6100a63660046108f4565b610185565b60405190151581526020015b60405180910390f35b6100e36100ce366004610881565b60009081526020819052604090206001015490565b6040519081526020016100b7565b6101046100ff366004610899565b6101b0565b005b610104610114366004610899565b6101da565b61012c6101273660046108d3565b61025d565b6040516001600160a01b0390911681526020016100b7565b6100ab610152366004610899565b61027c565b6100e3600081565b6100e361016d366004610881565b6102a5565b610104610180366004610899565b6102bc565b60006001600160e01b03198216635a05180f60e01b14806101aa57506101aa8261037a565b92915050565b6000828152602081905260409020600101546101cb816103af565b6101d583836103bc565b505050565b6001600160a01b038116331461024f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61025982826103de565b5050565b60008281526001602052604081206102759083610400565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60008181526001602052604081206101aa9061040c565b6000828152602081905260409020600101546102d7816103af565b6101d583836103de565b6102eb828261027c565b610259576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556103213390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610275836001600160a01b038416610416565b60006001600160e01b03198216637965db0b60e01b14806101aa57506301ffc9a760e01b6001600160e01b03198316146101aa565b6103b98133610465565b50565b6103c682826102e1565b60008281526001602052604090206101d59082610365565b6103e882826104be565b60008281526001602052604090206101d59082610523565b60006102758383610538565b60006101aa825490565b600081815260018301602052604081205461045d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556101aa565b5060006101aa565b61046f828261027c565b6102595761047c81610570565b610487836020610582565b60405160200161049892919061091c565b60408051601f198184030181529082905262461bcd60e51b825261024691600401610991565b6104c8828261027c565b15610259576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610275836001600160a01b038416610764565b600082600001828154811061055d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60606101aa6001600160a01b03831660145b606060006105918360026109dc565b61059c9060026109c4565b67ffffffffffffffff8111156105c257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156105ec576020820181803683370190505b509050600360fc1b8160008151811061061557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061065257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006106768460026109dc565b6106819060016109c4565b90505b6001811115610715576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106106c357634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106106e757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361070e81610a42565b9050610684565b5083156102755760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610246565b600081815260018301602052604081205480156108775760006107886001836109fb565b855490915060009061079c906001906109fb565b905081811461081d5760008660000182815481106107ca57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106107fb57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061083c57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506101aa565b60009150506101aa565b600060208284031215610892578081fd5b5035919050565b600080604083850312156108ab578081fd5b8235915060208301356001600160a01b03811681146108c8578182fd5b809150509250929050565b600080604083850312156108e5578182fd5b50508035926020909101359150565b600060208284031215610905578081fd5b81356001600160e01b031981168114610275578182fd5b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351610954816017850160208801610a12565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351610985816028840160208801610a12565b01602801949350505050565b60208152600082518060208401526109b0816040850160208701610a12565b601f01601f19169190910160400192915050565b600082198211156109d7576109d7610a59565b500190565b60008160001904831182151516156109f6576109f6610a59565b500290565b600082821015610a0d57610a0d610a59565b500390565b60005b83811015610a2d578181015183820152602001610a15565b83811115610a3c576000848401525b50505050565b600081610a5157610a51610a59565b506000190190565b634e487b7160e01b600052601160045260246000fdfea26469706673582212201a949fcc635b1f817699767b282df8648242e8fc5a24715713cae3781dafc60264736f6c63430008040033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c80639010d07c116100665780639010d07c1461011957806391d1485414610144578063a217fddf14610157578063ca15c8731461015f578063d547741f1461017257600080fd5b806301ffc9a714610098578063248a9ca3146100c05780632f2ff15d146100f157806336568abe14610106575b600080fd5b6100ab6100a63660046108f4565b610185565b60405190151581526020015b60405180910390f35b6100e36100ce366004610881565b60009081526020819052604090206001015490565b6040519081526020016100b7565b6101046100ff366004610899565b6101b0565b005b610104610114366004610899565b6101da565b61012c6101273660046108d3565b61025d565b6040516001600160a01b0390911681526020016100b7565b6100ab610152366004610899565b61027c565b6100e3600081565b6100e361016d366004610881565b6102a5565b610104610180366004610899565b6102bc565b60006001600160e01b03198216635a05180f60e01b14806101aa57506101aa8261037a565b92915050565b6000828152602081905260409020600101546101cb816103af565b6101d583836103bc565b505050565b6001600160a01b038116331461024f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61025982826103de565b5050565b60008281526001602052604081206102759083610400565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60008181526001602052604081206101aa9061040c565b6000828152602081905260409020600101546102d7816103af565b6101d583836103de565b6102eb828261027c565b610259576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556103213390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610275836001600160a01b038416610416565b60006001600160e01b03198216637965db0b60e01b14806101aa57506301ffc9a760e01b6001600160e01b03198316146101aa565b6103b98133610465565b50565b6103c682826102e1565b60008281526001602052604090206101d59082610365565b6103e882826104be565b60008281526001602052604090206101d59082610523565b60006102758383610538565b60006101aa825490565b600081815260018301602052604081205461045d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556101aa565b5060006101aa565b61046f828261027c565b6102595761047c81610570565b610487836020610582565b60405160200161049892919061091c565b60408051601f198184030181529082905262461bcd60e51b825261024691600401610991565b6104c8828261027c565b15610259576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610275836001600160a01b038416610764565b600082600001828154811061055d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60606101aa6001600160a01b03831660145b606060006105918360026109dc565b61059c9060026109c4565b67ffffffffffffffff8111156105c257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156105ec576020820181803683370190505b509050600360fc1b8160008151811061061557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061065257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006106768460026109dc565b6106819060016109c4565b90505b6001811115610715576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106106c357634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106106e757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361070e81610a42565b9050610684565b5083156102755760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610246565b600081815260018301602052604081205480156108775760006107886001836109fb565b855490915060009061079c906001906109fb565b905081811461081d5760008660000182815481106107ca57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106107fb57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061083c57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506101aa565b60009150506101aa565b600060208284031215610892578081fd5b5035919050565b600080604083850312156108ab578081fd5b8235915060208301356001600160a01b03811681146108c8578182fd5b809150509250929050565b600080604083850312156108e5578182fd5b50508035926020909101359150565b600060208284031215610905578081fd5b81356001600160e01b031981168114610275578182fd5b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351610954816017850160208801610a12565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351610985816028840160208801610a12565b01602801949350505050565b60208152600082518060208401526109b0816040850160208701610a12565b601f01601f19169190910160400192915050565b600082198211156109d7576109d7610a59565b500190565b60008160001904831182151516156109f6576109f6610a59565b500290565b600082821015610a0d57610a0d610a59565b500390565b60005b83811015610a2d578181015183820152602001610a15565b83811115610a3c576000848401525b50505050565b600081610a5157610a51610a59565b506000190190565b634e487b7160e01b600052601160045260246000fdfea26469706673582212201a949fcc635b1f817699767b282df8648242e8fc5a24715713cae3781dafc60264736f6c63430008040033", + "devdoc": { + "kind": "dev", + "methods": { + "getRoleAdmin(bytes32)": { + "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." + }, + "getRoleMember(bytes32,uint256)": { + "details": "Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information." + }, + "getRoleMemberCount(bytes32)": { + "details": "Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role." + }, + "grantRole(bytes32,address)": { + "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event." + }, + "hasRole(bytes32,address)": { + "details": "Returns `true` if `account` has been granted `role`." + }, + "renounceRole(bytes32,address)": { + "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event." + }, + "revokeRole(bytes32,address)": { + "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event." + }, + "supportsInterface(bytes4)": { + "details": "See {IERC165-supportsInterface}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 6733, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_roles", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_bytes32,t_struct(RoleData)6728_storage)" + }, + { + "astId": 7043, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_roleMembers", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_struct(AddressSet)12153_storage)" + } + ], + "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_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_bytes32,t_struct(AddressSet)12153_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)12153_storage" + }, + "t_mapping(t_bytes32,t_struct(RoleData)6728_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct AccessControl.RoleData)", + "numberOfBytes": "32", + "value": "t_struct(RoleData)6728_storage" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)12153_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 12152, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)11838_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(RoleData)6728_storage": { + "encoding": "inplace", + "label": "struct AccessControl.RoleData", + "members": [ + { + "astId": 6725, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "members", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 6727, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "adminRole", + "offset": 0, + "slot": "1", + "type": "t_bytes32" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)11838_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 11833, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 11837, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/deployments/scroll-sepolia/Introspection.json b/deployments/scroll-sepolia/Introspection.json new file mode 100644 index 0000000..a1f85fe --- /dev/null +++ b/deployments/scroll-sepolia/Introspection.json @@ -0,0 +1,65 @@ +{ + "address": "0x29b1aC5C0737Ddbe93e7F54780855deaD94ADa1D", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes4[]", + "name": "interfaceIds", + "type": "bytes4[]" + } + ], + "name": "getSupportedInterfaces", + "outputs": [ + { + "internalType": "bool[]", + "name": "", + "type": "bool[]" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x7ca133a8efa9f3fea1abf37d972b6ef3486f9d55ac80f26ac12f38f3fb57d555", + "receipt": { + "to": null, + "from": "0xf4a5990Ab778A2c760Be43f3380725BFC4D78b14", + "contractAddress": "0x29b1aC5C0737Ddbe93e7F54780855deaD94ADa1D", + "transactionIndex": 0, + "gasUsed": "290079", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xf63e644c1e711375e47fe831e04cd1f1a27ef991a0809db7d99728d8039fa1b3", + "transactionHash": "0x7ca133a8efa9f3fea1abf37d972b6ef3486f9d55ac80f26ac12f38f3fb57d555", + "logs": [], + "blockNumber": 5334820, + "cumulativeGasUsed": "290079", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "fccf71bfc76cbdc7bd823fe97c30d41c", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes4[]\",\"name\":\"interfaceIds\",\"type\":\"bytes4[]\"}],\"name\":\"getSupportedInterfaces\",\"outputs\":[{\"internalType\":\"bool[]\",\"name\":\"\",\"type\":\"bool[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Introspection.sol\":\"Introspection\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/introspection/ERC165Checker.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Library used to query support of an interface declared via {IERC165}.\\n *\\n * Note that these functions return the actual result of the query: they do not\\n * `revert` if an interface is not supported. It is up to the caller to decide\\n * what to do in these cases.\\n */\\nlibrary ERC165Checker {\\n // As per the EIP-165 spec, no interface should ever match 0xffffffff\\n bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\\n\\n /**\\n * @dev Returns true if `account` supports the {IERC165} interface.\\n */\\n function supportsERC165(address account) internal view returns (bool) {\\n // Any contract that implements ERC165 must explicitly indicate support of\\n // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\\n return\\n supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&\\n !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);\\n }\\n\\n /**\\n * @dev Returns true if `account` supports the interface defined by\\n * `interfaceId`. Support for {IERC165} itself is queried automatically.\\n *\\n * See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\\n // query support of both ERC165 as per the spec and support of _interfaceId\\n return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);\\n }\\n\\n /**\\n * @dev Returns a boolean array where each value corresponds to the\\n * interfaces passed in and whether they're supported or not. This allows\\n * you to batch check interfaces for a contract where your expectation\\n * is that some interfaces may not be supported.\\n *\\n * See {IERC165-supportsInterface}.\\n *\\n * _Available since v3.4._\\n */\\n function getSupportedInterfaces(\\n address account,\\n bytes4[] memory interfaceIds\\n ) internal view returns (bool[] memory) {\\n // an array of booleans corresponding to interfaceIds and whether they're supported or not\\n bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\\n\\n // query support of ERC165 itself\\n if (supportsERC165(account)) {\\n // query support of each interface in interfaceIds\\n for (uint256 i = 0; i < interfaceIds.length; i++) {\\n interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);\\n }\\n }\\n\\n return interfaceIdsSupported;\\n }\\n\\n /**\\n * @dev Returns true if `account` supports all the interfaces defined in\\n * `interfaceIds`. Support for {IERC165} itself is queried automatically.\\n *\\n * Batch-querying can lead to gas savings by skipping repeated checks for\\n * {IERC165} support.\\n *\\n * See {IERC165-supportsInterface}.\\n */\\n function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\\n // query support of ERC165 itself\\n if (!supportsERC165(account)) {\\n return false;\\n }\\n\\n // query support of each interface in interfaceIds\\n for (uint256 i = 0; i < interfaceIds.length; i++) {\\n if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {\\n return false;\\n }\\n }\\n\\n // all interfaces supported\\n return true;\\n }\\n\\n /**\\n * @notice Query if a contract implements an interface, does not check ERC165 support\\n * @param account The address of the contract to query for support of an interface\\n * @param interfaceId The interface identifier, as specified in ERC-165\\n * @return true if the contract at account indicates support of the interface with\\n * identifier interfaceId, false otherwise\\n * @dev Assumes that account contains a contract that supports ERC165, otherwise\\n * the behavior of this method is undefined. This precondition can be checked\\n * with {supportsERC165}.\\n *\\n * Some precompiled contracts will falsely indicate support for a given interface, so caution\\n * should be exercised when using this function.\\n *\\n * Interface identification is specified in ERC-165.\\n */\\n function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {\\n // prepare call\\n bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\\n\\n // perform static call\\n bool success;\\n uint256 returnSize;\\n uint256 returnValue;\\n assembly {\\n success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)\\n returnSize := returndatasize()\\n returnValue := mload(0x00)\\n }\\n\\n return success && returnSize >= 0x20 && returnValue > 0;\\n }\\n}\\n\",\"keccak256\":\"0x5a08ad61f4e82b8a3323562661a86fb10b10190848073fdc13d4ac43710ffba5\",\"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\"},\"contracts/Introspection.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\\\";\\n\\ncontract Introspection {\\n using ERC165Checker for address;\\n\\n function getSupportedInterfaces(\\n address account,\\n bytes4[] memory interfaceIds\\n ) public view returns (bool[] memory) {\\n require(account.code.length > 0, \\\"Introspection: account not a contract\\\");\\n\\n return account.getSupportedInterfaces(interfaceIds);\\n }\\n}\\n\",\"keccak256\":\"0xa0032c78e6ac2446b60a975f8e81357cca2fa7b505f1e8aed41b1e8a88329b43\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610448806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806377e6b4cc14610030575b600080fd5b61004361003e3660046102a8565b610059565b604051610050919061038f565b60405180910390f35b60606000836001600160a01b03163b116100c75760405162461bcd60e51b815260206004820152602560248201527f496e74726f7370656374696f6e3a206163636f756e74206e6f74206120636f6e6044820152641d1c9858dd60da1b606482015260840160405180910390fd5b6100da6001600160a01b038416836100e1565b9392505050565b60606000825167ffffffffffffffff81111561010d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610136578160200160208202803683370190505b509050610142846101ce565b156100da5760005b83518110156101c6576101848585838151811061017757634e487b7160e01b600052603260045260246000fd5b6020026020010151610202565b8282815181106101a457634e487b7160e01b600052603260045260246000fd5b91151560209283029190910190910152806101be816103d5565b91505061014a565b509392505050565b60006101e1826301ffc9a760e01b610202565b80156101fc57506101fa826001600160e01b0319610202565b155b92915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d91506000519050828015610274575060208210155b80156102805750600081115b979650505050505050565b80356001600160e01b0319811681146102a357600080fd5b919050565b600080604083850312156102ba578182fd5b82356001600160a01b03811681146102d0578283fd5b915060208381013567ffffffffffffffff808211156102ed578384fd5b818601915086601f830112610300578384fd5b813581811115610312576103126103fc565b8060051b604051601f19603f83011681018181108582111715610337576103376103fc565b604052828152858101935084860182860187018b1015610355578788fd5b8795505b8386101561037e5761036a8161028b565b855260019590950194938601938601610359565b508096505050505050509250929050565b6020808252825182820181905260009190848201906040850190845b818110156103c95783511515835292840192918401916001016103ab565b50909695505050505050565b60006000198214156103f557634e487b7160e01b81526011600452602481fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212203b01b8de7b6025f176c420a590d4c952574d8111b332fda18225e2670653f50964736f6c63430008040033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c806377e6b4cc14610030575b600080fd5b61004361003e3660046102a8565b610059565b604051610050919061038f565b60405180910390f35b60606000836001600160a01b03163b116100c75760405162461bcd60e51b815260206004820152602560248201527f496e74726f7370656374696f6e3a206163636f756e74206e6f74206120636f6e6044820152641d1c9858dd60da1b606482015260840160405180910390fd5b6100da6001600160a01b038416836100e1565b9392505050565b60606000825167ffffffffffffffff81111561010d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610136578160200160208202803683370190505b509050610142846101ce565b156100da5760005b83518110156101c6576101848585838151811061017757634e487b7160e01b600052603260045260246000fd5b6020026020010151610202565b8282815181106101a457634e487b7160e01b600052603260045260246000fd5b91151560209283029190910190910152806101be816103d5565b91505061014a565b509392505050565b60006101e1826301ffc9a760e01b610202565b80156101fc57506101fa826001600160e01b0319610202565b155b92915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d91506000519050828015610274575060208210155b80156102805750600081115b979650505050505050565b80356001600160e01b0319811681146102a357600080fd5b919050565b600080604083850312156102ba578182fd5b82356001600160a01b03811681146102d0578283fd5b915060208381013567ffffffffffffffff808211156102ed578384fd5b818601915086601f830112610300578384fd5b813581811115610312576103126103fc565b8060051b604051601f19603f83011681018181108582111715610337576103376103fc565b604052828152858101935084860182860187018b1015610355578788fd5b8795505b8386101561037e5761036a8161028b565b855260019590950194938601938601610359565b508096505050505050509250929050565b6020808252825182820181905260009190848201906040850190845b818110156103c95783511515835292840192918401916001016103ab565b50909695505050505050565b60006000198214156103f557634e487b7160e01b81526011600452602481fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212203b01b8de7b6025f176c420a590d4c952574d8111b332fda18225e2670653f50964736f6c63430008040033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/deployments/scroll-sepolia/solcInputs/fccf71bfc76cbdc7bd823fe97c30d41c.json b/deployments/scroll-sepolia/solcInputs/fccf71bfc76cbdc7bd823fe97c30d41c.json new file mode 100644 index 0000000..fe4143b --- /dev/null +++ b/deployments/scroll-sepolia/solcInputs/fccf71bfc76cbdc7bd823fe97c30d41c.json @@ -0,0 +1,365 @@ +{ + "language": "Solidity", + "sources": { + "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarExecutable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IAxelarGateway } from './IAxelarGateway.sol';\n\ninterface IAxelarExecutable {\n error InvalidAddress();\n error NotApprovedByGateway();\n\n function gateway() external view returns (IAxelarGateway);\n\n function execute(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes calldata payload\n ) external;\n\n function executeWithToken(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes calldata payload,\n string calldata tokenSymbol,\n uint256 amount\n ) external;\n}\n" + }, + "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n// This should be owned by the microservice that is paying for gas.\ninterface IAxelarGasService {\n error NothingReceived();\n error InvalidAddress();\n error NotCollector();\n error InvalidAmounts();\n\n event GasPaidForContractCall(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event GasPaidForContractCallWithToken(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeGasPaidForContractCall(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeGasPaidForContractCallWithToken(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event GasPaidForExpressCallWithToken(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeGasPaidForExpressCallWithToken(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event GasAdded(\n bytes32 indexed txHash,\n uint256 indexed logIndex,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeGasAdded(bytes32 indexed txHash, uint256 indexed logIndex, uint256 gasFeeAmount, address refundAddress);\n\n event ExpressGasAdded(\n bytes32 indexed txHash,\n uint256 indexed logIndex,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeExpressGasAdded(\n bytes32 indexed txHash,\n uint256 indexed logIndex,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payGasForContractCall(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payGasForContractCallWithToken(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payNativeGasForContractCall(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n address refundAddress\n ) external payable;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payNativeGasForContractCallWithToken(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount,\n address refundAddress\n ) external payable;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payGasForExpressCallWithToken(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payNativeGasForExpressCallWithToken(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount,\n address refundAddress\n ) external payable;\n\n function addGas(\n bytes32 txHash,\n uint256 txIndex,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n function addNativeGas(\n bytes32 txHash,\n uint256 logIndex,\n address refundAddress\n ) external payable;\n\n function addExpressGas(\n bytes32 txHash,\n uint256 txIndex,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n function addNativeExpressGas(\n bytes32 txHash,\n uint256 logIndex,\n address refundAddress\n ) external payable;\n\n function collectFees(\n address payable receiver,\n address[] calldata tokens,\n uint256[] calldata amounts\n ) external;\n\n function refund(\n address payable receiver,\n address token,\n uint256 amount\n ) external;\n\n function gasCollector() external returns (address);\n}\n" + }, + "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IAxelarGateway {\n /**********\\\n |* Errors *|\n \\**********/\n\n error NotSelf();\n error NotProxy();\n error InvalidCodeHash();\n error SetupFailed();\n error InvalidAuthModule();\n error InvalidTokenDeployer();\n error InvalidAmount();\n error InvalidChainId();\n error InvalidCommands();\n error TokenDoesNotExist(string symbol);\n error TokenAlreadyExists(string symbol);\n error TokenDeployFailed(string symbol);\n error TokenContractDoesNotExist(address token);\n error BurnFailed(string symbol);\n error MintFailed(string symbol);\n error InvalidSetMintLimitsParams();\n error ExceedMintLimit(string symbol);\n\n /**********\\\n |* Events *|\n \\**********/\n\n event TokenSent(\n address indexed sender,\n string destinationChain,\n string destinationAddress,\n string symbol,\n uint256 amount\n );\n\n event ContractCall(\n address indexed sender,\n string destinationChain,\n string destinationContractAddress,\n bytes32 indexed payloadHash,\n bytes payload\n );\n\n event ContractCallWithToken(\n address indexed sender,\n string destinationChain,\n string destinationContractAddress,\n bytes32 indexed payloadHash,\n bytes payload,\n string symbol,\n uint256 amount\n );\n\n event Executed(bytes32 indexed commandId);\n\n event TokenDeployed(string symbol, address tokenAddresses);\n\n event ContractCallApproved(\n bytes32 indexed commandId,\n string sourceChain,\n string sourceAddress,\n address indexed contractAddress,\n bytes32 indexed payloadHash,\n bytes32 sourceTxHash,\n uint256 sourceEventIndex\n );\n\n event ContractCallApprovedWithMint(\n bytes32 indexed commandId,\n string sourceChain,\n string sourceAddress,\n address indexed contractAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n bytes32 sourceTxHash,\n uint256 sourceEventIndex\n );\n\n event TokenMintLimitUpdated(string symbol, uint256 limit);\n\n event OperatorshipTransferred(bytes newOperatorsData);\n\n event Upgraded(address indexed implementation);\n\n /********************\\\n |* Public Functions *|\n \\********************/\n\n function sendToken(\n string calldata destinationChain,\n string calldata destinationAddress,\n string calldata symbol,\n uint256 amount\n ) external;\n\n function callContract(\n string calldata destinationChain,\n string calldata contractAddress,\n bytes calldata payload\n ) external;\n\n function callContractWithToken(\n string calldata destinationChain,\n string calldata contractAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount\n ) external;\n\n function isContractCallApproved(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n address contractAddress,\n bytes32 payloadHash\n ) external view returns (bool);\n\n function isContractCallAndMintApproved(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n address contractAddress,\n bytes32 payloadHash,\n string calldata symbol,\n uint256 amount\n ) external view returns (bool);\n\n function validateContractCall(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes32 payloadHash\n ) external returns (bool);\n\n function validateContractCallAndMint(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes32 payloadHash,\n string calldata symbol,\n uint256 amount\n ) external returns (bool);\n\n /***********\\\n |* Getters *|\n \\***********/\n\n function authModule() external view returns (address);\n\n function tokenDeployer() external view returns (address);\n\n function tokenMintLimit(string memory symbol) external view returns (uint256);\n\n function tokenMintAmount(string memory symbol) external view returns (uint256);\n\n function allTokensFrozen() external view returns (bool);\n\n function implementation() external view returns (address);\n\n function tokenAddresses(string memory symbol) external view returns (address);\n\n function tokenFrozen(string memory symbol) external view returns (bool);\n\n function isCommandExecuted(bytes32 commandId) external view returns (bool);\n\n function adminEpoch() external view returns (uint256);\n\n function adminThreshold(uint256 epoch) external view returns (uint256);\n\n function admins(uint256 epoch) external view returns (address[] memory);\n\n /*******************\\\n |* Admin Functions *|\n \\*******************/\n\n function setTokenMintLimits(string[] calldata symbols, uint256[] calldata limits) external;\n\n function upgrade(\n address newImplementation,\n bytes32 newImplementationCodeHash,\n bytes calldata setupParams\n ) external;\n\n /**********************\\\n |* External Functions *|\n \\**********************/\n\n function setup(bytes calldata params) external;\n\n function execute(bytes calldata input) external;\n}\n" + }, + "@chainlink/contracts/src/v0.8/Chainlink.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {CBORChainlink} from \"./vendor/CBORChainlink.sol\";\nimport {BufferChainlink} from \"./vendor/BufferChainlink.sol\";\n\n/**\n * @title Library for common Chainlink functions\n * @dev Uses imported CBOR library for encoding to buffer\n */\nlibrary Chainlink {\n uint256 internal constant defaultBufferSize = 256; // solhint-disable-line const-name-snakecase\n\n using CBORChainlink for BufferChainlink.buffer;\n\n struct Request {\n bytes32 id;\n address callbackAddress;\n bytes4 callbackFunctionId;\n uint256 nonce;\n BufferChainlink.buffer buf;\n }\n\n /**\n * @notice Initializes a Chainlink request\n * @dev Sets the ID, callback address, and callback function signature on the request\n * @param self The uninitialized request\n * @param jobId The Job Specification ID\n * @param callbackAddr The callback address\n * @param callbackFunc The callback function signature\n * @return The initialized request\n */\n function initialize(\n Request memory self,\n bytes32 jobId,\n address callbackAddr,\n bytes4 callbackFunc\n ) internal pure returns (Chainlink.Request memory) {\n BufferChainlink.init(self.buf, defaultBufferSize);\n self.id = jobId;\n self.callbackAddress = callbackAddr;\n self.callbackFunctionId = callbackFunc;\n return self;\n }\n\n /**\n * @notice Sets the data for the buffer without encoding CBOR on-chain\n * @dev CBOR can be closed with curly-brackets {} or they can be left off\n * @param self The initialized request\n * @param data The CBOR data\n */\n function setBuffer(Request memory self, bytes memory data) internal pure {\n BufferChainlink.init(self.buf, data.length);\n BufferChainlink.append(self.buf, data);\n }\n\n /**\n * @notice Adds a string value to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param value The string value to add\n */\n function add(\n Request memory self,\n string memory key,\n string memory value\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.encodeString(value);\n }\n\n /**\n * @notice Adds a bytes value to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param value The bytes value to add\n */\n function addBytes(\n Request memory self,\n string memory key,\n bytes memory value\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.encodeBytes(value);\n }\n\n /**\n * @notice Adds a int256 value to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param value The int256 value to add\n */\n function addInt(\n Request memory self,\n string memory key,\n int256 value\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.encodeInt(value);\n }\n\n /**\n * @notice Adds a uint256 value to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param value The uint256 value to add\n */\n function addUint(\n Request memory self,\n string memory key,\n uint256 value\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.encodeUInt(value);\n }\n\n /**\n * @notice Adds an array of strings to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param values The array of string values to add\n */\n function addStringArray(\n Request memory self,\n string memory key,\n string[] memory values\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.startArray();\n for (uint256 i = 0; i < values.length; i++) {\n self.buf.encodeString(values[i]);\n }\n self.buf.endSequence();\n }\n}\n" + }, + "@chainlink/contracts/src/v0.8/ChainlinkClient.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./Chainlink.sol\";\nimport \"./interfaces/ENSInterface.sol\";\nimport \"./interfaces/LinkTokenInterface.sol\";\nimport \"./interfaces/ChainlinkRequestInterface.sol\";\nimport \"./interfaces/OperatorInterface.sol\";\nimport \"./interfaces/PointerInterface.sol\";\nimport {ENSResolver as ENSResolver_Chainlink} from \"./vendor/ENSResolver.sol\";\n\n/**\n * @title The ChainlinkClient contract\n * @notice Contract writers can inherit this contract in order to create requests for the\n * Chainlink network\n */\nabstract contract ChainlinkClient {\n using Chainlink for Chainlink.Request;\n\n uint256 internal constant LINK_DIVISIBILITY = 10**18;\n uint256 private constant AMOUNT_OVERRIDE = 0;\n address private constant SENDER_OVERRIDE = address(0);\n uint256 private constant ORACLE_ARGS_VERSION = 1;\n uint256 private constant OPERATOR_ARGS_VERSION = 2;\n bytes32 private constant ENS_TOKEN_SUBNAME = keccak256(\"link\");\n bytes32 private constant ENS_ORACLE_SUBNAME = keccak256(\"oracle\");\n address private constant LINK_TOKEN_POINTER = 0xC89bD4E1632D3A43CB03AAAd5262cbe4038Bc571;\n\n ENSInterface private s_ens;\n bytes32 private s_ensNode;\n LinkTokenInterface private s_link;\n OperatorInterface private s_oracle;\n uint256 private s_requestCount = 1;\n mapping(bytes32 => address) private s_pendingRequests;\n\n event ChainlinkRequested(bytes32 indexed id);\n event ChainlinkFulfilled(bytes32 indexed id);\n event ChainlinkCancelled(bytes32 indexed id);\n\n /**\n * @notice Creates a request that can hold additional parameters\n * @param specId The Job Specification ID that the request will be created for\n * @param callbackAddr address to operate the callback on\n * @param callbackFunctionSignature function signature to use for the callback\n * @return A Chainlink Request struct in memory\n */\n function buildChainlinkRequest(\n bytes32 specId,\n address callbackAddr,\n bytes4 callbackFunctionSignature\n ) internal pure returns (Chainlink.Request memory) {\n Chainlink.Request memory req;\n return req.initialize(specId, callbackAddr, callbackFunctionSignature);\n }\n\n /**\n * @notice Creates a request that can hold additional parameters\n * @param specId The Job Specification ID that the request will be created for\n * @param callbackFunctionSignature function signature to use for the callback\n * @return A Chainlink Request struct in memory\n */\n function buildOperatorRequest(bytes32 specId, bytes4 callbackFunctionSignature)\n internal\n view\n returns (Chainlink.Request memory)\n {\n Chainlink.Request memory req;\n return req.initialize(specId, address(this), callbackFunctionSignature);\n }\n\n /**\n * @notice Creates a Chainlink request to the stored oracle address\n * @dev Calls `chainlinkRequestTo` with the stored oracle address\n * @param req The initialized Chainlink Request\n * @param payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendChainlinkRequest(Chainlink.Request memory req, uint256 payment) internal returns (bytes32) {\n return sendChainlinkRequestTo(address(s_oracle), req, payment);\n }\n\n /**\n * @notice Creates a Chainlink request to the specified oracle address\n * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to\n * send LINK which creates a request on the target oracle contract.\n * Emits ChainlinkRequested event.\n * @param oracleAddress The address of the oracle for the request\n * @param req The initialized Chainlink Request\n * @param payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendChainlinkRequestTo(\n address oracleAddress,\n Chainlink.Request memory req,\n uint256 payment\n ) internal returns (bytes32 requestId) {\n uint256 nonce = s_requestCount;\n s_requestCount = nonce + 1;\n bytes memory encodedRequest = abi.encodeWithSelector(\n ChainlinkRequestInterface.oracleRequest.selector,\n SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address\n AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent\n req.id,\n address(this),\n req.callbackFunctionId,\n nonce,\n ORACLE_ARGS_VERSION,\n req.buf.buf\n );\n return _rawRequest(oracleAddress, nonce, payment, encodedRequest);\n }\n\n /**\n * @notice Creates a Chainlink request to the stored oracle address\n * @dev This function supports multi-word response\n * @dev Calls `sendOperatorRequestTo` with the stored oracle address\n * @param req The initialized Chainlink Request\n * @param payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendOperatorRequest(Chainlink.Request memory req, uint256 payment) internal returns (bytes32) {\n return sendOperatorRequestTo(address(s_oracle), req, payment);\n }\n\n /**\n * @notice Creates a Chainlink request to the specified oracle address\n * @dev This function supports multi-word response\n * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to\n * send LINK which creates a request on the target oracle contract.\n * Emits ChainlinkRequested event.\n * @param oracleAddress The address of the oracle for the request\n * @param req The initialized Chainlink Request\n * @param payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendOperatorRequestTo(\n address oracleAddress,\n Chainlink.Request memory req,\n uint256 payment\n ) internal returns (bytes32 requestId) {\n uint256 nonce = s_requestCount;\n s_requestCount = nonce + 1;\n bytes memory encodedRequest = abi.encodeWithSelector(\n OperatorInterface.operatorRequest.selector,\n SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address\n AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent\n req.id,\n req.callbackFunctionId,\n nonce,\n OPERATOR_ARGS_VERSION,\n req.buf.buf\n );\n return _rawRequest(oracleAddress, nonce, payment, encodedRequest);\n }\n\n /**\n * @notice Make a request to an oracle\n * @param oracleAddress The address of the oracle for the request\n * @param nonce used to generate the request ID\n * @param payment The amount of LINK to send for the request\n * @param encodedRequest data encoded for request type specific format\n * @return requestId The request ID\n */\n function _rawRequest(\n address oracleAddress,\n uint256 nonce,\n uint256 payment,\n bytes memory encodedRequest\n ) private returns (bytes32 requestId) {\n requestId = keccak256(abi.encodePacked(this, nonce));\n s_pendingRequests[requestId] = oracleAddress;\n emit ChainlinkRequested(requestId);\n require(s_link.transferAndCall(oracleAddress, payment, encodedRequest), \"unable to transferAndCall to oracle\");\n }\n\n /**\n * @notice Allows a request to be cancelled if it has not been fulfilled\n * @dev Requires keeping track of the expiration value emitted from the oracle contract.\n * Deletes the request from the `pendingRequests` mapping.\n * Emits ChainlinkCancelled event.\n * @param requestId The request ID\n * @param payment The amount of LINK sent for the request\n * @param callbackFunc The callback function specified for the request\n * @param expiration The time of the expiration for the request\n */\n function cancelChainlinkRequest(\n bytes32 requestId,\n uint256 payment,\n bytes4 callbackFunc,\n uint256 expiration\n ) internal {\n OperatorInterface requested = OperatorInterface(s_pendingRequests[requestId]);\n delete s_pendingRequests[requestId];\n emit ChainlinkCancelled(requestId);\n requested.cancelOracleRequest(requestId, payment, callbackFunc, expiration);\n }\n\n /**\n * @notice the next request count to be used in generating a nonce\n * @dev starts at 1 in order to ensure consistent gas cost\n * @return returns the next request count to be used in a nonce\n */\n function getNextRequestCount() internal view returns (uint256) {\n return s_requestCount;\n }\n\n /**\n * @notice Sets the stored oracle address\n * @param oracleAddress The address of the oracle contract\n */\n function setChainlinkOracle(address oracleAddress) internal {\n s_oracle = OperatorInterface(oracleAddress);\n }\n\n /**\n * @notice Sets the LINK token address\n * @param linkAddress The address of the LINK token contract\n */\n function setChainlinkToken(address linkAddress) internal {\n s_link = LinkTokenInterface(linkAddress);\n }\n\n /**\n * @notice Sets the Chainlink token address for the public\n * network as given by the Pointer contract\n */\n function setPublicChainlinkToken() internal {\n setChainlinkToken(PointerInterface(LINK_TOKEN_POINTER).getAddress());\n }\n\n /**\n * @notice Retrieves the stored address of the LINK token\n * @return The address of the LINK token\n */\n function chainlinkTokenAddress() internal view returns (address) {\n return address(s_link);\n }\n\n /**\n * @notice Retrieves the stored address of the oracle contract\n * @return The address of the oracle contract\n */\n function chainlinkOracleAddress() internal view returns (address) {\n return address(s_oracle);\n }\n\n /**\n * @notice Allows for a request which was created on another contract to be fulfilled\n * on this contract\n * @param oracleAddress The address of the oracle contract that will fulfill the request\n * @param requestId The request ID used for the response\n */\n function addChainlinkExternalRequest(address oracleAddress, bytes32 requestId) internal notPendingRequest(requestId) {\n s_pendingRequests[requestId] = oracleAddress;\n }\n\n /**\n * @notice Sets the stored oracle and LINK token contracts with the addresses resolved by ENS\n * @dev Accounts for subnodes having different resolvers\n * @param ensAddress The address of the ENS contract\n * @param node The ENS node hash\n */\n function useChainlinkWithENS(address ensAddress, bytes32 node) internal {\n s_ens = ENSInterface(ensAddress);\n s_ensNode = node;\n bytes32 linkSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_TOKEN_SUBNAME));\n ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(linkSubnode));\n setChainlinkToken(resolver.addr(linkSubnode));\n updateChainlinkOracleWithENS();\n }\n\n /**\n * @notice Sets the stored oracle contract with the address resolved by ENS\n * @dev This may be called on its own as long as `useChainlinkWithENS` has been called previously\n */\n function updateChainlinkOracleWithENS() internal {\n bytes32 oracleSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_ORACLE_SUBNAME));\n ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(oracleSubnode));\n setChainlinkOracle(resolver.addr(oracleSubnode));\n }\n\n /**\n * @notice Ensures that the fulfillment is valid for this contract\n * @dev Use if the contract developer prefers methods instead of modifiers for validation\n * @param requestId The request ID for fulfillment\n */\n function validateChainlinkCallback(bytes32 requestId)\n internal\n recordChainlinkFulfillment(requestId)\n // solhint-disable-next-line no-empty-blocks\n {\n\n }\n\n /**\n * @dev Reverts if the sender is not the oracle of the request.\n * Emits ChainlinkFulfilled event.\n * @param requestId The request ID for fulfillment\n */\n modifier recordChainlinkFulfillment(bytes32 requestId) {\n require(msg.sender == s_pendingRequests[requestId], \"Source must be the oracle of the request\");\n delete s_pendingRequests[requestId];\n emit ChainlinkFulfilled(requestId);\n _;\n }\n\n /**\n * @dev Reverts if the request is already pending\n * @param requestId The request ID for fulfillment\n */\n modifier notPendingRequest(bytes32 requestId) {\n require(s_pendingRequests[requestId] == address(0), \"Request is already pending\");\n _;\n }\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/ChainlinkRequestInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ChainlinkRequestInterface {\n function oracleRequest(\n address sender,\n uint256 requestPrice,\n bytes32 serviceAgreementID,\n address callbackAddress,\n bytes4 callbackFunctionId,\n uint256 nonce,\n uint256 dataVersion,\n bytes calldata data\n ) external;\n\n function cancelOracleRequest(\n bytes32 requestId,\n uint256 payment,\n bytes4 callbackFunctionId,\n uint256 expiration\n ) external;\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/ENSInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ENSInterface {\n // Logged when the owner of a node assigns a new owner to a subnode.\n event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);\n\n // Logged when the owner of a node transfers ownership to a new account.\n event Transfer(bytes32 indexed node, address owner);\n\n // Logged when the resolver for a node changes.\n event NewResolver(bytes32 indexed node, address resolver);\n\n // Logged when the TTL of a node changes\n event NewTTL(bytes32 indexed node, uint64 ttl);\n\n function setSubnodeOwner(\n bytes32 node,\n bytes32 label,\n address owner\n ) external;\n\n function setResolver(bytes32 node, address resolver) external;\n\n function setOwner(bytes32 node, address owner) external;\n\n function setTTL(bytes32 node, uint64 ttl) external;\n\n function owner(bytes32 node) external view returns (address);\n\n function resolver(bytes32 node) external view returns (address);\n\n function ttl(bytes32 node) external view returns (uint64);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/LinkTokenInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface LinkTokenInterface {\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n function approve(address spender, uint256 value) external returns (bool success);\n\n function balanceOf(address owner) external view returns (uint256 balance);\n\n function decimals() external view returns (uint8 decimalPlaces);\n\n function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);\n\n function increaseApproval(address spender, uint256 subtractedValue) external;\n\n function name() external view returns (string memory tokenName);\n\n function symbol() external view returns (string memory tokenSymbol);\n\n function totalSupply() external view returns (uint256 totalTokensIssued);\n\n function transfer(address to, uint256 value) external returns (bool success);\n\n function transferAndCall(\n address to,\n uint256 value,\n bytes calldata data\n ) external returns (bool success);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool success);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/OperatorInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./OracleInterface.sol\";\nimport \"./ChainlinkRequestInterface.sol\";\n\ninterface OperatorInterface is OracleInterface, ChainlinkRequestInterface {\n function operatorRequest(\n address sender,\n uint256 payment,\n bytes32 specId,\n bytes4 callbackFunctionId,\n uint256 nonce,\n uint256 dataVersion,\n bytes calldata data\n ) external;\n\n function fulfillOracleRequest2(\n bytes32 requestId,\n uint256 payment,\n address callbackAddress,\n bytes4 callbackFunctionId,\n uint256 expiration,\n bytes calldata data\n ) external returns (bool);\n\n function ownerTransferAndCall(\n address to,\n uint256 value,\n bytes calldata data\n ) external returns (bool success);\n\n function distributeFunds(address payable[] calldata receivers, uint256[] calldata amounts) external payable;\n\n function getAuthorizedSenders() external returns (address[] memory);\n\n function setAuthorizedSenders(address[] calldata senders) external;\n\n function getForwarder() external returns (address);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/OracleInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface OracleInterface {\n function fulfillOracleRequest(\n bytes32 requestId,\n uint256 payment,\n address callbackAddress,\n bytes4 callbackFunctionId,\n uint256 expiration,\n bytes32 data\n ) external returns (bool);\n\n function isAuthorizedSender(address node) external view returns (bool);\n\n function withdraw(address recipient, uint256 amount) external;\n\n function withdrawable() external view returns (uint256);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/PointerInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface PointerInterface {\n function getAddress() external view returns (address);\n}\n" + }, + "@chainlink/contracts/src/v0.8/vendor/BufferChainlink.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @dev A library for working with mutable byte buffers in Solidity.\n *\n * Byte buffers are mutable and expandable, and provide a variety of primitives\n * for writing to them. At any time you can fetch a bytes object containing the\n * current contents of the buffer. The bytes object should not be stored between\n * operations, as it may change due to resizing of the buffer.\n */\nlibrary BufferChainlink {\n /**\n * @dev Represents a mutable buffer. Buffers have a current value (buf) and\n * a capacity. The capacity may be longer than the current value, in\n * which case it can be extended without the need to allocate more memory.\n */\n struct buffer {\n bytes buf;\n uint256 capacity;\n }\n\n /**\n * @dev Initializes a buffer with an initial capacity.\n * @param buf The buffer to initialize.\n * @param capacity The number of bytes of space to allocate the buffer.\n * @return The buffer, for chaining.\n */\n function init(buffer memory buf, uint256 capacity) internal pure returns (buffer memory) {\n if (capacity % 32 != 0) {\n capacity += 32 - (capacity % 32);\n }\n // Allocate space for the buffer data\n buf.capacity = capacity;\n assembly {\n let ptr := mload(0x40)\n mstore(buf, ptr)\n mstore(ptr, 0)\n mstore(0x40, add(32, add(ptr, capacity)))\n }\n return buf;\n }\n\n /**\n * @dev Initializes a new buffer from an existing bytes object.\n * Changes to the buffer may mutate the original value.\n * @param b The bytes object to initialize the buffer with.\n * @return A new buffer.\n */\n function fromBytes(bytes memory b) internal pure returns (buffer memory) {\n buffer memory buf;\n buf.buf = b;\n buf.capacity = b.length;\n return buf;\n }\n\n function resize(buffer memory buf, uint256 capacity) private pure {\n bytes memory oldbuf = buf.buf;\n init(buf, capacity);\n append(buf, oldbuf);\n }\n\n function max(uint256 a, uint256 b) private pure returns (uint256) {\n if (a > b) {\n return a;\n }\n return b;\n }\n\n /**\n * @dev Sets buffer length to 0.\n * @param buf The buffer to truncate.\n * @return The original buffer, for chaining..\n */\n function truncate(buffer memory buf) internal pure returns (buffer memory) {\n assembly {\n let bufptr := mload(buf)\n mstore(bufptr, 0)\n }\n return buf;\n }\n\n /**\n * @dev Writes a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The start offset to write to.\n * @param data The data to append.\n * @param len The number of bytes to copy.\n * @return The original buffer, for chaining.\n */\n function write(\n buffer memory buf,\n uint256 off,\n bytes memory data,\n uint256 len\n ) internal pure returns (buffer memory) {\n require(len <= data.length);\n\n if (off + len > buf.capacity) {\n resize(buf, max(buf.capacity, len + off) * 2);\n }\n\n uint256 dest;\n uint256 src;\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Length of existing buffer data\n let buflen := mload(bufptr)\n // Start address = buffer address + offset + sizeof(buffer length)\n dest := add(add(bufptr, 32), off)\n // Update buffer length if we're extending it\n if gt(add(len, off), buflen) {\n mstore(bufptr, add(len, off))\n }\n src := add(data, 32)\n }\n\n // Copy word-length chunks while possible\n for (; len >= 32; len -= 32) {\n assembly {\n mstore(dest, mload(src))\n }\n dest += 32;\n src += 32;\n }\n\n // Copy remaining bytes\n unchecked {\n uint256 mask = (256**(32 - len)) - 1;\n assembly {\n let srcpart := and(mload(src), not(mask))\n let destpart := and(mload(dest), mask)\n mstore(dest, or(destpart, srcpart))\n }\n }\n\n return buf;\n }\n\n /**\n * @dev Appends a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @param len The number of bytes to copy.\n * @return The original buffer, for chaining.\n */\n function append(\n buffer memory buf,\n bytes memory data,\n uint256 len\n ) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, data, len);\n }\n\n /**\n * @dev Appends a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, data, data.length);\n }\n\n /**\n * @dev Writes a byte to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write the byte at.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function writeUint8(\n buffer memory buf,\n uint256 off,\n uint8 data\n ) internal pure returns (buffer memory) {\n if (off >= buf.capacity) {\n resize(buf, buf.capacity * 2);\n }\n\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Length of existing buffer data\n let buflen := mload(bufptr)\n // Address = buffer address + sizeof(buffer length) + off\n let dest := add(add(bufptr, off), 32)\n mstore8(dest, data)\n // Update buffer length if we extended it\n if eq(off, buflen) {\n mstore(bufptr, add(buflen, 1))\n }\n }\n return buf;\n }\n\n /**\n * @dev Appends a byte to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function appendUint8(buffer memory buf, uint8 data) internal pure returns (buffer memory) {\n return writeUint8(buf, buf.buf.length, data);\n }\n\n /**\n * @dev Writes up to 32 bytes to the buffer. Resizes if doing so would\n * exceed the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write at.\n * @param data The data to append.\n * @param len The number of bytes to write (left-aligned).\n * @return The original buffer, for chaining.\n */\n function write(\n buffer memory buf,\n uint256 off,\n bytes32 data,\n uint256 len\n ) private pure returns (buffer memory) {\n if (len + off > buf.capacity) {\n resize(buf, (len + off) * 2);\n }\n\n unchecked {\n uint256 mask = (256**len) - 1;\n // Right-align data\n data = data >> (8 * (32 - len));\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Address = buffer address + sizeof(buffer length) + off + len\n let dest := add(add(bufptr, off), len)\n mstore(dest, or(and(mload(dest), not(mask)), data))\n // Update buffer length if we extended it\n if gt(add(off, len), mload(bufptr)) {\n mstore(bufptr, add(off, len))\n }\n }\n }\n return buf;\n }\n\n /**\n * @dev Writes a bytes20 to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write at.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function writeBytes20(\n buffer memory buf,\n uint256 off,\n bytes20 data\n ) internal pure returns (buffer memory) {\n return write(buf, off, bytes32(data), 20);\n }\n\n /**\n * @dev Appends a bytes20 to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chhaining.\n */\n function appendBytes20(buffer memory buf, bytes20 data) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, bytes32(data), 20);\n }\n\n /**\n * @dev Appends a bytes32 to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function appendBytes32(buffer memory buf, bytes32 data) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, data, 32);\n }\n\n /**\n * @dev Writes an integer to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write at.\n * @param data The data to append.\n * @param len The number of bytes to write (right-aligned).\n * @return The original buffer, for chaining.\n */\n function writeInt(\n buffer memory buf,\n uint256 off,\n uint256 data,\n uint256 len\n ) private pure returns (buffer memory) {\n if (len + off > buf.capacity) {\n resize(buf, (len + off) * 2);\n }\n\n uint256 mask = (256**len) - 1;\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Address = buffer address + off + sizeof(buffer length) + len\n let dest := add(add(bufptr, off), len)\n mstore(dest, or(and(mload(dest), not(mask)), data))\n // Update buffer length if we extended it\n if gt(add(off, len), mload(bufptr)) {\n mstore(bufptr, add(off, len))\n }\n }\n return buf;\n }\n\n /**\n * @dev Appends a byte to the end of the buffer. Resizes if doing so would\n * exceed the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer.\n */\n function appendInt(\n buffer memory buf,\n uint256 data,\n uint256 len\n ) internal pure returns (buffer memory) {\n return writeInt(buf, buf.buf.length, data, len);\n }\n}\n" + }, + "@chainlink/contracts/src/v0.8/vendor/CBORChainlink.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.19;\n\nimport {BufferChainlink} from \"./BufferChainlink.sol\";\n\nlibrary CBORChainlink {\n using BufferChainlink for BufferChainlink.buffer;\n\n uint8 private constant MAJOR_TYPE_INT = 0;\n uint8 private constant MAJOR_TYPE_NEGATIVE_INT = 1;\n uint8 private constant MAJOR_TYPE_BYTES = 2;\n uint8 private constant MAJOR_TYPE_STRING = 3;\n uint8 private constant MAJOR_TYPE_ARRAY = 4;\n uint8 private constant MAJOR_TYPE_MAP = 5;\n uint8 private constant MAJOR_TYPE_TAG = 6;\n uint8 private constant MAJOR_TYPE_CONTENT_FREE = 7;\n\n uint8 private constant TAG_TYPE_BIGNUM = 2;\n uint8 private constant TAG_TYPE_NEGATIVE_BIGNUM = 3;\n\n function encodeFixedNumeric(BufferChainlink.buffer memory buf, uint8 major, uint64 value) private pure {\n if(value <= 23) {\n buf.appendUint8(uint8((major << 5) | value));\n } else if (value <= 0xFF) {\n buf.appendUint8(uint8((major << 5) | 24));\n buf.appendInt(value, 1);\n } else if (value <= 0xFFFF) {\n buf.appendUint8(uint8((major << 5) | 25));\n buf.appendInt(value, 2);\n } else if (value <= 0xFFFFFFFF) {\n buf.appendUint8(uint8((major << 5) | 26));\n buf.appendInt(value, 4);\n } else {\n buf.appendUint8(uint8((major << 5) | 27));\n buf.appendInt(value, 8);\n }\n }\n\n function encodeIndefiniteLengthType(BufferChainlink.buffer memory buf, uint8 major) private pure {\n buf.appendUint8(uint8((major << 5) | 31));\n }\n\n function encodeUInt(BufferChainlink.buffer memory buf, uint value) internal pure {\n if(value > 0xFFFFFFFFFFFFFFFF) {\n encodeBigNum(buf, value);\n } else {\n encodeFixedNumeric(buf, MAJOR_TYPE_INT, uint64(value));\n }\n }\n\n function encodeInt(BufferChainlink.buffer memory buf, int value) internal pure {\n if(value < -0x10000000000000000) {\n encodeSignedBigNum(buf, value);\n } else if(value > 0xFFFFFFFFFFFFFFFF) {\n encodeBigNum(buf, uint(value));\n } else if(value >= 0) {\n encodeFixedNumeric(buf, MAJOR_TYPE_INT, uint64(uint256(value)));\n } else {\n encodeFixedNumeric(buf, MAJOR_TYPE_NEGATIVE_INT, uint64(uint256(-1 - value)));\n }\n }\n\n function encodeBytes(BufferChainlink.buffer memory buf, bytes memory value) internal pure {\n encodeFixedNumeric(buf, MAJOR_TYPE_BYTES, uint64(value.length));\n buf.append(value);\n }\n\n function encodeBigNum(BufferChainlink.buffer memory buf, uint value) internal pure {\n buf.appendUint8(uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_BIGNUM));\n encodeBytes(buf, abi.encode(value));\n }\n\n function encodeSignedBigNum(BufferChainlink.buffer memory buf, int input) internal pure {\n buf.appendUint8(uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_NEGATIVE_BIGNUM));\n encodeBytes(buf, abi.encode(uint256(-1 - input)));\n }\n\n function encodeString(BufferChainlink.buffer memory buf, string memory value) internal pure {\n encodeFixedNumeric(buf, MAJOR_TYPE_STRING, uint64(bytes(value).length));\n buf.append(bytes(value));\n }\n\n function startArray(BufferChainlink.buffer memory buf) internal pure {\n encodeIndefiniteLengthType(buf, MAJOR_TYPE_ARRAY);\n }\n\n function startMap(BufferChainlink.buffer memory buf) internal pure {\n encodeIndefiniteLengthType(buf, MAJOR_TYPE_MAP);\n }\n\n function endSequence(BufferChainlink.buffer memory buf) internal pure {\n encodeIndefiniteLengthType(buf, MAJOR_TYPE_CONTENT_FREE);\n }\n}\n" + }, + "@chainlink/contracts/src/v0.8/vendor/ENSResolver.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract ENSResolver {\n function addr(bytes32 node) public view virtual returns (address);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlUpgradeable.sol\";\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../utils/StringsUpgradeable.sol\";\nimport \"../utils/introspection/ERC165Upgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n StringsUpgradeable.toHexString(account),\n \" is missing role \",\n StringsUpgradeable.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControlUpgradeable {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (security/PullPayment.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/escrow/EscrowUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Simple implementation of a\n * https://consensys.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls[pull-payment]\n * strategy, where the paying contract doesn't interact directly with the\n * receiver account, which must withdraw its payments itself.\n *\n * Pull-payments are often considered the best practice when it comes to sending\n * Ether, security-wise. It prevents recipients from blocking execution, and\n * eliminates reentrancy concerns.\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 *\n * To use, derive from the `PullPayment` contract, and use {_asyncTransfer}\n * instead of Solidity's `transfer` function. Payees can query their due\n * payments with {payments}, and retrieve them with {withdrawPayments}.\n *\n * @custom:storage-size 51\n */\nabstract contract PullPaymentUpgradeable is Initializable {\n EscrowUpgradeable private _escrow;\n\n function __PullPayment_init() internal onlyInitializing {\n __PullPayment_init_unchained();\n }\n\n function __PullPayment_init_unchained() internal onlyInitializing {\n _escrow = new EscrowUpgradeable();\n _escrow.initialize();\n }\n\n /**\n * @dev Withdraw accumulated payments, forwarding all gas to the recipient.\n *\n * Note that _any_ account can call this function, not just the `payee`.\n * This means that contracts unaware of the `PullPayment` protocol can still\n * receive funds this way, by having a separate account call\n * {withdrawPayments}.\n *\n * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.\n * Make sure you trust the recipient, or are either following the\n * checks-effects-interactions pattern or using {ReentrancyGuard}.\n *\n * @param payee Whose payments will be withdrawn.\n *\n * Causes the `escrow` to emit a {Withdrawn} event.\n */\n function withdrawPayments(address payable payee) public virtual {\n _escrow.withdraw(payee);\n }\n\n /**\n * @dev Returns the payments owed to an address.\n * @param dest The creditor's address.\n */\n function payments(address dest) public view returns (uint256) {\n return _escrow.depositsOf(dest);\n }\n\n /**\n * @dev Called by the payer to store the sent amount as credit to be pulled.\n * Funds sent in this way are stored in an intermediate {Escrow} contract, so\n * there is no danger of them being spent before withdrawal.\n *\n * @param dest The destination address of the funds.\n * @param amount The amount to transfer.\n *\n * Causes the `escrow` to emit a {Deposited} event.\n */\n function _asyncTransfer(address dest, uint256 amount) internal virtual {\n _escrow.deposit{value: amount}(dest);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n using AddressUpgradeable for address;\n using StringsUpgradeable for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC721_init_unchained(name_, symbol_);\n }\n\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n return\n interfaceId == type(IERC721Upgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\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 * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\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 `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 _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\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 _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721Upgradeable.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\n *\n * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant\n * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such\n * that `ownerOf(tokenId)` is `a`.\n */\n // solhint-disable-next-line func-name-mixedcase\n function __unsafe_increaseBalance(address account, uint256 amount) internal {\n _balances[account] += amount;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[44] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721EnumerableUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.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 IERC721ReceiverUpgradeable {\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-upgradeable/token/ERC721/IERC721Upgradeable.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/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\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-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/Base64Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.6) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64Upgradeable {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 0x20)\n let dataPtr := data\n let endPtr := add(data, mload(data))\n\n // In some cases, the last iteration will read bytes after the end of the data. We cache the value, and\n // set it to zero to make sure no dirty bytes are read in that section.\n let afterPtr := add(endPtr, 0x20)\n let afterCache := mload(afterPtr)\n mstore(afterPtr, 0x00)\n\n // Run over the input, 3 bytes at a time\n for {\n\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 byte (24 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F to bitmask the least significant 6 bits.\n // Use this as an index into the lookup table, mload an entire word\n // so the desired character is in the least significant byte, and\n // mstore8 this least significant byte into the result and continue.\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // Reset the value that was cached\n mstore(afterPtr, afterCache)\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/escrow/EscrowUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/escrow/Escrow.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../access/OwnableUpgradeable.sol\";\nimport \"../AddressUpgradeable.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @title Escrow\n * @dev Base escrow contract, holds funds designated for a payee until they\n * withdraw them.\n *\n * Intended usage: This contract (and derived escrow contracts) should be a\n * standalone contract, that only interacts with the contract that instantiated\n * it. That way, it is guaranteed that all Ether will be handled according to\n * the `Escrow` rules, and there is no need to check for payable functions or\n * transfers in the inheritance tree. The contract that uses the escrow as its\n * payment method should be its owner, and provide public methods redirecting\n * to the escrow's deposit and withdraw.\n */\ncontract EscrowUpgradeable is Initializable, OwnableUpgradeable {\n using AddressUpgradeable for address payable;\n\n event Deposited(address indexed payee, uint256 weiAmount);\n event Withdrawn(address indexed payee, uint256 weiAmount);\n\n mapping(address => uint256) private _deposits;\n\n function __Escrow_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Escrow_init_unchained() internal onlyInitializing {\n }\n function initialize() public virtual initializer {\n __Escrow_init();\n }\n function depositsOf(address payee) public view returns (uint256) {\n return _deposits[payee];\n }\n\n /**\n * @dev Stores the sent amount as credit to be withdrawn.\n * @param payee The destination address of the funds.\n *\n * Emits a {Deposited} event.\n */\n function deposit(address payee) public payable virtual onlyOwner {\n uint256 amount = msg.value;\n _deposits[payee] += amount;\n emit Deposited(payee, amount);\n }\n\n /**\n * @dev Withdraw accumulated balance for a payee, forwarding all gas to the\n * recipient.\n *\n * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.\n * Make sure you trust the recipient, or are either following the\n * checks-effects-interactions pattern or using {ReentrancyGuard}.\n *\n * @param payee The address whose funds will be withdrawn and transferred to.\n *\n * Emits a {Withdrawn} event.\n */\n function withdraw(address payable payee) public virtual onlyOwner {\n uint256 payment = _deposits[payee];\n\n _deposits[payee] = 0;\n\n payee.sendValue(payment);\n\n emit Withdrawn(payee, payment);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.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 IERC165Upgradeable {\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-upgradeable/utils/math/MathUpgradeable.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 MathUpgradeable {\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" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.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 SignedMathUpgradeable {\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" + }, + "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.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/MathUpgradeable.sol\";\nimport \"./math/SignedMathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\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 = MathUpgradeable.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(SignedMathUpgradeable.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, MathUpgradeable.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" + }, + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n" + }, + "@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/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(address from, address to, uint256 amount) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\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/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\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 * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\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 `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 _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\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 _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\n *\n * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant\n * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such\n * that `ownerOf(tokenId)` is `a`.\n */\n // solhint-disable-next-line func-name-mixedcase\n function __unsafe_increaseBalance(address account, uint256 amount) internal {\n _balances[account] += amount;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\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/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Base64.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.6) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 0x20)\n let dataPtr := data\n let endPtr := add(data, mload(data))\n\n // In some cases, the last iteration will read bytes after the end of the data. We cache the value, and\n // set it to zero to make sure no dirty bytes are read in that section.\n let afterPtr := add(endPtr, 0x20)\n let afterCache := mload(afterPtr)\n mstore(afterPtr, 0x00)\n\n // Run over the input, 3 bytes at a time\n for {\n\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 byte (24 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F to bitmask the least significant 6 bits.\n // Use this as an index into the lookup table, mload an entire word\n // so the desired character is in the least significant byte, and\n // mstore8 this least significant byte into the result and continue.\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // Reset the value that was cached\n mstore(afterPtr, afterCache)\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\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" + }, + "@openzeppelin/contracts/utils/Counters.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@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/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/introspection/ERC165Checker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Library used to query support of an interface declared via {IERC165}.\n *\n * Note that these functions return the actual result of the query: they do not\n * `revert` if an interface is not supported. It is up to the caller to decide\n * what to do in these cases.\n */\nlibrary ERC165Checker {\n // As per the EIP-165 spec, no interface should ever match 0xffffffff\n bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\n\n /**\n * @dev Returns true if `account` supports the {IERC165} interface.\n */\n function supportsERC165(address account) internal view returns (bool) {\n // Any contract that implements ERC165 must explicitly indicate support of\n // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\n return\n supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&\n !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);\n }\n\n /**\n * @dev Returns true if `account` supports the interface defined by\n * `interfaceId`. Support for {IERC165} itself is queried automatically.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\n // query support of both ERC165 as per the spec and support of _interfaceId\n return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);\n }\n\n /**\n * @dev Returns a boolean array where each value corresponds to the\n * interfaces passed in and whether they're supported or not. This allows\n * you to batch check interfaces for a contract where your expectation\n * is that some interfaces may not be supported.\n *\n * See {IERC165-supportsInterface}.\n *\n * _Available since v3.4._\n */\n function getSupportedInterfaces(\n address account,\n bytes4[] memory interfaceIds\n ) internal view returns (bool[] memory) {\n // an array of booleans corresponding to interfaceIds and whether they're supported or not\n bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\n\n // query support of ERC165 itself\n if (supportsERC165(account)) {\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);\n }\n }\n\n return interfaceIdsSupported;\n }\n\n /**\n * @dev Returns true if `account` supports all the interfaces defined in\n * `interfaceIds`. Support for {IERC165} itself is queried automatically.\n *\n * Batch-querying can lead to gas savings by skipping repeated checks for\n * {IERC165} support.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\n // query support of ERC165 itself\n if (!supportsERC165(account)) {\n return false;\n }\n\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {\n return false;\n }\n }\n\n // all interfaces supported\n return true;\n }\n\n /**\n * @notice Query if a contract implements an interface, does not check ERC165 support\n * @param account The address of the contract to query for support of an interface\n * @param interfaceId The interface identifier, as specified in ERC-165\n * @return true if the contract at account indicates support of the interface with\n * identifier interfaceId, false otherwise\n * @dev Assumes that account contains a contract that supports ERC165, otherwise\n * the behavior of this method is undefined. This precondition can be checked\n * with {supportsERC165}.\n *\n * Some precompiled contracts will falsely indicate support for a given interface, so caution\n * should be exercised when using this function.\n *\n * Interface identification is specified in ERC-165.\n */\n function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {\n // prepare call\n bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\n\n // perform static call\n bool success;\n uint256 returnSize;\n uint256 returnValue;\n assembly {\n success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)\n returnSize := returndatasize()\n returnValue := mload(0x00)\n }\n\n return success && returnSize >= 0x20 && returnValue > 0;\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" + }, + "@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" + }, + "@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" + }, + "@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/AccessRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\n\ncontract AccessRegistry is AccessControlEnumerable {\n constructor() {\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n}\n" + }, + "contracts/ChainlinkRequest.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@chainlink/contracts/src/v0.8/ChainlinkClient.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\ncontract ChainlinkRequest is ChainlinkClient, Ownable {\n using Chainlink for Chainlink.Request;\n\n bytes32 private _jobId;\n uint256 private _fee;\n string private _url;\n\n struct PendingRequest {\n address sender;\n bytes4 selector;\n bytes state;\n }\n mapping(bytes32 => PendingRequest) private _pendingRequests;\n\n function config()\n public\n view\n returns (\n address chainlinkToken,\n address chainlinkOracle,\n bytes32 jobId,\n uint256 fee,\n string memory url\n )\n {\n return (\n chainlinkTokenAddress(),\n chainlinkOracleAddress(),\n _jobId,\n _fee,\n _url\n );\n }\n\n function configure(\n address chainlinkToken,\n address chainlinkOracle,\n bytes32 jobId,\n uint256 fee,\n string memory url\n ) public onlyOwner {\n setChainlinkToken(chainlinkToken);\n setChainlinkOracle(chainlinkOracle);\n\n _jobId = jobId;\n _fee = fee;\n _url = url;\n }\n\n function requestBytes(bytes4 selector, bytes memory state)\n public\n returns (bytes32 requestId)\n {\n uint256 selector_;\n assembly {\n let ptr := mload(0x40)\n calldatacopy(ptr, 4, 4)\n selector_ := shr(224, mload(ptr))\n }\n\n Chainlink.Request memory req = buildChainlinkRequest(\n _jobId,\n address(this),\n this.fulfillBytes.selector\n );\n req.add(\n \"get\",\n string(\n abi.encodePacked(\n _url,\n \"&sender=\",\n Strings.toHexString(uint256(uint160(msg.sender)), 20),\n \"&selector=\",\n Strings.toHexString(selector_, 4),\n \"&state=\",\n Base64.encode(state)\n )\n )\n );\n req.add(\"path\", \"data\");\n requestId = sendChainlinkRequest(req, _fee);\n\n _pendingRequests[requestId] = PendingRequest({\n sender: msg.sender,\n selector: selector,\n state: state\n });\n return requestId;\n }\n\n function fulfillBytes(bytes32 requestId, bytes memory bytesData)\n public\n recordChainlinkFulfillment(requestId)\n {\n PendingRequest memory pendingRequest = _pendingRequests[requestId];\n\n (bool success, bytes memory result) = pendingRequest.sender.call(\n abi.encodeWithSelector(\n pendingRequest.selector,\n pendingRequest.state,\n bytesData\n )\n );\n if (!success) {\n if (result.length > 0) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n } else {\n revert(\"ChainlinkRequest: callback failed\");\n }\n }\n\n delete _pendingRequests[requestId];\n }\n\n function withdrawLink(address to) public onlyOwner {\n LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());\n require(\n link.transfer(to, link.balanceOf(address(this))),\n \"ChainlinkRequest: unable to transfer\"\n );\n }\n}\n" + }, + "contracts/ERC20Mint.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract ERC20Mint is ERC20 {\n constructor(string memory name, string memory symbol, address owner, uint256 initialSupply) ERC20(name, symbol) {\n _mint(owner, initialSupply);\n }\n}\n" + }, + "contracts/ERC721CollectionV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"./rarible/LibPart.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\nbytes4 constant ERC2981_INTERFACE_ID = 0x2a55205a;\nbytes4 constant RaribleRoyaltiesV2_INTERFACE_ID = 0xcad96cca;\n\ncontract OwnableDelegateProxy {}\n\ncontract ProxyRegistry {\n mapping(address => OwnableDelegateProxy) public proxies;\n}\n\ncontract ERC721CollectionV1 is ERC165, ERC721, Ownable {\n address private _proxyRegistryAddress;\n address private _creator;\n uint96 private _royalty;\n string private _baseTokenURI;\n uint256 private _totalSupply;\n\n constructor(\n string memory name,\n string memory symbol,\n address proxyRegistryAddress,\n address creator,\n uint96 royalty,\n string memory baseTokenURI,\n uint256 totalSupply_\n ) ERC721(name, symbol) {\n _transferOwnership(creator);\n\n _proxyRegistryAddress = proxyRegistryAddress;\n _creator = creator;\n _royalty = royalty;\n _baseTokenURI = baseTokenURI;\n _totalSupply = totalSupply_;\n\n for (uint256 tokenId; tokenId < totalSupply_; tokenId++) {\n _mint(creator, tokenId);\n }\n }\n\n function _baseURI() internal view virtual override returns (string memory) {\n return _baseTokenURI;\n }\n\n function getRaribleV2Royalties(uint256)\n external\n view\n returns (LibPart.Part[] memory)\n {\n LibPart.Part[] memory result;\n if (_royalty == 0) {\n return result;\n }\n\n result = new LibPart.Part[](1);\n result[0].account = payable(_creator);\n result[0].value = _royalty;\n return result;\n }\n\n function isApprovedForAll(address owner, address operator)\n public\n view\n override\n returns (bool)\n {\n // Whitelist OpenSea proxy contract for easy trading.\n ProxyRegistry proxyRegistry = ProxyRegistry(_proxyRegistryAddress);\n if (address(proxyRegistry.proxies(owner)) == operator) {\n return true;\n }\n\n return super.isApprovedForAll(owner, operator);\n }\n\n function royaltyInfo(uint256, uint256 price)\n external\n view\n returns (address receiver, uint256 royaltyAmount)\n {\n if (_royalty == 0) {\n return (address(0), 0);\n }\n\n return (_creator, (price * _royalty) / 10000);\n }\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC165, ERC721)\n returns (bool)\n {\n return\n interfaceId == ERC2981_INTERFACE_ID ||\n interfaceId == RaribleRoyaltiesV2_INTERFACE_ID ||\n super.supportsInterface(interfaceId);\n }\n\n function totalSupply() public view returns (uint256) {\n return _totalSupply;\n }\n}\n" + }, + "contracts/ERC721LemonadeV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./rarible/LibPart.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\nbytes4 constant ERC2981_INTERFACE_ID = 0x2a55205a;\nbytes4 constant RaribleRoyaltiesV2_INTERFACE_ID = 0xcad96cca;\n\ninterface IMintable {\n function mintToCaller(string memory tokenURI) external returns (uint256);\n\n function mintToCallerWithRoyalty(\n string memory tokenURI,\n LibPart.Part[] memory royalties\n ) external returns (uint256);\n}\n\ncontract ERC721LemonadeV1 is ERC721, Ownable, IMintable {\n using Counters for Counters.Counter;\n\n Counters.Counter public tokenIdTracker;\n\n mapping(uint256 => string) public tokenURIs;\n mapping(uint256 => LibPart.Part[]) public royalties;\n\n constructor(string memory name, string memory symbol)\n ERC721(name, symbol)\n {}\n\n function mintToCaller(string memory tokenURI_)\n public\n override\n returns (uint256)\n {\n uint256 tokenId = tokenIdTracker.current();\n\n _mint(_msgSender(), tokenId);\n tokenURIs[tokenId] = tokenURI_;\n\n tokenIdTracker.increment();\n\n return tokenId;\n }\n\n function mintToCallerWithRoyalty(\n string memory tokenURI_,\n LibPart.Part[] memory royalties_\n ) public override returns (uint256) {\n uint256 tokenId = mintToCaller(tokenURI_);\n\n uint256 length = royalties_.length;\n for (uint256 i; i < length; ) {\n royalties[tokenId].push(royalties_[i]);\n unchecked {\n ++i;\n }\n }\n\n return tokenId;\n }\n\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n require(\n _exists(tokenId),\n \"ERC721Lemonade: URI query for nonexistent token\"\n );\n\n return tokenURIs[tokenId];\n }\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override\n returns (bool)\n {\n return\n interfaceId == ERC2981_INTERFACE_ID ||\n interfaceId == RaribleRoyaltiesV2_INTERFACE_ID ||\n super.supportsInterface(interfaceId);\n }\n\n function getRaribleV2Royalties(uint256 tokenId)\n public\n view\n returns (LibPart.Part[] memory)\n {\n return royalties[tokenId];\n }\n\n function royaltyInfo(uint256 tokenId, uint256 price)\n public\n view\n returns (address receiver, uint256 royaltyAmount)\n {\n uint256 length = royalties[tokenId].length;\n\n if (length == 0) {\n return (address(0), 0);\n }\n\n uint256 totalValue;\n for (uint256 i; i < length; i++) {\n totalValue += royalties[tokenId][i].value;\n }\n return (royalties[tokenId][0].account, (price * totalValue) / 10000);\n }\n}\n" + }, + "contracts/ERC721LemonadeV1Ethereum.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ERC721LemonadeV1.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract OwnableDelegateProxy {}\n\ncontract ProxyRegistry {\n mapping(address => OwnableDelegateProxy) public proxies;\n}\n\ncontract ERC721LemonadeV1Ethereum is ERC721LemonadeV1 {\n address private _proxyRegistryAddress;\n\n constructor(\n string memory name,\n string memory symbol,\n address proxyRegistryAddress\n ) ERC721LemonadeV1(name, symbol) {\n _proxyRegistryAddress = proxyRegistryAddress;\n }\n\n function isApprovedForAll(address owner, address operator)\n public\n view\n override\n returns (bool)\n {\n // Whitelist OpenSea proxy contract for easy trading.\n ProxyRegistry proxyRegistry = ProxyRegistry(_proxyRegistryAddress);\n if (address(proxyRegistry.proxies(owner)) == operator) {\n return true;\n }\n\n return super.isApprovedForAll(owner, operator);\n }\n}\n" + }, + "contracts/ERC721LemonadeV1Forwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ERC721LemonadeV1.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract ERC721LemonadeV1Forwardable is ERC721LemonadeV1, RelayRecipient {\n constructor(\n string memory name,\n string memory symbol,\n address trustedForwarder\n ) ERC721LemonadeV1(name, symbol) RelayRecipient(trustedForwarder) {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n}\n" + }, + "contracts/FestivalHeadsV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./AccessRegistry.sol\";\nimport \"./ChainlinkRequest.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\nbytes32 constant FESTIVAL_HEADS_OPERATOR_ROLE = keccak256(\n \"FESTIVAL_HEADS_OPERATOR_ROLE\"\n);\nbytes32 constant TRUSTED_CLAIMER_ROLE = keccak256(\"TRUSTED_CLAIMER_ROLE\");\n\ninterface IFestivalHeadsV1 is IERC721 {\n function hasClaimed(\n address[] calldata claimers\n ) external view returns (bool[] memory);\n\n function supply() external view returns (uint256, uint256);\n\n function totalSupply() external view returns (uint256);\n}\n\ncontract FestivalHeadsV1 is ERC721, Ownable, IFestivalHeadsV1 {\n using Counters for Counters.Counter;\n\n error AllClaimed();\n error AlreadyClaimed();\n error Forbidden();\n error NotFound();\n\n event ClaimFailed(string reason);\n event ClaimFailedBytes(bytes reason);\n\n uint256 public maxSupply;\n address public immutable accessRegistry;\n address public chainlinkRequest;\n\n Counters.Counter public tokenIdTracker;\n mapping(address => bool) public claimed;\n mapping(uint256 => string) public tokenURIs;\n\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n uint256 maxSupply_,\n address accessRegistry_,\n address chainlinkRequest_\n ) ERC721(name, symbol) {\n _transferOwnership(creator);\n\n maxSupply = maxSupply_;\n accessRegistry = accessRegistry_;\n chainlinkRequest = chainlinkRequest_;\n }\n\n function _checkBeforeMint(\n address claimer,\n uint256 tokenId\n ) internal virtual {\n if (tokenId >= maxSupply) {\n revert AllClaimed();\n }\n if (claimed[claimer]) {\n revert AlreadyClaimed();\n }\n }\n\n function _mint(address claimer, string memory tokenURI_) internal virtual {\n uint256 tokenId = tokenIdTracker.current();\n\n _checkBeforeMint(claimer, tokenId);\n _mint(claimer, tokenId);\n\n claimed[claimer] = true;\n tokenURIs[tokenId] = tokenURI_;\n tokenIdTracker.increment();\n }\n\n function claimTo(address claimer, string memory tokenURI_) public virtual {\n if (\n !AccessRegistry(accessRegistry).hasRole(\n TRUSTED_CLAIMER_ROLE,\n _msgSender()\n )\n ) {\n revert Forbidden();\n }\n\n if (chainlinkRequest == address(0)) {\n return _mint(claimer, tokenURI_);\n }\n\n _checkBeforeMint(claimer, tokenIdTracker.current());\n\n bytes memory state = abi.encode(claimer, tokenURI_);\n\n ChainlinkRequest(chainlinkRequest).requestBytes(\n this.fulfillClaim.selector,\n state\n );\n }\n\n function fulfillMint(address claimer, string memory tokenURI_) external {\n if (_msgSender() != address(this)) {\n revert Forbidden();\n }\n\n _mint(claimer, tokenURI_);\n }\n\n function fulfillClaim(\n bytes memory state,\n bytes memory bytesData\n ) public virtual {\n if (_msgSender() != chainlinkRequest) {\n revert Forbidden();\n }\n\n (bool ok, string memory err) = abi.decode(bytesData, (bool, string));\n\n if (ok) {\n (address claimer, string memory tokenURI_) = abi.decode(\n state,\n (address, string)\n );\n\n try this.fulfillMint(claimer, tokenURI_) {\n /* no-op */\n } catch Error(string memory reason) {\n err = reason;\n } catch (bytes memory reason) {\n emit ClaimFailedBytes(reason);\n }\n }\n if (bytes(err).length > 0) {\n emit ClaimFailed(err);\n }\n }\n\n function hasClaimed(\n address[] calldata claimers\n ) public view virtual override returns (bool[] memory) {\n uint256 length = claimers.length;\n bool[] memory result = new bool[](length);\n\n for (uint256 i; i < length; i++) {\n result[i] = claimed[claimers[i]];\n }\n return result;\n }\n\n function supply() public view virtual override returns (uint256, uint256) {\n return (tokenIdTracker.current(), maxSupply);\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return (tokenIdTracker.current());\n }\n\n function _isApprovedOrOwner(\n address spender,\n uint256\n ) internal view virtual override returns (bool) {\n return\n AccessRegistry(accessRegistry).hasRole(\n FESTIVAL_HEADS_OPERATOR_ROLE,\n spender\n );\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IFestivalHeadsV1).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function tokenURI(\n uint256 tokenId\n ) public view virtual override returns (string memory) {\n if (!_exists(tokenId)) {\n revert NotFound();\n }\n\n return tokenURIs[tokenId];\n }\n\n function setChainlinkRequest(\n address chainlinkRequest_\n ) public onlyFestivalHeadsOperator {\n chainlinkRequest = chainlinkRequest_;\n }\n\n function setMaxSupply(uint256 maxSupply_) public onlyFestivalHeadsOperator {\n maxSupply = maxSupply_;\n }\n\n function burn(\n uint256 tokenId,\n bool reset\n ) public onlyFestivalHeadsOperator {\n if (reset) {\n claimed[ownerOf(tokenId)] = false;\n }\n\n _burn(tokenId);\n }\n\n function mint(\n address claimer,\n string memory tokenURI_,\n uint256 tokenId\n ) public onlyFestivalHeadsOperator {\n uint256 nextTokenId = tokenIdTracker.current();\n\n if (tokenId > nextTokenId) {\n revert NotFound();\n }\n\n _mint(claimer, tokenId);\n\n claimed[claimer] = true;\n tokenURIs[tokenId] = tokenURI_;\n\n if (tokenId == nextTokenId) {\n tokenIdTracker.increment();\n }\n }\n\n modifier onlyFestivalHeadsOperator() {\n if (\n !AccessRegistry(accessRegistry).hasRole(\n FESTIVAL_HEADS_OPERATOR_ROLE,\n _msgSender()\n )\n ) {\n revert Forbidden();\n }\n _;\n }\n}\n" + }, + "contracts/IERC2981.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\n///\n/// @dev Interface for the NFT Royalty Standard\n///\ninterface IERC2981 is IERC165 {\n /// ERC165 bytes to add to interface array - set in parent contract\n /// implementing this standard\n ///\n /// bytes4(keccak256(\"royaltyInfo(uint256,uint256)\")) == 0x2a55205a\n /// bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;\n /// _registerInterface(_INTERFACE_ID_ERC2981);\n\n /// @notice Called with the sale price to determine how much royalty\n // is owed and to whom.\n /// @param _tokenId - the NFT asset queried for royalty information\n /// @param _salePrice - the sale price of the NFT asset specified by _tokenId\n /// @return receiver - address of who should be sent the royalty payment\n /// @return royaltyAmount - the royalty payment amount for _salePrice\n function royaltyInfo(\n uint256 _tokenId,\n uint256 _salePrice\n ) external view returns (\n address receiver,\n uint256 royaltyAmount\n );\n}\n" + }, + "contracts/Introspection.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\n\ncontract Introspection {\n using ERC165Checker for address;\n\n function getSupportedInterfaces(\n address account,\n bytes4[] memory interfaceIds\n ) public view returns (bool[] memory) {\n require(account.code.length > 0, \"Introspection: account not a contract\");\n\n return account.getSupportedInterfaces(interfaceIds);\n }\n}\n" + }, + "contracts/IRelayRecipient.sol": { + "content": "// SPDX-License-Identifier:MIT\npragma solidity ^0.8.0;\n\n/**\n * a contract must implement this interface in order to support relayed transaction.\n * It is better to inherit the BaseRelayRecipient as its implementation.\n */\nabstract contract IRelayRecipient {\n\n /**\n * return if the forwarder is trusted to forward relayed transactions to us.\n * the forwarder is required to verify the sender's signature, and verify\n * the call is not a replay.\n */\n function isTrustedForwarder(address forwarder) public virtual view returns(bool);\n\n /**\n * return the sender of this call.\n * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes\n * of the msg.data.\n * otherwise, return `msg.sender`\n * should be used in the contract anywhere instead of msg.sender\n */\n function _msgSender() internal virtual view returns (address);\n\n function versionRecipient() external virtual view returns (string memory);\n}\n" + }, + "contracts/LemonadeMarketplaceV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC2981.sol\";\nimport \"./rarible/RoyaltiesV2.sol\";\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\ncontract LemonadeMarketplaceV1 is AccessControlEnumerable {\n using Counters for Counters.Counter;\n\n address public immutable feeAccount;\n uint96 public immutable feeValue;\n\n enum OrderKind {\n Direct,\n Auction\n }\n\n event OrderCreated(\n uint256 indexed orderId,\n OrderKind kind,\n uint256 openFrom,\n uint256 openTo,\n address indexed maker,\n address currency,\n uint256 price,\n address tokenContract,\n uint256 tokenId\n );\n event OrderBid(\n uint256 indexed orderId,\n address indexed bidder,\n uint256 bidAmount\n );\n event OrderFilled(\n uint256 indexed orderId,\n address indexed taker,\n uint256 paidAmount\n );\n event OrderCancelled(uint256 indexed orderId);\n\n struct Order {\n OrderKind kind;\n bool open;\n uint256 openFrom;\n uint256 openTo;\n address maker;\n address currency;\n uint256 price;\n address tokenContract;\n uint256 tokenId;\n address bidder;\n uint256 bidAmount;\n address taker;\n uint256 paidAmount;\n }\n mapping(uint256 => Order) private _orders;\n Counters.Counter public orderIdTracker;\n\n constructor(address feeAccount_, uint96 feeValue_) {\n feeAccount = feeAccount_;\n feeValue = feeValue_;\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function order(uint256 orderId)\n external\n view\n virtual\n whenExists(orderId)\n returns (\n OrderKind,\n bool,\n uint256,\n uint256,\n address,\n address,\n uint256,\n uint256,\n address,\n uint256\n )\n {\n Order memory order_ = _orders[orderId];\n return (\n order_.kind,\n order_.open,\n order_.openFrom,\n order_.openTo,\n order_.maker,\n order_.currency,\n order_.price,\n order_.bidAmount,\n order_.taker,\n order_.paidAmount\n );\n }\n\n function token(uint256 orderId)\n external\n view\n virtual\n whenExists(orderId)\n returns (address, uint256)\n {\n return (_orders[orderId].tokenContract, _orders[orderId].tokenId);\n }\n\n function createOrder(\n OrderKind kind,\n uint256 openFrom,\n uint256 openTo,\n address currency,\n uint256 price,\n address tokenContract,\n uint256 tokenId\n ) external virtual returns (uint256) {\n uint256 openDuration_ = openDuration(openFrom, openTo);\n\n require(\n openDuration_ > 0,\n \"LemonadeMarketplace: order must be open at some point\"\n );\n\n if (kind == OrderKind.Auction) {\n require(\n openDuration_ <= 30 * 24 * 60 * 60,\n \"LemonadeMarketplace: order of kind auction must not be open for more than 30 days\"\n );\n }\n\n IERC721(tokenContract).transferFrom(\n _msgSender(),\n address(this),\n tokenId\n );\n\n uint256 orderId = orderIdTracker.current();\n\n _orders[orderId] = Order({\n kind: kind,\n open: true,\n openFrom: openFrom,\n openTo: openTo,\n maker: _msgSender(),\n currency: currency,\n price: price,\n tokenContract: tokenContract,\n tokenId: tokenId,\n bidder: address(0),\n bidAmount: 0,\n taker: address(0),\n paidAmount: 0\n });\n\n orderIdTracker.increment();\n\n Order memory order_ = _orders[orderId];\n emit OrderCreated(\n orderId,\n order_.kind,\n order_.openFrom,\n order_.openTo,\n order_.maker,\n order_.currency,\n order_.price,\n order_.tokenContract,\n order_.tokenId\n );\n return orderId;\n }\n\n function cancelOrder(uint256 orderId) external virtual whenExists(orderId) {\n Order memory order_ = _orders[orderId];\n require(\n order_.maker == _msgSender() ||\n hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),\n \"LemonadeMarketplace: must be the maker to cancel\"\n );\n require(\n order_.open,\n \"LemonadeMarketplace: order must be open to cancel\"\n );\n require(\n order_.bidder == address(0),\n \"LemonadeMarketplace: order must have no bid to cancel\"\n );\n\n IERC721(order_.tokenContract).transferFrom(\n address(this),\n order_.maker,\n order_.tokenId\n );\n\n _orders[orderId].open = false;\n emit OrderCancelled(orderId);\n }\n\n function bidOrder(uint256 orderId, uint256 amount)\n external\n payable\n virtual\n whenExists(orderId)\n {\n Order memory order_ = _orders[orderId];\n require(\n order_.kind == OrderKind.Auction,\n \"LemonadeMarketplace: order must be of kind auction to bid\"\n );\n require(order_.open, \"LemonadeMarketplace: order must be open to bid\");\n require(\n order_.openFrom <= block.timestamp,\n \"LemonadeMarketplace: order must be open to bid - too early\"\n );\n require(\n order_.openTo > block.timestamp,\n \"LemonadeMarketplace: order must be open to bid - too late\"\n );\n require(\n order_.price <= amount,\n \"LemonadeMarketplace: must match price to bid\"\n );\n require(\n order_.currency != address(0) || amount == msg.value,\n \"LemonadeMarketplace: amount must match tx value\"\n );\n\n if (order_.bidder != address(0)) {\n require(\n order_.bidAmount < amount,\n \"LemonadeMarketplace: must surpass bid to bid\"\n );\n\n if (order_.bidAmount > 0) {\n transfer(\n order_.currency,\n address(this),\n order_.bidder,\n order_.bidAmount\n );\n }\n }\n\n _orders[orderId].bidder = _msgSender();\n _orders[orderId].bidAmount = amount;\n order_ = _orders[orderId];\n\n if (order_.bidAmount > 0) {\n transfer(\n order_.currency,\n order_.bidder,\n address(this),\n order_.bidAmount\n );\n }\n\n emit OrderBid(orderId, order_.bidder, order_.bidAmount);\n }\n\n function fillOrder(uint256 orderId, uint256 amount)\n external\n payable\n virtual\n whenExists(orderId)\n {\n Order memory order_ = _orders[orderId];\n require(order_.open, \"LemonadeMarketplace: order must be open to fill\");\n\n _orders[orderId].open = false;\n address spender;\n\n if (order_.kind == OrderKind.Direct) {\n require(\n order_.openFrom <= block.timestamp,\n \"LemonadeMarketplace: order must be open to fill - too early\"\n );\n require(\n order_.openTo == 0 || order_.openTo > block.timestamp,\n \"LemonadeMarketplace: order must be open to fill - too late\"\n );\n require(\n order_.price <= amount,\n \"LemonadeMarketplace: must match price to fill direct order\"\n );\n require(\n order_.currency != address(0) || amount == msg.value,\n \"LemonadeMarketplace: amount must match tx value\"\n );\n\n _orders[orderId].taker = _msgSender();\n _orders[orderId].paidAmount = amount;\n spender = _msgSender();\n } else if (order_.kind == OrderKind.Auction) {\n require(\n (order_.bidder != address(0)),\n \"LemonadeMarketplace: order must have bid to fill auction order\"\n );\n require(\n (order_.bidder == _msgSender() &&\n order_.openTo <= block.timestamp) ||\n order_.maker == _msgSender() ||\n hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),\n \"LemonadeMarketplace: must be the maker or final bidder to fill auction order\"\n );\n\n _orders[orderId].taker = order_.bidder;\n _orders[orderId].paidAmount = order_.bidAmount;\n spender = address(this);\n }\n\n order_ = _orders[orderId];\n\n if (order_.paidAmount > 0) {\n uint256 transferAmount = order_.paidAmount;\n\n uint256 feeAmount = (order_.paidAmount * feeValue) / 10000;\n transfer(order_.currency, spender, feeAccount, feeAmount);\n transferAmount -= feeAmount;\n\n (\n bool supportsRaribleV2Royalties,\n LibPart.Part[] memory royalties\n ) = getRaribleV2Royalties(order_.tokenContract, order_.tokenId);\n if (supportsRaribleV2Royalties) {\n uint256 length = royalties.length;\n for (uint256 i; i < length; i++) {\n if (\n order_.maker != royalties[i].account &&\n royalties[i].value > 0\n ) {\n uint256 royaltyAmount = (order_.paidAmount *\n royalties[i].value) / 10000;\n transfer(\n order_.currency,\n spender,\n royalties[i].account,\n royaltyAmount\n );\n transferAmount -= royaltyAmount;\n }\n }\n } else {\n (\n bool supportsRoyaltyInfo,\n address receiver,\n uint256 royaltyAmount\n ) = getRoyaltyInfo(\n order_.tokenContract,\n order_.tokenId,\n order_.paidAmount\n );\n if (\n supportsRoyaltyInfo &&\n order_.maker != receiver &&\n royaltyAmount > 0\n ) {\n transfer(order_.currency, spender, receiver, royaltyAmount);\n transferAmount -= royaltyAmount;\n }\n }\n\n if (transferAmount > 0) {\n transfer(\n order_.currency,\n spender,\n order_.maker,\n transferAmount\n );\n transferAmount -= transferAmount;\n }\n\n require(\n transferAmount == 0,\n \"LemonadeMarketplace: transfer amount must be zero\"\n );\n }\n\n IERC721(order_.tokenContract).transferFrom(\n address(this),\n order_.taker,\n order_.tokenId\n );\n\n emit OrderFilled(orderId, order_.taker, order_.paidAmount);\n }\n\n function getRaribleV2Royalties(address tokenContract, uint256 tokenId)\n public\n view\n virtual\n returns (bool, LibPart.Part[] memory)\n {\n try RoyaltiesV2(tokenContract).getRaribleV2Royalties(tokenId) returns (\n LibPart.Part[] memory royalties\n ) {\n return (true, royalties);\n } catch {\n return (false, new LibPart.Part[](0));\n }\n }\n\n function getRoyaltyInfo(\n address tokenContract,\n uint256 tokenId,\n uint256 paidAmount\n )\n public\n view\n virtual\n returns (\n bool,\n address,\n uint256\n )\n {\n try IERC2981(tokenContract).royaltyInfo(tokenId, paidAmount) returns (\n address receiver,\n uint256 royaltyAmount\n ) {\n return (true, receiver, royaltyAmount);\n } catch {\n return (false, address(0), 0);\n }\n }\n\n function transfer(\n address currency,\n address spender,\n address recipient,\n uint256 amount\n ) private {\n if (currency == address(0)) {\n if (recipient != address(this)) {\n payable(recipient).transfer(amount);\n }\n } else {\n if (spender == address(this)) {\n IERC20(currency).transfer(recipient, amount);\n } else {\n IERC20(currency).transferFrom(spender, recipient, amount);\n }\n }\n }\n\n function openDuration(uint256 openFrom, uint256 openTo)\n private\n view\n returns (uint256)\n {\n uint256 start = openFrom < block.timestamp ? block.timestamp : openFrom;\n uint256 end = openTo == 0 ? type(uint256).max : openTo;\n\n if (start > end) {\n return 0;\n }\n return end - start;\n }\n\n modifier whenExists(uint256 orderId) {\n require(\n _orders[orderId].maker != address(0),\n \"LemonadeMarketplace: order nonexistent\"\n );\n _;\n }\n}\n" + }, + "contracts/LemonadeMarketplaceV1Forwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadeMarketplaceV1.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract LemonadeMarketplaceV1Forwardable is\n LemonadeMarketplaceV1,\n RelayRecipient\n{\n constructor(\n address feeAccount,\n uint96 feeValue,\n address trustedForwarder\n )\n LemonadeMarketplaceV1(feeAccount, feeValue)\n RelayRecipient(trustedForwarder)\n {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n}\n" + }, + "contracts/LemonadeMarketplaceV1Unique.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadeMarketplaceV1.sol\";\nimport \"./unique/ICollection.sol\";\nimport \"./unique/LibPartAdapter.sol\";\n\ncontract LemonadeMarketplaceV1Unique is LemonadeMarketplaceV1 {\n constructor(\n address feeAccount,\n uint96 feeValue\n ) LemonadeMarketplaceV1(feeAccount, feeValue) {}\n\n function getRaribleV2Royalties(\n address tokenContract,\n uint256 tokenId\n ) public view override returns (bool, LibPart.Part[] memory) {\n if (!isCollection(tokenContract)) {\n return\n LemonadeMarketplaceV1.getRaribleV2Royalties(\n tokenContract,\n tokenId\n );\n }\n\n try\n ICollection(tokenContract).property(tokenId, ROYALTIES_PROPERTY)\n returns (bytes memory data) {\n return (true, LibPartAdapter.decode(data));\n } catch {\n return (false, new LibPart.Part[](0));\n }\n }\n\n function isCollection(address addr) private pure returns (bool) {\n return\n uint160(addr) & 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000 ==\n 0x0017c4e6453cc49aaaaeaca894e6d9683e00000000;\n }\n}\n" + }, + "contracts/LemonadeMarketplaceV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC2981.sol\";\nimport \"./rarible/RoyaltiesV2.sol\";\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\ncontract LemonadeMarketplaceV2 is AccessControlEnumerable {\n using Counters for Counters.Counter;\n\n address public immutable feeAccount;\n uint96 public immutable feeValue;\n\n enum OrderKind {\n Direct,\n Auction\n }\n\n event OrderCreated(\n uint256 indexed orderId,\n OrderKind kind,\n uint256 openFrom,\n uint256 openTo,\n address indexed maker,\n address currency,\n uint256 price,\n address tokenContract,\n uint256 tokenId\n );\n event OrderBid(\n uint256 indexed orderId,\n address indexed bidder,\n uint256 bidAmount\n );\n event OrderFilled(\n uint256 indexed orderId,\n address indexed taker,\n uint256 paidAmount\n );\n event OrderCancelled(uint256 indexed orderId);\n\n struct Order {\n OrderKind kind;\n bool open;\n uint256 openFrom;\n uint256 openTo;\n address maker;\n address currency;\n uint256 price;\n address tokenContract;\n uint256 tokenId;\n address bidder;\n uint256 bidAmount;\n address taker;\n uint256 paidAmount;\n }\n mapping(uint256 => Order) private _orders;\n Counters.Counter public orderIdTracker;\n\n constructor(address feeAccount_, uint96 feeValue_) {\n feeAccount = feeAccount_;\n feeValue = feeValue_;\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function order(uint256 orderId)\n external\n view\n virtual\n whenExists(orderId)\n returns (\n OrderKind,\n bool,\n uint256,\n uint256,\n address,\n address,\n uint256,\n uint256,\n address,\n uint256\n )\n {\n Order memory order_ = _orders[orderId];\n return (\n order_.kind,\n order_.open,\n order_.openFrom,\n order_.openTo,\n order_.maker,\n order_.currency,\n order_.price,\n order_.bidAmount,\n order_.taker,\n order_.paidAmount\n );\n }\n\n function token(uint256 orderId)\n external\n view\n virtual\n whenExists(orderId)\n returns (address, uint256)\n {\n return (_orders[orderId].tokenContract, _orders[orderId].tokenId);\n }\n\n function createOrder(\n OrderKind kind,\n uint256 openFrom,\n uint256 openTo,\n address currency,\n uint256 price,\n address tokenContract,\n uint256 tokenId\n ) external virtual returns (uint256) {\n uint256 openDuration_ = openDuration(openFrom, openTo);\n\n require(\n openDuration_ > 0,\n \"LemonadeMarketplace: order must be open at some point\"\n );\n\n if (kind == OrderKind.Auction) {\n require(\n openDuration_ <= 30 * 24 * 60 * 60,\n \"LemonadeMarketplace: order of kind auction must not be open for more than 30 days\"\n );\n }\n\n IERC721(tokenContract).transferFrom(\n _msgSender(),\n address(this),\n tokenId\n );\n\n uint256 orderId = orderIdTracker.current();\n\n _orders[orderId] = Order({\n kind: kind,\n open: true,\n openFrom: openFrom,\n openTo: openTo,\n maker: _msgSender(),\n currency: currency,\n price: price,\n tokenContract: tokenContract,\n tokenId: tokenId,\n bidder: address(0),\n bidAmount: 0,\n taker: address(0),\n paidAmount: 0\n });\n\n orderIdTracker.increment();\n\n Order memory order_ = _orders[orderId];\n emit OrderCreated(\n orderId,\n order_.kind,\n order_.openFrom,\n order_.openTo,\n order_.maker,\n order_.currency,\n order_.price,\n order_.tokenContract,\n order_.tokenId\n );\n return orderId;\n }\n\n function cancelOrder(uint256 orderId) external virtual whenExists(orderId) {\n Order memory order_ = _orders[orderId];\n require(\n order_.maker == _msgSender() ||\n hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),\n \"LemonadeMarketplace: must be the maker to cancel\"\n );\n require(\n order_.open,\n \"LemonadeMarketplace: order must be open to cancel\"\n );\n require(\n order_.bidder == address(0),\n \"LemonadeMarketplace: order must have no bid to cancel\"\n );\n\n IERC721(order_.tokenContract).transferFrom(\n address(this),\n order_.maker,\n order_.tokenId\n );\n\n _orders[orderId].open = false;\n emit OrderCancelled(orderId);\n }\n\n function bidOrder(uint256 orderId, uint256 amount, address subject)\n external\n payable\n virtual\n whenExists(orderId)\n {\n Order memory order_ = _orders[orderId];\n require(\n order_.kind == OrderKind.Auction,\n \"LemonadeMarketplace: order must be of kind auction to bid\"\n );\n require(order_.open, \"LemonadeMarketplace: order must be open to bid\");\n require(\n order_.openFrom <= block.timestamp,\n \"LemonadeMarketplace: order must be open to bid - too early\"\n );\n require(\n order_.openTo > block.timestamp,\n \"LemonadeMarketplace: order must be open to bid - too late\"\n );\n require(\n order_.price <= amount,\n \"LemonadeMarketplace: must match price to bid\"\n );\n require(\n order_.currency != address(0) || amount == msg.value,\n \"LemonadeMarketplace: amount must match tx value\"\n );\n\n if (order_.bidder != address(0)) {\n require(\n order_.bidAmount < amount,\n \"LemonadeMarketplace: must surpass bid to bid\"\n );\n\n if (order_.bidAmount > 0) {\n transfer(\n order_.currency,\n address(this),\n order_.bidder,\n order_.bidAmount\n );\n }\n }\n\n address spender = _msgSender();\n\n _orders[orderId].bidder = subject != address(0) ? subject : spender;\n _orders[orderId].bidAmount = amount;\n order_ = _orders[orderId];\n\n if (order_.bidAmount > 0) {\n transfer(\n order_.currency,\n spender,\n address(this),\n order_.bidAmount\n );\n }\n\n emit OrderBid(orderId, order_.bidder, order_.bidAmount);\n }\n\n function fillOrder(uint256 orderId, uint256 amount, address subject)\n external\n payable\n virtual\n whenExists(orderId)\n {\n Order memory order_ = _orders[orderId];\n require(order_.open, \"LemonadeMarketplace: order must be open to fill\");\n\n _orders[orderId].open = false;\n address spender;\n\n if (order_.kind == OrderKind.Direct) {\n require(\n order_.openFrom <= block.timestamp,\n \"LemonadeMarketplace: order must be open to fill - too early\"\n );\n require(\n order_.openTo == 0 || order_.openTo > block.timestamp,\n \"LemonadeMarketplace: order must be open to fill - too late\"\n );\n require(\n order_.price <= amount,\n \"LemonadeMarketplace: must match price to fill direct order\"\n );\n require(\n order_.currency != address(0) || amount == msg.value,\n \"LemonadeMarketplace: amount must match tx value\"\n );\n\n spender = _msgSender();\n _orders[orderId].taker = subject != address(0) ? subject : spender;\n _orders[orderId].paidAmount = amount;\n } else if (order_.kind == OrderKind.Auction) {\n require(\n (order_.bidder != address(0)),\n \"LemonadeMarketplace: order must have bid to fill auction order\"\n );\n require(\n (order_.bidder == _msgSender() &&\n order_.openTo <= block.timestamp) ||\n order_.maker == _msgSender() ||\n hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),\n \"LemonadeMarketplace: must be the maker or final bidder to fill auction order\"\n );\n\n _orders[orderId].taker = order_.bidder;\n _orders[orderId].paidAmount = order_.bidAmount;\n spender = address(this);\n }\n\n order_ = _orders[orderId];\n\n if (order_.paidAmount > 0) {\n uint256 transferAmount = order_.paidAmount;\n\n uint256 feeAmount = (order_.paidAmount * feeValue) / 10000;\n transfer(order_.currency, spender, feeAccount, feeAmount);\n transferAmount -= feeAmount;\n\n (\n bool supportsRaribleV2Royalties,\n LibPart.Part[] memory royalties\n ) = getRaribleV2Royalties(order_.tokenContract, order_.tokenId);\n if (supportsRaribleV2Royalties) {\n uint256 length = royalties.length;\n for (uint256 i; i < length; i++) {\n if (\n order_.maker != royalties[i].account &&\n royalties[i].value > 0\n ) {\n uint256 royaltyAmount = (order_.paidAmount *\n royalties[i].value) / 10000;\n transfer(\n order_.currency,\n spender,\n royalties[i].account,\n royaltyAmount\n );\n transferAmount -= royaltyAmount;\n }\n }\n } else {\n (\n bool supportsRoyaltyInfo,\n address receiver,\n uint256 royaltyAmount\n ) = getRoyaltyInfo(\n order_.tokenContract,\n order_.tokenId,\n order_.paidAmount\n );\n if (\n supportsRoyaltyInfo &&\n order_.maker != receiver &&\n royaltyAmount > 0\n ) {\n transfer(order_.currency, spender, receiver, royaltyAmount);\n transferAmount -= royaltyAmount;\n }\n }\n\n if (transferAmount > 0) {\n transfer(\n order_.currency,\n spender,\n order_.maker,\n transferAmount\n );\n transferAmount -= transferAmount;\n }\n\n require(\n transferAmount == 0,\n \"LemonadeMarketplace: transfer amount must be zero\"\n );\n }\n\n IERC721(order_.tokenContract).transferFrom(\n address(this),\n order_.taker,\n order_.tokenId\n );\n\n emit OrderFilled(orderId, order_.taker, order_.paidAmount);\n }\n\n function getRaribleV2Royalties(address tokenContract, uint256 tokenId)\n public\n view\n virtual\n returns (bool, LibPart.Part[] memory)\n {\n try RoyaltiesV2(tokenContract).getRaribleV2Royalties(tokenId) returns (\n LibPart.Part[] memory royalties\n ) {\n return (true, royalties);\n } catch {\n return (false, new LibPart.Part[](0));\n }\n }\n\n function getRoyaltyInfo(\n address tokenContract,\n uint256 tokenId,\n uint256 paidAmount\n )\n public\n view\n virtual\n returns (\n bool,\n address,\n uint256\n )\n {\n try IERC2981(tokenContract).royaltyInfo(tokenId, paidAmount) returns (\n address receiver,\n uint256 royaltyAmount\n ) {\n return (true, receiver, royaltyAmount);\n } catch {\n return (false, address(0), 0);\n }\n }\n\n function transfer(\n address currency,\n address spender,\n address recipient,\n uint256 amount\n ) private {\n if (currency == address(0)) {\n if (recipient != address(this)) {\n payable(recipient).transfer(amount);\n }\n } else {\n if (spender == address(this)) {\n IERC20(currency).transfer(recipient, amount);\n } else {\n IERC20(currency).transferFrom(spender, recipient, amount);\n }\n }\n }\n\n function openDuration(uint256 openFrom, uint256 openTo)\n private\n view\n returns (uint256)\n {\n uint256 start = openFrom < block.timestamp ? block.timestamp : openFrom;\n uint256 end = openTo == 0 ? type(uint256).max : openTo;\n\n if (start > end) {\n return 0;\n }\n return end - start;\n }\n\n modifier whenExists(uint256 orderId) {\n require(\n _orders[orderId].maker != address(0),\n \"LemonadeMarketplace: order nonexistent\"\n );\n _;\n }\n}\n" + }, + "contracts/LemonadeMarketplaceV2Forwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadeMarketplaceV2.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract LemonadeMarketplaceV2Forwardable is\n LemonadeMarketplaceV2,\n RelayRecipient\n{\n constructor(\n address feeAccount,\n uint96 feeValue,\n address trustedForwarder\n )\n LemonadeMarketplaceV2(feeAccount, feeValue)\n RelayRecipient(trustedForwarder)\n {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n}\n" + }, + "contracts/LemonadePoapV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"./AccessRegistry.sol\";\nimport \"./IERC2981.sol\";\nimport \"./rarible/RoyaltiesV2.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\nbytes32 constant TRUSTED_CLAIMER_ROLE = keccak256(\"TRUSTED_CLAIMER_ROLE\");\nbytes32 constant TRUSTED_OPERATOR_ROLE = keccak256(\"TRUSTED_OPERATOR_ROLE\");\n\ninterface ILemonadePoapV1 is IERC721 {\n function claim() external;\n\n function hasClaimed(\n address[] calldata claimers\n ) external view returns (bool[] memory);\n\n function supply() external view returns (uint256, uint256);\n\n function totalSupply() external view returns (uint256);\n}\n\ncontract LemonadePoapV1 is\n ERC721,\n IERC2981,\n ILemonadePoapV1,\n Ownable,\n RoyaltiesV2\n{\n using Counters for Counters.Counter;\n\n error AllClaimed();\n error AlreadyClaimed();\n error Forbidden();\n error NotFound();\n\n address public immutable creator;\n string public tokenURI_;\n LibPart.Part[] public royalties;\n uint256 public maxSupply;\n address public immutable accessRegistry;\n\n Counters.Counter public tokenIdTracker;\n mapping(address => bool) public claimed;\n\n constructor(\n string memory name,\n string memory symbol,\n address creator_,\n string memory tokenURI__,\n LibPart.Part[] memory royalties_,\n uint256 maxSupply_,\n address accessRegistry_\n ) ERC721(name, symbol) {\n creator = creator_;\n tokenURI_ = tokenURI__;\n\n uint256 length = royalties_.length;\n for (uint256 i; i < length; ) {\n royalties.push(royalties_[i]);\n unchecked {\n ++i;\n }\n }\n\n maxSupply = maxSupply_;\n accessRegistry = accessRegistry_;\n\n _mint(creator_);\n }\n\n function _checkBeforeMint(\n address claimer,\n uint256 tokenId\n ) internal virtual {\n if (maxSupply != 0 && tokenId == maxSupply) {\n revert AllClaimed();\n }\n if (claimed[claimer]) {\n revert AlreadyClaimed();\n }\n }\n\n function _mint(address claimer) internal virtual {\n uint256 tokenId = tokenIdTracker.current();\n\n _checkBeforeMint(claimer, tokenId);\n _mint(claimer, tokenId);\n\n claimed[claimer] = true;\n tokenIdTracker.increment();\n }\n\n function _afterTokenTransfer(\n address,\n address to,\n uint256 tokenId\n ) internal {\n if (tokenId == 0 && owner() != to) {\n _transferOwnership(to);\n }\n }\n\n function claim() public virtual override {\n address claimer = _msgSender();\n\n _mint(claimer);\n }\n\n function claimTo(address claimer) public virtual {\n if (\n !AccessRegistry(accessRegistry).hasRole(\n TRUSTED_CLAIMER_ROLE,\n _msgSender()\n )\n ) {\n revert Forbidden();\n }\n\n _mint(claimer);\n }\n\n function hasClaimed(\n address[] calldata claimers\n ) public view virtual override returns (bool[] memory) {\n uint256 length = claimers.length;\n bool[] memory result = new bool[](length);\n\n for (uint256 i; i < length; i++) {\n result[i] = claimed[claimers[i]];\n }\n return result;\n }\n\n function supply() public view virtual override returns (uint256, uint256) {\n return (tokenIdTracker.current(), maxSupply);\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return (tokenIdTracker.current());\n }\n\n function isApprovedForAll(\n address owner,\n address operator\n ) public view virtual override(ERC721, IERC721) returns (bool isOperator) {\n if (\n AccessRegistry(accessRegistry).hasRole(\n TRUSTED_OPERATOR_ROLE,\n operator\n )\n ) {\n return true;\n }\n\n return super.isApprovedForAll(owner, operator);\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(ILemonadePoapV1).interfaceId ||\n interfaceId == type(RoyaltiesV2).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function tokenURI(\n uint256 tokenId\n ) public view virtual override returns (string memory) {\n if (!_exists(tokenId)) {\n revert NotFound();\n }\n\n return tokenURI_;\n }\n\n function getRaribleV2Royalties(\n uint256\n ) public view override returns (LibPart.Part[] memory) {\n return royalties;\n }\n\n function royaltyInfo(\n uint256,\n uint256 price\n ) public view override returns (address receiver, uint256 royaltyAmount) {\n uint256 length = royalties.length;\n\n if (length == 0) {\n return (address(0), 0);\n }\n\n uint256 totalValue;\n for (uint256 i; i < length; i++) {\n totalValue += royalties[i].value;\n }\n return (royalties[0].account, (price * totalValue) / 10000);\n }\n}\n" + }, + "contracts/LemonadePoapV1ChainlinkRequest.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ChainlinkRequest.sol\";\nimport \"./LemonadePoapV1.sol\";\n\ncontract LemonadePoapV1ChainlinkRequest is LemonadePoapV1 {\n using Counters for Counters.Counter;\n\n event ClaimFailed(string reason);\n event ClaimFailedBytes(bytes reason);\n\n address public chainlinkRequest;\n\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n string memory tokenURI,\n LibPart.Part[] memory royalties,\n uint256 totalSupply,\n address accessRegistry,\n address chainlinkRequest_\n )\n LemonadePoapV1(\n name,\n symbol,\n creator,\n tokenURI,\n royalties,\n totalSupply,\n accessRegistry\n )\n {\n chainlinkRequest = chainlinkRequest_;\n }\n\n function _mint(address claimer) internal virtual override {\n if (chainlinkRequest == address(0)) {\n return super._mint(claimer);\n }\n\n _checkBeforeMint(claimer, tokenIdTracker.current());\n\n bytes memory state = abi.encode(claimer);\n\n ChainlinkRequest(chainlinkRequest).requestBytes(\n this.fulfillClaim.selector,\n state\n );\n }\n\n function fulfillMint(address claimer) external {\n if (_msgSender() != address(this)) {\n revert Forbidden();\n }\n\n super._mint(claimer);\n }\n\n function fulfillClaim(\n bytes memory state,\n bytes memory bytesData\n ) public virtual {\n if (_msgSender() != chainlinkRequest) {\n revert Forbidden();\n }\n\n (bool ok, string memory err) = abi.decode(bytesData, (bool, string));\n\n if (ok) {\n address claimer = abi.decode(state, (address));\n\n try this.fulfillMint(claimer) {\n /* no-op */\n } catch Error(string memory reason) {\n err = reason;\n } catch (bytes memory reason) {\n emit ClaimFailedBytes(reason);\n }\n }\n if (bytes(err).length > 0) {\n emit ClaimFailed(err);\n }\n }\n\n function setChainlinkRequest(address chainlinkRequest_) public onlyOwner {\n chainlinkRequest = chainlinkRequest_;\n }\n}\n" + }, + "contracts/LemonadePoapV1ChainlinkRequestForwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadePoapV1ChainlinkRequest.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract LemonadePoapV1ChainlinkRequestForwardable is\n LemonadePoapV1ChainlinkRequest,\n RelayRecipient\n{\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n string memory tokenURI,\n LibPart.Part[] memory royalties,\n uint256 totalSupply,\n address accessRegistry,\n address chainlinkRequest,\n address trustedForwarder\n )\n LemonadePoapV1ChainlinkRequest(\n name,\n symbol,\n creator,\n tokenURI,\n royalties,\n totalSupply,\n accessRegistry,\n chainlinkRequest\n )\n RelayRecipient(trustedForwarder)\n {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n\n function setTrustedForwarder(address trustedForwarder_) public onlyOwner {\n trustedForwarder = trustedForwarder_;\n }\n}\n" + }, + "contracts/LemonadePoapV1Forwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadePoapV1.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract LemonadePoapV1Forwardable is LemonadePoapV1, RelayRecipient {\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n string memory tokenURI,\n LibPart.Part[] memory royalties,\n uint256 totalSupply,\n address accessRegistry,\n address trustedForwarder\n )\n LemonadePoapV1(\n name,\n symbol,\n creator,\n tokenURI,\n royalties,\n totalSupply,\n accessRegistry\n )\n RelayRecipient(trustedForwarder)\n {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n\n function setTrustedForwarder(address trustedForwarder_) public onlyOwner {\n trustedForwarder = trustedForwarder_;\n }\n}\n" + }, + "contracts/LemonadePoapV1Unique.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadePoapV1.sol\";\nimport \"./unique/ICollection.sol\";\nimport \"./unique/ICollectionHelpers.sol\";\nimport \"./unique/LibPartAdapter.sol\";\n\ncontract LemonadePoapV1Unique is LemonadePoapV1 {\n using Counters for Counters.Counter;\n\n address public collection;\n\n bytes public royaltiesBytes;\n\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n string memory tokenURI,\n LibPart.Part[] memory royalties,\n uint256 totalSupply,\n address accessRegistry,\n address collectionHelpers\n )\n payable\n LemonadePoapV1(\n name,\n symbol,\n creator,\n tokenURI,\n royalties,\n totalSupply,\n accessRegistry\n )\n {\n ICollectionHelpers collectionHelpers_ = ICollectionHelpers(\n collectionHelpers\n );\n\n collection = collectionHelpers_.createNFTCollection{value: msg.value}(\n name,\n name,\n symbol\n );\n collectionHelpers_.makeCollectionERC721MetadataCompatible(\n collection,\n tokenURI\n );\n\n ICollection collection_ = ICollection(collection);\n\n collection_.addCollectionAdminCross(\n CrossAddress({eth: address(this), sub: 0})\n );\n collection_.changeCollectionOwnerCross(\n CrossAddress({eth: msg.sender, sub: 0})\n );\n\n if (royalties.length > 0) {\n PropertyPermission[] memory permissions = new PropertyPermission[](\n 3\n );\n\n permissions[0] = PropertyPermission({\n code: TokenPermissionField.Mutable,\n value: false\n });\n permissions[1] = PropertyPermission({\n code: TokenPermissionField.CollectionAdmin,\n value: true\n });\n permissions[2] = PropertyPermission({\n code: TokenPermissionField.TokenOwner,\n value: false\n });\n\n TokenPropertyPermission[]\n memory permissionsArray = new TokenPropertyPermission[](1);\n\n permissionsArray[0] = TokenPropertyPermission({\n key: ROYALTIES_PROPERTY,\n permissions: permissions\n });\n\n collection_.setTokenPropertyPermissions(permissionsArray);\n\n royaltiesBytes = LibPartAdapter.encode(royalties);\n }\n }\n\n function _mint(\n address claimer,\n uint256 tokenId_\n ) internal virtual override {\n if (tokenId_ == 0) {\n return super._mint(claimer, tokenId_);\n }\n\n ICollection collection_ = ICollection(collection);\n\n uint256 tokenId = collection_.mint(claimer);\n\n if (royaltiesBytes.length > 0) {\n Property[] memory properties = new Property[](1);\n\n properties[0] = Property({\n key: ROYALTIES_PROPERTY,\n value: royaltiesBytes\n });\n\n collection_.setProperties(tokenId, properties);\n }\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n if (tokenId == 0) {\n return super.transferFrom(from, to, tokenId);\n }\n\n ICollection collection_ = ICollection(collection);\n\n address owner = collection_.ownerOf(tokenId);\n\n if (msg.sender != owner && !isApprovedForAll(owner, msg.sender)) {\n revert Forbidden();\n }\n\n collection_.transferFrom(from, to, tokenId);\n }\n}\n" + }, + "contracts/LemonadeUniqueCollectionV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ERC721LemonadeV1.sol\";\nimport \"./unique/ICollection.sol\";\nimport \"./unique/ICollectionHelpers.sol\";\nimport \"./unique/LibPartAdapter.sol\";\n\ncontract LemonadeUniqueCollectionV1 is IMintable {\n address public collection;\n\n constructor(\n address collectionHelpers,\n string memory name,\n string memory description,\n string memory tokenPrefix\n ) payable {\n ICollectionHelpers collectionHelpers_ = ICollectionHelpers(\n collectionHelpers\n );\n\n collection = collectionHelpers_.createNFTCollection{value: msg.value}(\n name,\n description,\n tokenPrefix\n );\n collectionHelpers_.makeCollectionERC721MetadataCompatible(\n collection,\n \"\"\n );\n\n ICollection collection_ = ICollection(collection);\n\n collection_.addCollectionAdminCross(\n CrossAddress({eth: address(this), sub: 0})\n );\n collection_.changeCollectionOwnerCross(\n CrossAddress({eth: msg.sender, sub: 0})\n );\n\n PropertyPermission[] memory permissions = new PropertyPermission[](3);\n\n permissions[0] = PropertyPermission({\n code: TokenPermissionField.Mutable,\n value: false\n });\n permissions[1] = PropertyPermission({\n code: TokenPermissionField.CollectionAdmin,\n value: true\n });\n permissions[2] = PropertyPermission({\n code: TokenPermissionField.TokenOwner,\n value: false\n });\n\n TokenPropertyPermission[]\n memory permissionsArray = new TokenPropertyPermission[](1);\n\n permissionsArray[0] = TokenPropertyPermission({\n key: ROYALTIES_PROPERTY,\n permissions: permissions\n });\n\n collection_.setTokenPropertyPermissions(permissionsArray);\n }\n\n function mintToCaller(\n string memory tokenURI\n ) public override returns (uint256) {\n return ICollection(collection).mintWithTokenURI(msg.sender, tokenURI);\n }\n\n function mintToCallerWithRoyalty(\n string memory tokenURI,\n LibPart.Part[] memory royalties\n ) public override returns (uint256) {\n uint256 tokenId = mintToCaller(tokenURI);\n\n Property[] memory properties = new Property[](1);\n\n properties[0] = Property({\n key: ROYALTIES_PROPERTY,\n value: LibPartAdapter.encode(royalties)\n });\n\n ICollection(collection).setProperties(tokenId, properties);\n\n return tokenId;\n }\n}\n" + }, + "contracts/passport/BaseV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./GatewayV1Axelar.sol\";\nimport \"./GatewayV1Call.sol\";\nimport \"./IBaseV1.sol\";\nimport \"./Shared.sol\";\n\ncontract BaseV1 is GatewayV1Axelar, GatewayV1Call, IBaseV1 {\n bytes32 public callNetwork;\n uint256 public maxSupply;\n\n uint256 private _tokenIdCounter;\n uint256 private _totalReservations;\n\n mapping(address => uint256) private _referrals;\n mapping(address => uint256) private _reservations;\n mapping(address => uint256) private _tokens;\n\n mapping(uint256 => address) private _owners;\n mapping(uint256 => bytes32) private _networks;\n\n function initialize(\n IAxelarGateway axelarGateway,\n IAxelarGasService axelarGasService,\n AxelarNetwork[] calldata axelarNetworks,\n address callAddress,\n bytes32 callNetwork_,\n uint256 maxSupply_\n ) public initializer {\n __GatewayV1Axelar_init(axelarGateway, axelarGasService, axelarNetworks);\n __GatewayV1Call_init(callAddress);\n\n callNetwork = callNetwork_;\n maxSupply = maxSupply_;\n\n _tokenIdCounter = 1;\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function assign(Assignment[] calldata assignments) public override {\n address sender = _msgSender();\n\n _assign(sender, assignments);\n\n emit Assign(sender, assignments);\n }\n\n function claim(bytes32 network) public payable override {\n address sender = _msgSender();\n\n uint256 tokenId = _claim(network, sender, msg.value, sender);\n\n emit Claim(sender, network, tokenId);\n }\n\n function grant(\n Assignment[] calldata assignments\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n (bool success, ) = _tryReserve(assignments);\n\n if (!success) {\n revert Forbidden();\n }\n }\n\n function balanceOf(\n address owner\n ) public view override returns (uint256 balance) {\n if (_tokens[owner] != 0) {\n balance = 1;\n }\n }\n\n function networkOf(uint256 tokenId) public view override returns (bytes32) {\n if (_owners[tokenId] == address(0)) {\n revert NotFound();\n }\n\n return _networks[tokenId];\n }\n\n function ownerOf(\n uint256 tokenId\n ) public view override returns (address owner) {\n owner = _owners[tokenId];\n\n if (owner == address(0)) {\n revert NotFound();\n }\n }\n\n function referrals(\n address referrer\n ) public view override returns (uint256) {\n return _referrals[referrer];\n }\n\n function reservations(\n address owner\n ) public view override returns (uint256) {\n return _reservations[owner];\n }\n\n function token(address owner) public view override returns (uint256) {\n return tokenOfOwnerByIndex(owner, 0);\n }\n\n function tokenByIndex(\n uint256 index\n ) public view override returns (uint256) {\n if (index >= totalSupply()) {\n revert NotFound();\n }\n\n return index + 1;\n }\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) public view override returns (uint256 tokenId) {\n tokenId = _tokens[owner];\n\n if (tokenId == 0 || index > 0) {\n revert NotFound();\n }\n }\n\n function totalReservations() public view override returns (uint256) {\n return _totalReservations;\n }\n\n function totalSupply() public view override returns (uint256) {\n unchecked {\n return _tokenIdCounter - 1;\n }\n }\n\n function _assign(address sender, Assignment[] memory assignments) internal {\n uint256 count = _increaseReservations(assignments);\n\n if (!_tryReservationsDecrease(sender, count)) {\n revert Forbidden();\n }\n }\n\n function _callContract(\n bytes32 network,\n bytes32 method,\n bytes memory params,\n uint256 gasFee,\n address refundAddress\n ) internal override {\n if (network == callNetwork) {\n return GatewayV1Call._callContract(method, params);\n }\n\n GatewayV1Axelar._callContract(\n network,\n method,\n params,\n gasFee,\n refundAddress\n );\n }\n\n function _claim(\n bytes32 network,\n address sender,\n uint256 gasFee,\n address refundAddress\n ) internal returns (uint256 tokenId) {\n tokenId = _tokenIdCounter;\n\n if (\n !_tryReservationsDecrease(sender, 1) ||\n !_tryMint(network, sender, tokenId)\n ) {\n revert Forbidden();\n }\n\n unchecked {\n _totalReservations--;\n _tokenIdCounter = tokenId + 1;\n }\n\n _callContract(\n network,\n CLAIM_METHOD,\n abi.encode(sender, tokenId),\n gasFee,\n refundAddress\n );\n }\n\n function _execute(bytes32 method, bytes memory params) internal override {\n _execute(callNetwork, method, params);\n }\n\n function _execute(\n bytes32 network,\n bytes32 method,\n bytes memory params\n ) internal override {\n if (method == ASSIGN_METHOD) {\n _executeAssign(network, params);\n } else if (method == CLAIM_METHOD) {\n _executeClaim(network, params);\n } else if (method == PURCHASE_METHOD) {\n _executePurchase(network, params);\n } else if (method == RESERVE_METHOD) {\n _executeReserve(network, params);\n } else {\n revert NotImplemented();\n }\n }\n\n function _executeAssign(bytes32 network, bytes memory params) internal {\n (address sender, Assignment[] memory assignments) = abi.decode(\n params,\n (address, Assignment[])\n );\n\n _assign(sender, assignments);\n\n emit ExecuteAssign(network, sender, assignments);\n }\n\n function _executeClaim(bytes32 network, bytes memory params) internal {\n address sender = abi.decode(params, (address));\n\n uint256 tokenId = _claim(network, sender, 0, address(0));\n\n emit ExecuteClaim(network, sender, tokenId);\n }\n\n function _executePurchase(bytes32 network, bytes memory params) internal {\n (uint256 purchaseId, address sender, address referrer) = abi.decode(\n params,\n (uint256, address, address)\n );\n\n bool success;\n uint256 tokenId = _tokenIdCounter;\n\n if (\n _totalReservations + tokenId <= maxSupply &&\n _tryMint(network, sender, tokenId)\n ) {\n success = true;\n\n unchecked {\n _tokenIdCounter = tokenId + 1;\n }\n }\n\n if (_tokens[referrer] == 0) {\n delete referrer;\n } else if (success) {\n unchecked {\n ++_referrals[referrer];\n }\n }\n\n emit ExecutePurchase(\n network,\n purchaseId,\n sender,\n referrer,\n tokenId,\n success\n );\n\n _callContract(\n network,\n PURCHASE_METHOD,\n abi.encode(purchaseId, referrer, tokenId, success),\n 0,\n address(0)\n );\n }\n\n function _executeReserve(bytes32 network, bytes memory params) internal {\n (\n uint256 paymentId,\n address sender,\n Assignment[] memory assignments\n ) = abi.decode(params, (uint256, address, Assignment[]));\n\n (bool success, uint256 count) = _tryReserve(assignments);\n\n if (success) {\n _referrals[sender] += count;\n }\n\n bool referred = _tokens[sender] != 0;\n\n emit ExecuteReserve(\n network,\n paymentId,\n sender,\n assignments,\n referred,\n success\n );\n\n _callContract(\n network,\n RESERVE_METHOD,\n abi.encode(paymentId, referred, success),\n 0,\n address(0)\n );\n }\n\n function _increaseReservations(\n Assignment[] memory assignments\n ) internal returns (uint256 count) {\n uint256 length = assignments.length;\n\n for (uint256 i; i < length; ) {\n Assignment memory assignment = assignments[i];\n\n _reservations[assignment.to] += assignment.count;\n\n count += assignment.count;\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _tryMint(\n bytes32 network,\n address to,\n uint256 tokenId\n ) internal returns (bool success) {\n if (_tokens[to] != 0) {\n return false;\n }\n\n _tokens[to] = tokenId;\n _owners[tokenId] = to;\n _networks[tokenId] = network;\n\n emit Mint(network, to, tokenId);\n\n return true;\n }\n\n function _tryReservationsDecrease(\n address owner,\n uint256 count\n ) internal returns (bool success) {\n uint256 reservations_ = _reservations[owner];\n\n if (reservations_ < count) {\n return false;\n }\n\n unchecked {\n _reservations[owner] = reservations_ - count;\n }\n\n return true;\n }\n\n function _tryReserve(\n Assignment[] memory assignments\n ) internal returns (bool success, uint256) {\n uint256 totalReservations_ = _totalReservations +\n countAssignments(assignments);\n\n if (totalReservations_ + totalSupply() > maxSupply) {\n return (false, 0);\n }\n\n _totalReservations = totalReservations_;\n\n return (true, _increaseReservations(assignments));\n }\n}\n" + }, + "contracts/passport/CrowdfundV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ICrowdfundV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"./IPassportV1Reserver.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol\";\n\ncontract CrowdfundV1 is\n AccessControlUpgradeable,\n PullPaymentUpgradeable,\n ICrowdfundV1,\n IPassportV1Reserver\n{\n IPassportV1 public passport;\n\n uint256 private _campaignIdCounter;\n struct Campaign {\n State state;\n address creator;\n string title;\n string description;\n address[] contributors;\n uint256 total;\n uint256 unused;\n }\n mapping(uint256 => Campaign) private _campaigns;\n mapping(uint256 => Assignment[]) private _assignments;\n mapping(uint256 => mapping(address => uint256)) private _contributions;\n\n function initialize(IPassportV1 passport_) public initializer {\n __PullPayment_init();\n\n passport = passport_;\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n receive() external payable {}\n\n function create(\n string memory title_,\n string memory description_,\n Assignment[] memory assignments_\n ) public override returns (uint256 campaignId) {\n unchecked {\n campaignId = _campaignIdCounter++;\n }\n\n address creator_ = _msgSender();\n\n _campaigns[campaignId] = Campaign({\n state: State.PENDING,\n creator: creator_,\n title: title_,\n description: description_,\n contributors: new address[](0),\n total: 0,\n unused: 0\n });\n\n uint256 length = assignments_.length;\n\n for (uint256 i; i < length; ) {\n _assignments[campaignId].push(assignments_[i]);\n\n unchecked {\n ++i;\n }\n }\n\n emit Create(creator_, title_, description_, assignments_, campaignId);\n }\n\n function execute(\n uint256 campaignId,\n uint160 roundIds\n ) public payable override whenExists(campaignId) {\n Assignment[] memory assignments_ = _assignments[campaignId];\n\n uint256 price = countAssignments(assignments_) *\n passport.priceAt(roundIds);\n\n Campaign memory campaign = _campaigns[campaignId];\n\n if (campaign.state != State.PENDING || campaign.total < price) {\n revert Forbidden();\n }\n\n _setState(campaignId, State.EXECUTED);\n\n unchecked {\n _campaigns[campaignId].unused = campaign.total - price;\n }\n\n passport.reserve{value: price + msg.value}(\n roundIds,\n assignments_,\n abi.encode(campaignId)\n );\n }\n\n function fund(\n uint256 campaignId\n ) public payable override whenExists(campaignId) {\n Campaign memory campaign = _campaigns[campaignId];\n\n if (campaign.state != State.PENDING || msg.value == 0) {\n revert Forbidden();\n }\n\n address contributor = _msgSender();\n uint256 contribution = _contributions[campaignId][contributor];\n\n if (contribution == 0) {\n _campaigns[campaignId].contributors.push(contributor);\n }\n\n _campaigns[campaignId].total = campaign.total + msg.value;\n _contributions[campaignId][contributor] = contribution + msg.value;\n\n emit Fund(campaignId, contributor, msg.value);\n }\n\n function onPassportV1Reserved(\n bool success,\n bytes calldata data\n ) public override {\n uint256 campaignId = abi.decode(data, (uint256));\n\n Campaign memory campaign = _campaigns[campaignId];\n\n if (\n campaign.state != State.EXECUTED ||\n _msgSender() != address(passport)\n ) {\n revert Forbidden();\n }\n\n if (success) {\n _setState(campaignId, State.CONFIRMED);\n\n if (campaign.unused > 0) {\n _asyncTransfer(campaign.creator, campaign.unused);\n }\n } else {\n _refund(campaignId);\n }\n }\n\n function refund(uint256 campaignId) public override whenExists(campaignId) {\n Campaign memory campaign = _campaigns[campaignId];\n\n if (\n campaign.state != State.PENDING || _msgSender() != campaign.creator\n ) {\n revert Forbidden();\n }\n\n _refund(campaignId);\n }\n\n function withdraw(\n address recipient,\n uint256 amount\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n _asyncTransfer(recipient, amount);\n }\n\n function assignments(\n uint256 campaignId\n )\n public\n view\n override\n whenExists(campaignId)\n returns (Assignment[] memory)\n {\n return _assignments[campaignId];\n }\n\n function contributors(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (address[] memory) {\n return _campaigns[campaignId].contributors;\n }\n\n function creator(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (address) {\n return _campaigns[campaignId].creator;\n }\n\n function description(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (string memory) {\n return _campaigns[campaignId].description;\n }\n\n function goal(\n uint256 campaignId\n )\n public\n view\n override\n whenExists(campaignId)\n returns (uint160, uint256 amount)\n {\n (uint160 roundIds, uint256 price) = passport.price();\n\n return (roundIds, countAssignments(_assignments[campaignId]) * price);\n }\n\n function state(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (State) {\n return _campaigns[campaignId].state;\n }\n\n function title(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (string memory) {\n return _campaigns[campaignId].title;\n }\n\n function total(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (uint256) {\n return _campaigns[campaignId].total;\n }\n\n function _refund(uint256 campaignId) internal {\n _setState(campaignId, State.REFUNDED);\n\n address[] memory contributors_ = _campaigns[campaignId].contributors;\n uint256 length = contributors_.length;\n\n for (uint256 i; i < length; ) {\n address contributor = contributors_[i];\n\n _asyncTransfer(\n contributor,\n _contributions[campaignId][contributor]\n );\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _setState(uint256 campaignId, State state_) internal {\n _campaigns[campaignId].state = state_;\n\n emit StateChanged(campaignId, state_);\n }\n\n modifier whenExists(uint256 campaignId) {\n if (_campaigns[campaignId].creator == address(0)) {\n revert NotFound();\n }\n\n _;\n }\n}\n" + }, + "contracts/passport/DateTime.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary/blob/master/contracts/BokkyPooBahsDateTimeLibrary.sol\n */\nlibrary DateTime {\n uint constant SECONDS_PER_DAY = 24 * 60 * 60;\n int constant OFFSET19700101 = 2440588;\n\n function _daysToDate(\n uint _days\n ) internal pure returns (uint year, uint month, uint day) {\n int __days = int(_days);\n\n int L = __days + 68569 + OFFSET19700101;\n int N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int _month = (80 * L) / 2447;\n int _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint(_year);\n month = uint(_month);\n day = uint(_day);\n }\n\n function timestampToDate(\n uint timestamp\n ) internal pure returns (uint year, uint month, uint day) {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n}\n" + }, + "contracts/passport/DrawerV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./DateTime.sol\";\nimport \"./IDrawerV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"./Shared.sol\";\n\nabstract contract DrawerV1 is IDrawerV1 {\n function _createdAt(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n uint256 timestamp = passport.createdAt(tokenId);\n\n return _timestamp(timestamp);\n }\n\n function _updatedAt(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n uint256 timestamp = passport.updatedAt(tokenId);\n\n if (timestamp == 0) {\n return _createdAt(passport, tokenId);\n }\n\n return _timestamp(timestamp);\n }\n\n function _username(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n return string(passport.property(tokenId, keccak256(\"username\")));\n }\n\n function _date(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure virtual returns (string memory);\n\n function _padStart(\n string memory str,\n uint256 length,\n bytes1 char\n ) internal pure returns (string memory) {\n bytes memory strb = bytes(str);\n uint256 strl = strb.length;\n\n if (strl >= length) {\n return str;\n }\n\n uint256 padl;\n unchecked {\n padl = length - strl;\n }\n bytes memory padb = new bytes(padl);\n\n for (; padl > 0; ) {\n unchecked {\n padb[--padl] = char;\n }\n }\n\n return string(bytes.concat(padb, strb));\n }\n\n function _timestamp(\n uint256 timestamp\n ) internal pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day) = DateTime.timestampToDate(\n timestamp\n );\n\n return _date(year, month, day);\n }\n\n modifier whenMinted(IPassportV1 passport, uint256 tokenId) {\n try passport.ownerOf(tokenId) {\n _;\n } catch {\n revert NotFound();\n }\n }\n\n uint256[50] private __gap;\n}\n" + }, + "contracts/passport/DrawerV1Test.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./DrawerV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/Base64Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\n\ncontract DrawerV1Test is DrawerV1 {\n using StringsUpgradeable for uint256;\n\n function tokenURI(\n IPassportV1 passport,\n uint256 tokenId\n )\n public\n view\n override\n whenMinted(passport, tokenId)\n returns (string memory)\n {\n return\n string(\n abi.encodePacked(\n \"data:application/json;base64,\",\n Base64Upgradeable.encode(\n bytes(\n abi.encodePacked(\n '{\"name\":\"Citizen #',\n tokenId.toString(),\n '\",\"image\":\"',\n _image(passport, tokenId),\n '\"}'\n )\n )\n )\n )\n );\n }\n\n function _image(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n return\n string(\n abi.encodePacked(\n \"data:image/svg+xml;base64,\",\n Base64Upgradeable.encode(\n bytes(\n abi.encodePacked(\n 'CITIZEN',\n _padStart(tokenId.toString(), 8, \"0\"),\n '',\n _createdAt(passport, tokenId),\n 'VINYL NATIONDATE OF MINT:',\n _updatedAt(passport, tokenId),\n 'LAST UPDATED:/// PASSPORT NO://///',\n _username(passport, tokenId),\n ''\n )\n )\n )\n )\n );\n }\n\n function _date(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure override returns (string memory) {\n return\n string(\n abi.encodePacked(\n day.toString(),\n \"/\",\n month.toString(),\n \"/\",\n year.toString()\n )\n );\n }\n}\n" + }, + "contracts/passport/DrawerV1VinylNation.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./DrawerV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/Base64Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\n\ncontract DrawerV1VinylNation is DrawerV1 {\n using StringsUpgradeable for uint256;\n\n function tokenURI(\n IPassportV1 passport,\n uint256 tokenId\n )\n public\n view\n override\n whenMinted(passport, tokenId)\n returns (string memory)\n {\n return\n string(\n abi.encodePacked(\n \"data:application/json;base64,\",\n Base64Upgradeable.encode(\n bytes(\n abi.encodePacked(\n '{\"name\":\"Citizen #',\n tokenId.toString(),\n '\",\"image\":\"',\n _image(passport, tokenId),\n '\"}'\n )\n )\n )\n )\n );\n }\n\n function _image(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n return\n string(\n abi.encodePacked(\n \"data:image/svg+xml;base64,\",\n Base64Upgradeable.encode(\n bytes(\n abi.encodePacked(\n 'CITIZEN',\n _padStart(tokenId.toString(), 8, \"0\"),\n '',\n _createdAt(passport, tokenId),\n 'VINYL NATIONDATE OF MINT:',\n _updatedAt(passport, tokenId),\n 'LAST UPDATED:/// PASSPORT NO://///',\n _username(passport, tokenId),\n ''\n )\n )\n )\n )\n );\n }\n\n function _date(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure override returns (string memory) {\n return\n string(\n abi.encodePacked(\n day.toString(),\n \"/\",\n month.toString(),\n \"/\",\n year.toString()\n )\n );\n }\n}\n" + }, + "contracts/passport/GatewayV1Axelar.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Shared.sol\";\nimport \"@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarExecutable.sol\";\nimport \"@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol\";\nimport \"@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\n\nabstract contract GatewayV1Axelar is\n AccessControlUpgradeable,\n IAxelarExecutable\n{\n IAxelarGateway public override gateway;\n IAxelarGasService public gasService;\n\n struct AxelarDestination {\n string chain;\n string contractAddress;\n }\n mapping(bytes32 => AxelarDestination) public axelarDestinations;\n mapping(string => mapping(string => bytes32)) public axelarSources;\n\n struct AxelarNetwork {\n bytes32 network;\n AxelarDestination axelarDestination;\n }\n\n function __GatewayV1Axelar_init(\n IAxelarGateway axelarGateway,\n IAxelarGasService axelarGasService,\n AxelarNetwork[] calldata axelarNetworks\n ) internal onlyInitializing {\n __GatewayV1Axelar_init_unchained(\n axelarGateway,\n axelarGasService,\n axelarNetworks\n );\n }\n\n function __GatewayV1Axelar_init_unchained(\n IAxelarGateway axelarGateway,\n IAxelarGasService axelarGasService,\n AxelarNetwork[] calldata axelarNetworks\n ) internal onlyInitializing {\n gateway = axelarGateway;\n gasService = axelarGasService;\n\n _addAxelarNetworks(axelarNetworks);\n }\n\n function execute(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes calldata payload\n ) external override {\n bytes32 network = axelarSources[sourceChain][sourceAddress];\n\n if (network == 0) {\n revert Forbidden();\n }\n\n bytes32 payloadHash = keccak256(payload);\n\n if (\n !gateway.validateContractCall(\n commandId,\n sourceChain,\n sourceAddress,\n payloadHash\n )\n ) {\n revert NotApprovedByGateway();\n }\n\n (bytes32 method, bytes memory params) = abi.decode(\n payload,\n (bytes32, bytes)\n );\n\n _execute(network, method, params);\n }\n\n function executeWithToken(\n bytes32,\n string calldata,\n string calldata,\n bytes calldata,\n string calldata,\n uint256\n ) external pure override {\n revert NotImplemented();\n }\n\n function addAxelarNetworks(\n AxelarNetwork[] calldata axelarNetworks\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n _addAxelarNetworks(axelarNetworks);\n }\n\n function removeAxelarNetworks(\n bytes32[] calldata axelarNetworks\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n uint256 length = axelarNetworks.length;\n\n for (uint256 i; i < length; ) {\n bytes32 axelarNetwork = axelarNetworks[i];\n\n AxelarDestination memory axelarDestination = axelarDestinations[\n axelarNetwork\n ];\n\n delete axelarSources[axelarDestination.chain][\n axelarDestination.contractAddress\n ];\n delete axelarDestinations[axelarNetwork];\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _addAxelarNetworks(\n AxelarNetwork[] calldata axelarNetworks\n ) internal {\n uint256 length = axelarNetworks.length;\n\n for (uint256 i; i < length; ) {\n AxelarNetwork calldata axelarNetwork = axelarNetworks[i];\n\n axelarDestinations[axelarNetwork.network] = axelarNetwork\n .axelarDestination;\n axelarSources[axelarNetwork.axelarDestination.chain][\n axelarNetwork.axelarDestination.contractAddress\n ] = axelarNetwork.network;\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _callContract(\n bytes32 network,\n bytes32 method,\n bytes memory params,\n uint256 gasFee,\n address refundAddress\n ) internal virtual {\n AxelarDestination memory axelarDestination = axelarDestinations[\n network\n ];\n\n if (bytes(axelarDestination.chain).length == 0) {\n revert Forbidden();\n }\n\n bytes memory payload = abi.encode(method, params);\n\n if (gasFee > 0) {\n gasService.payNativeGasForContractCall{value: gasFee}(\n address(this),\n axelarDestination.chain,\n axelarDestination.contractAddress,\n payload,\n refundAddress\n );\n }\n\n gateway.callContract(\n axelarDestination.chain,\n axelarDestination.contractAddress,\n payload\n );\n }\n\n function _execute(\n bytes32 network,\n bytes32 method,\n bytes memory params\n ) internal virtual;\n\n uint256[46] private __gap;\n}\n" + }, + "contracts/passport/GatewayV1Call.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Shared.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\nabstract contract GatewayV1Call is AccessControlUpgradeable {\n using AddressUpgradeable for address;\n\n address public callAddress;\n\n function __GatewayV1Call_init(\n address callAddress_\n ) internal onlyInitializing {\n __GatewayV1Call_init_unchained(callAddress_);\n }\n\n function __GatewayV1Call_init_unchained(\n address callAddress_\n ) internal onlyInitializing {\n callAddress = callAddress_;\n }\n\n function execute(bytes32 method, bytes memory params) external {\n if (_msgSender() != callAddress) {\n revert Forbidden();\n }\n\n _execute(method, params);\n }\n\n function setCallAddress(\n address callAddress_\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n callAddress = callAddress_;\n }\n\n function _callContract(bytes32 method, bytes memory params) internal {\n callAddress.functionCall(\n abi.encodeWithSelector(this.execute.selector, method, params)\n );\n }\n\n function _execute(bytes32 method, bytes memory params) internal virtual;\n\n uint256[49] private __gap;\n}\n" + }, + "contracts/passport/IBaseV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Shared.sol\";\n\ninterface IBaseV1 {\n event Assign(address indexed sender, Assignment[] assignments);\n event Claim(\n address indexed sender,\n bytes32 indexed network,\n uint256 tokenId\n );\n event ExecuteAssign(\n bytes32 indexed network,\n address indexed sender,\n Assignment[] assignments\n );\n event ExecuteClaim(\n bytes32 indexed network,\n address indexed sender,\n uint256 tokenId\n );\n event ExecutePurchase(\n bytes32 indexed network,\n uint256 indexed paymentId,\n address indexed sender,\n address referrer,\n uint256 tokenId,\n bool success\n );\n event ExecuteReserve(\n bytes32 indexed network,\n uint256 indexed paymentId,\n address indexed sender,\n Assignment[] assignments,\n bool referred,\n bool success\n );\n event Mint(\n bytes32 indexed network,\n address indexed to,\n uint256 indexed tokenId\n );\n\n function assign(Assignment[] calldata assignments) external;\n\n function claim(bytes32 network) external payable;\n\n function balanceOf(address owner) external view returns (uint256 balance);\n\n function networkOf(uint256 tokenId) external view returns (bytes32 network);\n\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n function referrals(address referrer) external view returns (uint256);\n\n function reservations(address owner) external view returns (uint256);\n\n function token(address owner) external view returns (uint256);\n\n function tokenByIndex(uint256 index) external view returns (uint256);\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) external view returns (uint256);\n\n function totalReservations() external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n}\n" + }, + "contracts/passport/ICrowdfundV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IPassportV1.sol\";\n\ninterface ICrowdfundV1 {\n event Create(\n address indexed creator,\n string title,\n string description,\n Assignment[] assignments,\n uint256 indexed campaignId\n );\n event Fund(\n uint256 indexed campaignId,\n address indexed contributor,\n uint256 amount\n );\n event StateChanged(uint256 indexed campaignId, State state);\n\n enum State {\n PENDING,\n EXECUTED,\n CONFIRMED,\n REFUNDED\n }\n\n function create(\n string memory title_,\n string memory description_,\n Assignment[] calldata assignments_\n ) external returns (uint256 campaignId);\n\n function execute(uint256 campaignId, uint160 roundIds) external payable;\n\n function fund(uint256 campaignId) external payable;\n\n function refund(uint256 campaignId) external;\n\n function assignments(\n uint256 campaignId\n ) external view returns (Assignment[] memory);\n\n function contributors(\n uint256 campaignId\n ) external view returns (address[] memory);\n\n function creator(uint256 campaignId) external view returns (address);\n\n function description(\n uint256 campaignId\n ) external view returns (string memory);\n\n function goal(\n uint256 campaignId\n ) external view returns (uint160 roundIds, uint256 amount);\n\n function state(uint256 campaignId) external view returns (State);\n\n function title(uint256 campaignId) external view returns (string memory);\n\n function total(uint256 campaignId) external view returns (uint256);\n}\n" + }, + "contracts/passport/IDrawerV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IPassportV1.sol\";\n\ninterface IDrawerV1 {\n function tokenURI(\n IPassportV1 passport,\n uint256 tokenId\n ) external view returns (string memory);\n}\n" + }, + "contracts/passport/IPassportV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Shared.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol\";\n\ninterface IPassportV1 is\n IERC721EnumerableUpgradeable,\n IERC721MetadataUpgradeable\n{\n event Assign(address indexed sender, Assignment[] assignments);\n event Claim(address indexed sender);\n event ExecuteClaim(address indexed sender, uint256 tokenId);\n event ExecutePurchase(\n uint256 indexed paymentId,\n address payable indexed sender,\n uint256 value,\n address referrer,\n uint256 tokenId,\n bool success\n );\n event ExecuteReserve(\n uint256 indexed paymentId,\n address payable indexed sender,\n uint256 value,\n bool referred,\n bool success\n );\n event Payout(address payable indexed recipient, uint256 amount);\n event Purchase(\n uint256 indexed paymentId,\n address payable indexed sender,\n uint256 value,\n address referrer\n );\n event Reserve(\n uint256 indexed paymentId,\n address payable indexed sender,\n uint256 value,\n Assignment[] assignments\n );\n event SetProperty(uint256 indexed tokenId, bytes32 key, bytes value);\n event SetPropertyBatch(uint256 indexed tokenId, Property[] properties);\n\n struct Property {\n bytes32 key;\n bytes value;\n }\n\n function assign(Assignment[] calldata assignments) external payable;\n\n function claim() external payable;\n\n function purchase(\n uint160 roundIds,\n address referrer,\n bytes calldata data\n ) external payable;\n\n function reserve(\n uint160 roundIds,\n Assignment[] calldata assignments,\n bytes calldata data\n ) external payable;\n\n function setProperty(bytes32 key, bytes calldata value) external;\n\n function setPropertyBatch(Property[] calldata properties) external;\n\n function createdAt(uint256 tokenId) external view returns (uint256);\n\n function price() external view returns (uint160 roundIds, uint256);\n\n function priceAt(uint160 roundIds) external view returns (uint256);\n\n function property(\n uint256 tokenId,\n bytes32 key\n ) external view returns (bytes memory value);\n\n function propertyBatch(\n uint256 tokenId,\n bytes32[] calldata keys\n ) external view returns (bytes[] memory values);\n\n function token(address owner) external view returns (uint256);\n\n function updatedAt(uint256 tokenId) external view returns (uint256);\n}\n" + }, + "contracts/passport/IPassportV1Purchaser.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IPassportV1Purchaser {\n function onPassportV1Purchased(bool success, bytes calldata data) external;\n}\n" + }, + "contracts/passport/IPassportV1Reserver.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IPassportV1Reserver {\n function onPassportV1Reserved(bool success, bytes calldata data) external;\n}\n" + }, + "contracts/passport/PassportV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IDrawerV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"./IPassportV1Purchaser.sol\";\nimport \"./IPassportV1Reserver.sol\";\nimport \"./Shared.sol\";\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\nuint256 constant PRICE_MAX_AGE = 24 hours;\n\nabstract contract PassportV1 is\n AccessControlUpgradeable,\n ERC721Upgradeable,\n PullPaymentUpgradeable,\n IPassportV1\n{\n using AddressUpgradeable for address payable;\n\n uint256 public priceAmount;\n AggregatorV3Interface public priceFeed1;\n AggregatorV3Interface public priceFeed2;\n uint256 public incentive;\n address payable public treasury;\n IDrawerV1 public drawer;\n\n uint256 private _paymentIdCounter;\n struct Payment {\n address payable sender;\n uint256 value;\n bytes data;\n }\n mapping(uint256 => Payment) private _payments;\n\n uint256[] private _allTokens;\n mapping(address => uint256) private _tokens;\n\n mapping(uint256 => uint256) private _createdAts;\n mapping(uint256 => uint256) private _updatedAts;\n mapping(uint256 => mapping(bytes32 => bytes)) private _properties;\n\n function __PassportV1_init(\n string memory name,\n string memory symbol,\n uint256 priceAmount_,\n AggregatorV3Interface priceFeed1_,\n AggregatorV3Interface priceFeed2_,\n uint256 incentive_,\n address payable treasury_,\n IDrawerV1 drawer_\n ) internal onlyInitializing {\n __ERC721_init_unchained(name, symbol);\n __PassportV1_init_unchained(\n priceAmount_,\n priceFeed1_,\n priceFeed2_,\n incentive_,\n treasury_,\n drawer_\n );\n __PullPayment_init_unchained();\n }\n\n function __PassportV1_init_unchained(\n uint256 priceAmount_,\n AggregatorV3Interface priceFeed1_,\n AggregatorV3Interface priceFeed2_,\n uint256 incentive_,\n address payable treasury_,\n IDrawerV1 drawer_\n ) internal onlyInitializing {\n priceAmount = priceAmount_;\n priceFeed1 = priceFeed1_;\n priceFeed2 = priceFeed2_;\n incentive = incentive_;\n treasury = treasury_;\n drawer = drawer_;\n }\n\n function assign(Assignment[] calldata assignments) public payable override {\n address sender = _msgSender();\n\n emit Assign(sender, assignments);\n\n _callContract(\n ASSIGN_METHOD,\n abi.encode(sender, assignments),\n msg.value,\n sender\n );\n }\n\n function claim() public payable override whenNotToken {\n address sender = _msgSender();\n\n emit Claim(sender);\n\n _callContract(CLAIM_METHOD, abi.encode(sender), msg.value, sender);\n }\n\n function purchase(\n uint160 roundIds,\n address referrer,\n bytes calldata data\n ) public payable override whenNotToken {\n (\n uint256 paymentId,\n Payment memory payment,\n uint256 unused\n ) = _createPayment(roundIds, 1, data);\n\n emit Purchase(paymentId, payment.sender, payment.value, referrer);\n\n _callContract(\n PURCHASE_METHOD,\n abi.encode(paymentId, payment.sender, referrer),\n unused,\n payment.sender\n );\n }\n\n function reserve(\n uint160 roundIds,\n Assignment[] calldata assignments,\n bytes calldata data\n ) public payable override {\n (\n uint256 paymentId,\n Payment memory payment,\n uint256 unused\n ) = _createPayment(roundIds, countAssignments(assignments), data);\n\n emit Reserve(paymentId, payment.sender, payment.value, assignments);\n\n _callContract(\n RESERVE_METHOD,\n abi.encode(paymentId, payment.sender, assignments),\n unused,\n payment.sender\n );\n }\n\n function setDrawer(\n IDrawerV1 drawer_\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n drawer = drawer_;\n }\n\n function setProperty(bytes32 key, bytes calldata value) public override {\n uint256 tokenId = _requireTokenUpdate();\n\n _properties[tokenId][key] = value;\n\n emit SetProperty(tokenId, key, value);\n }\n\n function setPropertyBatch(Property[] calldata properties) public override {\n uint256 tokenId = _requireTokenUpdate();\n\n uint256 length = properties.length;\n\n for (uint256 i; i < length; ) {\n Property memory property_ = properties[i];\n\n _properties[tokenId][property_.key] = property_.value;\n\n unchecked {\n ++i;\n }\n }\n\n emit SetPropertyBatch(tokenId, properties);\n }\n\n function withdraw(\n address recipient,\n uint256 amount\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n _asyncTransfer(recipient, amount);\n }\n\n function withdrawPayment(\n uint256 paymentId\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n Payment memory payment = _requirePaymentDelete(paymentId);\n\n _asyncTransfer(payment.sender, payment.value);\n }\n\n function createdAt(\n uint256 tokenId\n ) public view override whenMinted(tokenId) returns (uint256) {\n return _createdAts[tokenId];\n }\n\n function price() public view override returns (uint160 roundIds, uint256) {\n int256 answer1;\n int256 answer2;\n\n if (address(priceFeed1) != address(0)) {\n (uint80 roundId, int256 answer, , , ) = priceFeed1\n .latestRoundData();\n\n roundIds |= roundId;\n answer1 = answer;\n }\n\n if (address(priceFeed2) != address(0)) {\n (uint80 roundId, int256 answer, , , ) = priceFeed2\n .latestRoundData();\n\n roundIds |= uint160(roundId) << 80;\n answer2 = answer;\n }\n\n return (roundIds, _price(answer1, answer2));\n }\n\n function priceAt(uint160 roundIds) public view override returns (uint256) {\n int256 answer1;\n int256 answer2;\n\n if (address(priceFeed1) != address(0)) {\n answer1 = _getRoundAnswer(priceFeed1, uint80(roundIds));\n }\n\n if (address(priceFeed2) != address(0)) {\n answer2 = _getRoundAnswer(priceFeed2, uint80(roundIds >> 80));\n }\n\n return _price(answer1, answer2);\n }\n\n function property(\n uint256 tokenId,\n bytes32 key\n ) public view override whenMinted(tokenId) returns (bytes memory) {\n return _properties[tokenId][key];\n }\n\n function propertyBatch(\n uint256 tokenId,\n bytes32[] calldata keys\n ) public view override whenMinted(tokenId) returns (bytes[] memory values) {\n uint256 length = keys.length;\n\n for (uint256 i; i < length; ) {\n values[i] = _properties[tokenId][keys[i]];\n\n unchecked {\n ++i;\n }\n }\n }\n\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n virtual\n override(\n AccessControlUpgradeable,\n ERC721Upgradeable,\n IERC165Upgradeable\n )\n returns (bool)\n {\n return\n interfaceId == type(IERC721EnumerableUpgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n interfaceId == type(IPassportV1).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function token(address owner) public view override returns (uint256) {\n return tokenOfOwnerByIndex(owner, 0);\n }\n\n function tokenByIndex(\n uint256 index\n ) public view override returns (uint256) {\n if (index >= _allTokens.length) {\n revert NotFound();\n }\n\n return _allTokens[index];\n }\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) public view override returns (uint256 tokenId) {\n tokenId = _tokens[owner];\n\n if (tokenId == 0 || index > 0) {\n revert NotFound();\n }\n }\n\n function tokenURI(\n uint256 tokenId\n )\n public\n view\n override(ERC721Upgradeable, IERC721MetadataUpgradeable)\n whenMinted(tokenId)\n returns (string memory)\n {\n return drawer.tokenURI(this, tokenId);\n }\n\n function totalSupply() public view override returns (uint256) {\n return _allTokens.length;\n }\n\n function updatedAt(\n uint256 tokenId\n ) public view override whenMinted(tokenId) returns (uint256) {\n return _updatedAts[tokenId];\n }\n\n function _afterExecutePurchase(bool success) internal virtual {}\n\n function _afterExecuteReserve(bool success) internal virtual {}\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId,\n uint256\n ) internal override {\n if (from != address(0) || _tokens[to] != 0) {\n revert Forbidden();\n }\n\n _allTokens.push(tokenId);\n _tokens[to] = tokenId;\n\n _createdAts[tokenId] = block.timestamp;\n }\n\n function _callContract(\n bytes32 method,\n bytes memory params,\n uint256 gasFee,\n address refundAddress\n ) internal virtual;\n\n function _createPayment(\n uint160 roundIds,\n uint256 count,\n bytes calldata data\n )\n internal\n returns (uint256 paymentId, Payment memory payment, uint256 unused)\n {\n payment = Payment({\n sender: payable(_msgSender()),\n value: count * priceAt(roundIds),\n data: data\n });\n\n if (msg.value < payment.value) {\n revert Forbidden();\n }\n\n unchecked {\n paymentId = _paymentIdCounter++;\n unused = msg.value - payment.value;\n }\n\n _payments[paymentId] = payment;\n }\n\n function _doHook(address target, bytes memory data) internal {\n if (target.code.length > 0) {\n (bool success, ) = target.call(data);\n success;\n }\n }\n\n function _doTransfer(address payable recipient, uint256 amount) internal {\n recipient.sendValue(amount);\n\n emit Payout(recipient, amount);\n }\n\n function _execute(bytes32 method, bytes memory params) internal virtual {\n if (method == CLAIM_METHOD) {\n _executeClaim(params);\n } else if (method == PURCHASE_METHOD) {\n _executePurchase(params);\n } else if (method == RESERVE_METHOD) {\n _executeReserve(params);\n } else {\n revert NotImplemented();\n }\n }\n\n function _executeClaim(bytes memory params) internal {\n (address sender, uint256 tokenId) = abi.decode(\n params,\n (address, uint256)\n );\n\n _mint(sender, tokenId);\n\n emit ExecuteClaim(sender, tokenId);\n }\n\n function _executePurchase(bytes memory params) internal {\n (\n uint256 paymentId,\n address referrer,\n uint256 tokenId,\n bool success\n ) = abi.decode(params, (uint256, address, uint256, bool));\n\n Payment memory payment = _requirePaymentDelete(paymentId);\n\n emit ExecutePurchase(\n paymentId,\n payment.sender,\n payment.value,\n referrer,\n tokenId,\n success\n );\n\n if (success) {\n _mint(payment.sender, tokenId);\n\n if (referrer != address(0)) {\n uint256 n = (payment.value * incentive) / 100;\n\n _doTransfer(payment.sender, n);\n _asyncTransfer(referrer, n);\n\n payment.value -= n + n;\n }\n }\n\n _doTransfer(success ? treasury : payment.sender, payment.value);\n\n _doHook(\n payment.sender,\n abi.encodeWithSelector(\n IPassportV1Purchaser.onPassportV1Purchased.selector,\n success,\n payment.data\n )\n );\n\n _afterExecutePurchase(success);\n }\n\n function _executeReserve(bytes memory params) internal {\n (uint256 paymentId, bool referred, bool success) = abi.decode(\n params,\n (uint256, bool, bool)\n );\n\n Payment memory payment = _requirePaymentDelete(paymentId);\n\n emit ExecuteReserve(\n paymentId,\n payment.sender,\n payment.value,\n referred,\n success\n );\n\n if (success && referred) {\n uint256 n = (payment.value * incentive) / 100;\n\n _doTransfer(payment.sender, n);\n\n payment.value -= n;\n }\n\n _doTransfer(success ? treasury : payment.sender, payment.value);\n\n _doHook(\n payment.sender,\n abi.encodeWithSelector(\n IPassportV1Reserver.onPassportV1Reserved.selector,\n success,\n payment.data\n )\n );\n\n _afterExecuteReserve(success);\n }\n\n function _requirePaymentDelete(\n uint256 paymentId\n ) internal returns (Payment memory state) {\n state = _payments[paymentId];\n\n if (state.sender == address(0)) {\n revert Forbidden();\n }\n\n delete _payments[paymentId];\n }\n\n function _requireTokenUpdate() internal returns (uint256 tokenId) {\n tokenId = _tokens[_msgSender()];\n\n if (tokenId == 0) {\n revert Forbidden();\n }\n\n _updatedAts[tokenId] = block.timestamp;\n }\n\n function _getRoundAnswer(\n AggregatorV3Interface priceFeed,\n uint80 roundId\n ) internal view returns (int256) {\n (, int256 answer, , uint256 timestamp, ) = priceFeed.getRoundData(\n roundId\n );\n\n if (timestamp < block.timestamp - PRICE_MAX_AGE) {\n revert Forbidden();\n }\n\n return answer;\n }\n\n function _price(\n int256 answer1,\n int256 answer2\n ) internal view returns (uint256) {\n uint256 base = 1e18;\n uint256 quote = 1e18;\n\n if (address(priceFeed1) != address(0)) {\n base = _priceFeedAnswer(priceFeed1, answer1);\n }\n\n if (address(priceFeed2) != address(0)) {\n quote = _priceFeedAnswer(priceFeed2, answer2);\n }\n\n return (priceAmount * base) / quote;\n }\n\n function _priceFeedAnswer(\n AggregatorV3Interface priceFeed,\n int256 answer\n ) internal view returns (uint256) {\n require(answer > 0);\n\n uint8 decimals = priceFeed.decimals();\n\n if (decimals < 18) {\n return uint256(answer) * (10 ** (18 - decimals));\n } else if (decimals > 18) {\n return uint256(answer) / (10 ** (decimals - 18));\n }\n\n return uint256(answer);\n }\n\n function _requireMinted(uint256 tokenId) internal view override {\n if (!_exists(tokenId)) {\n revert NotFound();\n }\n }\n\n modifier whenMinted(uint256 tokenId) {\n _requireMinted(tokenId);\n _;\n }\n\n modifier whenNotToken() {\n uint256 tokenId = _tokens[_msgSender()];\n\n if (tokenId != 0) {\n revert Forbidden();\n }\n\n _;\n }\n\n uint256[37] private __gap;\n}\n" + }, + "contracts/passport/PassportV1AsyncMock.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./GatewayV1Call.sol\";\nimport \"./PassportV1.sol\";\n\ncontract PassportV1AsyncMock is GatewayV1Call, PassportV1 {\n function initialize(\n address callAddress,\n string memory name,\n string memory symbol,\n uint256 priceAmount,\n AggregatorV3Interface priceFeed1,\n AggregatorV3Interface priceFeed2,\n uint256 incentive,\n address payable treasury,\n IDrawerV1 drawer\n ) public initializer {\n __GatewayV1Call_init(callAddress);\n __PassportV1_init(\n name,\n symbol,\n priceAmount,\n priceFeed1,\n priceFeed2,\n incentive,\n treasury,\n drawer\n );\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n override(AccessControlUpgradeable, PassportV1)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n function _callContract(\n bytes32 method,\n bytes memory params,\n uint256,\n address\n ) internal override {\n GatewayV1Call._callContract(method, params);\n }\n\n function _execute(\n bytes32 method,\n bytes memory params\n ) internal override(GatewayV1Call, PassportV1) {\n PassportV1._execute(method, params);\n }\n}\n" + }, + "contracts/passport/PassportV1Axelar.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./GatewayV1Axelar.sol\";\nimport \"./PassportV1.sol\";\n\nbytes32 constant BASE_NETWORK = keccak256(\"BASE_NETWORK\");\n\ncontract PassportV1Axelar is GatewayV1Axelar, PassportV1 {\n function initialize(\n IAxelarGateway axelarGateway,\n IAxelarGasService axelarGasService,\n AxelarNetwork[] calldata axelarNetworks,\n string memory name,\n string memory symbol,\n uint256 priceAmount,\n AggregatorV3Interface priceFeed1,\n AggregatorV3Interface priceFeed2,\n uint256 incentive,\n address payable treasury,\n IDrawerV1 drawer\n ) public initializer {\n __GatewayV1Axelar_init(axelarGateway, axelarGasService, axelarNetworks);\n __PassportV1_init(\n name,\n symbol,\n priceAmount,\n priceFeed1,\n priceFeed2,\n incentive,\n treasury,\n drawer\n );\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n override(AccessControlUpgradeable, PassportV1)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n function _callContract(\n bytes32 method,\n bytes memory params,\n uint256 gasFee,\n address refundAddress\n ) internal override {\n GatewayV1Axelar._callContract(\n BASE_NETWORK,\n method,\n params,\n gasFee,\n refundAddress\n );\n }\n\n function _execute(\n bytes32,\n bytes32 method,\n bytes memory params\n ) internal override {\n PassportV1._execute(method, params);\n }\n}\n" + }, + "contracts/passport/PassportV1Call.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./GatewayV1Call.sol\";\nimport \"./PassportV1.sol\";\n\ncontract PassportV1Call is GatewayV1Call, PassportV1 {\n function initialize(\n address callAddress,\n string memory name,\n string memory symbol,\n uint256 priceAmount,\n AggregatorV3Interface priceFeed1,\n AggregatorV3Interface priceFeed2,\n uint256 incentive,\n address payable treasury,\n IDrawerV1 drawer\n ) public initializer {\n __GatewayV1Call_init(callAddress);\n __PassportV1_init(\n name,\n symbol,\n priceAmount,\n priceFeed1,\n priceFeed2,\n incentive,\n treasury,\n drawer\n );\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n override(AccessControlUpgradeable, PassportV1)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n function _callContract(\n bytes32 method,\n bytes memory params,\n uint256,\n address\n ) internal override {\n GatewayV1Call._callContract(method, params);\n }\n\n function _execute(\n bytes32 method,\n bytes memory params\n ) internal override(GatewayV1Call, PassportV1) {\n PassportV1._execute(method, params);\n }\n\n function _afterExecutePurchase(bool success) internal pure override {\n if (!success) {\n revert Forbidden();\n }\n }\n\n function _afterExecuteReserve(bool success) internal pure override {\n if (!success) {\n revert Forbidden();\n }\n }\n}\n" + }, + "contracts/passport/PaymentSplitterV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\ncontract PaymentSplitterV1 is Initializable {\n using AddressUpgradeable for address payable;\n\n struct Recipient {\n address payable account;\n uint256 shares;\n }\n Recipient[] public recipients;\n\n uint256 private _totalShares;\n\n function initialize(Recipient[] calldata recipients_) public initializer {\n _addRecipients(recipients_);\n }\n\n receive() external payable {\n _sendValue(address(this).balance);\n }\n\n function _addRecipients(Recipient[] calldata recipients_) internal {\n uint256 length = recipients_.length;\n\n for (uint256 i; i < length; ) {\n Recipient calldata recipient = recipients_[i];\n\n recipients.push(recipient);\n\n _totalShares += recipient.shares;\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _sendValue(uint256 amount) internal {\n uint256 length = recipients.length;\n\n for (uint256 i; i < length; ) {\n Recipient memory recipient = recipients[i];\n\n recipient.account.sendValue(\n (amount * recipient.shares) / _totalShares\n );\n\n unchecked {\n ++i;\n }\n }\n }\n}\n" + }, + "contracts/passport/Shared.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nbytes32 constant ASSIGN_METHOD = keccak256(\"ASSIGN_METHOD\");\nbytes32 constant CLAIM_METHOD = keccak256(\"CLAIM_METHOD\");\nbytes32 constant PURCHASE_METHOD = keccak256(\"PURCHASE_METHOD\");\nbytes32 constant RESERVE_METHOD = keccak256(\"RESERVE_METHOD\");\n\nerror Forbidden();\nerror NotFound();\nerror NotImplemented();\n\nstruct Assignment {\n address to;\n uint256 count;\n}\n\nfunction countAssignments(\n Assignment[] memory assignments\n) pure returns (uint256 count) {\n uint256 length = assignments.length;\n\n for (uint256 i; i < length; ) {\n count += assignments[i].count;\n\n unchecked {\n ++i;\n }\n }\n}\n" + }, + "contracts/payment/PaymentConfigRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"../AccessRegistry.sol\";\n\nbytes32 constant PAYMENT_ADMIN_ROLE = keccak256(\"PAYMENT_ADMIN_ROLE\");\n\ncontract PaymentConfigRegistry is OwnableUpgradeable {\n using ECDSA for bytes;\n using ECDSA for bytes32;\n\n error InvalidSignature();\n error Forbidden();\n error CannotWithdraw();\n\n address public accessRegistry;\n address public authorizedSigner;\n uint256 public feePPM;\n uint256[20] __gap;\n\n event FeeCollected(string eventId, address token, uint256 amount);\n\n function initialize(\n address registry,\n address signer,\n uint256 ppm\n ) public initializer {\n __Ownable_init();\n accessRegistry = registry;\n authorizedSigner = signer;\n feePPM = ppm;\n }\n\n function setAccessRegistry(address registry) external onlyOwner {\n accessRegistry = registry;\n }\n\n function setAuthorizedSigner(address signer) external onlyAdmin {\n authorizedSigner = signer;\n }\n\n function setFeePPM(uint256 ppm) external onlyAdmin {\n feePPM = ppm;\n }\n\n function withdraw(\n address token,\n uint256 amount,\n address payable destination\n ) external onlyAdmin {\n bool success;\n\n if (token == address(0)) {\n (success, ) = destination.call{value: amount}(\"\");\n } else {\n success = IERC20(token).transfer(destination, amount);\n }\n\n if (!success) revert CannotWithdraw();\n }\n\n function notifyFee(\n string calldata eventId,\n address token,\n uint256 amount\n ) external {\n emit FeeCollected(eventId, token, amount);\n }\n\n function assertSignature(\n bytes32[] calldata data,\n bytes calldata signature\n ) public view {\n address actualSigner = abi\n .encode(data)\n .toEthSignedMessageHash()\n .recover(signature);\n\n if (actualSigner != authorizedSigner) {\n revert InvalidSignature();\n }\n }\n\n function balances(\n address[] calldata currencies\n ) external view returns (uint256[] memory balance_) {\n uint256 length = currencies.length;\n\n balance_ = new uint256[](length);\n\n address contractAddress = address(this);\n\n for (uint256 i = 0; i < length; ) {\n address currency = currencies[i];\n\n if (currency == address(0)) {\n balance_[i] = contractAddress.balance;\n } else {\n balance_[i] = IERC20(currency).balanceOf(contractAddress);\n }\n\n unchecked {\n ++i;\n }\n }\n\n return balance_;\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n\n modifier onlyAdmin() {\n if (\n !AccessRegistry(accessRegistry).hasRole(\n PAYMENT_ADMIN_ROLE,\n _msgSender()\n )\n ) {\n revert Forbidden();\n }\n _;\n }\n}\n" + }, + "contracts/payment/PaymentSplitter.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol)\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @title PaymentSplitter\n * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware\n * that the Ether will be split in this way, since it is handled transparently by the contract.\n *\n * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each\n * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim\n * an amount proportional to the percentage of total shares they were assigned.\n *\n * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the\n * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}\n * function.\n *\n * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and\n * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you\n * to run tests before sending real value to this contract.\n */\n\nstruct Payee {\n address account;\n uint256 shares;\n}\n\ncontract PaymentSplitter is Context {\n uint256 private _totalShares;\n uint256 private _totalReleased;\n\n mapping(address => uint256) private _shares;\n mapping(address => uint256) private _released;\n address[] private _payees;\n\n mapping(IERC20 => uint256) private _erc20TotalReleased;\n mapping(IERC20 => mapping(address => uint256)) private _erc20Released;\n\n event PayeeAdded(address account, uint256 shares);\n event PayeesReset();\n event PaymentReleased(address to, uint256 amount);\n event ERC20PaymentReleased(\n IERC20 indexed token,\n address to,\n uint256 amount\n );\n event PaymentReceived(address from, uint256 amount);\n\n error LengthMismatch();\n error ZeroLength();\n error AccountHasNoShare();\n error AccountHasShare();\n error NoDueAmount();\n error InvalidShare();\n error InvalidAddress();\n\n /**\n * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at\n * the matching position in the `shares` array.\n *\n * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no\n * duplicates in `payees`.\n */\n constructor(address[] memory payees, uint256[] memory shares_) payable {\n if (payees.length == 0) revert ZeroLength();\n\n if (payees.length != shares_.length) revert LengthMismatch();\n\n for (uint256 i = 0; i < payees.length; i++) {\n _addPayee(payees[i], shares_[i]);\n }\n }\n\n /**\n * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully\n * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the\n * reliability of the events, and not the actual splitting of Ether.\n *\n * To learn more about this see the Solidity documentation for\n * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback\n * functions].\n */\n receive() external payable virtual {\n emit PaymentReceived(_msgSender(), msg.value);\n }\n\n /**\n * @dev Getter for the total shares held by payees.\n */\n function totalShares() public view returns (uint256) {\n return _totalShares;\n }\n\n /**\n * @dev Getter for the total amount of Ether already released.\n */\n function totalReleased() public view returns (uint256) {\n return _totalReleased;\n }\n\n /**\n * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20\n * contract.\n */\n function totalReleased(IERC20 token) public view returns (uint256) {\n return _erc20TotalReleased[token];\n }\n\n /**\n * @dev Getter for the amount of shares held by an account.\n */\n function shares(address account) public view returns (uint256) {\n return _shares[account];\n }\n\n /**\n * @dev Getter for the amount of Ether already released to a payee.\n */\n function released(address account) public view returns (uint256) {\n return _released[account];\n }\n\n /**\n * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an\n * IERC20 contract.\n */\n function released(\n IERC20 token,\n address account\n ) public view returns (uint256) {\n return _erc20Released[token][account];\n }\n\n function released(\n address[] calldata currencies,\n address account\n ) public view returns (uint256[] memory balances) {\n uint256 length = currencies.length;\n\n if (length == 0) revert ZeroLength();\n\n balances = new uint256[](length);\n\n for (uint256 i = 0; i < length; ) {\n address currency = currencies[i];\n\n if (currency == address(0)) {\n balances[i] = released(account);\n } else {\n balances[i] = released(IERC20(currency), account);\n }\n\n unchecked {\n ++i;\n }\n }\n\n return balances;\n }\n\n function pending(address account) public view returns (uint256) {\n uint256 totalReceived = address(this).balance + totalReleased();\n return _pendingPayment(account, totalReceived, released(account));\n }\n\n function pending(\n IERC20 token,\n address account\n ) public view returns (uint256) {\n uint256 totalReceived = token.balanceOf(address(this)) +\n totalReleased(token);\n return\n _pendingPayment(account, totalReceived, released(token, account));\n }\n\n function pending(\n address[] calldata currencies,\n address account\n ) public view returns (uint256[] memory balances) {\n uint256 length = currencies.length;\n\n if (length == 0) revert ZeroLength();\n\n balances = new uint256[](length);\n\n for (uint256 i = 0; i < length; ) {\n address currency = currencies[i];\n\n if (currency == address(0)) {\n balances[i] = pending(account);\n } else {\n balances[i] = pending(IERC20(currency), account);\n }\n\n unchecked {\n ++i;\n }\n }\n\n return balances;\n }\n\n function allPayees() public view returns (Payee[] memory payees) {\n uint256 length = _payees.length;\n\n payees = new Payee[](length);\n\n for (uint256 i; i < length; ) {\n address account = _payees[i];\n payees[i] = Payee(account, _shares[account]);\n\n unchecked {\n ++i;\n }\n }\n\n return payees;\n }\n\n /**\n * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the\n * total shares and their previous withdrawals.\n */\n function release(address payable account) public virtual {\n if (_shares[account] == 0) revert AccountHasNoShare();\n\n uint256 payment = pending(account);\n\n if (payment == 0) revert NoDueAmount();\n\n _released[account] += payment;\n _totalReleased += payment;\n\n Address.sendValue(account, payment);\n emit PaymentReleased(account, payment);\n }\n\n /**\n * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their\n * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20\n * contract.\n */\n function release(IERC20 token, address account) public virtual {\n if (_shares[account] == 0) revert AccountHasNoShare();\n\n uint256 payment = pending(token, account);\n\n if (payment == 0) revert NoDueAmount();\n\n _erc20Released[token][account] += payment;\n _erc20TotalReleased[token] += payment;\n\n SafeERC20.safeTransfer(token, account, payment);\n emit ERC20PaymentReleased(token, account, payment);\n }\n\n function release(\n address[] calldata currencies,\n address payable account\n ) public virtual {\n uint256 length = currencies.length;\n\n if (length == 0) revert ZeroLength();\n\n for (uint256 i = 0; i < length; ) {\n address currency = currencies[i];\n if (currency == address(0)) {\n release(account);\n } else {\n release(IERC20(currency), account);\n }\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev internal logic for computing the pending payment of an `account` given the token historical balances and\n * already released amounts.\n */\n function _pendingPayment(\n address account,\n uint256 totalReceived,\n uint256 alreadyReleased\n ) private view returns (uint256) {\n return\n (totalReceived * _shares[account]) / _totalShares - alreadyReleased;\n }\n\n /**\n * @dev Add a new payee to the contract.\n * @param account The address of the payee to add.\n * @param shares_ The number of shares owned by the payee.\n */\n function _addPayee(address account, uint256 shares_) private {\n if (account == address(0)) revert InvalidAddress();\n\n if (shares_ == 0) revert InvalidShare();\n\n if (_shares[account] != 0) revert AccountHasShare();\n\n _payees.push(account);\n _shares[account] = shares_;\n _totalShares = _totalShares + shares_;\n emit PayeeAdded(account, shares_);\n }\n\n function _resetPayees(\n address[] memory payees,\n uint256[] memory shares_\n ) internal {\n //-- reset total share\n _totalShares = 0;\n\n //-- reset payees array\n delete _payees;\n\n for (uint256 i = 0; i < payees.length; i++) {\n address account = payees[i];\n uint256 shared = shares_[i];\n\n if (account == address(0)) revert InvalidAddress();\n\n if (shared == 0) revert InvalidShare();\n\n _payees.push(account);\n _shares[account] = shared;\n _totalShares = _totalShares + shared;\n }\n\n emit PayeesReset();\n }\n}\n" + }, + "contracts/payment/relay/LemonadeRelayPayment.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"../PaymentConfigRegistry.sol\";\nimport \"../PaymentSplitter.sol\";\n\ncontract RelayPaymentSplitter is PaymentSplitter {\n address internal _owner;\n\n error Forbidden();\n\n constructor(\n address owner,\n address[] memory payees,\n uint256[] memory shares\n ) PaymentSplitter(payees, shares) {\n _owner = owner;\n }\n\n function resetPayees(\n address[] memory payees,\n uint256[] memory shares\n ) public {\n if (_msgSender() != _owner) revert Forbidden();\n\n _resetPayees(payees, shares);\n }\n}\n\ncontract LemonadeRelayPayment is OwnableUpgradeable {\n struct Payment {\n address guest;\n address currency;\n uint256 amount;\n }\n\n address public configRegistry;\n mapping(bytes32 => Payment) internal payments;\n mapping(address => bool) internal splitters;\n uint256[20] __gap;\n\n event OnRegister(address splitter);\n\n event OnPay(\n address splitter,\n string eventId,\n string paymentId,\n address guest,\n address currency,\n uint256 amount\n );\n\n error NotRegistered();\n error AlreadyPay();\n error InvalidAmount();\n error CannotPayFee();\n error CannotPay();\n\n function initialize(address registry) public initializer {\n __Ownable_init();\n configRegistry = registry;\n }\n\n function setConfigRegistry(address registry) external onlyOwner {\n configRegistry = registry;\n }\n\n /**\n * Register wallets to receive payments of a specific event\n * @param payees Param of payment splitter\n * @param shares Param of payment splitter\n */\n function register(\n address[] calldata payees,\n uint256[] calldata shares\n ) external {\n RelayPaymentSplitter splitter = new RelayPaymentSplitter(\n _msgSender(),\n payees,\n shares\n );\n\n address splitterAddress = address(splitter);\n\n splitters[splitterAddress] = true;\n\n emit OnRegister(splitterAddress);\n }\n\n function getPayment(\n string calldata paymentId\n ) external view returns (Payment memory) {\n bytes32 id = _toId(paymentId);\n\n return payments[id];\n }\n\n /**\n * Guest pays the tickets\n * @param splitter The address of the registered splitter\n * @param paymentId The id of the payment\n * @param currency Token address of the currency, zero address for native currency\n * @param amount The ticket amount plus fee\n */\n function pay(\n address splitter,\n string memory eventId,\n string memory paymentId,\n address currency,\n uint256 amount\n ) external payable {\n if (amount == 0) revert InvalidAmount();\n\n bytes32 id = _toId(paymentId);\n\n if (payments[id].amount > 0) revert AlreadyPay();\n\n if (!splitters[splitter]) revert NotRegistered();\n\n bool isNative = currency == address(0);\n\n if (isNative && msg.value != amount) revert InvalidAmount();\n\n PaymentConfigRegistry registry = PaymentConfigRegistry(\n payable(configRegistry)\n );\n\n uint256 transferAmount = amount * 1000000 / (registry.feePPM() + 1000000);\n uint256 feeAmount = amount - transferAmount;\n\n address guest = _msgSender();\n\n if (isNative) {\n (bool success, ) = payable(configRegistry).call{value: feeAmount}(\n \"\"\n );\n\n if (!success) revert CannotPayFee();\n\n (success, ) = payable(splitter).call{value: transferAmount}(\"\");\n\n if (!success) revert CannotPay();\n } else {\n bool success = IERC20(currency).transferFrom(\n guest,\n configRegistry,\n feeAmount\n );\n\n if (!success) revert CannotPayFee();\n\n success = IERC20(currency).transferFrom(\n guest,\n splitter,\n transferAmount\n );\n\n if (!success) revert CannotPay();\n }\n\n registry.notifyFee(eventId, currency, feeAmount);\n\n Payment memory payment = Payment(guest, currency, amount);\n\n payments[id] = payment;\n\n emit OnPay(\n splitter,\n eventId,\n paymentId,\n guest,\n currency,\n transferAmount\n );\n }\n\n function _toId(string memory id) internal pure returns (bytes32) {\n return keccak256(abi.encode(id));\n }\n}\n" + }, + "contracts/rarible/LibPart.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary LibPart {\n bytes32 public constant TYPE_HASH = keccak256(\"Part(address account,uint96 value)\");\n\n struct Part {\n address payable account;\n uint96 value;\n }\n\n function hash(Part memory part) internal pure returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, part.account, part.value));\n }\n}\n" + }, + "contracts/rarible/RoyaltiesV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"./LibPart.sol\";\n\ninterface RoyaltiesV2 {\n event RoyaltiesSet(uint256 tokenId, LibPart.Part[] royalties);\n\n function getRaribleV2Royalties(uint256 id) external view returns (LibPart.Part[] memory);\n}\n" + }, + "contracts/RelayRecipient.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IRelayRecipient.sol\";\n\nabstract contract RelayRecipient is IRelayRecipient {\n address public trustedForwarder;\n\n constructor(address forwarder) {\n trustedForwarder = forwarder;\n }\n\n function isTrustedForwarder(address forwarder)\n public\n view\n override\n returns (bool)\n {\n return forwarder == trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address ret) {\n if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) {\n // At this point we know that the sender is a trusted forwarder,\n // so we trust that the last bytes of msg.data are the verified sender address.\n // extract sender address from the end of msg.data\n assembly {\n ret := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return msg.sender;\n }\n }\n\n function versionRecipient() external pure override returns (string memory) {\n return \"1\";\n }\n}\n" + }, + "contracts/unique/ICollection.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\nstring constant ROYALTIES_PROPERTY = \"royalties\";\n\nstruct Property {\n string key;\n bytes value;\n}\n\nenum TokenPermissionField {\n Mutable,\n TokenOwner,\n CollectionAdmin\n}\n\nstruct PropertyPermission {\n TokenPermissionField code;\n bool value;\n}\n\nstruct TokenPropertyPermission {\n string key;\n PropertyPermission[] permissions;\n}\n\nstruct CrossAddress {\n address eth;\n uint256 sub;\n}\n\ninterface ICollection is IERC721 {\n function addCollectionAdminCross(CrossAddress memory newAdmin)\n external;\n\n function changeCollectionOwnerCross(CrossAddress memory newOwner)\n external;\n\n function mint(address to) external returns (uint256);\n\n function mintWithTokenURI(address to, string memory tokenUri)\n external\n returns (uint256);\n\n function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions)\n external;\n\n function setProperties(uint256 tokenId, Property[] memory properties)\n external;\n\n function property(uint256 tokenId, string memory key)\n external\n view\n returns (bytes memory);\n}\n" + }, + "contracts/unique/ICollectionHelpers.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface ICollectionHelpers {\n function createNFTCollection(\n string memory name,\n string memory description,\n string memory tokenPrefix\n ) external payable returns (address);\n\n function makeCollectionERC721MetadataCompatible(\n address collection,\n string memory baseUri\n ) external;\n}\n" + }, + "contracts/unique/LibPartAdapter.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../rarible/LibPart.sol\";\n\nlibrary LibPartAdapter {\n function encode(LibPart.Part[] memory parts) internal pure returns (bytes memory) {\n if (parts.length == 0) return \"\";\n\n uint256[] memory encoded = new uint256[](parts.length * 2);\n\n for (uint i = 0; i < parts.length; i++) {\n encoded[i * 2] = 0x0100000000000000000000000000000000000000000000040000000000000000 | uint256(parts[i].value);\n encoded[i * 2 + 1] = uint256(uint160(address(parts[i].account)));\n }\n\n return abi.encodePacked(encoded);\n }\n\n function decode(bytes memory b) internal pure returns (LibPart.Part[] memory) {\n if (b.length == 0) return new LibPart.Part[](0);\n\n require((b.length % (32 * 2)) == 0, \"Invalid bytes length, expected (32 * 2) * UniqueRoyaltyParts count\");\n uint partsCount = b.length / (32 * 2);\n uint numbersCount = partsCount * 2;\n\n LibPart.Part[] memory parts = new LibPart.Part[](partsCount);\n\n // need this because numbers encoded via abi.encodePacked\n bytes memory prefix = new bytes(64);\n\n assembly {\n mstore(add(prefix, 32), 32)\n mstore(add(prefix, 64), numbersCount)\n }\n\n uint256[] memory encoded = abi.decode(bytes.concat(prefix, b), (uint256[]));\n\n for (uint i = 0; i < partsCount; i++) {\n uint96 value = uint96(encoded[i * 2] & 0xFFFFFFFFFFFFFFFF);\n address account = address(uint160(encoded[i * 2 + 1]));\n\n parts[i] = LibPart.Part({\n account: payable(account),\n value: value\n });\n }\n\n return parts;\n }\n}" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "storageLayout", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/scroll/.chainId b/deployments/scroll/.chainId new file mode 100644 index 0000000..9ff6790 --- /dev/null +++ b/deployments/scroll/.chainId @@ -0,0 +1 @@ +534352 \ No newline at end of file diff --git a/deployments/scroll/AccessRegistry.json b/deployments/scroll/AccessRegistry.json new file mode 100644 index 0000000..f35e06b --- /dev/null +++ b/deployments/scroll/AccessRegistry.json @@ -0,0 +1,467 @@ +{ + "address": "0xaB82089834336AA0A6bec3583c462256260cB2B7", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getRoleMember", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleMemberCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x4659639d6a37bb4b0d7b4e7203791f13719f57f8d6c1590a5e1375127f78cfaf", + "receipt": { + "to": null, + "from": "0x6950Af4b7815c15073066C7540b1c64Fa7Be97F1", + "contractAddress": "0xaB82089834336AA0A6bec3583c462256260cB2B7", + "transactionIndex": 5, + "gasUsed": "738540", + "logsBloom": "0x00000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000004000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000020000400000100000000000020000000000000000000004000000000000000000000000100000000000000000001", + "blockHash": "0x6d54f207b5d623340928d0bfb968ae9ea69c4c9cb86b3326bcb840bea631c555", + "transactionHash": "0x4659639d6a37bb4b0d7b4e7203791f13719f57f8d6c1590a5e1375127f78cfaf", + "logs": [ + { + "transactionIndex": 5, + "blockNumber": 7292256, + "transactionHash": "0x4659639d6a37bb4b0d7b4e7203791f13719f57f8d6c1590a5e1375127f78cfaf", + "address": "0xaB82089834336AA0A6bec3583c462256260cB2B7", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000006950af4b7815c15073066c7540b1c64fa7be97f1", + "0x0000000000000000000000006950af4b7815c15073066c7540b1c64fa7be97f1" + ], + "data": "0x", + "logIndex": 46, + "blockHash": "0x6d54f207b5d623340928d0bfb968ae9ea69c4c9cb86b3326bcb840bea631c555" + } + ], + "blockNumber": 7292256, + "cumulativeGasUsed": "2143276", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "fccf71bfc76cbdc7bd823fe97c30d41c", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/AccessRegistry.sol\":\"AccessRegistry\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControl.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\nimport \\\"../utils/Strings.sol\\\";\\nimport \\\"../utils/introspection/ERC165.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```solidity\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```solidity\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\\n * to enforce additional security measures for this role.\\n */\\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n Strings.toHexString(account),\\n \\\" is missing role \\\",\\n Strings.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * May emit a {RoleGranted} event.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0dd6e52cb394d7f5abe5dca2d4908a6be40417914720932de757de34a99ab87f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/AccessControlEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControlEnumerable.sol\\\";\\nimport \\\"./AccessControl.sol\\\";\\nimport \\\"../utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\\n */\\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns one of the accounts that have `role`. `index` must be a\\n * value between 0 and {getRoleMemberCount}, non-inclusive.\\n *\\n * Role bearers are not sorted in any particular way, and their ordering may\\n * change at any point.\\n *\\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\\n * you perform all queries on the same block. See the following\\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\\n * for more information.\\n */\\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\\n return _roleMembers[role].at(index);\\n }\\n\\n /**\\n * @dev Returns the number of accounts that have `role`. Can be used\\n * together with {getRoleMember} to enumerate all bearers of a role.\\n */\\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\\n return _roleMembers[role].length();\\n }\\n\\n /**\\n * @dev Overload {_grantRole} to track enumerable memberships\\n */\\n function _grantRole(bytes32 role, address account) internal virtual override {\\n super._grantRole(role, account);\\n _roleMembers[role].add(account);\\n }\\n\\n /**\\n * @dev Overload {_revokeRole} to track enumerable memberships\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual override {\\n super._revokeRole(role, account);\\n _roleMembers[role].remove(account);\\n }\\n}\\n\",\"keccak256\":\"0x13f5e15f2a0650c0b6aaee2ef19e89eaf4870d6e79662d572a393334c1397247\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControlEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControl.sol\\\";\\n\\n/**\\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\\n */\\ninterface IAccessControlEnumerable is IAccessControl {\\n /**\\n * @dev Returns one of the accounts that have `role`. `index` must be a\\n * value between 0 and {getRoleMemberCount}, non-inclusive.\\n *\\n * Role bearers are not sorted in any particular way, and their ordering may\\n * change at any point.\\n *\\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\\n * you perform all queries on the same block. See the following\\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\\n * for more information.\\n */\\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\\n\\n /**\\n * @dev Returns the number of accounts that have `role`. Can be used\\n * together with {getRoleMember} to enumerate all bearers of a role.\\n */\\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xba4459ab871dfa300f5212c6c30178b63898c03533a1ede28436f11546626676\",\"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/introspection/ERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165 is IERC165 {\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0xd10975de010d89fd1c78dc5e8a9a7e7f496198085c151648f20cba166b32582b\",\"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/AccessRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControlEnumerable.sol\\\";\\n\\ncontract AccessRegistry is AccessControlEnumerable {\\n constructor() {\\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\\n }\\n}\\n\",\"keccak256\":\"0x30e4846797d261dded6b67dd219d08c982a3f585950325733a8ce1c937451c9e\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061001c600033610021565b610177565b61002b828261002f565b5050565b610043828261006c60201b6102e11760201c565b600082815260016020908152604090912061006791839061036561010a821b17901c565b505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661002b576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556100c63390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061011f836001600160a01b038416610128565b90505b92915050565b600081815260018301602052604081205461016f57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610122565b506000610122565b610aa5806101866000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c80639010d07c116100665780639010d07c1461011957806391d1485414610144578063a217fddf14610157578063ca15c8731461015f578063d547741f1461017257600080fd5b806301ffc9a714610098578063248a9ca3146100c05780632f2ff15d146100f157806336568abe14610106575b600080fd5b6100ab6100a63660046108f4565b610185565b60405190151581526020015b60405180910390f35b6100e36100ce366004610881565b60009081526020819052604090206001015490565b6040519081526020016100b7565b6101046100ff366004610899565b6101b0565b005b610104610114366004610899565b6101da565b61012c6101273660046108d3565b61025d565b6040516001600160a01b0390911681526020016100b7565b6100ab610152366004610899565b61027c565b6100e3600081565b6100e361016d366004610881565b6102a5565b610104610180366004610899565b6102bc565b60006001600160e01b03198216635a05180f60e01b14806101aa57506101aa8261037a565b92915050565b6000828152602081905260409020600101546101cb816103af565b6101d583836103bc565b505050565b6001600160a01b038116331461024f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61025982826103de565b5050565b60008281526001602052604081206102759083610400565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60008181526001602052604081206101aa9061040c565b6000828152602081905260409020600101546102d7816103af565b6101d583836103de565b6102eb828261027c565b610259576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556103213390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610275836001600160a01b038416610416565b60006001600160e01b03198216637965db0b60e01b14806101aa57506301ffc9a760e01b6001600160e01b03198316146101aa565b6103b98133610465565b50565b6103c682826102e1565b60008281526001602052604090206101d59082610365565b6103e882826104be565b60008281526001602052604090206101d59082610523565b60006102758383610538565b60006101aa825490565b600081815260018301602052604081205461045d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556101aa565b5060006101aa565b61046f828261027c565b6102595761047c81610570565b610487836020610582565b60405160200161049892919061091c565b60408051601f198184030181529082905262461bcd60e51b825261024691600401610991565b6104c8828261027c565b15610259576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610275836001600160a01b038416610764565b600082600001828154811061055d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60606101aa6001600160a01b03831660145b606060006105918360026109dc565b61059c9060026109c4565b67ffffffffffffffff8111156105c257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156105ec576020820181803683370190505b509050600360fc1b8160008151811061061557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061065257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006106768460026109dc565b6106819060016109c4565b90505b6001811115610715576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106106c357634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106106e757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361070e81610a42565b9050610684565b5083156102755760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610246565b600081815260018301602052604081205480156108775760006107886001836109fb565b855490915060009061079c906001906109fb565b905081811461081d5760008660000182815481106107ca57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106107fb57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061083c57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506101aa565b60009150506101aa565b600060208284031215610892578081fd5b5035919050565b600080604083850312156108ab578081fd5b8235915060208301356001600160a01b03811681146108c8578182fd5b809150509250929050565b600080604083850312156108e5578182fd5b50508035926020909101359150565b600060208284031215610905578081fd5b81356001600160e01b031981168114610275578182fd5b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351610954816017850160208801610a12565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351610985816028840160208801610a12565b01602801949350505050565b60208152600082518060208401526109b0816040850160208701610a12565b601f01601f19169190910160400192915050565b600082198211156109d7576109d7610a59565b500190565b60008160001904831182151516156109f6576109f6610a59565b500290565b600082821015610a0d57610a0d610a59565b500390565b60005b83811015610a2d578181015183820152602001610a15565b83811115610a3c576000848401525b50505050565b600081610a5157610a51610a59565b506000190190565b634e487b7160e01b600052601160045260246000fdfea26469706673582212201a949fcc635b1f817699767b282df8648242e8fc5a24715713cae3781dafc60264736f6c63430008040033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c80639010d07c116100665780639010d07c1461011957806391d1485414610144578063a217fddf14610157578063ca15c8731461015f578063d547741f1461017257600080fd5b806301ffc9a714610098578063248a9ca3146100c05780632f2ff15d146100f157806336568abe14610106575b600080fd5b6100ab6100a63660046108f4565b610185565b60405190151581526020015b60405180910390f35b6100e36100ce366004610881565b60009081526020819052604090206001015490565b6040519081526020016100b7565b6101046100ff366004610899565b6101b0565b005b610104610114366004610899565b6101da565b61012c6101273660046108d3565b61025d565b6040516001600160a01b0390911681526020016100b7565b6100ab610152366004610899565b61027c565b6100e3600081565b6100e361016d366004610881565b6102a5565b610104610180366004610899565b6102bc565b60006001600160e01b03198216635a05180f60e01b14806101aa57506101aa8261037a565b92915050565b6000828152602081905260409020600101546101cb816103af565b6101d583836103bc565b505050565b6001600160a01b038116331461024f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61025982826103de565b5050565b60008281526001602052604081206102759083610400565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60008181526001602052604081206101aa9061040c565b6000828152602081905260409020600101546102d7816103af565b6101d583836103de565b6102eb828261027c565b610259576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556103213390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610275836001600160a01b038416610416565b60006001600160e01b03198216637965db0b60e01b14806101aa57506301ffc9a760e01b6001600160e01b03198316146101aa565b6103b98133610465565b50565b6103c682826102e1565b60008281526001602052604090206101d59082610365565b6103e882826104be565b60008281526001602052604090206101d59082610523565b60006102758383610538565b60006101aa825490565b600081815260018301602052604081205461045d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556101aa565b5060006101aa565b61046f828261027c565b6102595761047c81610570565b610487836020610582565b60405160200161049892919061091c565b60408051601f198184030181529082905262461bcd60e51b825261024691600401610991565b6104c8828261027c565b15610259576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610275836001600160a01b038416610764565b600082600001828154811061055d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60606101aa6001600160a01b03831660145b606060006105918360026109dc565b61059c9060026109c4565b67ffffffffffffffff8111156105c257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156105ec576020820181803683370190505b509050600360fc1b8160008151811061061557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061065257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006106768460026109dc565b6106819060016109c4565b90505b6001811115610715576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106106c357634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106106e757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361070e81610a42565b9050610684565b5083156102755760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610246565b600081815260018301602052604081205480156108775760006107886001836109fb565b855490915060009061079c906001906109fb565b905081811461081d5760008660000182815481106107ca57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106107fb57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061083c57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506101aa565b60009150506101aa565b600060208284031215610892578081fd5b5035919050565b600080604083850312156108ab578081fd5b8235915060208301356001600160a01b03811681146108c8578182fd5b809150509250929050565b600080604083850312156108e5578182fd5b50508035926020909101359150565b600060208284031215610905578081fd5b81356001600160e01b031981168114610275578182fd5b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351610954816017850160208801610a12565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351610985816028840160208801610a12565b01602801949350505050565b60208152600082518060208401526109b0816040850160208701610a12565b601f01601f19169190910160400192915050565b600082198211156109d7576109d7610a59565b500190565b60008160001904831182151516156109f6576109f6610a59565b500290565b600082821015610a0d57610a0d610a59565b500390565b60005b83811015610a2d578181015183820152602001610a15565b83811115610a3c576000848401525b50505050565b600081610a5157610a51610a59565b506000190190565b634e487b7160e01b600052601160045260246000fdfea26469706673582212201a949fcc635b1f817699767b282df8648242e8fc5a24715713cae3781dafc60264736f6c63430008040033", + "devdoc": { + "kind": "dev", + "methods": { + "getRoleAdmin(bytes32)": { + "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." + }, + "getRoleMember(bytes32,uint256)": { + "details": "Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information." + }, + "getRoleMemberCount(bytes32)": { + "details": "Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role." + }, + "grantRole(bytes32,address)": { + "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event." + }, + "hasRole(bytes32,address)": { + "details": "Returns `true` if `account` has been granted `role`." + }, + "renounceRole(bytes32,address)": { + "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event." + }, + "revokeRole(bytes32,address)": { + "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event." + }, + "supportsInterface(bytes4)": { + "details": "See {IERC165-supportsInterface}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 6733, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_roles", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_bytes32,t_struct(RoleData)6728_storage)" + }, + { + "astId": 7043, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_roleMembers", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_struct(AddressSet)12153_storage)" + } + ], + "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_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_bytes32,t_struct(AddressSet)12153_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)12153_storage" + }, + "t_mapping(t_bytes32,t_struct(RoleData)6728_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct AccessControl.RoleData)", + "numberOfBytes": "32", + "value": "t_struct(RoleData)6728_storage" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)12153_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 12152, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)11838_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(RoleData)6728_storage": { + "encoding": "inplace", + "label": "struct AccessControl.RoleData", + "members": [ + { + "astId": 6725, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "members", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 6727, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "adminRole", + "offset": 0, + "slot": "1", + "type": "t_bytes32" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)11838_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 11833, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 11837, + "contract": "contracts/AccessRegistry.sol:AccessRegistry", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/deployments/scroll/Introspection.json b/deployments/scroll/Introspection.json new file mode 100644 index 0000000..3dc6929 --- /dev/null +++ b/deployments/scroll/Introspection.json @@ -0,0 +1,65 @@ +{ + "address": "0x238dee460551E42c7Ee1f08272a7536c14C12eE5", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes4[]", + "name": "interfaceIds", + "type": "bytes4[]" + } + ], + "name": "getSupportedInterfaces", + "outputs": [ + { + "internalType": "bool[]", + "name": "", + "type": "bool[]" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xf8df491e8e112025296f0dff8e2cec740d3d36892330b6b3ea6fee9232ac009c", + "receipt": { + "to": null, + "from": "0x6950Af4b7815c15073066C7540b1c64Fa7Be97F1", + "contractAddress": "0x238dee460551E42c7Ee1f08272a7536c14C12eE5", + "transactionIndex": 4, + "gasUsed": "290079", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x16b7c052160435fc121ef0aaa1107ee021f20b74075636b1547612b9d0e4752f", + "transactionHash": "0xf8df491e8e112025296f0dff8e2cec740d3d36892330b6b3ea6fee9232ac009c", + "logs": [], + "blockNumber": 7292240, + "cumulativeGasUsed": "943146", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "fccf71bfc76cbdc7bd823fe97c30d41c", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes4[]\",\"name\":\"interfaceIds\",\"type\":\"bytes4[]\"}],\"name\":\"getSupportedInterfaces\",\"outputs\":[{\"internalType\":\"bool[]\",\"name\":\"\",\"type\":\"bool[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Introspection.sol\":\"Introspection\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/introspection/ERC165Checker.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Library used to query support of an interface declared via {IERC165}.\\n *\\n * Note that these functions return the actual result of the query: they do not\\n * `revert` if an interface is not supported. It is up to the caller to decide\\n * what to do in these cases.\\n */\\nlibrary ERC165Checker {\\n // As per the EIP-165 spec, no interface should ever match 0xffffffff\\n bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\\n\\n /**\\n * @dev Returns true if `account` supports the {IERC165} interface.\\n */\\n function supportsERC165(address account) internal view returns (bool) {\\n // Any contract that implements ERC165 must explicitly indicate support of\\n // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\\n return\\n supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&\\n !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);\\n }\\n\\n /**\\n * @dev Returns true if `account` supports the interface defined by\\n * `interfaceId`. Support for {IERC165} itself is queried automatically.\\n *\\n * See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\\n // query support of both ERC165 as per the spec and support of _interfaceId\\n return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);\\n }\\n\\n /**\\n * @dev Returns a boolean array where each value corresponds to the\\n * interfaces passed in and whether they're supported or not. This allows\\n * you to batch check interfaces for a contract where your expectation\\n * is that some interfaces may not be supported.\\n *\\n * See {IERC165-supportsInterface}.\\n *\\n * _Available since v3.4._\\n */\\n function getSupportedInterfaces(\\n address account,\\n bytes4[] memory interfaceIds\\n ) internal view returns (bool[] memory) {\\n // an array of booleans corresponding to interfaceIds and whether they're supported or not\\n bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\\n\\n // query support of ERC165 itself\\n if (supportsERC165(account)) {\\n // query support of each interface in interfaceIds\\n for (uint256 i = 0; i < interfaceIds.length; i++) {\\n interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);\\n }\\n }\\n\\n return interfaceIdsSupported;\\n }\\n\\n /**\\n * @dev Returns true if `account` supports all the interfaces defined in\\n * `interfaceIds`. Support for {IERC165} itself is queried automatically.\\n *\\n * Batch-querying can lead to gas savings by skipping repeated checks for\\n * {IERC165} support.\\n *\\n * See {IERC165-supportsInterface}.\\n */\\n function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\\n // query support of ERC165 itself\\n if (!supportsERC165(account)) {\\n return false;\\n }\\n\\n // query support of each interface in interfaceIds\\n for (uint256 i = 0; i < interfaceIds.length; i++) {\\n if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {\\n return false;\\n }\\n }\\n\\n // all interfaces supported\\n return true;\\n }\\n\\n /**\\n * @notice Query if a contract implements an interface, does not check ERC165 support\\n * @param account The address of the contract to query for support of an interface\\n * @param interfaceId The interface identifier, as specified in ERC-165\\n * @return true if the contract at account indicates support of the interface with\\n * identifier interfaceId, false otherwise\\n * @dev Assumes that account contains a contract that supports ERC165, otherwise\\n * the behavior of this method is undefined. This precondition can be checked\\n * with {supportsERC165}.\\n *\\n * Some precompiled contracts will falsely indicate support for a given interface, so caution\\n * should be exercised when using this function.\\n *\\n * Interface identification is specified in ERC-165.\\n */\\n function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {\\n // prepare call\\n bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\\n\\n // perform static call\\n bool success;\\n uint256 returnSize;\\n uint256 returnValue;\\n assembly {\\n success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)\\n returnSize := returndatasize()\\n returnValue := mload(0x00)\\n }\\n\\n return success && returnSize >= 0x20 && returnValue > 0;\\n }\\n}\\n\",\"keccak256\":\"0x5a08ad61f4e82b8a3323562661a86fb10b10190848073fdc13d4ac43710ffba5\",\"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\"},\"contracts/Introspection.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\\\";\\n\\ncontract Introspection {\\n using ERC165Checker for address;\\n\\n function getSupportedInterfaces(\\n address account,\\n bytes4[] memory interfaceIds\\n ) public view returns (bool[] memory) {\\n require(account.code.length > 0, \\\"Introspection: account not a contract\\\");\\n\\n return account.getSupportedInterfaces(interfaceIds);\\n }\\n}\\n\",\"keccak256\":\"0xa0032c78e6ac2446b60a975f8e81357cca2fa7b505f1e8aed41b1e8a88329b43\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610448806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806377e6b4cc14610030575b600080fd5b61004361003e3660046102a8565b610059565b604051610050919061038f565b60405180910390f35b60606000836001600160a01b03163b116100c75760405162461bcd60e51b815260206004820152602560248201527f496e74726f7370656374696f6e3a206163636f756e74206e6f74206120636f6e6044820152641d1c9858dd60da1b606482015260840160405180910390fd5b6100da6001600160a01b038416836100e1565b9392505050565b60606000825167ffffffffffffffff81111561010d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610136578160200160208202803683370190505b509050610142846101ce565b156100da5760005b83518110156101c6576101848585838151811061017757634e487b7160e01b600052603260045260246000fd5b6020026020010151610202565b8282815181106101a457634e487b7160e01b600052603260045260246000fd5b91151560209283029190910190910152806101be816103d5565b91505061014a565b509392505050565b60006101e1826301ffc9a760e01b610202565b80156101fc57506101fa826001600160e01b0319610202565b155b92915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d91506000519050828015610274575060208210155b80156102805750600081115b979650505050505050565b80356001600160e01b0319811681146102a357600080fd5b919050565b600080604083850312156102ba578182fd5b82356001600160a01b03811681146102d0578283fd5b915060208381013567ffffffffffffffff808211156102ed578384fd5b818601915086601f830112610300578384fd5b813581811115610312576103126103fc565b8060051b604051601f19603f83011681018181108582111715610337576103376103fc565b604052828152858101935084860182860187018b1015610355578788fd5b8795505b8386101561037e5761036a8161028b565b855260019590950194938601938601610359565b508096505050505050509250929050565b6020808252825182820181905260009190848201906040850190845b818110156103c95783511515835292840192918401916001016103ab565b50909695505050505050565b60006000198214156103f557634e487b7160e01b81526011600452602481fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212203b01b8de7b6025f176c420a590d4c952574d8111b332fda18225e2670653f50964736f6c63430008040033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c806377e6b4cc14610030575b600080fd5b61004361003e3660046102a8565b610059565b604051610050919061038f565b60405180910390f35b60606000836001600160a01b03163b116100c75760405162461bcd60e51b815260206004820152602560248201527f496e74726f7370656374696f6e3a206163636f756e74206e6f74206120636f6e6044820152641d1c9858dd60da1b606482015260840160405180910390fd5b6100da6001600160a01b038416836100e1565b9392505050565b60606000825167ffffffffffffffff81111561010d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610136578160200160208202803683370190505b509050610142846101ce565b156100da5760005b83518110156101c6576101848585838151811061017757634e487b7160e01b600052603260045260246000fd5b6020026020010151610202565b8282815181106101a457634e487b7160e01b600052603260045260246000fd5b91151560209283029190910190910152806101be816103d5565b91505061014a565b509392505050565b60006101e1826301ffc9a760e01b610202565b80156101fc57506101fa826001600160e01b0319610202565b155b92915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d91506000519050828015610274575060208210155b80156102805750600081115b979650505050505050565b80356001600160e01b0319811681146102a357600080fd5b919050565b600080604083850312156102ba578182fd5b82356001600160a01b03811681146102d0578283fd5b915060208381013567ffffffffffffffff808211156102ed578384fd5b818601915086601f830112610300578384fd5b813581811115610312576103126103fc565b8060051b604051601f19603f83011681018181108582111715610337576103376103fc565b604052828152858101935084860182860187018b1015610355578788fd5b8795505b8386101561037e5761036a8161028b565b855260019590950194938601938601610359565b508096505050505050509250929050565b6020808252825182820181905260009190848201906040850190845b818110156103c95783511515835292840192918401916001016103ab565b50909695505050505050565b60006000198214156103f557634e487b7160e01b81526011600452602481fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212203b01b8de7b6025f176c420a590d4c952574d8111b332fda18225e2670653f50964736f6c63430008040033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/deployments/scroll/solcInputs/fccf71bfc76cbdc7bd823fe97c30d41c.json b/deployments/scroll/solcInputs/fccf71bfc76cbdc7bd823fe97c30d41c.json new file mode 100644 index 0000000..fe4143b --- /dev/null +++ b/deployments/scroll/solcInputs/fccf71bfc76cbdc7bd823fe97c30d41c.json @@ -0,0 +1,365 @@ +{ + "language": "Solidity", + "sources": { + "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarExecutable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IAxelarGateway } from './IAxelarGateway.sol';\n\ninterface IAxelarExecutable {\n error InvalidAddress();\n error NotApprovedByGateway();\n\n function gateway() external view returns (IAxelarGateway);\n\n function execute(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes calldata payload\n ) external;\n\n function executeWithToken(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes calldata payload,\n string calldata tokenSymbol,\n uint256 amount\n ) external;\n}\n" + }, + "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n// This should be owned by the microservice that is paying for gas.\ninterface IAxelarGasService {\n error NothingReceived();\n error InvalidAddress();\n error NotCollector();\n error InvalidAmounts();\n\n event GasPaidForContractCall(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event GasPaidForContractCallWithToken(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeGasPaidForContractCall(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeGasPaidForContractCallWithToken(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event GasPaidForExpressCallWithToken(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeGasPaidForExpressCallWithToken(\n address indexed sourceAddress,\n string destinationChain,\n string destinationAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event GasAdded(\n bytes32 indexed txHash,\n uint256 indexed logIndex,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeGasAdded(bytes32 indexed txHash, uint256 indexed logIndex, uint256 gasFeeAmount, address refundAddress);\n\n event ExpressGasAdded(\n bytes32 indexed txHash,\n uint256 indexed logIndex,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n event NativeExpressGasAdded(\n bytes32 indexed txHash,\n uint256 indexed logIndex,\n uint256 gasFeeAmount,\n address refundAddress\n );\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payGasForContractCall(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payGasForContractCallWithToken(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payNativeGasForContractCall(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n address refundAddress\n ) external payable;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payNativeGasForContractCallWithToken(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount,\n address refundAddress\n ) external payable;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payGasForExpressCallWithToken(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n // This is called on the source chain before calling the gateway to execute a remote contract.\n function payNativeGasForExpressCallWithToken(\n address sender,\n string calldata destinationChain,\n string calldata destinationAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount,\n address refundAddress\n ) external payable;\n\n function addGas(\n bytes32 txHash,\n uint256 txIndex,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n function addNativeGas(\n bytes32 txHash,\n uint256 logIndex,\n address refundAddress\n ) external payable;\n\n function addExpressGas(\n bytes32 txHash,\n uint256 txIndex,\n address gasToken,\n uint256 gasFeeAmount,\n address refundAddress\n ) external;\n\n function addNativeExpressGas(\n bytes32 txHash,\n uint256 logIndex,\n address refundAddress\n ) external payable;\n\n function collectFees(\n address payable receiver,\n address[] calldata tokens,\n uint256[] calldata amounts\n ) external;\n\n function refund(\n address payable receiver,\n address token,\n uint256 amount\n ) external;\n\n function gasCollector() external returns (address);\n}\n" + }, + "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IAxelarGateway {\n /**********\\\n |* Errors *|\n \\**********/\n\n error NotSelf();\n error NotProxy();\n error InvalidCodeHash();\n error SetupFailed();\n error InvalidAuthModule();\n error InvalidTokenDeployer();\n error InvalidAmount();\n error InvalidChainId();\n error InvalidCommands();\n error TokenDoesNotExist(string symbol);\n error TokenAlreadyExists(string symbol);\n error TokenDeployFailed(string symbol);\n error TokenContractDoesNotExist(address token);\n error BurnFailed(string symbol);\n error MintFailed(string symbol);\n error InvalidSetMintLimitsParams();\n error ExceedMintLimit(string symbol);\n\n /**********\\\n |* Events *|\n \\**********/\n\n event TokenSent(\n address indexed sender,\n string destinationChain,\n string destinationAddress,\n string symbol,\n uint256 amount\n );\n\n event ContractCall(\n address indexed sender,\n string destinationChain,\n string destinationContractAddress,\n bytes32 indexed payloadHash,\n bytes payload\n );\n\n event ContractCallWithToken(\n address indexed sender,\n string destinationChain,\n string destinationContractAddress,\n bytes32 indexed payloadHash,\n bytes payload,\n string symbol,\n uint256 amount\n );\n\n event Executed(bytes32 indexed commandId);\n\n event TokenDeployed(string symbol, address tokenAddresses);\n\n event ContractCallApproved(\n bytes32 indexed commandId,\n string sourceChain,\n string sourceAddress,\n address indexed contractAddress,\n bytes32 indexed payloadHash,\n bytes32 sourceTxHash,\n uint256 sourceEventIndex\n );\n\n event ContractCallApprovedWithMint(\n bytes32 indexed commandId,\n string sourceChain,\n string sourceAddress,\n address indexed contractAddress,\n bytes32 indexed payloadHash,\n string symbol,\n uint256 amount,\n bytes32 sourceTxHash,\n uint256 sourceEventIndex\n );\n\n event TokenMintLimitUpdated(string symbol, uint256 limit);\n\n event OperatorshipTransferred(bytes newOperatorsData);\n\n event Upgraded(address indexed implementation);\n\n /********************\\\n |* Public Functions *|\n \\********************/\n\n function sendToken(\n string calldata destinationChain,\n string calldata destinationAddress,\n string calldata symbol,\n uint256 amount\n ) external;\n\n function callContract(\n string calldata destinationChain,\n string calldata contractAddress,\n bytes calldata payload\n ) external;\n\n function callContractWithToken(\n string calldata destinationChain,\n string calldata contractAddress,\n bytes calldata payload,\n string calldata symbol,\n uint256 amount\n ) external;\n\n function isContractCallApproved(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n address contractAddress,\n bytes32 payloadHash\n ) external view returns (bool);\n\n function isContractCallAndMintApproved(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n address contractAddress,\n bytes32 payloadHash,\n string calldata symbol,\n uint256 amount\n ) external view returns (bool);\n\n function validateContractCall(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes32 payloadHash\n ) external returns (bool);\n\n function validateContractCallAndMint(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes32 payloadHash,\n string calldata symbol,\n uint256 amount\n ) external returns (bool);\n\n /***********\\\n |* Getters *|\n \\***********/\n\n function authModule() external view returns (address);\n\n function tokenDeployer() external view returns (address);\n\n function tokenMintLimit(string memory symbol) external view returns (uint256);\n\n function tokenMintAmount(string memory symbol) external view returns (uint256);\n\n function allTokensFrozen() external view returns (bool);\n\n function implementation() external view returns (address);\n\n function tokenAddresses(string memory symbol) external view returns (address);\n\n function tokenFrozen(string memory symbol) external view returns (bool);\n\n function isCommandExecuted(bytes32 commandId) external view returns (bool);\n\n function adminEpoch() external view returns (uint256);\n\n function adminThreshold(uint256 epoch) external view returns (uint256);\n\n function admins(uint256 epoch) external view returns (address[] memory);\n\n /*******************\\\n |* Admin Functions *|\n \\*******************/\n\n function setTokenMintLimits(string[] calldata symbols, uint256[] calldata limits) external;\n\n function upgrade(\n address newImplementation,\n bytes32 newImplementationCodeHash,\n bytes calldata setupParams\n ) external;\n\n /**********************\\\n |* External Functions *|\n \\**********************/\n\n function setup(bytes calldata params) external;\n\n function execute(bytes calldata input) external;\n}\n" + }, + "@chainlink/contracts/src/v0.8/Chainlink.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {CBORChainlink} from \"./vendor/CBORChainlink.sol\";\nimport {BufferChainlink} from \"./vendor/BufferChainlink.sol\";\n\n/**\n * @title Library for common Chainlink functions\n * @dev Uses imported CBOR library for encoding to buffer\n */\nlibrary Chainlink {\n uint256 internal constant defaultBufferSize = 256; // solhint-disable-line const-name-snakecase\n\n using CBORChainlink for BufferChainlink.buffer;\n\n struct Request {\n bytes32 id;\n address callbackAddress;\n bytes4 callbackFunctionId;\n uint256 nonce;\n BufferChainlink.buffer buf;\n }\n\n /**\n * @notice Initializes a Chainlink request\n * @dev Sets the ID, callback address, and callback function signature on the request\n * @param self The uninitialized request\n * @param jobId The Job Specification ID\n * @param callbackAddr The callback address\n * @param callbackFunc The callback function signature\n * @return The initialized request\n */\n function initialize(\n Request memory self,\n bytes32 jobId,\n address callbackAddr,\n bytes4 callbackFunc\n ) internal pure returns (Chainlink.Request memory) {\n BufferChainlink.init(self.buf, defaultBufferSize);\n self.id = jobId;\n self.callbackAddress = callbackAddr;\n self.callbackFunctionId = callbackFunc;\n return self;\n }\n\n /**\n * @notice Sets the data for the buffer without encoding CBOR on-chain\n * @dev CBOR can be closed with curly-brackets {} or they can be left off\n * @param self The initialized request\n * @param data The CBOR data\n */\n function setBuffer(Request memory self, bytes memory data) internal pure {\n BufferChainlink.init(self.buf, data.length);\n BufferChainlink.append(self.buf, data);\n }\n\n /**\n * @notice Adds a string value to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param value The string value to add\n */\n function add(\n Request memory self,\n string memory key,\n string memory value\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.encodeString(value);\n }\n\n /**\n * @notice Adds a bytes value to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param value The bytes value to add\n */\n function addBytes(\n Request memory self,\n string memory key,\n bytes memory value\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.encodeBytes(value);\n }\n\n /**\n * @notice Adds a int256 value to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param value The int256 value to add\n */\n function addInt(\n Request memory self,\n string memory key,\n int256 value\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.encodeInt(value);\n }\n\n /**\n * @notice Adds a uint256 value to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param value The uint256 value to add\n */\n function addUint(\n Request memory self,\n string memory key,\n uint256 value\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.encodeUInt(value);\n }\n\n /**\n * @notice Adds an array of strings to the request with a given key name\n * @param self The initialized request\n * @param key The name of the key\n * @param values The array of string values to add\n */\n function addStringArray(\n Request memory self,\n string memory key,\n string[] memory values\n ) internal pure {\n self.buf.encodeString(key);\n self.buf.startArray();\n for (uint256 i = 0; i < values.length; i++) {\n self.buf.encodeString(values[i]);\n }\n self.buf.endSequence();\n }\n}\n" + }, + "@chainlink/contracts/src/v0.8/ChainlinkClient.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./Chainlink.sol\";\nimport \"./interfaces/ENSInterface.sol\";\nimport \"./interfaces/LinkTokenInterface.sol\";\nimport \"./interfaces/ChainlinkRequestInterface.sol\";\nimport \"./interfaces/OperatorInterface.sol\";\nimport \"./interfaces/PointerInterface.sol\";\nimport {ENSResolver as ENSResolver_Chainlink} from \"./vendor/ENSResolver.sol\";\n\n/**\n * @title The ChainlinkClient contract\n * @notice Contract writers can inherit this contract in order to create requests for the\n * Chainlink network\n */\nabstract contract ChainlinkClient {\n using Chainlink for Chainlink.Request;\n\n uint256 internal constant LINK_DIVISIBILITY = 10**18;\n uint256 private constant AMOUNT_OVERRIDE = 0;\n address private constant SENDER_OVERRIDE = address(0);\n uint256 private constant ORACLE_ARGS_VERSION = 1;\n uint256 private constant OPERATOR_ARGS_VERSION = 2;\n bytes32 private constant ENS_TOKEN_SUBNAME = keccak256(\"link\");\n bytes32 private constant ENS_ORACLE_SUBNAME = keccak256(\"oracle\");\n address private constant LINK_TOKEN_POINTER = 0xC89bD4E1632D3A43CB03AAAd5262cbe4038Bc571;\n\n ENSInterface private s_ens;\n bytes32 private s_ensNode;\n LinkTokenInterface private s_link;\n OperatorInterface private s_oracle;\n uint256 private s_requestCount = 1;\n mapping(bytes32 => address) private s_pendingRequests;\n\n event ChainlinkRequested(bytes32 indexed id);\n event ChainlinkFulfilled(bytes32 indexed id);\n event ChainlinkCancelled(bytes32 indexed id);\n\n /**\n * @notice Creates a request that can hold additional parameters\n * @param specId The Job Specification ID that the request will be created for\n * @param callbackAddr address to operate the callback on\n * @param callbackFunctionSignature function signature to use for the callback\n * @return A Chainlink Request struct in memory\n */\n function buildChainlinkRequest(\n bytes32 specId,\n address callbackAddr,\n bytes4 callbackFunctionSignature\n ) internal pure returns (Chainlink.Request memory) {\n Chainlink.Request memory req;\n return req.initialize(specId, callbackAddr, callbackFunctionSignature);\n }\n\n /**\n * @notice Creates a request that can hold additional parameters\n * @param specId The Job Specification ID that the request will be created for\n * @param callbackFunctionSignature function signature to use for the callback\n * @return A Chainlink Request struct in memory\n */\n function buildOperatorRequest(bytes32 specId, bytes4 callbackFunctionSignature)\n internal\n view\n returns (Chainlink.Request memory)\n {\n Chainlink.Request memory req;\n return req.initialize(specId, address(this), callbackFunctionSignature);\n }\n\n /**\n * @notice Creates a Chainlink request to the stored oracle address\n * @dev Calls `chainlinkRequestTo` with the stored oracle address\n * @param req The initialized Chainlink Request\n * @param payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendChainlinkRequest(Chainlink.Request memory req, uint256 payment) internal returns (bytes32) {\n return sendChainlinkRequestTo(address(s_oracle), req, payment);\n }\n\n /**\n * @notice Creates a Chainlink request to the specified oracle address\n * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to\n * send LINK which creates a request on the target oracle contract.\n * Emits ChainlinkRequested event.\n * @param oracleAddress The address of the oracle for the request\n * @param req The initialized Chainlink Request\n * @param payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendChainlinkRequestTo(\n address oracleAddress,\n Chainlink.Request memory req,\n uint256 payment\n ) internal returns (bytes32 requestId) {\n uint256 nonce = s_requestCount;\n s_requestCount = nonce + 1;\n bytes memory encodedRequest = abi.encodeWithSelector(\n ChainlinkRequestInterface.oracleRequest.selector,\n SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address\n AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent\n req.id,\n address(this),\n req.callbackFunctionId,\n nonce,\n ORACLE_ARGS_VERSION,\n req.buf.buf\n );\n return _rawRequest(oracleAddress, nonce, payment, encodedRequest);\n }\n\n /**\n * @notice Creates a Chainlink request to the stored oracle address\n * @dev This function supports multi-word response\n * @dev Calls `sendOperatorRequestTo` with the stored oracle address\n * @param req The initialized Chainlink Request\n * @param payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendOperatorRequest(Chainlink.Request memory req, uint256 payment) internal returns (bytes32) {\n return sendOperatorRequestTo(address(s_oracle), req, payment);\n }\n\n /**\n * @notice Creates a Chainlink request to the specified oracle address\n * @dev This function supports multi-word response\n * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to\n * send LINK which creates a request on the target oracle contract.\n * Emits ChainlinkRequested event.\n * @param oracleAddress The address of the oracle for the request\n * @param req The initialized Chainlink Request\n * @param payment The amount of LINK to send for the request\n * @return requestId The request ID\n */\n function sendOperatorRequestTo(\n address oracleAddress,\n Chainlink.Request memory req,\n uint256 payment\n ) internal returns (bytes32 requestId) {\n uint256 nonce = s_requestCount;\n s_requestCount = nonce + 1;\n bytes memory encodedRequest = abi.encodeWithSelector(\n OperatorInterface.operatorRequest.selector,\n SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address\n AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent\n req.id,\n req.callbackFunctionId,\n nonce,\n OPERATOR_ARGS_VERSION,\n req.buf.buf\n );\n return _rawRequest(oracleAddress, nonce, payment, encodedRequest);\n }\n\n /**\n * @notice Make a request to an oracle\n * @param oracleAddress The address of the oracle for the request\n * @param nonce used to generate the request ID\n * @param payment The amount of LINK to send for the request\n * @param encodedRequest data encoded for request type specific format\n * @return requestId The request ID\n */\n function _rawRequest(\n address oracleAddress,\n uint256 nonce,\n uint256 payment,\n bytes memory encodedRequest\n ) private returns (bytes32 requestId) {\n requestId = keccak256(abi.encodePacked(this, nonce));\n s_pendingRequests[requestId] = oracleAddress;\n emit ChainlinkRequested(requestId);\n require(s_link.transferAndCall(oracleAddress, payment, encodedRequest), \"unable to transferAndCall to oracle\");\n }\n\n /**\n * @notice Allows a request to be cancelled if it has not been fulfilled\n * @dev Requires keeping track of the expiration value emitted from the oracle contract.\n * Deletes the request from the `pendingRequests` mapping.\n * Emits ChainlinkCancelled event.\n * @param requestId The request ID\n * @param payment The amount of LINK sent for the request\n * @param callbackFunc The callback function specified for the request\n * @param expiration The time of the expiration for the request\n */\n function cancelChainlinkRequest(\n bytes32 requestId,\n uint256 payment,\n bytes4 callbackFunc,\n uint256 expiration\n ) internal {\n OperatorInterface requested = OperatorInterface(s_pendingRequests[requestId]);\n delete s_pendingRequests[requestId];\n emit ChainlinkCancelled(requestId);\n requested.cancelOracleRequest(requestId, payment, callbackFunc, expiration);\n }\n\n /**\n * @notice the next request count to be used in generating a nonce\n * @dev starts at 1 in order to ensure consistent gas cost\n * @return returns the next request count to be used in a nonce\n */\n function getNextRequestCount() internal view returns (uint256) {\n return s_requestCount;\n }\n\n /**\n * @notice Sets the stored oracle address\n * @param oracleAddress The address of the oracle contract\n */\n function setChainlinkOracle(address oracleAddress) internal {\n s_oracle = OperatorInterface(oracleAddress);\n }\n\n /**\n * @notice Sets the LINK token address\n * @param linkAddress The address of the LINK token contract\n */\n function setChainlinkToken(address linkAddress) internal {\n s_link = LinkTokenInterface(linkAddress);\n }\n\n /**\n * @notice Sets the Chainlink token address for the public\n * network as given by the Pointer contract\n */\n function setPublicChainlinkToken() internal {\n setChainlinkToken(PointerInterface(LINK_TOKEN_POINTER).getAddress());\n }\n\n /**\n * @notice Retrieves the stored address of the LINK token\n * @return The address of the LINK token\n */\n function chainlinkTokenAddress() internal view returns (address) {\n return address(s_link);\n }\n\n /**\n * @notice Retrieves the stored address of the oracle contract\n * @return The address of the oracle contract\n */\n function chainlinkOracleAddress() internal view returns (address) {\n return address(s_oracle);\n }\n\n /**\n * @notice Allows for a request which was created on another contract to be fulfilled\n * on this contract\n * @param oracleAddress The address of the oracle contract that will fulfill the request\n * @param requestId The request ID used for the response\n */\n function addChainlinkExternalRequest(address oracleAddress, bytes32 requestId) internal notPendingRequest(requestId) {\n s_pendingRequests[requestId] = oracleAddress;\n }\n\n /**\n * @notice Sets the stored oracle and LINK token contracts with the addresses resolved by ENS\n * @dev Accounts for subnodes having different resolvers\n * @param ensAddress The address of the ENS contract\n * @param node The ENS node hash\n */\n function useChainlinkWithENS(address ensAddress, bytes32 node) internal {\n s_ens = ENSInterface(ensAddress);\n s_ensNode = node;\n bytes32 linkSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_TOKEN_SUBNAME));\n ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(linkSubnode));\n setChainlinkToken(resolver.addr(linkSubnode));\n updateChainlinkOracleWithENS();\n }\n\n /**\n * @notice Sets the stored oracle contract with the address resolved by ENS\n * @dev This may be called on its own as long as `useChainlinkWithENS` has been called previously\n */\n function updateChainlinkOracleWithENS() internal {\n bytes32 oracleSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_ORACLE_SUBNAME));\n ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(oracleSubnode));\n setChainlinkOracle(resolver.addr(oracleSubnode));\n }\n\n /**\n * @notice Ensures that the fulfillment is valid for this contract\n * @dev Use if the contract developer prefers methods instead of modifiers for validation\n * @param requestId The request ID for fulfillment\n */\n function validateChainlinkCallback(bytes32 requestId)\n internal\n recordChainlinkFulfillment(requestId)\n // solhint-disable-next-line no-empty-blocks\n {\n\n }\n\n /**\n * @dev Reverts if the sender is not the oracle of the request.\n * Emits ChainlinkFulfilled event.\n * @param requestId The request ID for fulfillment\n */\n modifier recordChainlinkFulfillment(bytes32 requestId) {\n require(msg.sender == s_pendingRequests[requestId], \"Source must be the oracle of the request\");\n delete s_pendingRequests[requestId];\n emit ChainlinkFulfilled(requestId);\n _;\n }\n\n /**\n * @dev Reverts if the request is already pending\n * @param requestId The request ID for fulfillment\n */\n modifier notPendingRequest(bytes32 requestId) {\n require(s_pendingRequests[requestId] == address(0), \"Request is already pending\");\n _;\n }\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/ChainlinkRequestInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ChainlinkRequestInterface {\n function oracleRequest(\n address sender,\n uint256 requestPrice,\n bytes32 serviceAgreementID,\n address callbackAddress,\n bytes4 callbackFunctionId,\n uint256 nonce,\n uint256 dataVersion,\n bytes calldata data\n ) external;\n\n function cancelOracleRequest(\n bytes32 requestId,\n uint256 payment,\n bytes4 callbackFunctionId,\n uint256 expiration\n ) external;\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/ENSInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ENSInterface {\n // Logged when the owner of a node assigns a new owner to a subnode.\n event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);\n\n // Logged when the owner of a node transfers ownership to a new account.\n event Transfer(bytes32 indexed node, address owner);\n\n // Logged when the resolver for a node changes.\n event NewResolver(bytes32 indexed node, address resolver);\n\n // Logged when the TTL of a node changes\n event NewTTL(bytes32 indexed node, uint64 ttl);\n\n function setSubnodeOwner(\n bytes32 node,\n bytes32 label,\n address owner\n ) external;\n\n function setResolver(bytes32 node, address resolver) external;\n\n function setOwner(bytes32 node, address owner) external;\n\n function setTTL(bytes32 node, uint64 ttl) external;\n\n function owner(bytes32 node) external view returns (address);\n\n function resolver(bytes32 node) external view returns (address);\n\n function ttl(bytes32 node) external view returns (uint64);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/LinkTokenInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface LinkTokenInterface {\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n function approve(address spender, uint256 value) external returns (bool success);\n\n function balanceOf(address owner) external view returns (uint256 balance);\n\n function decimals() external view returns (uint8 decimalPlaces);\n\n function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);\n\n function increaseApproval(address spender, uint256 subtractedValue) external;\n\n function name() external view returns (string memory tokenName);\n\n function symbol() external view returns (string memory tokenSymbol);\n\n function totalSupply() external view returns (uint256 totalTokensIssued);\n\n function transfer(address to, uint256 value) external returns (bool success);\n\n function transferAndCall(\n address to,\n uint256 value,\n bytes calldata data\n ) external returns (bool success);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool success);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/OperatorInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./OracleInterface.sol\";\nimport \"./ChainlinkRequestInterface.sol\";\n\ninterface OperatorInterface is OracleInterface, ChainlinkRequestInterface {\n function operatorRequest(\n address sender,\n uint256 payment,\n bytes32 specId,\n bytes4 callbackFunctionId,\n uint256 nonce,\n uint256 dataVersion,\n bytes calldata data\n ) external;\n\n function fulfillOracleRequest2(\n bytes32 requestId,\n uint256 payment,\n address callbackAddress,\n bytes4 callbackFunctionId,\n uint256 expiration,\n bytes calldata data\n ) external returns (bool);\n\n function ownerTransferAndCall(\n address to,\n uint256 value,\n bytes calldata data\n ) external returns (bool success);\n\n function distributeFunds(address payable[] calldata receivers, uint256[] calldata amounts) external payable;\n\n function getAuthorizedSenders() external returns (address[] memory);\n\n function setAuthorizedSenders(address[] calldata senders) external;\n\n function getForwarder() external returns (address);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/OracleInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface OracleInterface {\n function fulfillOracleRequest(\n bytes32 requestId,\n uint256 payment,\n address callbackAddress,\n bytes4 callbackFunctionId,\n uint256 expiration,\n bytes32 data\n ) external returns (bool);\n\n function isAuthorizedSender(address node) external view returns (bool);\n\n function withdraw(address recipient, uint256 amount) external;\n\n function withdrawable() external view returns (uint256);\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/PointerInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface PointerInterface {\n function getAddress() external view returns (address);\n}\n" + }, + "@chainlink/contracts/src/v0.8/vendor/BufferChainlink.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @dev A library for working with mutable byte buffers in Solidity.\n *\n * Byte buffers are mutable and expandable, and provide a variety of primitives\n * for writing to them. At any time you can fetch a bytes object containing the\n * current contents of the buffer. The bytes object should not be stored between\n * operations, as it may change due to resizing of the buffer.\n */\nlibrary BufferChainlink {\n /**\n * @dev Represents a mutable buffer. Buffers have a current value (buf) and\n * a capacity. The capacity may be longer than the current value, in\n * which case it can be extended without the need to allocate more memory.\n */\n struct buffer {\n bytes buf;\n uint256 capacity;\n }\n\n /**\n * @dev Initializes a buffer with an initial capacity.\n * @param buf The buffer to initialize.\n * @param capacity The number of bytes of space to allocate the buffer.\n * @return The buffer, for chaining.\n */\n function init(buffer memory buf, uint256 capacity) internal pure returns (buffer memory) {\n if (capacity % 32 != 0) {\n capacity += 32 - (capacity % 32);\n }\n // Allocate space for the buffer data\n buf.capacity = capacity;\n assembly {\n let ptr := mload(0x40)\n mstore(buf, ptr)\n mstore(ptr, 0)\n mstore(0x40, add(32, add(ptr, capacity)))\n }\n return buf;\n }\n\n /**\n * @dev Initializes a new buffer from an existing bytes object.\n * Changes to the buffer may mutate the original value.\n * @param b The bytes object to initialize the buffer with.\n * @return A new buffer.\n */\n function fromBytes(bytes memory b) internal pure returns (buffer memory) {\n buffer memory buf;\n buf.buf = b;\n buf.capacity = b.length;\n return buf;\n }\n\n function resize(buffer memory buf, uint256 capacity) private pure {\n bytes memory oldbuf = buf.buf;\n init(buf, capacity);\n append(buf, oldbuf);\n }\n\n function max(uint256 a, uint256 b) private pure returns (uint256) {\n if (a > b) {\n return a;\n }\n return b;\n }\n\n /**\n * @dev Sets buffer length to 0.\n * @param buf The buffer to truncate.\n * @return The original buffer, for chaining..\n */\n function truncate(buffer memory buf) internal pure returns (buffer memory) {\n assembly {\n let bufptr := mload(buf)\n mstore(bufptr, 0)\n }\n return buf;\n }\n\n /**\n * @dev Writes a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The start offset to write to.\n * @param data The data to append.\n * @param len The number of bytes to copy.\n * @return The original buffer, for chaining.\n */\n function write(\n buffer memory buf,\n uint256 off,\n bytes memory data,\n uint256 len\n ) internal pure returns (buffer memory) {\n require(len <= data.length);\n\n if (off + len > buf.capacity) {\n resize(buf, max(buf.capacity, len + off) * 2);\n }\n\n uint256 dest;\n uint256 src;\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Length of existing buffer data\n let buflen := mload(bufptr)\n // Start address = buffer address + offset + sizeof(buffer length)\n dest := add(add(bufptr, 32), off)\n // Update buffer length if we're extending it\n if gt(add(len, off), buflen) {\n mstore(bufptr, add(len, off))\n }\n src := add(data, 32)\n }\n\n // Copy word-length chunks while possible\n for (; len >= 32; len -= 32) {\n assembly {\n mstore(dest, mload(src))\n }\n dest += 32;\n src += 32;\n }\n\n // Copy remaining bytes\n unchecked {\n uint256 mask = (256**(32 - len)) - 1;\n assembly {\n let srcpart := and(mload(src), not(mask))\n let destpart := and(mload(dest), mask)\n mstore(dest, or(destpart, srcpart))\n }\n }\n\n return buf;\n }\n\n /**\n * @dev Appends a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @param len The number of bytes to copy.\n * @return The original buffer, for chaining.\n */\n function append(\n buffer memory buf,\n bytes memory data,\n uint256 len\n ) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, data, len);\n }\n\n /**\n * @dev Appends a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, data, data.length);\n }\n\n /**\n * @dev Writes a byte to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write the byte at.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function writeUint8(\n buffer memory buf,\n uint256 off,\n uint8 data\n ) internal pure returns (buffer memory) {\n if (off >= buf.capacity) {\n resize(buf, buf.capacity * 2);\n }\n\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Length of existing buffer data\n let buflen := mload(bufptr)\n // Address = buffer address + sizeof(buffer length) + off\n let dest := add(add(bufptr, off), 32)\n mstore8(dest, data)\n // Update buffer length if we extended it\n if eq(off, buflen) {\n mstore(bufptr, add(buflen, 1))\n }\n }\n return buf;\n }\n\n /**\n * @dev Appends a byte to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function appendUint8(buffer memory buf, uint8 data) internal pure returns (buffer memory) {\n return writeUint8(buf, buf.buf.length, data);\n }\n\n /**\n * @dev Writes up to 32 bytes to the buffer. Resizes if doing so would\n * exceed the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write at.\n * @param data The data to append.\n * @param len The number of bytes to write (left-aligned).\n * @return The original buffer, for chaining.\n */\n function write(\n buffer memory buf,\n uint256 off,\n bytes32 data,\n uint256 len\n ) private pure returns (buffer memory) {\n if (len + off > buf.capacity) {\n resize(buf, (len + off) * 2);\n }\n\n unchecked {\n uint256 mask = (256**len) - 1;\n // Right-align data\n data = data >> (8 * (32 - len));\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Address = buffer address + sizeof(buffer length) + off + len\n let dest := add(add(bufptr, off), len)\n mstore(dest, or(and(mload(dest), not(mask)), data))\n // Update buffer length if we extended it\n if gt(add(off, len), mload(bufptr)) {\n mstore(bufptr, add(off, len))\n }\n }\n }\n return buf;\n }\n\n /**\n * @dev Writes a bytes20 to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write at.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function writeBytes20(\n buffer memory buf,\n uint256 off,\n bytes20 data\n ) internal pure returns (buffer memory) {\n return write(buf, off, bytes32(data), 20);\n }\n\n /**\n * @dev Appends a bytes20 to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chhaining.\n */\n function appendBytes20(buffer memory buf, bytes20 data) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, bytes32(data), 20);\n }\n\n /**\n * @dev Appends a bytes32 to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function appendBytes32(buffer memory buf, bytes32 data) internal pure returns (buffer memory) {\n return write(buf, buf.buf.length, data, 32);\n }\n\n /**\n * @dev Writes an integer to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param off The offset to write at.\n * @param data The data to append.\n * @param len The number of bytes to write (right-aligned).\n * @return The original buffer, for chaining.\n */\n function writeInt(\n buffer memory buf,\n uint256 off,\n uint256 data,\n uint256 len\n ) private pure returns (buffer memory) {\n if (len + off > buf.capacity) {\n resize(buf, (len + off) * 2);\n }\n\n uint256 mask = (256**len) - 1;\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Address = buffer address + off + sizeof(buffer length) + len\n let dest := add(add(bufptr, off), len)\n mstore(dest, or(and(mload(dest), not(mask)), data))\n // Update buffer length if we extended it\n if gt(add(off, len), mload(bufptr)) {\n mstore(bufptr, add(off, len))\n }\n }\n return buf;\n }\n\n /**\n * @dev Appends a byte to the end of the buffer. Resizes if doing so would\n * exceed the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer.\n */\n function appendInt(\n buffer memory buf,\n uint256 data,\n uint256 len\n ) internal pure returns (buffer memory) {\n return writeInt(buf, buf.buf.length, data, len);\n }\n}\n" + }, + "@chainlink/contracts/src/v0.8/vendor/CBORChainlink.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.19;\n\nimport {BufferChainlink} from \"./BufferChainlink.sol\";\n\nlibrary CBORChainlink {\n using BufferChainlink for BufferChainlink.buffer;\n\n uint8 private constant MAJOR_TYPE_INT = 0;\n uint8 private constant MAJOR_TYPE_NEGATIVE_INT = 1;\n uint8 private constant MAJOR_TYPE_BYTES = 2;\n uint8 private constant MAJOR_TYPE_STRING = 3;\n uint8 private constant MAJOR_TYPE_ARRAY = 4;\n uint8 private constant MAJOR_TYPE_MAP = 5;\n uint8 private constant MAJOR_TYPE_TAG = 6;\n uint8 private constant MAJOR_TYPE_CONTENT_FREE = 7;\n\n uint8 private constant TAG_TYPE_BIGNUM = 2;\n uint8 private constant TAG_TYPE_NEGATIVE_BIGNUM = 3;\n\n function encodeFixedNumeric(BufferChainlink.buffer memory buf, uint8 major, uint64 value) private pure {\n if(value <= 23) {\n buf.appendUint8(uint8((major << 5) | value));\n } else if (value <= 0xFF) {\n buf.appendUint8(uint8((major << 5) | 24));\n buf.appendInt(value, 1);\n } else if (value <= 0xFFFF) {\n buf.appendUint8(uint8((major << 5) | 25));\n buf.appendInt(value, 2);\n } else if (value <= 0xFFFFFFFF) {\n buf.appendUint8(uint8((major << 5) | 26));\n buf.appendInt(value, 4);\n } else {\n buf.appendUint8(uint8((major << 5) | 27));\n buf.appendInt(value, 8);\n }\n }\n\n function encodeIndefiniteLengthType(BufferChainlink.buffer memory buf, uint8 major) private pure {\n buf.appendUint8(uint8((major << 5) | 31));\n }\n\n function encodeUInt(BufferChainlink.buffer memory buf, uint value) internal pure {\n if(value > 0xFFFFFFFFFFFFFFFF) {\n encodeBigNum(buf, value);\n } else {\n encodeFixedNumeric(buf, MAJOR_TYPE_INT, uint64(value));\n }\n }\n\n function encodeInt(BufferChainlink.buffer memory buf, int value) internal pure {\n if(value < -0x10000000000000000) {\n encodeSignedBigNum(buf, value);\n } else if(value > 0xFFFFFFFFFFFFFFFF) {\n encodeBigNum(buf, uint(value));\n } else if(value >= 0) {\n encodeFixedNumeric(buf, MAJOR_TYPE_INT, uint64(uint256(value)));\n } else {\n encodeFixedNumeric(buf, MAJOR_TYPE_NEGATIVE_INT, uint64(uint256(-1 - value)));\n }\n }\n\n function encodeBytes(BufferChainlink.buffer memory buf, bytes memory value) internal pure {\n encodeFixedNumeric(buf, MAJOR_TYPE_BYTES, uint64(value.length));\n buf.append(value);\n }\n\n function encodeBigNum(BufferChainlink.buffer memory buf, uint value) internal pure {\n buf.appendUint8(uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_BIGNUM));\n encodeBytes(buf, abi.encode(value));\n }\n\n function encodeSignedBigNum(BufferChainlink.buffer memory buf, int input) internal pure {\n buf.appendUint8(uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_NEGATIVE_BIGNUM));\n encodeBytes(buf, abi.encode(uint256(-1 - input)));\n }\n\n function encodeString(BufferChainlink.buffer memory buf, string memory value) internal pure {\n encodeFixedNumeric(buf, MAJOR_TYPE_STRING, uint64(bytes(value).length));\n buf.append(bytes(value));\n }\n\n function startArray(BufferChainlink.buffer memory buf) internal pure {\n encodeIndefiniteLengthType(buf, MAJOR_TYPE_ARRAY);\n }\n\n function startMap(BufferChainlink.buffer memory buf) internal pure {\n encodeIndefiniteLengthType(buf, MAJOR_TYPE_MAP);\n }\n\n function endSequence(BufferChainlink.buffer memory buf) internal pure {\n encodeIndefiniteLengthType(buf, MAJOR_TYPE_CONTENT_FREE);\n }\n}\n" + }, + "@chainlink/contracts/src/v0.8/vendor/ENSResolver.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nabstract contract ENSResolver {\n function addr(bytes32 node) public view virtual returns (address);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlUpgradeable.sol\";\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../utils/StringsUpgradeable.sol\";\nimport \"../utils/introspection/ERC165Upgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n StringsUpgradeable.toHexString(account),\n \" is missing role \",\n StringsUpgradeable.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControlUpgradeable {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (security/PullPayment.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/escrow/EscrowUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Simple implementation of a\n * https://consensys.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls[pull-payment]\n * strategy, where the paying contract doesn't interact directly with the\n * receiver account, which must withdraw its payments itself.\n *\n * Pull-payments are often considered the best practice when it comes to sending\n * Ether, security-wise. It prevents recipients from blocking execution, and\n * eliminates reentrancy concerns.\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 *\n * To use, derive from the `PullPayment` contract, and use {_asyncTransfer}\n * instead of Solidity's `transfer` function. Payees can query their due\n * payments with {payments}, and retrieve them with {withdrawPayments}.\n *\n * @custom:storage-size 51\n */\nabstract contract PullPaymentUpgradeable is Initializable {\n EscrowUpgradeable private _escrow;\n\n function __PullPayment_init() internal onlyInitializing {\n __PullPayment_init_unchained();\n }\n\n function __PullPayment_init_unchained() internal onlyInitializing {\n _escrow = new EscrowUpgradeable();\n _escrow.initialize();\n }\n\n /**\n * @dev Withdraw accumulated payments, forwarding all gas to the recipient.\n *\n * Note that _any_ account can call this function, not just the `payee`.\n * This means that contracts unaware of the `PullPayment` protocol can still\n * receive funds this way, by having a separate account call\n * {withdrawPayments}.\n *\n * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.\n * Make sure you trust the recipient, or are either following the\n * checks-effects-interactions pattern or using {ReentrancyGuard}.\n *\n * @param payee Whose payments will be withdrawn.\n *\n * Causes the `escrow` to emit a {Withdrawn} event.\n */\n function withdrawPayments(address payable payee) public virtual {\n _escrow.withdraw(payee);\n }\n\n /**\n * @dev Returns the payments owed to an address.\n * @param dest The creditor's address.\n */\n function payments(address dest) public view returns (uint256) {\n return _escrow.depositsOf(dest);\n }\n\n /**\n * @dev Called by the payer to store the sent amount as credit to be pulled.\n * Funds sent in this way are stored in an intermediate {Escrow} contract, so\n * there is no danger of them being spent before withdrawal.\n *\n * @param dest The destination address of the funds.\n * @param amount The amount to transfer.\n *\n * Causes the `escrow` to emit a {Deposited} event.\n */\n function _asyncTransfer(address dest, uint256 amount) internal virtual {\n _escrow.deposit{value: amount}(dest);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n using AddressUpgradeable for address;\n using StringsUpgradeable for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC721_init_unchained(name_, symbol_);\n }\n\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n return\n interfaceId == type(IERC721Upgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\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 * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\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 `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 _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\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 _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721Upgradeable.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\n *\n * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant\n * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such\n * that `ownerOf(tokenId)` is `a`.\n */\n // solhint-disable-next-line func-name-mixedcase\n function __unsafe_increaseBalance(address account, uint256 amount) internal {\n _balances[account] += amount;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[44] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721EnumerableUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.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 IERC721ReceiverUpgradeable {\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-upgradeable/token/ERC721/IERC721Upgradeable.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/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\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-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/Base64Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.6) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64Upgradeable {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 0x20)\n let dataPtr := data\n let endPtr := add(data, mload(data))\n\n // In some cases, the last iteration will read bytes after the end of the data. We cache the value, and\n // set it to zero to make sure no dirty bytes are read in that section.\n let afterPtr := add(endPtr, 0x20)\n let afterCache := mload(afterPtr)\n mstore(afterPtr, 0x00)\n\n // Run over the input, 3 bytes at a time\n for {\n\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 byte (24 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F to bitmask the least significant 6 bits.\n // Use this as an index into the lookup table, mload an entire word\n // so the desired character is in the least significant byte, and\n // mstore8 this least significant byte into the result and continue.\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // Reset the value that was cached\n mstore(afterPtr, afterCache)\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/escrow/EscrowUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/escrow/Escrow.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../access/OwnableUpgradeable.sol\";\nimport \"../AddressUpgradeable.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @title Escrow\n * @dev Base escrow contract, holds funds designated for a payee until they\n * withdraw them.\n *\n * Intended usage: This contract (and derived escrow contracts) should be a\n * standalone contract, that only interacts with the contract that instantiated\n * it. That way, it is guaranteed that all Ether will be handled according to\n * the `Escrow` rules, and there is no need to check for payable functions or\n * transfers in the inheritance tree. The contract that uses the escrow as its\n * payment method should be its owner, and provide public methods redirecting\n * to the escrow's deposit and withdraw.\n */\ncontract EscrowUpgradeable is Initializable, OwnableUpgradeable {\n using AddressUpgradeable for address payable;\n\n event Deposited(address indexed payee, uint256 weiAmount);\n event Withdrawn(address indexed payee, uint256 weiAmount);\n\n mapping(address => uint256) private _deposits;\n\n function __Escrow_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Escrow_init_unchained() internal onlyInitializing {\n }\n function initialize() public virtual initializer {\n __Escrow_init();\n }\n function depositsOf(address payee) public view returns (uint256) {\n return _deposits[payee];\n }\n\n /**\n * @dev Stores the sent amount as credit to be withdrawn.\n * @param payee The destination address of the funds.\n *\n * Emits a {Deposited} event.\n */\n function deposit(address payee) public payable virtual onlyOwner {\n uint256 amount = msg.value;\n _deposits[payee] += amount;\n emit Deposited(payee, amount);\n }\n\n /**\n * @dev Withdraw accumulated balance for a payee, forwarding all gas to the\n * recipient.\n *\n * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.\n * Make sure you trust the recipient, or are either following the\n * checks-effects-interactions pattern or using {ReentrancyGuard}.\n *\n * @param payee The address whose funds will be withdrawn and transferred to.\n *\n * Emits a {Withdrawn} event.\n */\n function withdraw(address payable payee) public virtual onlyOwner {\n uint256 payment = _deposits[payee];\n\n _deposits[payee] = 0;\n\n payee.sendValue(payment);\n\n emit Withdrawn(payee, payment);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.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 IERC165Upgradeable {\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-upgradeable/utils/math/MathUpgradeable.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 MathUpgradeable {\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" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.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 SignedMathUpgradeable {\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" + }, + "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.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/MathUpgradeable.sol\";\nimport \"./math/SignedMathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\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 = MathUpgradeable.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(SignedMathUpgradeable.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, MathUpgradeable.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" + }, + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n" + }, + "@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/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(address from, address to, uint256 amount) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\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/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\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 * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\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 `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 _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\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 _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\n *\n * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant\n * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such\n * that `ownerOf(tokenId)` is `a`.\n */\n // solhint-disable-next-line func-name-mixedcase\n function __unsafe_increaseBalance(address account, uint256 amount) internal {\n _balances[account] += amount;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\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/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Base64.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.6) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 0x20)\n let dataPtr := data\n let endPtr := add(data, mload(data))\n\n // In some cases, the last iteration will read bytes after the end of the data. We cache the value, and\n // set it to zero to make sure no dirty bytes are read in that section.\n let afterPtr := add(endPtr, 0x20)\n let afterCache := mload(afterPtr)\n mstore(afterPtr, 0x00)\n\n // Run over the input, 3 bytes at a time\n for {\n\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 byte (24 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F to bitmask the least significant 6 bits.\n // Use this as an index into the lookup table, mload an entire word\n // so the desired character is in the least significant byte, and\n // mstore8 this least significant byte into the result and continue.\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // Reset the value that was cached\n mstore(afterPtr, afterCache)\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\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" + }, + "@openzeppelin/contracts/utils/Counters.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@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/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/introspection/ERC165Checker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Library used to query support of an interface declared via {IERC165}.\n *\n * Note that these functions return the actual result of the query: they do not\n * `revert` if an interface is not supported. It is up to the caller to decide\n * what to do in these cases.\n */\nlibrary ERC165Checker {\n // As per the EIP-165 spec, no interface should ever match 0xffffffff\n bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\n\n /**\n * @dev Returns true if `account` supports the {IERC165} interface.\n */\n function supportsERC165(address account) internal view returns (bool) {\n // Any contract that implements ERC165 must explicitly indicate support of\n // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\n return\n supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&\n !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);\n }\n\n /**\n * @dev Returns true if `account` supports the interface defined by\n * `interfaceId`. Support for {IERC165} itself is queried automatically.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\n // query support of both ERC165 as per the spec and support of _interfaceId\n return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);\n }\n\n /**\n * @dev Returns a boolean array where each value corresponds to the\n * interfaces passed in and whether they're supported or not. This allows\n * you to batch check interfaces for a contract where your expectation\n * is that some interfaces may not be supported.\n *\n * See {IERC165-supportsInterface}.\n *\n * _Available since v3.4._\n */\n function getSupportedInterfaces(\n address account,\n bytes4[] memory interfaceIds\n ) internal view returns (bool[] memory) {\n // an array of booleans corresponding to interfaceIds and whether they're supported or not\n bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\n\n // query support of ERC165 itself\n if (supportsERC165(account)) {\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);\n }\n }\n\n return interfaceIdsSupported;\n }\n\n /**\n * @dev Returns true if `account` supports all the interfaces defined in\n * `interfaceIds`. Support for {IERC165} itself is queried automatically.\n *\n * Batch-querying can lead to gas savings by skipping repeated checks for\n * {IERC165} support.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\n // query support of ERC165 itself\n if (!supportsERC165(account)) {\n return false;\n }\n\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {\n return false;\n }\n }\n\n // all interfaces supported\n return true;\n }\n\n /**\n * @notice Query if a contract implements an interface, does not check ERC165 support\n * @param account The address of the contract to query for support of an interface\n * @param interfaceId The interface identifier, as specified in ERC-165\n * @return true if the contract at account indicates support of the interface with\n * identifier interfaceId, false otherwise\n * @dev Assumes that account contains a contract that supports ERC165, otherwise\n * the behavior of this method is undefined. This precondition can be checked\n * with {supportsERC165}.\n *\n * Some precompiled contracts will falsely indicate support for a given interface, so caution\n * should be exercised when using this function.\n *\n * Interface identification is specified in ERC-165.\n */\n function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {\n // prepare call\n bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\n\n // perform static call\n bool success;\n uint256 returnSize;\n uint256 returnValue;\n assembly {\n success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)\n returnSize := returndatasize()\n returnValue := mload(0x00)\n }\n\n return success && returnSize >= 0x20 && returnValue > 0;\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" + }, + "@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" + }, + "@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" + }, + "@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/AccessRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\n\ncontract AccessRegistry is AccessControlEnumerable {\n constructor() {\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n}\n" + }, + "contracts/ChainlinkRequest.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@chainlink/contracts/src/v0.8/ChainlinkClient.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\ncontract ChainlinkRequest is ChainlinkClient, Ownable {\n using Chainlink for Chainlink.Request;\n\n bytes32 private _jobId;\n uint256 private _fee;\n string private _url;\n\n struct PendingRequest {\n address sender;\n bytes4 selector;\n bytes state;\n }\n mapping(bytes32 => PendingRequest) private _pendingRequests;\n\n function config()\n public\n view\n returns (\n address chainlinkToken,\n address chainlinkOracle,\n bytes32 jobId,\n uint256 fee,\n string memory url\n )\n {\n return (\n chainlinkTokenAddress(),\n chainlinkOracleAddress(),\n _jobId,\n _fee,\n _url\n );\n }\n\n function configure(\n address chainlinkToken,\n address chainlinkOracle,\n bytes32 jobId,\n uint256 fee,\n string memory url\n ) public onlyOwner {\n setChainlinkToken(chainlinkToken);\n setChainlinkOracle(chainlinkOracle);\n\n _jobId = jobId;\n _fee = fee;\n _url = url;\n }\n\n function requestBytes(bytes4 selector, bytes memory state)\n public\n returns (bytes32 requestId)\n {\n uint256 selector_;\n assembly {\n let ptr := mload(0x40)\n calldatacopy(ptr, 4, 4)\n selector_ := shr(224, mload(ptr))\n }\n\n Chainlink.Request memory req = buildChainlinkRequest(\n _jobId,\n address(this),\n this.fulfillBytes.selector\n );\n req.add(\n \"get\",\n string(\n abi.encodePacked(\n _url,\n \"&sender=\",\n Strings.toHexString(uint256(uint160(msg.sender)), 20),\n \"&selector=\",\n Strings.toHexString(selector_, 4),\n \"&state=\",\n Base64.encode(state)\n )\n )\n );\n req.add(\"path\", \"data\");\n requestId = sendChainlinkRequest(req, _fee);\n\n _pendingRequests[requestId] = PendingRequest({\n sender: msg.sender,\n selector: selector,\n state: state\n });\n return requestId;\n }\n\n function fulfillBytes(bytes32 requestId, bytes memory bytesData)\n public\n recordChainlinkFulfillment(requestId)\n {\n PendingRequest memory pendingRequest = _pendingRequests[requestId];\n\n (bool success, bytes memory result) = pendingRequest.sender.call(\n abi.encodeWithSelector(\n pendingRequest.selector,\n pendingRequest.state,\n bytesData\n )\n );\n if (!success) {\n if (result.length > 0) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n } else {\n revert(\"ChainlinkRequest: callback failed\");\n }\n }\n\n delete _pendingRequests[requestId];\n }\n\n function withdrawLink(address to) public onlyOwner {\n LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());\n require(\n link.transfer(to, link.balanceOf(address(this))),\n \"ChainlinkRequest: unable to transfer\"\n );\n }\n}\n" + }, + "contracts/ERC20Mint.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract ERC20Mint is ERC20 {\n constructor(string memory name, string memory symbol, address owner, uint256 initialSupply) ERC20(name, symbol) {\n _mint(owner, initialSupply);\n }\n}\n" + }, + "contracts/ERC721CollectionV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"./rarible/LibPart.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\nbytes4 constant ERC2981_INTERFACE_ID = 0x2a55205a;\nbytes4 constant RaribleRoyaltiesV2_INTERFACE_ID = 0xcad96cca;\n\ncontract OwnableDelegateProxy {}\n\ncontract ProxyRegistry {\n mapping(address => OwnableDelegateProxy) public proxies;\n}\n\ncontract ERC721CollectionV1 is ERC165, ERC721, Ownable {\n address private _proxyRegistryAddress;\n address private _creator;\n uint96 private _royalty;\n string private _baseTokenURI;\n uint256 private _totalSupply;\n\n constructor(\n string memory name,\n string memory symbol,\n address proxyRegistryAddress,\n address creator,\n uint96 royalty,\n string memory baseTokenURI,\n uint256 totalSupply_\n ) ERC721(name, symbol) {\n _transferOwnership(creator);\n\n _proxyRegistryAddress = proxyRegistryAddress;\n _creator = creator;\n _royalty = royalty;\n _baseTokenURI = baseTokenURI;\n _totalSupply = totalSupply_;\n\n for (uint256 tokenId; tokenId < totalSupply_; tokenId++) {\n _mint(creator, tokenId);\n }\n }\n\n function _baseURI() internal view virtual override returns (string memory) {\n return _baseTokenURI;\n }\n\n function getRaribleV2Royalties(uint256)\n external\n view\n returns (LibPart.Part[] memory)\n {\n LibPart.Part[] memory result;\n if (_royalty == 0) {\n return result;\n }\n\n result = new LibPart.Part[](1);\n result[0].account = payable(_creator);\n result[0].value = _royalty;\n return result;\n }\n\n function isApprovedForAll(address owner, address operator)\n public\n view\n override\n returns (bool)\n {\n // Whitelist OpenSea proxy contract for easy trading.\n ProxyRegistry proxyRegistry = ProxyRegistry(_proxyRegistryAddress);\n if (address(proxyRegistry.proxies(owner)) == operator) {\n return true;\n }\n\n return super.isApprovedForAll(owner, operator);\n }\n\n function royaltyInfo(uint256, uint256 price)\n external\n view\n returns (address receiver, uint256 royaltyAmount)\n {\n if (_royalty == 0) {\n return (address(0), 0);\n }\n\n return (_creator, (price * _royalty) / 10000);\n }\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC165, ERC721)\n returns (bool)\n {\n return\n interfaceId == ERC2981_INTERFACE_ID ||\n interfaceId == RaribleRoyaltiesV2_INTERFACE_ID ||\n super.supportsInterface(interfaceId);\n }\n\n function totalSupply() public view returns (uint256) {\n return _totalSupply;\n }\n}\n" + }, + "contracts/ERC721LemonadeV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./rarible/LibPart.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\nbytes4 constant ERC2981_INTERFACE_ID = 0x2a55205a;\nbytes4 constant RaribleRoyaltiesV2_INTERFACE_ID = 0xcad96cca;\n\ninterface IMintable {\n function mintToCaller(string memory tokenURI) external returns (uint256);\n\n function mintToCallerWithRoyalty(\n string memory tokenURI,\n LibPart.Part[] memory royalties\n ) external returns (uint256);\n}\n\ncontract ERC721LemonadeV1 is ERC721, Ownable, IMintable {\n using Counters for Counters.Counter;\n\n Counters.Counter public tokenIdTracker;\n\n mapping(uint256 => string) public tokenURIs;\n mapping(uint256 => LibPart.Part[]) public royalties;\n\n constructor(string memory name, string memory symbol)\n ERC721(name, symbol)\n {}\n\n function mintToCaller(string memory tokenURI_)\n public\n override\n returns (uint256)\n {\n uint256 tokenId = tokenIdTracker.current();\n\n _mint(_msgSender(), tokenId);\n tokenURIs[tokenId] = tokenURI_;\n\n tokenIdTracker.increment();\n\n return tokenId;\n }\n\n function mintToCallerWithRoyalty(\n string memory tokenURI_,\n LibPart.Part[] memory royalties_\n ) public override returns (uint256) {\n uint256 tokenId = mintToCaller(tokenURI_);\n\n uint256 length = royalties_.length;\n for (uint256 i; i < length; ) {\n royalties[tokenId].push(royalties_[i]);\n unchecked {\n ++i;\n }\n }\n\n return tokenId;\n }\n\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n require(\n _exists(tokenId),\n \"ERC721Lemonade: URI query for nonexistent token\"\n );\n\n return tokenURIs[tokenId];\n }\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override\n returns (bool)\n {\n return\n interfaceId == ERC2981_INTERFACE_ID ||\n interfaceId == RaribleRoyaltiesV2_INTERFACE_ID ||\n super.supportsInterface(interfaceId);\n }\n\n function getRaribleV2Royalties(uint256 tokenId)\n public\n view\n returns (LibPart.Part[] memory)\n {\n return royalties[tokenId];\n }\n\n function royaltyInfo(uint256 tokenId, uint256 price)\n public\n view\n returns (address receiver, uint256 royaltyAmount)\n {\n uint256 length = royalties[tokenId].length;\n\n if (length == 0) {\n return (address(0), 0);\n }\n\n uint256 totalValue;\n for (uint256 i; i < length; i++) {\n totalValue += royalties[tokenId][i].value;\n }\n return (royalties[tokenId][0].account, (price * totalValue) / 10000);\n }\n}\n" + }, + "contracts/ERC721LemonadeV1Ethereum.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ERC721LemonadeV1.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract OwnableDelegateProxy {}\n\ncontract ProxyRegistry {\n mapping(address => OwnableDelegateProxy) public proxies;\n}\n\ncontract ERC721LemonadeV1Ethereum is ERC721LemonadeV1 {\n address private _proxyRegistryAddress;\n\n constructor(\n string memory name,\n string memory symbol,\n address proxyRegistryAddress\n ) ERC721LemonadeV1(name, symbol) {\n _proxyRegistryAddress = proxyRegistryAddress;\n }\n\n function isApprovedForAll(address owner, address operator)\n public\n view\n override\n returns (bool)\n {\n // Whitelist OpenSea proxy contract for easy trading.\n ProxyRegistry proxyRegistry = ProxyRegistry(_proxyRegistryAddress);\n if (address(proxyRegistry.proxies(owner)) == operator) {\n return true;\n }\n\n return super.isApprovedForAll(owner, operator);\n }\n}\n" + }, + "contracts/ERC721LemonadeV1Forwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ERC721LemonadeV1.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract ERC721LemonadeV1Forwardable is ERC721LemonadeV1, RelayRecipient {\n constructor(\n string memory name,\n string memory symbol,\n address trustedForwarder\n ) ERC721LemonadeV1(name, symbol) RelayRecipient(trustedForwarder) {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n}\n" + }, + "contracts/FestivalHeadsV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./AccessRegistry.sol\";\nimport \"./ChainlinkRequest.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\nbytes32 constant FESTIVAL_HEADS_OPERATOR_ROLE = keccak256(\n \"FESTIVAL_HEADS_OPERATOR_ROLE\"\n);\nbytes32 constant TRUSTED_CLAIMER_ROLE = keccak256(\"TRUSTED_CLAIMER_ROLE\");\n\ninterface IFestivalHeadsV1 is IERC721 {\n function hasClaimed(\n address[] calldata claimers\n ) external view returns (bool[] memory);\n\n function supply() external view returns (uint256, uint256);\n\n function totalSupply() external view returns (uint256);\n}\n\ncontract FestivalHeadsV1 is ERC721, Ownable, IFestivalHeadsV1 {\n using Counters for Counters.Counter;\n\n error AllClaimed();\n error AlreadyClaimed();\n error Forbidden();\n error NotFound();\n\n event ClaimFailed(string reason);\n event ClaimFailedBytes(bytes reason);\n\n uint256 public maxSupply;\n address public immutable accessRegistry;\n address public chainlinkRequest;\n\n Counters.Counter public tokenIdTracker;\n mapping(address => bool) public claimed;\n mapping(uint256 => string) public tokenURIs;\n\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n uint256 maxSupply_,\n address accessRegistry_,\n address chainlinkRequest_\n ) ERC721(name, symbol) {\n _transferOwnership(creator);\n\n maxSupply = maxSupply_;\n accessRegistry = accessRegistry_;\n chainlinkRequest = chainlinkRequest_;\n }\n\n function _checkBeforeMint(\n address claimer,\n uint256 tokenId\n ) internal virtual {\n if (tokenId >= maxSupply) {\n revert AllClaimed();\n }\n if (claimed[claimer]) {\n revert AlreadyClaimed();\n }\n }\n\n function _mint(address claimer, string memory tokenURI_) internal virtual {\n uint256 tokenId = tokenIdTracker.current();\n\n _checkBeforeMint(claimer, tokenId);\n _mint(claimer, tokenId);\n\n claimed[claimer] = true;\n tokenURIs[tokenId] = tokenURI_;\n tokenIdTracker.increment();\n }\n\n function claimTo(address claimer, string memory tokenURI_) public virtual {\n if (\n !AccessRegistry(accessRegistry).hasRole(\n TRUSTED_CLAIMER_ROLE,\n _msgSender()\n )\n ) {\n revert Forbidden();\n }\n\n if (chainlinkRequest == address(0)) {\n return _mint(claimer, tokenURI_);\n }\n\n _checkBeforeMint(claimer, tokenIdTracker.current());\n\n bytes memory state = abi.encode(claimer, tokenURI_);\n\n ChainlinkRequest(chainlinkRequest).requestBytes(\n this.fulfillClaim.selector,\n state\n );\n }\n\n function fulfillMint(address claimer, string memory tokenURI_) external {\n if (_msgSender() != address(this)) {\n revert Forbidden();\n }\n\n _mint(claimer, tokenURI_);\n }\n\n function fulfillClaim(\n bytes memory state,\n bytes memory bytesData\n ) public virtual {\n if (_msgSender() != chainlinkRequest) {\n revert Forbidden();\n }\n\n (bool ok, string memory err) = abi.decode(bytesData, (bool, string));\n\n if (ok) {\n (address claimer, string memory tokenURI_) = abi.decode(\n state,\n (address, string)\n );\n\n try this.fulfillMint(claimer, tokenURI_) {\n /* no-op */\n } catch Error(string memory reason) {\n err = reason;\n } catch (bytes memory reason) {\n emit ClaimFailedBytes(reason);\n }\n }\n if (bytes(err).length > 0) {\n emit ClaimFailed(err);\n }\n }\n\n function hasClaimed(\n address[] calldata claimers\n ) public view virtual override returns (bool[] memory) {\n uint256 length = claimers.length;\n bool[] memory result = new bool[](length);\n\n for (uint256 i; i < length; i++) {\n result[i] = claimed[claimers[i]];\n }\n return result;\n }\n\n function supply() public view virtual override returns (uint256, uint256) {\n return (tokenIdTracker.current(), maxSupply);\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return (tokenIdTracker.current());\n }\n\n function _isApprovedOrOwner(\n address spender,\n uint256\n ) internal view virtual override returns (bool) {\n return\n AccessRegistry(accessRegistry).hasRole(\n FESTIVAL_HEADS_OPERATOR_ROLE,\n spender\n );\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IFestivalHeadsV1).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function tokenURI(\n uint256 tokenId\n ) public view virtual override returns (string memory) {\n if (!_exists(tokenId)) {\n revert NotFound();\n }\n\n return tokenURIs[tokenId];\n }\n\n function setChainlinkRequest(\n address chainlinkRequest_\n ) public onlyFestivalHeadsOperator {\n chainlinkRequest = chainlinkRequest_;\n }\n\n function setMaxSupply(uint256 maxSupply_) public onlyFestivalHeadsOperator {\n maxSupply = maxSupply_;\n }\n\n function burn(\n uint256 tokenId,\n bool reset\n ) public onlyFestivalHeadsOperator {\n if (reset) {\n claimed[ownerOf(tokenId)] = false;\n }\n\n _burn(tokenId);\n }\n\n function mint(\n address claimer,\n string memory tokenURI_,\n uint256 tokenId\n ) public onlyFestivalHeadsOperator {\n uint256 nextTokenId = tokenIdTracker.current();\n\n if (tokenId > nextTokenId) {\n revert NotFound();\n }\n\n _mint(claimer, tokenId);\n\n claimed[claimer] = true;\n tokenURIs[tokenId] = tokenURI_;\n\n if (tokenId == nextTokenId) {\n tokenIdTracker.increment();\n }\n }\n\n modifier onlyFestivalHeadsOperator() {\n if (\n !AccessRegistry(accessRegistry).hasRole(\n FESTIVAL_HEADS_OPERATOR_ROLE,\n _msgSender()\n )\n ) {\n revert Forbidden();\n }\n _;\n }\n}\n" + }, + "contracts/IERC2981.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\n///\n/// @dev Interface for the NFT Royalty Standard\n///\ninterface IERC2981 is IERC165 {\n /// ERC165 bytes to add to interface array - set in parent contract\n /// implementing this standard\n ///\n /// bytes4(keccak256(\"royaltyInfo(uint256,uint256)\")) == 0x2a55205a\n /// bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;\n /// _registerInterface(_INTERFACE_ID_ERC2981);\n\n /// @notice Called with the sale price to determine how much royalty\n // is owed and to whom.\n /// @param _tokenId - the NFT asset queried for royalty information\n /// @param _salePrice - the sale price of the NFT asset specified by _tokenId\n /// @return receiver - address of who should be sent the royalty payment\n /// @return royaltyAmount - the royalty payment amount for _salePrice\n function royaltyInfo(\n uint256 _tokenId,\n uint256 _salePrice\n ) external view returns (\n address receiver,\n uint256 royaltyAmount\n );\n}\n" + }, + "contracts/Introspection.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\n\ncontract Introspection {\n using ERC165Checker for address;\n\n function getSupportedInterfaces(\n address account,\n bytes4[] memory interfaceIds\n ) public view returns (bool[] memory) {\n require(account.code.length > 0, \"Introspection: account not a contract\");\n\n return account.getSupportedInterfaces(interfaceIds);\n }\n}\n" + }, + "contracts/IRelayRecipient.sol": { + "content": "// SPDX-License-Identifier:MIT\npragma solidity ^0.8.0;\n\n/**\n * a contract must implement this interface in order to support relayed transaction.\n * It is better to inherit the BaseRelayRecipient as its implementation.\n */\nabstract contract IRelayRecipient {\n\n /**\n * return if the forwarder is trusted to forward relayed transactions to us.\n * the forwarder is required to verify the sender's signature, and verify\n * the call is not a replay.\n */\n function isTrustedForwarder(address forwarder) public virtual view returns(bool);\n\n /**\n * return the sender of this call.\n * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes\n * of the msg.data.\n * otherwise, return `msg.sender`\n * should be used in the contract anywhere instead of msg.sender\n */\n function _msgSender() internal virtual view returns (address);\n\n function versionRecipient() external virtual view returns (string memory);\n}\n" + }, + "contracts/LemonadeMarketplaceV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC2981.sol\";\nimport \"./rarible/RoyaltiesV2.sol\";\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\ncontract LemonadeMarketplaceV1 is AccessControlEnumerable {\n using Counters for Counters.Counter;\n\n address public immutable feeAccount;\n uint96 public immutable feeValue;\n\n enum OrderKind {\n Direct,\n Auction\n }\n\n event OrderCreated(\n uint256 indexed orderId,\n OrderKind kind,\n uint256 openFrom,\n uint256 openTo,\n address indexed maker,\n address currency,\n uint256 price,\n address tokenContract,\n uint256 tokenId\n );\n event OrderBid(\n uint256 indexed orderId,\n address indexed bidder,\n uint256 bidAmount\n );\n event OrderFilled(\n uint256 indexed orderId,\n address indexed taker,\n uint256 paidAmount\n );\n event OrderCancelled(uint256 indexed orderId);\n\n struct Order {\n OrderKind kind;\n bool open;\n uint256 openFrom;\n uint256 openTo;\n address maker;\n address currency;\n uint256 price;\n address tokenContract;\n uint256 tokenId;\n address bidder;\n uint256 bidAmount;\n address taker;\n uint256 paidAmount;\n }\n mapping(uint256 => Order) private _orders;\n Counters.Counter public orderIdTracker;\n\n constructor(address feeAccount_, uint96 feeValue_) {\n feeAccount = feeAccount_;\n feeValue = feeValue_;\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function order(uint256 orderId)\n external\n view\n virtual\n whenExists(orderId)\n returns (\n OrderKind,\n bool,\n uint256,\n uint256,\n address,\n address,\n uint256,\n uint256,\n address,\n uint256\n )\n {\n Order memory order_ = _orders[orderId];\n return (\n order_.kind,\n order_.open,\n order_.openFrom,\n order_.openTo,\n order_.maker,\n order_.currency,\n order_.price,\n order_.bidAmount,\n order_.taker,\n order_.paidAmount\n );\n }\n\n function token(uint256 orderId)\n external\n view\n virtual\n whenExists(orderId)\n returns (address, uint256)\n {\n return (_orders[orderId].tokenContract, _orders[orderId].tokenId);\n }\n\n function createOrder(\n OrderKind kind,\n uint256 openFrom,\n uint256 openTo,\n address currency,\n uint256 price,\n address tokenContract,\n uint256 tokenId\n ) external virtual returns (uint256) {\n uint256 openDuration_ = openDuration(openFrom, openTo);\n\n require(\n openDuration_ > 0,\n \"LemonadeMarketplace: order must be open at some point\"\n );\n\n if (kind == OrderKind.Auction) {\n require(\n openDuration_ <= 30 * 24 * 60 * 60,\n \"LemonadeMarketplace: order of kind auction must not be open for more than 30 days\"\n );\n }\n\n IERC721(tokenContract).transferFrom(\n _msgSender(),\n address(this),\n tokenId\n );\n\n uint256 orderId = orderIdTracker.current();\n\n _orders[orderId] = Order({\n kind: kind,\n open: true,\n openFrom: openFrom,\n openTo: openTo,\n maker: _msgSender(),\n currency: currency,\n price: price,\n tokenContract: tokenContract,\n tokenId: tokenId,\n bidder: address(0),\n bidAmount: 0,\n taker: address(0),\n paidAmount: 0\n });\n\n orderIdTracker.increment();\n\n Order memory order_ = _orders[orderId];\n emit OrderCreated(\n orderId,\n order_.kind,\n order_.openFrom,\n order_.openTo,\n order_.maker,\n order_.currency,\n order_.price,\n order_.tokenContract,\n order_.tokenId\n );\n return orderId;\n }\n\n function cancelOrder(uint256 orderId) external virtual whenExists(orderId) {\n Order memory order_ = _orders[orderId];\n require(\n order_.maker == _msgSender() ||\n hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),\n \"LemonadeMarketplace: must be the maker to cancel\"\n );\n require(\n order_.open,\n \"LemonadeMarketplace: order must be open to cancel\"\n );\n require(\n order_.bidder == address(0),\n \"LemonadeMarketplace: order must have no bid to cancel\"\n );\n\n IERC721(order_.tokenContract).transferFrom(\n address(this),\n order_.maker,\n order_.tokenId\n );\n\n _orders[orderId].open = false;\n emit OrderCancelled(orderId);\n }\n\n function bidOrder(uint256 orderId, uint256 amount)\n external\n payable\n virtual\n whenExists(orderId)\n {\n Order memory order_ = _orders[orderId];\n require(\n order_.kind == OrderKind.Auction,\n \"LemonadeMarketplace: order must be of kind auction to bid\"\n );\n require(order_.open, \"LemonadeMarketplace: order must be open to bid\");\n require(\n order_.openFrom <= block.timestamp,\n \"LemonadeMarketplace: order must be open to bid - too early\"\n );\n require(\n order_.openTo > block.timestamp,\n \"LemonadeMarketplace: order must be open to bid - too late\"\n );\n require(\n order_.price <= amount,\n \"LemonadeMarketplace: must match price to bid\"\n );\n require(\n order_.currency != address(0) || amount == msg.value,\n \"LemonadeMarketplace: amount must match tx value\"\n );\n\n if (order_.bidder != address(0)) {\n require(\n order_.bidAmount < amount,\n \"LemonadeMarketplace: must surpass bid to bid\"\n );\n\n if (order_.bidAmount > 0) {\n transfer(\n order_.currency,\n address(this),\n order_.bidder,\n order_.bidAmount\n );\n }\n }\n\n _orders[orderId].bidder = _msgSender();\n _orders[orderId].bidAmount = amount;\n order_ = _orders[orderId];\n\n if (order_.bidAmount > 0) {\n transfer(\n order_.currency,\n order_.bidder,\n address(this),\n order_.bidAmount\n );\n }\n\n emit OrderBid(orderId, order_.bidder, order_.bidAmount);\n }\n\n function fillOrder(uint256 orderId, uint256 amount)\n external\n payable\n virtual\n whenExists(orderId)\n {\n Order memory order_ = _orders[orderId];\n require(order_.open, \"LemonadeMarketplace: order must be open to fill\");\n\n _orders[orderId].open = false;\n address spender;\n\n if (order_.kind == OrderKind.Direct) {\n require(\n order_.openFrom <= block.timestamp,\n \"LemonadeMarketplace: order must be open to fill - too early\"\n );\n require(\n order_.openTo == 0 || order_.openTo > block.timestamp,\n \"LemonadeMarketplace: order must be open to fill - too late\"\n );\n require(\n order_.price <= amount,\n \"LemonadeMarketplace: must match price to fill direct order\"\n );\n require(\n order_.currency != address(0) || amount == msg.value,\n \"LemonadeMarketplace: amount must match tx value\"\n );\n\n _orders[orderId].taker = _msgSender();\n _orders[orderId].paidAmount = amount;\n spender = _msgSender();\n } else if (order_.kind == OrderKind.Auction) {\n require(\n (order_.bidder != address(0)),\n \"LemonadeMarketplace: order must have bid to fill auction order\"\n );\n require(\n (order_.bidder == _msgSender() &&\n order_.openTo <= block.timestamp) ||\n order_.maker == _msgSender() ||\n hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),\n \"LemonadeMarketplace: must be the maker or final bidder to fill auction order\"\n );\n\n _orders[orderId].taker = order_.bidder;\n _orders[orderId].paidAmount = order_.bidAmount;\n spender = address(this);\n }\n\n order_ = _orders[orderId];\n\n if (order_.paidAmount > 0) {\n uint256 transferAmount = order_.paidAmount;\n\n uint256 feeAmount = (order_.paidAmount * feeValue) / 10000;\n transfer(order_.currency, spender, feeAccount, feeAmount);\n transferAmount -= feeAmount;\n\n (\n bool supportsRaribleV2Royalties,\n LibPart.Part[] memory royalties\n ) = getRaribleV2Royalties(order_.tokenContract, order_.tokenId);\n if (supportsRaribleV2Royalties) {\n uint256 length = royalties.length;\n for (uint256 i; i < length; i++) {\n if (\n order_.maker != royalties[i].account &&\n royalties[i].value > 0\n ) {\n uint256 royaltyAmount = (order_.paidAmount *\n royalties[i].value) / 10000;\n transfer(\n order_.currency,\n spender,\n royalties[i].account,\n royaltyAmount\n );\n transferAmount -= royaltyAmount;\n }\n }\n } else {\n (\n bool supportsRoyaltyInfo,\n address receiver,\n uint256 royaltyAmount\n ) = getRoyaltyInfo(\n order_.tokenContract,\n order_.tokenId,\n order_.paidAmount\n );\n if (\n supportsRoyaltyInfo &&\n order_.maker != receiver &&\n royaltyAmount > 0\n ) {\n transfer(order_.currency, spender, receiver, royaltyAmount);\n transferAmount -= royaltyAmount;\n }\n }\n\n if (transferAmount > 0) {\n transfer(\n order_.currency,\n spender,\n order_.maker,\n transferAmount\n );\n transferAmount -= transferAmount;\n }\n\n require(\n transferAmount == 0,\n \"LemonadeMarketplace: transfer amount must be zero\"\n );\n }\n\n IERC721(order_.tokenContract).transferFrom(\n address(this),\n order_.taker,\n order_.tokenId\n );\n\n emit OrderFilled(orderId, order_.taker, order_.paidAmount);\n }\n\n function getRaribleV2Royalties(address tokenContract, uint256 tokenId)\n public\n view\n virtual\n returns (bool, LibPart.Part[] memory)\n {\n try RoyaltiesV2(tokenContract).getRaribleV2Royalties(tokenId) returns (\n LibPart.Part[] memory royalties\n ) {\n return (true, royalties);\n } catch {\n return (false, new LibPart.Part[](0));\n }\n }\n\n function getRoyaltyInfo(\n address tokenContract,\n uint256 tokenId,\n uint256 paidAmount\n )\n public\n view\n virtual\n returns (\n bool,\n address,\n uint256\n )\n {\n try IERC2981(tokenContract).royaltyInfo(tokenId, paidAmount) returns (\n address receiver,\n uint256 royaltyAmount\n ) {\n return (true, receiver, royaltyAmount);\n } catch {\n return (false, address(0), 0);\n }\n }\n\n function transfer(\n address currency,\n address spender,\n address recipient,\n uint256 amount\n ) private {\n if (currency == address(0)) {\n if (recipient != address(this)) {\n payable(recipient).transfer(amount);\n }\n } else {\n if (spender == address(this)) {\n IERC20(currency).transfer(recipient, amount);\n } else {\n IERC20(currency).transferFrom(spender, recipient, amount);\n }\n }\n }\n\n function openDuration(uint256 openFrom, uint256 openTo)\n private\n view\n returns (uint256)\n {\n uint256 start = openFrom < block.timestamp ? block.timestamp : openFrom;\n uint256 end = openTo == 0 ? type(uint256).max : openTo;\n\n if (start > end) {\n return 0;\n }\n return end - start;\n }\n\n modifier whenExists(uint256 orderId) {\n require(\n _orders[orderId].maker != address(0),\n \"LemonadeMarketplace: order nonexistent\"\n );\n _;\n }\n}\n" + }, + "contracts/LemonadeMarketplaceV1Forwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadeMarketplaceV1.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract LemonadeMarketplaceV1Forwardable is\n LemonadeMarketplaceV1,\n RelayRecipient\n{\n constructor(\n address feeAccount,\n uint96 feeValue,\n address trustedForwarder\n )\n LemonadeMarketplaceV1(feeAccount, feeValue)\n RelayRecipient(trustedForwarder)\n {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n}\n" + }, + "contracts/LemonadeMarketplaceV1Unique.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadeMarketplaceV1.sol\";\nimport \"./unique/ICollection.sol\";\nimport \"./unique/LibPartAdapter.sol\";\n\ncontract LemonadeMarketplaceV1Unique is LemonadeMarketplaceV1 {\n constructor(\n address feeAccount,\n uint96 feeValue\n ) LemonadeMarketplaceV1(feeAccount, feeValue) {}\n\n function getRaribleV2Royalties(\n address tokenContract,\n uint256 tokenId\n ) public view override returns (bool, LibPart.Part[] memory) {\n if (!isCollection(tokenContract)) {\n return\n LemonadeMarketplaceV1.getRaribleV2Royalties(\n tokenContract,\n tokenId\n );\n }\n\n try\n ICollection(tokenContract).property(tokenId, ROYALTIES_PROPERTY)\n returns (bytes memory data) {\n return (true, LibPartAdapter.decode(data));\n } catch {\n return (false, new LibPart.Part[](0));\n }\n }\n\n function isCollection(address addr) private pure returns (bool) {\n return\n uint160(addr) & 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000 ==\n 0x0017c4e6453cc49aaaaeaca894e6d9683e00000000;\n }\n}\n" + }, + "contracts/LemonadeMarketplaceV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC2981.sol\";\nimport \"./rarible/RoyaltiesV2.sol\";\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\ncontract LemonadeMarketplaceV2 is AccessControlEnumerable {\n using Counters for Counters.Counter;\n\n address public immutable feeAccount;\n uint96 public immutable feeValue;\n\n enum OrderKind {\n Direct,\n Auction\n }\n\n event OrderCreated(\n uint256 indexed orderId,\n OrderKind kind,\n uint256 openFrom,\n uint256 openTo,\n address indexed maker,\n address currency,\n uint256 price,\n address tokenContract,\n uint256 tokenId\n );\n event OrderBid(\n uint256 indexed orderId,\n address indexed bidder,\n uint256 bidAmount\n );\n event OrderFilled(\n uint256 indexed orderId,\n address indexed taker,\n uint256 paidAmount\n );\n event OrderCancelled(uint256 indexed orderId);\n\n struct Order {\n OrderKind kind;\n bool open;\n uint256 openFrom;\n uint256 openTo;\n address maker;\n address currency;\n uint256 price;\n address tokenContract;\n uint256 tokenId;\n address bidder;\n uint256 bidAmount;\n address taker;\n uint256 paidAmount;\n }\n mapping(uint256 => Order) private _orders;\n Counters.Counter public orderIdTracker;\n\n constructor(address feeAccount_, uint96 feeValue_) {\n feeAccount = feeAccount_;\n feeValue = feeValue_;\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function order(uint256 orderId)\n external\n view\n virtual\n whenExists(orderId)\n returns (\n OrderKind,\n bool,\n uint256,\n uint256,\n address,\n address,\n uint256,\n uint256,\n address,\n uint256\n )\n {\n Order memory order_ = _orders[orderId];\n return (\n order_.kind,\n order_.open,\n order_.openFrom,\n order_.openTo,\n order_.maker,\n order_.currency,\n order_.price,\n order_.bidAmount,\n order_.taker,\n order_.paidAmount\n );\n }\n\n function token(uint256 orderId)\n external\n view\n virtual\n whenExists(orderId)\n returns (address, uint256)\n {\n return (_orders[orderId].tokenContract, _orders[orderId].tokenId);\n }\n\n function createOrder(\n OrderKind kind,\n uint256 openFrom,\n uint256 openTo,\n address currency,\n uint256 price,\n address tokenContract,\n uint256 tokenId\n ) external virtual returns (uint256) {\n uint256 openDuration_ = openDuration(openFrom, openTo);\n\n require(\n openDuration_ > 0,\n \"LemonadeMarketplace: order must be open at some point\"\n );\n\n if (kind == OrderKind.Auction) {\n require(\n openDuration_ <= 30 * 24 * 60 * 60,\n \"LemonadeMarketplace: order of kind auction must not be open for more than 30 days\"\n );\n }\n\n IERC721(tokenContract).transferFrom(\n _msgSender(),\n address(this),\n tokenId\n );\n\n uint256 orderId = orderIdTracker.current();\n\n _orders[orderId] = Order({\n kind: kind,\n open: true,\n openFrom: openFrom,\n openTo: openTo,\n maker: _msgSender(),\n currency: currency,\n price: price,\n tokenContract: tokenContract,\n tokenId: tokenId,\n bidder: address(0),\n bidAmount: 0,\n taker: address(0),\n paidAmount: 0\n });\n\n orderIdTracker.increment();\n\n Order memory order_ = _orders[orderId];\n emit OrderCreated(\n orderId,\n order_.kind,\n order_.openFrom,\n order_.openTo,\n order_.maker,\n order_.currency,\n order_.price,\n order_.tokenContract,\n order_.tokenId\n );\n return orderId;\n }\n\n function cancelOrder(uint256 orderId) external virtual whenExists(orderId) {\n Order memory order_ = _orders[orderId];\n require(\n order_.maker == _msgSender() ||\n hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),\n \"LemonadeMarketplace: must be the maker to cancel\"\n );\n require(\n order_.open,\n \"LemonadeMarketplace: order must be open to cancel\"\n );\n require(\n order_.bidder == address(0),\n \"LemonadeMarketplace: order must have no bid to cancel\"\n );\n\n IERC721(order_.tokenContract).transferFrom(\n address(this),\n order_.maker,\n order_.tokenId\n );\n\n _orders[orderId].open = false;\n emit OrderCancelled(orderId);\n }\n\n function bidOrder(uint256 orderId, uint256 amount, address subject)\n external\n payable\n virtual\n whenExists(orderId)\n {\n Order memory order_ = _orders[orderId];\n require(\n order_.kind == OrderKind.Auction,\n \"LemonadeMarketplace: order must be of kind auction to bid\"\n );\n require(order_.open, \"LemonadeMarketplace: order must be open to bid\");\n require(\n order_.openFrom <= block.timestamp,\n \"LemonadeMarketplace: order must be open to bid - too early\"\n );\n require(\n order_.openTo > block.timestamp,\n \"LemonadeMarketplace: order must be open to bid - too late\"\n );\n require(\n order_.price <= amount,\n \"LemonadeMarketplace: must match price to bid\"\n );\n require(\n order_.currency != address(0) || amount == msg.value,\n \"LemonadeMarketplace: amount must match tx value\"\n );\n\n if (order_.bidder != address(0)) {\n require(\n order_.bidAmount < amount,\n \"LemonadeMarketplace: must surpass bid to bid\"\n );\n\n if (order_.bidAmount > 0) {\n transfer(\n order_.currency,\n address(this),\n order_.bidder,\n order_.bidAmount\n );\n }\n }\n\n address spender = _msgSender();\n\n _orders[orderId].bidder = subject != address(0) ? subject : spender;\n _orders[orderId].bidAmount = amount;\n order_ = _orders[orderId];\n\n if (order_.bidAmount > 0) {\n transfer(\n order_.currency,\n spender,\n address(this),\n order_.bidAmount\n );\n }\n\n emit OrderBid(orderId, order_.bidder, order_.bidAmount);\n }\n\n function fillOrder(uint256 orderId, uint256 amount, address subject)\n external\n payable\n virtual\n whenExists(orderId)\n {\n Order memory order_ = _orders[orderId];\n require(order_.open, \"LemonadeMarketplace: order must be open to fill\");\n\n _orders[orderId].open = false;\n address spender;\n\n if (order_.kind == OrderKind.Direct) {\n require(\n order_.openFrom <= block.timestamp,\n \"LemonadeMarketplace: order must be open to fill - too early\"\n );\n require(\n order_.openTo == 0 || order_.openTo > block.timestamp,\n \"LemonadeMarketplace: order must be open to fill - too late\"\n );\n require(\n order_.price <= amount,\n \"LemonadeMarketplace: must match price to fill direct order\"\n );\n require(\n order_.currency != address(0) || amount == msg.value,\n \"LemonadeMarketplace: amount must match tx value\"\n );\n\n spender = _msgSender();\n _orders[orderId].taker = subject != address(0) ? subject : spender;\n _orders[orderId].paidAmount = amount;\n } else if (order_.kind == OrderKind.Auction) {\n require(\n (order_.bidder != address(0)),\n \"LemonadeMarketplace: order must have bid to fill auction order\"\n );\n require(\n (order_.bidder == _msgSender() &&\n order_.openTo <= block.timestamp) ||\n order_.maker == _msgSender() ||\n hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),\n \"LemonadeMarketplace: must be the maker or final bidder to fill auction order\"\n );\n\n _orders[orderId].taker = order_.bidder;\n _orders[orderId].paidAmount = order_.bidAmount;\n spender = address(this);\n }\n\n order_ = _orders[orderId];\n\n if (order_.paidAmount > 0) {\n uint256 transferAmount = order_.paidAmount;\n\n uint256 feeAmount = (order_.paidAmount * feeValue) / 10000;\n transfer(order_.currency, spender, feeAccount, feeAmount);\n transferAmount -= feeAmount;\n\n (\n bool supportsRaribleV2Royalties,\n LibPart.Part[] memory royalties\n ) = getRaribleV2Royalties(order_.tokenContract, order_.tokenId);\n if (supportsRaribleV2Royalties) {\n uint256 length = royalties.length;\n for (uint256 i; i < length; i++) {\n if (\n order_.maker != royalties[i].account &&\n royalties[i].value > 0\n ) {\n uint256 royaltyAmount = (order_.paidAmount *\n royalties[i].value) / 10000;\n transfer(\n order_.currency,\n spender,\n royalties[i].account,\n royaltyAmount\n );\n transferAmount -= royaltyAmount;\n }\n }\n } else {\n (\n bool supportsRoyaltyInfo,\n address receiver,\n uint256 royaltyAmount\n ) = getRoyaltyInfo(\n order_.tokenContract,\n order_.tokenId,\n order_.paidAmount\n );\n if (\n supportsRoyaltyInfo &&\n order_.maker != receiver &&\n royaltyAmount > 0\n ) {\n transfer(order_.currency, spender, receiver, royaltyAmount);\n transferAmount -= royaltyAmount;\n }\n }\n\n if (transferAmount > 0) {\n transfer(\n order_.currency,\n spender,\n order_.maker,\n transferAmount\n );\n transferAmount -= transferAmount;\n }\n\n require(\n transferAmount == 0,\n \"LemonadeMarketplace: transfer amount must be zero\"\n );\n }\n\n IERC721(order_.tokenContract).transferFrom(\n address(this),\n order_.taker,\n order_.tokenId\n );\n\n emit OrderFilled(orderId, order_.taker, order_.paidAmount);\n }\n\n function getRaribleV2Royalties(address tokenContract, uint256 tokenId)\n public\n view\n virtual\n returns (bool, LibPart.Part[] memory)\n {\n try RoyaltiesV2(tokenContract).getRaribleV2Royalties(tokenId) returns (\n LibPart.Part[] memory royalties\n ) {\n return (true, royalties);\n } catch {\n return (false, new LibPart.Part[](0));\n }\n }\n\n function getRoyaltyInfo(\n address tokenContract,\n uint256 tokenId,\n uint256 paidAmount\n )\n public\n view\n virtual\n returns (\n bool,\n address,\n uint256\n )\n {\n try IERC2981(tokenContract).royaltyInfo(tokenId, paidAmount) returns (\n address receiver,\n uint256 royaltyAmount\n ) {\n return (true, receiver, royaltyAmount);\n } catch {\n return (false, address(0), 0);\n }\n }\n\n function transfer(\n address currency,\n address spender,\n address recipient,\n uint256 amount\n ) private {\n if (currency == address(0)) {\n if (recipient != address(this)) {\n payable(recipient).transfer(amount);\n }\n } else {\n if (spender == address(this)) {\n IERC20(currency).transfer(recipient, amount);\n } else {\n IERC20(currency).transferFrom(spender, recipient, amount);\n }\n }\n }\n\n function openDuration(uint256 openFrom, uint256 openTo)\n private\n view\n returns (uint256)\n {\n uint256 start = openFrom < block.timestamp ? block.timestamp : openFrom;\n uint256 end = openTo == 0 ? type(uint256).max : openTo;\n\n if (start > end) {\n return 0;\n }\n return end - start;\n }\n\n modifier whenExists(uint256 orderId) {\n require(\n _orders[orderId].maker != address(0),\n \"LemonadeMarketplace: order nonexistent\"\n );\n _;\n }\n}\n" + }, + "contracts/LemonadeMarketplaceV2Forwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadeMarketplaceV2.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract LemonadeMarketplaceV2Forwardable is\n LemonadeMarketplaceV2,\n RelayRecipient\n{\n constructor(\n address feeAccount,\n uint96 feeValue,\n address trustedForwarder\n )\n LemonadeMarketplaceV2(feeAccount, feeValue)\n RelayRecipient(trustedForwarder)\n {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n}\n" + }, + "contracts/LemonadePoapV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"./AccessRegistry.sol\";\nimport \"./IERC2981.sol\";\nimport \"./rarible/RoyaltiesV2.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\nbytes32 constant TRUSTED_CLAIMER_ROLE = keccak256(\"TRUSTED_CLAIMER_ROLE\");\nbytes32 constant TRUSTED_OPERATOR_ROLE = keccak256(\"TRUSTED_OPERATOR_ROLE\");\n\ninterface ILemonadePoapV1 is IERC721 {\n function claim() external;\n\n function hasClaimed(\n address[] calldata claimers\n ) external view returns (bool[] memory);\n\n function supply() external view returns (uint256, uint256);\n\n function totalSupply() external view returns (uint256);\n}\n\ncontract LemonadePoapV1 is\n ERC721,\n IERC2981,\n ILemonadePoapV1,\n Ownable,\n RoyaltiesV2\n{\n using Counters for Counters.Counter;\n\n error AllClaimed();\n error AlreadyClaimed();\n error Forbidden();\n error NotFound();\n\n address public immutable creator;\n string public tokenURI_;\n LibPart.Part[] public royalties;\n uint256 public maxSupply;\n address public immutable accessRegistry;\n\n Counters.Counter public tokenIdTracker;\n mapping(address => bool) public claimed;\n\n constructor(\n string memory name,\n string memory symbol,\n address creator_,\n string memory tokenURI__,\n LibPart.Part[] memory royalties_,\n uint256 maxSupply_,\n address accessRegistry_\n ) ERC721(name, symbol) {\n creator = creator_;\n tokenURI_ = tokenURI__;\n\n uint256 length = royalties_.length;\n for (uint256 i; i < length; ) {\n royalties.push(royalties_[i]);\n unchecked {\n ++i;\n }\n }\n\n maxSupply = maxSupply_;\n accessRegistry = accessRegistry_;\n\n _mint(creator_);\n }\n\n function _checkBeforeMint(\n address claimer,\n uint256 tokenId\n ) internal virtual {\n if (maxSupply != 0 && tokenId == maxSupply) {\n revert AllClaimed();\n }\n if (claimed[claimer]) {\n revert AlreadyClaimed();\n }\n }\n\n function _mint(address claimer) internal virtual {\n uint256 tokenId = tokenIdTracker.current();\n\n _checkBeforeMint(claimer, tokenId);\n _mint(claimer, tokenId);\n\n claimed[claimer] = true;\n tokenIdTracker.increment();\n }\n\n function _afterTokenTransfer(\n address,\n address to,\n uint256 tokenId\n ) internal {\n if (tokenId == 0 && owner() != to) {\n _transferOwnership(to);\n }\n }\n\n function claim() public virtual override {\n address claimer = _msgSender();\n\n _mint(claimer);\n }\n\n function claimTo(address claimer) public virtual {\n if (\n !AccessRegistry(accessRegistry).hasRole(\n TRUSTED_CLAIMER_ROLE,\n _msgSender()\n )\n ) {\n revert Forbidden();\n }\n\n _mint(claimer);\n }\n\n function hasClaimed(\n address[] calldata claimers\n ) public view virtual override returns (bool[] memory) {\n uint256 length = claimers.length;\n bool[] memory result = new bool[](length);\n\n for (uint256 i; i < length; i++) {\n result[i] = claimed[claimers[i]];\n }\n return result;\n }\n\n function supply() public view virtual override returns (uint256, uint256) {\n return (tokenIdTracker.current(), maxSupply);\n }\n\n function totalSupply() public view virtual override returns (uint256) {\n return (tokenIdTracker.current());\n }\n\n function isApprovedForAll(\n address owner,\n address operator\n ) public view virtual override(ERC721, IERC721) returns (bool isOperator) {\n if (\n AccessRegistry(accessRegistry).hasRole(\n TRUSTED_OPERATOR_ROLE,\n operator\n )\n ) {\n return true;\n }\n\n return super.isApprovedForAll(owner, operator);\n }\n\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(ILemonadePoapV1).interfaceId ||\n interfaceId == type(RoyaltiesV2).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function tokenURI(\n uint256 tokenId\n ) public view virtual override returns (string memory) {\n if (!_exists(tokenId)) {\n revert NotFound();\n }\n\n return tokenURI_;\n }\n\n function getRaribleV2Royalties(\n uint256\n ) public view override returns (LibPart.Part[] memory) {\n return royalties;\n }\n\n function royaltyInfo(\n uint256,\n uint256 price\n ) public view override returns (address receiver, uint256 royaltyAmount) {\n uint256 length = royalties.length;\n\n if (length == 0) {\n return (address(0), 0);\n }\n\n uint256 totalValue;\n for (uint256 i; i < length; i++) {\n totalValue += royalties[i].value;\n }\n return (royalties[0].account, (price * totalValue) / 10000);\n }\n}\n" + }, + "contracts/LemonadePoapV1ChainlinkRequest.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ChainlinkRequest.sol\";\nimport \"./LemonadePoapV1.sol\";\n\ncontract LemonadePoapV1ChainlinkRequest is LemonadePoapV1 {\n using Counters for Counters.Counter;\n\n event ClaimFailed(string reason);\n event ClaimFailedBytes(bytes reason);\n\n address public chainlinkRequest;\n\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n string memory tokenURI,\n LibPart.Part[] memory royalties,\n uint256 totalSupply,\n address accessRegistry,\n address chainlinkRequest_\n )\n LemonadePoapV1(\n name,\n symbol,\n creator,\n tokenURI,\n royalties,\n totalSupply,\n accessRegistry\n )\n {\n chainlinkRequest = chainlinkRequest_;\n }\n\n function _mint(address claimer) internal virtual override {\n if (chainlinkRequest == address(0)) {\n return super._mint(claimer);\n }\n\n _checkBeforeMint(claimer, tokenIdTracker.current());\n\n bytes memory state = abi.encode(claimer);\n\n ChainlinkRequest(chainlinkRequest).requestBytes(\n this.fulfillClaim.selector,\n state\n );\n }\n\n function fulfillMint(address claimer) external {\n if (_msgSender() != address(this)) {\n revert Forbidden();\n }\n\n super._mint(claimer);\n }\n\n function fulfillClaim(\n bytes memory state,\n bytes memory bytesData\n ) public virtual {\n if (_msgSender() != chainlinkRequest) {\n revert Forbidden();\n }\n\n (bool ok, string memory err) = abi.decode(bytesData, (bool, string));\n\n if (ok) {\n address claimer = abi.decode(state, (address));\n\n try this.fulfillMint(claimer) {\n /* no-op */\n } catch Error(string memory reason) {\n err = reason;\n } catch (bytes memory reason) {\n emit ClaimFailedBytes(reason);\n }\n }\n if (bytes(err).length > 0) {\n emit ClaimFailed(err);\n }\n }\n\n function setChainlinkRequest(address chainlinkRequest_) public onlyOwner {\n chainlinkRequest = chainlinkRequest_;\n }\n}\n" + }, + "contracts/LemonadePoapV1ChainlinkRequestForwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadePoapV1ChainlinkRequest.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract LemonadePoapV1ChainlinkRequestForwardable is\n LemonadePoapV1ChainlinkRequest,\n RelayRecipient\n{\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n string memory tokenURI,\n LibPart.Part[] memory royalties,\n uint256 totalSupply,\n address accessRegistry,\n address chainlinkRequest,\n address trustedForwarder\n )\n LemonadePoapV1ChainlinkRequest(\n name,\n symbol,\n creator,\n tokenURI,\n royalties,\n totalSupply,\n accessRegistry,\n chainlinkRequest\n )\n RelayRecipient(trustedForwarder)\n {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n\n function setTrustedForwarder(address trustedForwarder_) public onlyOwner {\n trustedForwarder = trustedForwarder_;\n }\n}\n" + }, + "contracts/LemonadePoapV1Forwardable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadePoapV1.sol\";\nimport \"./RelayRecipient.sol\";\n\ncontract LemonadePoapV1Forwardable is LemonadePoapV1, RelayRecipient {\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n string memory tokenURI,\n LibPart.Part[] memory royalties,\n uint256 totalSupply,\n address accessRegistry,\n address trustedForwarder\n )\n LemonadePoapV1(\n name,\n symbol,\n creator,\n tokenURI,\n royalties,\n totalSupply,\n accessRegistry\n )\n RelayRecipient(trustedForwarder)\n {}\n\n function _msgSender()\n internal\n view\n virtual\n override(Context, RelayRecipient)\n returns (address)\n {\n return RelayRecipient._msgSender();\n }\n\n function setTrustedForwarder(address trustedForwarder_) public onlyOwner {\n trustedForwarder = trustedForwarder_;\n }\n}\n" + }, + "contracts/LemonadePoapV1Unique.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./LemonadePoapV1.sol\";\nimport \"./unique/ICollection.sol\";\nimport \"./unique/ICollectionHelpers.sol\";\nimport \"./unique/LibPartAdapter.sol\";\n\ncontract LemonadePoapV1Unique is LemonadePoapV1 {\n using Counters for Counters.Counter;\n\n address public collection;\n\n bytes public royaltiesBytes;\n\n constructor(\n string memory name,\n string memory symbol,\n address creator,\n string memory tokenURI,\n LibPart.Part[] memory royalties,\n uint256 totalSupply,\n address accessRegistry,\n address collectionHelpers\n )\n payable\n LemonadePoapV1(\n name,\n symbol,\n creator,\n tokenURI,\n royalties,\n totalSupply,\n accessRegistry\n )\n {\n ICollectionHelpers collectionHelpers_ = ICollectionHelpers(\n collectionHelpers\n );\n\n collection = collectionHelpers_.createNFTCollection{value: msg.value}(\n name,\n name,\n symbol\n );\n collectionHelpers_.makeCollectionERC721MetadataCompatible(\n collection,\n tokenURI\n );\n\n ICollection collection_ = ICollection(collection);\n\n collection_.addCollectionAdminCross(\n CrossAddress({eth: address(this), sub: 0})\n );\n collection_.changeCollectionOwnerCross(\n CrossAddress({eth: msg.sender, sub: 0})\n );\n\n if (royalties.length > 0) {\n PropertyPermission[] memory permissions = new PropertyPermission[](\n 3\n );\n\n permissions[0] = PropertyPermission({\n code: TokenPermissionField.Mutable,\n value: false\n });\n permissions[1] = PropertyPermission({\n code: TokenPermissionField.CollectionAdmin,\n value: true\n });\n permissions[2] = PropertyPermission({\n code: TokenPermissionField.TokenOwner,\n value: false\n });\n\n TokenPropertyPermission[]\n memory permissionsArray = new TokenPropertyPermission[](1);\n\n permissionsArray[0] = TokenPropertyPermission({\n key: ROYALTIES_PROPERTY,\n permissions: permissions\n });\n\n collection_.setTokenPropertyPermissions(permissionsArray);\n\n royaltiesBytes = LibPartAdapter.encode(royalties);\n }\n }\n\n function _mint(\n address claimer,\n uint256 tokenId_\n ) internal virtual override {\n if (tokenId_ == 0) {\n return super._mint(claimer, tokenId_);\n }\n\n ICollection collection_ = ICollection(collection);\n\n uint256 tokenId = collection_.mint(claimer);\n\n if (royaltiesBytes.length > 0) {\n Property[] memory properties = new Property[](1);\n\n properties[0] = Property({\n key: ROYALTIES_PROPERTY,\n value: royaltiesBytes\n });\n\n collection_.setProperties(tokenId, properties);\n }\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n if (tokenId == 0) {\n return super.transferFrom(from, to, tokenId);\n }\n\n ICollection collection_ = ICollection(collection);\n\n address owner = collection_.ownerOf(tokenId);\n\n if (msg.sender != owner && !isApprovedForAll(owner, msg.sender)) {\n revert Forbidden();\n }\n\n collection_.transferFrom(from, to, tokenId);\n }\n}\n" + }, + "contracts/LemonadeUniqueCollectionV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ERC721LemonadeV1.sol\";\nimport \"./unique/ICollection.sol\";\nimport \"./unique/ICollectionHelpers.sol\";\nimport \"./unique/LibPartAdapter.sol\";\n\ncontract LemonadeUniqueCollectionV1 is IMintable {\n address public collection;\n\n constructor(\n address collectionHelpers,\n string memory name,\n string memory description,\n string memory tokenPrefix\n ) payable {\n ICollectionHelpers collectionHelpers_ = ICollectionHelpers(\n collectionHelpers\n );\n\n collection = collectionHelpers_.createNFTCollection{value: msg.value}(\n name,\n description,\n tokenPrefix\n );\n collectionHelpers_.makeCollectionERC721MetadataCompatible(\n collection,\n \"\"\n );\n\n ICollection collection_ = ICollection(collection);\n\n collection_.addCollectionAdminCross(\n CrossAddress({eth: address(this), sub: 0})\n );\n collection_.changeCollectionOwnerCross(\n CrossAddress({eth: msg.sender, sub: 0})\n );\n\n PropertyPermission[] memory permissions = new PropertyPermission[](3);\n\n permissions[0] = PropertyPermission({\n code: TokenPermissionField.Mutable,\n value: false\n });\n permissions[1] = PropertyPermission({\n code: TokenPermissionField.CollectionAdmin,\n value: true\n });\n permissions[2] = PropertyPermission({\n code: TokenPermissionField.TokenOwner,\n value: false\n });\n\n TokenPropertyPermission[]\n memory permissionsArray = new TokenPropertyPermission[](1);\n\n permissionsArray[0] = TokenPropertyPermission({\n key: ROYALTIES_PROPERTY,\n permissions: permissions\n });\n\n collection_.setTokenPropertyPermissions(permissionsArray);\n }\n\n function mintToCaller(\n string memory tokenURI\n ) public override returns (uint256) {\n return ICollection(collection).mintWithTokenURI(msg.sender, tokenURI);\n }\n\n function mintToCallerWithRoyalty(\n string memory tokenURI,\n LibPart.Part[] memory royalties\n ) public override returns (uint256) {\n uint256 tokenId = mintToCaller(tokenURI);\n\n Property[] memory properties = new Property[](1);\n\n properties[0] = Property({\n key: ROYALTIES_PROPERTY,\n value: LibPartAdapter.encode(royalties)\n });\n\n ICollection(collection).setProperties(tokenId, properties);\n\n return tokenId;\n }\n}\n" + }, + "contracts/passport/BaseV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./GatewayV1Axelar.sol\";\nimport \"./GatewayV1Call.sol\";\nimport \"./IBaseV1.sol\";\nimport \"./Shared.sol\";\n\ncontract BaseV1 is GatewayV1Axelar, GatewayV1Call, IBaseV1 {\n bytes32 public callNetwork;\n uint256 public maxSupply;\n\n uint256 private _tokenIdCounter;\n uint256 private _totalReservations;\n\n mapping(address => uint256) private _referrals;\n mapping(address => uint256) private _reservations;\n mapping(address => uint256) private _tokens;\n\n mapping(uint256 => address) private _owners;\n mapping(uint256 => bytes32) private _networks;\n\n function initialize(\n IAxelarGateway axelarGateway,\n IAxelarGasService axelarGasService,\n AxelarNetwork[] calldata axelarNetworks,\n address callAddress,\n bytes32 callNetwork_,\n uint256 maxSupply_\n ) public initializer {\n __GatewayV1Axelar_init(axelarGateway, axelarGasService, axelarNetworks);\n __GatewayV1Call_init(callAddress);\n\n callNetwork = callNetwork_;\n maxSupply = maxSupply_;\n\n _tokenIdCounter = 1;\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function assign(Assignment[] calldata assignments) public override {\n address sender = _msgSender();\n\n _assign(sender, assignments);\n\n emit Assign(sender, assignments);\n }\n\n function claim(bytes32 network) public payable override {\n address sender = _msgSender();\n\n uint256 tokenId = _claim(network, sender, msg.value, sender);\n\n emit Claim(sender, network, tokenId);\n }\n\n function grant(\n Assignment[] calldata assignments\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n (bool success, ) = _tryReserve(assignments);\n\n if (!success) {\n revert Forbidden();\n }\n }\n\n function balanceOf(\n address owner\n ) public view override returns (uint256 balance) {\n if (_tokens[owner] != 0) {\n balance = 1;\n }\n }\n\n function networkOf(uint256 tokenId) public view override returns (bytes32) {\n if (_owners[tokenId] == address(0)) {\n revert NotFound();\n }\n\n return _networks[tokenId];\n }\n\n function ownerOf(\n uint256 tokenId\n ) public view override returns (address owner) {\n owner = _owners[tokenId];\n\n if (owner == address(0)) {\n revert NotFound();\n }\n }\n\n function referrals(\n address referrer\n ) public view override returns (uint256) {\n return _referrals[referrer];\n }\n\n function reservations(\n address owner\n ) public view override returns (uint256) {\n return _reservations[owner];\n }\n\n function token(address owner) public view override returns (uint256) {\n return tokenOfOwnerByIndex(owner, 0);\n }\n\n function tokenByIndex(\n uint256 index\n ) public view override returns (uint256) {\n if (index >= totalSupply()) {\n revert NotFound();\n }\n\n return index + 1;\n }\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) public view override returns (uint256 tokenId) {\n tokenId = _tokens[owner];\n\n if (tokenId == 0 || index > 0) {\n revert NotFound();\n }\n }\n\n function totalReservations() public view override returns (uint256) {\n return _totalReservations;\n }\n\n function totalSupply() public view override returns (uint256) {\n unchecked {\n return _tokenIdCounter - 1;\n }\n }\n\n function _assign(address sender, Assignment[] memory assignments) internal {\n uint256 count = _increaseReservations(assignments);\n\n if (!_tryReservationsDecrease(sender, count)) {\n revert Forbidden();\n }\n }\n\n function _callContract(\n bytes32 network,\n bytes32 method,\n bytes memory params,\n uint256 gasFee,\n address refundAddress\n ) internal override {\n if (network == callNetwork) {\n return GatewayV1Call._callContract(method, params);\n }\n\n GatewayV1Axelar._callContract(\n network,\n method,\n params,\n gasFee,\n refundAddress\n );\n }\n\n function _claim(\n bytes32 network,\n address sender,\n uint256 gasFee,\n address refundAddress\n ) internal returns (uint256 tokenId) {\n tokenId = _tokenIdCounter;\n\n if (\n !_tryReservationsDecrease(sender, 1) ||\n !_tryMint(network, sender, tokenId)\n ) {\n revert Forbidden();\n }\n\n unchecked {\n _totalReservations--;\n _tokenIdCounter = tokenId + 1;\n }\n\n _callContract(\n network,\n CLAIM_METHOD,\n abi.encode(sender, tokenId),\n gasFee,\n refundAddress\n );\n }\n\n function _execute(bytes32 method, bytes memory params) internal override {\n _execute(callNetwork, method, params);\n }\n\n function _execute(\n bytes32 network,\n bytes32 method,\n bytes memory params\n ) internal override {\n if (method == ASSIGN_METHOD) {\n _executeAssign(network, params);\n } else if (method == CLAIM_METHOD) {\n _executeClaim(network, params);\n } else if (method == PURCHASE_METHOD) {\n _executePurchase(network, params);\n } else if (method == RESERVE_METHOD) {\n _executeReserve(network, params);\n } else {\n revert NotImplemented();\n }\n }\n\n function _executeAssign(bytes32 network, bytes memory params) internal {\n (address sender, Assignment[] memory assignments) = abi.decode(\n params,\n (address, Assignment[])\n );\n\n _assign(sender, assignments);\n\n emit ExecuteAssign(network, sender, assignments);\n }\n\n function _executeClaim(bytes32 network, bytes memory params) internal {\n address sender = abi.decode(params, (address));\n\n uint256 tokenId = _claim(network, sender, 0, address(0));\n\n emit ExecuteClaim(network, sender, tokenId);\n }\n\n function _executePurchase(bytes32 network, bytes memory params) internal {\n (uint256 purchaseId, address sender, address referrer) = abi.decode(\n params,\n (uint256, address, address)\n );\n\n bool success;\n uint256 tokenId = _tokenIdCounter;\n\n if (\n _totalReservations + tokenId <= maxSupply &&\n _tryMint(network, sender, tokenId)\n ) {\n success = true;\n\n unchecked {\n _tokenIdCounter = tokenId + 1;\n }\n }\n\n if (_tokens[referrer] == 0) {\n delete referrer;\n } else if (success) {\n unchecked {\n ++_referrals[referrer];\n }\n }\n\n emit ExecutePurchase(\n network,\n purchaseId,\n sender,\n referrer,\n tokenId,\n success\n );\n\n _callContract(\n network,\n PURCHASE_METHOD,\n abi.encode(purchaseId, referrer, tokenId, success),\n 0,\n address(0)\n );\n }\n\n function _executeReserve(bytes32 network, bytes memory params) internal {\n (\n uint256 paymentId,\n address sender,\n Assignment[] memory assignments\n ) = abi.decode(params, (uint256, address, Assignment[]));\n\n (bool success, uint256 count) = _tryReserve(assignments);\n\n if (success) {\n _referrals[sender] += count;\n }\n\n bool referred = _tokens[sender] != 0;\n\n emit ExecuteReserve(\n network,\n paymentId,\n sender,\n assignments,\n referred,\n success\n );\n\n _callContract(\n network,\n RESERVE_METHOD,\n abi.encode(paymentId, referred, success),\n 0,\n address(0)\n );\n }\n\n function _increaseReservations(\n Assignment[] memory assignments\n ) internal returns (uint256 count) {\n uint256 length = assignments.length;\n\n for (uint256 i; i < length; ) {\n Assignment memory assignment = assignments[i];\n\n _reservations[assignment.to] += assignment.count;\n\n count += assignment.count;\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _tryMint(\n bytes32 network,\n address to,\n uint256 tokenId\n ) internal returns (bool success) {\n if (_tokens[to] != 0) {\n return false;\n }\n\n _tokens[to] = tokenId;\n _owners[tokenId] = to;\n _networks[tokenId] = network;\n\n emit Mint(network, to, tokenId);\n\n return true;\n }\n\n function _tryReservationsDecrease(\n address owner,\n uint256 count\n ) internal returns (bool success) {\n uint256 reservations_ = _reservations[owner];\n\n if (reservations_ < count) {\n return false;\n }\n\n unchecked {\n _reservations[owner] = reservations_ - count;\n }\n\n return true;\n }\n\n function _tryReserve(\n Assignment[] memory assignments\n ) internal returns (bool success, uint256) {\n uint256 totalReservations_ = _totalReservations +\n countAssignments(assignments);\n\n if (totalReservations_ + totalSupply() > maxSupply) {\n return (false, 0);\n }\n\n _totalReservations = totalReservations_;\n\n return (true, _increaseReservations(assignments));\n }\n}\n" + }, + "contracts/passport/CrowdfundV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ICrowdfundV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"./IPassportV1Reserver.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol\";\n\ncontract CrowdfundV1 is\n AccessControlUpgradeable,\n PullPaymentUpgradeable,\n ICrowdfundV1,\n IPassportV1Reserver\n{\n IPassportV1 public passport;\n\n uint256 private _campaignIdCounter;\n struct Campaign {\n State state;\n address creator;\n string title;\n string description;\n address[] contributors;\n uint256 total;\n uint256 unused;\n }\n mapping(uint256 => Campaign) private _campaigns;\n mapping(uint256 => Assignment[]) private _assignments;\n mapping(uint256 => mapping(address => uint256)) private _contributions;\n\n function initialize(IPassportV1 passport_) public initializer {\n __PullPayment_init();\n\n passport = passport_;\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n receive() external payable {}\n\n function create(\n string memory title_,\n string memory description_,\n Assignment[] memory assignments_\n ) public override returns (uint256 campaignId) {\n unchecked {\n campaignId = _campaignIdCounter++;\n }\n\n address creator_ = _msgSender();\n\n _campaigns[campaignId] = Campaign({\n state: State.PENDING,\n creator: creator_,\n title: title_,\n description: description_,\n contributors: new address[](0),\n total: 0,\n unused: 0\n });\n\n uint256 length = assignments_.length;\n\n for (uint256 i; i < length; ) {\n _assignments[campaignId].push(assignments_[i]);\n\n unchecked {\n ++i;\n }\n }\n\n emit Create(creator_, title_, description_, assignments_, campaignId);\n }\n\n function execute(\n uint256 campaignId,\n uint160 roundIds\n ) public payable override whenExists(campaignId) {\n Assignment[] memory assignments_ = _assignments[campaignId];\n\n uint256 price = countAssignments(assignments_) *\n passport.priceAt(roundIds);\n\n Campaign memory campaign = _campaigns[campaignId];\n\n if (campaign.state != State.PENDING || campaign.total < price) {\n revert Forbidden();\n }\n\n _setState(campaignId, State.EXECUTED);\n\n unchecked {\n _campaigns[campaignId].unused = campaign.total - price;\n }\n\n passport.reserve{value: price + msg.value}(\n roundIds,\n assignments_,\n abi.encode(campaignId)\n );\n }\n\n function fund(\n uint256 campaignId\n ) public payable override whenExists(campaignId) {\n Campaign memory campaign = _campaigns[campaignId];\n\n if (campaign.state != State.PENDING || msg.value == 0) {\n revert Forbidden();\n }\n\n address contributor = _msgSender();\n uint256 contribution = _contributions[campaignId][contributor];\n\n if (contribution == 0) {\n _campaigns[campaignId].contributors.push(contributor);\n }\n\n _campaigns[campaignId].total = campaign.total + msg.value;\n _contributions[campaignId][contributor] = contribution + msg.value;\n\n emit Fund(campaignId, contributor, msg.value);\n }\n\n function onPassportV1Reserved(\n bool success,\n bytes calldata data\n ) public override {\n uint256 campaignId = abi.decode(data, (uint256));\n\n Campaign memory campaign = _campaigns[campaignId];\n\n if (\n campaign.state != State.EXECUTED ||\n _msgSender() != address(passport)\n ) {\n revert Forbidden();\n }\n\n if (success) {\n _setState(campaignId, State.CONFIRMED);\n\n if (campaign.unused > 0) {\n _asyncTransfer(campaign.creator, campaign.unused);\n }\n } else {\n _refund(campaignId);\n }\n }\n\n function refund(uint256 campaignId) public override whenExists(campaignId) {\n Campaign memory campaign = _campaigns[campaignId];\n\n if (\n campaign.state != State.PENDING || _msgSender() != campaign.creator\n ) {\n revert Forbidden();\n }\n\n _refund(campaignId);\n }\n\n function withdraw(\n address recipient,\n uint256 amount\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n _asyncTransfer(recipient, amount);\n }\n\n function assignments(\n uint256 campaignId\n )\n public\n view\n override\n whenExists(campaignId)\n returns (Assignment[] memory)\n {\n return _assignments[campaignId];\n }\n\n function contributors(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (address[] memory) {\n return _campaigns[campaignId].contributors;\n }\n\n function creator(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (address) {\n return _campaigns[campaignId].creator;\n }\n\n function description(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (string memory) {\n return _campaigns[campaignId].description;\n }\n\n function goal(\n uint256 campaignId\n )\n public\n view\n override\n whenExists(campaignId)\n returns (uint160, uint256 amount)\n {\n (uint160 roundIds, uint256 price) = passport.price();\n\n return (roundIds, countAssignments(_assignments[campaignId]) * price);\n }\n\n function state(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (State) {\n return _campaigns[campaignId].state;\n }\n\n function title(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (string memory) {\n return _campaigns[campaignId].title;\n }\n\n function total(\n uint256 campaignId\n ) public view override whenExists(campaignId) returns (uint256) {\n return _campaigns[campaignId].total;\n }\n\n function _refund(uint256 campaignId) internal {\n _setState(campaignId, State.REFUNDED);\n\n address[] memory contributors_ = _campaigns[campaignId].contributors;\n uint256 length = contributors_.length;\n\n for (uint256 i; i < length; ) {\n address contributor = contributors_[i];\n\n _asyncTransfer(\n contributor,\n _contributions[campaignId][contributor]\n );\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _setState(uint256 campaignId, State state_) internal {\n _campaigns[campaignId].state = state_;\n\n emit StateChanged(campaignId, state_);\n }\n\n modifier whenExists(uint256 campaignId) {\n if (_campaigns[campaignId].creator == address(0)) {\n revert NotFound();\n }\n\n _;\n }\n}\n" + }, + "contracts/passport/DateTime.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary/blob/master/contracts/BokkyPooBahsDateTimeLibrary.sol\n */\nlibrary DateTime {\n uint constant SECONDS_PER_DAY = 24 * 60 * 60;\n int constant OFFSET19700101 = 2440588;\n\n function _daysToDate(\n uint _days\n ) internal pure returns (uint year, uint month, uint day) {\n int __days = int(_days);\n\n int L = __days + 68569 + OFFSET19700101;\n int N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int _month = (80 * L) / 2447;\n int _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint(_year);\n month = uint(_month);\n day = uint(_day);\n }\n\n function timestampToDate(\n uint timestamp\n ) internal pure returns (uint year, uint month, uint day) {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n}\n" + }, + "contracts/passport/DrawerV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./DateTime.sol\";\nimport \"./IDrawerV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"./Shared.sol\";\n\nabstract contract DrawerV1 is IDrawerV1 {\n function _createdAt(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n uint256 timestamp = passport.createdAt(tokenId);\n\n return _timestamp(timestamp);\n }\n\n function _updatedAt(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n uint256 timestamp = passport.updatedAt(tokenId);\n\n if (timestamp == 0) {\n return _createdAt(passport, tokenId);\n }\n\n return _timestamp(timestamp);\n }\n\n function _username(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n return string(passport.property(tokenId, keccak256(\"username\")));\n }\n\n function _date(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure virtual returns (string memory);\n\n function _padStart(\n string memory str,\n uint256 length,\n bytes1 char\n ) internal pure returns (string memory) {\n bytes memory strb = bytes(str);\n uint256 strl = strb.length;\n\n if (strl >= length) {\n return str;\n }\n\n uint256 padl;\n unchecked {\n padl = length - strl;\n }\n bytes memory padb = new bytes(padl);\n\n for (; padl > 0; ) {\n unchecked {\n padb[--padl] = char;\n }\n }\n\n return string(bytes.concat(padb, strb));\n }\n\n function _timestamp(\n uint256 timestamp\n ) internal pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day) = DateTime.timestampToDate(\n timestamp\n );\n\n return _date(year, month, day);\n }\n\n modifier whenMinted(IPassportV1 passport, uint256 tokenId) {\n try passport.ownerOf(tokenId) {\n _;\n } catch {\n revert NotFound();\n }\n }\n\n uint256[50] private __gap;\n}\n" + }, + "contracts/passport/DrawerV1Test.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./DrawerV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/Base64Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\n\ncontract DrawerV1Test is DrawerV1 {\n using StringsUpgradeable for uint256;\n\n function tokenURI(\n IPassportV1 passport,\n uint256 tokenId\n )\n public\n view\n override\n whenMinted(passport, tokenId)\n returns (string memory)\n {\n return\n string(\n abi.encodePacked(\n \"data:application/json;base64,\",\n Base64Upgradeable.encode(\n bytes(\n abi.encodePacked(\n '{\"name\":\"Citizen #',\n tokenId.toString(),\n '\",\"image\":\"',\n _image(passport, tokenId),\n '\"}'\n )\n )\n )\n )\n );\n }\n\n function _image(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n return\n string(\n abi.encodePacked(\n \"data:image/svg+xml;base64,\",\n Base64Upgradeable.encode(\n bytes(\n abi.encodePacked(\n 'CITIZEN',\n _padStart(tokenId.toString(), 8, \"0\"),\n '',\n _createdAt(passport, tokenId),\n 'VINYL NATIONDATE OF MINT:',\n _updatedAt(passport, tokenId),\n 'LAST UPDATED:/// PASSPORT NO://///',\n _username(passport, tokenId),\n ''\n )\n )\n )\n )\n );\n }\n\n function _date(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure override returns (string memory) {\n return\n string(\n abi.encodePacked(\n day.toString(),\n \"/\",\n month.toString(),\n \"/\",\n year.toString()\n )\n );\n }\n}\n" + }, + "contracts/passport/DrawerV1VinylNation.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./DrawerV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/Base64Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\n\ncontract DrawerV1VinylNation is DrawerV1 {\n using StringsUpgradeable for uint256;\n\n function tokenURI(\n IPassportV1 passport,\n uint256 tokenId\n )\n public\n view\n override\n whenMinted(passport, tokenId)\n returns (string memory)\n {\n return\n string(\n abi.encodePacked(\n \"data:application/json;base64,\",\n Base64Upgradeable.encode(\n bytes(\n abi.encodePacked(\n '{\"name\":\"Citizen #',\n tokenId.toString(),\n '\",\"image\":\"',\n _image(passport, tokenId),\n '\"}'\n )\n )\n )\n )\n );\n }\n\n function _image(\n IPassportV1 passport,\n uint256 tokenId\n ) internal view returns (string memory) {\n return\n string(\n abi.encodePacked(\n \"data:image/svg+xml;base64,\",\n Base64Upgradeable.encode(\n bytes(\n abi.encodePacked(\n 'CITIZEN',\n _padStart(tokenId.toString(), 8, \"0\"),\n '',\n _createdAt(passport, tokenId),\n 'VINYL NATIONDATE OF MINT:',\n _updatedAt(passport, tokenId),\n 'LAST UPDATED:/// PASSPORT NO://///',\n _username(passport, tokenId),\n ''\n )\n )\n )\n )\n );\n }\n\n function _date(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure override returns (string memory) {\n return\n string(\n abi.encodePacked(\n day.toString(),\n \"/\",\n month.toString(),\n \"/\",\n year.toString()\n )\n );\n }\n}\n" + }, + "contracts/passport/GatewayV1Axelar.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Shared.sol\";\nimport \"@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarExecutable.sol\";\nimport \"@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol\";\nimport \"@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\n\nabstract contract GatewayV1Axelar is\n AccessControlUpgradeable,\n IAxelarExecutable\n{\n IAxelarGateway public override gateway;\n IAxelarGasService public gasService;\n\n struct AxelarDestination {\n string chain;\n string contractAddress;\n }\n mapping(bytes32 => AxelarDestination) public axelarDestinations;\n mapping(string => mapping(string => bytes32)) public axelarSources;\n\n struct AxelarNetwork {\n bytes32 network;\n AxelarDestination axelarDestination;\n }\n\n function __GatewayV1Axelar_init(\n IAxelarGateway axelarGateway,\n IAxelarGasService axelarGasService,\n AxelarNetwork[] calldata axelarNetworks\n ) internal onlyInitializing {\n __GatewayV1Axelar_init_unchained(\n axelarGateway,\n axelarGasService,\n axelarNetworks\n );\n }\n\n function __GatewayV1Axelar_init_unchained(\n IAxelarGateway axelarGateway,\n IAxelarGasService axelarGasService,\n AxelarNetwork[] calldata axelarNetworks\n ) internal onlyInitializing {\n gateway = axelarGateway;\n gasService = axelarGasService;\n\n _addAxelarNetworks(axelarNetworks);\n }\n\n function execute(\n bytes32 commandId,\n string calldata sourceChain,\n string calldata sourceAddress,\n bytes calldata payload\n ) external override {\n bytes32 network = axelarSources[sourceChain][sourceAddress];\n\n if (network == 0) {\n revert Forbidden();\n }\n\n bytes32 payloadHash = keccak256(payload);\n\n if (\n !gateway.validateContractCall(\n commandId,\n sourceChain,\n sourceAddress,\n payloadHash\n )\n ) {\n revert NotApprovedByGateway();\n }\n\n (bytes32 method, bytes memory params) = abi.decode(\n payload,\n (bytes32, bytes)\n );\n\n _execute(network, method, params);\n }\n\n function executeWithToken(\n bytes32,\n string calldata,\n string calldata,\n bytes calldata,\n string calldata,\n uint256\n ) external pure override {\n revert NotImplemented();\n }\n\n function addAxelarNetworks(\n AxelarNetwork[] calldata axelarNetworks\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n _addAxelarNetworks(axelarNetworks);\n }\n\n function removeAxelarNetworks(\n bytes32[] calldata axelarNetworks\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n uint256 length = axelarNetworks.length;\n\n for (uint256 i; i < length; ) {\n bytes32 axelarNetwork = axelarNetworks[i];\n\n AxelarDestination memory axelarDestination = axelarDestinations[\n axelarNetwork\n ];\n\n delete axelarSources[axelarDestination.chain][\n axelarDestination.contractAddress\n ];\n delete axelarDestinations[axelarNetwork];\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _addAxelarNetworks(\n AxelarNetwork[] calldata axelarNetworks\n ) internal {\n uint256 length = axelarNetworks.length;\n\n for (uint256 i; i < length; ) {\n AxelarNetwork calldata axelarNetwork = axelarNetworks[i];\n\n axelarDestinations[axelarNetwork.network] = axelarNetwork\n .axelarDestination;\n axelarSources[axelarNetwork.axelarDestination.chain][\n axelarNetwork.axelarDestination.contractAddress\n ] = axelarNetwork.network;\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _callContract(\n bytes32 network,\n bytes32 method,\n bytes memory params,\n uint256 gasFee,\n address refundAddress\n ) internal virtual {\n AxelarDestination memory axelarDestination = axelarDestinations[\n network\n ];\n\n if (bytes(axelarDestination.chain).length == 0) {\n revert Forbidden();\n }\n\n bytes memory payload = abi.encode(method, params);\n\n if (gasFee > 0) {\n gasService.payNativeGasForContractCall{value: gasFee}(\n address(this),\n axelarDestination.chain,\n axelarDestination.contractAddress,\n payload,\n refundAddress\n );\n }\n\n gateway.callContract(\n axelarDestination.chain,\n axelarDestination.contractAddress,\n payload\n );\n }\n\n function _execute(\n bytes32 network,\n bytes32 method,\n bytes memory params\n ) internal virtual;\n\n uint256[46] private __gap;\n}\n" + }, + "contracts/passport/GatewayV1Call.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Shared.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\nabstract contract GatewayV1Call is AccessControlUpgradeable {\n using AddressUpgradeable for address;\n\n address public callAddress;\n\n function __GatewayV1Call_init(\n address callAddress_\n ) internal onlyInitializing {\n __GatewayV1Call_init_unchained(callAddress_);\n }\n\n function __GatewayV1Call_init_unchained(\n address callAddress_\n ) internal onlyInitializing {\n callAddress = callAddress_;\n }\n\n function execute(bytes32 method, bytes memory params) external {\n if (_msgSender() != callAddress) {\n revert Forbidden();\n }\n\n _execute(method, params);\n }\n\n function setCallAddress(\n address callAddress_\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n callAddress = callAddress_;\n }\n\n function _callContract(bytes32 method, bytes memory params) internal {\n callAddress.functionCall(\n abi.encodeWithSelector(this.execute.selector, method, params)\n );\n }\n\n function _execute(bytes32 method, bytes memory params) internal virtual;\n\n uint256[49] private __gap;\n}\n" + }, + "contracts/passport/IBaseV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Shared.sol\";\n\ninterface IBaseV1 {\n event Assign(address indexed sender, Assignment[] assignments);\n event Claim(\n address indexed sender,\n bytes32 indexed network,\n uint256 tokenId\n );\n event ExecuteAssign(\n bytes32 indexed network,\n address indexed sender,\n Assignment[] assignments\n );\n event ExecuteClaim(\n bytes32 indexed network,\n address indexed sender,\n uint256 tokenId\n );\n event ExecutePurchase(\n bytes32 indexed network,\n uint256 indexed paymentId,\n address indexed sender,\n address referrer,\n uint256 tokenId,\n bool success\n );\n event ExecuteReserve(\n bytes32 indexed network,\n uint256 indexed paymentId,\n address indexed sender,\n Assignment[] assignments,\n bool referred,\n bool success\n );\n event Mint(\n bytes32 indexed network,\n address indexed to,\n uint256 indexed tokenId\n );\n\n function assign(Assignment[] calldata assignments) external;\n\n function claim(bytes32 network) external payable;\n\n function balanceOf(address owner) external view returns (uint256 balance);\n\n function networkOf(uint256 tokenId) external view returns (bytes32 network);\n\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n function referrals(address referrer) external view returns (uint256);\n\n function reservations(address owner) external view returns (uint256);\n\n function token(address owner) external view returns (uint256);\n\n function tokenByIndex(uint256 index) external view returns (uint256);\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) external view returns (uint256);\n\n function totalReservations() external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n}\n" + }, + "contracts/passport/ICrowdfundV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IPassportV1.sol\";\n\ninterface ICrowdfundV1 {\n event Create(\n address indexed creator,\n string title,\n string description,\n Assignment[] assignments,\n uint256 indexed campaignId\n );\n event Fund(\n uint256 indexed campaignId,\n address indexed contributor,\n uint256 amount\n );\n event StateChanged(uint256 indexed campaignId, State state);\n\n enum State {\n PENDING,\n EXECUTED,\n CONFIRMED,\n REFUNDED\n }\n\n function create(\n string memory title_,\n string memory description_,\n Assignment[] calldata assignments_\n ) external returns (uint256 campaignId);\n\n function execute(uint256 campaignId, uint160 roundIds) external payable;\n\n function fund(uint256 campaignId) external payable;\n\n function refund(uint256 campaignId) external;\n\n function assignments(\n uint256 campaignId\n ) external view returns (Assignment[] memory);\n\n function contributors(\n uint256 campaignId\n ) external view returns (address[] memory);\n\n function creator(uint256 campaignId) external view returns (address);\n\n function description(\n uint256 campaignId\n ) external view returns (string memory);\n\n function goal(\n uint256 campaignId\n ) external view returns (uint160 roundIds, uint256 amount);\n\n function state(uint256 campaignId) external view returns (State);\n\n function title(uint256 campaignId) external view returns (string memory);\n\n function total(uint256 campaignId) external view returns (uint256);\n}\n" + }, + "contracts/passport/IDrawerV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IPassportV1.sol\";\n\ninterface IDrawerV1 {\n function tokenURI(\n IPassportV1 passport,\n uint256 tokenId\n ) external view returns (string memory);\n}\n" + }, + "contracts/passport/IPassportV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Shared.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol\";\n\ninterface IPassportV1 is\n IERC721EnumerableUpgradeable,\n IERC721MetadataUpgradeable\n{\n event Assign(address indexed sender, Assignment[] assignments);\n event Claim(address indexed sender);\n event ExecuteClaim(address indexed sender, uint256 tokenId);\n event ExecutePurchase(\n uint256 indexed paymentId,\n address payable indexed sender,\n uint256 value,\n address referrer,\n uint256 tokenId,\n bool success\n );\n event ExecuteReserve(\n uint256 indexed paymentId,\n address payable indexed sender,\n uint256 value,\n bool referred,\n bool success\n );\n event Payout(address payable indexed recipient, uint256 amount);\n event Purchase(\n uint256 indexed paymentId,\n address payable indexed sender,\n uint256 value,\n address referrer\n );\n event Reserve(\n uint256 indexed paymentId,\n address payable indexed sender,\n uint256 value,\n Assignment[] assignments\n );\n event SetProperty(uint256 indexed tokenId, bytes32 key, bytes value);\n event SetPropertyBatch(uint256 indexed tokenId, Property[] properties);\n\n struct Property {\n bytes32 key;\n bytes value;\n }\n\n function assign(Assignment[] calldata assignments) external payable;\n\n function claim() external payable;\n\n function purchase(\n uint160 roundIds,\n address referrer,\n bytes calldata data\n ) external payable;\n\n function reserve(\n uint160 roundIds,\n Assignment[] calldata assignments,\n bytes calldata data\n ) external payable;\n\n function setProperty(bytes32 key, bytes calldata value) external;\n\n function setPropertyBatch(Property[] calldata properties) external;\n\n function createdAt(uint256 tokenId) external view returns (uint256);\n\n function price() external view returns (uint160 roundIds, uint256);\n\n function priceAt(uint160 roundIds) external view returns (uint256);\n\n function property(\n uint256 tokenId,\n bytes32 key\n ) external view returns (bytes memory value);\n\n function propertyBatch(\n uint256 tokenId,\n bytes32[] calldata keys\n ) external view returns (bytes[] memory values);\n\n function token(address owner) external view returns (uint256);\n\n function updatedAt(uint256 tokenId) external view returns (uint256);\n}\n" + }, + "contracts/passport/IPassportV1Purchaser.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IPassportV1Purchaser {\n function onPassportV1Purchased(bool success, bytes calldata data) external;\n}\n" + }, + "contracts/passport/IPassportV1Reserver.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IPassportV1Reserver {\n function onPassportV1Reserved(bool success, bytes calldata data) external;\n}\n" + }, + "contracts/passport/PassportV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IDrawerV1.sol\";\nimport \"./IPassportV1.sol\";\nimport \"./IPassportV1Purchaser.sol\";\nimport \"./IPassportV1Reserver.sol\";\nimport \"./Shared.sol\";\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\nuint256 constant PRICE_MAX_AGE = 24 hours;\n\nabstract contract PassportV1 is\n AccessControlUpgradeable,\n ERC721Upgradeable,\n PullPaymentUpgradeable,\n IPassportV1\n{\n using AddressUpgradeable for address payable;\n\n uint256 public priceAmount;\n AggregatorV3Interface public priceFeed1;\n AggregatorV3Interface public priceFeed2;\n uint256 public incentive;\n address payable public treasury;\n IDrawerV1 public drawer;\n\n uint256 private _paymentIdCounter;\n struct Payment {\n address payable sender;\n uint256 value;\n bytes data;\n }\n mapping(uint256 => Payment) private _payments;\n\n uint256[] private _allTokens;\n mapping(address => uint256) private _tokens;\n\n mapping(uint256 => uint256) private _createdAts;\n mapping(uint256 => uint256) private _updatedAts;\n mapping(uint256 => mapping(bytes32 => bytes)) private _properties;\n\n function __PassportV1_init(\n string memory name,\n string memory symbol,\n uint256 priceAmount_,\n AggregatorV3Interface priceFeed1_,\n AggregatorV3Interface priceFeed2_,\n uint256 incentive_,\n address payable treasury_,\n IDrawerV1 drawer_\n ) internal onlyInitializing {\n __ERC721_init_unchained(name, symbol);\n __PassportV1_init_unchained(\n priceAmount_,\n priceFeed1_,\n priceFeed2_,\n incentive_,\n treasury_,\n drawer_\n );\n __PullPayment_init_unchained();\n }\n\n function __PassportV1_init_unchained(\n uint256 priceAmount_,\n AggregatorV3Interface priceFeed1_,\n AggregatorV3Interface priceFeed2_,\n uint256 incentive_,\n address payable treasury_,\n IDrawerV1 drawer_\n ) internal onlyInitializing {\n priceAmount = priceAmount_;\n priceFeed1 = priceFeed1_;\n priceFeed2 = priceFeed2_;\n incentive = incentive_;\n treasury = treasury_;\n drawer = drawer_;\n }\n\n function assign(Assignment[] calldata assignments) public payable override {\n address sender = _msgSender();\n\n emit Assign(sender, assignments);\n\n _callContract(\n ASSIGN_METHOD,\n abi.encode(sender, assignments),\n msg.value,\n sender\n );\n }\n\n function claim() public payable override whenNotToken {\n address sender = _msgSender();\n\n emit Claim(sender);\n\n _callContract(CLAIM_METHOD, abi.encode(sender), msg.value, sender);\n }\n\n function purchase(\n uint160 roundIds,\n address referrer,\n bytes calldata data\n ) public payable override whenNotToken {\n (\n uint256 paymentId,\n Payment memory payment,\n uint256 unused\n ) = _createPayment(roundIds, 1, data);\n\n emit Purchase(paymentId, payment.sender, payment.value, referrer);\n\n _callContract(\n PURCHASE_METHOD,\n abi.encode(paymentId, payment.sender, referrer),\n unused,\n payment.sender\n );\n }\n\n function reserve(\n uint160 roundIds,\n Assignment[] calldata assignments,\n bytes calldata data\n ) public payable override {\n (\n uint256 paymentId,\n Payment memory payment,\n uint256 unused\n ) = _createPayment(roundIds, countAssignments(assignments), data);\n\n emit Reserve(paymentId, payment.sender, payment.value, assignments);\n\n _callContract(\n RESERVE_METHOD,\n abi.encode(paymentId, payment.sender, assignments),\n unused,\n payment.sender\n );\n }\n\n function setDrawer(\n IDrawerV1 drawer_\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n drawer = drawer_;\n }\n\n function setProperty(bytes32 key, bytes calldata value) public override {\n uint256 tokenId = _requireTokenUpdate();\n\n _properties[tokenId][key] = value;\n\n emit SetProperty(tokenId, key, value);\n }\n\n function setPropertyBatch(Property[] calldata properties) public override {\n uint256 tokenId = _requireTokenUpdate();\n\n uint256 length = properties.length;\n\n for (uint256 i; i < length; ) {\n Property memory property_ = properties[i];\n\n _properties[tokenId][property_.key] = property_.value;\n\n unchecked {\n ++i;\n }\n }\n\n emit SetPropertyBatch(tokenId, properties);\n }\n\n function withdraw(\n address recipient,\n uint256 amount\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n _asyncTransfer(recipient, amount);\n }\n\n function withdrawPayment(\n uint256 paymentId\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\n Payment memory payment = _requirePaymentDelete(paymentId);\n\n _asyncTransfer(payment.sender, payment.value);\n }\n\n function createdAt(\n uint256 tokenId\n ) public view override whenMinted(tokenId) returns (uint256) {\n return _createdAts[tokenId];\n }\n\n function price() public view override returns (uint160 roundIds, uint256) {\n int256 answer1;\n int256 answer2;\n\n if (address(priceFeed1) != address(0)) {\n (uint80 roundId, int256 answer, , , ) = priceFeed1\n .latestRoundData();\n\n roundIds |= roundId;\n answer1 = answer;\n }\n\n if (address(priceFeed2) != address(0)) {\n (uint80 roundId, int256 answer, , , ) = priceFeed2\n .latestRoundData();\n\n roundIds |= uint160(roundId) << 80;\n answer2 = answer;\n }\n\n return (roundIds, _price(answer1, answer2));\n }\n\n function priceAt(uint160 roundIds) public view override returns (uint256) {\n int256 answer1;\n int256 answer2;\n\n if (address(priceFeed1) != address(0)) {\n answer1 = _getRoundAnswer(priceFeed1, uint80(roundIds));\n }\n\n if (address(priceFeed2) != address(0)) {\n answer2 = _getRoundAnswer(priceFeed2, uint80(roundIds >> 80));\n }\n\n return _price(answer1, answer2);\n }\n\n function property(\n uint256 tokenId,\n bytes32 key\n ) public view override whenMinted(tokenId) returns (bytes memory) {\n return _properties[tokenId][key];\n }\n\n function propertyBatch(\n uint256 tokenId,\n bytes32[] calldata keys\n ) public view override whenMinted(tokenId) returns (bytes[] memory values) {\n uint256 length = keys.length;\n\n for (uint256 i; i < length; ) {\n values[i] = _properties[tokenId][keys[i]];\n\n unchecked {\n ++i;\n }\n }\n }\n\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n virtual\n override(\n AccessControlUpgradeable,\n ERC721Upgradeable,\n IERC165Upgradeable\n )\n returns (bool)\n {\n return\n interfaceId == type(IERC721EnumerableUpgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n interfaceId == type(IPassportV1).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n function token(address owner) public view override returns (uint256) {\n return tokenOfOwnerByIndex(owner, 0);\n }\n\n function tokenByIndex(\n uint256 index\n ) public view override returns (uint256) {\n if (index >= _allTokens.length) {\n revert NotFound();\n }\n\n return _allTokens[index];\n }\n\n function tokenOfOwnerByIndex(\n address owner,\n uint256 index\n ) public view override returns (uint256 tokenId) {\n tokenId = _tokens[owner];\n\n if (tokenId == 0 || index > 0) {\n revert NotFound();\n }\n }\n\n function tokenURI(\n uint256 tokenId\n )\n public\n view\n override(ERC721Upgradeable, IERC721MetadataUpgradeable)\n whenMinted(tokenId)\n returns (string memory)\n {\n return drawer.tokenURI(this, tokenId);\n }\n\n function totalSupply() public view override returns (uint256) {\n return _allTokens.length;\n }\n\n function updatedAt(\n uint256 tokenId\n ) public view override whenMinted(tokenId) returns (uint256) {\n return _updatedAts[tokenId];\n }\n\n function _afterExecutePurchase(bool success) internal virtual {}\n\n function _afterExecuteReserve(bool success) internal virtual {}\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId,\n uint256\n ) internal override {\n if (from != address(0) || _tokens[to] != 0) {\n revert Forbidden();\n }\n\n _allTokens.push(tokenId);\n _tokens[to] = tokenId;\n\n _createdAts[tokenId] = block.timestamp;\n }\n\n function _callContract(\n bytes32 method,\n bytes memory params,\n uint256 gasFee,\n address refundAddress\n ) internal virtual;\n\n function _createPayment(\n uint160 roundIds,\n uint256 count,\n bytes calldata data\n )\n internal\n returns (uint256 paymentId, Payment memory payment, uint256 unused)\n {\n payment = Payment({\n sender: payable(_msgSender()),\n value: count * priceAt(roundIds),\n data: data\n });\n\n if (msg.value < payment.value) {\n revert Forbidden();\n }\n\n unchecked {\n paymentId = _paymentIdCounter++;\n unused = msg.value - payment.value;\n }\n\n _payments[paymentId] = payment;\n }\n\n function _doHook(address target, bytes memory data) internal {\n if (target.code.length > 0) {\n (bool success, ) = target.call(data);\n success;\n }\n }\n\n function _doTransfer(address payable recipient, uint256 amount) internal {\n recipient.sendValue(amount);\n\n emit Payout(recipient, amount);\n }\n\n function _execute(bytes32 method, bytes memory params) internal virtual {\n if (method == CLAIM_METHOD) {\n _executeClaim(params);\n } else if (method == PURCHASE_METHOD) {\n _executePurchase(params);\n } else if (method == RESERVE_METHOD) {\n _executeReserve(params);\n } else {\n revert NotImplemented();\n }\n }\n\n function _executeClaim(bytes memory params) internal {\n (address sender, uint256 tokenId) = abi.decode(\n params,\n (address, uint256)\n );\n\n _mint(sender, tokenId);\n\n emit ExecuteClaim(sender, tokenId);\n }\n\n function _executePurchase(bytes memory params) internal {\n (\n uint256 paymentId,\n address referrer,\n uint256 tokenId,\n bool success\n ) = abi.decode(params, (uint256, address, uint256, bool));\n\n Payment memory payment = _requirePaymentDelete(paymentId);\n\n emit ExecutePurchase(\n paymentId,\n payment.sender,\n payment.value,\n referrer,\n tokenId,\n success\n );\n\n if (success) {\n _mint(payment.sender, tokenId);\n\n if (referrer != address(0)) {\n uint256 n = (payment.value * incentive) / 100;\n\n _doTransfer(payment.sender, n);\n _asyncTransfer(referrer, n);\n\n payment.value -= n + n;\n }\n }\n\n _doTransfer(success ? treasury : payment.sender, payment.value);\n\n _doHook(\n payment.sender,\n abi.encodeWithSelector(\n IPassportV1Purchaser.onPassportV1Purchased.selector,\n success,\n payment.data\n )\n );\n\n _afterExecutePurchase(success);\n }\n\n function _executeReserve(bytes memory params) internal {\n (uint256 paymentId, bool referred, bool success) = abi.decode(\n params,\n (uint256, bool, bool)\n );\n\n Payment memory payment = _requirePaymentDelete(paymentId);\n\n emit ExecuteReserve(\n paymentId,\n payment.sender,\n payment.value,\n referred,\n success\n );\n\n if (success && referred) {\n uint256 n = (payment.value * incentive) / 100;\n\n _doTransfer(payment.sender, n);\n\n payment.value -= n;\n }\n\n _doTransfer(success ? treasury : payment.sender, payment.value);\n\n _doHook(\n payment.sender,\n abi.encodeWithSelector(\n IPassportV1Reserver.onPassportV1Reserved.selector,\n success,\n payment.data\n )\n );\n\n _afterExecuteReserve(success);\n }\n\n function _requirePaymentDelete(\n uint256 paymentId\n ) internal returns (Payment memory state) {\n state = _payments[paymentId];\n\n if (state.sender == address(0)) {\n revert Forbidden();\n }\n\n delete _payments[paymentId];\n }\n\n function _requireTokenUpdate() internal returns (uint256 tokenId) {\n tokenId = _tokens[_msgSender()];\n\n if (tokenId == 0) {\n revert Forbidden();\n }\n\n _updatedAts[tokenId] = block.timestamp;\n }\n\n function _getRoundAnswer(\n AggregatorV3Interface priceFeed,\n uint80 roundId\n ) internal view returns (int256) {\n (, int256 answer, , uint256 timestamp, ) = priceFeed.getRoundData(\n roundId\n );\n\n if (timestamp < block.timestamp - PRICE_MAX_AGE) {\n revert Forbidden();\n }\n\n return answer;\n }\n\n function _price(\n int256 answer1,\n int256 answer2\n ) internal view returns (uint256) {\n uint256 base = 1e18;\n uint256 quote = 1e18;\n\n if (address(priceFeed1) != address(0)) {\n base = _priceFeedAnswer(priceFeed1, answer1);\n }\n\n if (address(priceFeed2) != address(0)) {\n quote = _priceFeedAnswer(priceFeed2, answer2);\n }\n\n return (priceAmount * base) / quote;\n }\n\n function _priceFeedAnswer(\n AggregatorV3Interface priceFeed,\n int256 answer\n ) internal view returns (uint256) {\n require(answer > 0);\n\n uint8 decimals = priceFeed.decimals();\n\n if (decimals < 18) {\n return uint256(answer) * (10 ** (18 - decimals));\n } else if (decimals > 18) {\n return uint256(answer) / (10 ** (decimals - 18));\n }\n\n return uint256(answer);\n }\n\n function _requireMinted(uint256 tokenId) internal view override {\n if (!_exists(tokenId)) {\n revert NotFound();\n }\n }\n\n modifier whenMinted(uint256 tokenId) {\n _requireMinted(tokenId);\n _;\n }\n\n modifier whenNotToken() {\n uint256 tokenId = _tokens[_msgSender()];\n\n if (tokenId != 0) {\n revert Forbidden();\n }\n\n _;\n }\n\n uint256[37] private __gap;\n}\n" + }, + "contracts/passport/PassportV1AsyncMock.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./GatewayV1Call.sol\";\nimport \"./PassportV1.sol\";\n\ncontract PassportV1AsyncMock is GatewayV1Call, PassportV1 {\n function initialize(\n address callAddress,\n string memory name,\n string memory symbol,\n uint256 priceAmount,\n AggregatorV3Interface priceFeed1,\n AggregatorV3Interface priceFeed2,\n uint256 incentive,\n address payable treasury,\n IDrawerV1 drawer\n ) public initializer {\n __GatewayV1Call_init(callAddress);\n __PassportV1_init(\n name,\n symbol,\n priceAmount,\n priceFeed1,\n priceFeed2,\n incentive,\n treasury,\n drawer\n );\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n override(AccessControlUpgradeable, PassportV1)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n function _callContract(\n bytes32 method,\n bytes memory params,\n uint256,\n address\n ) internal override {\n GatewayV1Call._callContract(method, params);\n }\n\n function _execute(\n bytes32 method,\n bytes memory params\n ) internal override(GatewayV1Call, PassportV1) {\n PassportV1._execute(method, params);\n }\n}\n" + }, + "contracts/passport/PassportV1Axelar.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./GatewayV1Axelar.sol\";\nimport \"./PassportV1.sol\";\n\nbytes32 constant BASE_NETWORK = keccak256(\"BASE_NETWORK\");\n\ncontract PassportV1Axelar is GatewayV1Axelar, PassportV1 {\n function initialize(\n IAxelarGateway axelarGateway,\n IAxelarGasService axelarGasService,\n AxelarNetwork[] calldata axelarNetworks,\n string memory name,\n string memory symbol,\n uint256 priceAmount,\n AggregatorV3Interface priceFeed1,\n AggregatorV3Interface priceFeed2,\n uint256 incentive,\n address payable treasury,\n IDrawerV1 drawer\n ) public initializer {\n __GatewayV1Axelar_init(axelarGateway, axelarGasService, axelarNetworks);\n __PassportV1_init(\n name,\n symbol,\n priceAmount,\n priceFeed1,\n priceFeed2,\n incentive,\n treasury,\n drawer\n );\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n override(AccessControlUpgradeable, PassportV1)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n function _callContract(\n bytes32 method,\n bytes memory params,\n uint256 gasFee,\n address refundAddress\n ) internal override {\n GatewayV1Axelar._callContract(\n BASE_NETWORK,\n method,\n params,\n gasFee,\n refundAddress\n );\n }\n\n function _execute(\n bytes32,\n bytes32 method,\n bytes memory params\n ) internal override {\n PassportV1._execute(method, params);\n }\n}\n" + }, + "contracts/passport/PassportV1Call.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./GatewayV1Call.sol\";\nimport \"./PassportV1.sol\";\n\ncontract PassportV1Call is GatewayV1Call, PassportV1 {\n function initialize(\n address callAddress,\n string memory name,\n string memory symbol,\n uint256 priceAmount,\n AggregatorV3Interface priceFeed1,\n AggregatorV3Interface priceFeed2,\n uint256 incentive,\n address payable treasury,\n IDrawerV1 drawer\n ) public initializer {\n __GatewayV1Call_init(callAddress);\n __PassportV1_init(\n name,\n symbol,\n priceAmount,\n priceFeed1,\n priceFeed2,\n incentive,\n treasury,\n drawer\n );\n\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n override(AccessControlUpgradeable, PassportV1)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n function _callContract(\n bytes32 method,\n bytes memory params,\n uint256,\n address\n ) internal override {\n GatewayV1Call._callContract(method, params);\n }\n\n function _execute(\n bytes32 method,\n bytes memory params\n ) internal override(GatewayV1Call, PassportV1) {\n PassportV1._execute(method, params);\n }\n\n function _afterExecutePurchase(bool success) internal pure override {\n if (!success) {\n revert Forbidden();\n }\n }\n\n function _afterExecuteReserve(bool success) internal pure override {\n if (!success) {\n revert Forbidden();\n }\n }\n}\n" + }, + "contracts/passport/PaymentSplitterV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\ncontract PaymentSplitterV1 is Initializable {\n using AddressUpgradeable for address payable;\n\n struct Recipient {\n address payable account;\n uint256 shares;\n }\n Recipient[] public recipients;\n\n uint256 private _totalShares;\n\n function initialize(Recipient[] calldata recipients_) public initializer {\n _addRecipients(recipients_);\n }\n\n receive() external payable {\n _sendValue(address(this).balance);\n }\n\n function _addRecipients(Recipient[] calldata recipients_) internal {\n uint256 length = recipients_.length;\n\n for (uint256 i; i < length; ) {\n Recipient calldata recipient = recipients_[i];\n\n recipients.push(recipient);\n\n _totalShares += recipient.shares;\n\n unchecked {\n ++i;\n }\n }\n }\n\n function _sendValue(uint256 amount) internal {\n uint256 length = recipients.length;\n\n for (uint256 i; i < length; ) {\n Recipient memory recipient = recipients[i];\n\n recipient.account.sendValue(\n (amount * recipient.shares) / _totalShares\n );\n\n unchecked {\n ++i;\n }\n }\n }\n}\n" + }, + "contracts/passport/Shared.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nbytes32 constant ASSIGN_METHOD = keccak256(\"ASSIGN_METHOD\");\nbytes32 constant CLAIM_METHOD = keccak256(\"CLAIM_METHOD\");\nbytes32 constant PURCHASE_METHOD = keccak256(\"PURCHASE_METHOD\");\nbytes32 constant RESERVE_METHOD = keccak256(\"RESERVE_METHOD\");\n\nerror Forbidden();\nerror NotFound();\nerror NotImplemented();\n\nstruct Assignment {\n address to;\n uint256 count;\n}\n\nfunction countAssignments(\n Assignment[] memory assignments\n) pure returns (uint256 count) {\n uint256 length = assignments.length;\n\n for (uint256 i; i < length; ) {\n count += assignments[i].count;\n\n unchecked {\n ++i;\n }\n }\n}\n" + }, + "contracts/payment/PaymentConfigRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"../AccessRegistry.sol\";\n\nbytes32 constant PAYMENT_ADMIN_ROLE = keccak256(\"PAYMENT_ADMIN_ROLE\");\n\ncontract PaymentConfigRegistry is OwnableUpgradeable {\n using ECDSA for bytes;\n using ECDSA for bytes32;\n\n error InvalidSignature();\n error Forbidden();\n error CannotWithdraw();\n\n address public accessRegistry;\n address public authorizedSigner;\n uint256 public feePPM;\n uint256[20] __gap;\n\n event FeeCollected(string eventId, address token, uint256 amount);\n\n function initialize(\n address registry,\n address signer,\n uint256 ppm\n ) public initializer {\n __Ownable_init();\n accessRegistry = registry;\n authorizedSigner = signer;\n feePPM = ppm;\n }\n\n function setAccessRegistry(address registry) external onlyOwner {\n accessRegistry = registry;\n }\n\n function setAuthorizedSigner(address signer) external onlyAdmin {\n authorizedSigner = signer;\n }\n\n function setFeePPM(uint256 ppm) external onlyAdmin {\n feePPM = ppm;\n }\n\n function withdraw(\n address token,\n uint256 amount,\n address payable destination\n ) external onlyAdmin {\n bool success;\n\n if (token == address(0)) {\n (success, ) = destination.call{value: amount}(\"\");\n } else {\n success = IERC20(token).transfer(destination, amount);\n }\n\n if (!success) revert CannotWithdraw();\n }\n\n function notifyFee(\n string calldata eventId,\n address token,\n uint256 amount\n ) external {\n emit FeeCollected(eventId, token, amount);\n }\n\n function assertSignature(\n bytes32[] calldata data,\n bytes calldata signature\n ) public view {\n address actualSigner = abi\n .encode(data)\n .toEthSignedMessageHash()\n .recover(signature);\n\n if (actualSigner != authorizedSigner) {\n revert InvalidSignature();\n }\n }\n\n function balances(\n address[] calldata currencies\n ) external view returns (uint256[] memory balance_) {\n uint256 length = currencies.length;\n\n balance_ = new uint256[](length);\n\n address contractAddress = address(this);\n\n for (uint256 i = 0; i < length; ) {\n address currency = currencies[i];\n\n if (currency == address(0)) {\n balance_[i] = contractAddress.balance;\n } else {\n balance_[i] = IERC20(currency).balanceOf(contractAddress);\n }\n\n unchecked {\n ++i;\n }\n }\n\n return balance_;\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n\n modifier onlyAdmin() {\n if (\n !AccessRegistry(accessRegistry).hasRole(\n PAYMENT_ADMIN_ROLE,\n _msgSender()\n )\n ) {\n revert Forbidden();\n }\n _;\n }\n}\n" + }, + "contracts/payment/PaymentSplitter.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol)\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @title PaymentSplitter\n * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware\n * that the Ether will be split in this way, since it is handled transparently by the contract.\n *\n * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each\n * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim\n * an amount proportional to the percentage of total shares they were assigned.\n *\n * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the\n * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}\n * function.\n *\n * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and\n * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you\n * to run tests before sending real value to this contract.\n */\n\nstruct Payee {\n address account;\n uint256 shares;\n}\n\ncontract PaymentSplitter is Context {\n uint256 private _totalShares;\n uint256 private _totalReleased;\n\n mapping(address => uint256) private _shares;\n mapping(address => uint256) private _released;\n address[] private _payees;\n\n mapping(IERC20 => uint256) private _erc20TotalReleased;\n mapping(IERC20 => mapping(address => uint256)) private _erc20Released;\n\n event PayeeAdded(address account, uint256 shares);\n event PayeesReset();\n event PaymentReleased(address to, uint256 amount);\n event ERC20PaymentReleased(\n IERC20 indexed token,\n address to,\n uint256 amount\n );\n event PaymentReceived(address from, uint256 amount);\n\n error LengthMismatch();\n error ZeroLength();\n error AccountHasNoShare();\n error AccountHasShare();\n error NoDueAmount();\n error InvalidShare();\n error InvalidAddress();\n\n /**\n * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at\n * the matching position in the `shares` array.\n *\n * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no\n * duplicates in `payees`.\n */\n constructor(address[] memory payees, uint256[] memory shares_) payable {\n if (payees.length == 0) revert ZeroLength();\n\n if (payees.length != shares_.length) revert LengthMismatch();\n\n for (uint256 i = 0; i < payees.length; i++) {\n _addPayee(payees[i], shares_[i]);\n }\n }\n\n /**\n * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully\n * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the\n * reliability of the events, and not the actual splitting of Ether.\n *\n * To learn more about this see the Solidity documentation for\n * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback\n * functions].\n */\n receive() external payable virtual {\n emit PaymentReceived(_msgSender(), msg.value);\n }\n\n /**\n * @dev Getter for the total shares held by payees.\n */\n function totalShares() public view returns (uint256) {\n return _totalShares;\n }\n\n /**\n * @dev Getter for the total amount of Ether already released.\n */\n function totalReleased() public view returns (uint256) {\n return _totalReleased;\n }\n\n /**\n * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20\n * contract.\n */\n function totalReleased(IERC20 token) public view returns (uint256) {\n return _erc20TotalReleased[token];\n }\n\n /**\n * @dev Getter for the amount of shares held by an account.\n */\n function shares(address account) public view returns (uint256) {\n return _shares[account];\n }\n\n /**\n * @dev Getter for the amount of Ether already released to a payee.\n */\n function released(address account) public view returns (uint256) {\n return _released[account];\n }\n\n /**\n * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an\n * IERC20 contract.\n */\n function released(\n IERC20 token,\n address account\n ) public view returns (uint256) {\n return _erc20Released[token][account];\n }\n\n function released(\n address[] calldata currencies,\n address account\n ) public view returns (uint256[] memory balances) {\n uint256 length = currencies.length;\n\n if (length == 0) revert ZeroLength();\n\n balances = new uint256[](length);\n\n for (uint256 i = 0; i < length; ) {\n address currency = currencies[i];\n\n if (currency == address(0)) {\n balances[i] = released(account);\n } else {\n balances[i] = released(IERC20(currency), account);\n }\n\n unchecked {\n ++i;\n }\n }\n\n return balances;\n }\n\n function pending(address account) public view returns (uint256) {\n uint256 totalReceived = address(this).balance + totalReleased();\n return _pendingPayment(account, totalReceived, released(account));\n }\n\n function pending(\n IERC20 token,\n address account\n ) public view returns (uint256) {\n uint256 totalReceived = token.balanceOf(address(this)) +\n totalReleased(token);\n return\n _pendingPayment(account, totalReceived, released(token, account));\n }\n\n function pending(\n address[] calldata currencies,\n address account\n ) public view returns (uint256[] memory balances) {\n uint256 length = currencies.length;\n\n if (length == 0) revert ZeroLength();\n\n balances = new uint256[](length);\n\n for (uint256 i = 0; i < length; ) {\n address currency = currencies[i];\n\n if (currency == address(0)) {\n balances[i] = pending(account);\n } else {\n balances[i] = pending(IERC20(currency), account);\n }\n\n unchecked {\n ++i;\n }\n }\n\n return balances;\n }\n\n function allPayees() public view returns (Payee[] memory payees) {\n uint256 length = _payees.length;\n\n payees = new Payee[](length);\n\n for (uint256 i; i < length; ) {\n address account = _payees[i];\n payees[i] = Payee(account, _shares[account]);\n\n unchecked {\n ++i;\n }\n }\n\n return payees;\n }\n\n /**\n * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the\n * total shares and their previous withdrawals.\n */\n function release(address payable account) public virtual {\n if (_shares[account] == 0) revert AccountHasNoShare();\n\n uint256 payment = pending(account);\n\n if (payment == 0) revert NoDueAmount();\n\n _released[account] += payment;\n _totalReleased += payment;\n\n Address.sendValue(account, payment);\n emit PaymentReleased(account, payment);\n }\n\n /**\n * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their\n * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20\n * contract.\n */\n function release(IERC20 token, address account) public virtual {\n if (_shares[account] == 0) revert AccountHasNoShare();\n\n uint256 payment = pending(token, account);\n\n if (payment == 0) revert NoDueAmount();\n\n _erc20Released[token][account] += payment;\n _erc20TotalReleased[token] += payment;\n\n SafeERC20.safeTransfer(token, account, payment);\n emit ERC20PaymentReleased(token, account, payment);\n }\n\n function release(\n address[] calldata currencies,\n address payable account\n ) public virtual {\n uint256 length = currencies.length;\n\n if (length == 0) revert ZeroLength();\n\n for (uint256 i = 0; i < length; ) {\n address currency = currencies[i];\n if (currency == address(0)) {\n release(account);\n } else {\n release(IERC20(currency), account);\n }\n\n unchecked {\n ++i;\n }\n }\n }\n\n /**\n * @dev internal logic for computing the pending payment of an `account` given the token historical balances and\n * already released amounts.\n */\n function _pendingPayment(\n address account,\n uint256 totalReceived,\n uint256 alreadyReleased\n ) private view returns (uint256) {\n return\n (totalReceived * _shares[account]) / _totalShares - alreadyReleased;\n }\n\n /**\n * @dev Add a new payee to the contract.\n * @param account The address of the payee to add.\n * @param shares_ The number of shares owned by the payee.\n */\n function _addPayee(address account, uint256 shares_) private {\n if (account == address(0)) revert InvalidAddress();\n\n if (shares_ == 0) revert InvalidShare();\n\n if (_shares[account] != 0) revert AccountHasShare();\n\n _payees.push(account);\n _shares[account] = shares_;\n _totalShares = _totalShares + shares_;\n emit PayeeAdded(account, shares_);\n }\n\n function _resetPayees(\n address[] memory payees,\n uint256[] memory shares_\n ) internal {\n //-- reset total share\n _totalShares = 0;\n\n //-- reset payees array\n delete _payees;\n\n for (uint256 i = 0; i < payees.length; i++) {\n address account = payees[i];\n uint256 shared = shares_[i];\n\n if (account == address(0)) revert InvalidAddress();\n\n if (shared == 0) revert InvalidShare();\n\n _payees.push(account);\n _shares[account] = shared;\n _totalShares = _totalShares + shared;\n }\n\n emit PayeesReset();\n }\n}\n" + }, + "contracts/payment/relay/LemonadeRelayPayment.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"../PaymentConfigRegistry.sol\";\nimport \"../PaymentSplitter.sol\";\n\ncontract RelayPaymentSplitter is PaymentSplitter {\n address internal _owner;\n\n error Forbidden();\n\n constructor(\n address owner,\n address[] memory payees,\n uint256[] memory shares\n ) PaymentSplitter(payees, shares) {\n _owner = owner;\n }\n\n function resetPayees(\n address[] memory payees,\n uint256[] memory shares\n ) public {\n if (_msgSender() != _owner) revert Forbidden();\n\n _resetPayees(payees, shares);\n }\n}\n\ncontract LemonadeRelayPayment is OwnableUpgradeable {\n struct Payment {\n address guest;\n address currency;\n uint256 amount;\n }\n\n address public configRegistry;\n mapping(bytes32 => Payment) internal payments;\n mapping(address => bool) internal splitters;\n uint256[20] __gap;\n\n event OnRegister(address splitter);\n\n event OnPay(\n address splitter,\n string eventId,\n string paymentId,\n address guest,\n address currency,\n uint256 amount\n );\n\n error NotRegistered();\n error AlreadyPay();\n error InvalidAmount();\n error CannotPayFee();\n error CannotPay();\n\n function initialize(address registry) public initializer {\n __Ownable_init();\n configRegistry = registry;\n }\n\n function setConfigRegistry(address registry) external onlyOwner {\n configRegistry = registry;\n }\n\n /**\n * Register wallets to receive payments of a specific event\n * @param payees Param of payment splitter\n * @param shares Param of payment splitter\n */\n function register(\n address[] calldata payees,\n uint256[] calldata shares\n ) external {\n RelayPaymentSplitter splitter = new RelayPaymentSplitter(\n _msgSender(),\n payees,\n shares\n );\n\n address splitterAddress = address(splitter);\n\n splitters[splitterAddress] = true;\n\n emit OnRegister(splitterAddress);\n }\n\n function getPayment(\n string calldata paymentId\n ) external view returns (Payment memory) {\n bytes32 id = _toId(paymentId);\n\n return payments[id];\n }\n\n /**\n * Guest pays the tickets\n * @param splitter The address of the registered splitter\n * @param paymentId The id of the payment\n * @param currency Token address of the currency, zero address for native currency\n * @param amount The ticket amount plus fee\n */\n function pay(\n address splitter,\n string memory eventId,\n string memory paymentId,\n address currency,\n uint256 amount\n ) external payable {\n if (amount == 0) revert InvalidAmount();\n\n bytes32 id = _toId(paymentId);\n\n if (payments[id].amount > 0) revert AlreadyPay();\n\n if (!splitters[splitter]) revert NotRegistered();\n\n bool isNative = currency == address(0);\n\n if (isNative && msg.value != amount) revert InvalidAmount();\n\n PaymentConfigRegistry registry = PaymentConfigRegistry(\n payable(configRegistry)\n );\n\n uint256 transferAmount = amount * 1000000 / (registry.feePPM() + 1000000);\n uint256 feeAmount = amount - transferAmount;\n\n address guest = _msgSender();\n\n if (isNative) {\n (bool success, ) = payable(configRegistry).call{value: feeAmount}(\n \"\"\n );\n\n if (!success) revert CannotPayFee();\n\n (success, ) = payable(splitter).call{value: transferAmount}(\"\");\n\n if (!success) revert CannotPay();\n } else {\n bool success = IERC20(currency).transferFrom(\n guest,\n configRegistry,\n feeAmount\n );\n\n if (!success) revert CannotPayFee();\n\n success = IERC20(currency).transferFrom(\n guest,\n splitter,\n transferAmount\n );\n\n if (!success) revert CannotPay();\n }\n\n registry.notifyFee(eventId, currency, feeAmount);\n\n Payment memory payment = Payment(guest, currency, amount);\n\n payments[id] = payment;\n\n emit OnPay(\n splitter,\n eventId,\n paymentId,\n guest,\n currency,\n transferAmount\n );\n }\n\n function _toId(string memory id) internal pure returns (bytes32) {\n return keccak256(abi.encode(id));\n }\n}\n" + }, + "contracts/rarible/LibPart.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary LibPart {\n bytes32 public constant TYPE_HASH = keccak256(\"Part(address account,uint96 value)\");\n\n struct Part {\n address payable account;\n uint96 value;\n }\n\n function hash(Part memory part) internal pure returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, part.account, part.value));\n }\n}\n" + }, + "contracts/rarible/RoyaltiesV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"./LibPart.sol\";\n\ninterface RoyaltiesV2 {\n event RoyaltiesSet(uint256 tokenId, LibPart.Part[] royalties);\n\n function getRaribleV2Royalties(uint256 id) external view returns (LibPart.Part[] memory);\n}\n" + }, + "contracts/RelayRecipient.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IRelayRecipient.sol\";\n\nabstract contract RelayRecipient is IRelayRecipient {\n address public trustedForwarder;\n\n constructor(address forwarder) {\n trustedForwarder = forwarder;\n }\n\n function isTrustedForwarder(address forwarder)\n public\n view\n override\n returns (bool)\n {\n return forwarder == trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address ret) {\n if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) {\n // At this point we know that the sender is a trusted forwarder,\n // so we trust that the last bytes of msg.data are the verified sender address.\n // extract sender address from the end of msg.data\n assembly {\n ret := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return msg.sender;\n }\n }\n\n function versionRecipient() external pure override returns (string memory) {\n return \"1\";\n }\n}\n" + }, + "contracts/unique/ICollection.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\nstring constant ROYALTIES_PROPERTY = \"royalties\";\n\nstruct Property {\n string key;\n bytes value;\n}\n\nenum TokenPermissionField {\n Mutable,\n TokenOwner,\n CollectionAdmin\n}\n\nstruct PropertyPermission {\n TokenPermissionField code;\n bool value;\n}\n\nstruct TokenPropertyPermission {\n string key;\n PropertyPermission[] permissions;\n}\n\nstruct CrossAddress {\n address eth;\n uint256 sub;\n}\n\ninterface ICollection is IERC721 {\n function addCollectionAdminCross(CrossAddress memory newAdmin)\n external;\n\n function changeCollectionOwnerCross(CrossAddress memory newOwner)\n external;\n\n function mint(address to) external returns (uint256);\n\n function mintWithTokenURI(address to, string memory tokenUri)\n external\n returns (uint256);\n\n function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions)\n external;\n\n function setProperties(uint256 tokenId, Property[] memory properties)\n external;\n\n function property(uint256 tokenId, string memory key)\n external\n view\n returns (bytes memory);\n}\n" + }, + "contracts/unique/ICollectionHelpers.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface ICollectionHelpers {\n function createNFTCollection(\n string memory name,\n string memory description,\n string memory tokenPrefix\n ) external payable returns (address);\n\n function makeCollectionERC721MetadataCompatible(\n address collection,\n string memory baseUri\n ) external;\n}\n" + }, + "contracts/unique/LibPartAdapter.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../rarible/LibPart.sol\";\n\nlibrary LibPartAdapter {\n function encode(LibPart.Part[] memory parts) internal pure returns (bytes memory) {\n if (parts.length == 0) return \"\";\n\n uint256[] memory encoded = new uint256[](parts.length * 2);\n\n for (uint i = 0; i < parts.length; i++) {\n encoded[i * 2] = 0x0100000000000000000000000000000000000000000000040000000000000000 | uint256(parts[i].value);\n encoded[i * 2 + 1] = uint256(uint160(address(parts[i].account)));\n }\n\n return abi.encodePacked(encoded);\n }\n\n function decode(bytes memory b) internal pure returns (LibPart.Part[] memory) {\n if (b.length == 0) return new LibPart.Part[](0);\n\n require((b.length % (32 * 2)) == 0, \"Invalid bytes length, expected (32 * 2) * UniqueRoyaltyParts count\");\n uint partsCount = b.length / (32 * 2);\n uint numbersCount = partsCount * 2;\n\n LibPart.Part[] memory parts = new LibPart.Part[](partsCount);\n\n // need this because numbers encoded via abi.encodePacked\n bytes memory prefix = new bytes(64);\n\n assembly {\n mstore(add(prefix, 32), 32)\n mstore(add(prefix, 64), numbersCount)\n }\n\n uint256[] memory encoded = abi.decode(bytes.concat(prefix, b), (uint256[]));\n\n for (uint i = 0; i < partsCount; i++) {\n uint96 value = uint96(encoded[i * 2] & 0xFFFFFFFFFFFFFFFF);\n address account = address(uint160(encoded[i * 2 + 1]));\n\n parts[i] = LibPart.Part({\n account: payable(account),\n value: value\n });\n }\n\n return parts;\n }\n}" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "storageLayout", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index c303c97..4be0f48 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -203,6 +203,18 @@ const config: HardhatUserConfig = { accounts, deploy: ['deploy/__all__', 'deploy/moonbeam'], }, + 'scroll': { + url: process.env.NETWORK_SCROLL_URL || 'https://rpc.scroll.io', + chainId: 534352, + accounts, + deploy: ['deploy/__all__', 'deploy/scroll'], + }, + 'scroll-sepolia': { + url: process.env.NETWORK_SCROLL_SEPOLIA_URL || 'https://sepolia-rpc.scroll.io', + chainId: 534351, + accounts, + deploy: ['deploy/__all__', 'deploy/scroll-sepolia'], + }, 'sepolia': { url: process.env.NETWORK_SEPOLIA_URL || 'https://ethereum-sepolia.publicnode.com/', chainId: 11155111, diff --git a/scripts/deploy-proxy.ts b/scripts/deploy-proxy.ts index b8e5182..5339ddb 100644 --- a/scripts/deploy-proxy.ts +++ b/scripts/deploy-proxy.ts @@ -10,7 +10,7 @@ async function main() { const proxy = await upgrades.deployProxy(contractFactory, ARGS && JSON.parse(ARGS) || []); - console.log(proxy.address); + console.log(proxy.target); } main();