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