@artblocks/contracts 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/.env.example +10 -0
  2. package/LICENSE +165 -0
  3. package/README.md +286 -0
  4. package/artifacts/contracts/AdminACLV0.sol/AdminACLV0.json +164 -0
  5. package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +248 -0
  6. package/artifacts/contracts/BasicRandomizer.sol/BasicRandomizer.json +24 -0
  7. package/artifacts/contracts/BasicRandomizerV2.sol/BasicRandomizerV2.json +102 -0
  8. package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +1020 -0
  9. package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +1928 -0
  10. package/artifacts/contracts/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +1942 -0
  11. package/artifacts/contracts/engine/GenArt721CoreV2_ENGINE_FLEX.sol/GenArt721CoreV2_ENGINE_FLEX.json +1708 -0
  12. package/artifacts/contracts/engine/GenArt721CoreV2_PBAB.sol/GenArt721CoreV2_PBAB.json +1410 -0
  13. package/artifacts/contracts/engine/GenArt721CoreV2_PRTNR.sol/GenArt721CoreV2_PRTNR.json +1436 -0
  14. package/artifacts/contracts/engine/GenArt721MinterBurner_PBAB.sol/GenArt721MinterBurner_PBAB.json +437 -0
  15. package/artifacts/contracts/engine/GenArt721MinterDAExp_PBAB.sol/GenArt721MinterDAExp_PBAB.json +508 -0
  16. package/artifacts/contracts/engine/GenArt721Minter_PBAB.sol/GenArt721Minter_PBAB.json +381 -0
  17. package/artifacts/contracts/engine-registry/EngineRegistryV0.sol/EngineRegistryV0.json +109 -0
  18. package/artifacts/contracts/engine-registry/future/EngineRegistryV1.sol/EngineRegistryV1.json +109 -0
  19. package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +1902 -0
  20. package/artifacts/contracts/interfaces/0.5.x/IBonusContract.sol/IBonusContract.json +47 -0
  21. package/artifacts/contracts/interfaces/0.5.x/IGenArt721CoreContractV1.sol/IGenArt721CoreContractV1.json +413 -0
  22. package/artifacts/contracts/interfaces/0.5.x/IGenArt721CoreV2_PBAB.sol/IGenArt721CoreV2_PBAB.json +392 -0
  23. package/artifacts/contracts/interfaces/0.5.x/IRandomizer.sol/IRandomizer.json +26 -0
  24. package/artifacts/contracts/interfaces/0.8.x/IAdminACLV0.sol/IAdminACLV0.json +122 -0
  25. package/artifacts/contracts/interfaces/0.8.x/IArtblocksRoyaltyOverride.sol/IArtblocksRoyaltyOverride.json +59 -0
  26. package/artifacts/contracts/interfaces/0.8.x/IBonusContract.sol/IBonusContract.json +43 -0
  27. package/artifacts/contracts/interfaces/0.8.x/IDelegationRegistry.sol/IDelegationRegistry.json +510 -0
  28. package/artifacts/contracts/interfaces/0.8.x/IDependencyRegistryCompatibleV0.sol/IDependencyRegistryCompatibleV0.json +53 -0
  29. package/artifacts/contracts/interfaces/0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +350 -0
  30. package/artifacts/contracts/interfaces/0.8.x/IEngineRegistryV0.sol/IEngineRegistryV0.json +85 -0
  31. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol/IFilteredMinterDAExpSettlementV0.json +730 -0
  32. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpV0.sol/IFilteredMinterDAExpV0.json +311 -0
  33. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpV1.sol/IFilteredMinterDAExpV1.json +617 -0
  34. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDALinV0.sol/IFilteredMinterDALinV0.json +292 -0
  35. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDALinV1.sol/IFilteredMinterDALinV1.json +598 -0
  36. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterHolderV0.sol/IFilteredMinterHolderV0.json +355 -0
  37. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterHolderV1.sol/IFilteredMinterHolderV1.json +368 -0
  38. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterHolderV2.sol/IFilteredMinterHolderV2.json +674 -0
  39. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterMerkleV0.sol/IFilteredMinterMerkleV0.json +551 -0
  40. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterMerkleV1.sol/IFilteredMinterMerkleV1.json +564 -0
  41. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterMerkleV2.sol/IFilteredMinterMerkleV2.json +601 -0
  42. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterV0.sol/IFilteredMinterV0.json +216 -0
  43. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterV1.sol/IFilteredMinterV1.json +485 -0
  44. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterV2.sol/IFilteredMinterV2.json +522 -0
  45. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV1.sol/IGenArt721CoreContractV1.json +299 -0
  46. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3.sol/IGenArt721CoreContractV3.json +609 -0
  47. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol/IGenArt721CoreContractV3_Base.json +448 -0
  48. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol/IGenArt721CoreContractV3_Engine.json +649 -0
  49. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreV2_PBAB.sol/IGenArt721CoreV2_PBAB.json +362 -0
  50. package/artifacts/contracts/interfaces/0.8.x/IManifold.sol/IManifold.json +35 -0
  51. package/artifacts/contracts/interfaces/0.8.x/IMinterFilterV0.sol/IMinterFilterV0.json +192 -0
  52. package/artifacts/contracts/interfaces/0.8.x/IRandomizer.sol/IRandomizer.json +24 -0
  53. package/artifacts/contracts/interfaces/0.8.x/IRandomizerV2.sol/IRandomizerV2.json +37 -0
  54. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/Address.json +10 -0
  55. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/Counters.json +10 -0
  56. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/CustomERC721Metadata.json +425 -0
  57. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/ERC165.json +38 -0
  58. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/ERC721.json +322 -0
  59. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/ERC721Enumerable.json +384 -0
  60. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/GenArt721CoreV1.json +1773 -0
  61. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC165.json +32 -0
  62. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC721.json +316 -0
  63. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC721Enumerable.json +378 -0
  64. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC721Receiver.json +47 -0
  65. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/SafeMath.json +10 -0
  66. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/Strings.json +10 -0
  67. package/artifacts/contracts/legacy/GenArt721LegacyMinter.sol/GenArt721LegacyMinter.json +338 -0
  68. package/artifacts/contracts/libs/0.5.x/CustomERC721Metadata.sol/CustomERC721Metadata.json +425 -0
  69. package/artifacts/contracts/libs/0.5.x/IERC20.sol/IERC20.json +206 -0
  70. package/artifacts/contracts/libs/0.5.x/SafeMath.sol/SafeMath.json +10 -0
  71. package/artifacts/contracts/libs/0.5.x/Strings.sol/Strings.json +10 -0
  72. package/artifacts/contracts/libs/0.8.x/BytecodeStorage.sol/BytecodeStorage.json +10 -0
  73. package/artifacts/contracts/libs/0.8.x/Bytes32Strings.sol/Bytes32Strings.json +10 -0
  74. package/artifacts/contracts/libs/0.8.x/ERC721_PackedHashSeed.sol/ERC721_PackedHashSeed.json +357 -0
  75. package/artifacts/contracts/libs/integration-refs/delegation-registry/DelegationRegistry.sol/DelegationRegistry.json +529 -0
  76. package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeMock.sol/GnosisSafeMock.json +1037 -0
  77. package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeProxyFactoryMock.sol/GnosisSafeProxyFactoryMock.json +172 -0
  78. package/artifacts/contracts/libs/integration-refs/gnosis-safe/MultiSendMock.sol/MultiSendMock.json +24 -0
  79. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV0.sol/MinterFilterV0.json +342 -0
  80. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +322 -0
  81. package/artifacts/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +550 -0
  82. package/artifacts/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +856 -0
  83. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +1053 -0
  84. package/artifacts/contracts/minter-suite/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +526 -0
  85. package/artifacts/contracts/minter-suite/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +832 -0
  86. package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +794 -0
  87. package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +1100 -0
  88. package/artifacts/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +1002 -0
  89. package/artifacts/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +1039 -0
  90. package/artifacts/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +365 -0
  91. package/artifacts/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +671 -0
  92. package/artifacts/contracts/minter-suite/Minters/MinterSetPrice/deprecated/MinterSetPriceV1.sol/MinterSetPriceV1.json +288 -0
  93. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +436 -0
  94. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +742 -0
  95. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20/deprecated/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +461 -0
  96. package/artifacts/contracts/mock/BytecodeTextCR_DMock.sol/BytecodeTextCR_DMock.json +194 -0
  97. package/artifacts/contracts/mock/DeadReceiverMock.sol/DeadReceiverMock.json +15 -0
  98. package/artifacts/contracts/mock/ERC20Mock.sol/ERC20Mock.json +292 -0
  99. package/artifacts/contracts/mock/MockAdminACLV0.sol/MockAdminACLV0Events.json +165 -0
  100. package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +128 -0
  101. package/artifacts/contracts/mock/ReentrancyHolderMock.sol/ReentrancyHolderMock.json +118 -0
  102. package/artifacts/contracts/mock/ReentrancyMerkleMock.sol/ReentrancyMerkleMock.json +87 -0
  103. package/artifacts/contracts/mock/ReentrancyMock.sol/ReentrancyMock.json +82 -0
  104. package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride.sol/GenArt721RoyaltyOverride.json +208 -0
  105. package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride_PBAB.sol/GenArt721RoyaltyOverride_PBAB.json +301 -0
  106. package/contracts/AdminACLV0.sol +103 -0
  107. package/contracts/AdminACLV1.sol +193 -0
  108. package/contracts/BasicRandomizer.sol +23 -0
  109. package/contracts/BasicRandomizerV2.sol +36 -0
  110. package/contracts/DependencyRegistryV0.sol +893 -0
  111. package/contracts/GenArt721CoreV3.sol +2001 -0
  112. package/contracts/GenArt721CoreV3_Engine.sol +2061 -0
  113. package/contracts/engine/GenArt721CoreV2_ENGINE_FLEX.sol +887 -0
  114. package/contracts/engine/GenArt721CoreV2_PBAB.sol +695 -0
  115. package/contracts/engine/GenArt721CoreV2_PRTNR.sol +749 -0
  116. package/contracts/engine/GenArt721MinterBurner_PBAB.sol +467 -0
  117. package/contracts/engine/GenArt721MinterDAExp_PBAB.sol +614 -0
  118. package/contracts/engine/GenArt721Minter_PBAB.sol +420 -0
  119. package/contracts/engine-registry/EngineRegistryV0.sol +72 -0
  120. package/contracts/engine-registry/future/EngineRegistryV1.sol +86 -0
  121. package/contracts/explorations/GenArt721CoreV3_Explorations.sol +1989 -0
  122. package/contracts/interfaces/0.5.x/IBonusContract.sol +10 -0
  123. package/contracts/interfaces/0.5.x/IGenArt721CoreContractV1.sol +91 -0
  124. package/contracts/interfaces/0.5.x/IGenArt721CoreV2_PBAB.sol +92 -0
  125. package/contracts/interfaces/0.5.x/IRandomizer.sol +8 -0
  126. package/contracts/interfaces/0.8.x/IAdminACLV0.sol +51 -0
  127. package/contracts/interfaces/0.8.x/IArtblocksRoyaltyOverride.sol +34 -0
  128. package/contracts/interfaces/0.8.x/IBonusContract.sol +10 -0
  129. package/contracts/interfaces/0.8.x/IDelegationRegistry.sol +221 -0
  130. package/contracts/interfaces/0.8.x/IDependencyRegistryCompatibleV0.sol +31 -0
  131. package/contracts/interfaces/0.8.x/IDependencyRegistryV0.sol +95 -0
  132. package/contracts/interfaces/0.8.x/IEngineRegistryV0.sol +38 -0
  133. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol +70 -0
  134. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpV0.sol +35 -0
  135. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpV1.sol +16 -0
  136. package/contracts/interfaces/0.8.x/IFilteredMinterDALinV0.sol +32 -0
  137. package/contracts/interfaces/0.8.x/IFilteredMinterDALinV1.sol +16 -0
  138. package/contracts/interfaces/0.8.x/IFilteredMinterHolderV0.sol +68 -0
  139. package/contracts/interfaces/0.8.x/IFilteredMinterHolderV1.sol +19 -0
  140. package/contracts/interfaces/0.8.x/IFilteredMinterHolderV2.sol +19 -0
  141. package/contracts/interfaces/0.8.x/IFilteredMinterMerkleV0.sol +37 -0
  142. package/contracts/interfaces/0.8.x/IFilteredMinterMerkleV1.sol +19 -0
  143. package/contracts/interfaces/0.8.x/IFilteredMinterMerkleV2.sol +19 -0
  144. package/contracts/interfaces/0.8.x/IFilteredMinterV0.sol +74 -0
  145. package/contracts/interfaces/0.8.x/IFilteredMinterV1.sol +127 -0
  146. package/contracts/interfaces/0.8.x/IFilteredMinterV2.sol +30 -0
  147. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV1.sol +73 -0
  148. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3.sol +79 -0
  149. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol +127 -0
  150. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol +80 -0
  151. package/contracts/interfaces/0.8.x/IGenArt721CoreV2_PBAB.sol +91 -0
  152. package/contracts/interfaces/0.8.x/IManifold.sol +24 -0
  153. package/contracts/interfaces/0.8.x/IMinterFilterV0.sol +47 -0
  154. package/contracts/interfaces/0.8.x/IRandomizer.sol +8 -0
  155. package/contracts/interfaces/0.8.x/IRandomizerV2.sol +15 -0
  156. package/contracts/legacy/GenArt721CoreV1.sol +1593 -0
  157. package/contracts/legacy/GenArt721LegacyMinter.sol +275 -0
  158. package/contracts/libs/0.5.x/CustomERC721Metadata.sol +52 -0
  159. package/contracts/libs/0.5.x/IERC20.sol +96 -0
  160. package/contracts/libs/0.5.x/SafeMath.sol +98 -0
  161. package/contracts/libs/0.5.x/Strings.sol +92 -0
  162. package/contracts/libs/0.8.x/BytecodeStorage.sol +314 -0
  163. package/contracts/libs/0.8.x/Bytes32Strings.sol +66 -0
  164. package/contracts/libs/0.8.x/ERC721_PackedHashSeed.sol +514 -0
  165. package/contracts/libs/integration-refs/delegation-registry/DelegationRegistry.sol +663 -0
  166. package/contracts/libs/integration-refs/gnosis-safe/GnosisSafeMock.sol +6 -0
  167. package/contracts/libs/integration-refs/gnosis-safe/GnosisSafeProxyFactoryMock.sol +6 -0
  168. package/contracts/libs/integration-refs/gnosis-safe/MultiSendMock.sol +6 -0
  169. package/contracts/minter-suite/MinterFilter/MinterFilterV0.sol +291 -0
  170. package/contracts/minter-suite/MinterFilter/MinterFilterV1.sol +320 -0
  171. package/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol +571 -0
  172. package/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol +622 -0
  173. package/contracts/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol +1066 -0
  174. package/contracts/minter-suite/Minters/MinterDALin/MinterDALinV2.sol +527 -0
  175. package/contracts/minter-suite/Minters/MinterDALin/MinterDALinV3.sol +576 -0
  176. package/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol +749 -0
  177. package/contracts/minter-suite/Minters/MinterHolder/MinterHolderV3.sol +798 -0
  178. package/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol +682 -0
  179. package/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol +733 -0
  180. package/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol +350 -0
  181. package/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol +401 -0
  182. package/contracts/minter-suite/Minters/MinterSetPrice/deprecated/MinterSetPriceV1.sol +274 -0
  183. package/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol +491 -0
  184. package/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol +542 -0
  185. package/contracts/minter-suite/Minters/MinterSetPriceERC20/deprecated/MinterSetPriceERC20V0.sol +470 -0
  186. package/contracts/mock/BytecodeTextCR_DMock.sol +184 -0
  187. package/contracts/mock/DeadReceiverMock.sol +13 -0
  188. package/contracts/mock/ERC20Mock.sol +11 -0
  189. package/contracts/mock/MockAdminACLV0.sol +65 -0
  190. package/contracts/mock/RandomizerV2_NoAssignMock.sol +43 -0
  191. package/contracts/mock/ReentrancyHolderMock.sol +50 -0
  192. package/contracts/mock/ReentrancyMerkleMock.sol +64 -0
  193. package/contracts/mock/ReentrancyMock.sol +44 -0
  194. package/contracts/royalty-registry/GenArt721RoyaltyOverride.sol +168 -0
  195. package/contracts/royalty-registry/GenArt721RoyaltyOverride_PBAB.sol +221 -0
  196. package/package.json +83 -0
@@ -0,0 +1,1593 @@
1
+ /**
2
+ * Etherscan verified contract:
3
+ * https://etherscan.io/address/0xa7d8d9ef8d8ce8992df33d8b8cf4aebabd5bd270#code
4
+ * REPO-ONLY MODIFICATIONS relative to deployed contract source code:
5
+ * - use IRandomizer to avoid namespace nuisance with `Randomizer` interface
6
+ * - add `is IGenArt721CoreContractV1` to core contract to ensure repo
7
+ * maintains conforming V1 core contract interface
8
+ */
9
+
10
+ import "../interfaces/0.5.x/IRandomizer.sol";
11
+ import "../interfaces/0.5.x/IGenArt721CoreContractV1.sol";
12
+
13
+ /// -----------------------------------------------------
14
+ /**
15
+ *Submitted for verification at Etherscan.io on 2020-12-12
16
+ */
17
+
18
+ // File contracts/libs/IERC165.sol
19
+
20
+ // File: openzeppelin-solidity/contracts/introspection/IERC165.sol
21
+ pragma solidity ^0.5.0;
22
+
23
+ /**
24
+ * @dev Interface of the ERC165 standard, as defined in the
25
+ * [EIP](https://eips.ethereum.org/EIPS/eip-165).
26
+ *
27
+ * Implementers can declare support of contract interfaces, which can then be
28
+ * queried by others (`ERC165Checker`).
29
+ *
30
+ * For an implementation, see `ERC165`.
31
+ */
32
+ interface IERC165 {
33
+ /**
34
+ * @dev Returns true if this contract implements the interface defined by
35
+ * `interfaceId`. See the corresponding
36
+ * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
37
+ * to learn more about how these ids are created.
38
+ *
39
+ * This function call must use less than 30 000 gas.
40
+ */
41
+ function supportsInterface(bytes4 interfaceId) external view returns (bool);
42
+ }
43
+
44
+ // File contracts/libs/ERC165.sol
45
+
46
+ // File: openzeppelin-solidity/contracts/introspection/ERC165.sol
47
+
48
+ pragma solidity ^0.5.0;
49
+
50
+ /**
51
+ * @dev Implementation of the `IERC165` interface.
52
+ *
53
+ * Contracts may inherit from this and call `_registerInterface` to declare
54
+ * their support of an interface.
55
+ */
56
+ contract ERC165 is IERC165 {
57
+ /*
58
+ * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
59
+ */
60
+ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
61
+
62
+ /**
63
+ * @dev Mapping of interface ids to whether or not it's supported.
64
+ */
65
+ mapping(bytes4 => bool) private _supportedInterfaces;
66
+
67
+ constructor() internal {
68
+ // Derived contracts need only register support for their own interfaces,
69
+ // we register support for ERC165 itself here
70
+ _registerInterface(_INTERFACE_ID_ERC165);
71
+ }
72
+
73
+ /**
74
+ * @dev See `IERC165.supportsInterface`.
75
+ *
76
+ * Time complexity O(1), guaranteed to always use less than 30 000 gas.
77
+ */
78
+ function supportsInterface(
79
+ bytes4 interfaceId
80
+ ) external view returns (bool) {
81
+ return _supportedInterfaces[interfaceId];
82
+ }
83
+
84
+ /**
85
+ * @dev Registers the contract as an implementer of the interface defined by
86
+ * `interfaceId`. Support of the actual ERC165 interface is automatic and
87
+ * registering its interface id is not required.
88
+ *
89
+ * See `IERC165.supportsInterface`.
90
+ *
91
+ * Requirements:
92
+ *
93
+ * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
94
+ */
95
+ function _registerInterface(bytes4 interfaceId) internal {
96
+ require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
97
+ _supportedInterfaces[interfaceId] = true;
98
+ }
99
+ }
100
+
101
+ // File contracts/libs/IERC721.sol
102
+
103
+ // File: openzeppelin-solidity/contracts/token/ERC721/IERC721.sol
104
+
105
+ pragma solidity ^0.5.0;
106
+
107
+ /**
108
+ * @dev Required interface of an ERC721 compliant contract.
109
+ */
110
+ contract IERC721 is IERC165 {
111
+ event Transfer(
112
+ address indexed from,
113
+ address indexed to,
114
+ uint256 indexed tokenId
115
+ );
116
+ event Approval(
117
+ address indexed owner,
118
+ address indexed approved,
119
+ uint256 indexed tokenId
120
+ );
121
+ event ApprovalForAll(
122
+ address indexed owner,
123
+ address indexed operator,
124
+ bool approved
125
+ );
126
+
127
+ /**
128
+ * @dev Returns the number of NFTs in `owner`'s account.
129
+ */
130
+ function balanceOf(address owner) public view returns (uint256 balance);
131
+
132
+ /**
133
+ * @dev Returns the owner of the NFT specified by `tokenId`.
134
+ */
135
+ function ownerOf(uint256 tokenId) public view returns (address owner);
136
+
137
+ /**
138
+ * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
139
+ * another (`to`).
140
+ *
141
+ *
142
+ *
143
+ * Requirements:
144
+ * - `from`, `to` cannot be zero.
145
+ * - `tokenId` must be owned by `from`.
146
+ * - If the caller is not `from`, it must be have been allowed to move this
147
+ * NFT by either `approve` or `setApproveForAll`.
148
+ */
149
+ function safeTransferFrom(address from, address to, uint256 tokenId) public;
150
+
151
+ /**
152
+ * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
153
+ * another (`to`).
154
+ *
155
+ * Requirements:
156
+ * - If the caller is not `from`, it must be approved to move this NFT by
157
+ * either `approve` or `setApproveForAll`.
158
+ */
159
+ function transferFrom(address from, address to, uint256 tokenId) public;
160
+
161
+ function approve(address to, uint256 tokenId) public;
162
+
163
+ function getApproved(
164
+ uint256 tokenId
165
+ ) public view returns (address operator);
166
+
167
+ function setApprovalForAll(address operator, bool _approved) public;
168
+
169
+ function isApprovedForAll(
170
+ address owner,
171
+ address operator
172
+ ) public view returns (bool);
173
+
174
+ function safeTransferFrom(
175
+ address from,
176
+ address to,
177
+ uint256 tokenId,
178
+ bytes memory data
179
+ ) public;
180
+ }
181
+
182
+ // File contracts/libs/SafeMath.sol
183
+
184
+ // File: openzeppelin-solidity/contracts/math/SafeMath.sol
185
+
186
+ pragma solidity ^0.5.0;
187
+
188
+ /**
189
+ * @dev Wrappers over Solidity's arithmetic operations with added overflow
190
+ * checks.
191
+ *
192
+ * Arithmetic operations in Solidity wrap on overflow. This can easily result
193
+ * in bugs, because programmers usually assume that an overflow raises an
194
+ * error, which is the standard behavior in high level programming languages.
195
+ * `SafeMath` restores this intuition by reverting the transaction when an
196
+ * operation overflows.
197
+ *
198
+ * Using this library instead of the unchecked operations eliminates an entire
199
+ * class of bugs, so it's recommended to use it always.
200
+ */
201
+ library SafeMath {
202
+ /**
203
+ * @dev Returns the addition of two unsigned integers, reverting on
204
+ * overflow.
205
+ *
206
+ * Counterpart to Solidity's `+` operator.
207
+ *
208
+ * Requirements:
209
+ * - Addition cannot overflow.
210
+ */
211
+ function add(uint256 a, uint256 b) internal pure returns (uint256) {
212
+ uint256 c = a + b;
213
+ require(c >= a, "SafeMath: addition overflow");
214
+
215
+ return c;
216
+ }
217
+
218
+ /**
219
+ * @dev Returns the subtraction of two unsigned integers, reverting on
220
+ * overflow (when the result is negative).
221
+ *
222
+ * Counterpart to Solidity's `-` operator.
223
+ *
224
+ * Requirements:
225
+ * - Subtraction cannot overflow.
226
+ */
227
+ function sub(uint256 a, uint256 b) internal pure returns (uint256) {
228
+ require(b <= a, "SafeMath: subtraction overflow");
229
+ uint256 c = a - b;
230
+
231
+ return c;
232
+ }
233
+
234
+ /**
235
+ * @dev Returns the multiplication of two unsigned integers, reverting on
236
+ * overflow.
237
+ *
238
+ * Counterpart to Solidity's `*` operator.
239
+ *
240
+ * Requirements:
241
+ * - Multiplication cannot overflow.
242
+ */
243
+ function mul(uint256 a, uint256 b) internal pure returns (uint256) {
244
+ // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
245
+ // benefit is lost if 'b' is also tested.
246
+ // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
247
+ if (a == 0) {
248
+ return 0;
249
+ }
250
+
251
+ uint256 c = a * b;
252
+ require(c / a == b, "SafeMath: multiplication overflow");
253
+
254
+ return c;
255
+ }
256
+
257
+ /**
258
+ * @dev Returns the integer division of two unsigned integers. Reverts on
259
+ * division by zero. The result is rounded towards zero.
260
+ *
261
+ * Counterpart to Solidity's `/` operator. Note: this function uses a
262
+ * `revert` opcode (which leaves remaining gas untouched) while Solidity
263
+ * uses an invalid opcode to revert (consuming all remaining gas).
264
+ *
265
+ * Requirements:
266
+ * - The divisor cannot be zero.
267
+ */
268
+ function div(uint256 a, uint256 b) internal pure returns (uint256) {
269
+ // Solidity only automatically asserts when dividing by 0
270
+ require(b > 0, "SafeMath: division by zero");
271
+ uint256 c = a / b;
272
+ // assert(a == b * c + a % b); // There is no case in which this doesn't hold
273
+
274
+ return c;
275
+ }
276
+ }
277
+
278
+ // File contracts/libs/Address.sol
279
+
280
+ // File: openzeppelin-solidity/contracts/utils/Address.sol
281
+
282
+ pragma solidity ^0.5.0;
283
+
284
+ /**
285
+ * @dev Collection of functions related to the address type,
286
+ */
287
+ library Address {
288
+ /**
289
+ * @dev Returns true if `account` is a contract.
290
+ *
291
+ * This test is non-exhaustive, and there may be false-negatives: during the
292
+ * execution of a contract's constructor, its address will be reported as
293
+ * not containing a contract.
294
+ *
295
+ * > It is unsafe to assume that an address for which this function returns
296
+ * false is an externally-owned account (EOA) and not a contract.
297
+ */
298
+ function isContract(address account) internal view returns (bool) {
299
+ // This method relies in extcodesize, which returns 0 for contracts in
300
+ // construction, since the code is only stored at the end of the
301
+ // constructor execution.
302
+
303
+ uint256 size;
304
+ // solhint-disable-next-line no-inline-assembly
305
+ assembly {
306
+ size := extcodesize(account)
307
+ }
308
+ return size > 0;
309
+ }
310
+ }
311
+
312
+ // File contracts/libs/Counters.sol
313
+
314
+ // File: openzeppelin-solidity/contracts/drafts/Counters.sol
315
+
316
+ pragma solidity ^0.5.0;
317
+
318
+ /**
319
+ * @title Counters
320
+ * @author Matt Condon (@shrugs)
321
+ * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
322
+ * of elements in a mapping, issuing ERC721 ids, or counting request ids.
323
+ *
324
+ * Include with `using Counters for Counters.Counter;`
325
+ * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the SafeMath
326
+ * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
327
+ * directly accessed.
328
+ */
329
+ library Counters {
330
+ using SafeMath for uint256;
331
+
332
+ struct Counter {
333
+ // This variable should never be directly accessed by users of the library: interactions must be restricted to
334
+ // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
335
+ // this feature: see https://github.com/ethereum/solidity/issues/4637
336
+ uint256 _value; // default: 0
337
+ }
338
+
339
+ function current(Counter storage counter) internal view returns (uint256) {
340
+ return counter._value;
341
+ }
342
+
343
+ function increment(Counter storage counter) internal {
344
+ counter._value += 1;
345
+ }
346
+
347
+ function decrement(Counter storage counter) internal {
348
+ counter._value = counter._value.sub(1);
349
+ }
350
+ }
351
+
352
+ // File contracts/libs/IERC721Receiver.sol
353
+
354
+ // File: openzeppelin-solidity/contracts/token/ERC721/IERC721Receiver.sol
355
+
356
+ pragma solidity ^0.5.0;
357
+
358
+ /**
359
+ * @title ERC721 token receiver interface
360
+ * @dev Interface for any contract that wants to support safeTransfers
361
+ * from ERC721 asset contracts.
362
+ */
363
+ contract IERC721Receiver {
364
+ function onERC721Received(
365
+ address operator,
366
+ address from,
367
+ uint256 tokenId,
368
+ bytes memory data
369
+ ) public returns (bytes4);
370
+ }
371
+
372
+ // File contracts/libs/ERC721.sol
373
+
374
+ // File: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol
375
+
376
+ pragma solidity ^0.5.0;
377
+
378
+ /**
379
+ * @title ERC721 Non-Fungible Token Standard basic implementation
380
+ * @dev see https://eips.ethereum.org/EIPS/eip-721
381
+ */
382
+ contract ERC721 is ERC165, IERC721 {
383
+ using SafeMath for uint256;
384
+ using Address for address;
385
+ using Counters for Counters.Counter;
386
+
387
+ // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
388
+ // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
389
+ bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
390
+
391
+ // Mapping from token ID to owner
392
+ mapping(uint256 => address) private _tokenOwner;
393
+
394
+ // Mapping from token ID to approved address
395
+ mapping(uint256 => address) private _tokenApprovals;
396
+
397
+ // Mapping from owner to number of owned token
398
+ mapping(address => Counters.Counter) private _ownedTokensCount;
399
+
400
+ // Mapping from owner to operator approvals
401
+ mapping(address => mapping(address => bool)) private _operatorApprovals;
402
+
403
+ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
404
+
405
+ constructor() public {
406
+ // register the supported interfaces to conform to ERC721 via ERC165
407
+ _registerInterface(_INTERFACE_ID_ERC721);
408
+ }
409
+
410
+ function balanceOf(address owner) public view returns (uint256) {
411
+ require(
412
+ owner != address(0),
413
+ "ERC721: balance query for the zero address"
414
+ );
415
+
416
+ return _ownedTokensCount[owner].current();
417
+ }
418
+
419
+ function ownerOf(uint256 tokenId) public view returns (address) {
420
+ address owner = _tokenOwner[tokenId];
421
+ require(
422
+ owner != address(0),
423
+ "ERC721: owner query for nonexistent token"
424
+ );
425
+
426
+ return owner;
427
+ }
428
+
429
+ function approve(address to, uint256 tokenId) public {
430
+ address owner = ownerOf(tokenId);
431
+ require(to != owner, "ERC721: approval to current owner");
432
+
433
+ require(
434
+ msg.sender == owner || isApprovedForAll(owner, msg.sender),
435
+ "ERC721: approve caller is not owner nor approved for all"
436
+ );
437
+
438
+ _tokenApprovals[tokenId] = to;
439
+ emit Approval(owner, to, tokenId);
440
+ }
441
+
442
+ function getApproved(uint256 tokenId) public view returns (address) {
443
+ require(
444
+ _exists(tokenId),
445
+ "ERC721: approved query for nonexistent token"
446
+ );
447
+
448
+ return _tokenApprovals[tokenId];
449
+ }
450
+
451
+ function setApprovalForAll(address to, bool approved) public {
452
+ require(to != msg.sender, "ERC721: approve to caller");
453
+
454
+ _operatorApprovals[msg.sender][to] = approved;
455
+ emit ApprovalForAll(msg.sender, to, approved);
456
+ }
457
+
458
+ function isApprovedForAll(
459
+ address owner,
460
+ address operator
461
+ ) public view returns (bool) {
462
+ return _operatorApprovals[owner][operator];
463
+ }
464
+
465
+ function transferFrom(address from, address to, uint256 tokenId) public {
466
+ //solhint-disable-next-line max-line-length
467
+ require(
468
+ _isApprovedOrOwner(msg.sender, tokenId),
469
+ "ERC721: transfer caller is not owner nor approved"
470
+ );
471
+
472
+ _transferFrom(from, to, tokenId);
473
+ }
474
+
475
+ function safeTransferFrom(
476
+ address from,
477
+ address to,
478
+ uint256 tokenId
479
+ ) public {
480
+ safeTransferFrom(from, to, tokenId, "");
481
+ }
482
+
483
+ function safeTransferFrom(
484
+ address from,
485
+ address to,
486
+ uint256 tokenId,
487
+ bytes memory _data
488
+ ) public {
489
+ transferFrom(from, to, tokenId);
490
+ require(
491
+ _checkOnERC721Received(from, to, tokenId, _data),
492
+ "ERC721: transfer to non ERC721Receiver implementer"
493
+ );
494
+ }
495
+
496
+ function _exists(uint256 tokenId) internal view returns (bool) {
497
+ address owner = _tokenOwner[tokenId];
498
+ return owner != address(0);
499
+ }
500
+
501
+ function _isApprovedOrOwner(
502
+ address spender,
503
+ uint256 tokenId
504
+ ) internal view returns (bool) {
505
+ require(
506
+ _exists(tokenId),
507
+ "ERC721: operator query for nonexistent token"
508
+ );
509
+ address owner = ownerOf(tokenId);
510
+ return (spender == owner ||
511
+ getApproved(tokenId) == spender ||
512
+ isApprovedForAll(owner, spender));
513
+ }
514
+
515
+ function _mint(address to, uint256 tokenId) internal {
516
+ require(to != address(0), "ERC721: mint to the zero address");
517
+ require(!_exists(tokenId), "ERC721: token already minted");
518
+
519
+ _tokenOwner[tokenId] = to;
520
+ _ownedTokensCount[to].increment();
521
+
522
+ emit Transfer(address(0), to, tokenId);
523
+ }
524
+
525
+ function _burn(address owner, uint256 tokenId) internal {
526
+ require(
527
+ ownerOf(tokenId) == owner,
528
+ "ERC721: burn of token that is not own"
529
+ );
530
+
531
+ _clearApproval(tokenId);
532
+
533
+ _ownedTokensCount[owner].decrement();
534
+ _tokenOwner[tokenId] = address(0);
535
+
536
+ emit Transfer(owner, address(0), tokenId);
537
+ }
538
+
539
+ function _burn(uint256 tokenId) internal {
540
+ _burn(ownerOf(tokenId), tokenId);
541
+ }
542
+
543
+ function _transferFrom(address from, address to, uint256 tokenId) internal {
544
+ require(
545
+ ownerOf(tokenId) == from,
546
+ "ERC721: transfer of token that is not own"
547
+ );
548
+ require(to != address(0), "ERC721: transfer to the zero address");
549
+
550
+ _clearApproval(tokenId);
551
+
552
+ _ownedTokensCount[from].decrement();
553
+ _ownedTokensCount[to].increment();
554
+
555
+ _tokenOwner[tokenId] = to;
556
+
557
+ emit Transfer(from, to, tokenId);
558
+ }
559
+
560
+ function _checkOnERC721Received(
561
+ address from,
562
+ address to,
563
+ uint256 tokenId,
564
+ bytes memory _data
565
+ ) internal returns (bool) {
566
+ if (!to.isContract()) {
567
+ return true;
568
+ }
569
+
570
+ bytes4 retval = IERC721Receiver(to).onERC721Received(
571
+ msg.sender,
572
+ from,
573
+ tokenId,
574
+ _data
575
+ );
576
+ return (retval == _ERC721_RECEIVED);
577
+ }
578
+
579
+ function _clearApproval(uint256 tokenId) private {
580
+ if (_tokenApprovals[tokenId] != address(0)) {
581
+ _tokenApprovals[tokenId] = address(0);
582
+ }
583
+ }
584
+ }
585
+
586
+ // File contracts/libs/IERC721Enumerable.sol
587
+
588
+ // File: openzeppelin-solidity/contracts/token/ERC721/IERC721Enumerable.sol
589
+
590
+ pragma solidity ^0.5.0;
591
+
592
+ /**
593
+ * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
594
+ * @dev See https://eips.ethereum.org/EIPS/eip-721
595
+ */
596
+ contract IERC721Enumerable is IERC721 {
597
+ function totalSupply() public view returns (uint256);
598
+
599
+ function tokenOfOwnerByIndex(
600
+ address owner,
601
+ uint256 index
602
+ ) public view returns (uint256 tokenId);
603
+
604
+ function tokenByIndex(uint256 index) public view returns (uint256);
605
+ }
606
+
607
+ // File contracts/libs/ERC721Enumerable.sol
608
+
609
+ // File: openzeppelin-solidity/contracts/token/ERC721/ERC721Enumerable.sol
610
+
611
+ pragma solidity ^0.5.0;
612
+
613
+ /**
614
+ * @title ERC-721 Non-Fungible Token with optional enumeration extension logic
615
+ * @dev See https://eips.ethereum.org/EIPS/eip-721
616
+ */
617
+ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
618
+ // Mapping from owner to list of owned token IDs
619
+ mapping(address => uint256[]) private _ownedTokens;
620
+
621
+ // Mapping from token ID to index of the owner tokens list
622
+ mapping(uint256 => uint256) private _ownedTokensIndex;
623
+
624
+ // Array with all token ids, used for enumeration
625
+ uint256[] private _allTokens;
626
+
627
+ // Mapping from token id to position in the allTokens array
628
+ mapping(uint256 => uint256) private _allTokensIndex;
629
+
630
+ /*
631
+ * bytes4(keccak256('totalSupply()')) == 0x18160ddd
632
+ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
633
+ * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
634
+ *
635
+ * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
636
+ */
637
+ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
638
+
639
+ /**
640
+ * @dev Constructor function.
641
+ */
642
+ constructor() public {
643
+ // register the supported interface to conform to ERC721Enumerable via ERC165
644
+ _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
645
+ }
646
+
647
+ /**
648
+ * @dev Gets the token ID at a given index of the tokens list of the requested owner.
649
+ * @param owner address owning the tokens list to be accessed
650
+ * @param index uint256 representing the index to be accessed of the requested tokens list
651
+ * @return uint256 token ID at the given index of the tokens list owned by the requested address
652
+ */
653
+ function tokenOfOwnerByIndex(
654
+ address owner,
655
+ uint256 index
656
+ ) public view returns (uint256) {
657
+ require(
658
+ index < balanceOf(owner),
659
+ "ERC721Enumerable: owner index out of bounds"
660
+ );
661
+ return _ownedTokens[owner][index];
662
+ }
663
+
664
+ /**
665
+ * @dev Gets the total amount of tokens stored by the contract.
666
+ * @return uint256 representing the total amount of tokens
667
+ */
668
+ function totalSupply() public view returns (uint256) {
669
+ return _allTokens.length;
670
+ }
671
+
672
+ /**
673
+ * @dev Gets the token ID at a given index of all the tokens in this contract
674
+ * Reverts if the index is greater or equal to the total number of tokens.
675
+ * @param index uint256 representing the index to be accessed of the tokens list
676
+ * @return uint256 token ID at the given index of the tokens list
677
+ */
678
+ function tokenByIndex(uint256 index) public view returns (uint256) {
679
+ require(
680
+ index < totalSupply(),
681
+ "ERC721Enumerable: global index out of bounds"
682
+ );
683
+ return _allTokens[index];
684
+ }
685
+
686
+ /**
687
+ * @dev Internal function to transfer ownership of a given token ID to another address.
688
+ * As opposed to transferFrom, this imposes no restrictions on msg.sender.
689
+ * @param from current owner of the token
690
+ * @param to address to receive the ownership of the given token ID
691
+ * @param tokenId uint256 ID of the token to be transferred
692
+ */
693
+ function _transferFrom(address from, address to, uint256 tokenId) internal {
694
+ super._transferFrom(from, to, tokenId);
695
+
696
+ _removeTokenFromOwnerEnumeration(from, tokenId);
697
+
698
+ _addTokenToOwnerEnumeration(to, tokenId);
699
+ }
700
+
701
+ /**
702
+ * @dev Internal function to mint a new token.
703
+ * Reverts if the given token ID already exists.
704
+ * @param to address the beneficiary that will own the minted token
705
+ * @param tokenId uint256 ID of the token to be minted
706
+ */
707
+ function _mint(address to, uint256 tokenId) internal {
708
+ super._mint(to, tokenId);
709
+
710
+ _addTokenToOwnerEnumeration(to, tokenId);
711
+
712
+ _addTokenToAllTokensEnumeration(tokenId);
713
+ }
714
+
715
+ /**
716
+ * @dev Internal function to burn a specific token.
717
+ * Reverts if the token does not exist.
718
+ * Deprecated, use _burn(uint256) instead.
719
+ * @param owner owner of the token to burn
720
+ * @param tokenId uint256 ID of the token being burned
721
+ */
722
+ function _burn(address owner, uint256 tokenId) internal {
723
+ super._burn(owner, tokenId);
724
+
725
+ _removeTokenFromOwnerEnumeration(owner, tokenId);
726
+ // Since tokenId will be deleted, we can clear its slot in _ownedTokensIndex to trigger a gas refund
727
+ _ownedTokensIndex[tokenId] = 0;
728
+
729
+ _removeTokenFromAllTokensEnumeration(tokenId);
730
+ }
731
+
732
+ /**
733
+ * @dev Gets the list of token IDs of the requested owner.
734
+ * @param owner address owning the tokens
735
+ * @return uint256[] List of token IDs owned by the requested address
736
+ */
737
+ function _tokensOfOwner(
738
+ address owner
739
+ ) internal view returns (uint256[] storage) {
740
+ return _ownedTokens[owner];
741
+ }
742
+
743
+ /**
744
+ * @dev Private function to add a token to this extension's ownership-tracking data structures.
745
+ * @param to address representing the new owner of the given token ID
746
+ * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
747
+ */
748
+ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
749
+ _ownedTokensIndex[tokenId] = _ownedTokens[to].length;
750
+ _ownedTokens[to].push(tokenId);
751
+ }
752
+
753
+ /**
754
+ * @dev Private function to add a token to this extension's token tracking data structures.
755
+ * @param tokenId uint256 ID of the token to be added to the tokens list
756
+ */
757
+ function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
758
+ _allTokensIndex[tokenId] = _allTokens.length;
759
+ _allTokens.push(tokenId);
760
+ }
761
+
762
+ /**
763
+ * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
764
+ * while the token is not assigned a new owner, the _ownedTokensIndex mapping is _not_ updated: this allows for
765
+ * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
766
+ * This has O(1) time complexity, but alters the order of the _ownedTokens array.
767
+ * @param from address representing the previous owner of the given token ID
768
+ * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
769
+ */
770
+ function _removeTokenFromOwnerEnumeration(
771
+ address from,
772
+ uint256 tokenId
773
+ ) private {
774
+ // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
775
+ // then delete the last slot (swap and pop).
776
+
777
+ uint256 lastTokenIndex = _ownedTokens[from].length.sub(1);
778
+ uint256 tokenIndex = _ownedTokensIndex[tokenId];
779
+
780
+ // When the token to delete is the last token, the swap operation is unnecessary
781
+ if (tokenIndex != lastTokenIndex) {
782
+ uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
783
+
784
+ _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
785
+ _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
786
+ }
787
+
788
+ // This also deletes the contents at the last position of the array
789
+ _ownedTokens[from].length--;
790
+
791
+ // Note that _ownedTokensIndex[tokenId] hasn't been cleared: it still points to the old slot (now occupied by
792
+ // lastTokenId, or just over the end of the array if the token was the last one).
793
+ }
794
+
795
+ /**
796
+ * @dev Private function to remove a token from this extension's token tracking data structures.
797
+ * This has O(1) time complexity, but alters the order of the _allTokens array.
798
+ * @param tokenId uint256 ID of the token to be removed from the tokens list
799
+ */
800
+ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
801
+ // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
802
+ // then delete the last slot (swap and pop).
803
+
804
+ uint256 lastTokenIndex = _allTokens.length.sub(1);
805
+ uint256 tokenIndex = _allTokensIndex[tokenId];
806
+
807
+ // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
808
+ // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
809
+ // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
810
+ uint256 lastTokenId = _allTokens[lastTokenIndex];
811
+
812
+ _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
813
+ _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
814
+
815
+ // This also deletes the contents at the last position of the array
816
+ _allTokens.length--;
817
+ _allTokensIndex[tokenId] = 0;
818
+ }
819
+ }
820
+
821
+ // File contracts/libs/CustomERC721Metadata.sol
822
+
823
+ // File: contracts/CustomERC721Metadata.sol
824
+
825
+ pragma solidity ^0.5.0;
826
+
827
+ /**
828
+ * ERC721 base contract without the concept of tokenUri as this is managed by the parent
829
+ */
830
+ contract CustomERC721Metadata is ERC165, ERC721, ERC721Enumerable {
831
+ // Token name
832
+ string private _name;
833
+
834
+ // Token symbol
835
+ string private _symbol;
836
+
837
+ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
838
+
839
+ /**
840
+ * @dev Constructor function
841
+ */
842
+ constructor(string memory name, string memory symbol) public {
843
+ _name = name;
844
+ _symbol = symbol;
845
+
846
+ // register the supported interfaces to conform to ERC721 via ERC165
847
+ _registerInterface(_INTERFACE_ID_ERC721_METADATA);
848
+ }
849
+
850
+ /**
851
+ * @dev Gets the token name
852
+ * @return string representing the token name
853
+ */
854
+ function name() external view returns (string memory) {
855
+ return _name;
856
+ }
857
+
858
+ /**
859
+ * @dev Gets the token symbol
860
+ * @return string representing the token symbol
861
+ */
862
+ function symbol() external view returns (string memory) {
863
+ return _symbol;
864
+ }
865
+ }
866
+
867
+ // File contracts/libs/Strings.sol
868
+
869
+ // File: contracts/Strings.sol
870
+
871
+ pragma solidity ^0.5.0;
872
+
873
+ //https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol
874
+ library Strings {
875
+ function strConcat(
876
+ string memory _a,
877
+ string memory _b
878
+ ) internal pure returns (string memory _concatenatedString) {
879
+ return strConcat(_a, _b, "", "", "");
880
+ }
881
+
882
+ function strConcat(
883
+ string memory _a,
884
+ string memory _b,
885
+ string memory _c
886
+ ) internal pure returns (string memory _concatenatedString) {
887
+ return strConcat(_a, _b, _c, "", "");
888
+ }
889
+
890
+ function strConcat(
891
+ string memory _a,
892
+ string memory _b,
893
+ string memory _c,
894
+ string memory _d
895
+ ) internal pure returns (string memory _concatenatedString) {
896
+ return strConcat(_a, _b, _c, _d, "");
897
+ }
898
+
899
+ function strConcat(
900
+ string memory _a,
901
+ string memory _b,
902
+ string memory _c,
903
+ string memory _d,
904
+ string memory _e
905
+ ) internal pure returns (string memory _concatenatedString) {
906
+ bytes memory _ba = bytes(_a);
907
+ bytes memory _bb = bytes(_b);
908
+ bytes memory _bc = bytes(_c);
909
+ bytes memory _bd = bytes(_d);
910
+ bytes memory _be = bytes(_e);
911
+ string memory abcde = new string(
912
+ _ba.length + _bb.length + _bc.length + _bd.length + _be.length
913
+ );
914
+ bytes memory babcde = bytes(abcde);
915
+ uint256 k = 0;
916
+ uint256 i = 0;
917
+ for (i = 0; i < _ba.length; i++) {
918
+ babcde[k++] = _ba[i];
919
+ }
920
+ for (i = 0; i < _bb.length; i++) {
921
+ babcde[k++] = _bb[i];
922
+ }
923
+ for (i = 0; i < _bc.length; i++) {
924
+ babcde[k++] = _bc[i];
925
+ }
926
+ for (i = 0; i < _bd.length; i++) {
927
+ babcde[k++] = _bd[i];
928
+ }
929
+ for (i = 0; i < _be.length; i++) {
930
+ babcde[k++] = _be[i];
931
+ }
932
+ return string(babcde);
933
+ }
934
+
935
+ function uint2str(
936
+ uint256 _i
937
+ ) internal pure returns (string memory _uintAsString) {
938
+ if (_i == 0) {
939
+ return "0";
940
+ }
941
+ uint256 j = _i;
942
+ uint256 len;
943
+ while (j != 0) {
944
+ len++;
945
+ j /= 10;
946
+ }
947
+ bytes memory bstr = new bytes(len);
948
+ uint256 k = len - 1;
949
+ while (_i != 0) {
950
+ bstr[k--] = bytes1(uint8(48 + (_i % 10)));
951
+ _i /= 10;
952
+ }
953
+ return string(bstr);
954
+ }
955
+ }
956
+
957
+ // File contracts/GenArt721Core.sol
958
+
959
+ // File: contracts/GenArt721Core.sol
960
+
961
+ //0x1454EFCa69FA654e5A7d83CB61c1aD81790c44B7
962
+
963
+ //https://oneclickdapp.com/radar-valery/
964
+
965
+ pragma solidity ^0.5.0;
966
+
967
+ /// REPO-ONLY - use repo's IRandomizer to avoid namespace hell
968
+ // interface Randomizer {
969
+ // function returnValue() external view returns(bytes32);
970
+ // }
971
+
972
+ /// REPO-ONLY - add is IGenArt721CoreContractV1 to ensure repo has conforming
973
+ /// interface for V1 contract
974
+ contract GenArt721CoreV1 is CustomERC721Metadata, IGenArt721CoreContractV1 {
975
+ using SafeMath for uint256;
976
+
977
+ event Mint(
978
+ address indexed _to,
979
+ uint256 indexed _tokenId,
980
+ uint256 indexed _projectId
981
+ );
982
+
983
+ IRandomizer public randomizerContract;
984
+
985
+ struct Project {
986
+ string name;
987
+ string artist;
988
+ string description;
989
+ string website;
990
+ string license;
991
+ bool dynamic;
992
+ string projectBaseURI;
993
+ string projectBaseIpfsURI;
994
+ uint256 invocations;
995
+ uint256 maxInvocations;
996
+ string scriptJSON;
997
+ mapping(uint256 => string) scripts;
998
+ uint256 scriptCount;
999
+ string ipfsHash;
1000
+ bool useHashString;
1001
+ bool useIpfs;
1002
+ bool active;
1003
+ bool locked;
1004
+ bool paused;
1005
+ }
1006
+
1007
+ uint256 constant ONE_MILLION = 1_000_000;
1008
+ mapping(uint256 => Project) projects;
1009
+
1010
+ //All financial functions are stripped from struct for visibility
1011
+ mapping(uint256 => address) public projectIdToArtistAddress;
1012
+ mapping(uint256 => string) public projectIdToCurrencySymbol;
1013
+ mapping(uint256 => address) public projectIdToCurrencyAddress;
1014
+ mapping(uint256 => uint256) public projectIdToPricePerTokenInWei;
1015
+ mapping(uint256 => address) public projectIdToAdditionalPayee;
1016
+ mapping(uint256 => uint256) public projectIdToAdditionalPayeePercentage;
1017
+ mapping(uint256 => uint256)
1018
+ public projectIdToSecondaryMarketRoyaltyPercentage;
1019
+
1020
+ address public artblocksAddress;
1021
+ uint256 public artblocksPercentage = 10;
1022
+
1023
+ mapping(uint256 => string) public staticIpfsImageLink;
1024
+ mapping(uint256 => uint256) public tokenIdToProjectId;
1025
+ mapping(uint256 => uint256[]) internal projectIdToTokenIds;
1026
+ mapping(uint256 => bytes32) public tokenIdToHash;
1027
+ mapping(bytes32 => uint256) public hashToTokenId;
1028
+
1029
+ address public admin;
1030
+ mapping(address => bool) public isWhitelisted;
1031
+ mapping(address => bool) public isMintWhitelisted;
1032
+
1033
+ uint256 public nextProjectId = 3;
1034
+
1035
+ modifier onlyValidTokenId(uint256 _tokenId) {
1036
+ require(_exists(_tokenId), "Token ID does not exist");
1037
+ _;
1038
+ }
1039
+
1040
+ modifier onlyUnlocked(uint256 _projectId) {
1041
+ require(!projects[_projectId].locked, "Only if unlocked");
1042
+ _;
1043
+ }
1044
+
1045
+ modifier onlyArtist(uint256 _projectId) {
1046
+ require(
1047
+ msg.sender == projectIdToArtistAddress[_projectId],
1048
+ "Only artist"
1049
+ );
1050
+ _;
1051
+ }
1052
+
1053
+ modifier onlyAdmin() {
1054
+ require(msg.sender == admin, "Only admin");
1055
+ _;
1056
+ }
1057
+
1058
+ modifier onlyWhitelisted() {
1059
+ require(isWhitelisted[msg.sender], "Only whitelisted");
1060
+ _;
1061
+ }
1062
+
1063
+ modifier onlyArtistOrWhitelisted(uint256 _projectId) {
1064
+ require(
1065
+ isWhitelisted[msg.sender] ||
1066
+ msg.sender == projectIdToArtistAddress[_projectId],
1067
+ "Only artist or whitelisted"
1068
+ );
1069
+ _;
1070
+ }
1071
+
1072
+ constructor(
1073
+ string memory _tokenName,
1074
+ string memory _tokenSymbol,
1075
+ address _randomizerContract
1076
+ ) public CustomERC721Metadata(_tokenName, _tokenSymbol) {
1077
+ admin = msg.sender;
1078
+ isWhitelisted[msg.sender] = true;
1079
+ artblocksAddress = msg.sender;
1080
+ randomizerContract = IRandomizer(_randomizerContract);
1081
+ }
1082
+
1083
+ function mint(
1084
+ address _to,
1085
+ uint256 _projectId,
1086
+ address _by
1087
+ ) external returns (uint256 _tokenId) {
1088
+ require(
1089
+ isMintWhitelisted[msg.sender],
1090
+ "Must mint from whitelisted minter contract."
1091
+ );
1092
+ require(
1093
+ projects[_projectId].invocations.add(1) <=
1094
+ projects[_projectId].maxInvocations,
1095
+ "Must not exceed max invocations"
1096
+ );
1097
+ require(
1098
+ projects[_projectId].active ||
1099
+ _by == projectIdToArtistAddress[_projectId],
1100
+ "Project must exist and be active"
1101
+ );
1102
+ require(
1103
+ !projects[_projectId].paused ||
1104
+ _by == projectIdToArtistAddress[_projectId],
1105
+ "Purchases are paused."
1106
+ );
1107
+
1108
+ uint256 tokenId = _mintToken(_to, _projectId);
1109
+
1110
+ return tokenId;
1111
+ }
1112
+
1113
+ function _mintToken(
1114
+ address _to,
1115
+ uint256 _projectId
1116
+ ) internal returns (uint256 _tokenId) {
1117
+ uint256 tokenIdToBe = (_projectId * ONE_MILLION) +
1118
+ projects[_projectId].invocations;
1119
+
1120
+ projects[_projectId].invocations = projects[_projectId].invocations.add(
1121
+ 1
1122
+ );
1123
+
1124
+ bytes32 hash = keccak256(
1125
+ abi.encodePacked(
1126
+ projects[_projectId].invocations,
1127
+ block.number,
1128
+ blockhash(block.number - 1),
1129
+ msg.sender,
1130
+ randomizerContract.returnValue()
1131
+ )
1132
+ );
1133
+ tokenIdToHash[tokenIdToBe] = hash;
1134
+ hashToTokenId[hash] = tokenIdToBe;
1135
+
1136
+ _mint(_to, tokenIdToBe);
1137
+
1138
+ tokenIdToProjectId[tokenIdToBe] = _projectId;
1139
+ projectIdToTokenIds[_projectId].push(tokenIdToBe);
1140
+
1141
+ emit Mint(_to, tokenIdToBe, _projectId);
1142
+
1143
+ return tokenIdToBe;
1144
+ }
1145
+
1146
+ function updateArtblocksAddress(
1147
+ address _artblocksAddress
1148
+ ) public onlyAdmin {
1149
+ artblocksAddress = _artblocksAddress;
1150
+ }
1151
+
1152
+ function updateArtblocksPercentage(
1153
+ uint256 _artblocksPercentage
1154
+ ) public onlyAdmin {
1155
+ require(_artblocksPercentage <= 25, "Max of 25%");
1156
+ artblocksPercentage = _artblocksPercentage;
1157
+ }
1158
+
1159
+ function addWhitelisted(address _address) public onlyAdmin {
1160
+ isWhitelisted[_address] = true;
1161
+ }
1162
+
1163
+ function removeWhitelisted(address _address) public onlyAdmin {
1164
+ isWhitelisted[_address] = false;
1165
+ }
1166
+
1167
+ function addMintWhitelisted(address _address) public onlyAdmin {
1168
+ isMintWhitelisted[_address] = true;
1169
+ }
1170
+
1171
+ function removeMintWhitelisted(address _address) public onlyAdmin {
1172
+ isMintWhitelisted[_address] = false;
1173
+ }
1174
+
1175
+ function updateRandomizerAddress(
1176
+ address _randomizerAddress
1177
+ ) public onlyWhitelisted {
1178
+ randomizerContract = IRandomizer(_randomizerAddress);
1179
+ }
1180
+
1181
+ function toggleProjectIsLocked(
1182
+ uint256 _projectId
1183
+ ) public onlyWhitelisted onlyUnlocked(_projectId) {
1184
+ projects[_projectId].locked = true;
1185
+ }
1186
+
1187
+ function toggleProjectIsActive(uint256 _projectId) public onlyWhitelisted {
1188
+ projects[_projectId].active = !projects[_projectId].active;
1189
+ }
1190
+
1191
+ function updateProjectArtistAddress(
1192
+ uint256 _projectId,
1193
+ address _artistAddress
1194
+ ) public onlyArtistOrWhitelisted(_projectId) {
1195
+ projectIdToArtistAddress[_projectId] = _artistAddress;
1196
+ }
1197
+
1198
+ function toggleProjectIsPaused(
1199
+ uint256 _projectId
1200
+ ) public onlyArtist(_projectId) {
1201
+ projects[_projectId].paused = !projects[_projectId].paused;
1202
+ }
1203
+
1204
+ function addProject(
1205
+ string memory _projectName,
1206
+ address _artistAddress,
1207
+ uint256 _pricePerTokenInWei,
1208
+ bool _dynamic
1209
+ ) public onlyWhitelisted {
1210
+ uint256 projectId = nextProjectId;
1211
+ projectIdToArtistAddress[projectId] = _artistAddress;
1212
+ projects[projectId].name = _projectName;
1213
+ projectIdToCurrencySymbol[projectId] = "ETH";
1214
+ projectIdToPricePerTokenInWei[projectId] = _pricePerTokenInWei;
1215
+ projects[projectId].paused = true;
1216
+ projects[projectId].dynamic = _dynamic;
1217
+ projects[projectId].maxInvocations = ONE_MILLION;
1218
+ if (!_dynamic) {
1219
+ projects[projectId].useHashString = false;
1220
+ } else {
1221
+ projects[projectId].useHashString = true;
1222
+ }
1223
+ nextProjectId = nextProjectId.add(1);
1224
+ }
1225
+
1226
+ function updateProjectCurrencyInfo(
1227
+ uint256 _projectId,
1228
+ string memory _currencySymbol,
1229
+ address _currencyAddress
1230
+ ) public onlyArtist(_projectId) {
1231
+ projectIdToCurrencySymbol[_projectId] = _currencySymbol;
1232
+ projectIdToCurrencyAddress[_projectId] = _currencyAddress;
1233
+ }
1234
+
1235
+ function updateProjectPricePerTokenInWei(
1236
+ uint256 _projectId,
1237
+ uint256 _pricePerTokenInWei
1238
+ ) public onlyArtist(_projectId) {
1239
+ projectIdToPricePerTokenInWei[_projectId] = _pricePerTokenInWei;
1240
+ }
1241
+
1242
+ function updateProjectName(
1243
+ uint256 _projectId,
1244
+ string memory _projectName
1245
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1246
+ projects[_projectId].name = _projectName;
1247
+ }
1248
+
1249
+ function updateProjectArtistName(
1250
+ uint256 _projectId,
1251
+ string memory _projectArtistName
1252
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1253
+ projects[_projectId].artist = _projectArtistName;
1254
+ }
1255
+
1256
+ function updateProjectAdditionalPayeeInfo(
1257
+ uint256 _projectId,
1258
+ address _additionalPayee,
1259
+ uint256 _additionalPayeePercentage
1260
+ ) public onlyArtist(_projectId) {
1261
+ require(_additionalPayeePercentage <= 100, "Max of 100%");
1262
+ projectIdToAdditionalPayee[_projectId] = _additionalPayee;
1263
+ projectIdToAdditionalPayeePercentage[
1264
+ _projectId
1265
+ ] = _additionalPayeePercentage;
1266
+ }
1267
+
1268
+ function updateProjectSecondaryMarketRoyaltyPercentage(
1269
+ uint256 _projectId,
1270
+ uint256 _secondMarketRoyalty
1271
+ ) public onlyArtist(_projectId) {
1272
+ require(_secondMarketRoyalty <= 100, "Max of 100%");
1273
+ projectIdToSecondaryMarketRoyaltyPercentage[
1274
+ _projectId
1275
+ ] = _secondMarketRoyalty;
1276
+ }
1277
+
1278
+ function updateProjectDescription(
1279
+ uint256 _projectId,
1280
+ string memory _projectDescription
1281
+ ) public onlyArtist(_projectId) {
1282
+ projects[_projectId].description = _projectDescription;
1283
+ }
1284
+
1285
+ function updateProjectWebsite(
1286
+ uint256 _projectId,
1287
+ string memory _projectWebsite
1288
+ ) public onlyArtist(_projectId) {
1289
+ projects[_projectId].website = _projectWebsite;
1290
+ }
1291
+
1292
+ function updateProjectLicense(
1293
+ uint256 _projectId,
1294
+ string memory _projectLicense
1295
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1296
+ projects[_projectId].license = _projectLicense;
1297
+ }
1298
+
1299
+ function updateProjectMaxInvocations(
1300
+ uint256 _projectId,
1301
+ uint256 _maxInvocations
1302
+ ) public onlyArtist(_projectId) {
1303
+ require(
1304
+ (!projects[_projectId].locked ||
1305
+ _maxInvocations < projects[_projectId].maxInvocations),
1306
+ "Only if unlocked"
1307
+ );
1308
+ require(
1309
+ _maxInvocations > projects[_projectId].invocations,
1310
+ "You must set max invocations greater than current invocations"
1311
+ );
1312
+ require(_maxInvocations <= ONE_MILLION, "Cannot exceed 1,000,000");
1313
+ projects[_projectId].maxInvocations = _maxInvocations;
1314
+ }
1315
+
1316
+ function toggleProjectUseHashString(
1317
+ uint256 _projectId
1318
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1319
+ require(
1320
+ projects[_projectId].invocations == 0,
1321
+ "Cannot modify after a token is minted."
1322
+ );
1323
+ projects[_projectId].useHashString = !projects[_projectId]
1324
+ .useHashString;
1325
+ }
1326
+
1327
+ function addProjectScript(
1328
+ uint256 _projectId,
1329
+ string memory _script
1330
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1331
+ projects[_projectId].scripts[
1332
+ projects[_projectId].scriptCount
1333
+ ] = _script;
1334
+ projects[_projectId].scriptCount = projects[_projectId].scriptCount.add(
1335
+ 1
1336
+ );
1337
+ }
1338
+
1339
+ function updateProjectScript(
1340
+ uint256 _projectId,
1341
+ uint256 _scriptId,
1342
+ string memory _script
1343
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1344
+ require(
1345
+ _scriptId < projects[_projectId].scriptCount,
1346
+ "scriptId out of range"
1347
+ );
1348
+ projects[_projectId].scripts[_scriptId] = _script;
1349
+ }
1350
+
1351
+ function removeProjectLastScript(
1352
+ uint256 _projectId
1353
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1354
+ require(
1355
+ projects[_projectId].scriptCount > 0,
1356
+ "there are no scripts to remove"
1357
+ );
1358
+ delete projects[_projectId].scripts[
1359
+ projects[_projectId].scriptCount - 1
1360
+ ];
1361
+ projects[_projectId].scriptCount = projects[_projectId].scriptCount.sub(
1362
+ 1
1363
+ );
1364
+ }
1365
+
1366
+ function updateProjectScriptJSON(
1367
+ uint256 _projectId,
1368
+ string memory _projectScriptJSON
1369
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1370
+ projects[_projectId].scriptJSON = _projectScriptJSON;
1371
+ }
1372
+
1373
+ function updateProjectIpfsHash(
1374
+ uint256 _projectId,
1375
+ string memory _ipfsHash
1376
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1377
+ projects[_projectId].ipfsHash = _ipfsHash;
1378
+ }
1379
+
1380
+ function updateProjectBaseURI(
1381
+ uint256 _projectId,
1382
+ string memory _newBaseURI
1383
+ ) public onlyArtist(_projectId) {
1384
+ projects[_projectId].projectBaseURI = _newBaseURI;
1385
+ }
1386
+
1387
+ function updateProjectBaseIpfsURI(
1388
+ uint256 _projectId,
1389
+ string memory _projectBaseIpfsURI
1390
+ ) public onlyArtist(_projectId) {
1391
+ projects[_projectId].projectBaseIpfsURI = _projectBaseIpfsURI;
1392
+ }
1393
+
1394
+ function toggleProjectUseIpfsForStatic(
1395
+ uint256 _projectId
1396
+ ) public onlyArtist(_projectId) {
1397
+ require(
1398
+ !projects[_projectId].dynamic,
1399
+ "can only set static IPFS hash for static projects"
1400
+ );
1401
+ projects[_projectId].useIpfs = !projects[_projectId].useIpfs;
1402
+ }
1403
+
1404
+ function toggleProjectIsDynamic(
1405
+ uint256 _projectId
1406
+ ) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
1407
+ require(
1408
+ projects[_projectId].invocations == 0,
1409
+ "Can not switch after a token is minted."
1410
+ );
1411
+ if (projects[_projectId].dynamic) {
1412
+ projects[_projectId].useHashString = false;
1413
+ } else {
1414
+ projects[_projectId].useHashString = true;
1415
+ }
1416
+ projects[_projectId].dynamic = !projects[_projectId].dynamic;
1417
+ }
1418
+
1419
+ function overrideTokenDynamicImageWithIpfsLink(
1420
+ uint256 _tokenId,
1421
+ string memory _ipfsHash
1422
+ ) public onlyArtist(tokenIdToProjectId[_tokenId]) {
1423
+ staticIpfsImageLink[_tokenId] = _ipfsHash;
1424
+ }
1425
+
1426
+ function clearTokenIpfsImageUri(
1427
+ uint256 _tokenId
1428
+ ) public onlyArtist(tokenIdToProjectId[_tokenId]) {
1429
+ delete staticIpfsImageLink[tokenIdToProjectId[_tokenId]];
1430
+ }
1431
+
1432
+ function projectDetails(
1433
+ uint256 _projectId
1434
+ )
1435
+ public
1436
+ view
1437
+ returns (
1438
+ string memory projectName,
1439
+ string memory artist,
1440
+ string memory description,
1441
+ string memory website,
1442
+ string memory license,
1443
+ bool dynamic
1444
+ )
1445
+ {
1446
+ projectName = projects[_projectId].name;
1447
+ artist = projects[_projectId].artist;
1448
+ description = projects[_projectId].description;
1449
+ website = projects[_projectId].website;
1450
+ license = projects[_projectId].license;
1451
+ dynamic = projects[_projectId].dynamic;
1452
+ }
1453
+
1454
+ function projectTokenInfo(
1455
+ uint256 _projectId
1456
+ )
1457
+ public
1458
+ view
1459
+ returns (
1460
+ address artistAddress,
1461
+ uint256 pricePerTokenInWei,
1462
+ uint256 invocations,
1463
+ uint256 maxInvocations,
1464
+ bool active,
1465
+ address additionalPayee,
1466
+ uint256 additionalPayeePercentage,
1467
+ string memory currency,
1468
+ address currencyAddress
1469
+ )
1470
+ {
1471
+ artistAddress = projectIdToArtistAddress[_projectId];
1472
+ pricePerTokenInWei = projectIdToPricePerTokenInWei[_projectId];
1473
+ invocations = projects[_projectId].invocations;
1474
+ maxInvocations = projects[_projectId].maxInvocations;
1475
+ active = projects[_projectId].active;
1476
+ additionalPayee = projectIdToAdditionalPayee[_projectId];
1477
+ additionalPayeePercentage = projectIdToAdditionalPayeePercentage[
1478
+ _projectId
1479
+ ];
1480
+ currency = projectIdToCurrencySymbol[_projectId];
1481
+ currencyAddress = projectIdToCurrencyAddress[_projectId];
1482
+ }
1483
+
1484
+ function projectScriptInfo(
1485
+ uint256 _projectId
1486
+ )
1487
+ public
1488
+ view
1489
+ returns (
1490
+ string memory scriptJSON,
1491
+ uint256 scriptCount,
1492
+ bool useHashString,
1493
+ string memory ipfsHash,
1494
+ bool locked,
1495
+ bool paused
1496
+ )
1497
+ {
1498
+ scriptJSON = projects[_projectId].scriptJSON;
1499
+ scriptCount = projects[_projectId].scriptCount;
1500
+ useHashString = projects[_projectId].useHashString;
1501
+ ipfsHash = projects[_projectId].ipfsHash;
1502
+ locked = projects[_projectId].locked;
1503
+ paused = projects[_projectId].paused;
1504
+ }
1505
+
1506
+ function projectScriptByIndex(
1507
+ uint256 _projectId,
1508
+ uint256 _index
1509
+ ) public view returns (string memory) {
1510
+ return projects[_projectId].scripts[_index];
1511
+ }
1512
+
1513
+ function projectURIInfo(
1514
+ uint256 _projectId
1515
+ )
1516
+ public
1517
+ view
1518
+ returns (
1519
+ string memory projectBaseURI,
1520
+ string memory projectBaseIpfsURI,
1521
+ bool useIpfs
1522
+ )
1523
+ {
1524
+ projectBaseURI = projects[_projectId].projectBaseURI;
1525
+ projectBaseIpfsURI = projects[_projectId].projectBaseIpfsURI;
1526
+ useIpfs = projects[_projectId].useIpfs;
1527
+ }
1528
+
1529
+ function projectShowAllTokens(
1530
+ uint256 _projectId
1531
+ ) public view returns (uint256[] memory) {
1532
+ return projectIdToTokenIds[_projectId];
1533
+ }
1534
+
1535
+ function tokensOfOwner(
1536
+ address owner
1537
+ ) external view returns (uint256[] memory) {
1538
+ return _tokensOfOwner(owner);
1539
+ }
1540
+
1541
+ function getRoyaltyData(
1542
+ uint256 _tokenId
1543
+ )
1544
+ public
1545
+ view
1546
+ returns (
1547
+ address artistAddress,
1548
+ address additionalPayee,
1549
+ uint256 additionalPayeePercentage,
1550
+ uint256 royaltyFeeByID
1551
+ )
1552
+ {
1553
+ artistAddress = projectIdToArtistAddress[tokenIdToProjectId[_tokenId]];
1554
+ additionalPayee = projectIdToAdditionalPayee[
1555
+ tokenIdToProjectId[_tokenId]
1556
+ ];
1557
+ additionalPayeePercentage = projectIdToAdditionalPayeePercentage[
1558
+ tokenIdToProjectId[_tokenId]
1559
+ ];
1560
+ royaltyFeeByID = projectIdToSecondaryMarketRoyaltyPercentage[
1561
+ tokenIdToProjectId[_tokenId]
1562
+ ];
1563
+ }
1564
+
1565
+ function tokenURI(
1566
+ uint256 _tokenId
1567
+ ) external view onlyValidTokenId(_tokenId) returns (string memory) {
1568
+ if (bytes(staticIpfsImageLink[_tokenId]).length > 0) {
1569
+ return
1570
+ Strings.strConcat(
1571
+ projects[tokenIdToProjectId[_tokenId]].projectBaseIpfsURI,
1572
+ staticIpfsImageLink[_tokenId]
1573
+ );
1574
+ }
1575
+
1576
+ if (
1577
+ !projects[tokenIdToProjectId[_tokenId]].dynamic &&
1578
+ projects[tokenIdToProjectId[_tokenId]].useIpfs
1579
+ ) {
1580
+ return
1581
+ Strings.strConcat(
1582
+ projects[tokenIdToProjectId[_tokenId]].projectBaseIpfsURI,
1583
+ projects[tokenIdToProjectId[_tokenId]].ipfsHash
1584
+ );
1585
+ }
1586
+
1587
+ return
1588
+ Strings.strConcat(
1589
+ projects[tokenIdToProjectId[_tokenId]].projectBaseURI,
1590
+ Strings.uint2str(_tokenId)
1591
+ );
1592
+ }
1593
+ }