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