diff --git a/contracts/.openzeppelin/optimism.json b/contracts/.openzeppelin/optimism.json index 0097926c..f5240457 100644 --- a/contracts/.openzeppelin/optimism.json +++ b/contracts/.openzeppelin/optimism.json @@ -2,753 +2,15 @@ "manifestVersion": "3.2", "proxies": [ { - "address": "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07", + "address": "0x822f17a9a5eecfd66dbaff7946a8071c265d1d07", "kind": "uups" } ], "impls": { - "5bd56aa108022a80651301eeed96e6ac20fea02040073a01f341a6c8b635d38e": { - "address": "0xc6FbcFE16D5eBFEd21aCe224C49C94dE49046A04", - "layout": { - "solcVersion": "0.8.16", - "storage": [ - { - "label": "_initialized", - "offset": 0, - "slot": "0", - "type": "t_uint8", - "contract": "Initializable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:62", - "retypedFrom": "bool" - }, - { - "label": "_initializing", - "offset": 1, - "slot": "0", - "type": "t_bool", - "contract": "Initializable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:67" - }, - { - "label": "__gap", - "offset": 0, - "slot": "1", - "type": "t_array(t_uint256)50_storage", - "contract": "ContextUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol:36" - }, - { - "label": "__gap", - "offset": 0, - "slot": "51", - "type": "t_array(t_uint256)50_storage", - "contract": "ERC165Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol:41" - }, - { - "label": "_balances", - "offset": 0, - "slot": "101", - "type": "t_mapping(t_uint256,t_mapping(t_address,t_uint256))", - "contract": "ERC1155Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:25" - }, - { - "label": "_operatorApprovals", - "offset": 0, - "slot": "102", - "type": "t_mapping(t_address,t_mapping(t_address,t_bool))", - "contract": "ERC1155Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:28" - }, - { - "label": "_uri", - "offset": 0, - "slot": "103", - "type": "t_string_storage", - "contract": "ERC1155Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:31" - }, - { - "label": "__gap", - "offset": 0, - "slot": "104", - "type": "t_array(t_uint256)47_storage", - "contract": "ERC1155Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:528" - }, - { - "label": "__gap", - "offset": 0, - "slot": "151", - "type": "t_array(t_uint256)50_storage", - "contract": "ERC1155BurnableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol:52" - }, - { - "label": "_baseURI", - "offset": 0, - "slot": "201", - "type": "t_string_storage", - "contract": "ERC1155URIStorageUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:27" - }, - { - "label": "_tokenURIs", - "offset": 0, - "slot": "202", - "type": "t_mapping(t_uint256,t_string_storage)", - "contract": "ERC1155URIStorageUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:30" - }, - { - "label": "__gap", - "offset": 0, - "slot": "203", - "type": "t_array(t_uint256)48_storage", - "contract": "ERC1155URIStorageUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:77" - }, - { - "label": "_owner", - "offset": 0, - "slot": "251", - "type": "t_address", - "contract": "OwnableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:22" - }, - { - "label": "__gap", - "offset": 0, - "slot": "252", - "type": "t_array(t_uint256)49_storage", - "contract": "OwnableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:94" - }, - { - "label": "__gap", - "offset": 0, - "slot": "301", - "type": "t_array(t_uint256)50_storage", - "contract": "ERC1967UpgradeUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211" - }, - { - "label": "__gap", - "offset": 0, - "slot": "351", - "type": "t_array(t_uint256)50_storage", - "contract": "UUPSUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol:107" - }, - { - "label": "typeCounter", - "offset": 0, - "slot": "401", - "type": "t_uint256", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:27" - }, - { - "label": "owners", - "offset": 0, - "slot": "402", - "type": "t_mapping(t_uint256,t_address)", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:38" - }, - { - "label": "creators", - "offset": 0, - "slot": "403", - "type": "t_mapping(t_uint256,t_address)", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:41" - }, - { - "label": "tokenValues", - "offset": 0, - "slot": "404", - "type": "t_mapping(t_uint256,t_uint256)", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:44" - }, - { - "label": "maxIndex", - "offset": 0, - "slot": "405", - "type": "t_mapping(t_uint256,t_uint256)", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:47" - }, - { - "label": "__gap", - "offset": 0, - "slot": "406", - "type": "t_array(t_uint256)25_storage", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:433" - }, - { - "label": "merkleRoots", - "offset": 0, - "slot": "431", - "type": "t_mapping(t_uint256,t_bytes32)", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:17" - }, - { - "label": "hasBeenClaimed", - "offset": 0, - "slot": "432", - "type": "t_mapping(t_uint256,t_mapping(t_bytes32,t_bool))", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:18" - }, - { - "label": "maxUnits", - "offset": 0, - "slot": "433", - "type": "t_mapping(t_uint256,t_uint256)", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:19" - }, - { - "label": "minted", - "offset": 0, - "slot": "434", - "type": "t_mapping(t_uint256,t_uint256)", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:20" - }, - { - "label": "__gap", - "offset": 0, - "slot": "435", - "type": "t_array(t_uint256)26_storage", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:69" - }, - { - "label": "_paused", - "offset": 0, - "slot": "461", - "type": "t_bool", - "contract": "PausableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:29" - }, - { - "label": "__gap", - "offset": 0, - "slot": "462", - "type": "t_array(t_uint256)49_storage", - "contract": "PausableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:116" - }, - { - "label": "typeRestrictions", - "offset": 0, - "slot": "511", - "type": "t_mapping(t_uint256,t_enum(TransferRestrictions)6765)", - "contract": "HypercertMinter", - "src": "src/HypercertMinter.sol:20" - }, - { - "label": "__gap", - "offset": 0, - "slot": "512", - "type": "t_array(t_uint256)29_storage", - "contract": "HypercertMinter", - "src": "src/HypercertMinter.sol:228" - } - ], - "types": { - "t_address": { - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_uint256)25_storage": { - "label": "uint256[25]", - "numberOfBytes": "800" - }, - "t_array(t_uint256)26_storage": { - "label": "uint256[26]", - "numberOfBytes": "832" - }, - "t_array(t_uint256)29_storage": { - "label": "uint256[29]", - "numberOfBytes": "928" - }, - "t_array(t_uint256)47_storage": { - "label": "uint256[47]", - "numberOfBytes": "1504" - }, - "t_array(t_uint256)48_storage": { - "label": "uint256[48]", - "numberOfBytes": "1536" - }, - "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_enum(TransferRestrictions)6765": { - "label": "enum IHypercertToken.TransferRestrictions", - "members": [ - "AllowAll", - "DisallowAll", - "FromCreatorOnly" - ], - "numberOfBytes": "1" - }, - "t_mapping(t_address,t_bool)": { - "label": "mapping(address => bool)", - "numberOfBytes": "32" - }, - "t_mapping(t_address,t_mapping(t_address,t_bool))": { - "label": "mapping(address => mapping(address => bool))", - "numberOfBytes": "32" - }, - "t_mapping(t_address,t_uint256)": { - "label": "mapping(address => uint256)", - "numberOfBytes": "32" - }, - "t_mapping(t_bytes32,t_bool)": { - "label": "mapping(bytes32 => bool)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_address)": { - "label": "mapping(uint256 => address)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_bytes32)": { - "label": "mapping(uint256 => bytes32)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_enum(TransferRestrictions)6765)": { - "label": "mapping(uint256 => enum IHypercertToken.TransferRestrictions)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_mapping(t_address,t_uint256))": { - "label": "mapping(uint256 => mapping(address => uint256))", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_mapping(t_bytes32,t_bool))": { - "label": "mapping(uint256 => mapping(bytes32 => bool))", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_string_storage)": { - "label": "mapping(uint256 => string)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_uint256)": { - "label": "mapping(uint256 => uint256)", - "numberOfBytes": "32" - }, - "t_string_storage": { - "label": "string", - "numberOfBytes": "32" - }, - "t_uint256": { - "label": "uint256", - "numberOfBytes": "32" - }, - "t_uint8": { - "label": "uint8", - "numberOfBytes": "1" - } - } - } - }, - "31f9c6a26cf17ca4bb624cde3829d09c9a5a4a1d419afe174e7bd6d46cc5c0d9": { - "address": "0x396D5f1EF3aa92dDAd4DEad04388374A03BC5577", - "txHash": "0xaa0093e2c748592309277ebc3f82d2a265071a11fce81822dc75bab1f2ea838e", - "layout": { - "solcVersion": "0.8.16", - "storage": [ - { - "label": "_initialized", - "offset": 0, - "slot": "0", - "type": "t_uint8", - "contract": "Initializable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:62", - "retypedFrom": "bool" - }, - { - "label": "_initializing", - "offset": 1, - "slot": "0", - "type": "t_bool", - "contract": "Initializable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:67" - }, - { - "label": "__gap", - "offset": 0, - "slot": "1", - "type": "t_array(t_uint256)50_storage", - "contract": "ContextUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol:36" - }, - { - "label": "__gap", - "offset": 0, - "slot": "51", - "type": "t_array(t_uint256)50_storage", - "contract": "ERC165Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol:41" - }, - { - "label": "_balances", - "offset": 0, - "slot": "101", - "type": "t_mapping(t_uint256,t_mapping(t_address,t_uint256))", - "contract": "ERC1155Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:25" - }, - { - "label": "_operatorApprovals", - "offset": 0, - "slot": "102", - "type": "t_mapping(t_address,t_mapping(t_address,t_bool))", - "contract": "ERC1155Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:28" - }, - { - "label": "_uri", - "offset": 0, - "slot": "103", - "type": "t_string_storage", - "contract": "ERC1155Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:31" - }, - { - "label": "__gap", - "offset": 0, - "slot": "104", - "type": "t_array(t_uint256)47_storage", - "contract": "ERC1155Upgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:528" - }, - { - "label": "__gap", - "offset": 0, - "slot": "151", - "type": "t_array(t_uint256)50_storage", - "contract": "ERC1155BurnableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol:52" - }, - { - "label": "_baseURI", - "offset": 0, - "slot": "201", - "type": "t_string_storage", - "contract": "ERC1155URIStorageUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:27" - }, - { - "label": "_tokenURIs", - "offset": 0, - "slot": "202", - "type": "t_mapping(t_uint256,t_string_storage)", - "contract": "ERC1155URIStorageUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:30" - }, - { - "label": "__gap", - "offset": 0, - "slot": "203", - "type": "t_array(t_uint256)48_storage", - "contract": "ERC1155URIStorageUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:77" - }, - { - "label": "_owner", - "offset": 0, - "slot": "251", - "type": "t_address", - "contract": "OwnableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:22" - }, - { - "label": "__gap", - "offset": 0, - "slot": "252", - "type": "t_array(t_uint256)49_storage", - "contract": "OwnableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:94" - }, - { - "label": "__gap", - "offset": 0, - "slot": "301", - "type": "t_array(t_uint256)50_storage", - "contract": "ERC1967UpgradeUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211" - }, - { - "label": "__gap", - "offset": 0, - "slot": "351", - "type": "t_array(t_uint256)50_storage", - "contract": "UUPSUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol:107" - }, - { - "label": "typeCounter", - "offset": 0, - "slot": "401", - "type": "t_uint256", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:27" - }, - { - "label": "owners", - "offset": 0, - "slot": "402", - "type": "t_mapping(t_uint256,t_address)", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:38" - }, - { - "label": "creators", - "offset": 0, - "slot": "403", - "type": "t_mapping(t_uint256,t_address)", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:41" - }, - { - "label": "tokenValues", - "offset": 0, - "slot": "404", - "type": "t_mapping(t_uint256,t_uint256)", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:44" - }, - { - "label": "maxIndex", - "offset": 0, - "slot": "405", - "type": "t_mapping(t_uint256,t_uint256)", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:47" - }, - { - "label": "__gap", - "offset": 0, - "slot": "406", - "type": "t_array(t_uint256)25_storage", - "contract": "SemiFungible1155", - "src": "src/SemiFungible1155.sol:432" - }, - { - "label": "merkleRoots", - "offset": 0, - "slot": "431", - "type": "t_mapping(t_uint256,t_bytes32)", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:17" - }, - { - "label": "hasBeenClaimed", - "offset": 0, - "slot": "432", - "type": "t_mapping(t_uint256,t_mapping(t_bytes32,t_bool))", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:18" - }, - { - "label": "maxUnits", - "offset": 0, - "slot": "433", - "type": "t_mapping(t_uint256,t_uint256)", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:19" - }, - { - "label": "minted", - "offset": 0, - "slot": "434", - "type": "t_mapping(t_uint256,t_uint256)", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:20" - }, - { - "label": "__gap", - "offset": 0, - "slot": "435", - "type": "t_array(t_uint256)26_storage", - "contract": "AllowlistMinter", - "src": "src/AllowlistMinter.sol:69" - }, - { - "label": "_paused", - "offset": 0, - "slot": "461", - "type": "t_bool", - "contract": "PausableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:29" - }, - { - "label": "__gap", - "offset": 0, - "slot": "462", - "type": "t_array(t_uint256)49_storage", - "contract": "PausableUpgradeable", - "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:116" - }, - { - "label": "typeRestrictions", - "offset": 0, - "slot": "511", - "type": "t_mapping(t_uint256,t_enum(TransferRestrictions)6761)", - "contract": "HypercertMinter", - "src": "src/HypercertMinter.sol:20" - }, - { - "label": "__gap", - "offset": 0, - "slot": "512", - "type": "t_array(t_uint256)29_storage", - "contract": "HypercertMinter", - "src": "src/HypercertMinter.sol:228" - } - ], - "types": { - "t_address": { - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_uint256)25_storage": { - "label": "uint256[25]", - "numberOfBytes": "800" - }, - "t_array(t_uint256)26_storage": { - "label": "uint256[26]", - "numberOfBytes": "832" - }, - "t_array(t_uint256)29_storage": { - "label": "uint256[29]", - "numberOfBytes": "928" - }, - "t_array(t_uint256)47_storage": { - "label": "uint256[47]", - "numberOfBytes": "1504" - }, - "t_array(t_uint256)48_storage": { - "label": "uint256[48]", - "numberOfBytes": "1536" - }, - "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_enum(TransferRestrictions)6761": { - "label": "enum IHypercertToken.TransferRestrictions", - "members": [ - "AllowAll", - "DisallowAll", - "FromCreatorOnly" - ], - "numberOfBytes": "1" - }, - "t_mapping(t_address,t_bool)": { - "label": "mapping(address => bool)", - "numberOfBytes": "32" - }, - "t_mapping(t_address,t_mapping(t_address,t_bool))": { - "label": "mapping(address => mapping(address => bool))", - "numberOfBytes": "32" - }, - "t_mapping(t_address,t_uint256)": { - "label": "mapping(address => uint256)", - "numberOfBytes": "32" - }, - "t_mapping(t_bytes32,t_bool)": { - "label": "mapping(bytes32 => bool)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_address)": { - "label": "mapping(uint256 => address)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_bytes32)": { - "label": "mapping(uint256 => bytes32)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_enum(TransferRestrictions)6761)": { - "label": "mapping(uint256 => enum IHypercertToken.TransferRestrictions)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_mapping(t_address,t_uint256))": { - "label": "mapping(uint256 => mapping(address => uint256))", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_mapping(t_bytes32,t_bool))": { - "label": "mapping(uint256 => mapping(bytes32 => bool))", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_string_storage)": { - "label": "mapping(uint256 => string)", - "numberOfBytes": "32" - }, - "t_mapping(t_uint256,t_uint256)": { - "label": "mapping(uint256 => uint256)", - "numberOfBytes": "32" - }, - "t_string_storage": { - "label": "string", - "numberOfBytes": "32" - }, - "t_uint256": { - "label": "uint256", - "numberOfBytes": "32" - }, - "t_uint8": { - "label": "uint8", - "numberOfBytes": "1" - } - } - } - }, -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json - "030e0101c01e933929a2efcd3396e960802166732a863419a7ab502c6da71509": { - "address": "0xc695a9f30131C3566f5E7A577Cf39Ad7F305eD55", - "txHash": "0x11b92b34289c6926fd9673c234cb75c9cea9ee1b1c8462ab60745f0061c19ef5", + "125db54394ee349f18c5e7b6f717dff5868c4ccab68a96eeef38a6321b3f05b2": { + "address": "0x396D5f1EF3aa92dDAd4DEad04388374A03BC5577", "layout": { "solcVersion": "0.8.17", -======== - "ba3b8c36d1292bdec3593f0e2b8f6d2e38d080b76cb70de7876aba5db39b7d86": { - "address": "0xDb77A1fDC905685B4052a512522D502638DdA5E3", - "txHash": "0xeb77995d2103baee6ba64beff908b9ed6653f1b1c9c1373321b8e8770a89a651", - "layout": { - "solcVersion": "0.8.16", ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json "storage": [ { "label": "_initialized", @@ -885,11 +147,7 @@ "slot": "401", "type": "t_uint256", "contract": "SemiFungible1155", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/SemiFungible1155.sol:27" -======== - "src": "src/SemiFungible1155.sol:27" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "owners", @@ -897,11 +155,7 @@ "slot": "402", "type": "t_mapping(t_uint256,t_address)", "contract": "SemiFungible1155", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/SemiFungible1155.sol:38" -======== - "src": "src/SemiFungible1155.sol:38" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "creators", @@ -909,11 +163,7 @@ "slot": "403", "type": "t_mapping(t_uint256,t_address)", "contract": "SemiFungible1155", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/SemiFungible1155.sol:41" -======== - "src": "src/SemiFungible1155.sol:41" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "tokenValues", @@ -921,11 +171,7 @@ "slot": "404", "type": "t_mapping(t_uint256,t_uint256)", "contract": "SemiFungible1155", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/SemiFungible1155.sol:44" -======== - "src": "src/SemiFungible1155.sol:44" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "maxIndex", @@ -933,11 +179,7 @@ "slot": "405", "type": "t_mapping(t_uint256,t_uint256)", "contract": "SemiFungible1155", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/SemiFungible1155.sol:47" -======== - "src": "src/SemiFungible1155.sol:47" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "__gap", @@ -945,11 +187,7 @@ "slot": "406", "type": "t_array(t_uint256)25_storage", "contract": "SemiFungible1155", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json - "src": "src/protocol/SemiFungible1155.sol:640" -======== - "src": "src/SemiFungible1155.sol:436" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json + "src": "src/protocol/SemiFungible1155.sol:648" }, { "label": "merkleRoots", @@ -957,11 +195,7 @@ "slot": "431", "type": "t_mapping(t_uint256,t_bytes32)", "contract": "AllowlistMinter", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/AllowlistMinter.sol:17" -======== - "src": "src/AllowlistMinter.sol:17" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "hasBeenClaimed", @@ -969,11 +203,7 @@ "slot": "432", "type": "t_mapping(t_uint256,t_mapping(t_bytes32,t_bool))", "contract": "AllowlistMinter", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/AllowlistMinter.sol:18" -======== - "src": "src/AllowlistMinter.sol:18" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "maxUnits", @@ -981,11 +211,7 @@ "slot": "433", "type": "t_mapping(t_uint256,t_uint256)", "contract": "AllowlistMinter", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/AllowlistMinter.sol:19" -======== - "src": "src/AllowlistMinter.sol:19" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "minted", @@ -993,11 +219,7 @@ "slot": "434", "type": "t_mapping(t_uint256,t_uint256)", "contract": "AllowlistMinter", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/AllowlistMinter.sol:20" -======== - "src": "src/AllowlistMinter.sol:20" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "__gap", @@ -1005,11 +227,7 @@ "slot": "435", "type": "t_array(t_uint256)26_storage", "contract": "AllowlistMinter", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/AllowlistMinter.sol:75" -======== - "src": "src/AllowlistMinter.sol:69" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "_paused", @@ -1031,15 +249,9 @@ "label": "typeRestrictions", "offset": 0, "slot": "511", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json - "type": "t_mapping(t_uint256,t_enum(TransferRestrictions)18919)", + "type": "t_mapping(t_uint256,t_enum(TransferRestrictions)19595)", "contract": "HypercertMinter", "src": "src/protocol/HypercertMinter.sol:20" -======== - "type": "t_mapping(t_uint256,t_enum(TransferRestrictions)6793)", - "contract": "HypercertMinter", - "src": "src/HypercertMinter.sol:20" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json }, { "label": "__gap", @@ -1047,11 +259,7 @@ "slot": "512", "type": "t_array(t_uint256)29_storage", "contract": "HypercertMinter", -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json "src": "src/protocol/HypercertMinter.sol:258" -======== - "src": "src/HypercertMinter.sol:228" ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json } ], "types": { @@ -1095,11 +303,7 @@ "label": "bytes32", "numberOfBytes": "32" }, -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json - "t_enum(TransferRestrictions)18919": { -======== - "t_enum(TransferRestrictions)6793": { ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json + "t_enum(TransferRestrictions)19595": { "label": "enum IHypercertToken.TransferRestrictions", "members": [ "AllowAll", @@ -1132,11 +336,7 @@ "label": "mapping(uint256 => bytes32)", "numberOfBytes": "32" }, -<<<<<<<< HEAD:contracts/.openzeppelin/optimism.json - "t_mapping(t_uint256,t_enum(TransferRestrictions)18919)": { -======== - "t_mapping(t_uint256,t_enum(TransferRestrictions)6793)": { ->>>>>>>> develop:contracts/.openzeppelin/sepolia.json + "t_mapping(t_uint256,t_enum(TransferRestrictions)19595)": { "label": "mapping(uint256 => enum IHypercertToken.TransferRestrictions)", "numberOfBytes": "32" }, @@ -1170,7 +370,11 @@ } }, "namespaces": {} - } + }, + "allAddresses": [ + "0x396D5f1EF3aa92dDAd4DEad04388374A03BC5577", + "0xEbA30978164Cc0985091F11532C8f83a5Fa98622" + ] } } } diff --git a/contracts/contracts/AllowlistMinter.sol b/contracts/contracts/AllowlistMinter.sol deleted file mode 100644 index 599831cb..00000000 --- a/contracts/contracts/AllowlistMinter.sol +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.16; - -import {MerkleProofUpgradeable} from "oz-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; -import {IAllowlist} from "./interfaces/IAllowlist.sol"; - -import {Errors} from "./libs/Errors.sol"; - -/// @title Interface for hypercert token interactions -/// @author bitbeckers -/// @notice This interface declares the required functionality for a hypercert token -/// @notice This interface does not specify the underlying token type (e.g. 721 or 1155) -contract AllowlistMinter is IAllowlist { - event AllowlistCreated(uint256 tokenID, bytes32 root); - event LeafClaimed(uint256 tokenID, bytes32 leaf); - - mapping(uint256 => bytes32) internal merkleRoots; - mapping(uint256 => mapping(bytes32 => bool)) public hasBeenClaimed; - mapping(uint256 => uint256) internal maxUnits; - mapping(uint256 => uint256) internal minted; - - function isAllowedToClaim(bytes32[] calldata proof, uint256 claimID, bytes32 leaf) - external - view - returns (bool isAllowed) - { - if (merkleRoots[claimID].length == 0) revert Errors.DoesNotExist(); - isAllowed = MerkleProofUpgradeable.verifyCalldata(proof, merkleRoots[claimID], leaf); - } - - function _createAllowlist(uint256 claimID, bytes32 merkleRoot, uint256 units) internal { - if (merkleRoot == "" || units == 0) revert Errors.Invalid(); - if (merkleRoots[claimID] != "") revert Errors.DuplicateEntry(); - - merkleRoots[claimID] = merkleRoot; - maxUnits[claimID] = units; - emit AllowlistCreated(claimID, merkleRoot); - } - - function _processClaim(bytes32[] calldata proof, uint256 claimID, uint256 amount) internal { - if (merkleRoots[claimID].length == 0) revert Errors.DoesNotExist(); - - bytes32 leaf = _calculateLeaf(msg.sender, amount); - - if (hasBeenClaimed[claimID][leaf]) revert Errors.AlreadyClaimed(); - if ( - !MerkleProofUpgradeable.verifyCalldata(proof, merkleRoots[claimID], leaf) - || (minted[claimID] + amount) > maxUnits[claimID] - ) revert Errors.Invalid(); - hasBeenClaimed[claimID][leaf] = true; - - emit LeafClaimed(claimID, leaf); - } - - function _calculateLeaf(address account, uint256 amount) internal pure returns (bytes32 leaf) { - leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount)))); - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - * Assuming 30 available slots (slots cost space, cost gas) - * 1. merkleRoots - * 2. hasBeenClaimed - * 3. maxUnits - * 4. minted - */ - uint256[26] private __gap; -} diff --git a/contracts/contracts/HypercertMinter.sol b/contracts/contracts/HypercertMinter.sol deleted file mode 100644 index 6e97b17f..00000000 --- a/contracts/contracts/HypercertMinter.sol +++ /dev/null @@ -1,227 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.16; - -import {IHypercertToken} from "./interfaces/IHypercertToken.sol"; -import {SemiFungible1155} from "./SemiFungible1155.sol"; -import {AllowlistMinter} from "./AllowlistMinter.sol"; -import {PausableUpgradeable} from "oz-upgradeable/security/PausableUpgradeable.sol"; - -import {Errors} from "./libs/Errors.sol"; - -/// @title Contract for managing hypercert claims and whitelists -/// @author bitbeckers -/// @notice Implementation of the HypercertTokenInterface using { SemiFungible1155 } as underlying token. -/// @notice This contract supports whitelisted minting via { AllowlistMinter }. -/// @dev Wrapper contract to expose and chain functions. -contract HypercertMinter is IHypercertToken, SemiFungible1155, AllowlistMinter, PausableUpgradeable { - // solhint-disable-next-line const-name-snakecase - string public constant name = "HypercertMinter"; - /// @dev from typeID to a transfer policy - mapping(uint256 => TransferRestrictions) internal typeRestrictions; - - /// INIT - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol } - /// @custom:oz-upgrades-unsafe-allow constructor - constructor() { - _disableInitializers(); - } - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol } - function initialize() public virtual initializer { - __SemiFungible1155_init(); - __Pausable_init(); - } - - /// EXTERNAL - - /// @notice Mint a semi-fungible token for the impact claim referenced via `uri` - /// @dev see {IHypercertToken} - function mintClaim(address account, uint256 units, string memory _uri, TransferRestrictions restrictions) - external - override - whenNotPaused - { - // This enables us to release this restriction in the future - if (msg.sender != account) revert Errors.NotAllowed(); - uint256 claimID = _mintNewTypeWithToken(account, units, _uri); - typeRestrictions[claimID] = restrictions; - emit ClaimStored(claimID, _uri, units); - } - - /// @notice Mint semi-fungible tokens for the impact claim referenced via `uri` - /// @dev see {IHypercertToken} - function mintClaimWithFractions( - address account, - uint256 units, - uint256[] calldata fractions, - string memory _uri, - TransferRestrictions restrictions - ) external override whenNotPaused { - // This enables us to release this restriction in the future - if (msg.sender != account) revert Errors.NotAllowed(); - //Using sum to compare units and fractions (sanity check) - if (_getSum(fractions) != units) revert Errors.Invalid(); - - uint256 claimID = _mintNewTypeWithTokens(account, fractions, _uri); - typeRestrictions[claimID] = restrictions; - emit ClaimStored(claimID, _uri, units); - } - - /// @notice Mint a semi-fungible token representing a fraction of the claim - /// @dev Calls AllowlistMinter to verify `proof`. - /// @dev Mints the `amount` of units for the hypercert stored under `claimID` - function mintClaimFromAllowlist(address account, bytes32[] calldata proof, uint256 claimID, uint256 units) - external - whenNotPaused - { - _processClaim(proof, claimID, units); - _mintToken(account, claimID, units); - } - - /// @notice Mint semi-fungible tokens representing a fraction of the claims in `claimIDs` - /// @dev Calls AllowlistMinter to verify `proofs`. - /// @dev Mints the `amount` of units for the hypercert stored under `claimIDs` - function batchMintClaimsFromAllowlists( - address account, - bytes32[][] calldata proofs, - uint256[] calldata claimIDs, - uint256[] calldata units - ) external whenNotPaused { - uint256 len = claimIDs.length; - for (uint256 i; i < len;) { - _processClaim(proofs[i], claimIDs[i], units[i]); - unchecked { - ++i; - } - } - _batchMintTokens(account, claimIDs, units); - } - - /// @notice Register a claim and the whitelist for minting token(s) belonging to that claim - /// @dev Calls SemiFungible1155 to store the claim referenced in `uri` with amount of `units` - /// @dev Calls AllowlistMinter to store the `merkleRoot` as proof to authorize claims - function createAllowlist( - address account, - uint256 units, - bytes32 merkleRoot, - string memory _uri, - TransferRestrictions restrictions - ) external whenNotPaused { - uint256 claimID = _createTokenType(account, units, _uri); - _createAllowlist(claimID, merkleRoot, units); - typeRestrictions[claimID] = restrictions; - emit ClaimStored(claimID, _uri, units); - } - - /// @notice Split a claimtokens value into parts with summed value equal to the original - /// @dev see {IHypercertToken} - function splitFraction(address _to, uint256 _tokenID, uint256[] calldata _newFractions) external whenNotPaused { - _splitTokenUnits(_to, _tokenID, _newFractions); - } - - /// @notice Merge the value of tokens belonging to the same claim - /// @dev see {IHypercertToken} - function mergeFractions(address _account, uint256[] calldata _fractionIDs) external whenNotPaused { - _mergeTokensUnits(_account, _fractionIDs); - } - - /// @notice Burn a claimtoken - /// @dev see {IHypercertToken} - function burnFraction(address _account, uint256 _tokenID) external whenNotPaused { - _burnToken(_account, _tokenID); - } - - /// @dev see {IHypercertToken} - function unitsOf(uint256 tokenID) external view override returns (uint256 units) { - units = _unitsOf(tokenID); - } - - /// @dev see {IHypercertToken} - function unitsOf(address account, uint256 tokenID) external view override returns (uint256 units) { - units = _unitsOf(account, tokenID); - } - - /// PAUSABLE - - function pause() external onlyOwner { - _pause(); - } - - function unpause() external onlyOwner { - _unpause(); - } - - /// METADATA - - /// @dev see { IHypercertMetadata} - function uri(uint256 tokenID) - public - view - override(IHypercertToken, SemiFungible1155) - returns (string memory _uri) - { - _uri = SemiFungible1155.uri(tokenID); - } - - /// TRANSFER RESTRICTIONS - - function readTransferRestriction(uint256 tokenID) external view returns (string memory) { - TransferRestrictions temp = typeRestrictions[getBaseType(tokenID)]; - if (temp == TransferRestrictions.AllowAll) return "AllowAll"; - if (temp == TransferRestrictions.DisallowAll) return "DisallowAll"; - if (temp == TransferRestrictions.FromCreatorOnly) return "FromCreatorOnly"; - return ""; - } - - /// INTERNAL - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol } - function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner { - // solhint-disable-previous-line no-empty-blocks - } - - function _beforeTokenTransfer( - address operator, - address from, - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal virtual override { - super._beforeTokenTransfer(operator, from, to, ids, amounts, data); - - // By-pass transfer restrictions for minting and burning - if (from == address(0)) { - // Minting - return; - } else if (to == address(0)) { - // Burning - return; - } - - // Transfer case, where to and from are non-zero - uint256 len = ids.length; - for (uint256 i; i < len;) { - uint256 typeID = getBaseType(ids[i]); - TransferRestrictions policy = typeRestrictions[typeID]; - if (policy == TransferRestrictions.DisallowAll) { - revert Errors.TransfersNotAllowed(); - } else if (policy == TransferRestrictions.FromCreatorOnly && from != creators[typeID]) { - revert Errors.TransfersNotAllowed(); - } - unchecked { - ++i; - } - } - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - * Assuming 30 available slots (slots cost space, cost gas) - * 1. typeRestrictions - */ - uint256[29] private __gap; -} diff --git a/contracts/contracts/SemiFungible1155.sol b/contracts/contracts/SemiFungible1155.sol deleted file mode 100644 index 07a0382a..00000000 --- a/contracts/contracts/SemiFungible1155.sol +++ /dev/null @@ -1,443 +0,0 @@ -// SPDX-License-Identifier: MIT -// Used components of Enjin example implementation for mixed fungibility -// https://github.com/enjin/erc-1155/blob/master/contracts/ERC1155MixedFungibleMintable.sol -pragma solidity 0.8.16; - -import {ERC1155Upgradeable} from "oz-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; -import {ERC1155BurnableUpgradeable} from "oz-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; -import {ERC1155URIStorageUpgradeable} from "oz-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol"; -import {OwnableUpgradeable} from "oz-upgradeable/access/OwnableUpgradeable.sol"; -import {Initializable} from "oz-upgradeable/proxy/utils/Initializable.sol"; -import {UUPSUpgradeable} from "oz-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import {Errors} from "./libs/Errors.sol"; - -/// @title Contract for minting semi-fungible EIP1155 tokens -/// @author bitbeckers -/// @notice Extends { Upgradeable1155 } token with semi-fungible properties and the concept of `units` -/// @dev Adds split bit strategy as described in [EIP-1155](https://eips.ethereum.org/EIPS/eip-1155#non-fungible-tokens) -contract SemiFungible1155 is - Initializable, - ERC1155Upgradeable, - ERC1155BurnableUpgradeable, - ERC1155URIStorageUpgradeable, - OwnableUpgradeable, - UUPSUpgradeable -{ - /// @dev Counter used to generate next typeID. - uint256 internal typeCounter; - - /// @dev Bitmask used to expose only upper 128 bits of uint256 - uint256 internal constant TYPE_MASK = type(uint256).max << 128; - - /// @dev Bitmask used to expose only lower 128 bits of uint256 - uint256 internal constant NF_INDEX_MASK = type(uint256).max >> 128; - - uint256 internal constant FRACTION_LIMIT = 253; - - /// @dev Mapping of `tokenID` to address of `owner` - mapping(uint256 => address) internal owners; - - /// @dev Mapping of `tokenID` to address of `creator` - mapping(uint256 => address) internal creators; - - /// @dev Used to determine amount of `units` stored in token at `tokenID` - mapping(uint256 => uint256) internal tokenValues; - - /// @dev Used to find highest index of token belonging to token at `typeID` - mapping(uint256 => uint256) internal maxIndex; - - /// @dev Emitted on transfer of `value` between `fromTokenID` to `toTokenID` of the same `claimID` - event ValueTransfer(uint256 claimID, uint256 fromTokenID, uint256 toTokenID, uint256 value); - - /// @dev Emitted on transfer of `values` between `fromTokenIDs` to `toTokenIDs` of `claimIDs` - event BatchValueTransfer(uint256[] claimIDs, uint256[] fromTokenIDs, uint256[] toTokenIDs, uint256[] values); - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol } - // solhint-disable-next-line func-name-mixedcase - function __SemiFungible1155_init() public virtual onlyInitializing { - __ERC1155_init(""); - __ERC1155Burnable_init(); - __ERC1155URIStorage_init(); - __Ownable_init(); - __UUPSUpgradeable_init(); - } - - /// @dev Get index of fractional token at `_id` by returning lower 128 bit values - /// @dev Returns 0 if `_id` is a baseType - function getItemIndex(uint256 tokenID) internal pure returns (uint256) { - return tokenID & NF_INDEX_MASK; - } - - /// @dev Get base type ID for token at `_id` by returning upper 128 bit values - function getBaseType(uint256 tokenID) internal pure returns (uint256) { - return tokenID & TYPE_MASK; - } - - /// @dev Identify that token at `_id` is base type. - /// @dev Upper 128 bits identify base type ID, lower bits should be 0 - function isBaseType(uint256 tokenID) internal pure returns (bool) { - return (tokenID & TYPE_MASK == tokenID) && (tokenID & NF_INDEX_MASK == 0); - } - - /// @dev Identify that token at `_id` is fraction of a claim. - /// @dev Upper 128 bits identify base type ID, lower bits should be > 0 - function isTypedItem(uint256 tokenID) internal pure returns (bool) { - return (tokenID & TYPE_MASK != 0) && (tokenID & NF_INDEX_MASK != 0); - } - - /// READ - function ownerOf(uint256 tokenID) public view returns (address _owner) { - _owner = owners[tokenID]; - } - - /// @dev see {IHypercertToken} - function _unitsOf(uint256 tokenID) internal view returns (uint256 units) { - units = tokenValues[tokenID]; - } - - /// @dev see {IHypercertToken} - function _unitsOf(address account, uint256 tokenID) internal view returns (uint256 units) { - // Check if fraction token and accounts owns it - if (ownerOf(tokenID) == account) { - units = tokenValues[tokenID]; - } - } - - /// MUTATE - - /// @dev create token type ID based of token counter - - function _createTokenType(address _account, uint256 units, string memory _uri) internal returns (uint256 typeID) { - _notMaxType(typeCounter); - typeID = ++typeCounter << 128; - - creators[typeID] = _account; - tokenValues[typeID] = units; - - _setURI(typeID, _uri); - - //Event emitted for indexing purposes - emit TransferSingle(_account, address(0), address(0), typeID, 0); - } - - /// @dev Mint a new token type and the initial units - function _mintNewTypeWithToken(address _account, uint256 _units, string memory _uri) - internal - returns (uint256 typeID) - { - if (_units == 0) { - revert Errors.NotAllowed(); - } - typeID = _createTokenType(_account, _units, _uri); - - uint256 tokenID = typeID + ++maxIndex[typeID]; //1 based indexing, 0 holds type data - - tokenValues[tokenID] = _units; - - _mint(_account, tokenID, 1, ""); - emit ValueTransfer(typeID, 0, tokenID, _units); - } - - /// @dev Mint a new token type and the initial fractions - function _mintNewTypeWithTokens(address _account, uint256[] calldata _fractions, string memory _uri) - internal - returns (uint256 typeID) - { - typeID = _mintNewTypeWithToken(_account, _getSum(_fractions), _uri); - _splitTokenUnits(_account, typeID + maxIndex[typeID], _fractions); - } - - /// @dev Mint a new token for an existing type - function _mintToken(address _account, uint256 _typeID, uint256 _units) internal returns (uint256 tokenID) { - if (!isBaseType(_typeID)) revert Errors.NotAllowed(); - - _notMaxItem(maxIndex[_typeID]); - - unchecked { - tokenID = _typeID + ++maxIndex[_typeID]; //1 based indexing, 0 holds type data - } - - tokenValues[tokenID] = _units; - - _mint(_account, tokenID, 1, ""); - emit ValueTransfer(_typeID, 0, tokenID, _units); - } - - /// @dev Mint new tokens for existing types - /// @notice Enables batch claiming from multiple allowlists - function _batchMintTokens(address _account, uint256[] calldata _typeIDs, uint256[] calldata _units) - internal - returns (uint256[] memory tokenIDs) - { - uint256 len = _typeIDs.length; - - tokenIDs = new uint256[](len); - uint256[] memory amounts = new uint256[](len); - uint256[] memory zeroes = new uint256[](len); - - for (uint256 i; i < len;) { - uint256 _typeID = _typeIDs[i]; - if (!isBaseType(_typeID)) revert Errors.NotAllowed(); - _notMaxItem(maxIndex[_typeID]); - - unchecked { - uint256 tokenID = _typeID + ++maxIndex[_typeID]; //1 based indexing, 0 holds type data - tokenValues[tokenID] = _units[i]; - tokenIDs[i] = tokenID; - amounts[i] = 1; - ++i; - } - } - - _mintBatch(_account, tokenIDs, amounts, ""); - emit BatchValueTransfer(_typeIDs, zeroes, tokenIDs, _units); - } - - /// @dev Split the units of `_tokenID` across `_values` to `_to` - /// @dev `_values` must sum to total `units` held at `_tokenID` - /// @dev `_to` must not be zero address, that's a burn - function _splitTokenUnits(address _to, uint256 _tokenID, uint256[] calldata _values) internal { - if (_values.length > FRACTION_LIMIT || _values.length < 2) revert Errors.ArraySize(); - if (tokenValues[_tokenID] != _getSum(_values)) revert Errors.NotAllowed(); - if (_to == address(0)) revert Errors.NotAllowed(); - - // Current token - uint256 _typeID = getBaseType(_tokenID); - uint256 valueLeft = tokenValues[_tokenID]; - - // Prepare batch processing, we want to skip the first entry - uint256 len = _values.length - 1; - - uint256[] memory typeIDs = new uint256[](len); - uint256[] memory fromIDs = new uint256[](len); - uint256[] memory toIDs = new uint256[](len); - uint256[] memory amounts = new uint256[](len); - uint256[] memory values = new uint256[](len); - - { - uint256[] memory _valuesCache = _values; - uint256 swapValue = _valuesCache[len]; - _valuesCache[len] = _valuesCache[0]; - _valuesCache[0] = swapValue; - - for (uint256 i; i < len;) { - _notMaxItem(maxIndex[_typeID]); - - typeIDs[i] = _typeID; - fromIDs[i] = _tokenID; - toIDs[i] = _typeID + ++maxIndex[_typeID]; - amounts[i] = 1; - values[i] = _valuesCache[i]; - - unchecked { - ++i; - } - } - } - - _beforeUnitTransfer(_msgSender(), owners(_tokenID), fromIDs, toIDs, values, ""); - - for (uint256 i; i < len;) { - valueLeft -= values[i]; - - tokenValues[toIDs[i]] = values[i]; - - unchecked { - ++i; - } - } - - tokenValues[_tokenID] = valueLeft; - - _mintBatch(_to, toIDs, amounts, ""); - - emit BatchValueTransfer(typeIDs, fromIDs, toIDs, values); - } - - /// @dev Merge the units of `_fractionIDs`. - /// @dev Base type of `_fractionIDs` must be identical for all tokens. - function _mergeTokensUnits(address _account, uint256[] memory _fractionIDs) internal { - if (_fractionIDs.length > FRACTION_LIMIT || _fractionIDs.length < 2) { - revert Errors.ArraySize(); - } - - uint256 len = _fractionIDs.length - 1; - - uint256 target = _fractionIDs[len]; - - if (_to == address(0) || owners[target] != _account) revert Errors.NotAllowed(); - - uint256 _totalValue; - uint256[] memory fromIDs = new uint256[](len); - uint256[] memory toIDs = new uint256[](len); - uint256[] memory values = new uint256[](len); - uint256[] memory amounts = new uint256[](len); - - { - for (uint256 i; i < len;) { - uint256 _fractionID = _fractionIDs[i]; - fromIDs[i] = _fractionID; - toIDs[i] = target; - amounts[i] = 1; - values[i] = tokenValues[_fractionID]; - - if (owners[_fractionID] != _account) { - revert Errors.NotAllowed(); - } - - unchecked { - ++i; - } - } - } - - _beforeUnitTransfer(_msgSender(), _account, fromIDs, toIDs, values, ""); - - for (uint256 i; i < len;) { - _totalValue += values[i]; - - delete tokenValues[fromIDs[i]]; - unchecked { - ++i; - } - } - - tokenValues[target] += _totalValue; - - _burnBatch(_account, fromIDs, amounts); - } - - /// @dev Burn the token at `_tokenID` owned by `_account` - /// @dev Not allowed to burn base type. - /// @dev `_tokenID` must hold all value declared at base type - function _burnToken(address _account, uint256 _tokenID) internal { - if (_account != _msgSender() && !isApprovedForAll(_account, _msgSender())) revert Errors.NotApprovedOrOwner(); - - uint256 value = tokenValues[_tokenID]; - - delete tokenValues[_tokenID]; - - _burn(_account, _tokenID, 1); - emit ValueTransfer(getBaseType(_tokenID), _tokenID, 0, value); - } - - /// TRANSFERS - - // The following functions are overrides required by Solidity. - function _afterTokenTransfer( - address operator, - address from, - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal virtual override { - super._afterTokenTransfer(operator, from, to, ids, amounts, data); - - uint256 len = ids.length; - - for (uint256 i; i < len;) { - owners[ids[i]] = to; - unchecked { - ++i; - } - } - } - - function _beforeUnitTransfer( - address operator, - address from, - uint256[] memory fromIDs, - uint256[] memory toIDs, - uint256[] memory values, - bytes memory data - ) internal virtual { - uint256 len = fromIDs.length; - if (from != _msgSender() && !isApprovedForAll(from, _msgSender())) revert Errors.NotApprovedOrOwner(); - - for (uint256 i; i < len;) { - uint256 _from = fromIDs[i]; - uint256 _to = toIDs[i]; - - if (isBaseType(_from)) revert Errors.NotAllowed(); - if (getBaseType(_from) != getBaseType(_to)) revert Errors.TypeMismatch(); - unchecked { - ++i; - } - } - } - - /// METADATA - - /// @dev see { openzeppelin-contracts-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol } - /// @dev Always returns the URI for the basetype so that it's managed in one place. - function uri(uint256 tokenID) - public - view - virtual - override(ERC1155Upgradeable, ERC1155URIStorageUpgradeable) - returns (string memory _uri) - { - // All tokens share the same metadata at the moment - _uri = ERC1155URIStorageUpgradeable.uri(getBaseType(tokenID)); - } - - /// UTILS - - /** - * @dev Check if value is below max item index - */ - function _notMaxItem(uint256 tokenID) private pure { - uint128 _count = uint128(tokenID); - ++_count; - } - - /** - * @dev Check if value is below max type index - */ - function _notMaxType(uint256 tokenID) private pure { - uint128 _count = uint128(tokenID >> 128); - ++_count; - } - - /** - * @dev calculate the sum of the elements of an array - */ - function _getSum(uint256[] memory array) internal pure returns (uint256 sum) { - uint256 len = array.length; - for (uint256 i; i < len;) { - if (array[i] == 0) revert Errors.NotAllowed(); - sum += array[i]; - unchecked { - ++i; - } - } - } - - function _getSingletonArray(uint256 element) private pure returns (uint256[] memory) { - uint256[] memory array = new uint256[](1); - array[0] = element; - - return array; - } - - // UUPS PROXY - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol } - function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner { - // solhint-disable-previous-line no-empty-blocks - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - * Assuming 30 available slots (slots cost space, cost gas) - * 1. typeCounter - * 2. owners - * 3. creators - * 4. tokenValues - * 5. maxIndex - */ - uint256[25] private __gap; -} diff --git a/contracts/contracts/interfaces/IAllowlist.sol b/contracts/contracts/interfaces/IAllowlist.sol deleted file mode 100644 index 2ce9a044..00000000 --- a/contracts/contracts/interfaces/IAllowlist.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.16; - -/// @title Interface for allowlist -/// @author bitbeckers -/// @notice This interface declares the required functionality for a hypercert token -/// @notice This interface does not specify the underlying token type (e.g. 721 or 1155) -interface IAllowlist { - function isAllowedToClaim(bytes32[] calldata proof, uint256 tokenID, bytes32 leaf) - external - view - returns (bool isAllowed); -} diff --git a/contracts/contracts/interfaces/IHypercertToken.sol b/contracts/contracts/interfaces/IHypercertToken.sol deleted file mode 100644 index 1ed1e34e..00000000 --- a/contracts/contracts/interfaces/IHypercertToken.sol +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.16; - -/// @title Interface for hypercert token interactions -/// @author bitbeckers -/// @notice This interface declares the required functionality for a hypercert token -/// @notice This interface does not specify the underlying token type (e.g. 721 or 1155) -interface IHypercertToken { - /** - * AllowAll = Unrestricted - * DisallowAll = Transfers disabled after minting - * FromCreatorOnly = Only the original creator can transfer - */ - /// @dev Transfer restriction policies on hypercerts - enum TransferRestrictions { - AllowAll, - DisallowAll, - FromCreatorOnly - } - - /// @dev Emitted when token with tokenID `claimID` is stored, with external data reference via `uri`. - event ClaimStored(uint256 indexed claimID, string uri, uint256 totalUnits); - - /// @dev Function called to store a claim referenced via `uri` with a maximum number of fractions `units`. - function mintClaim(address account, uint256 units, string memory uri, TransferRestrictions restrictions) external; - - /// @dev Function called to store a claim referenced via `uri` with a set of `fractions`. - /// @dev Fractions are internally summed to total units. - function mintClaimWithFractions( - address account, - uint256 units, - uint256[] memory fractions, - string memory uri, - TransferRestrictions restrictions - ) external; - - /// @dev Function called to split `tokenID` owned by `account` into units declared in `values`. - /// @notice The sum of `values` must equal the current value of `_tokenID`. - function splitFraction(address account, uint256 tokenID, uint256[] memory _values) external; - - /// @dev Function called to merge tokens within `tokenIDs`. - /// @notice Tokens that have been merged are burned. - function mergeFractions(address account, uint256[] memory tokenIDs) external; - - /// @dev Function to burn the token at `tokenID` for `account` - /// @notice Operator must be allowed by `creator` and the token must represent the total amount of available units. - function burnFraction(address account, uint256 tokenID) external; - - /// @dev Returns the `units` held by a (fractional) token at `claimID` - /// @dev If `tokenID` is a base type, the total amount of `units` for the claim is returned. - /// @dev If `tokenID` is a fractional token, the `units` held by the token is returned - function unitsOf(uint256 tokenID) external view returns (uint256 units); - - /// @dev Returns the `units` held by `account` of a (fractional) token at `claimID` - /// @dev If `tokenID` is a base type, the total amount of `units` held by `account` for the claim is returned. - /// @dev If `tokenID` is a fractional token, the `units` held by `account` the token is returned - function unitsOf(address account, uint256 tokenID) external view returns (uint256 units); - - /// @dev Returns the `uri` for metadata of the claim represented by `tokenID` - /// @dev Metadata must conform to { Hypercert Metadata } spec (based on ERC1155 Metadata) - function uri(uint256 tokenID) external view returns (string memory metadata); -} diff --git a/contracts/contracts/libs/Errors.sol b/contracts/contracts/libs/Errors.sol deleted file mode 100644 index e19d6b5c..00000000 --- a/contracts/contracts/libs/Errors.sol +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.16; - -/// @author bitbeckers -library Errors { - error AlreadyClaimed(); - error ArraySize(); - error DoesNotExist(); - error DuplicateEntry(); - error Invalid(); - error NotAllowed(); - error NotApprovedOrOwner(); - error TransfersNotAllowed(); - error TypeMismatch(); -} diff --git a/contracts/hardhat.config.cts b/contracts/hardhat.config.cts index 12f16ae9..6ad1e73e 100644 --- a/contracts/hardhat.config.cts +++ b/contracts/hardhat.config.cts @@ -83,6 +83,7 @@ function getChainConfig(chain: keyof typeof chainIds) { if (chain === "optimism-mainnet") { config = { ...config, + // url: "https://virtual.optimism.rpc.tenderly.co/41aca07e-03d1-4a5c-807a-e43c1777100a" url: `https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, }; } diff --git a/contracts/package.json b/contracts/package.json index 647817e0..157ee56d 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,7 +1,7 @@ { "name": "@hypercerts-org/contracts", "description": "EVM compatible protocol for managing impact claims", - "version": "2.0.0-alpha.5", + "version": "2.0.0-alpha.6", "author": { "name": "Hypercerts Foundation", "url": "https://github.com/hypercerts-org/hypercerts" diff --git a/contracts/src/deployments/deployments-protocol.json b/contracts/src/deployments/deployments-protocol.json index 6740f84c..8060e845 100644 --- a/contracts/src/deployments/deployments-protocol.json +++ b/contracts/src/deployments/deployments-protocol.json @@ -5,7 +5,7 @@ }, "10": { "HypercertMinterUUPS": "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07", - "HypercertMinterImplementation": "0x396d5f1ef3aa92ddad4dead04388374a03bc5577" + "HypercertMinterImplementation": "0xEbA30978164Cc0985091F11532C8f83a5Fa98622" }, "42220": { "HypercertMinterUUPS": "0x16bA53B74c234C870c61EFC04cD418B8f2865959", diff --git a/contracts/tasks/deploy-propose-upgrade.ts b/contracts/tasks/deploy-propose-upgrade.ts new file mode 100644 index 00000000..0e9327e8 --- /dev/null +++ b/contracts/tasks/deploy-propose-upgrade.ts @@ -0,0 +1,52 @@ +import { task } from "hardhat/config"; + +task("deploy-propose-upgrade", "Validate, deploy and verify an upgraded implementation") + .addParam("proxy", "Provider current proxy address") + .setAction(async ({ proxy }, { ethers, upgrades, network, run }) => { + console.log("network: ", network); + console.log("Using address: ", await ethers.getSigners().then((res) => res[0].address)); + const HypercertMinter = await ethers.getContractFactory("HypercertMinter"); + + console.log("Validating implementation.."); + await upgrades + .validateImplementation(HypercertMinter, { kind: "uups" }) + .then(() => console.log("Valid implementation")); + + console.log("Preparing upgrade.."); + const newImplementationAddress = await upgrades + .prepareUpgrade(proxy, HypercertMinter, { + useDefenderDeploy: false, + redeployImplementation: "always", + kind: "uups", + }) + .then((res) => { + return res; + }); + + console.log(`Deployed upgraded contract to ${newImplementationAddress}`); + + if (network.name !== "hardhat" && network.name !== "localhost") { + console.log(`Starting verification process...`); + + try { + const code = await ethers.provider.getCode(newImplementationAddress); + if (code === "0x") { + console.log(`Contract deployment has not completed. waiting to verify...`); + await HypercertMinter.attach(newImplementationAddress).deployed(); + } + + await run("verify:verify", { + address: newImplementationAddress, + }); + } catch (error) { + const errorMessage = (error as Error).message; + + if (errorMessage.includes("Reason: Already Verified")) { + console.log("Reason: Already Verified"); + } + console.error(errorMessage); + } + } + + console.log(`Done 🚀`); + }); diff --git a/contracts/tasks/force-import.ts b/contracts/tasks/force-import.ts index 9c919855..bd03fe38 100644 --- a/contracts/tasks/force-import.ts +++ b/contracts/tasks/force-import.ts @@ -7,5 +7,6 @@ task("force-import", "Deploy contracts and verify") const hypercertMinter = await upgrades.forceImport(proxy, HypercertMinter, { kind: "uups", }); - console.log(`HypercertMinter imported: ${hypercertMinter.address}`); + console.log(`HypercertMinter imported: ${hypercertMinter}`); + console.log(Object.keys(hypercertMinter)); }); diff --git a/contracts/tasks/index.ts b/contracts/tasks/index.ts index 5a260774..9b31a4b3 100644 --- a/contracts/tasks/index.ts +++ b/contracts/tasks/index.ts @@ -12,3 +12,4 @@ export * from "./validate-upgrade.js"; export * from "./deploy-marketplace.js"; export * from "./propose-owner.js"; export * from "./deploy-fee-recipient.js"; +export * from "./deploy-propose-upgrade.js";