OniReimu commited on
Commit
57eca40
·
verified ·
1 Parent(s): 7fc80d0

NFTBench 0.9.0 preview (part 8)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol +466 -0
  2. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol +132 -0
  3. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol +27 -0
  4. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol +27 -0
  5. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/Address.sol +244 -0
  6. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/Context.sol +24 -0
  7. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/Strings.sol +85 -0
  8. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol +29 -0
  9. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol +25 -0
  10. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/math/Math.sol +339 -0
  11. third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol +43 -0
  12. third_party/real_code/rc16/sources/src/MichiWalletNFT.sol +61 -0
  13. third_party/real_code/rc17/NOTICE +71 -0
  14. third_party/real_code/rc17/abi.json +666 -0
  15. third_party/real_code/rc17/creation.hex +1 -0
  16. third_party/real_code/rc17/provenance.json +10 -0
  17. third_party/real_code/rc17/recipe.yaml +11 -0
  18. third_party/real_code/rc17/sources/@openzeppelin/contracts/access/Ownable.sol +100 -0
  19. third_party/real_code/rc17/sources/@openzeppelin/contracts/interfaces/IERC165.sol +6 -0
  20. third_party/real_code/rc17/sources/@openzeppelin/contracts/interfaces/IERC4906.sol +20 -0
  21. third_party/real_code/rc17/sources/@openzeppelin/contracts/interfaces/IERC721.sol +6 -0
  22. third_party/real_code/rc17/sources/@openzeppelin/contracts/interfaces/draft-IERC6093.sol +161 -0
  23. third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/ERC721.sol +456 -0
  24. third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/IERC721.sol +135 -0
  25. third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol +28 -0
  26. third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol +174 -0
  27. third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol +61 -0
  28. third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol +29 -0
  29. third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol +27 -0
  30. third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol +50 -0
  31. third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/Context.sol +28 -0
  32. third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/Panic.sol +57 -0
  33. third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/Strings.sol +490 -0
  34. third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/introspection/ERC165.sol +27 -0
  35. third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/introspection/IERC165.sol +25 -0
  36. third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/math/Math.sol +749 -0
  37. third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/math/SafeCast.sol +1162 -0
  38. third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/math/SignedMath.sol +68 -0
  39. third_party/real_code/rc17/sources/contracts/SharpNFT.sol +41 -0
  40. third_party/real_code/rc18/NOTICE +44 -0
  41. third_party/real_code/rc18/abi.json +834 -0
  42. third_party/real_code/rc18/creation.hex +1 -0
  43. third_party/real_code/rc18/provenance.json +10 -0
  44. third_party/real_code/rc18/recipe.yaml +16 -0
  45. third_party/real_code/rc18/sources/@openzeppelin/contracts/access/Ownable.sol +76 -0
  46. third_party/real_code/rc18/sources/@openzeppelin/contracts/security/ReentrancyGuard.sol +63 -0
  47. third_party/real_code/rc18/sources/@openzeppelin/contracts/token/ERC721/IERC721.sol +143 -0
  48. third_party/real_code/rc18/sources/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol +27 -0
  49. third_party/real_code/rc18/sources/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol +27 -0
  50. third_party/real_code/rc18/sources/@openzeppelin/contracts/utils/Address.sol +222 -0
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import "./IERC721.sol";
7
+ import "./IERC721Receiver.sol";
8
+ import "./extensions/IERC721Metadata.sol";
9
+ import "../../utils/Address.sol";
10
+ import "../../utils/Context.sol";
11
+ import "../../utils/Strings.sol";
12
+ import "../../utils/introspection/ERC165.sol";
13
+
14
+ /**
15
+ * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
16
+ * the Metadata extension, but not including the Enumerable extension, which is available separately as
17
+ * {ERC721Enumerable}.
18
+ */
19
+ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
20
+ using Address for address;
21
+ using Strings for uint256;
22
+
23
+ // Token name
24
+ string private _name;
25
+
26
+ // Token symbol
27
+ string private _symbol;
28
+
29
+ // Mapping from token ID to owner address
30
+ mapping(uint256 => address) private _owners;
31
+
32
+ // Mapping owner address to token count
33
+ mapping(address => uint256) private _balances;
34
+
35
+ // Mapping from token ID to approved address
36
+ mapping(uint256 => address) private _tokenApprovals;
37
+
38
+ // Mapping from owner to operator approvals
39
+ mapping(address => mapping(address => bool)) private _operatorApprovals;
40
+
41
+ /**
42
+ * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
43
+ */
44
+ constructor(string memory name_, string memory symbol_) {
45
+ _name = name_;
46
+ _symbol = symbol_;
47
+ }
48
+
49
+ /**
50
+ * @dev See {IERC165-supportsInterface}.
51
+ */
52
+ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
53
+ return
54
+ interfaceId == type(IERC721).interfaceId ||
55
+ interfaceId == type(IERC721Metadata).interfaceId ||
56
+ super.supportsInterface(interfaceId);
57
+ }
58
+
59
+ /**
60
+ * @dev See {IERC721-balanceOf}.
61
+ */
62
+ function balanceOf(address owner) public view virtual override returns (uint256) {
63
+ require(owner != address(0), "ERC721: address zero is not a valid owner");
64
+ return _balances[owner];
65
+ }
66
+
67
+ /**
68
+ * @dev See {IERC721-ownerOf}.
69
+ */
70
+ function ownerOf(uint256 tokenId) public view virtual override returns (address) {
71
+ address owner = _ownerOf(tokenId);
72
+ require(owner != address(0), "ERC721: invalid token ID");
73
+ return owner;
74
+ }
75
+
76
+ /**
77
+ * @dev See {IERC721Metadata-name}.
78
+ */
79
+ function name() public view virtual override returns (string memory) {
80
+ return _name;
81
+ }
82
+
83
+ /**
84
+ * @dev See {IERC721Metadata-symbol}.
85
+ */
86
+ function symbol() public view virtual override returns (string memory) {
87
+ return _symbol;
88
+ }
89
+
90
+ /**
91
+ * @dev See {IERC721Metadata-tokenURI}.
92
+ */
93
+ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
94
+ _requireMinted(tokenId);
95
+
96
+ string memory baseURI = _baseURI();
97
+ return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
98
+ }
99
+
100
+ /**
101
+ * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
102
+ * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
103
+ * by default, can be overridden in child contracts.
104
+ */
105
+ function _baseURI() internal view virtual returns (string memory) {
106
+ return "";
107
+ }
108
+
109
+ /**
110
+ * @dev See {IERC721-approve}.
111
+ */
112
+ function approve(address to, uint256 tokenId) public virtual override {
113
+ address owner = ERC721.ownerOf(tokenId);
114
+ require(to != owner, "ERC721: approval to current owner");
115
+
116
+ require(
117
+ _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
118
+ "ERC721: approve caller is not token owner or approved for all"
119
+ );
120
+
121
+ _approve(to, tokenId);
122
+ }
123
+
124
+ /**
125
+ * @dev See {IERC721-getApproved}.
126
+ */
127
+ function getApproved(uint256 tokenId) public view virtual override returns (address) {
128
+ _requireMinted(tokenId);
129
+
130
+ return _tokenApprovals[tokenId];
131
+ }
132
+
133
+ /**
134
+ * @dev See {IERC721-setApprovalForAll}.
135
+ */
136
+ function setApprovalForAll(address operator, bool approved) public virtual override {
137
+ _setApprovalForAll(_msgSender(), operator, approved);
138
+ }
139
+
140
+ /**
141
+ * @dev See {IERC721-isApprovedForAll}.
142
+ */
143
+ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
144
+ return _operatorApprovals[owner][operator];
145
+ }
146
+
147
+ /**
148
+ * @dev See {IERC721-transferFrom}.
149
+ */
150
+ function transferFrom(address from, address to, uint256 tokenId) public virtual override {
151
+ //solhint-disable-next-line max-line-length
152
+ require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
153
+
154
+ _transfer(from, to, tokenId);
155
+ }
156
+
157
+ /**
158
+ * @dev See {IERC721-safeTransferFrom}.
159
+ */
160
+ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
161
+ safeTransferFrom(from, to, tokenId, "");
162
+ }
163
+
164
+ /**
165
+ * @dev See {IERC721-safeTransferFrom}.
166
+ */
167
+ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {
168
+ require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
169
+ _safeTransfer(from, to, tokenId, data);
170
+ }
171
+
172
+ /**
173
+ * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
174
+ * are aware of the ERC721 protocol to prevent tokens from being forever locked.
175
+ *
176
+ * `data` is additional data, it has no specified format and it is sent in call to `to`.
177
+ *
178
+ * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
179
+ * implement alternative mechanisms to perform token transfer, such as signature-based.
180
+ *
181
+ * Requirements:
182
+ *
183
+ * - `from` cannot be the zero address.
184
+ * - `to` cannot be the zero address.
185
+ * - `tokenId` token must exist and be owned by `from`.
186
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
187
+ *
188
+ * Emits a {Transfer} event.
189
+ */
190
+ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
191
+ _transfer(from, to, tokenId);
192
+ require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
193
+ }
194
+
195
+ /**
196
+ * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
197
+ */
198
+ function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
199
+ return _owners[tokenId];
200
+ }
201
+
202
+ /**
203
+ * @dev Returns whether `tokenId` exists.
204
+ *
205
+ * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
206
+ *
207
+ * Tokens start existing when they are minted (`_mint`),
208
+ * and stop existing when they are burned (`_burn`).
209
+ */
210
+ function _exists(uint256 tokenId) internal view virtual returns (bool) {
211
+ return _ownerOf(tokenId) != address(0);
212
+ }
213
+
214
+ /**
215
+ * @dev Returns whether `spender` is allowed to manage `tokenId`.
216
+ *
217
+ * Requirements:
218
+ *
219
+ * - `tokenId` must exist.
220
+ */
221
+ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
222
+ address owner = ERC721.ownerOf(tokenId);
223
+ return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
224
+ }
225
+
226
+ /**
227
+ * @dev Safely mints `tokenId` and transfers it to `to`.
228
+ *
229
+ * Requirements:
230
+ *
231
+ * - `tokenId` must not exist.
232
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
233
+ *
234
+ * Emits a {Transfer} event.
235
+ */
236
+ function _safeMint(address to, uint256 tokenId) internal virtual {
237
+ _safeMint(to, tokenId, "");
238
+ }
239
+
240
+ /**
241
+ * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
242
+ * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
243
+ */
244
+ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
245
+ _mint(to, tokenId);
246
+ require(
247
+ _checkOnERC721Received(address(0), to, tokenId, data),
248
+ "ERC721: transfer to non ERC721Receiver implementer"
249
+ );
250
+ }
251
+
252
+ /**
253
+ * @dev Mints `tokenId` and transfers it to `to`.
254
+ *
255
+ * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
256
+ *
257
+ * Requirements:
258
+ *
259
+ * - `tokenId` must not exist.
260
+ * - `to` cannot be the zero address.
261
+ *
262
+ * Emits a {Transfer} event.
263
+ */
264
+ function _mint(address to, uint256 tokenId) internal virtual {
265
+ require(to != address(0), "ERC721: mint to the zero address");
266
+ require(!_exists(tokenId), "ERC721: token already minted");
267
+
268
+ _beforeTokenTransfer(address(0), to, tokenId, 1);
269
+
270
+ // Check that tokenId was not minted by `_beforeTokenTransfer` hook
271
+ require(!_exists(tokenId), "ERC721: token already minted");
272
+
273
+ unchecked {
274
+ // Will not overflow unless all 2**256 token ids are minted to the same owner.
275
+ // Given that tokens are minted one by one, it is impossible in practice that
276
+ // this ever happens. Might change if we allow batch minting.
277
+ // The ERC fails to describe this case.
278
+ _balances[to] += 1;
279
+ }
280
+
281
+ _owners[tokenId] = to;
282
+
283
+ emit Transfer(address(0), to, tokenId);
284
+
285
+ _afterTokenTransfer(address(0), to, tokenId, 1);
286
+ }
287
+
288
+ /**
289
+ * @dev Destroys `tokenId`.
290
+ * The approval is cleared when the token is burned.
291
+ * This is an internal function that does not check if the sender is authorized to operate on the token.
292
+ *
293
+ * Requirements:
294
+ *
295
+ * - `tokenId` must exist.
296
+ *
297
+ * Emits a {Transfer} event.
298
+ */
299
+ function _burn(uint256 tokenId) internal virtual {
300
+ address owner = ERC721.ownerOf(tokenId);
301
+
302
+ _beforeTokenTransfer(owner, address(0), tokenId, 1);
303
+
304
+ // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
305
+ owner = ERC721.ownerOf(tokenId);
306
+
307
+ // Clear approvals
308
+ delete _tokenApprovals[tokenId];
309
+
310
+ unchecked {
311
+ // Cannot overflow, as that would require more tokens to be burned/transferred
312
+ // out than the owner initially received through minting and transferring in.
313
+ _balances[owner] -= 1;
314
+ }
315
+ delete _owners[tokenId];
316
+
317
+ emit Transfer(owner, address(0), tokenId);
318
+
319
+ _afterTokenTransfer(owner, address(0), tokenId, 1);
320
+ }
321
+
322
+ /**
323
+ * @dev Transfers `tokenId` from `from` to `to`.
324
+ * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
325
+ *
326
+ * Requirements:
327
+ *
328
+ * - `to` cannot be the zero address.
329
+ * - `tokenId` token must be owned by `from`.
330
+ *
331
+ * Emits a {Transfer} event.
332
+ */
333
+ function _transfer(address from, address to, uint256 tokenId) internal virtual {
334
+ require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
335
+ require(to != address(0), "ERC721: transfer to the zero address");
336
+
337
+ _beforeTokenTransfer(from, to, tokenId, 1);
338
+
339
+ // Check that tokenId was not transferred by `_beforeTokenTransfer` hook
340
+ require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
341
+
342
+ // Clear approvals from the previous owner
343
+ delete _tokenApprovals[tokenId];
344
+
345
+ unchecked {
346
+ // `_balances[from]` cannot overflow for the same reason as described in `_burn`:
347
+ // `from`'s balance is the number of token held, which is at least one before the current
348
+ // transfer.
349
+ // `_balances[to]` could overflow in the conditions described in `_mint`. That would require
350
+ // all 2**256 token ids to be minted, which in practice is impossible.
351
+ _balances[from] -= 1;
352
+ _balances[to] += 1;
353
+ }
354
+ _owners[tokenId] = to;
355
+
356
+ emit Transfer(from, to, tokenId);
357
+
358
+ _afterTokenTransfer(from, to, tokenId, 1);
359
+ }
360
+
361
+ /**
362
+ * @dev Approve `to` to operate on `tokenId`
363
+ *
364
+ * Emits an {Approval} event.
365
+ */
366
+ function _approve(address to, uint256 tokenId) internal virtual {
367
+ _tokenApprovals[tokenId] = to;
368
+ emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
369
+ }
370
+
371
+ /**
372
+ * @dev Approve `operator` to operate on all of `owner` tokens
373
+ *
374
+ * Emits an {ApprovalForAll} event.
375
+ */
376
+ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
377
+ require(owner != operator, "ERC721: approve to caller");
378
+ _operatorApprovals[owner][operator] = approved;
379
+ emit ApprovalForAll(owner, operator, approved);
380
+ }
381
+
382
+ /**
383
+ * @dev Reverts if the `tokenId` has not been minted yet.
384
+ */
385
+ function _requireMinted(uint256 tokenId) internal view virtual {
386
+ require(_exists(tokenId), "ERC721: invalid token ID");
387
+ }
388
+
389
+ /**
390
+ * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
391
+ * The call is not executed if the target address is not a contract.
392
+ *
393
+ * @param from address representing the previous owner of the given token ID
394
+ * @param to target address that will receive the tokens
395
+ * @param tokenId uint256 ID of the token to be transferred
396
+ * @param data bytes optional data to send along with the call
397
+ * @return bool whether the call correctly returned the expected magic value
398
+ */
399
+ function _checkOnERC721Received(
400
+ address from,
401
+ address to,
402
+ uint256 tokenId,
403
+ bytes memory data
404
+ ) private returns (bool) {
405
+ if (to.isContract()) {
406
+ try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
407
+ return retval == IERC721Receiver.onERC721Received.selector;
408
+ } catch (bytes memory reason) {
409
+ if (reason.length == 0) {
410
+ revert("ERC721: transfer to non ERC721Receiver implementer");
411
+ } else {
412
+ /// @solidity memory-safe-assembly
413
+ assembly {
414
+ revert(add(32, reason), mload(reason))
415
+ }
416
+ }
417
+ }
418
+ } else {
419
+ return true;
420
+ }
421
+ }
422
+
423
+ /**
424
+ * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
425
+ * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
426
+ *
427
+ * Calling conditions:
428
+ *
429
+ * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
430
+ * - When `from` is zero, the tokens will be minted for `to`.
431
+ * - When `to` is zero, ``from``'s tokens will be burned.
432
+ * - `from` and `to` are never both zero.
433
+ * - `batchSize` is non-zero.
434
+ *
435
+ * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
436
+ */
437
+ function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}
438
+
439
+ /**
440
+ * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
441
+ * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
442
+ *
443
+ * Calling conditions:
444
+ *
445
+ * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
446
+ * - When `from` is zero, the tokens were minted for `to`.
447
+ * - When `to` is zero, ``from``'s tokens were burned.
448
+ * - `from` and `to` are never both zero.
449
+ * - `batchSize` is non-zero.
450
+ *
451
+ * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
452
+ */
453
+ function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}
454
+
455
+ /**
456
+ * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
457
+ *
458
+ * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
459
+ * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
460
+ * that `ownerOf(tokenId)` is `a`.
461
+ */
462
+ // solhint-disable-next-line func-name-mixedcase
463
+ function __unsafe_increaseBalance(address account, uint256 amount) internal {
464
+ _balances[account] += amount;
465
+ }
466
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import "../../utils/introspection/IERC165.sol";
7
+
8
+ /**
9
+ * @dev Required interface of an ERC721 compliant contract.
10
+ */
11
+ interface IERC721 is IERC165 {
12
+ /**
13
+ * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
14
+ */
15
+ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
16
+
17
+ /**
18
+ * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
19
+ */
20
+ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
21
+
22
+ /**
23
+ * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
24
+ */
25
+ event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
26
+
27
+ /**
28
+ * @dev Returns the number of tokens in ``owner``'s account.
29
+ */
30
+ function balanceOf(address owner) external view returns (uint256 balance);
31
+
32
+ /**
33
+ * @dev Returns the owner of the `tokenId` token.
34
+ *
35
+ * Requirements:
36
+ *
37
+ * - `tokenId` must exist.
38
+ */
39
+ function ownerOf(uint256 tokenId) external view returns (address owner);
40
+
41
+ /**
42
+ * @dev Safely transfers `tokenId` token from `from` to `to`.
43
+ *
44
+ * Requirements:
45
+ *
46
+ * - `from` cannot be the zero address.
47
+ * - `to` cannot be the zero address.
48
+ * - `tokenId` token must exist and be owned by `from`.
49
+ * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
50
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
51
+ *
52
+ * Emits a {Transfer} event.
53
+ */
54
+ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
55
+
56
+ /**
57
+ * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
58
+ * are aware of the ERC721 protocol to prevent tokens from being forever locked.
59
+ *
60
+ * Requirements:
61
+ *
62
+ * - `from` cannot be the zero address.
63
+ * - `to` cannot be the zero address.
64
+ * - `tokenId` token must exist and be owned by `from`.
65
+ * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
66
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
67
+ *
68
+ * Emits a {Transfer} event.
69
+ */
70
+ function safeTransferFrom(address from, address to, uint256 tokenId) external;
71
+
72
+ /**
73
+ * @dev Transfers `tokenId` token from `from` to `to`.
74
+ *
75
+ * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
76
+ * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
77
+ * understand this adds an external call which potentially creates a reentrancy vulnerability.
78
+ *
79
+ * Requirements:
80
+ *
81
+ * - `from` cannot be the zero address.
82
+ * - `to` cannot be the zero address.
83
+ * - `tokenId` token must be owned by `from`.
84
+ * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
85
+ *
86
+ * Emits a {Transfer} event.
87
+ */
88
+ function transferFrom(address from, address to, uint256 tokenId) external;
89
+
90
+ /**
91
+ * @dev Gives permission to `to` to transfer `tokenId` token to another account.
92
+ * The approval is cleared when the token is transferred.
93
+ *
94
+ * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
95
+ *
96
+ * Requirements:
97
+ *
98
+ * - The caller must own the token or be an approved operator.
99
+ * - `tokenId` must exist.
100
+ *
101
+ * Emits an {Approval} event.
102
+ */
103
+ function approve(address to, uint256 tokenId) external;
104
+
105
+ /**
106
+ * @dev Approve or remove `operator` as an operator for the caller.
107
+ * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
108
+ *
109
+ * Requirements:
110
+ *
111
+ * - The `operator` cannot be the caller.
112
+ *
113
+ * Emits an {ApprovalForAll} event.
114
+ */
115
+ function setApprovalForAll(address operator, bool approved) external;
116
+
117
+ /**
118
+ * @dev Returns the account approved for `tokenId` token.
119
+ *
120
+ * Requirements:
121
+ *
122
+ * - `tokenId` must exist.
123
+ */
124
+ function getApproved(uint256 tokenId) external view returns (address operator);
125
+
126
+ /**
127
+ * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
128
+ *
129
+ * See {setApprovalForAll}
130
+ */
131
+ function isApprovedForAll(address owner, address operator) external view returns (bool);
132
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ /**
7
+ * @title ERC721 token receiver interface
8
+ * @dev Interface for any contract that wants to support safeTransfers
9
+ * from ERC721 asset contracts.
10
+ */
11
+ interface IERC721Receiver {
12
+ /**
13
+ * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
14
+ * by `operator` from `from`, this function is called.
15
+ *
16
+ * It must return its Solidity selector to confirm the token transfer.
17
+ * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
18
+ *
19
+ * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
20
+ */
21
+ function onERC721Received(
22
+ address operator,
23
+ address from,
24
+ uint256 tokenId,
25
+ bytes calldata data
26
+ ) external returns (bytes4);
27
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import "../IERC721.sol";
7
+
8
+ /**
9
+ * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
10
+ * @dev See https://eips.ethereum.org/EIPS/eip-721
11
+ */
12
+ interface IERC721Metadata is IERC721 {
13
+ /**
14
+ * @dev Returns the token collection name.
15
+ */
16
+ function name() external view returns (string memory);
17
+
18
+ /**
19
+ * @dev Returns the token collection symbol.
20
+ */
21
+ function symbol() external view returns (string memory);
22
+
23
+ /**
24
+ * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
25
+ */
26
+ function tokenURI(uint256 tokenId) external view returns (string memory);
27
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/Address.sol ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
3
+
4
+ pragma solidity ^0.8.1;
5
+
6
+ /**
7
+ * @dev Collection of functions related to the address type
8
+ */
9
+ library Address {
10
+ /**
11
+ * @dev Returns true if `account` is a contract.
12
+ *
13
+ * [IMPORTANT]
14
+ * ====
15
+ * It is unsafe to assume that an address for which this function returns
16
+ * false is an externally-owned account (EOA) and not a contract.
17
+ *
18
+ * Among others, `isContract` will return false for the following
19
+ * types of addresses:
20
+ *
21
+ * - an externally-owned account
22
+ * - a contract in construction
23
+ * - an address where a contract will be created
24
+ * - an address where a contract lived, but was destroyed
25
+ *
26
+ * Furthermore, `isContract` will also return true if the target contract within
27
+ * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
28
+ * which only has an effect at the end of a transaction.
29
+ * ====
30
+ *
31
+ * [IMPORTANT]
32
+ * ====
33
+ * You shouldn't rely on `isContract` to protect against flash loan attacks!
34
+ *
35
+ * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
36
+ * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
37
+ * constructor.
38
+ * ====
39
+ */
40
+ function isContract(address account) internal view returns (bool) {
41
+ // This method relies on extcodesize/address.code.length, which returns 0
42
+ // for contracts in construction, since the code is only stored at the end
43
+ // of the constructor execution.
44
+
45
+ return account.code.length > 0;
46
+ }
47
+
48
+ /**
49
+ * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
50
+ * `recipient`, forwarding all available gas and reverting on errors.
51
+ *
52
+ * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
53
+ * of certain opcodes, possibly making contracts go over the 2300 gas limit
54
+ * imposed by `transfer`, making them unable to receive funds via
55
+ * `transfer`. {sendValue} removes this limitation.
56
+ *
57
+ * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
58
+ *
59
+ * IMPORTANT: because control is transferred to `recipient`, care must be
60
+ * taken to not create reentrancy vulnerabilities. Consider using
61
+ * {ReentrancyGuard} or the
62
+ * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
63
+ */
64
+ function sendValue(address payable recipient, uint256 amount) internal {
65
+ require(address(this).balance >= amount, "Address: insufficient balance");
66
+
67
+ (bool success, ) = recipient.call{value: amount}("");
68
+ require(success, "Address: unable to send value, recipient may have reverted");
69
+ }
70
+
71
+ /**
72
+ * @dev Performs a Solidity function call using a low level `call`. A
73
+ * plain `call` is an unsafe replacement for a function call: use this
74
+ * function instead.
75
+ *
76
+ * If `target` reverts with a revert reason, it is bubbled up by this
77
+ * function (like regular Solidity function calls).
78
+ *
79
+ * Returns the raw returned data. To convert to the expected return value,
80
+ * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
81
+ *
82
+ * Requirements:
83
+ *
84
+ * - `target` must be a contract.
85
+ * - calling `target` with `data` must not revert.
86
+ *
87
+ * _Available since v3.1._
88
+ */
89
+ function functionCall(address target, bytes memory data) internal returns (bytes memory) {
90
+ return functionCallWithValue(target, data, 0, "Address: low-level call failed");
91
+ }
92
+
93
+ /**
94
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
95
+ * `errorMessage` as a fallback revert reason when `target` reverts.
96
+ *
97
+ * _Available since v3.1._
98
+ */
99
+ function functionCall(
100
+ address target,
101
+ bytes memory data,
102
+ string memory errorMessage
103
+ ) internal returns (bytes memory) {
104
+ return functionCallWithValue(target, data, 0, errorMessage);
105
+ }
106
+
107
+ /**
108
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
109
+ * but also transferring `value` wei to `target`.
110
+ *
111
+ * Requirements:
112
+ *
113
+ * - the calling contract must have an ETH balance of at least `value`.
114
+ * - the called Solidity function must be `payable`.
115
+ *
116
+ * _Available since v3.1._
117
+ */
118
+ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
119
+ return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
120
+ }
121
+
122
+ /**
123
+ * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
124
+ * with `errorMessage` as a fallback revert reason when `target` reverts.
125
+ *
126
+ * _Available since v3.1._
127
+ */
128
+ function functionCallWithValue(
129
+ address target,
130
+ bytes memory data,
131
+ uint256 value,
132
+ string memory errorMessage
133
+ ) internal returns (bytes memory) {
134
+ require(address(this).balance >= value, "Address: insufficient balance for call");
135
+ (bool success, bytes memory returndata) = target.call{value: value}(data);
136
+ return verifyCallResultFromTarget(target, success, returndata, errorMessage);
137
+ }
138
+
139
+ /**
140
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
141
+ * but performing a static call.
142
+ *
143
+ * _Available since v3.3._
144
+ */
145
+ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
146
+ return functionStaticCall(target, data, "Address: low-level static call failed");
147
+ }
148
+
149
+ /**
150
+ * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
151
+ * but performing a static call.
152
+ *
153
+ * _Available since v3.3._
154
+ */
155
+ function functionStaticCall(
156
+ address target,
157
+ bytes memory data,
158
+ string memory errorMessage
159
+ ) internal view returns (bytes memory) {
160
+ (bool success, bytes memory returndata) = target.staticcall(data);
161
+ return verifyCallResultFromTarget(target, success, returndata, errorMessage);
162
+ }
163
+
164
+ /**
165
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
166
+ * but performing a delegate call.
167
+ *
168
+ * _Available since v3.4._
169
+ */
170
+ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
171
+ return functionDelegateCall(target, data, "Address: low-level delegate call failed");
172
+ }
173
+
174
+ /**
175
+ * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
176
+ * but performing a delegate call.
177
+ *
178
+ * _Available since v3.4._
179
+ */
180
+ function functionDelegateCall(
181
+ address target,
182
+ bytes memory data,
183
+ string memory errorMessage
184
+ ) internal returns (bytes memory) {
185
+ (bool success, bytes memory returndata) = target.delegatecall(data);
186
+ return verifyCallResultFromTarget(target, success, returndata, errorMessage);
187
+ }
188
+
189
+ /**
190
+ * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
191
+ * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
192
+ *
193
+ * _Available since v4.8._
194
+ */
195
+ function verifyCallResultFromTarget(
196
+ address target,
197
+ bool success,
198
+ bytes memory returndata,
199
+ string memory errorMessage
200
+ ) internal view returns (bytes memory) {
201
+ if (success) {
202
+ if (returndata.length == 0) {
203
+ // only check isContract if the call was successful and the return data is empty
204
+ // otherwise we already know that it was a contract
205
+ require(isContract(target), "Address: call to non-contract");
206
+ }
207
+ return returndata;
208
+ } else {
209
+ _revert(returndata, errorMessage);
210
+ }
211
+ }
212
+
213
+ /**
214
+ * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
215
+ * revert reason or using the provided one.
216
+ *
217
+ * _Available since v4.3._
218
+ */
219
+ function verifyCallResult(
220
+ bool success,
221
+ bytes memory returndata,
222
+ string memory errorMessage
223
+ ) internal pure returns (bytes memory) {
224
+ if (success) {
225
+ return returndata;
226
+ } else {
227
+ _revert(returndata, errorMessage);
228
+ }
229
+ }
230
+
231
+ function _revert(bytes memory returndata, string memory errorMessage) private pure {
232
+ // Look for revert reason and bubble it up if present
233
+ if (returndata.length > 0) {
234
+ // The easiest way to bubble the revert reason is using memory via assembly
235
+ /// @solidity memory-safe-assembly
236
+ assembly {
237
+ let returndata_size := mload(returndata)
238
+ revert(add(32, returndata), returndata_size)
239
+ }
240
+ } else {
241
+ revert(errorMessage);
242
+ }
243
+ }
244
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/Context.sol ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ /**
7
+ * @dev Provides information about the current execution context, including the
8
+ * sender of the transaction and its data. While these are generally available
9
+ * via msg.sender and msg.data, they should not be accessed in such a direct
10
+ * manner, since when dealing with meta-transactions the account sending and
11
+ * paying for execution may not be the actual sender (as far as an application
12
+ * is concerned).
13
+ *
14
+ * This contract is only required for intermediate, library-like contracts.
15
+ */
16
+ abstract contract Context {
17
+ function _msgSender() internal view virtual returns (address) {
18
+ return msg.sender;
19
+ }
20
+
21
+ function _msgData() internal view virtual returns (bytes calldata) {
22
+ return msg.data;
23
+ }
24
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/Strings.sol ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import "./math/Math.sol";
7
+ import "./math/SignedMath.sol";
8
+
9
+ /**
10
+ * @dev String operations.
11
+ */
12
+ library Strings {
13
+ bytes16 private constant _SYMBOLS = "0123456789abcdef";
14
+ uint8 private constant _ADDRESS_LENGTH = 20;
15
+
16
+ /**
17
+ * @dev Converts a `uint256` to its ASCII `string` decimal representation.
18
+ */
19
+ function toString(uint256 value) internal pure returns (string memory) {
20
+ unchecked {
21
+ uint256 length = Math.log10(value) + 1;
22
+ string memory buffer = new string(length);
23
+ uint256 ptr;
24
+ /// @solidity memory-safe-assembly
25
+ assembly {
26
+ ptr := add(buffer, add(32, length))
27
+ }
28
+ while (true) {
29
+ ptr--;
30
+ /// @solidity memory-safe-assembly
31
+ assembly {
32
+ mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
33
+ }
34
+ value /= 10;
35
+ if (value == 0) break;
36
+ }
37
+ return buffer;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @dev Converts a `int256` to its ASCII `string` decimal representation.
43
+ */
44
+ function toString(int256 value) internal pure returns (string memory) {
45
+ return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
46
+ }
47
+
48
+ /**
49
+ * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
50
+ */
51
+ function toHexString(uint256 value) internal pure returns (string memory) {
52
+ unchecked {
53
+ return toHexString(value, Math.log256(value) + 1);
54
+ }
55
+ }
56
+
57
+ /**
58
+ * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
59
+ */
60
+ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
61
+ bytes memory buffer = new bytes(2 * length + 2);
62
+ buffer[0] = "0";
63
+ buffer[1] = "x";
64
+ for (uint256 i = 2 * length + 1; i > 1; --i) {
65
+ buffer[i] = _SYMBOLS[value & 0xf];
66
+ value >>= 4;
67
+ }
68
+ require(value == 0, "Strings: hex length insufficient");
69
+ return string(buffer);
70
+ }
71
+
72
+ /**
73
+ * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
74
+ */
75
+ function toHexString(address addr) internal pure returns (string memory) {
76
+ return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
77
+ }
78
+
79
+ /**
80
+ * @dev Returns true if the two strings are equal.
81
+ */
82
+ function equal(string memory a, string memory b) internal pure returns (bool) {
83
+ return keccak256(bytes(a)) == keccak256(bytes(b));
84
+ }
85
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import "./IERC165.sol";
7
+
8
+ /**
9
+ * @dev Implementation of the {IERC165} interface.
10
+ *
11
+ * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
12
+ * for the additional interface id that will be supported. For example:
13
+ *
14
+ * ```solidity
15
+ * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
16
+ * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
17
+ * }
18
+ * ```
19
+ *
20
+ * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
21
+ */
22
+ abstract contract ERC165 is IERC165 {
23
+ /**
24
+ * @dev See {IERC165-supportsInterface}.
25
+ */
26
+ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
27
+ return interfaceId == type(IERC165).interfaceId;
28
+ }
29
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ /**
7
+ * @dev Interface of the ERC165 standard, as defined in the
8
+ * https://eips.ethereum.org/EIPS/eip-165[EIP].
9
+ *
10
+ * Implementers can declare support of contract interfaces, which can then be
11
+ * queried by others ({ERC165Checker}).
12
+ *
13
+ * For an implementation, see {ERC165}.
14
+ */
15
+ interface IERC165 {
16
+ /**
17
+ * @dev Returns true if this contract implements the interface defined by
18
+ * `interfaceId`. See the corresponding
19
+ * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
20
+ * to learn more about how these ids are created.
21
+ *
22
+ * This function call must use less than 30 000 gas.
23
+ */
24
+ function supportsInterface(bytes4 interfaceId) external view returns (bool);
25
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/math/Math.sol ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ /**
7
+ * @dev Standard math utilities missing in the Solidity language.
8
+ */
9
+ library Math {
10
+ enum Rounding {
11
+ Down, // Toward negative infinity
12
+ Up, // Toward infinity
13
+ Zero // Toward zero
14
+ }
15
+
16
+ /**
17
+ * @dev Returns the largest of two numbers.
18
+ */
19
+ function max(uint256 a, uint256 b) internal pure returns (uint256) {
20
+ return a > b ? a : b;
21
+ }
22
+
23
+ /**
24
+ * @dev Returns the smallest of two numbers.
25
+ */
26
+ function min(uint256 a, uint256 b) internal pure returns (uint256) {
27
+ return a < b ? a : b;
28
+ }
29
+
30
+ /**
31
+ * @dev Returns the average of two numbers. The result is rounded towards
32
+ * zero.
33
+ */
34
+ function average(uint256 a, uint256 b) internal pure returns (uint256) {
35
+ // (a + b) / 2 can overflow.
36
+ return (a & b) + (a ^ b) / 2;
37
+ }
38
+
39
+ /**
40
+ * @dev Returns the ceiling of the division of two numbers.
41
+ *
42
+ * This differs from standard division with `/` in that it rounds up instead
43
+ * of rounding down.
44
+ */
45
+ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
46
+ // (a + b - 1) / b can overflow on addition, so we distribute.
47
+ return a == 0 ? 0 : (a - 1) / b + 1;
48
+ }
49
+
50
+ /**
51
+ * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
52
+ * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
53
+ * with further edits by Uniswap Labs also under MIT license.
54
+ */
55
+ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
56
+ unchecked {
57
+ // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
58
+ // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
59
+ // variables such that product = prod1 * 2^256 + prod0.
60
+ uint256 prod0; // Least significant 256 bits of the product
61
+ uint256 prod1; // Most significant 256 bits of the product
62
+ assembly {
63
+ let mm := mulmod(x, y, not(0))
64
+ prod0 := mul(x, y)
65
+ prod1 := sub(sub(mm, prod0), lt(mm, prod0))
66
+ }
67
+
68
+ // Handle non-overflow cases, 256 by 256 division.
69
+ if (prod1 == 0) {
70
+ // Solidity will revert if denominator == 0, unlike the div opcode on its own.
71
+ // The surrounding unchecked block does not change this fact.
72
+ // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
73
+ return prod0 / denominator;
74
+ }
75
+
76
+ // Make sure the result is less than 2^256. Also prevents denominator == 0.
77
+ require(denominator > prod1, "Math: mulDiv overflow");
78
+
79
+ ///////////////////////////////////////////////
80
+ // 512 by 256 division.
81
+ ///////////////////////////////////////////////
82
+
83
+ // Make division exact by subtracting the remainder from [prod1 prod0].
84
+ uint256 remainder;
85
+ assembly {
86
+ // Compute remainder using mulmod.
87
+ remainder := mulmod(x, y, denominator)
88
+
89
+ // Subtract 256 bit number from 512 bit number.
90
+ prod1 := sub(prod1, gt(remainder, prod0))
91
+ prod0 := sub(prod0, remainder)
92
+ }
93
+
94
+ // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
95
+ // See https://cs.stackexchange.com/q/138556/92363.
96
+
97
+ // Does not overflow because the denominator cannot be zero at this stage in the function.
98
+ uint256 twos = denominator & (~denominator + 1);
99
+ assembly {
100
+ // Divide denominator by twos.
101
+ denominator := div(denominator, twos)
102
+
103
+ // Divide [prod1 prod0] by twos.
104
+ prod0 := div(prod0, twos)
105
+
106
+ // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
107
+ twos := add(div(sub(0, twos), twos), 1)
108
+ }
109
+
110
+ // Shift in bits from prod1 into prod0.
111
+ prod0 |= prod1 * twos;
112
+
113
+ // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
114
+ // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
115
+ // four bits. That is, denominator * inv = 1 mod 2^4.
116
+ uint256 inverse = (3 * denominator) ^ 2;
117
+
118
+ // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
119
+ // in modular arithmetic, doubling the correct bits in each step.
120
+ inverse *= 2 - denominator * inverse; // inverse mod 2^8
121
+ inverse *= 2 - denominator * inverse; // inverse mod 2^16
122
+ inverse *= 2 - denominator * inverse; // inverse mod 2^32
123
+ inverse *= 2 - denominator * inverse; // inverse mod 2^64
124
+ inverse *= 2 - denominator * inverse; // inverse mod 2^128
125
+ inverse *= 2 - denominator * inverse; // inverse mod 2^256
126
+
127
+ // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
128
+ // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
129
+ // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
130
+ // is no longer required.
131
+ result = prod0 * inverse;
132
+ return result;
133
+ }
134
+ }
135
+
136
+ /**
137
+ * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
138
+ */
139
+ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
140
+ uint256 result = mulDiv(x, y, denominator);
141
+ if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
142
+ result += 1;
143
+ }
144
+ return result;
145
+ }
146
+
147
+ /**
148
+ * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
149
+ *
150
+ * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
151
+ */
152
+ function sqrt(uint256 a) internal pure returns (uint256) {
153
+ if (a == 0) {
154
+ return 0;
155
+ }
156
+
157
+ // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
158
+ //
159
+ // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
160
+ // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
161
+ //
162
+ // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
163
+ // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
164
+ // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
165
+ //
166
+ // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
167
+ uint256 result = 1 << (log2(a) >> 1);
168
+
169
+ // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
170
+ // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
171
+ // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
172
+ // into the expected uint128 result.
173
+ unchecked {
174
+ result = (result + a / result) >> 1;
175
+ result = (result + a / result) >> 1;
176
+ result = (result + a / result) >> 1;
177
+ result = (result + a / result) >> 1;
178
+ result = (result + a / result) >> 1;
179
+ result = (result + a / result) >> 1;
180
+ result = (result + a / result) >> 1;
181
+ return min(result, a / result);
182
+ }
183
+ }
184
+
185
+ /**
186
+ * @notice Calculates sqrt(a), following the selected rounding direction.
187
+ */
188
+ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
189
+ unchecked {
190
+ uint256 result = sqrt(a);
191
+ return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
192
+ }
193
+ }
194
+
195
+ /**
196
+ * @dev Return the log in base 2, rounded down, of a positive value.
197
+ * Returns 0 if given 0.
198
+ */
199
+ function log2(uint256 value) internal pure returns (uint256) {
200
+ uint256 result = 0;
201
+ unchecked {
202
+ if (value >> 128 > 0) {
203
+ value >>= 128;
204
+ result += 128;
205
+ }
206
+ if (value >> 64 > 0) {
207
+ value >>= 64;
208
+ result += 64;
209
+ }
210
+ if (value >> 32 > 0) {
211
+ value >>= 32;
212
+ result += 32;
213
+ }
214
+ if (value >> 16 > 0) {
215
+ value >>= 16;
216
+ result += 16;
217
+ }
218
+ if (value >> 8 > 0) {
219
+ value >>= 8;
220
+ result += 8;
221
+ }
222
+ if (value >> 4 > 0) {
223
+ value >>= 4;
224
+ result += 4;
225
+ }
226
+ if (value >> 2 > 0) {
227
+ value >>= 2;
228
+ result += 2;
229
+ }
230
+ if (value >> 1 > 0) {
231
+ result += 1;
232
+ }
233
+ }
234
+ return result;
235
+ }
236
+
237
+ /**
238
+ * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
239
+ * Returns 0 if given 0.
240
+ */
241
+ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
242
+ unchecked {
243
+ uint256 result = log2(value);
244
+ return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
245
+ }
246
+ }
247
+
248
+ /**
249
+ * @dev Return the log in base 10, rounded down, of a positive value.
250
+ * Returns 0 if given 0.
251
+ */
252
+ function log10(uint256 value) internal pure returns (uint256) {
253
+ uint256 result = 0;
254
+ unchecked {
255
+ if (value >= 10 ** 64) {
256
+ value /= 10 ** 64;
257
+ result += 64;
258
+ }
259
+ if (value >= 10 ** 32) {
260
+ value /= 10 ** 32;
261
+ result += 32;
262
+ }
263
+ if (value >= 10 ** 16) {
264
+ value /= 10 ** 16;
265
+ result += 16;
266
+ }
267
+ if (value >= 10 ** 8) {
268
+ value /= 10 ** 8;
269
+ result += 8;
270
+ }
271
+ if (value >= 10 ** 4) {
272
+ value /= 10 ** 4;
273
+ result += 4;
274
+ }
275
+ if (value >= 10 ** 2) {
276
+ value /= 10 ** 2;
277
+ result += 2;
278
+ }
279
+ if (value >= 10 ** 1) {
280
+ result += 1;
281
+ }
282
+ }
283
+ return result;
284
+ }
285
+
286
+ /**
287
+ * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
288
+ * Returns 0 if given 0.
289
+ */
290
+ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
291
+ unchecked {
292
+ uint256 result = log10(value);
293
+ return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
294
+ }
295
+ }
296
+
297
+ /**
298
+ * @dev Return the log in base 256, rounded down, of a positive value.
299
+ * Returns 0 if given 0.
300
+ *
301
+ * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
302
+ */
303
+ function log256(uint256 value) internal pure returns (uint256) {
304
+ uint256 result = 0;
305
+ unchecked {
306
+ if (value >> 128 > 0) {
307
+ value >>= 128;
308
+ result += 16;
309
+ }
310
+ if (value >> 64 > 0) {
311
+ value >>= 64;
312
+ result += 8;
313
+ }
314
+ if (value >> 32 > 0) {
315
+ value >>= 32;
316
+ result += 4;
317
+ }
318
+ if (value >> 16 > 0) {
319
+ value >>= 16;
320
+ result += 2;
321
+ }
322
+ if (value >> 8 > 0) {
323
+ result += 1;
324
+ }
325
+ }
326
+ return result;
327
+ }
328
+
329
+ /**
330
+ * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
331
+ * Returns 0 if given 0.
332
+ */
333
+ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
334
+ unchecked {
335
+ uint256 result = log256(value);
336
+ return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
337
+ }
338
+ }
339
+ }
third_party/real_code/rc16/sources/lib/tokenbound/lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ /**
7
+ * @dev Standard signed math utilities missing in the Solidity language.
8
+ */
9
+ library SignedMath {
10
+ /**
11
+ * @dev Returns the largest of two signed numbers.
12
+ */
13
+ function max(int256 a, int256 b) internal pure returns (int256) {
14
+ return a > b ? a : b;
15
+ }
16
+
17
+ /**
18
+ * @dev Returns the smallest of two signed numbers.
19
+ */
20
+ function min(int256 a, int256 b) internal pure returns (int256) {
21
+ return a < b ? a : b;
22
+ }
23
+
24
+ /**
25
+ * @dev Returns the average of two signed numbers without overflow.
26
+ * The result is rounded towards zero.
27
+ */
28
+ function average(int256 a, int256 b) internal pure returns (int256) {
29
+ // Formula from the book "Hacker's Delight"
30
+ int256 x = (a & b) + ((a ^ b) >> 1);
31
+ return x + (int256(uint256(x) >> 255) & (a ^ b));
32
+ }
33
+
34
+ /**
35
+ * @dev Returns the absolute unsigned value of a signed value.
36
+ */
37
+ function abs(int256 n) internal pure returns (uint256) {
38
+ unchecked {
39
+ // must be unchecked in order to support `n = type(int256).min`
40
+ return uint256(n >= 0 ? n : -n);
41
+ }
42
+ }
43
+ }
third_party/real_code/rc16/sources/src/MichiWalletNFT.sol ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.13;
3
+
4
+ import "@openzeppelin/contracts/access/Ownable.sol";
5
+ import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
6
+
7
+ contract MichiWalletNFT is ERC721, Ownable {
8
+ /// @notice tracks the next index to be minted
9
+ uint256 public currentIndex;
10
+
11
+ /// @notice tracks the total supply minted
12
+ uint256 public totalSupply;
13
+
14
+ /// @notice mint price in ETH
15
+ uint256 public mintPrice;
16
+
17
+ event Mint(address indexed minter, uint256 nftId);
18
+
19
+ event Withdrawal(address indexed withdrawer, uint256 amount);
20
+
21
+ error InvalidPayableAmount(uint256 amount);
22
+
23
+ error WithdrawalFailed();
24
+
25
+ constructor(uint256 startingIndex_, uint256 mintPrice_) ERC721("Michi Wallet NFT", "MICHI") {
26
+ currentIndex = startingIndex_;
27
+ mintPrice = mintPrice_;
28
+ }
29
+
30
+ function getCurrentIndex() public view returns (uint256) {
31
+ return currentIndex;
32
+ }
33
+
34
+ function getMintPrice() external view returns (uint256) {
35
+ return mintPrice;
36
+ }
37
+
38
+ function mint(address to) external payable {
39
+ if (msg.value != mintPrice) revert InvalidPayableAmount(msg.value);
40
+ _safeMint(to, currentIndex);
41
+
42
+ emit Mint(to, currentIndex);
43
+ currentIndex++;
44
+ totalSupply++;
45
+ }
46
+
47
+ function setMintPrice(uint256 newMintPrice_) external onlyOwner {
48
+ mintPrice = newMintPrice_;
49
+ }
50
+
51
+ function withdraw(address to) external onlyOwner {
52
+ uint256 withdrawAmount = address(this).balance;
53
+ (bool success,) = to.call{value: withdrawAmount}("");
54
+
55
+ if (!success) revert WithdrawalFailed();
56
+
57
+ emit Withdrawal(msg.sender, withdrawAmount);
58
+ }
59
+
60
+ receive() external payable {}
61
+ }
third_party/real_code/rc17/NOTICE ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Notice for rc17
2
+
3
+ This package contains smart contract source files verified on Sourcify.
4
+
5
+ ## Source Files and Licensing
6
+
7
+ - File: `@openzeppelin/contracts/access/Ownable.sol`
8
+ SPDX: MIT
9
+
10
+ - File: `@openzeppelin/contracts/interfaces/IERC165.sol`
11
+ SPDX: MIT
12
+
13
+ - File: `@openzeppelin/contracts/interfaces/IERC4906.sol`
14
+ SPDX: MIT
15
+
16
+ - File: `@openzeppelin/contracts/interfaces/IERC721.sol`
17
+ SPDX: MIT
18
+
19
+ - File: `@openzeppelin/contracts/interfaces/draft-IERC6093.sol`
20
+ SPDX: MIT
21
+
22
+ - File: `@openzeppelin/contracts/token/ERC721/ERC721.sol`
23
+ SPDX: MIT
24
+
25
+ - File: `@openzeppelin/contracts/token/ERC721/IERC721.sol`
26
+ SPDX: MIT
27
+
28
+ - File: `@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol`
29
+ SPDX: MIT
30
+
31
+ - File: `@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol`
32
+ SPDX: MIT
33
+
34
+ - File: `@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol`
35
+ SPDX: MIT
36
+
37
+ - File: `@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol`
38
+ SPDX: MIT
39
+
40
+ - File: `@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol`
41
+ SPDX: MIT
42
+
43
+ - File: `@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol`
44
+ SPDX: MIT
45
+
46
+ - File: `@openzeppelin/contracts/utils/Context.sol`
47
+ SPDX: MIT
48
+
49
+ - File: `@openzeppelin/contracts/utils/Panic.sol`
50
+ SPDX: MIT
51
+
52
+ - File: `@openzeppelin/contracts/utils/Strings.sol`
53
+ SPDX: MIT
54
+
55
+ - File: `@openzeppelin/contracts/utils/introspection/ERC165.sol`
56
+ SPDX: MIT
57
+
58
+ - File: `@openzeppelin/contracts/utils/introspection/IERC165.sol`
59
+ SPDX: MIT
60
+
61
+ - File: `@openzeppelin/contracts/utils/math/Math.sol`
62
+ SPDX: MIT
63
+
64
+ - File: `@openzeppelin/contracts/utils/math/SafeCast.sol`
65
+ SPDX: MIT
66
+
67
+ - File: `@openzeppelin/contracts/utils/math/SignedMath.sol`
68
+ SPDX: MIT
69
+
70
+ - File: `contracts/SharpNFT.sol`
71
+ SPDX: MIT
third_party/real_code/rc17/abi.json ADDED
@@ -0,0 +1,666 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "constructor",
4
+ "inputs": [
5
+ {
6
+ "name": "initialOwner",
7
+ "type": "address",
8
+ "internalType": "address"
9
+ }
10
+ ],
11
+ "stateMutability": "nonpayable"
12
+ },
13
+ {
14
+ "name": "ERC721EnumerableForbiddenBatchMint",
15
+ "type": "error",
16
+ "inputs": []
17
+ },
18
+ {
19
+ "name": "ERC721IncorrectOwner",
20
+ "type": "error",
21
+ "inputs": [
22
+ {
23
+ "name": "sender",
24
+ "type": "address",
25
+ "internalType": "address"
26
+ },
27
+ {
28
+ "name": "tokenId",
29
+ "type": "uint256",
30
+ "internalType": "uint256"
31
+ },
32
+ {
33
+ "name": "owner",
34
+ "type": "address",
35
+ "internalType": "address"
36
+ }
37
+ ]
38
+ },
39
+ {
40
+ "name": "ERC721InsufficientApproval",
41
+ "type": "error",
42
+ "inputs": [
43
+ {
44
+ "name": "operator",
45
+ "type": "address",
46
+ "internalType": "address"
47
+ },
48
+ {
49
+ "name": "tokenId",
50
+ "type": "uint256",
51
+ "internalType": "uint256"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "name": "ERC721InvalidApprover",
57
+ "type": "error",
58
+ "inputs": [
59
+ {
60
+ "name": "approver",
61
+ "type": "address",
62
+ "internalType": "address"
63
+ }
64
+ ]
65
+ },
66
+ {
67
+ "name": "ERC721InvalidOperator",
68
+ "type": "error",
69
+ "inputs": [
70
+ {
71
+ "name": "operator",
72
+ "type": "address",
73
+ "internalType": "address"
74
+ }
75
+ ]
76
+ },
77
+ {
78
+ "name": "ERC721InvalidOwner",
79
+ "type": "error",
80
+ "inputs": [
81
+ {
82
+ "name": "owner",
83
+ "type": "address",
84
+ "internalType": "address"
85
+ }
86
+ ]
87
+ },
88
+ {
89
+ "name": "ERC721InvalidReceiver",
90
+ "type": "error",
91
+ "inputs": [
92
+ {
93
+ "name": "receiver",
94
+ "type": "address",
95
+ "internalType": "address"
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ "name": "ERC721InvalidSender",
101
+ "type": "error",
102
+ "inputs": [
103
+ {
104
+ "name": "sender",
105
+ "type": "address",
106
+ "internalType": "address"
107
+ }
108
+ ]
109
+ },
110
+ {
111
+ "name": "ERC721NonexistentToken",
112
+ "type": "error",
113
+ "inputs": [
114
+ {
115
+ "name": "tokenId",
116
+ "type": "uint256",
117
+ "internalType": "uint256"
118
+ }
119
+ ]
120
+ },
121
+ {
122
+ "name": "ERC721OutOfBoundsIndex",
123
+ "type": "error",
124
+ "inputs": [
125
+ {
126
+ "name": "owner",
127
+ "type": "address",
128
+ "internalType": "address"
129
+ },
130
+ {
131
+ "name": "index",
132
+ "type": "uint256",
133
+ "internalType": "uint256"
134
+ }
135
+ ]
136
+ },
137
+ {
138
+ "name": "OwnableInvalidOwner",
139
+ "type": "error",
140
+ "inputs": [
141
+ {
142
+ "name": "owner",
143
+ "type": "address",
144
+ "internalType": "address"
145
+ }
146
+ ]
147
+ },
148
+ {
149
+ "name": "OwnableUnauthorizedAccount",
150
+ "type": "error",
151
+ "inputs": [
152
+ {
153
+ "name": "account",
154
+ "type": "address",
155
+ "internalType": "address"
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "name": "Approval",
161
+ "type": "event",
162
+ "inputs": [
163
+ {
164
+ "name": "owner",
165
+ "type": "address",
166
+ "indexed": true,
167
+ "internalType": "address"
168
+ },
169
+ {
170
+ "name": "approved",
171
+ "type": "address",
172
+ "indexed": true,
173
+ "internalType": "address"
174
+ },
175
+ {
176
+ "name": "tokenId",
177
+ "type": "uint256",
178
+ "indexed": true,
179
+ "internalType": "uint256"
180
+ }
181
+ ],
182
+ "anonymous": false
183
+ },
184
+ {
185
+ "name": "ApprovalForAll",
186
+ "type": "event",
187
+ "inputs": [
188
+ {
189
+ "name": "owner",
190
+ "type": "address",
191
+ "indexed": true,
192
+ "internalType": "address"
193
+ },
194
+ {
195
+ "name": "operator",
196
+ "type": "address",
197
+ "indexed": true,
198
+ "internalType": "address"
199
+ },
200
+ {
201
+ "name": "approved",
202
+ "type": "bool",
203
+ "indexed": false,
204
+ "internalType": "bool"
205
+ }
206
+ ],
207
+ "anonymous": false
208
+ },
209
+ {
210
+ "name": "BatchMetadataUpdate",
211
+ "type": "event",
212
+ "inputs": [
213
+ {
214
+ "name": "_fromTokenId",
215
+ "type": "uint256",
216
+ "indexed": false,
217
+ "internalType": "uint256"
218
+ },
219
+ {
220
+ "name": "_toTokenId",
221
+ "type": "uint256",
222
+ "indexed": false,
223
+ "internalType": "uint256"
224
+ }
225
+ ],
226
+ "anonymous": false
227
+ },
228
+ {
229
+ "name": "Locked",
230
+ "type": "event",
231
+ "inputs": [
232
+ {
233
+ "name": "tokenId",
234
+ "type": "uint256",
235
+ "indexed": false,
236
+ "internalType": "uint256"
237
+ }
238
+ ],
239
+ "anonymous": false
240
+ },
241
+ {
242
+ "name": "MetadataUpdate",
243
+ "type": "event",
244
+ "inputs": [
245
+ {
246
+ "name": "_tokenId",
247
+ "type": "uint256",
248
+ "indexed": false,
249
+ "internalType": "uint256"
250
+ }
251
+ ],
252
+ "anonymous": false
253
+ },
254
+ {
255
+ "name": "OwnershipTransferred",
256
+ "type": "event",
257
+ "inputs": [
258
+ {
259
+ "name": "previousOwner",
260
+ "type": "address",
261
+ "indexed": true,
262
+ "internalType": "address"
263
+ },
264
+ {
265
+ "name": "newOwner",
266
+ "type": "address",
267
+ "indexed": true,
268
+ "internalType": "address"
269
+ }
270
+ ],
271
+ "anonymous": false
272
+ },
273
+ {
274
+ "name": "Transfer",
275
+ "type": "event",
276
+ "inputs": [
277
+ {
278
+ "name": "from",
279
+ "type": "address",
280
+ "indexed": true,
281
+ "internalType": "address"
282
+ },
283
+ {
284
+ "name": "to",
285
+ "type": "address",
286
+ "indexed": true,
287
+ "internalType": "address"
288
+ },
289
+ {
290
+ "name": "tokenId",
291
+ "type": "uint256",
292
+ "indexed": true,
293
+ "internalType": "uint256"
294
+ }
295
+ ],
296
+ "anonymous": false
297
+ },
298
+ {
299
+ "name": "approve",
300
+ "type": "function",
301
+ "inputs": [
302
+ {
303
+ "name": "to",
304
+ "type": "address",
305
+ "internalType": "address"
306
+ },
307
+ {
308
+ "name": "tokenId",
309
+ "type": "uint256",
310
+ "internalType": "uint256"
311
+ }
312
+ ],
313
+ "outputs": [],
314
+ "stateMutability": "nonpayable"
315
+ },
316
+ {
317
+ "name": "balanceOf",
318
+ "type": "function",
319
+ "inputs": [
320
+ {
321
+ "name": "owner",
322
+ "type": "address",
323
+ "internalType": "address"
324
+ }
325
+ ],
326
+ "outputs": [
327
+ {
328
+ "name": "",
329
+ "type": "uint256",
330
+ "internalType": "uint256"
331
+ }
332
+ ],
333
+ "stateMutability": "view"
334
+ },
335
+ {
336
+ "name": "getApproved",
337
+ "type": "function",
338
+ "inputs": [
339
+ {
340
+ "name": "tokenId",
341
+ "type": "uint256",
342
+ "internalType": "uint256"
343
+ }
344
+ ],
345
+ "outputs": [
346
+ {
347
+ "name": "",
348
+ "type": "address",
349
+ "internalType": "address"
350
+ }
351
+ ],
352
+ "stateMutability": "view"
353
+ },
354
+ {
355
+ "name": "isApprovedForAll",
356
+ "type": "function",
357
+ "inputs": [
358
+ {
359
+ "name": "owner",
360
+ "type": "address",
361
+ "internalType": "address"
362
+ },
363
+ {
364
+ "name": "operator",
365
+ "type": "address",
366
+ "internalType": "address"
367
+ }
368
+ ],
369
+ "outputs": [
370
+ {
371
+ "name": "",
372
+ "type": "bool",
373
+ "internalType": "bool"
374
+ }
375
+ ],
376
+ "stateMutability": "view"
377
+ },
378
+ {
379
+ "name": "name",
380
+ "type": "function",
381
+ "inputs": [],
382
+ "outputs": [
383
+ {
384
+ "name": "",
385
+ "type": "string",
386
+ "internalType": "string"
387
+ }
388
+ ],
389
+ "stateMutability": "view"
390
+ },
391
+ {
392
+ "name": "owner",
393
+ "type": "function",
394
+ "inputs": [],
395
+ "outputs": [
396
+ {
397
+ "name": "",
398
+ "type": "address",
399
+ "internalType": "address"
400
+ }
401
+ ],
402
+ "stateMutability": "view"
403
+ },
404
+ {
405
+ "name": "ownerOf",
406
+ "type": "function",
407
+ "inputs": [
408
+ {
409
+ "name": "tokenId",
410
+ "type": "uint256",
411
+ "internalType": "uint256"
412
+ }
413
+ ],
414
+ "outputs": [
415
+ {
416
+ "name": "",
417
+ "type": "address",
418
+ "internalType": "address"
419
+ }
420
+ ],
421
+ "stateMutability": "view"
422
+ },
423
+ {
424
+ "name": "renounceOwnership",
425
+ "type": "function",
426
+ "inputs": [],
427
+ "outputs": [],
428
+ "stateMutability": "nonpayable"
429
+ },
430
+ {
431
+ "name": "safeMint",
432
+ "type": "function",
433
+ "inputs": [
434
+ {
435
+ "name": "to",
436
+ "type": "address",
437
+ "internalType": "address"
438
+ },
439
+ {
440
+ "name": "uri",
441
+ "type": "string",
442
+ "internalType": "string"
443
+ }
444
+ ],
445
+ "outputs": [
446
+ {
447
+ "name": "",
448
+ "type": "uint256",
449
+ "internalType": "uint256"
450
+ }
451
+ ],
452
+ "stateMutability": "nonpayable"
453
+ },
454
+ {
455
+ "name": "safeTransferFrom",
456
+ "type": "function",
457
+ "inputs": [
458
+ {
459
+ "name": "from",
460
+ "type": "address",
461
+ "internalType": "address"
462
+ },
463
+ {
464
+ "name": "to",
465
+ "type": "address",
466
+ "internalType": "address"
467
+ },
468
+ {
469
+ "name": "tokenId",
470
+ "type": "uint256",
471
+ "internalType": "uint256"
472
+ }
473
+ ],
474
+ "outputs": [],
475
+ "stateMutability": "nonpayable"
476
+ },
477
+ {
478
+ "name": "safeTransferFrom",
479
+ "type": "function",
480
+ "inputs": [
481
+ {
482
+ "name": "from",
483
+ "type": "address",
484
+ "internalType": "address"
485
+ },
486
+ {
487
+ "name": "to",
488
+ "type": "address",
489
+ "internalType": "address"
490
+ },
491
+ {
492
+ "name": "tokenId",
493
+ "type": "uint256",
494
+ "internalType": "uint256"
495
+ },
496
+ {
497
+ "name": "data",
498
+ "type": "bytes",
499
+ "internalType": "bytes"
500
+ }
501
+ ],
502
+ "outputs": [],
503
+ "stateMutability": "nonpayable"
504
+ },
505
+ {
506
+ "name": "setApprovalForAll",
507
+ "type": "function",
508
+ "inputs": [
509
+ {
510
+ "name": "operator",
511
+ "type": "address",
512
+ "internalType": "address"
513
+ },
514
+ {
515
+ "name": "approved",
516
+ "type": "bool",
517
+ "internalType": "bool"
518
+ }
519
+ ],
520
+ "outputs": [],
521
+ "stateMutability": "nonpayable"
522
+ },
523
+ {
524
+ "name": "supportsInterface",
525
+ "type": "function",
526
+ "inputs": [
527
+ {
528
+ "name": "interfaceId",
529
+ "type": "bytes4",
530
+ "internalType": "bytes4"
531
+ }
532
+ ],
533
+ "outputs": [
534
+ {
535
+ "name": "",
536
+ "type": "bool",
537
+ "internalType": "bool"
538
+ }
539
+ ],
540
+ "stateMutability": "view"
541
+ },
542
+ {
543
+ "name": "symbol",
544
+ "type": "function",
545
+ "inputs": [],
546
+ "outputs": [
547
+ {
548
+ "name": "",
549
+ "type": "string",
550
+ "internalType": "string"
551
+ }
552
+ ],
553
+ "stateMutability": "view"
554
+ },
555
+ {
556
+ "name": "tokenByIndex",
557
+ "type": "function",
558
+ "inputs": [
559
+ {
560
+ "name": "index",
561
+ "type": "uint256",
562
+ "internalType": "uint256"
563
+ }
564
+ ],
565
+ "outputs": [
566
+ {
567
+ "name": "",
568
+ "type": "uint256",
569
+ "internalType": "uint256"
570
+ }
571
+ ],
572
+ "stateMutability": "view"
573
+ },
574
+ {
575
+ "name": "tokenOfOwnerByIndex",
576
+ "type": "function",
577
+ "inputs": [
578
+ {
579
+ "name": "owner",
580
+ "type": "address",
581
+ "internalType": "address"
582
+ },
583
+ {
584
+ "name": "index",
585
+ "type": "uint256",
586
+ "internalType": "uint256"
587
+ }
588
+ ],
589
+ "outputs": [
590
+ {
591
+ "name": "",
592
+ "type": "uint256",
593
+ "internalType": "uint256"
594
+ }
595
+ ],
596
+ "stateMutability": "view"
597
+ },
598
+ {
599
+ "name": "tokenURI",
600
+ "type": "function",
601
+ "inputs": [
602
+ {
603
+ "name": "tokenId",
604
+ "type": "uint256",
605
+ "internalType": "uint256"
606
+ }
607
+ ],
608
+ "outputs": [
609
+ {
610
+ "name": "",
611
+ "type": "string",
612
+ "internalType": "string"
613
+ }
614
+ ],
615
+ "stateMutability": "view"
616
+ },
617
+ {
618
+ "name": "totalSupply",
619
+ "type": "function",
620
+ "inputs": [],
621
+ "outputs": [
622
+ {
623
+ "name": "",
624
+ "type": "uint256",
625
+ "internalType": "uint256"
626
+ }
627
+ ],
628
+ "stateMutability": "view"
629
+ },
630
+ {
631
+ "name": "transferFrom",
632
+ "type": "function",
633
+ "inputs": [
634
+ {
635
+ "name": "from",
636
+ "type": "address",
637
+ "internalType": "address"
638
+ },
639
+ {
640
+ "name": "to",
641
+ "type": "address",
642
+ "internalType": "address"
643
+ },
644
+ {
645
+ "name": "tokenId",
646
+ "type": "uint256",
647
+ "internalType": "uint256"
648
+ }
649
+ ],
650
+ "outputs": [],
651
+ "stateMutability": "nonpayable"
652
+ },
653
+ {
654
+ "name": "transferOwnership",
655
+ "type": "function",
656
+ "inputs": [
657
+ {
658
+ "name": "newOwner",
659
+ "type": "address",
660
+ "internalType": "address"
661
+ }
662
+ ],
663
+ "outputs": [],
664
+ "stateMutability": "nonpayable"
665
+ }
666
+ ]
third_party/real_code/rc17/creation.hex ADDED
@@ -0,0 +1 @@
 
 
1
+ 0x60806040523480156200001157600080fd5b5060405162001b2138038062001b2183398101604081905262000034916200012a565b806040518060400160405280600881526020016714da185c9c13919560c21b8152506040518060400160405280600481526020016314d3919560e21b815250816000908162000084919062000203565b50600162000093828262000203565b5050506001600160a01b038116620000c557604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b620000d081620000d8565b5050620002cf565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000602082840312156200013d57600080fd5b81516001600160a01b03811681146200015557600080fd5b9392505050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200018757607f821691505b602082108103620001a857634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620001fe576000816000526020600020601f850160051c81016020861015620001d95750805b601f850160051c820191505b81811015620001fa57828155600101620001e5565b5050505b505050565b81516001600160401b038111156200021f576200021f6200015c565b620002378162000230845462000172565b84620001ae565b602080601f8311600181146200026f5760008415620002565750858301515b600019600386901b1c1916600185901b178555620001fa565b600085815260208120601f198616915b82811015620002a0578886015182559484019460019091019084016200027f565b5085821015620002bf5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61184280620002df6000396000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c806370a08231116100ad578063b88d4fde11610071578063b88d4fde14610266578063c87b56dd14610279578063d204c45e1461028c578063e985e9c51461029f578063f2fde38b146102b257600080fd5b806370a082311461021f578063715018a6146102325780638da5cb5b1461023a57806395d89b411461024b578063a22cb4651461025357600080fd5b806323b872dd116100f457806323b872dd146101c05780632f745c59146101d357806342842e0e146101e65780634f6ccce7146101f95780636352211e1461020c57600080fd5b806301ffc9a71461013157806306fdde0314610159578063081812fc1461016e578063095ea7b31461019957806318160ddd146101ae575b600080fd5b61014461013f3660046112c4565b6102c5565b60405190151581526020015b60405180910390f35b6101616102d6565b6040516101509190611331565b61018161017c366004611344565b610368565b6040516001600160a01b039091168152602001610150565b6101ac6101a7366004611379565b610391565b005b6008545b604051908152602001610150565b6101ac6101ce3660046113a3565b6103a0565b6101b26101e1366004611379565b610430565b6101ac6101f43660046113a3565b610495565b6101b2610207366004611344565b6104b5565b61018161021a366004611344565b61050e565b6101b261022d3660046113df565b610519565b6101ac610561565b600b546001600160a01b0316610181565b610161610575565b6101ac6102613660046113fa565b610584565b6101ac6102743660046114c2565b61058f565b610161610287366004611344565b6105a7565b6101b261029a36600461153e565b6105b2565b6101446102ad3660046115a0565b610621565b6101ac6102c03660046113df565b61064f565b60006102d08261068d565b92915050565b6060600080546102e5906115d3565b80601f0160208091040260200160405190810160405280929190818152602001828054610311906115d3565b801561035e5780601f106103335761010080835404028352916020019161035e565b820191906000526020600020905b81548152906001019060200180831161034157829003601f168201915b5050505050905090565b6000610373826106b2565b506000828152600460205260409020546001600160a01b03166102d0565b61039c8282336106eb565b5050565b6001600160a01b0382166103cf57604051633250574960e11b8152600060048201526024015b60405180910390fd5b60006103dc8383336106f8565b9050836001600160a01b0316816001600160a01b03161461042a576040516364283d7b60e01b81526001600160a01b03808616600483015260248201849052821660448201526064016103c6565b50505050565b600061043b83610519565b821061046c5760405163295f44f760e21b81526001600160a01b0384166004820152602481018390526044016103c6565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6104b08383836040518060200160405280600081525061058f565b505050565b60006104c060085490565b82106104e95760405163295f44f760e21b815260006004820152602481018390526044016103c6565b600882815481106104fc576104fc61160d565b90600052602060002001549050919050565b60006102d0826106b2565b60006001600160a01b038216610545576040516322718ad960e21b8152600060048201526024016103c6565b506001600160a01b031660009081526003602052604090205490565b61056961070d565b610573600061073a565b565b6060600180546102e5906115d3565b61039c33838361078c565b61059a8484846103a0565b61042a338585858561082b565b60606102d082610956565b60006105bc61070d565b600c8054600091826105cd83611639565b9190505590506105dd8482610a5f565b6105e78184610a79565b6040518181527f032bc66be43dbccb7487781d168eb7bda224628a3b2c3388bdf69b532a3a16119060200160405180910390a19392505050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61065761070d565b6001600160a01b03811661068157604051631e4fbdf760e01b8152600060048201526024016103c6565b61068a8161073a565b50565b60006001600160e01b03198216632483248360e11b14806102d057506102d082610ac9565b6000818152600260205260408120546001600160a01b0316806102d057604051637e27328960e01b8152600481018490526024016103c6565b6104b08383836001610aee565b6000610705848484610bf4565b949350505050565b600b546001600160a01b031633146105735760405163118cdaa760e01b81523360048201526024016103c6565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166107be57604051630b61174360e31b81526001600160a01b03831660048201526024016103c6565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383163b1561094f57604051630a85bd0160e11b81526001600160a01b0384169063150b7a029061086d908890889087908790600401611652565b6020604051808303816000875af19250505080156108a8575060408051601f3d908101601f191682019092526108a59181019061168f565b60015b610911573d8080156108d6576040519150601f19603f3d011682016040523d82523d6000602084013e6108db565b606091505b50805160000361090957604051633250574960e11b81526001600160a01b03851660048201526024016103c6565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b1461094d57604051633250574960e11b81526001600160a01b03851660048201526024016103c6565b505b5050505050565b6060610961826106b2565b506000828152600a60205260408120805461097b906115d3565b80601f01602080910402602001604051908101604052809291908181526020018280546109a7906115d3565b80156109f45780601f106109c9576101008083540402835291602001916109f4565b820191906000526020600020905b8154815290600101906020018083116109d757829003601f168201915b505050505090506000610a1260408051602081019091526000815290565b90508051600003610a24575092915050565b815115610a56578082604051602001610a3e9291906116ac565b60405160208183030381529060405292505050919050565b61070584610cc1565b61039c828260405180602001604052806000815250610d36565b6000828152600a60205260409020610a918282611723565b506040518281527ff8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce79060200160405180910390a15050565b60006001600160e01b0319821663780e9d6360e01b14806102d057506102d082610d4e565b8080610b0257506001600160a01b03821615155b15610bc4576000610b12846106b2565b90506001600160a01b03831615801590610b3e5750826001600160a01b0316816001600160a01b031614155b8015610b515750610b4f8184610621565b155b15610b7a5760405163a9fbf51f60e01b81526001600160a01b03841660048201526024016103c6565b8115610bc25783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5050600090815260046020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b600080610c02858585610d9e565b90506001600160a01b038116610c5f57610c5a84600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b610c82565b846001600160a01b0316816001600160a01b031614610c8257610c828185610e97565b6001600160a01b038516610c9e57610c9984610f18565b610705565b846001600160a01b0316816001600160a01b031614610705576107058585610fc7565b6060610ccc826106b2565b506000610ce460408051602081019091526000815290565b90506000815111610d045760405180602001604052806000815250610d2f565b80610d0e84611017565b604051602001610d1f9291906116ac565b6040516020818303038152906040525b9392505050565b610d4083836110aa565b6104b033600085858561082b565b60006001600160e01b031982166380ac58cd60e01b1480610d7f57506001600160e01b03198216635b5e139f60e01b145b806102d057506301ffc9a760e01b6001600160e01b03198316146102d0565b6000828152600260205260408120546001600160a01b0390811690831615610dcb57610dcb81848661110f565b6001600160a01b03811615610e0957610de8600085600080610aee565b6001600160a01b038116600090815260036020526040902080546000190190555b6001600160a01b03851615610e38576001600160a01b0385166000908152600360205260409020805460010190555b60008481526002602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6000610ea283610519565b6000838152600760209081526040808320546001600160a01b0388168452600690925290912091925090818314610ef957600083815260208281526040808320548584528184208190558352600790915290208290555b6000938452600760209081526040808620869055938552525081205550565b600854600090610f2a906001906117e3565b60008381526009602052604081205460088054939450909284908110610f5257610f5261160d565b906000526020600020015490508060088381548110610f7357610f7361160d565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480610fab57610fab6117f6565b6001900381819060005260206000200160009055905550505050565b60006001610fd484610519565b610fde91906117e3565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6060600061102483611173565b600101905060008167ffffffffffffffff81111561104457611044611436565b6040519080825280601f01601f19166020018201604052801561106e576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461107857509392505050565b6001600160a01b0382166110d457604051633250574960e11b8152600060048201526024016103c6565b60006110e2838360006106f8565b90506001600160a01b038116156104b0576040516339e3563760e11b8152600060048201526024016103c6565b61111a83838361124b565b6104b0576001600160a01b03831661114857604051637e27328960e01b8152600481018290526024016103c6565b60405163177e802f60e01b81526001600160a01b0383166004820152602481018290526044016103c6565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106111b25772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106111de576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106111fc57662386f26fc10000830492506010015b6305f5e1008310611214576305f5e100830492506008015b612710831061122857612710830492506004015b6064831061123a576064830492506002015b600a83106102d05760010192915050565b60006001600160a01b038316158015906107055750826001600160a01b0316846001600160a01b0316148061128557506112858484610621565b806107055750506000908152600460205260409020546001600160a01b03908116911614919050565b6001600160e01b03198116811461068a57600080fd5b6000602082840312156112d657600080fd5b8135610d2f816112ae565b60005b838110156112fc5781810151838201526020016112e4565b50506000910152565b6000815180845261131d8160208601602086016112e1565b601f01601f19169290920160200192915050565b602081526000610d2f6020830184611305565b60006020828403121561135657600080fd5b5035919050565b80356001600160a01b038116811461137457600080fd5b919050565b6000806040838503121561138c57600080fd5b6113958361135d565b946020939093013593505050565b6000806000606084860312156113b857600080fd5b6113c18461135d565b92506113cf6020850161135d565b9150604084013590509250925092565b6000602082840312156113f157600080fd5b610d2f8261135d565b6000806040838503121561140d57600080fd5b6114168361135d565b91506020830135801515811461142b57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561146757611467611436565b604051601f8501601f19908116603f0116810190828211818310171561148f5761148f611436565b816040528093508581528686860111156114a857600080fd5b858560208301376000602087830101525050509392505050565b600080600080608085870312156114d857600080fd5b6114e18561135d565b93506114ef6020860161135d565b925060408501359150606085013567ffffffffffffffff81111561151257600080fd5b8501601f8101871361152357600080fd5b6115328782356020840161144c565b91505092959194509250565b6000806040838503121561155157600080fd5b61155a8361135d565b9150602083013567ffffffffffffffff81111561157657600080fd5b8301601f8101851361158757600080fd5b6115968582356020840161144c565b9150509250929050565b600080604083850312156115b357600080fd5b6115bc8361135d565b91506115ca6020840161135d565b90509250929050565b600181811c908216806115e757607f821691505b60208210810361160757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820161164b5761164b611623565b5060010190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061168590830184611305565b9695505050505050565b6000602082840312156116a157600080fd5b8151610d2f816112ae565b600083516116be8184602088016112e1565b8351908301906116d28183602088016112e1565b01949350505050565b601f8211156104b0576000816000526020600020601f850160051c810160208610156117045750805b601f850160051c820191505b8181101561094d57828155600101611710565b815167ffffffffffffffff81111561173d5761173d611436565b6117518161174b84546115d3565b846116db565b602080601f831160018114611786576000841561176e5750858301515b600019600386901b1c1916600185901b17855561094d565b600085815260208120601f198616915b828110156117b557888601518255948401946001909101908401611796565b50858210156117d35787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b818103818111156102d0576102d0611623565b634e487b7160e01b600052603160045260246000fdfea26469706673582212209c27477b4cd33bb3fc0ef2ad868b9d6951e5088afa99ab59c12d425d3776350964736f6c63430008180033
third_party/real_code/rc17/provenance.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "rc17",
3
+ "chain": "base",
4
+ "address": "0x85ea801b2e74b99f743dc870dd07199003d47145",
5
+ "is_proxy": false,
6
+ "implementation": "",
7
+ "sourcify_match_type": "exact_match",
8
+ "fetched_utc_time": "2026-07-09T15:15:42Z",
9
+ "creation_hex_sha256": "9cf1039212a1425c79dc6a5edf88b8dffe0e87aceddc1172aa9f2b136b7a5b6e"
10
+ }
third_party/real_code/rc17/recipe.yaml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ steps:
2
+ - signer: deployer
3
+ deploy: $target
4
+ args:
5
+ - '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
6
+ - signer: deployer
7
+ to: $target
8
+ function: safeMint
9
+ args:
10
+ - $alice
11
+ - uri
third_party/real_code/rc17/sources/@openzeppelin/contracts/access/Ownable.sol ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {Context} from "../utils/Context.sol";
7
+
8
+ /**
9
+ * @dev Contract module which provides a basic access control mechanism, where
10
+ * there is an account (an owner) that can be granted exclusive access to
11
+ * specific functions.
12
+ *
13
+ * The initial owner is set to the address provided by the deployer. This can
14
+ * later be changed with {transferOwnership}.
15
+ *
16
+ * This module is used through inheritance. It will make available the modifier
17
+ * `onlyOwner`, which can be applied to your functions to restrict their use to
18
+ * the owner.
19
+ */
20
+ abstract contract Ownable is Context {
21
+ address private _owner;
22
+
23
+ /**
24
+ * @dev The caller account is not authorized to perform an operation.
25
+ */
26
+ error OwnableUnauthorizedAccount(address account);
27
+
28
+ /**
29
+ * @dev The owner is not a valid owner account. (eg. `address(0)`)
30
+ */
31
+ error OwnableInvalidOwner(address owner);
32
+
33
+ event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
34
+
35
+ /**
36
+ * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
37
+ */
38
+ constructor(address initialOwner) {
39
+ if (initialOwner == address(0)) {
40
+ revert OwnableInvalidOwner(address(0));
41
+ }
42
+ _transferOwnership(initialOwner);
43
+ }
44
+
45
+ /**
46
+ * @dev Throws if called by any account other than the owner.
47
+ */
48
+ modifier onlyOwner() {
49
+ _checkOwner();
50
+ _;
51
+ }
52
+
53
+ /**
54
+ * @dev Returns the address of the current owner.
55
+ */
56
+ function owner() public view virtual returns (address) {
57
+ return _owner;
58
+ }
59
+
60
+ /**
61
+ * @dev Throws if the sender is not the owner.
62
+ */
63
+ function _checkOwner() internal view virtual {
64
+ if (owner() != _msgSender()) {
65
+ revert OwnableUnauthorizedAccount(_msgSender());
66
+ }
67
+ }
68
+
69
+ /**
70
+ * @dev Leaves the contract without owner. It will not be possible to call
71
+ * `onlyOwner` functions. Can only be called by the current owner.
72
+ *
73
+ * NOTE: Renouncing ownership will leave the contract without an owner,
74
+ * thereby disabling any functionality that is only available to the owner.
75
+ */
76
+ function renounceOwnership() public virtual onlyOwner {
77
+ _transferOwnership(address(0));
78
+ }
79
+
80
+ /**
81
+ * @dev Transfers ownership of the contract to a new account (`newOwner`).
82
+ * Can only be called by the current owner.
83
+ */
84
+ function transferOwnership(address newOwner) public virtual onlyOwner {
85
+ if (newOwner == address(0)) {
86
+ revert OwnableInvalidOwner(address(0));
87
+ }
88
+ _transferOwnership(newOwner);
89
+ }
90
+
91
+ /**
92
+ * @dev Transfers ownership of the contract to a new account (`newOwner`).
93
+ * Internal function without access restriction.
94
+ */
95
+ function _transferOwnership(address newOwner) internal virtual {
96
+ address oldOwner = _owner;
97
+ _owner = newOwner;
98
+ emit OwnershipTransferred(oldOwner, newOwner);
99
+ }
100
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/interfaces/IERC165.sol ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {IERC165} from "../utils/introspection/IERC165.sol";
third_party/real_code/rc17/sources/@openzeppelin/contracts/interfaces/IERC4906.sol ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC4906.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {IERC165} from "./IERC165.sol";
7
+ import {IERC721} from "./IERC721.sol";
8
+
9
+ /// @title ERC-721 Metadata Update Extension
10
+ interface IERC4906 is IERC165, IERC721 {
11
+ /// @dev This event emits when the metadata of a token is changed.
12
+ /// So that the third-party platforms such as NFT market could
13
+ /// timely update the images and related attributes of the NFT.
14
+ event MetadataUpdate(uint256 _tokenId);
15
+
16
+ /// @dev This event emits when the metadata of a range of tokens is changed.
17
+ /// So that the third-party platforms such as NFT market could
18
+ /// timely update the images and related attributes of the NFTs.
19
+ event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
20
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/interfaces/IERC721.sol ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {IERC721} from "../token/ERC721/IERC721.sol";
third_party/real_code/rc17/sources/@openzeppelin/contracts/interfaces/draft-IERC6093.sol ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
3
+ pragma solidity ^0.8.20;
4
+
5
+ /**
6
+ * @dev Standard ERC-20 Errors
7
+ * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
8
+ */
9
+ interface IERC20Errors {
10
+ /**
11
+ * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
12
+ * @param sender Address whose tokens are being transferred.
13
+ * @param balance Current balance for the interacting account.
14
+ * @param needed Minimum amount required to perform a transfer.
15
+ */
16
+ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
17
+
18
+ /**
19
+ * @dev Indicates a failure with the token `sender`. Used in transfers.
20
+ * @param sender Address whose tokens are being transferred.
21
+ */
22
+ error ERC20InvalidSender(address sender);
23
+
24
+ /**
25
+ * @dev Indicates a failure with the token `receiver`. Used in transfers.
26
+ * @param receiver Address to which tokens are being transferred.
27
+ */
28
+ error ERC20InvalidReceiver(address receiver);
29
+
30
+ /**
31
+ * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
32
+ * @param spender Address that may be allowed to operate on tokens without being their owner.
33
+ * @param allowance Amount of tokens a `spender` is allowed to operate with.
34
+ * @param needed Minimum amount required to perform a transfer.
35
+ */
36
+ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
37
+
38
+ /**
39
+ * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
40
+ * @param approver Address initiating an approval operation.
41
+ */
42
+ error ERC20InvalidApprover(address approver);
43
+
44
+ /**
45
+ * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
46
+ * @param spender Address that may be allowed to operate on tokens without being their owner.
47
+ */
48
+ error ERC20InvalidSpender(address spender);
49
+ }
50
+
51
+ /**
52
+ * @dev Standard ERC-721 Errors
53
+ * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
54
+ */
55
+ interface IERC721Errors {
56
+ /**
57
+ * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
58
+ * Used in balance queries.
59
+ * @param owner Address of the current owner of a token.
60
+ */
61
+ error ERC721InvalidOwner(address owner);
62
+
63
+ /**
64
+ * @dev Indicates a `tokenId` whose `owner` is the zero address.
65
+ * @param tokenId Identifier number of a token.
66
+ */
67
+ error ERC721NonexistentToken(uint256 tokenId);
68
+
69
+ /**
70
+ * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
71
+ * @param sender Address whose tokens are being transferred.
72
+ * @param tokenId Identifier number of a token.
73
+ * @param owner Address of the current owner of a token.
74
+ */
75
+ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
76
+
77
+ /**
78
+ * @dev Indicates a failure with the token `sender`. Used in transfers.
79
+ * @param sender Address whose tokens are being transferred.
80
+ */
81
+ error ERC721InvalidSender(address sender);
82
+
83
+ /**
84
+ * @dev Indicates a failure with the token `receiver`. Used in transfers.
85
+ * @param receiver Address to which tokens are being transferred.
86
+ */
87
+ error ERC721InvalidReceiver(address receiver);
88
+
89
+ /**
90
+ * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
91
+ * @param operator Address that may be allowed to operate on tokens without being their owner.
92
+ * @param tokenId Identifier number of a token.
93
+ */
94
+ error ERC721InsufficientApproval(address operator, uint256 tokenId);
95
+
96
+ /**
97
+ * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
98
+ * @param approver Address initiating an approval operation.
99
+ */
100
+ error ERC721InvalidApprover(address approver);
101
+
102
+ /**
103
+ * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
104
+ * @param operator Address that may be allowed to operate on tokens without being their owner.
105
+ */
106
+ error ERC721InvalidOperator(address operator);
107
+ }
108
+
109
+ /**
110
+ * @dev Standard ERC-1155 Errors
111
+ * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
112
+ */
113
+ interface IERC1155Errors {
114
+ /**
115
+ * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
116
+ * @param sender Address whose tokens are being transferred.
117
+ * @param balance Current balance for the interacting account.
118
+ * @param needed Minimum amount required to perform a transfer.
119
+ * @param tokenId Identifier number of a token.
120
+ */
121
+ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
122
+
123
+ /**
124
+ * @dev Indicates a failure with the token `sender`. Used in transfers.
125
+ * @param sender Address whose tokens are being transferred.
126
+ */
127
+ error ERC1155InvalidSender(address sender);
128
+
129
+ /**
130
+ * @dev Indicates a failure with the token `receiver`. Used in transfers.
131
+ * @param receiver Address to which tokens are being transferred.
132
+ */
133
+ error ERC1155InvalidReceiver(address receiver);
134
+
135
+ /**
136
+ * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
137
+ * @param operator Address that may be allowed to operate on tokens without being their owner.
138
+ * @param owner Address of the current owner of a token.
139
+ */
140
+ error ERC1155MissingApprovalForAll(address operator, address owner);
141
+
142
+ /**
143
+ * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
144
+ * @param approver Address initiating an approval operation.
145
+ */
146
+ error ERC1155InvalidApprover(address approver);
147
+
148
+ /**
149
+ * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
150
+ * @param operator Address that may be allowed to operate on tokens without being their owner.
151
+ */
152
+ error ERC1155InvalidOperator(address operator);
153
+
154
+ /**
155
+ * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
156
+ * Used in batch transfers.
157
+ * @param idsLength Length of the array of token identifiers
158
+ * @param valuesLength Length of the array of token amounts
159
+ */
160
+ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
161
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/ERC721.sol ADDED
@@ -0,0 +1,456 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/ERC721.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {IERC721} from "./IERC721.sol";
7
+ import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
8
+ import {ERC721Utils} from "./utils/ERC721Utils.sol";
9
+ import {Context} from "../../utils/Context.sol";
10
+ import {Strings} from "../../utils/Strings.sol";
11
+ import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
12
+ import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol";
13
+
14
+ /**
15
+ * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including
16
+ * the Metadata extension, but not including the Enumerable extension, which is available separately as
17
+ * {ERC721Enumerable}.
18
+ */
19
+ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors {
20
+ using Strings for uint256;
21
+
22
+ // Token name
23
+ string private _name;
24
+
25
+ // Token symbol
26
+ string private _symbol;
27
+
28
+ mapping(uint256 tokenId => address) private _owners;
29
+
30
+ mapping(address owner => uint256) private _balances;
31
+
32
+ mapping(uint256 tokenId => address) private _tokenApprovals;
33
+
34
+ mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;
35
+
36
+ /**
37
+ * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
38
+ */
39
+ constructor(string memory name_, string memory symbol_) {
40
+ _name = name_;
41
+ _symbol = symbol_;
42
+ }
43
+
44
+ /**
45
+ * @dev See {IERC165-supportsInterface}.
46
+ */
47
+ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
48
+ return
49
+ interfaceId == type(IERC721).interfaceId ||
50
+ interfaceId == type(IERC721Metadata).interfaceId ||
51
+ super.supportsInterface(interfaceId);
52
+ }
53
+
54
+ /**
55
+ * @dev See {IERC721-balanceOf}.
56
+ */
57
+ function balanceOf(address owner) public view virtual returns (uint256) {
58
+ if (owner == address(0)) {
59
+ revert ERC721InvalidOwner(address(0));
60
+ }
61
+ return _balances[owner];
62
+ }
63
+
64
+ /**
65
+ * @dev See {IERC721-ownerOf}.
66
+ */
67
+ function ownerOf(uint256 tokenId) public view virtual returns (address) {
68
+ return _requireOwned(tokenId);
69
+ }
70
+
71
+ /**
72
+ * @dev See {IERC721Metadata-name}.
73
+ */
74
+ function name() public view virtual returns (string memory) {
75
+ return _name;
76
+ }
77
+
78
+ /**
79
+ * @dev See {IERC721Metadata-symbol}.
80
+ */
81
+ function symbol() public view virtual returns (string memory) {
82
+ return _symbol;
83
+ }
84
+
85
+ /**
86
+ * @dev See {IERC721Metadata-tokenURI}.
87
+ */
88
+ function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
89
+ _requireOwned(tokenId);
90
+
91
+ string memory baseURI = _baseURI();
92
+ return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
93
+ }
94
+
95
+ /**
96
+ * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
97
+ * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
98
+ * by default, can be overridden in child contracts.
99
+ */
100
+ function _baseURI() internal view virtual returns (string memory) {
101
+ return "";
102
+ }
103
+
104
+ /**
105
+ * @dev See {IERC721-approve}.
106
+ */
107
+ function approve(address to, uint256 tokenId) public virtual {
108
+ _approve(to, tokenId, _msgSender());
109
+ }
110
+
111
+ /**
112
+ * @dev See {IERC721-getApproved}.
113
+ */
114
+ function getApproved(uint256 tokenId) public view virtual returns (address) {
115
+ _requireOwned(tokenId);
116
+
117
+ return _getApproved(tokenId);
118
+ }
119
+
120
+ /**
121
+ * @dev See {IERC721-setApprovalForAll}.
122
+ */
123
+ function setApprovalForAll(address operator, bool approved) public virtual {
124
+ _setApprovalForAll(_msgSender(), operator, approved);
125
+ }
126
+
127
+ /**
128
+ * @dev See {IERC721-isApprovedForAll}.
129
+ */
130
+ function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
131
+ return _operatorApprovals[owner][operator];
132
+ }
133
+
134
+ /**
135
+ * @dev See {IERC721-transferFrom}.
136
+ */
137
+ function transferFrom(address from, address to, uint256 tokenId) public virtual {
138
+ if (to == address(0)) {
139
+ revert ERC721InvalidReceiver(address(0));
140
+ }
141
+ // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
142
+ // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
143
+ address previousOwner = _update(to, tokenId, _msgSender());
144
+ if (previousOwner != from) {
145
+ revert ERC721IncorrectOwner(from, tokenId, previousOwner);
146
+ }
147
+ }
148
+
149
+ /**
150
+ * @dev See {IERC721-safeTransferFrom}.
151
+ */
152
+ function safeTransferFrom(address from, address to, uint256 tokenId) public {
153
+ safeTransferFrom(from, to, tokenId, "");
154
+ }
155
+
156
+ /**
157
+ * @dev See {IERC721-safeTransferFrom}.
158
+ */
159
+ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
160
+ transferFrom(from, to, tokenId);
161
+ ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
162
+ }
163
+
164
+ /**
165
+ * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
166
+ *
167
+ * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
168
+ * core ERC-721 logic MUST be matched with the use of {_increaseBalance} to keep balances
169
+ * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
170
+ * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
171
+ */
172
+ function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
173
+ return _owners[tokenId];
174
+ }
175
+
176
+ /**
177
+ * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
178
+ */
179
+ function _getApproved(uint256 tokenId) internal view virtual returns (address) {
180
+ return _tokenApprovals[tokenId];
181
+ }
182
+
183
+ /**
184
+ * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
185
+ * particular (ignoring whether it is owned by `owner`).
186
+ *
187
+ * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
188
+ * assumption.
189
+ */
190
+ function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
191
+ return
192
+ spender != address(0) &&
193
+ (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
194
+ }
195
+
196
+ /**
197
+ * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
198
+ * Reverts if:
199
+ * - `spender` does not have approval from `owner` for `tokenId`.
200
+ * - `spender` does not have approval to manage all of `owner`'s assets.
201
+ *
202
+ * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
203
+ * assumption.
204
+ */
205
+ function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
206
+ if (!_isAuthorized(owner, spender, tokenId)) {
207
+ if (owner == address(0)) {
208
+ revert ERC721NonexistentToken(tokenId);
209
+ } else {
210
+ revert ERC721InsufficientApproval(spender, tokenId);
211
+ }
212
+ }
213
+ }
214
+
215
+ /**
216
+ * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
217
+ *
218
+ * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
219
+ * a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
220
+ *
221
+ * WARNING: Increasing an account's balance using this function tends to be paired with an override of the
222
+ * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
223
+ * remain consistent with one another.
224
+ */
225
+ function _increaseBalance(address account, uint128 value) internal virtual {
226
+ unchecked {
227
+ _balances[account] += value;
228
+ }
229
+ }
230
+
231
+ /**
232
+ * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
233
+ * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
234
+ *
235
+ * The `auth` argument is optional. If the value passed is non 0, then this function will check that
236
+ * `auth` is either the owner of the token, or approved to operate on the token (by the owner).
237
+ *
238
+ * Emits a {Transfer} event.
239
+ *
240
+ * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
241
+ */
242
+ function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
243
+ address from = _ownerOf(tokenId);
244
+
245
+ // Perform (optional) operator check
246
+ if (auth != address(0)) {
247
+ _checkAuthorized(from, auth, tokenId);
248
+ }
249
+
250
+ // Execute the update
251
+ if (from != address(0)) {
252
+ // Clear approval. No need to re-authorize or emit the Approval event
253
+ _approve(address(0), tokenId, address(0), false);
254
+
255
+ unchecked {
256
+ _balances[from] -= 1;
257
+ }
258
+ }
259
+
260
+ if (to != address(0)) {
261
+ unchecked {
262
+ _balances[to] += 1;
263
+ }
264
+ }
265
+
266
+ _owners[tokenId] = to;
267
+
268
+ emit Transfer(from, to, tokenId);
269
+
270
+ return from;
271
+ }
272
+
273
+ /**
274
+ * @dev Mints `tokenId` and transfers it to `to`.
275
+ *
276
+ * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
277
+ *
278
+ * Requirements:
279
+ *
280
+ * - `tokenId` must not exist.
281
+ * - `to` cannot be the zero address.
282
+ *
283
+ * Emits a {Transfer} event.
284
+ */
285
+ function _mint(address to, uint256 tokenId) internal {
286
+ if (to == address(0)) {
287
+ revert ERC721InvalidReceiver(address(0));
288
+ }
289
+ address previousOwner = _update(to, tokenId, address(0));
290
+ if (previousOwner != address(0)) {
291
+ revert ERC721InvalidSender(address(0));
292
+ }
293
+ }
294
+
295
+ /**
296
+ * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.
297
+ *
298
+ * Requirements:
299
+ *
300
+ * - `tokenId` must not exist.
301
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
302
+ *
303
+ * Emits a {Transfer} event.
304
+ */
305
+ function _safeMint(address to, uint256 tokenId) internal {
306
+ _safeMint(to, tokenId, "");
307
+ }
308
+
309
+ /**
310
+ * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
311
+ * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
312
+ */
313
+ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
314
+ _mint(to, tokenId);
315
+ ERC721Utils.checkOnERC721Received(_msgSender(), address(0), to, tokenId, data);
316
+ }
317
+
318
+ /**
319
+ * @dev Destroys `tokenId`.
320
+ * The approval is cleared when the token is burned.
321
+ * This is an internal function that does not check if the sender is authorized to operate on the token.
322
+ *
323
+ * Requirements:
324
+ *
325
+ * - `tokenId` must exist.
326
+ *
327
+ * Emits a {Transfer} event.
328
+ */
329
+ function _burn(uint256 tokenId) internal {
330
+ address previousOwner = _update(address(0), tokenId, address(0));
331
+ if (previousOwner == address(0)) {
332
+ revert ERC721NonexistentToken(tokenId);
333
+ }
334
+ }
335
+
336
+ /**
337
+ * @dev Transfers `tokenId` from `from` to `to`.
338
+ * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
339
+ *
340
+ * Requirements:
341
+ *
342
+ * - `to` cannot be the zero address.
343
+ * - `tokenId` token must be owned by `from`.
344
+ *
345
+ * Emits a {Transfer} event.
346
+ */
347
+ function _transfer(address from, address to, uint256 tokenId) internal {
348
+ if (to == address(0)) {
349
+ revert ERC721InvalidReceiver(address(0));
350
+ }
351
+ address previousOwner = _update(to, tokenId, address(0));
352
+ if (previousOwner == address(0)) {
353
+ revert ERC721NonexistentToken(tokenId);
354
+ } else if (previousOwner != from) {
355
+ revert ERC721IncorrectOwner(from, tokenId, previousOwner);
356
+ }
357
+ }
358
+
359
+ /**
360
+ * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
361
+ * are aware of the ERC-721 standard to prevent tokens from being forever locked.
362
+ *
363
+ * `data` is additional data, it has no specified format and it is sent in call to `to`.
364
+ *
365
+ * This internal function is like {safeTransferFrom} in the sense that it invokes
366
+ * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
367
+ * implement alternative mechanisms to perform token transfer, such as signature-based.
368
+ *
369
+ * Requirements:
370
+ *
371
+ * - `tokenId` token must exist and be owned by `from`.
372
+ * - `to` cannot be the zero address.
373
+ * - `from` cannot be the zero address.
374
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
375
+ *
376
+ * Emits a {Transfer} event.
377
+ */
378
+ function _safeTransfer(address from, address to, uint256 tokenId) internal {
379
+ _safeTransfer(from, to, tokenId, "");
380
+ }
381
+
382
+ /**
383
+ * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
384
+ * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
385
+ */
386
+ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
387
+ _transfer(from, to, tokenId);
388
+ ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
389
+ }
390
+
391
+ /**
392
+ * @dev Approve `to` to operate on `tokenId`
393
+ *
394
+ * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
395
+ * either the owner of the token, or approved to operate on all tokens held by this owner.
396
+ *
397
+ * Emits an {Approval} event.
398
+ *
399
+ * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
400
+ */
401
+ function _approve(address to, uint256 tokenId, address auth) internal {
402
+ _approve(to, tokenId, auth, true);
403
+ }
404
+
405
+ /**
406
+ * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
407
+ * emitted in the context of transfers.
408
+ */
409
+ function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
410
+ // Avoid reading the owner unless necessary
411
+ if (emitEvent || auth != address(0)) {
412
+ address owner = _requireOwned(tokenId);
413
+
414
+ // We do not use _isAuthorized because single-token approvals should not be able to call approve
415
+ if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
416
+ revert ERC721InvalidApprover(auth);
417
+ }
418
+
419
+ if (emitEvent) {
420
+ emit Approval(owner, to, tokenId);
421
+ }
422
+ }
423
+
424
+ _tokenApprovals[tokenId] = to;
425
+ }
426
+
427
+ /**
428
+ * @dev Approve `operator` to operate on all of `owner` tokens
429
+ *
430
+ * Requirements:
431
+ * - operator can't be the address zero.
432
+ *
433
+ * Emits an {ApprovalForAll} event.
434
+ */
435
+ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
436
+ if (operator == address(0)) {
437
+ revert ERC721InvalidOperator(operator);
438
+ }
439
+ _operatorApprovals[owner][operator] = approved;
440
+ emit ApprovalForAll(owner, operator, approved);
441
+ }
442
+
443
+ /**
444
+ * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
445
+ * Returns the owner.
446
+ *
447
+ * Overrides to ownership logic should be done to {_ownerOf}.
448
+ */
449
+ function _requireOwned(uint256 tokenId) internal view returns (address) {
450
+ address owner = _ownerOf(tokenId);
451
+ if (owner == address(0)) {
452
+ revert ERC721NonexistentToken(tokenId);
453
+ }
454
+ return owner;
455
+ }
456
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/IERC721.sol ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {IERC165} from "../../utils/introspection/IERC165.sol";
7
+
8
+ /**
9
+ * @dev Required interface of an ERC-721 compliant contract.
10
+ */
11
+ interface IERC721 is IERC165 {
12
+ /**
13
+ * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
14
+ */
15
+ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
16
+
17
+ /**
18
+ * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
19
+ */
20
+ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
21
+
22
+ /**
23
+ * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
24
+ */
25
+ event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
26
+
27
+ /**
28
+ * @dev Returns the number of tokens in ``owner``'s account.
29
+ */
30
+ function balanceOf(address owner) external view returns (uint256 balance);
31
+
32
+ /**
33
+ * @dev Returns the owner of the `tokenId` token.
34
+ *
35
+ * Requirements:
36
+ *
37
+ * - `tokenId` must exist.
38
+ */
39
+ function ownerOf(uint256 tokenId) external view returns (address owner);
40
+
41
+ /**
42
+ * @dev Safely transfers `tokenId` token from `from` to `to`.
43
+ *
44
+ * Requirements:
45
+ *
46
+ * - `from` cannot be the zero address.
47
+ * - `to` cannot be the zero address.
48
+ * - `tokenId` token must exist and be owned by `from`.
49
+ * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
50
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
51
+ * a safe transfer.
52
+ *
53
+ * Emits a {Transfer} event.
54
+ */
55
+ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
56
+
57
+ /**
58
+ * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
59
+ * are aware of the ERC-721 protocol to prevent tokens from being forever locked.
60
+ *
61
+ * Requirements:
62
+ *
63
+ * - `from` cannot be the zero address.
64
+ * - `to` cannot be the zero address.
65
+ * - `tokenId` token must exist and be owned by `from`.
66
+ * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
67
+ * {setApprovalForAll}.
68
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
69
+ * a safe transfer.
70
+ *
71
+ * Emits a {Transfer} event.
72
+ */
73
+ function safeTransferFrom(address from, address to, uint256 tokenId) external;
74
+
75
+ /**
76
+ * @dev Transfers `tokenId` token from `from` to `to`.
77
+ *
78
+ * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
79
+ * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
80
+ * understand this adds an external call which potentially creates a reentrancy vulnerability.
81
+ *
82
+ * Requirements:
83
+ *
84
+ * - `from` cannot be the zero address.
85
+ * - `to` cannot be the zero address.
86
+ * - `tokenId` token must be owned by `from`.
87
+ * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
88
+ *
89
+ * Emits a {Transfer} event.
90
+ */
91
+ function transferFrom(address from, address to, uint256 tokenId) external;
92
+
93
+ /**
94
+ * @dev Gives permission to `to` to transfer `tokenId` token to another account.
95
+ * The approval is cleared when the token is transferred.
96
+ *
97
+ * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
98
+ *
99
+ * Requirements:
100
+ *
101
+ * - The caller must own the token or be an approved operator.
102
+ * - `tokenId` must exist.
103
+ *
104
+ * Emits an {Approval} event.
105
+ */
106
+ function approve(address to, uint256 tokenId) external;
107
+
108
+ /**
109
+ * @dev Approve or remove `operator` as an operator for the caller.
110
+ * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
111
+ *
112
+ * Requirements:
113
+ *
114
+ * - The `operator` cannot be the address zero.
115
+ *
116
+ * Emits an {ApprovalForAll} event.
117
+ */
118
+ function setApprovalForAll(address operator, bool approved) external;
119
+
120
+ /**
121
+ * @dev Returns the account approved for `tokenId` token.
122
+ *
123
+ * Requirements:
124
+ *
125
+ * - `tokenId` must exist.
126
+ */
127
+ function getApproved(uint256 tokenId) external view returns (address operator);
128
+
129
+ /**
130
+ * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
131
+ *
132
+ * See {setApprovalForAll}
133
+ */
134
+ function isApprovedForAll(address owner, address operator) external view returns (bool);
135
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ /**
7
+ * @title ERC-721 token receiver interface
8
+ * @dev Interface for any contract that wants to support safeTransfers
9
+ * from ERC-721 asset contracts.
10
+ */
11
+ interface IERC721Receiver {
12
+ /**
13
+ * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
14
+ * by `operator` from `from`, this function is called.
15
+ *
16
+ * It must return its Solidity selector to confirm the token transfer.
17
+ * If any other value is returned or the interface is not implemented by the recipient, the transfer will be
18
+ * reverted.
19
+ *
20
+ * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
21
+ */
22
+ function onERC721Received(
23
+ address operator,
24
+ address from,
25
+ uint256 tokenId,
26
+ bytes calldata data
27
+ ) external returns (bytes4);
28
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/extensions/ERC721Enumerable.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {ERC721} from "../ERC721.sol";
7
+ import {IERC721Enumerable} from "./IERC721Enumerable.sol";
8
+ import {IERC165} from "../../../utils/introspection/ERC165.sol";
9
+
10
+ /**
11
+ * @dev This implements an optional extension of {ERC721} defined in the ERC that adds enumerability
12
+ * of all the token ids in the contract as well as all token ids owned by each account.
13
+ *
14
+ * CAUTION: {ERC721} extensions that implement custom `balanceOf` logic, such as {ERC721Consecutive},
15
+ * interfere with enumerability and should not be used together with {ERC721Enumerable}.
16
+ */
17
+ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
18
+ mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens;
19
+ mapping(uint256 tokenId => uint256) private _ownedTokensIndex;
20
+
21
+ uint256[] private _allTokens;
22
+ mapping(uint256 tokenId => uint256) private _allTokensIndex;
23
+
24
+ /**
25
+ * @dev An `owner`'s token query was out of bounds for `index`.
26
+ *
27
+ * NOTE: The owner being `address(0)` indicates a global out of bounds index.
28
+ */
29
+ error ERC721OutOfBoundsIndex(address owner, uint256 index);
30
+
31
+ /**
32
+ * @dev Batch mint is not allowed.
33
+ */
34
+ error ERC721EnumerableForbiddenBatchMint();
35
+
36
+ /**
37
+ * @dev See {IERC165-supportsInterface}.
38
+ */
39
+ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
40
+ return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
41
+ }
42
+
43
+ /**
44
+ * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
45
+ */
46
+ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) {
47
+ if (index >= balanceOf(owner)) {
48
+ revert ERC721OutOfBoundsIndex(owner, index);
49
+ }
50
+ return _ownedTokens[owner][index];
51
+ }
52
+
53
+ /**
54
+ * @dev See {IERC721Enumerable-totalSupply}.
55
+ */
56
+ function totalSupply() public view virtual returns (uint256) {
57
+ return _allTokens.length;
58
+ }
59
+
60
+ /**
61
+ * @dev See {IERC721Enumerable-tokenByIndex}.
62
+ */
63
+ function tokenByIndex(uint256 index) public view virtual returns (uint256) {
64
+ if (index >= totalSupply()) {
65
+ revert ERC721OutOfBoundsIndex(address(0), index);
66
+ }
67
+ return _allTokens[index];
68
+ }
69
+
70
+ /**
71
+ * @dev See {ERC721-_update}.
72
+ */
73
+ function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {
74
+ address previousOwner = super._update(to, tokenId, auth);
75
+
76
+ if (previousOwner == address(0)) {
77
+ _addTokenToAllTokensEnumeration(tokenId);
78
+ } else if (previousOwner != to) {
79
+ _removeTokenFromOwnerEnumeration(previousOwner, tokenId);
80
+ }
81
+ if (to == address(0)) {
82
+ _removeTokenFromAllTokensEnumeration(tokenId);
83
+ } else if (previousOwner != to) {
84
+ _addTokenToOwnerEnumeration(to, tokenId);
85
+ }
86
+
87
+ return previousOwner;
88
+ }
89
+
90
+ /**
91
+ * @dev Private function to add a token to this extension's ownership-tracking data structures.
92
+ * @param to address representing the new owner of the given token ID
93
+ * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
94
+ */
95
+ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
96
+ uint256 length = balanceOf(to) - 1;
97
+ _ownedTokens[to][length] = tokenId;
98
+ _ownedTokensIndex[tokenId] = length;
99
+ }
100
+
101
+ /**
102
+ * @dev Private function to add a token to this extension's token tracking data structures.
103
+ * @param tokenId uint256 ID of the token to be added to the tokens list
104
+ */
105
+ function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
106
+ _allTokensIndex[tokenId] = _allTokens.length;
107
+ _allTokens.push(tokenId);
108
+ }
109
+
110
+ /**
111
+ * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
112
+ * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
113
+ * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
114
+ * This has O(1) time complexity, but alters the order of the _ownedTokens array.
115
+ * @param from address representing the previous owner of the given token ID
116
+ * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
117
+ */
118
+ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
119
+ // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
120
+ // then delete the last slot (swap and pop).
121
+
122
+ uint256 lastTokenIndex = balanceOf(from);
123
+ uint256 tokenIndex = _ownedTokensIndex[tokenId];
124
+
125
+ mapping(uint256 index => uint256) storage _ownedTokensByOwner = _ownedTokens[from];
126
+
127
+ // When the token to delete is the last token, the swap operation is unnecessary
128
+ if (tokenIndex != lastTokenIndex) {
129
+ uint256 lastTokenId = _ownedTokensByOwner[lastTokenIndex];
130
+
131
+ _ownedTokensByOwner[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
132
+ _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
133
+ }
134
+
135
+ // This also deletes the contents at the last position of the array
136
+ delete _ownedTokensIndex[tokenId];
137
+ delete _ownedTokensByOwner[lastTokenIndex];
138
+ }
139
+
140
+ /**
141
+ * @dev Private function to remove a token from this extension's token tracking data structures.
142
+ * This has O(1) time complexity, but alters the order of the _allTokens array.
143
+ * @param tokenId uint256 ID of the token to be removed from the tokens list
144
+ */
145
+ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
146
+ // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
147
+ // then delete the last slot (swap and pop).
148
+
149
+ uint256 lastTokenIndex = _allTokens.length - 1;
150
+ uint256 tokenIndex = _allTokensIndex[tokenId];
151
+
152
+ // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
153
+ // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
154
+ // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
155
+ uint256 lastTokenId = _allTokens[lastTokenIndex];
156
+
157
+ _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
158
+ _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
159
+
160
+ // This also deletes the contents at the last position of the array
161
+ delete _allTokensIndex[tokenId];
162
+ _allTokens.pop();
163
+ }
164
+
165
+ /**
166
+ * See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch
167
+ */
168
+ function _increaseBalance(address account, uint128 amount) internal virtual override {
169
+ if (amount > 0) {
170
+ revert ERC721EnumerableForbiddenBatchMint();
171
+ }
172
+ super._increaseBalance(account, amount);
173
+ }
174
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.3.0) (token/ERC721/extensions/ERC721URIStorage.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {ERC721} from "../ERC721.sol";
7
+ import {Strings} from "../../../utils/Strings.sol";
8
+ import {IERC4906} from "../../../interfaces/IERC4906.sol";
9
+ import {IERC165} from "../../../interfaces/IERC165.sol";
10
+
11
+ /**
12
+ * @dev ERC-721 token with storage based token URI management.
13
+ */
14
+ abstract contract ERC721URIStorage is IERC4906, ERC721 {
15
+ using Strings for uint256;
16
+
17
+ // Interface ID as defined in ERC-4906. This does not correspond to a traditional interface ID as ERC-4906 only
18
+ // defines events and does not include any external function.
19
+ bytes4 private constant ERC4906_INTERFACE_ID = bytes4(0x49064906);
20
+
21
+ // Optional mapping for token URIs
22
+ mapping(uint256 tokenId => string) private _tokenURIs;
23
+
24
+ /**
25
+ * @dev See {IERC165-supportsInterface}
26
+ */
27
+ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool) {
28
+ return interfaceId == ERC4906_INTERFACE_ID || super.supportsInterface(interfaceId);
29
+ }
30
+
31
+ /**
32
+ * @dev See {IERC721Metadata-tokenURI}.
33
+ */
34
+ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
35
+ _requireOwned(tokenId);
36
+
37
+ string memory _tokenURI = _tokenURIs[tokenId];
38
+ string memory base = _baseURI();
39
+
40
+ // If there is no base URI, return the token URI.
41
+ if (bytes(base).length == 0) {
42
+ return _tokenURI;
43
+ }
44
+ // If both are set, concatenate the baseURI and tokenURI (via string.concat).
45
+ if (bytes(_tokenURI).length > 0) {
46
+ return string.concat(base, _tokenURI);
47
+ }
48
+
49
+ return super.tokenURI(tokenId);
50
+ }
51
+
52
+ /**
53
+ * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
54
+ *
55
+ * Emits {IERC4906-MetadataUpdate}.
56
+ */
57
+ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
58
+ _tokenURIs[tokenId] = _tokenURI;
59
+ emit MetadataUpdate(tokenId);
60
+ }
61
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {IERC721} from "../IERC721.sol";
7
+
8
+ /**
9
+ * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
10
+ * @dev See https://eips.ethereum.org/EIPS/eip-721
11
+ */
12
+ interface IERC721Enumerable is IERC721 {
13
+ /**
14
+ * @dev Returns the total amount of tokens stored by the contract.
15
+ */
16
+ function totalSupply() external view returns (uint256);
17
+
18
+ /**
19
+ * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
20
+ * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
21
+ */
22
+ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
23
+
24
+ /**
25
+ * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
26
+ * Use along with {totalSupply} to enumerate all tokens.
27
+ */
28
+ function tokenByIndex(uint256 index) external view returns (uint256);
29
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {IERC721} from "../IERC721.sol";
7
+
8
+ /**
9
+ * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
10
+ * @dev See https://eips.ethereum.org/EIPS/eip-721
11
+ */
12
+ interface IERC721Metadata is IERC721 {
13
+ /**
14
+ * @dev Returns the token collection name.
15
+ */
16
+ function name() external view returns (string memory);
17
+
18
+ /**
19
+ * @dev Returns the token collection symbol.
20
+ */
21
+ function symbol() external view returns (string memory);
22
+
23
+ /**
24
+ * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
25
+ */
26
+ function tokenURI(uint256 tokenId) external view returns (string memory);
27
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.3.0) (token/ERC721/utils/ERC721Utils.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {IERC721Receiver} from "../IERC721Receiver.sol";
7
+ import {IERC721Errors} from "../../../interfaces/draft-IERC6093.sol";
8
+
9
+ /**
10
+ * @dev Library that provide common ERC-721 utility functions.
11
+ *
12
+ * See https://eips.ethereum.org/EIPS/eip-721[ERC-721].
13
+ *
14
+ * _Available since v5.1._
15
+ */
16
+ library ERC721Utils {
17
+ /**
18
+ * @dev Performs an acceptance check for the provided `operator` by calling {IERC721Receiver-onERC721Received}
19
+ * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
20
+ *
21
+ * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
22
+ * Otherwise, the recipient must implement {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept
23
+ * the transfer.
24
+ */
25
+ function checkOnERC721Received(
26
+ address operator,
27
+ address from,
28
+ address to,
29
+ uint256 tokenId,
30
+ bytes memory data
31
+ ) internal {
32
+ if (to.code.length > 0) {
33
+ try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) {
34
+ if (retval != IERC721Receiver.onERC721Received.selector) {
35
+ // Token rejected
36
+ revert IERC721Errors.ERC721InvalidReceiver(to);
37
+ }
38
+ } catch (bytes memory reason) {
39
+ if (reason.length == 0) {
40
+ // non-IERC721Receiver implementer
41
+ revert IERC721Errors.ERC721InvalidReceiver(to);
42
+ } else {
43
+ assembly ("memory-safe") {
44
+ revert(add(32, reason), mload(reason))
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/Context.sol ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ /**
7
+ * @dev Provides information about the current execution context, including the
8
+ * sender of the transaction and its data. While these are generally available
9
+ * via msg.sender and msg.data, they should not be accessed in such a direct
10
+ * manner, since when dealing with meta-transactions the account sending and
11
+ * paying for execution may not be the actual sender (as far as an application
12
+ * is concerned).
13
+ *
14
+ * This contract is only required for intermediate, library-like contracts.
15
+ */
16
+ abstract contract Context {
17
+ function _msgSender() internal view virtual returns (address) {
18
+ return msg.sender;
19
+ }
20
+
21
+ function _msgData() internal view virtual returns (bytes calldata) {
22
+ return msg.data;
23
+ }
24
+
25
+ function _contextSuffixLength() internal view virtual returns (uint256) {
26
+ return 0;
27
+ }
28
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/Panic.sol ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ /**
7
+ * @dev Helper library for emitting standardized panic codes.
8
+ *
9
+ * ```solidity
10
+ * contract Example {
11
+ * using Panic for uint256;
12
+ *
13
+ * // Use any of the declared internal constants
14
+ * function foo() { Panic.GENERIC.panic(); }
15
+ *
16
+ * // Alternatively
17
+ * function foo() { Panic.panic(Panic.GENERIC); }
18
+ * }
19
+ * ```
20
+ *
21
+ * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
22
+ *
23
+ * _Available since v5.1._
24
+ */
25
+ // slither-disable-next-line unused-state
26
+ library Panic {
27
+ /// @dev generic / unspecified error
28
+ uint256 internal constant GENERIC = 0x00;
29
+ /// @dev used by the assert() builtin
30
+ uint256 internal constant ASSERT = 0x01;
31
+ /// @dev arithmetic underflow or overflow
32
+ uint256 internal constant UNDER_OVERFLOW = 0x11;
33
+ /// @dev division or modulo by zero
34
+ uint256 internal constant DIVISION_BY_ZERO = 0x12;
35
+ /// @dev enum conversion error
36
+ uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
37
+ /// @dev invalid encoding in storage
38
+ uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
39
+ /// @dev empty array pop
40
+ uint256 internal constant EMPTY_ARRAY_POP = 0x31;
41
+ /// @dev array out of bounds access
42
+ uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
43
+ /// @dev resource error (too large allocation or too large array)
44
+ uint256 internal constant RESOURCE_ERROR = 0x41;
45
+ /// @dev calling invalid internal function
46
+ uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
47
+
48
+ /// @dev Reverts with a panic code. Recommended to use with
49
+ /// the internal constants with predefined codes.
50
+ function panic(uint256 code) internal pure {
51
+ assembly ("memory-safe") {
52
+ mstore(0x00, 0x4e487b71)
53
+ mstore(0x20, code)
54
+ revert(0x1c, 0x24)
55
+ }
56
+ }
57
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/Strings.sol ADDED
@@ -0,0 +1,490 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.3.0) (utils/Strings.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {Math} from "./math/Math.sol";
7
+ import {SafeCast} from "./math/SafeCast.sol";
8
+ import {SignedMath} from "./math/SignedMath.sol";
9
+
10
+ /**
11
+ * @dev String operations.
12
+ */
13
+ library Strings {
14
+ using SafeCast for *;
15
+
16
+ bytes16 private constant HEX_DIGITS = "0123456789abcdef";
17
+ uint8 private constant ADDRESS_LENGTH = 20;
18
+ uint256 private constant SPECIAL_CHARS_LOOKUP =
19
+ (1 << 0x08) | // backspace
20
+ (1 << 0x09) | // tab
21
+ (1 << 0x0a) | // newline
22
+ (1 << 0x0c) | // form feed
23
+ (1 << 0x0d) | // carriage return
24
+ (1 << 0x22) | // double quote
25
+ (1 << 0x5c); // backslash
26
+
27
+ /**
28
+ * @dev The `value` string doesn't fit in the specified `length`.
29
+ */
30
+ error StringsInsufficientHexLength(uint256 value, uint256 length);
31
+
32
+ /**
33
+ * @dev The string being parsed contains characters that are not in scope of the given base.
34
+ */
35
+ error StringsInvalidChar();
36
+
37
+ /**
38
+ * @dev The string being parsed is not a properly formatted address.
39
+ */
40
+ error StringsInvalidAddressFormat();
41
+
42
+ /**
43
+ * @dev Converts a `uint256` to its ASCII `string` decimal representation.
44
+ */
45
+ function toString(uint256 value) internal pure returns (string memory) {
46
+ unchecked {
47
+ uint256 length = Math.log10(value) + 1;
48
+ string memory buffer = new string(length);
49
+ uint256 ptr;
50
+ assembly ("memory-safe") {
51
+ ptr := add(buffer, add(32, length))
52
+ }
53
+ while (true) {
54
+ ptr--;
55
+ assembly ("memory-safe") {
56
+ mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
57
+ }
58
+ value /= 10;
59
+ if (value == 0) break;
60
+ }
61
+ return buffer;
62
+ }
63
+ }
64
+
65
+ /**
66
+ * @dev Converts a `int256` to its ASCII `string` decimal representation.
67
+ */
68
+ function toStringSigned(int256 value) internal pure returns (string memory) {
69
+ return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
70
+ }
71
+
72
+ /**
73
+ * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
74
+ */
75
+ function toHexString(uint256 value) internal pure returns (string memory) {
76
+ unchecked {
77
+ return toHexString(value, Math.log256(value) + 1);
78
+ }
79
+ }
80
+
81
+ /**
82
+ * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
83
+ */
84
+ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
85
+ uint256 localValue = value;
86
+ bytes memory buffer = new bytes(2 * length + 2);
87
+ buffer[0] = "0";
88
+ buffer[1] = "x";
89
+ for (uint256 i = 2 * length + 1; i > 1; --i) {
90
+ buffer[i] = HEX_DIGITS[localValue & 0xf];
91
+ localValue >>= 4;
92
+ }
93
+ if (localValue != 0) {
94
+ revert StringsInsufficientHexLength(value, length);
95
+ }
96
+ return string(buffer);
97
+ }
98
+
99
+ /**
100
+ * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
101
+ * representation.
102
+ */
103
+ function toHexString(address addr) internal pure returns (string memory) {
104
+ return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
105
+ }
106
+
107
+ /**
108
+ * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
109
+ * representation, according to EIP-55.
110
+ */
111
+ function toChecksumHexString(address addr) internal pure returns (string memory) {
112
+ bytes memory buffer = bytes(toHexString(addr));
113
+
114
+ // hash the hex part of buffer (skip length + 2 bytes, length 40)
115
+ uint256 hashValue;
116
+ assembly ("memory-safe") {
117
+ hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
118
+ }
119
+
120
+ for (uint256 i = 41; i > 1; --i) {
121
+ // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
122
+ if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
123
+ // case shift by xoring with 0x20
124
+ buffer[i] ^= 0x20;
125
+ }
126
+ hashValue >>= 4;
127
+ }
128
+ return string(buffer);
129
+ }
130
+
131
+ /**
132
+ * @dev Returns true if the two strings are equal.
133
+ */
134
+ function equal(string memory a, string memory b) internal pure returns (bool) {
135
+ return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
136
+ }
137
+
138
+ /**
139
+ * @dev Parse a decimal string and returns the value as a `uint256`.
140
+ *
141
+ * Requirements:
142
+ * - The string must be formatted as `[0-9]*`
143
+ * - The result must fit into an `uint256` type
144
+ */
145
+ function parseUint(string memory input) internal pure returns (uint256) {
146
+ return parseUint(input, 0, bytes(input).length);
147
+ }
148
+
149
+ /**
150
+ * @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and
151
+ * `end` (excluded).
152
+ *
153
+ * Requirements:
154
+ * - The substring must be formatted as `[0-9]*`
155
+ * - The result must fit into an `uint256` type
156
+ */
157
+ function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
158
+ (bool success, uint256 value) = tryParseUint(input, begin, end);
159
+ if (!success) revert StringsInvalidChar();
160
+ return value;
161
+ }
162
+
163
+ /**
164
+ * @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
165
+ *
166
+ * NOTE: This function will revert if the result does not fit in a `uint256`.
167
+ */
168
+ function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
169
+ return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
170
+ }
171
+
172
+ /**
173
+ * @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
174
+ * character.
175
+ *
176
+ * NOTE: This function will revert if the result does not fit in a `uint256`.
177
+ */
178
+ function tryParseUint(
179
+ string memory input,
180
+ uint256 begin,
181
+ uint256 end
182
+ ) internal pure returns (bool success, uint256 value) {
183
+ if (end > bytes(input).length || begin > end) return (false, 0);
184
+ return _tryParseUintUncheckedBounds(input, begin, end);
185
+ }
186
+
187
+ /**
188
+ * @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
189
+ * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
190
+ */
191
+ function _tryParseUintUncheckedBounds(
192
+ string memory input,
193
+ uint256 begin,
194
+ uint256 end
195
+ ) private pure returns (bool success, uint256 value) {
196
+ bytes memory buffer = bytes(input);
197
+
198
+ uint256 result = 0;
199
+ for (uint256 i = begin; i < end; ++i) {
200
+ uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
201
+ if (chr > 9) return (false, 0);
202
+ result *= 10;
203
+ result += chr;
204
+ }
205
+ return (true, result);
206
+ }
207
+
208
+ /**
209
+ * @dev Parse a decimal string and returns the value as a `int256`.
210
+ *
211
+ * Requirements:
212
+ * - The string must be formatted as `[-+]?[0-9]*`
213
+ * - The result must fit in an `int256` type.
214
+ */
215
+ function parseInt(string memory input) internal pure returns (int256) {
216
+ return parseInt(input, 0, bytes(input).length);
217
+ }
218
+
219
+ /**
220
+ * @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
221
+ * `end` (excluded).
222
+ *
223
+ * Requirements:
224
+ * - The substring must be formatted as `[-+]?[0-9]*`
225
+ * - The result must fit in an `int256` type.
226
+ */
227
+ function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
228
+ (bool success, int256 value) = tryParseInt(input, begin, end);
229
+ if (!success) revert StringsInvalidChar();
230
+ return value;
231
+ }
232
+
233
+ /**
234
+ * @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
235
+ * the result does not fit in a `int256`.
236
+ *
237
+ * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
238
+ */
239
+ function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
240
+ return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
241
+ }
242
+
243
+ uint256 private constant ABS_MIN_INT256 = 2 ** 255;
244
+
245
+ /**
246
+ * @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
247
+ * character or if the result does not fit in a `int256`.
248
+ *
249
+ * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
250
+ */
251
+ function tryParseInt(
252
+ string memory input,
253
+ uint256 begin,
254
+ uint256 end
255
+ ) internal pure returns (bool success, int256 value) {
256
+ if (end > bytes(input).length || begin > end) return (false, 0);
257
+ return _tryParseIntUncheckedBounds(input, begin, end);
258
+ }
259
+
260
+ /**
261
+ * @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
262
+ * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
263
+ */
264
+ function _tryParseIntUncheckedBounds(
265
+ string memory input,
266
+ uint256 begin,
267
+ uint256 end
268
+ ) private pure returns (bool success, int256 value) {
269
+ bytes memory buffer = bytes(input);
270
+
271
+ // Check presence of a negative sign.
272
+ bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
273
+ bool positiveSign = sign == bytes1("+");
274
+ bool negativeSign = sign == bytes1("-");
275
+ uint256 offset = (positiveSign || negativeSign).toUint();
276
+
277
+ (bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);
278
+
279
+ if (absSuccess && absValue < ABS_MIN_INT256) {
280
+ return (true, negativeSign ? -int256(absValue) : int256(absValue));
281
+ } else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
282
+ return (true, type(int256).min);
283
+ } else return (false, 0);
284
+ }
285
+
286
+ /**
287
+ * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
288
+ *
289
+ * Requirements:
290
+ * - The string must be formatted as `(0x)?[0-9a-fA-F]*`
291
+ * - The result must fit in an `uint256` type.
292
+ */
293
+ function parseHexUint(string memory input) internal pure returns (uint256) {
294
+ return parseHexUint(input, 0, bytes(input).length);
295
+ }
296
+
297
+ /**
298
+ * @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and
299
+ * `end` (excluded).
300
+ *
301
+ * Requirements:
302
+ * - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
303
+ * - The result must fit in an `uint256` type.
304
+ */
305
+ function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
306
+ (bool success, uint256 value) = tryParseHexUint(input, begin, end);
307
+ if (!success) revert StringsInvalidChar();
308
+ return value;
309
+ }
310
+
311
+ /**
312
+ * @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
313
+ *
314
+ * NOTE: This function will revert if the result does not fit in a `uint256`.
315
+ */
316
+ function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
317
+ return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
318
+ }
319
+
320
+ /**
321
+ * @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
322
+ * invalid character.
323
+ *
324
+ * NOTE: This function will revert if the result does not fit in a `uint256`.
325
+ */
326
+ function tryParseHexUint(
327
+ string memory input,
328
+ uint256 begin,
329
+ uint256 end
330
+ ) internal pure returns (bool success, uint256 value) {
331
+ if (end > bytes(input).length || begin > end) return (false, 0);
332
+ return _tryParseHexUintUncheckedBounds(input, begin, end);
333
+ }
334
+
335
+ /**
336
+ * @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
337
+ * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
338
+ */
339
+ function _tryParseHexUintUncheckedBounds(
340
+ string memory input,
341
+ uint256 begin,
342
+ uint256 end
343
+ ) private pure returns (bool success, uint256 value) {
344
+ bytes memory buffer = bytes(input);
345
+
346
+ // skip 0x prefix if present
347
+ bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
348
+ uint256 offset = hasPrefix.toUint() * 2;
349
+
350
+ uint256 result = 0;
351
+ for (uint256 i = begin + offset; i < end; ++i) {
352
+ uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
353
+ if (chr > 15) return (false, 0);
354
+ result *= 16;
355
+ unchecked {
356
+ // Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
357
+ // This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.
358
+ result += chr;
359
+ }
360
+ }
361
+ return (true, result);
362
+ }
363
+
364
+ /**
365
+ * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
366
+ *
367
+ * Requirements:
368
+ * - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
369
+ */
370
+ function parseAddress(string memory input) internal pure returns (address) {
371
+ return parseAddress(input, 0, bytes(input).length);
372
+ }
373
+
374
+ /**
375
+ * @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and
376
+ * `end` (excluded).
377
+ *
378
+ * Requirements:
379
+ * - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
380
+ */
381
+ function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
382
+ (bool success, address value) = tryParseAddress(input, begin, end);
383
+ if (!success) revert StringsInvalidAddressFormat();
384
+ return value;
385
+ }
386
+
387
+ /**
388
+ * @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
389
+ * formatted address. See {parseAddress-string} requirements.
390
+ */
391
+ function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
392
+ return tryParseAddress(input, 0, bytes(input).length);
393
+ }
394
+
395
+ /**
396
+ * @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
397
+ * formatted address. See {parseAddress-string-uint256-uint256} requirements.
398
+ */
399
+ function tryParseAddress(
400
+ string memory input,
401
+ uint256 begin,
402
+ uint256 end
403
+ ) internal pure returns (bool success, address value) {
404
+ if (end > bytes(input).length || begin > end) return (false, address(0));
405
+
406
+ bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
407
+ uint256 expectedLength = 40 + hasPrefix.toUint() * 2;
408
+
409
+ // check that input is the correct length
410
+ if (end - begin == expectedLength) {
411
+ // length guarantees that this does not overflow, and value is at most type(uint160).max
412
+ (bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
413
+ return (s, address(uint160(v)));
414
+ } else {
415
+ return (false, address(0));
416
+ }
417
+ }
418
+
419
+ function _tryParseChr(bytes1 chr) private pure returns (uint8) {
420
+ uint8 value = uint8(chr);
421
+
422
+ // Try to parse `chr`:
423
+ // - Case 1: [0-9]
424
+ // - Case 2: [a-f]
425
+ // - Case 3: [A-F]
426
+ // - otherwise not supported
427
+ unchecked {
428
+ if (value > 47 && value < 58) value -= 48;
429
+ else if (value > 96 && value < 103) value -= 87;
430
+ else if (value > 64 && value < 71) value -= 55;
431
+ else return type(uint8).max;
432
+ }
433
+
434
+ return value;
435
+ }
436
+
437
+ /**
438
+ * @dev Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
439
+ *
440
+ * WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
441
+ *
442
+ * NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of
443
+ * RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's `JSON.parse` does recover escaped unicode
444
+ * characters that are not in this range, but other tooling may provide different results.
445
+ */
446
+ function escapeJSON(string memory input) internal pure returns (string memory) {
447
+ bytes memory buffer = bytes(input);
448
+ bytes memory output = new bytes(2 * buffer.length); // worst case scenario
449
+ uint256 outputLength = 0;
450
+
451
+ for (uint256 i; i < buffer.length; ++i) {
452
+ bytes1 char = bytes1(_unsafeReadBytesOffset(buffer, i));
453
+ if (((SPECIAL_CHARS_LOOKUP & (1 << uint8(char))) != 0)) {
454
+ output[outputLength++] = "\\";
455
+ if (char == 0x08) output[outputLength++] = "b";
456
+ else if (char == 0x09) output[outputLength++] = "t";
457
+ else if (char == 0x0a) output[outputLength++] = "n";
458
+ else if (char == 0x0c) output[outputLength++] = "f";
459
+ else if (char == 0x0d) output[outputLength++] = "r";
460
+ else if (char == 0x5c) output[outputLength++] = "\\";
461
+ else if (char == 0x22) {
462
+ // solhint-disable-next-line quotes
463
+ output[outputLength++] = '"';
464
+ }
465
+ } else {
466
+ output[outputLength++] = char;
467
+ }
468
+ }
469
+ // write the actual length and deallocate unused memory
470
+ assembly ("memory-safe") {
471
+ mstore(output, outputLength)
472
+ mstore(0x40, add(output, shl(5, shr(5, add(outputLength, 63)))))
473
+ }
474
+
475
+ return string(output);
476
+ }
477
+
478
+ /**
479
+ * @dev Reads a bytes32 from a bytes array without bounds checking.
480
+ *
481
+ * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
482
+ * assembly block as such would prevent some optimizations.
483
+ */
484
+ function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
485
+ // This is not memory safe in the general case, but all calls to this private function are within bounds.
486
+ assembly ("memory-safe") {
487
+ value := mload(add(buffer, add(0x20, offset)))
488
+ }
489
+ }
490
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/introspection/ERC165.sol ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {IERC165} from "./IERC165.sol";
7
+
8
+ /**
9
+ * @dev Implementation of the {IERC165} interface.
10
+ *
11
+ * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
12
+ * for the additional interface id that will be supported. For example:
13
+ *
14
+ * ```solidity
15
+ * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
16
+ * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
17
+ * }
18
+ * ```
19
+ */
20
+ abstract contract ERC165 is IERC165 {
21
+ /**
22
+ * @dev See {IERC165-supportsInterface}.
23
+ */
24
+ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
25
+ return interfaceId == type(IERC165).interfaceId;
26
+ }
27
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/introspection/IERC165.sol ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ /**
7
+ * @dev Interface of the ERC-165 standard, as defined in the
8
+ * https://eips.ethereum.org/EIPS/eip-165[ERC].
9
+ *
10
+ * Implementers can declare support of contract interfaces, which can then be
11
+ * queried by others ({ERC165Checker}).
12
+ *
13
+ * For an implementation, see {ERC165}.
14
+ */
15
+ interface IERC165 {
16
+ /**
17
+ * @dev Returns true if this contract implements the interface defined by
18
+ * `interfaceId`. See the corresponding
19
+ * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
20
+ * to learn more about how these ids are created.
21
+ *
22
+ * This function call must use less than 30 000 gas.
23
+ */
24
+ function supportsInterface(bytes4 interfaceId) external view returns (bool);
25
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/math/Math.sol ADDED
@@ -0,0 +1,749 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {Panic} from "../Panic.sol";
7
+ import {SafeCast} from "./SafeCast.sol";
8
+
9
+ /**
10
+ * @dev Standard math utilities missing in the Solidity language.
11
+ */
12
+ library Math {
13
+ enum Rounding {
14
+ Floor, // Toward negative infinity
15
+ Ceil, // Toward positive infinity
16
+ Trunc, // Toward zero
17
+ Expand // Away from zero
18
+ }
19
+
20
+ /**
21
+ * @dev Return the 512-bit addition of two uint256.
22
+ *
23
+ * The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
24
+ */
25
+ function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
26
+ assembly ("memory-safe") {
27
+ low := add(a, b)
28
+ high := lt(low, a)
29
+ }
30
+ }
31
+
32
+ /**
33
+ * @dev Return the 512-bit multiplication of two uint256.
34
+ *
35
+ * The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
36
+ */
37
+ function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
38
+ // 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
39
+ // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
40
+ // variables such that product = high * 2²⁵⁶ + low.
41
+ assembly ("memory-safe") {
42
+ let mm := mulmod(a, b, not(0))
43
+ low := mul(a, b)
44
+ high := sub(sub(mm, low), lt(mm, low))
45
+ }
46
+ }
47
+
48
+ /**
49
+ * @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
50
+ */
51
+ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
52
+ unchecked {
53
+ uint256 c = a + b;
54
+ success = c >= a;
55
+ result = c * SafeCast.toUint(success);
56
+ }
57
+ }
58
+
59
+ /**
60
+ * @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
61
+ */
62
+ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
63
+ unchecked {
64
+ uint256 c = a - b;
65
+ success = c <= a;
66
+ result = c * SafeCast.toUint(success);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
72
+ */
73
+ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
74
+ unchecked {
75
+ uint256 c = a * b;
76
+ assembly ("memory-safe") {
77
+ // Only true when the multiplication doesn't overflow
78
+ // (c / a == b) || (a == 0)
79
+ success := or(eq(div(c, a), b), iszero(a))
80
+ }
81
+ // equivalent to: success ? c : 0
82
+ result = c * SafeCast.toUint(success);
83
+ }
84
+ }
85
+
86
+ /**
87
+ * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
88
+ */
89
+ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
90
+ unchecked {
91
+ success = b > 0;
92
+ assembly ("memory-safe") {
93
+ // The `DIV` opcode returns zero when the denominator is 0.
94
+ result := div(a, b)
95
+ }
96
+ }
97
+ }
98
+
99
+ /**
100
+ * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
101
+ */
102
+ function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
103
+ unchecked {
104
+ success = b > 0;
105
+ assembly ("memory-safe") {
106
+ // The `MOD` opcode returns zero when the denominator is 0.
107
+ result := mod(a, b)
108
+ }
109
+ }
110
+ }
111
+
112
+ /**
113
+ * @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
114
+ */
115
+ function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
116
+ (bool success, uint256 result) = tryAdd(a, b);
117
+ return ternary(success, result, type(uint256).max);
118
+ }
119
+
120
+ /**
121
+ * @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
122
+ */
123
+ function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
124
+ (, uint256 result) = trySub(a, b);
125
+ return result;
126
+ }
127
+
128
+ /**
129
+ * @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
130
+ */
131
+ function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
132
+ (bool success, uint256 result) = tryMul(a, b);
133
+ return ternary(success, result, type(uint256).max);
134
+ }
135
+
136
+ /**
137
+ * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
138
+ *
139
+ * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
140
+ * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
141
+ * one branch when needed, making this function more expensive.
142
+ */
143
+ function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
144
+ unchecked {
145
+ // branchless ternary works because:
146
+ // b ^ (a ^ b) == a
147
+ // b ^ 0 == b
148
+ return b ^ ((a ^ b) * SafeCast.toUint(condition));
149
+ }
150
+ }
151
+
152
+ /**
153
+ * @dev Returns the largest of two numbers.
154
+ */
155
+ function max(uint256 a, uint256 b) internal pure returns (uint256) {
156
+ return ternary(a > b, a, b);
157
+ }
158
+
159
+ /**
160
+ * @dev Returns the smallest of two numbers.
161
+ */
162
+ function min(uint256 a, uint256 b) internal pure returns (uint256) {
163
+ return ternary(a < b, a, b);
164
+ }
165
+
166
+ /**
167
+ * @dev Returns the average of two numbers. The result is rounded towards
168
+ * zero.
169
+ */
170
+ function average(uint256 a, uint256 b) internal pure returns (uint256) {
171
+ // (a + b) / 2 can overflow.
172
+ return (a & b) + (a ^ b) / 2;
173
+ }
174
+
175
+ /**
176
+ * @dev Returns the ceiling of the division of two numbers.
177
+ *
178
+ * This differs from standard division with `/` in that it rounds towards infinity instead
179
+ * of rounding towards zero.
180
+ */
181
+ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
182
+ if (b == 0) {
183
+ // Guarantee the same behavior as in a regular Solidity division.
184
+ Panic.panic(Panic.DIVISION_BY_ZERO);
185
+ }
186
+
187
+ // The following calculation ensures accurate ceiling division without overflow.
188
+ // Since a is non-zero, (a - 1) / b will not overflow.
189
+ // The largest possible result occurs when (a - 1) / b is type(uint256).max,
190
+ // but the largest value we can obtain is type(uint256).max - 1, which happens
191
+ // when a = type(uint256).max and b = 1.
192
+ unchecked {
193
+ return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
194
+ }
195
+ }
196
+
197
+ /**
198
+ * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
199
+ * denominator == 0.
200
+ *
201
+ * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
202
+ * Uniswap Labs also under MIT license.
203
+ */
204
+ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
205
+ unchecked {
206
+ (uint256 high, uint256 low) = mul512(x, y);
207
+
208
+ // Handle non-overflow cases, 256 by 256 division.
209
+ if (high == 0) {
210
+ // Solidity will revert if denominator == 0, unlike the div opcode on its own.
211
+ // The surrounding unchecked block does not change this fact.
212
+ // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
213
+ return low / denominator;
214
+ }
215
+
216
+ // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
217
+ if (denominator <= high) {
218
+ Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
219
+ }
220
+
221
+ ///////////////////////////////////////////////
222
+ // 512 by 256 division.
223
+ ///////////////////////////////////////////////
224
+
225
+ // Make division exact by subtracting the remainder from [high low].
226
+ uint256 remainder;
227
+ assembly ("memory-safe") {
228
+ // Compute remainder using mulmod.
229
+ remainder := mulmod(x, y, denominator)
230
+
231
+ // Subtract 256 bit number from 512 bit number.
232
+ high := sub(high, gt(remainder, low))
233
+ low := sub(low, remainder)
234
+ }
235
+
236
+ // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
237
+ // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
238
+
239
+ uint256 twos = denominator & (0 - denominator);
240
+ assembly ("memory-safe") {
241
+ // Divide denominator by twos.
242
+ denominator := div(denominator, twos)
243
+
244
+ // Divide [high low] by twos.
245
+ low := div(low, twos)
246
+
247
+ // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
248
+ twos := add(div(sub(0, twos), twos), 1)
249
+ }
250
+
251
+ // Shift in bits from high into low.
252
+ low |= high * twos;
253
+
254
+ // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
255
+ // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
256
+ // four bits. That is, denominator * inv ≡ 1 mod 2⁴.
257
+ uint256 inverse = (3 * denominator) ^ 2;
258
+
259
+ // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
260
+ // works in modular arithmetic, doubling the correct bits in each step.
261
+ inverse *= 2 - denominator * inverse; // inverse mod 2⁸
262
+ inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
263
+ inverse *= 2 - denominator * inverse; // inverse mod 2³²
264
+ inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
265
+ inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
266
+ inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
267
+
268
+ // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
269
+ // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
270
+ // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
271
+ // is no longer required.
272
+ result = low * inverse;
273
+ return result;
274
+ }
275
+ }
276
+
277
+ /**
278
+ * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
279
+ */
280
+ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
281
+ return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
282
+ }
283
+
284
+ /**
285
+ * @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
286
+ */
287
+ function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
288
+ unchecked {
289
+ (uint256 high, uint256 low) = mul512(x, y);
290
+ if (high >= 1 << n) {
291
+ Panic.panic(Panic.UNDER_OVERFLOW);
292
+ }
293
+ return (high << (256 - n)) | (low >> n);
294
+ }
295
+ }
296
+
297
+ /**
298
+ * @dev Calculates x * y >> n with full precision, following the selected rounding direction.
299
+ */
300
+ function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
301
+ return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
302
+ }
303
+
304
+ /**
305
+ * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
306
+ *
307
+ * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
308
+ * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
309
+ *
310
+ * If the input value is not inversible, 0 is returned.
311
+ *
312
+ * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
313
+ * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
314
+ */
315
+ function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
316
+ unchecked {
317
+ if (n == 0) return 0;
318
+
319
+ // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
320
+ // Used to compute integers x and y such that: ax + ny = gcd(a, n).
321
+ // When the gcd is 1, then the inverse of a modulo n exists and it's x.
322
+ // ax + ny = 1
323
+ // ax = 1 + (-y)n
324
+ // ax ≡ 1 (mod n) # x is the inverse of a modulo n
325
+
326
+ // If the remainder is 0 the gcd is n right away.
327
+ uint256 remainder = a % n;
328
+ uint256 gcd = n;
329
+
330
+ // Therefore the initial coefficients are:
331
+ // ax + ny = gcd(a, n) = n
332
+ // 0a + 1n = n
333
+ int256 x = 0;
334
+ int256 y = 1;
335
+
336
+ while (remainder != 0) {
337
+ uint256 quotient = gcd / remainder;
338
+
339
+ (gcd, remainder) = (
340
+ // The old remainder is the next gcd to try.
341
+ remainder,
342
+ // Compute the next remainder.
343
+ // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
344
+ // where gcd is at most n (capped to type(uint256).max)
345
+ gcd - remainder * quotient
346
+ );
347
+
348
+ (x, y) = (
349
+ // Increment the coefficient of a.
350
+ y,
351
+ // Decrement the coefficient of n.
352
+ // Can overflow, but the result is casted to uint256 so that the
353
+ // next value of y is "wrapped around" to a value between 0 and n - 1.
354
+ x - y * int256(quotient)
355
+ );
356
+ }
357
+
358
+ if (gcd != 1) return 0; // No inverse exists.
359
+ return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
360
+ }
361
+ }
362
+
363
+ /**
364
+ * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
365
+ *
366
+ * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
367
+ * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
368
+ * `a**(p-2)` is the modular multiplicative inverse of a in Fp.
369
+ *
370
+ * NOTE: this function does NOT check that `p` is a prime greater than `2`.
371
+ */
372
+ function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
373
+ unchecked {
374
+ return Math.modExp(a, p - 2, p);
375
+ }
376
+ }
377
+
378
+ /**
379
+ * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
380
+ *
381
+ * Requirements:
382
+ * - modulus can't be zero
383
+ * - underlying staticcall to precompile must succeed
384
+ *
385
+ * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
386
+ * sure the chain you're using it on supports the precompiled contract for modular exponentiation
387
+ * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
388
+ * the underlying function will succeed given the lack of a revert, but the result may be incorrectly
389
+ * interpreted as 0.
390
+ */
391
+ function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
392
+ (bool success, uint256 result) = tryModExp(b, e, m);
393
+ if (!success) {
394
+ Panic.panic(Panic.DIVISION_BY_ZERO);
395
+ }
396
+ return result;
397
+ }
398
+
399
+ /**
400
+ * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
401
+ * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
402
+ * to operate modulo 0 or if the underlying precompile reverted.
403
+ *
404
+ * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
405
+ * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
406
+ * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
407
+ * of a revert, but the result may be incorrectly interpreted as 0.
408
+ */
409
+ function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
410
+ if (m == 0) return (false, 0);
411
+ assembly ("memory-safe") {
412
+ let ptr := mload(0x40)
413
+ // | Offset | Content | Content (Hex) |
414
+ // |-----------|------------|--------------------------------------------------------------------|
415
+ // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
416
+ // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
417
+ // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
418
+ // | 0x60:0x7f | value of b | 0x<.............................................................b> |
419
+ // | 0x80:0x9f | value of e | 0x<.............................................................e> |
420
+ // | 0xa0:0xbf | value of m | 0x<.............................................................m> |
421
+ mstore(ptr, 0x20)
422
+ mstore(add(ptr, 0x20), 0x20)
423
+ mstore(add(ptr, 0x40), 0x20)
424
+ mstore(add(ptr, 0x60), b)
425
+ mstore(add(ptr, 0x80), e)
426
+ mstore(add(ptr, 0xa0), m)
427
+
428
+ // Given the result < m, it's guaranteed to fit in 32 bytes,
429
+ // so we can use the memory scratch space located at offset 0.
430
+ success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
431
+ result := mload(0x00)
432
+ }
433
+ }
434
+
435
+ /**
436
+ * @dev Variant of {modExp} that supports inputs of arbitrary length.
437
+ */
438
+ function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
439
+ (bool success, bytes memory result) = tryModExp(b, e, m);
440
+ if (!success) {
441
+ Panic.panic(Panic.DIVISION_BY_ZERO);
442
+ }
443
+ return result;
444
+ }
445
+
446
+ /**
447
+ * @dev Variant of {tryModExp} that supports inputs of arbitrary length.
448
+ */
449
+ function tryModExp(
450
+ bytes memory b,
451
+ bytes memory e,
452
+ bytes memory m
453
+ ) internal view returns (bool success, bytes memory result) {
454
+ if (_zeroBytes(m)) return (false, new bytes(0));
455
+
456
+ uint256 mLen = m.length;
457
+
458
+ // Encode call args in result and move the free memory pointer
459
+ result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
460
+
461
+ assembly ("memory-safe") {
462
+ let dataPtr := add(result, 0x20)
463
+ // Write result on top of args to avoid allocating extra memory.
464
+ success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
465
+ // Overwrite the length.
466
+ // result.length > returndatasize() is guaranteed because returndatasize() == m.length
467
+ mstore(result, mLen)
468
+ // Set the memory pointer after the returned data.
469
+ mstore(0x40, add(dataPtr, mLen))
470
+ }
471
+ }
472
+
473
+ /**
474
+ * @dev Returns whether the provided byte array is zero.
475
+ */
476
+ function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
477
+ for (uint256 i = 0; i < byteArray.length; ++i) {
478
+ if (byteArray[i] != 0) {
479
+ return false;
480
+ }
481
+ }
482
+ return true;
483
+ }
484
+
485
+ /**
486
+ * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
487
+ * towards zero.
488
+ *
489
+ * This method is based on Newton's method for computing square roots; the algorithm is restricted to only
490
+ * using integer operations.
491
+ */
492
+ function sqrt(uint256 a) internal pure returns (uint256) {
493
+ unchecked {
494
+ // Take care of easy edge cases when a == 0 or a == 1
495
+ if (a <= 1) {
496
+ return a;
497
+ }
498
+
499
+ // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
500
+ // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
501
+ // the current value as `ε_n = | x_n - sqrt(a) |`.
502
+ //
503
+ // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
504
+ // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
505
+ // bigger than any uint256.
506
+ //
507
+ // By noticing that
508
+ // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
509
+ // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
510
+ // to the msb function.
511
+ uint256 aa = a;
512
+ uint256 xn = 1;
513
+
514
+ if (aa >= (1 << 128)) {
515
+ aa >>= 128;
516
+ xn <<= 64;
517
+ }
518
+ if (aa >= (1 << 64)) {
519
+ aa >>= 64;
520
+ xn <<= 32;
521
+ }
522
+ if (aa >= (1 << 32)) {
523
+ aa >>= 32;
524
+ xn <<= 16;
525
+ }
526
+ if (aa >= (1 << 16)) {
527
+ aa >>= 16;
528
+ xn <<= 8;
529
+ }
530
+ if (aa >= (1 << 8)) {
531
+ aa >>= 8;
532
+ xn <<= 4;
533
+ }
534
+ if (aa >= (1 << 4)) {
535
+ aa >>= 4;
536
+ xn <<= 2;
537
+ }
538
+ if (aa >= (1 << 2)) {
539
+ xn <<= 1;
540
+ }
541
+
542
+ // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
543
+ //
544
+ // We can refine our estimation by noticing that the middle of that interval minimizes the error.
545
+ // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
546
+ // This is going to be our x_0 (and ε_0)
547
+ xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
548
+
549
+ // From here, Newton's method give us:
550
+ // x_{n+1} = (x_n + a / x_n) / 2
551
+ //
552
+ // One should note that:
553
+ // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
554
+ // = ((x_n² + a) / (2 * x_n))² - a
555
+ // = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
556
+ // = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
557
+ // = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
558
+ // = (x_n² - a)² / (2 * x_n)²
559
+ // = ((x_n² - a) / (2 * x_n))²
560
+ // ≥ 0
561
+ // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
562
+ //
563
+ // This gives us the proof of quadratic convergence of the sequence:
564
+ // ε_{n+1} = | x_{n+1} - sqrt(a) |
565
+ // = | (x_n + a / x_n) / 2 - sqrt(a) |
566
+ // = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
567
+ // = | (x_n - sqrt(a))² / (2 * x_n) |
568
+ // = | ε_n² / (2 * x_n) |
569
+ // = ε_n² / | (2 * x_n) |
570
+ //
571
+ // For the first iteration, we have a special case where x_0 is known:
572
+ // ε_1 = ε_0² / | (2 * x_0) |
573
+ // ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
574
+ // ≤ 2**(2*e-4) / (3 * 2**(e-1))
575
+ // ≤ 2**(e-3) / 3
576
+ // ≤ 2**(e-3-log2(3))
577
+ // ≤ 2**(e-4.5)
578
+ //
579
+ // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
580
+ // ε_{n+1} = ε_n² / | (2 * x_n) |
581
+ // ≤ (2**(e-k))² / (2 * 2**(e-1))
582
+ // ≤ 2**(2*e-2*k) / 2**e
583
+ // ≤ 2**(e-2*k)
584
+ xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
585
+ xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
586
+ xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
587
+ xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
588
+ xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
589
+ xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
590
+
591
+ // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
592
+ // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
593
+ // sqrt(a) or sqrt(a) + 1.
594
+ return xn - SafeCast.toUint(xn > a / xn);
595
+ }
596
+ }
597
+
598
+ /**
599
+ * @dev Calculates sqrt(a), following the selected rounding direction.
600
+ */
601
+ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
602
+ unchecked {
603
+ uint256 result = sqrt(a);
604
+ return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
605
+ }
606
+ }
607
+
608
+ /**
609
+ * @dev Return the log in base 2 of a positive value rounded towards zero.
610
+ * Returns 0 if given 0.
611
+ */
612
+ function log2(uint256 x) internal pure returns (uint256 r) {
613
+ // If value has upper 128 bits set, log2 result is at least 128
614
+ r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
615
+ // If upper 64 bits of 128-bit half set, add 64 to result
616
+ r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
617
+ // If upper 32 bits of 64-bit half set, add 32 to result
618
+ r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
619
+ // If upper 16 bits of 32-bit half set, add 16 to result
620
+ r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
621
+ // If upper 8 bits of 16-bit half set, add 8 to result
622
+ r |= SafeCast.toUint((x >> r) > 0xff) << 3;
623
+ // If upper 4 bits of 8-bit half set, add 4 to result
624
+ r |= SafeCast.toUint((x >> r) > 0xf) << 2;
625
+
626
+ // Shifts value right by the current result and use it as an index into this lookup table:
627
+ //
628
+ // | x (4 bits) | index | table[index] = MSB position |
629
+ // |------------|---------|-----------------------------|
630
+ // | 0000 | 0 | table[0] = 0 |
631
+ // | 0001 | 1 | table[1] = 0 |
632
+ // | 0010 | 2 | table[2] = 1 |
633
+ // | 0011 | 3 | table[3] = 1 |
634
+ // | 0100 | 4 | table[4] = 2 |
635
+ // | 0101 | 5 | table[5] = 2 |
636
+ // | 0110 | 6 | table[6] = 2 |
637
+ // | 0111 | 7 | table[7] = 2 |
638
+ // | 1000 | 8 | table[8] = 3 |
639
+ // | 1001 | 9 | table[9] = 3 |
640
+ // | 1010 | 10 | table[10] = 3 |
641
+ // | 1011 | 11 | table[11] = 3 |
642
+ // | 1100 | 12 | table[12] = 3 |
643
+ // | 1101 | 13 | table[13] = 3 |
644
+ // | 1110 | 14 | table[14] = 3 |
645
+ // | 1111 | 15 | table[15] = 3 |
646
+ //
647
+ // The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
648
+ assembly ("memory-safe") {
649
+ r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
650
+ }
651
+ }
652
+
653
+ /**
654
+ * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
655
+ * Returns 0 if given 0.
656
+ */
657
+ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
658
+ unchecked {
659
+ uint256 result = log2(value);
660
+ return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
661
+ }
662
+ }
663
+
664
+ /**
665
+ * @dev Return the log in base 10 of a positive value rounded towards zero.
666
+ * Returns 0 if given 0.
667
+ */
668
+ function log10(uint256 value) internal pure returns (uint256) {
669
+ uint256 result = 0;
670
+ unchecked {
671
+ if (value >= 10 ** 64) {
672
+ value /= 10 ** 64;
673
+ result += 64;
674
+ }
675
+ if (value >= 10 ** 32) {
676
+ value /= 10 ** 32;
677
+ result += 32;
678
+ }
679
+ if (value >= 10 ** 16) {
680
+ value /= 10 ** 16;
681
+ result += 16;
682
+ }
683
+ if (value >= 10 ** 8) {
684
+ value /= 10 ** 8;
685
+ result += 8;
686
+ }
687
+ if (value >= 10 ** 4) {
688
+ value /= 10 ** 4;
689
+ result += 4;
690
+ }
691
+ if (value >= 10 ** 2) {
692
+ value /= 10 ** 2;
693
+ result += 2;
694
+ }
695
+ if (value >= 10 ** 1) {
696
+ result += 1;
697
+ }
698
+ }
699
+ return result;
700
+ }
701
+
702
+ /**
703
+ * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
704
+ * Returns 0 if given 0.
705
+ */
706
+ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
707
+ unchecked {
708
+ uint256 result = log10(value);
709
+ return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
710
+ }
711
+ }
712
+
713
+ /**
714
+ * @dev Return the log in base 256 of a positive value rounded towards zero.
715
+ * Returns 0 if given 0.
716
+ *
717
+ * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
718
+ */
719
+ function log256(uint256 x) internal pure returns (uint256 r) {
720
+ // If value has upper 128 bits set, log2 result is at least 128
721
+ r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
722
+ // If upper 64 bits of 128-bit half set, add 64 to result
723
+ r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
724
+ // If upper 32 bits of 64-bit half set, add 32 to result
725
+ r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
726
+ // If upper 16 bits of 32-bit half set, add 16 to result
727
+ r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
728
+ // Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
729
+ return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
730
+ }
731
+
732
+ /**
733
+ * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
734
+ * Returns 0 if given 0.
735
+ */
736
+ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
737
+ unchecked {
738
+ uint256 result = log256(value);
739
+ return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
740
+ }
741
+ }
742
+
743
+ /**
744
+ * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
745
+ */
746
+ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
747
+ return uint8(rounding) % 2 == 1;
748
+ }
749
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/math/SafeCast.sol ADDED
@@ -0,0 +1,1162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
3
+ // This file was procedurally generated from scripts/generate/templates/SafeCast.js.
4
+
5
+ pragma solidity ^0.8.20;
6
+
7
+ /**
8
+ * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
9
+ * checks.
10
+ *
11
+ * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
12
+ * easily result in undesired exploitation or bugs, since developers usually
13
+ * assume that overflows raise errors. `SafeCast` restores this intuition by
14
+ * reverting the transaction when such an operation overflows.
15
+ *
16
+ * Using this library instead of the unchecked operations eliminates an entire
17
+ * class of bugs, so it's recommended to use it always.
18
+ */
19
+ library SafeCast {
20
+ /**
21
+ * @dev Value doesn't fit in an uint of `bits` size.
22
+ */
23
+ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
24
+
25
+ /**
26
+ * @dev An int value doesn't fit in an uint of `bits` size.
27
+ */
28
+ error SafeCastOverflowedIntToUint(int256 value);
29
+
30
+ /**
31
+ * @dev Value doesn't fit in an int of `bits` size.
32
+ */
33
+ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
34
+
35
+ /**
36
+ * @dev An uint value doesn't fit in an int of `bits` size.
37
+ */
38
+ error SafeCastOverflowedUintToInt(uint256 value);
39
+
40
+ /**
41
+ * @dev Returns the downcasted uint248 from uint256, reverting on
42
+ * overflow (when the input is greater than largest uint248).
43
+ *
44
+ * Counterpart to Solidity's `uint248` operator.
45
+ *
46
+ * Requirements:
47
+ *
48
+ * - input must fit into 248 bits
49
+ */
50
+ function toUint248(uint256 value) internal pure returns (uint248) {
51
+ if (value > type(uint248).max) {
52
+ revert SafeCastOverflowedUintDowncast(248, value);
53
+ }
54
+ return uint248(value);
55
+ }
56
+
57
+ /**
58
+ * @dev Returns the downcasted uint240 from uint256, reverting on
59
+ * overflow (when the input is greater than largest uint240).
60
+ *
61
+ * Counterpart to Solidity's `uint240` operator.
62
+ *
63
+ * Requirements:
64
+ *
65
+ * - input must fit into 240 bits
66
+ */
67
+ function toUint240(uint256 value) internal pure returns (uint240) {
68
+ if (value > type(uint240).max) {
69
+ revert SafeCastOverflowedUintDowncast(240, value);
70
+ }
71
+ return uint240(value);
72
+ }
73
+
74
+ /**
75
+ * @dev Returns the downcasted uint232 from uint256, reverting on
76
+ * overflow (when the input is greater than largest uint232).
77
+ *
78
+ * Counterpart to Solidity's `uint232` operator.
79
+ *
80
+ * Requirements:
81
+ *
82
+ * - input must fit into 232 bits
83
+ */
84
+ function toUint232(uint256 value) internal pure returns (uint232) {
85
+ if (value > type(uint232).max) {
86
+ revert SafeCastOverflowedUintDowncast(232, value);
87
+ }
88
+ return uint232(value);
89
+ }
90
+
91
+ /**
92
+ * @dev Returns the downcasted uint224 from uint256, reverting on
93
+ * overflow (when the input is greater than largest uint224).
94
+ *
95
+ * Counterpart to Solidity's `uint224` operator.
96
+ *
97
+ * Requirements:
98
+ *
99
+ * - input must fit into 224 bits
100
+ */
101
+ function toUint224(uint256 value) internal pure returns (uint224) {
102
+ if (value > type(uint224).max) {
103
+ revert SafeCastOverflowedUintDowncast(224, value);
104
+ }
105
+ return uint224(value);
106
+ }
107
+
108
+ /**
109
+ * @dev Returns the downcasted uint216 from uint256, reverting on
110
+ * overflow (when the input is greater than largest uint216).
111
+ *
112
+ * Counterpart to Solidity's `uint216` operator.
113
+ *
114
+ * Requirements:
115
+ *
116
+ * - input must fit into 216 bits
117
+ */
118
+ function toUint216(uint256 value) internal pure returns (uint216) {
119
+ if (value > type(uint216).max) {
120
+ revert SafeCastOverflowedUintDowncast(216, value);
121
+ }
122
+ return uint216(value);
123
+ }
124
+
125
+ /**
126
+ * @dev Returns the downcasted uint208 from uint256, reverting on
127
+ * overflow (when the input is greater than largest uint208).
128
+ *
129
+ * Counterpart to Solidity's `uint208` operator.
130
+ *
131
+ * Requirements:
132
+ *
133
+ * - input must fit into 208 bits
134
+ */
135
+ function toUint208(uint256 value) internal pure returns (uint208) {
136
+ if (value > type(uint208).max) {
137
+ revert SafeCastOverflowedUintDowncast(208, value);
138
+ }
139
+ return uint208(value);
140
+ }
141
+
142
+ /**
143
+ * @dev Returns the downcasted uint200 from uint256, reverting on
144
+ * overflow (when the input is greater than largest uint200).
145
+ *
146
+ * Counterpart to Solidity's `uint200` operator.
147
+ *
148
+ * Requirements:
149
+ *
150
+ * - input must fit into 200 bits
151
+ */
152
+ function toUint200(uint256 value) internal pure returns (uint200) {
153
+ if (value > type(uint200).max) {
154
+ revert SafeCastOverflowedUintDowncast(200, value);
155
+ }
156
+ return uint200(value);
157
+ }
158
+
159
+ /**
160
+ * @dev Returns the downcasted uint192 from uint256, reverting on
161
+ * overflow (when the input is greater than largest uint192).
162
+ *
163
+ * Counterpart to Solidity's `uint192` operator.
164
+ *
165
+ * Requirements:
166
+ *
167
+ * - input must fit into 192 bits
168
+ */
169
+ function toUint192(uint256 value) internal pure returns (uint192) {
170
+ if (value > type(uint192).max) {
171
+ revert SafeCastOverflowedUintDowncast(192, value);
172
+ }
173
+ return uint192(value);
174
+ }
175
+
176
+ /**
177
+ * @dev Returns the downcasted uint184 from uint256, reverting on
178
+ * overflow (when the input is greater than largest uint184).
179
+ *
180
+ * Counterpart to Solidity's `uint184` operator.
181
+ *
182
+ * Requirements:
183
+ *
184
+ * - input must fit into 184 bits
185
+ */
186
+ function toUint184(uint256 value) internal pure returns (uint184) {
187
+ if (value > type(uint184).max) {
188
+ revert SafeCastOverflowedUintDowncast(184, value);
189
+ }
190
+ return uint184(value);
191
+ }
192
+
193
+ /**
194
+ * @dev Returns the downcasted uint176 from uint256, reverting on
195
+ * overflow (when the input is greater than largest uint176).
196
+ *
197
+ * Counterpart to Solidity's `uint176` operator.
198
+ *
199
+ * Requirements:
200
+ *
201
+ * - input must fit into 176 bits
202
+ */
203
+ function toUint176(uint256 value) internal pure returns (uint176) {
204
+ if (value > type(uint176).max) {
205
+ revert SafeCastOverflowedUintDowncast(176, value);
206
+ }
207
+ return uint176(value);
208
+ }
209
+
210
+ /**
211
+ * @dev Returns the downcasted uint168 from uint256, reverting on
212
+ * overflow (when the input is greater than largest uint168).
213
+ *
214
+ * Counterpart to Solidity's `uint168` operator.
215
+ *
216
+ * Requirements:
217
+ *
218
+ * - input must fit into 168 bits
219
+ */
220
+ function toUint168(uint256 value) internal pure returns (uint168) {
221
+ if (value > type(uint168).max) {
222
+ revert SafeCastOverflowedUintDowncast(168, value);
223
+ }
224
+ return uint168(value);
225
+ }
226
+
227
+ /**
228
+ * @dev Returns the downcasted uint160 from uint256, reverting on
229
+ * overflow (when the input is greater than largest uint160).
230
+ *
231
+ * Counterpart to Solidity's `uint160` operator.
232
+ *
233
+ * Requirements:
234
+ *
235
+ * - input must fit into 160 bits
236
+ */
237
+ function toUint160(uint256 value) internal pure returns (uint160) {
238
+ if (value > type(uint160).max) {
239
+ revert SafeCastOverflowedUintDowncast(160, value);
240
+ }
241
+ return uint160(value);
242
+ }
243
+
244
+ /**
245
+ * @dev Returns the downcasted uint152 from uint256, reverting on
246
+ * overflow (when the input is greater than largest uint152).
247
+ *
248
+ * Counterpart to Solidity's `uint152` operator.
249
+ *
250
+ * Requirements:
251
+ *
252
+ * - input must fit into 152 bits
253
+ */
254
+ function toUint152(uint256 value) internal pure returns (uint152) {
255
+ if (value > type(uint152).max) {
256
+ revert SafeCastOverflowedUintDowncast(152, value);
257
+ }
258
+ return uint152(value);
259
+ }
260
+
261
+ /**
262
+ * @dev Returns the downcasted uint144 from uint256, reverting on
263
+ * overflow (when the input is greater than largest uint144).
264
+ *
265
+ * Counterpart to Solidity's `uint144` operator.
266
+ *
267
+ * Requirements:
268
+ *
269
+ * - input must fit into 144 bits
270
+ */
271
+ function toUint144(uint256 value) internal pure returns (uint144) {
272
+ if (value > type(uint144).max) {
273
+ revert SafeCastOverflowedUintDowncast(144, value);
274
+ }
275
+ return uint144(value);
276
+ }
277
+
278
+ /**
279
+ * @dev Returns the downcasted uint136 from uint256, reverting on
280
+ * overflow (when the input is greater than largest uint136).
281
+ *
282
+ * Counterpart to Solidity's `uint136` operator.
283
+ *
284
+ * Requirements:
285
+ *
286
+ * - input must fit into 136 bits
287
+ */
288
+ function toUint136(uint256 value) internal pure returns (uint136) {
289
+ if (value > type(uint136).max) {
290
+ revert SafeCastOverflowedUintDowncast(136, value);
291
+ }
292
+ return uint136(value);
293
+ }
294
+
295
+ /**
296
+ * @dev Returns the downcasted uint128 from uint256, reverting on
297
+ * overflow (when the input is greater than largest uint128).
298
+ *
299
+ * Counterpart to Solidity's `uint128` operator.
300
+ *
301
+ * Requirements:
302
+ *
303
+ * - input must fit into 128 bits
304
+ */
305
+ function toUint128(uint256 value) internal pure returns (uint128) {
306
+ if (value > type(uint128).max) {
307
+ revert SafeCastOverflowedUintDowncast(128, value);
308
+ }
309
+ return uint128(value);
310
+ }
311
+
312
+ /**
313
+ * @dev Returns the downcasted uint120 from uint256, reverting on
314
+ * overflow (when the input is greater than largest uint120).
315
+ *
316
+ * Counterpart to Solidity's `uint120` operator.
317
+ *
318
+ * Requirements:
319
+ *
320
+ * - input must fit into 120 bits
321
+ */
322
+ function toUint120(uint256 value) internal pure returns (uint120) {
323
+ if (value > type(uint120).max) {
324
+ revert SafeCastOverflowedUintDowncast(120, value);
325
+ }
326
+ return uint120(value);
327
+ }
328
+
329
+ /**
330
+ * @dev Returns the downcasted uint112 from uint256, reverting on
331
+ * overflow (when the input is greater than largest uint112).
332
+ *
333
+ * Counterpart to Solidity's `uint112` operator.
334
+ *
335
+ * Requirements:
336
+ *
337
+ * - input must fit into 112 bits
338
+ */
339
+ function toUint112(uint256 value) internal pure returns (uint112) {
340
+ if (value > type(uint112).max) {
341
+ revert SafeCastOverflowedUintDowncast(112, value);
342
+ }
343
+ return uint112(value);
344
+ }
345
+
346
+ /**
347
+ * @dev Returns the downcasted uint104 from uint256, reverting on
348
+ * overflow (when the input is greater than largest uint104).
349
+ *
350
+ * Counterpart to Solidity's `uint104` operator.
351
+ *
352
+ * Requirements:
353
+ *
354
+ * - input must fit into 104 bits
355
+ */
356
+ function toUint104(uint256 value) internal pure returns (uint104) {
357
+ if (value > type(uint104).max) {
358
+ revert SafeCastOverflowedUintDowncast(104, value);
359
+ }
360
+ return uint104(value);
361
+ }
362
+
363
+ /**
364
+ * @dev Returns the downcasted uint96 from uint256, reverting on
365
+ * overflow (when the input is greater than largest uint96).
366
+ *
367
+ * Counterpart to Solidity's `uint96` operator.
368
+ *
369
+ * Requirements:
370
+ *
371
+ * - input must fit into 96 bits
372
+ */
373
+ function toUint96(uint256 value) internal pure returns (uint96) {
374
+ if (value > type(uint96).max) {
375
+ revert SafeCastOverflowedUintDowncast(96, value);
376
+ }
377
+ return uint96(value);
378
+ }
379
+
380
+ /**
381
+ * @dev Returns the downcasted uint88 from uint256, reverting on
382
+ * overflow (when the input is greater than largest uint88).
383
+ *
384
+ * Counterpart to Solidity's `uint88` operator.
385
+ *
386
+ * Requirements:
387
+ *
388
+ * - input must fit into 88 bits
389
+ */
390
+ function toUint88(uint256 value) internal pure returns (uint88) {
391
+ if (value > type(uint88).max) {
392
+ revert SafeCastOverflowedUintDowncast(88, value);
393
+ }
394
+ return uint88(value);
395
+ }
396
+
397
+ /**
398
+ * @dev Returns the downcasted uint80 from uint256, reverting on
399
+ * overflow (when the input is greater than largest uint80).
400
+ *
401
+ * Counterpart to Solidity's `uint80` operator.
402
+ *
403
+ * Requirements:
404
+ *
405
+ * - input must fit into 80 bits
406
+ */
407
+ function toUint80(uint256 value) internal pure returns (uint80) {
408
+ if (value > type(uint80).max) {
409
+ revert SafeCastOverflowedUintDowncast(80, value);
410
+ }
411
+ return uint80(value);
412
+ }
413
+
414
+ /**
415
+ * @dev Returns the downcasted uint72 from uint256, reverting on
416
+ * overflow (when the input is greater than largest uint72).
417
+ *
418
+ * Counterpart to Solidity's `uint72` operator.
419
+ *
420
+ * Requirements:
421
+ *
422
+ * - input must fit into 72 bits
423
+ */
424
+ function toUint72(uint256 value) internal pure returns (uint72) {
425
+ if (value > type(uint72).max) {
426
+ revert SafeCastOverflowedUintDowncast(72, value);
427
+ }
428
+ return uint72(value);
429
+ }
430
+
431
+ /**
432
+ * @dev Returns the downcasted uint64 from uint256, reverting on
433
+ * overflow (when the input is greater than largest uint64).
434
+ *
435
+ * Counterpart to Solidity's `uint64` operator.
436
+ *
437
+ * Requirements:
438
+ *
439
+ * - input must fit into 64 bits
440
+ */
441
+ function toUint64(uint256 value) internal pure returns (uint64) {
442
+ if (value > type(uint64).max) {
443
+ revert SafeCastOverflowedUintDowncast(64, value);
444
+ }
445
+ return uint64(value);
446
+ }
447
+
448
+ /**
449
+ * @dev Returns the downcasted uint56 from uint256, reverting on
450
+ * overflow (when the input is greater than largest uint56).
451
+ *
452
+ * Counterpart to Solidity's `uint56` operator.
453
+ *
454
+ * Requirements:
455
+ *
456
+ * - input must fit into 56 bits
457
+ */
458
+ function toUint56(uint256 value) internal pure returns (uint56) {
459
+ if (value > type(uint56).max) {
460
+ revert SafeCastOverflowedUintDowncast(56, value);
461
+ }
462
+ return uint56(value);
463
+ }
464
+
465
+ /**
466
+ * @dev Returns the downcasted uint48 from uint256, reverting on
467
+ * overflow (when the input is greater than largest uint48).
468
+ *
469
+ * Counterpart to Solidity's `uint48` operator.
470
+ *
471
+ * Requirements:
472
+ *
473
+ * - input must fit into 48 bits
474
+ */
475
+ function toUint48(uint256 value) internal pure returns (uint48) {
476
+ if (value > type(uint48).max) {
477
+ revert SafeCastOverflowedUintDowncast(48, value);
478
+ }
479
+ return uint48(value);
480
+ }
481
+
482
+ /**
483
+ * @dev Returns the downcasted uint40 from uint256, reverting on
484
+ * overflow (when the input is greater than largest uint40).
485
+ *
486
+ * Counterpart to Solidity's `uint40` operator.
487
+ *
488
+ * Requirements:
489
+ *
490
+ * - input must fit into 40 bits
491
+ */
492
+ function toUint40(uint256 value) internal pure returns (uint40) {
493
+ if (value > type(uint40).max) {
494
+ revert SafeCastOverflowedUintDowncast(40, value);
495
+ }
496
+ return uint40(value);
497
+ }
498
+
499
+ /**
500
+ * @dev Returns the downcasted uint32 from uint256, reverting on
501
+ * overflow (when the input is greater than largest uint32).
502
+ *
503
+ * Counterpart to Solidity's `uint32` operator.
504
+ *
505
+ * Requirements:
506
+ *
507
+ * - input must fit into 32 bits
508
+ */
509
+ function toUint32(uint256 value) internal pure returns (uint32) {
510
+ if (value > type(uint32).max) {
511
+ revert SafeCastOverflowedUintDowncast(32, value);
512
+ }
513
+ return uint32(value);
514
+ }
515
+
516
+ /**
517
+ * @dev Returns the downcasted uint24 from uint256, reverting on
518
+ * overflow (when the input is greater than largest uint24).
519
+ *
520
+ * Counterpart to Solidity's `uint24` operator.
521
+ *
522
+ * Requirements:
523
+ *
524
+ * - input must fit into 24 bits
525
+ */
526
+ function toUint24(uint256 value) internal pure returns (uint24) {
527
+ if (value > type(uint24).max) {
528
+ revert SafeCastOverflowedUintDowncast(24, value);
529
+ }
530
+ return uint24(value);
531
+ }
532
+
533
+ /**
534
+ * @dev Returns the downcasted uint16 from uint256, reverting on
535
+ * overflow (when the input is greater than largest uint16).
536
+ *
537
+ * Counterpart to Solidity's `uint16` operator.
538
+ *
539
+ * Requirements:
540
+ *
541
+ * - input must fit into 16 bits
542
+ */
543
+ function toUint16(uint256 value) internal pure returns (uint16) {
544
+ if (value > type(uint16).max) {
545
+ revert SafeCastOverflowedUintDowncast(16, value);
546
+ }
547
+ return uint16(value);
548
+ }
549
+
550
+ /**
551
+ * @dev Returns the downcasted uint8 from uint256, reverting on
552
+ * overflow (when the input is greater than largest uint8).
553
+ *
554
+ * Counterpart to Solidity's `uint8` operator.
555
+ *
556
+ * Requirements:
557
+ *
558
+ * - input must fit into 8 bits
559
+ */
560
+ function toUint8(uint256 value) internal pure returns (uint8) {
561
+ if (value > type(uint8).max) {
562
+ revert SafeCastOverflowedUintDowncast(8, value);
563
+ }
564
+ return uint8(value);
565
+ }
566
+
567
+ /**
568
+ * @dev Converts a signed int256 into an unsigned uint256.
569
+ *
570
+ * Requirements:
571
+ *
572
+ * - input must be greater than or equal to 0.
573
+ */
574
+ function toUint256(int256 value) internal pure returns (uint256) {
575
+ if (value < 0) {
576
+ revert SafeCastOverflowedIntToUint(value);
577
+ }
578
+ return uint256(value);
579
+ }
580
+
581
+ /**
582
+ * @dev Returns the downcasted int248 from int256, reverting on
583
+ * overflow (when the input is less than smallest int248 or
584
+ * greater than largest int248).
585
+ *
586
+ * Counterpart to Solidity's `int248` operator.
587
+ *
588
+ * Requirements:
589
+ *
590
+ * - input must fit into 248 bits
591
+ */
592
+ function toInt248(int256 value) internal pure returns (int248 downcasted) {
593
+ downcasted = int248(value);
594
+ if (downcasted != value) {
595
+ revert SafeCastOverflowedIntDowncast(248, value);
596
+ }
597
+ }
598
+
599
+ /**
600
+ * @dev Returns the downcasted int240 from int256, reverting on
601
+ * overflow (when the input is less than smallest int240 or
602
+ * greater than largest int240).
603
+ *
604
+ * Counterpart to Solidity's `int240` operator.
605
+ *
606
+ * Requirements:
607
+ *
608
+ * - input must fit into 240 bits
609
+ */
610
+ function toInt240(int256 value) internal pure returns (int240 downcasted) {
611
+ downcasted = int240(value);
612
+ if (downcasted != value) {
613
+ revert SafeCastOverflowedIntDowncast(240, value);
614
+ }
615
+ }
616
+
617
+ /**
618
+ * @dev Returns the downcasted int232 from int256, reverting on
619
+ * overflow (when the input is less than smallest int232 or
620
+ * greater than largest int232).
621
+ *
622
+ * Counterpart to Solidity's `int232` operator.
623
+ *
624
+ * Requirements:
625
+ *
626
+ * - input must fit into 232 bits
627
+ */
628
+ function toInt232(int256 value) internal pure returns (int232 downcasted) {
629
+ downcasted = int232(value);
630
+ if (downcasted != value) {
631
+ revert SafeCastOverflowedIntDowncast(232, value);
632
+ }
633
+ }
634
+
635
+ /**
636
+ * @dev Returns the downcasted int224 from int256, reverting on
637
+ * overflow (when the input is less than smallest int224 or
638
+ * greater than largest int224).
639
+ *
640
+ * Counterpart to Solidity's `int224` operator.
641
+ *
642
+ * Requirements:
643
+ *
644
+ * - input must fit into 224 bits
645
+ */
646
+ function toInt224(int256 value) internal pure returns (int224 downcasted) {
647
+ downcasted = int224(value);
648
+ if (downcasted != value) {
649
+ revert SafeCastOverflowedIntDowncast(224, value);
650
+ }
651
+ }
652
+
653
+ /**
654
+ * @dev Returns the downcasted int216 from int256, reverting on
655
+ * overflow (when the input is less than smallest int216 or
656
+ * greater than largest int216).
657
+ *
658
+ * Counterpart to Solidity's `int216` operator.
659
+ *
660
+ * Requirements:
661
+ *
662
+ * - input must fit into 216 bits
663
+ */
664
+ function toInt216(int256 value) internal pure returns (int216 downcasted) {
665
+ downcasted = int216(value);
666
+ if (downcasted != value) {
667
+ revert SafeCastOverflowedIntDowncast(216, value);
668
+ }
669
+ }
670
+
671
+ /**
672
+ * @dev Returns the downcasted int208 from int256, reverting on
673
+ * overflow (when the input is less than smallest int208 or
674
+ * greater than largest int208).
675
+ *
676
+ * Counterpart to Solidity's `int208` operator.
677
+ *
678
+ * Requirements:
679
+ *
680
+ * - input must fit into 208 bits
681
+ */
682
+ function toInt208(int256 value) internal pure returns (int208 downcasted) {
683
+ downcasted = int208(value);
684
+ if (downcasted != value) {
685
+ revert SafeCastOverflowedIntDowncast(208, value);
686
+ }
687
+ }
688
+
689
+ /**
690
+ * @dev Returns the downcasted int200 from int256, reverting on
691
+ * overflow (when the input is less than smallest int200 or
692
+ * greater than largest int200).
693
+ *
694
+ * Counterpart to Solidity's `int200` operator.
695
+ *
696
+ * Requirements:
697
+ *
698
+ * - input must fit into 200 bits
699
+ */
700
+ function toInt200(int256 value) internal pure returns (int200 downcasted) {
701
+ downcasted = int200(value);
702
+ if (downcasted != value) {
703
+ revert SafeCastOverflowedIntDowncast(200, value);
704
+ }
705
+ }
706
+
707
+ /**
708
+ * @dev Returns the downcasted int192 from int256, reverting on
709
+ * overflow (when the input is less than smallest int192 or
710
+ * greater than largest int192).
711
+ *
712
+ * Counterpart to Solidity's `int192` operator.
713
+ *
714
+ * Requirements:
715
+ *
716
+ * - input must fit into 192 bits
717
+ */
718
+ function toInt192(int256 value) internal pure returns (int192 downcasted) {
719
+ downcasted = int192(value);
720
+ if (downcasted != value) {
721
+ revert SafeCastOverflowedIntDowncast(192, value);
722
+ }
723
+ }
724
+
725
+ /**
726
+ * @dev Returns the downcasted int184 from int256, reverting on
727
+ * overflow (when the input is less than smallest int184 or
728
+ * greater than largest int184).
729
+ *
730
+ * Counterpart to Solidity's `int184` operator.
731
+ *
732
+ * Requirements:
733
+ *
734
+ * - input must fit into 184 bits
735
+ */
736
+ function toInt184(int256 value) internal pure returns (int184 downcasted) {
737
+ downcasted = int184(value);
738
+ if (downcasted != value) {
739
+ revert SafeCastOverflowedIntDowncast(184, value);
740
+ }
741
+ }
742
+
743
+ /**
744
+ * @dev Returns the downcasted int176 from int256, reverting on
745
+ * overflow (when the input is less than smallest int176 or
746
+ * greater than largest int176).
747
+ *
748
+ * Counterpart to Solidity's `int176` operator.
749
+ *
750
+ * Requirements:
751
+ *
752
+ * - input must fit into 176 bits
753
+ */
754
+ function toInt176(int256 value) internal pure returns (int176 downcasted) {
755
+ downcasted = int176(value);
756
+ if (downcasted != value) {
757
+ revert SafeCastOverflowedIntDowncast(176, value);
758
+ }
759
+ }
760
+
761
+ /**
762
+ * @dev Returns the downcasted int168 from int256, reverting on
763
+ * overflow (when the input is less than smallest int168 or
764
+ * greater than largest int168).
765
+ *
766
+ * Counterpart to Solidity's `int168` operator.
767
+ *
768
+ * Requirements:
769
+ *
770
+ * - input must fit into 168 bits
771
+ */
772
+ function toInt168(int256 value) internal pure returns (int168 downcasted) {
773
+ downcasted = int168(value);
774
+ if (downcasted != value) {
775
+ revert SafeCastOverflowedIntDowncast(168, value);
776
+ }
777
+ }
778
+
779
+ /**
780
+ * @dev Returns the downcasted int160 from int256, reverting on
781
+ * overflow (when the input is less than smallest int160 or
782
+ * greater than largest int160).
783
+ *
784
+ * Counterpart to Solidity's `int160` operator.
785
+ *
786
+ * Requirements:
787
+ *
788
+ * - input must fit into 160 bits
789
+ */
790
+ function toInt160(int256 value) internal pure returns (int160 downcasted) {
791
+ downcasted = int160(value);
792
+ if (downcasted != value) {
793
+ revert SafeCastOverflowedIntDowncast(160, value);
794
+ }
795
+ }
796
+
797
+ /**
798
+ * @dev Returns the downcasted int152 from int256, reverting on
799
+ * overflow (when the input is less than smallest int152 or
800
+ * greater than largest int152).
801
+ *
802
+ * Counterpart to Solidity's `int152` operator.
803
+ *
804
+ * Requirements:
805
+ *
806
+ * - input must fit into 152 bits
807
+ */
808
+ function toInt152(int256 value) internal pure returns (int152 downcasted) {
809
+ downcasted = int152(value);
810
+ if (downcasted != value) {
811
+ revert SafeCastOverflowedIntDowncast(152, value);
812
+ }
813
+ }
814
+
815
+ /**
816
+ * @dev Returns the downcasted int144 from int256, reverting on
817
+ * overflow (when the input is less than smallest int144 or
818
+ * greater than largest int144).
819
+ *
820
+ * Counterpart to Solidity's `int144` operator.
821
+ *
822
+ * Requirements:
823
+ *
824
+ * - input must fit into 144 bits
825
+ */
826
+ function toInt144(int256 value) internal pure returns (int144 downcasted) {
827
+ downcasted = int144(value);
828
+ if (downcasted != value) {
829
+ revert SafeCastOverflowedIntDowncast(144, value);
830
+ }
831
+ }
832
+
833
+ /**
834
+ * @dev Returns the downcasted int136 from int256, reverting on
835
+ * overflow (when the input is less than smallest int136 or
836
+ * greater than largest int136).
837
+ *
838
+ * Counterpart to Solidity's `int136` operator.
839
+ *
840
+ * Requirements:
841
+ *
842
+ * - input must fit into 136 bits
843
+ */
844
+ function toInt136(int256 value) internal pure returns (int136 downcasted) {
845
+ downcasted = int136(value);
846
+ if (downcasted != value) {
847
+ revert SafeCastOverflowedIntDowncast(136, value);
848
+ }
849
+ }
850
+
851
+ /**
852
+ * @dev Returns the downcasted int128 from int256, reverting on
853
+ * overflow (when the input is less than smallest int128 or
854
+ * greater than largest int128).
855
+ *
856
+ * Counterpart to Solidity's `int128` operator.
857
+ *
858
+ * Requirements:
859
+ *
860
+ * - input must fit into 128 bits
861
+ */
862
+ function toInt128(int256 value) internal pure returns (int128 downcasted) {
863
+ downcasted = int128(value);
864
+ if (downcasted != value) {
865
+ revert SafeCastOverflowedIntDowncast(128, value);
866
+ }
867
+ }
868
+
869
+ /**
870
+ * @dev Returns the downcasted int120 from int256, reverting on
871
+ * overflow (when the input is less than smallest int120 or
872
+ * greater than largest int120).
873
+ *
874
+ * Counterpart to Solidity's `int120` operator.
875
+ *
876
+ * Requirements:
877
+ *
878
+ * - input must fit into 120 bits
879
+ */
880
+ function toInt120(int256 value) internal pure returns (int120 downcasted) {
881
+ downcasted = int120(value);
882
+ if (downcasted != value) {
883
+ revert SafeCastOverflowedIntDowncast(120, value);
884
+ }
885
+ }
886
+
887
+ /**
888
+ * @dev Returns the downcasted int112 from int256, reverting on
889
+ * overflow (when the input is less than smallest int112 or
890
+ * greater than largest int112).
891
+ *
892
+ * Counterpart to Solidity's `int112` operator.
893
+ *
894
+ * Requirements:
895
+ *
896
+ * - input must fit into 112 bits
897
+ */
898
+ function toInt112(int256 value) internal pure returns (int112 downcasted) {
899
+ downcasted = int112(value);
900
+ if (downcasted != value) {
901
+ revert SafeCastOverflowedIntDowncast(112, value);
902
+ }
903
+ }
904
+
905
+ /**
906
+ * @dev Returns the downcasted int104 from int256, reverting on
907
+ * overflow (when the input is less than smallest int104 or
908
+ * greater than largest int104).
909
+ *
910
+ * Counterpart to Solidity's `int104` operator.
911
+ *
912
+ * Requirements:
913
+ *
914
+ * - input must fit into 104 bits
915
+ */
916
+ function toInt104(int256 value) internal pure returns (int104 downcasted) {
917
+ downcasted = int104(value);
918
+ if (downcasted != value) {
919
+ revert SafeCastOverflowedIntDowncast(104, value);
920
+ }
921
+ }
922
+
923
+ /**
924
+ * @dev Returns the downcasted int96 from int256, reverting on
925
+ * overflow (when the input is less than smallest int96 or
926
+ * greater than largest int96).
927
+ *
928
+ * Counterpart to Solidity's `int96` operator.
929
+ *
930
+ * Requirements:
931
+ *
932
+ * - input must fit into 96 bits
933
+ */
934
+ function toInt96(int256 value) internal pure returns (int96 downcasted) {
935
+ downcasted = int96(value);
936
+ if (downcasted != value) {
937
+ revert SafeCastOverflowedIntDowncast(96, value);
938
+ }
939
+ }
940
+
941
+ /**
942
+ * @dev Returns the downcasted int88 from int256, reverting on
943
+ * overflow (when the input is less than smallest int88 or
944
+ * greater than largest int88).
945
+ *
946
+ * Counterpart to Solidity's `int88` operator.
947
+ *
948
+ * Requirements:
949
+ *
950
+ * - input must fit into 88 bits
951
+ */
952
+ function toInt88(int256 value) internal pure returns (int88 downcasted) {
953
+ downcasted = int88(value);
954
+ if (downcasted != value) {
955
+ revert SafeCastOverflowedIntDowncast(88, value);
956
+ }
957
+ }
958
+
959
+ /**
960
+ * @dev Returns the downcasted int80 from int256, reverting on
961
+ * overflow (when the input is less than smallest int80 or
962
+ * greater than largest int80).
963
+ *
964
+ * Counterpart to Solidity's `int80` operator.
965
+ *
966
+ * Requirements:
967
+ *
968
+ * - input must fit into 80 bits
969
+ */
970
+ function toInt80(int256 value) internal pure returns (int80 downcasted) {
971
+ downcasted = int80(value);
972
+ if (downcasted != value) {
973
+ revert SafeCastOverflowedIntDowncast(80, value);
974
+ }
975
+ }
976
+
977
+ /**
978
+ * @dev Returns the downcasted int72 from int256, reverting on
979
+ * overflow (when the input is less than smallest int72 or
980
+ * greater than largest int72).
981
+ *
982
+ * Counterpart to Solidity's `int72` operator.
983
+ *
984
+ * Requirements:
985
+ *
986
+ * - input must fit into 72 bits
987
+ */
988
+ function toInt72(int256 value) internal pure returns (int72 downcasted) {
989
+ downcasted = int72(value);
990
+ if (downcasted != value) {
991
+ revert SafeCastOverflowedIntDowncast(72, value);
992
+ }
993
+ }
994
+
995
+ /**
996
+ * @dev Returns the downcasted int64 from int256, reverting on
997
+ * overflow (when the input is less than smallest int64 or
998
+ * greater than largest int64).
999
+ *
1000
+ * Counterpart to Solidity's `int64` operator.
1001
+ *
1002
+ * Requirements:
1003
+ *
1004
+ * - input must fit into 64 bits
1005
+ */
1006
+ function toInt64(int256 value) internal pure returns (int64 downcasted) {
1007
+ downcasted = int64(value);
1008
+ if (downcasted != value) {
1009
+ revert SafeCastOverflowedIntDowncast(64, value);
1010
+ }
1011
+ }
1012
+
1013
+ /**
1014
+ * @dev Returns the downcasted int56 from int256, reverting on
1015
+ * overflow (when the input is less than smallest int56 or
1016
+ * greater than largest int56).
1017
+ *
1018
+ * Counterpart to Solidity's `int56` operator.
1019
+ *
1020
+ * Requirements:
1021
+ *
1022
+ * - input must fit into 56 bits
1023
+ */
1024
+ function toInt56(int256 value) internal pure returns (int56 downcasted) {
1025
+ downcasted = int56(value);
1026
+ if (downcasted != value) {
1027
+ revert SafeCastOverflowedIntDowncast(56, value);
1028
+ }
1029
+ }
1030
+
1031
+ /**
1032
+ * @dev Returns the downcasted int48 from int256, reverting on
1033
+ * overflow (when the input is less than smallest int48 or
1034
+ * greater than largest int48).
1035
+ *
1036
+ * Counterpart to Solidity's `int48` operator.
1037
+ *
1038
+ * Requirements:
1039
+ *
1040
+ * - input must fit into 48 bits
1041
+ */
1042
+ function toInt48(int256 value) internal pure returns (int48 downcasted) {
1043
+ downcasted = int48(value);
1044
+ if (downcasted != value) {
1045
+ revert SafeCastOverflowedIntDowncast(48, value);
1046
+ }
1047
+ }
1048
+
1049
+ /**
1050
+ * @dev Returns the downcasted int40 from int256, reverting on
1051
+ * overflow (when the input is less than smallest int40 or
1052
+ * greater than largest int40).
1053
+ *
1054
+ * Counterpart to Solidity's `int40` operator.
1055
+ *
1056
+ * Requirements:
1057
+ *
1058
+ * - input must fit into 40 bits
1059
+ */
1060
+ function toInt40(int256 value) internal pure returns (int40 downcasted) {
1061
+ downcasted = int40(value);
1062
+ if (downcasted != value) {
1063
+ revert SafeCastOverflowedIntDowncast(40, value);
1064
+ }
1065
+ }
1066
+
1067
+ /**
1068
+ * @dev Returns the downcasted int32 from int256, reverting on
1069
+ * overflow (when the input is less than smallest int32 or
1070
+ * greater than largest int32).
1071
+ *
1072
+ * Counterpart to Solidity's `int32` operator.
1073
+ *
1074
+ * Requirements:
1075
+ *
1076
+ * - input must fit into 32 bits
1077
+ */
1078
+ function toInt32(int256 value) internal pure returns (int32 downcasted) {
1079
+ downcasted = int32(value);
1080
+ if (downcasted != value) {
1081
+ revert SafeCastOverflowedIntDowncast(32, value);
1082
+ }
1083
+ }
1084
+
1085
+ /**
1086
+ * @dev Returns the downcasted int24 from int256, reverting on
1087
+ * overflow (when the input is less than smallest int24 or
1088
+ * greater than largest int24).
1089
+ *
1090
+ * Counterpart to Solidity's `int24` operator.
1091
+ *
1092
+ * Requirements:
1093
+ *
1094
+ * - input must fit into 24 bits
1095
+ */
1096
+ function toInt24(int256 value) internal pure returns (int24 downcasted) {
1097
+ downcasted = int24(value);
1098
+ if (downcasted != value) {
1099
+ revert SafeCastOverflowedIntDowncast(24, value);
1100
+ }
1101
+ }
1102
+
1103
+ /**
1104
+ * @dev Returns the downcasted int16 from int256, reverting on
1105
+ * overflow (when the input is less than smallest int16 or
1106
+ * greater than largest int16).
1107
+ *
1108
+ * Counterpart to Solidity's `int16` operator.
1109
+ *
1110
+ * Requirements:
1111
+ *
1112
+ * - input must fit into 16 bits
1113
+ */
1114
+ function toInt16(int256 value) internal pure returns (int16 downcasted) {
1115
+ downcasted = int16(value);
1116
+ if (downcasted != value) {
1117
+ revert SafeCastOverflowedIntDowncast(16, value);
1118
+ }
1119
+ }
1120
+
1121
+ /**
1122
+ * @dev Returns the downcasted int8 from int256, reverting on
1123
+ * overflow (when the input is less than smallest int8 or
1124
+ * greater than largest int8).
1125
+ *
1126
+ * Counterpart to Solidity's `int8` operator.
1127
+ *
1128
+ * Requirements:
1129
+ *
1130
+ * - input must fit into 8 bits
1131
+ */
1132
+ function toInt8(int256 value) internal pure returns (int8 downcasted) {
1133
+ downcasted = int8(value);
1134
+ if (downcasted != value) {
1135
+ revert SafeCastOverflowedIntDowncast(8, value);
1136
+ }
1137
+ }
1138
+
1139
+ /**
1140
+ * @dev Converts an unsigned uint256 into a signed int256.
1141
+ *
1142
+ * Requirements:
1143
+ *
1144
+ * - input must be less than or equal to maxInt256.
1145
+ */
1146
+ function toInt256(uint256 value) internal pure returns (int256) {
1147
+ // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
1148
+ if (value > uint256(type(int256).max)) {
1149
+ revert SafeCastOverflowedUintToInt(value);
1150
+ }
1151
+ return int256(value);
1152
+ }
1153
+
1154
+ /**
1155
+ * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
1156
+ */
1157
+ function toUint(bool b) internal pure returns (uint256 u) {
1158
+ assembly ("memory-safe") {
1159
+ u := iszero(iszero(b))
1160
+ }
1161
+ }
1162
+ }
third_party/real_code/rc17/sources/@openzeppelin/contracts/utils/math/SignedMath.sol ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ import {SafeCast} from "./SafeCast.sol";
7
+
8
+ /**
9
+ * @dev Standard signed math utilities missing in the Solidity language.
10
+ */
11
+ library SignedMath {
12
+ /**
13
+ * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
14
+ *
15
+ * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
16
+ * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
17
+ * one branch when needed, making this function more expensive.
18
+ */
19
+ function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
20
+ unchecked {
21
+ // branchless ternary works because:
22
+ // b ^ (a ^ b) == a
23
+ // b ^ 0 == b
24
+ return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
25
+ }
26
+ }
27
+
28
+ /**
29
+ * @dev Returns the largest of two signed numbers.
30
+ */
31
+ function max(int256 a, int256 b) internal pure returns (int256) {
32
+ return ternary(a > b, a, b);
33
+ }
34
+
35
+ /**
36
+ * @dev Returns the smallest of two signed numbers.
37
+ */
38
+ function min(int256 a, int256 b) internal pure returns (int256) {
39
+ return ternary(a < b, a, b);
40
+ }
41
+
42
+ /**
43
+ * @dev Returns the average of two signed numbers without overflow.
44
+ * The result is rounded towards zero.
45
+ */
46
+ function average(int256 a, int256 b) internal pure returns (int256) {
47
+ // Formula from the book "Hacker's Delight"
48
+ int256 x = (a & b) + ((a ^ b) >> 1);
49
+ return x + (int256(uint256(x) >> 255) & (a ^ b));
50
+ }
51
+
52
+ /**
53
+ * @dev Returns the absolute unsigned value of a signed value.
54
+ */
55
+ function abs(int256 n) internal pure returns (uint256) {
56
+ unchecked {
57
+ // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
58
+ // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
59
+ // taking advantage of the most significant (or "sign" bit) in two's complement representation.
60
+ // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
61
+ // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
62
+ int256 mask = n >> 255;
63
+
64
+ // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
65
+ return uint256((n + mask) ^ mask);
66
+ }
67
+ }
68
+ }
third_party/real_code/rc17/sources/contracts/SharpNFT.sol ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // Compatible with OpenZeppelin Contracts ^5.0.0
3
+ pragma solidity ^0.8.22;
4
+
5
+ import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
6
+ import {ERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
7
+ import {ERC721URIStorage} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
8
+ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
9
+
10
+ contract SharpNFT is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable {
11
+ uint256 private _nextTokenId;
12
+ event Locked(uint256 tokenId);
13
+ constructor( address initialOwner) ERC721("SharpNFT", "SNFT") Ownable(initialOwner) {}
14
+
15
+ function safeMint(address to, string memory uri) public onlyOwner returns (uint256) {
16
+ uint256 tokenId = _nextTokenId++;
17
+ _safeMint(to, tokenId);
18
+ _setTokenURI(tokenId, uri);
19
+ emit Locked(tokenId);
20
+ return tokenId;
21
+ }
22
+
23
+ // The following functions are overrides required by Solidity.
24
+
25
+ function _update(address to, uint256 tokenId, address auth) internal override(ERC721, ERC721Enumerable) returns (address) {
26
+ return super._update(to, tokenId, auth);
27
+ }
28
+
29
+ function _increaseBalance(address account, uint128 value) internal override(ERC721, ERC721Enumerable) {
30
+ super._increaseBalance(account, value);
31
+ }
32
+
33
+ function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) {
34
+ return super.tokenURI(tokenId);
35
+ }
36
+
37
+ function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC721URIStorage) returns (bool)
38
+ {
39
+ return super.supportsInterface(interfaceId);
40
+ }
41
+ }
third_party/real_code/rc18/NOTICE ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Notice for rc18
2
+
3
+ This package contains smart contract source files verified on Sourcify.
4
+
5
+ ## Source Files and Licensing
6
+
7
+ - File: `@openzeppelin/contracts/access/Ownable.sol`
8
+ SPDX: MIT
9
+
10
+ - File: `@openzeppelin/contracts/security/ReentrancyGuard.sol`
11
+ SPDX: MIT
12
+
13
+ - File: `@openzeppelin/contracts/token/ERC721/IERC721.sol`
14
+ SPDX: MIT
15
+
16
+ - File: `@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol`
17
+ SPDX: MIT
18
+
19
+ - File: `@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol`
20
+ SPDX: MIT
21
+
22
+ - File: `@openzeppelin/contracts/utils/Address.sol`
23
+ SPDX: MIT
24
+
25
+ - File: `@openzeppelin/contracts/utils/Context.sol`
26
+ SPDX: MIT
27
+
28
+ - File: `@openzeppelin/contracts/utils/Strings.sol`
29
+ SPDX: MIT
30
+
31
+ - File: `@openzeppelin/contracts/utils/cryptography/MerkleProof.sol`
32
+ SPDX: MIT
33
+
34
+ - File: `@openzeppelin/contracts/utils/introspection/ERC165.sol`
35
+ SPDX: MIT
36
+
37
+ - File: `@openzeppelin/contracts/utils/introspection/IERC165.sol`
38
+ SPDX: MIT
39
+
40
+ - File: `contracts/PerkyPigs.sol`
41
+ SPDX: MIT
42
+
43
+ - File: `erc721a/contracts/ERC721A.sol`
44
+ SPDX: MIT
third_party/real_code/rc18/abi.json ADDED
@@ -0,0 +1,834 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "constructor",
4
+ "inputs": [
5
+ {
6
+ "name": "_tokenName",
7
+ "type": "string",
8
+ "internalType": "string"
9
+ },
10
+ {
11
+ "name": "_tokenSymbol",
12
+ "type": "string",
13
+ "internalType": "string"
14
+ },
15
+ {
16
+ "name": "_cost",
17
+ "type": "uint256",
18
+ "internalType": "uint256"
19
+ },
20
+ {
21
+ "name": "_maxSupply",
22
+ "type": "uint256",
23
+ "internalType": "uint256"
24
+ },
25
+ {
26
+ "name": "_maxMintAmountPerTx",
27
+ "type": "uint256",
28
+ "internalType": "uint256"
29
+ },
30
+ {
31
+ "name": "_hiddenMetadataUri",
32
+ "type": "string",
33
+ "internalType": "string"
34
+ }
35
+ ],
36
+ "stateMutability": "nonpayable"
37
+ },
38
+ {
39
+ "name": "ApprovalCallerNotOwnerNorApproved",
40
+ "type": "error",
41
+ "inputs": []
42
+ },
43
+ {
44
+ "name": "ApprovalQueryForNonexistentToken",
45
+ "type": "error",
46
+ "inputs": []
47
+ },
48
+ {
49
+ "name": "ApprovalToCurrentOwner",
50
+ "type": "error",
51
+ "inputs": []
52
+ },
53
+ {
54
+ "name": "ApproveToCaller",
55
+ "type": "error",
56
+ "inputs": []
57
+ },
58
+ {
59
+ "name": "BalanceQueryForZeroAddress",
60
+ "type": "error",
61
+ "inputs": []
62
+ },
63
+ {
64
+ "name": "MintToZeroAddress",
65
+ "type": "error",
66
+ "inputs": []
67
+ },
68
+ {
69
+ "name": "MintZeroQuantity",
70
+ "type": "error",
71
+ "inputs": []
72
+ },
73
+ {
74
+ "name": "OwnerQueryForNonexistentToken",
75
+ "type": "error",
76
+ "inputs": []
77
+ },
78
+ {
79
+ "name": "TransferCallerNotOwnerNorApproved",
80
+ "type": "error",
81
+ "inputs": []
82
+ },
83
+ {
84
+ "name": "TransferFromIncorrectOwner",
85
+ "type": "error",
86
+ "inputs": []
87
+ },
88
+ {
89
+ "name": "TransferToNonERC721ReceiverImplementer",
90
+ "type": "error",
91
+ "inputs": []
92
+ },
93
+ {
94
+ "name": "TransferToZeroAddress",
95
+ "type": "error",
96
+ "inputs": []
97
+ },
98
+ {
99
+ "name": "Approval",
100
+ "type": "event",
101
+ "inputs": [
102
+ {
103
+ "name": "owner",
104
+ "type": "address",
105
+ "indexed": true,
106
+ "internalType": "address"
107
+ },
108
+ {
109
+ "name": "approved",
110
+ "type": "address",
111
+ "indexed": true,
112
+ "internalType": "address"
113
+ },
114
+ {
115
+ "name": "tokenId",
116
+ "type": "uint256",
117
+ "indexed": true,
118
+ "internalType": "uint256"
119
+ }
120
+ ],
121
+ "anonymous": false
122
+ },
123
+ {
124
+ "name": "ApprovalForAll",
125
+ "type": "event",
126
+ "inputs": [
127
+ {
128
+ "name": "owner",
129
+ "type": "address",
130
+ "indexed": true,
131
+ "internalType": "address"
132
+ },
133
+ {
134
+ "name": "operator",
135
+ "type": "address",
136
+ "indexed": true,
137
+ "internalType": "address"
138
+ },
139
+ {
140
+ "name": "approved",
141
+ "type": "bool",
142
+ "indexed": false,
143
+ "internalType": "bool"
144
+ }
145
+ ],
146
+ "anonymous": false
147
+ },
148
+ {
149
+ "name": "OwnershipTransferred",
150
+ "type": "event",
151
+ "inputs": [
152
+ {
153
+ "name": "previousOwner",
154
+ "type": "address",
155
+ "indexed": true,
156
+ "internalType": "address"
157
+ },
158
+ {
159
+ "name": "newOwner",
160
+ "type": "address",
161
+ "indexed": true,
162
+ "internalType": "address"
163
+ }
164
+ ],
165
+ "anonymous": false
166
+ },
167
+ {
168
+ "name": "Transfer",
169
+ "type": "event",
170
+ "inputs": [
171
+ {
172
+ "name": "from",
173
+ "type": "address",
174
+ "indexed": true,
175
+ "internalType": "address"
176
+ },
177
+ {
178
+ "name": "to",
179
+ "type": "address",
180
+ "indexed": true,
181
+ "internalType": "address"
182
+ },
183
+ {
184
+ "name": "tokenId",
185
+ "type": "uint256",
186
+ "indexed": true,
187
+ "internalType": "uint256"
188
+ }
189
+ ],
190
+ "anonymous": false
191
+ },
192
+ {
193
+ "name": "approve",
194
+ "type": "function",
195
+ "inputs": [
196
+ {
197
+ "name": "to",
198
+ "type": "address",
199
+ "internalType": "address"
200
+ },
201
+ {
202
+ "name": "tokenId",
203
+ "type": "uint256",
204
+ "internalType": "uint256"
205
+ }
206
+ ],
207
+ "outputs": [],
208
+ "stateMutability": "nonpayable"
209
+ },
210
+ {
211
+ "name": "balanceOf",
212
+ "type": "function",
213
+ "inputs": [
214
+ {
215
+ "name": "owner",
216
+ "type": "address",
217
+ "internalType": "address"
218
+ }
219
+ ],
220
+ "outputs": [
221
+ {
222
+ "name": "",
223
+ "type": "uint256",
224
+ "internalType": "uint256"
225
+ }
226
+ ],
227
+ "stateMutability": "view"
228
+ },
229
+ {
230
+ "name": "cost",
231
+ "type": "function",
232
+ "inputs": [],
233
+ "outputs": [
234
+ {
235
+ "name": "",
236
+ "type": "uint256",
237
+ "internalType": "uint256"
238
+ }
239
+ ],
240
+ "stateMutability": "view"
241
+ },
242
+ {
243
+ "name": "getApproved",
244
+ "type": "function",
245
+ "inputs": [
246
+ {
247
+ "name": "tokenId",
248
+ "type": "uint256",
249
+ "internalType": "uint256"
250
+ }
251
+ ],
252
+ "outputs": [
253
+ {
254
+ "name": "",
255
+ "type": "address",
256
+ "internalType": "address"
257
+ }
258
+ ],
259
+ "stateMutability": "view"
260
+ },
261
+ {
262
+ "name": "hiddenMetadataUri",
263
+ "type": "function",
264
+ "inputs": [],
265
+ "outputs": [
266
+ {
267
+ "name": "",
268
+ "type": "string",
269
+ "internalType": "string"
270
+ }
271
+ ],
272
+ "stateMutability": "view"
273
+ },
274
+ {
275
+ "name": "isApprovedForAll",
276
+ "type": "function",
277
+ "inputs": [
278
+ {
279
+ "name": "owner",
280
+ "type": "address",
281
+ "internalType": "address"
282
+ },
283
+ {
284
+ "name": "operator",
285
+ "type": "address",
286
+ "internalType": "address"
287
+ }
288
+ ],
289
+ "outputs": [
290
+ {
291
+ "name": "",
292
+ "type": "bool",
293
+ "internalType": "bool"
294
+ }
295
+ ],
296
+ "stateMutability": "view"
297
+ },
298
+ {
299
+ "name": "maxMintAmountPerTx",
300
+ "type": "function",
301
+ "inputs": [],
302
+ "outputs": [
303
+ {
304
+ "name": "",
305
+ "type": "uint256",
306
+ "internalType": "uint256"
307
+ }
308
+ ],
309
+ "stateMutability": "view"
310
+ },
311
+ {
312
+ "name": "maxSupply",
313
+ "type": "function",
314
+ "inputs": [],
315
+ "outputs": [
316
+ {
317
+ "name": "",
318
+ "type": "uint256",
319
+ "internalType": "uint256"
320
+ }
321
+ ],
322
+ "stateMutability": "view"
323
+ },
324
+ {
325
+ "name": "merkleRoot",
326
+ "type": "function",
327
+ "inputs": [],
328
+ "outputs": [
329
+ {
330
+ "name": "",
331
+ "type": "bytes32",
332
+ "internalType": "bytes32"
333
+ }
334
+ ],
335
+ "stateMutability": "view"
336
+ },
337
+ {
338
+ "name": "mint",
339
+ "type": "function",
340
+ "inputs": [
341
+ {
342
+ "name": "_mintAmount",
343
+ "type": "uint256",
344
+ "internalType": "uint256"
345
+ }
346
+ ],
347
+ "outputs": [],
348
+ "stateMutability": "payable"
349
+ },
350
+ {
351
+ "name": "mintForAddress",
352
+ "type": "function",
353
+ "inputs": [
354
+ {
355
+ "name": "_mintAmount",
356
+ "type": "uint256",
357
+ "internalType": "uint256"
358
+ },
359
+ {
360
+ "name": "_receiver",
361
+ "type": "address",
362
+ "internalType": "address"
363
+ }
364
+ ],
365
+ "outputs": [],
366
+ "stateMutability": "nonpayable"
367
+ },
368
+ {
369
+ "name": "name",
370
+ "type": "function",
371
+ "inputs": [],
372
+ "outputs": [
373
+ {
374
+ "name": "",
375
+ "type": "string",
376
+ "internalType": "string"
377
+ }
378
+ ],
379
+ "stateMutability": "view"
380
+ },
381
+ {
382
+ "name": "owner",
383
+ "type": "function",
384
+ "inputs": [],
385
+ "outputs": [
386
+ {
387
+ "name": "",
388
+ "type": "address",
389
+ "internalType": "address"
390
+ }
391
+ ],
392
+ "stateMutability": "view"
393
+ },
394
+ {
395
+ "name": "ownerOf",
396
+ "type": "function",
397
+ "inputs": [
398
+ {
399
+ "name": "tokenId",
400
+ "type": "uint256",
401
+ "internalType": "uint256"
402
+ }
403
+ ],
404
+ "outputs": [
405
+ {
406
+ "name": "",
407
+ "type": "address",
408
+ "internalType": "address"
409
+ }
410
+ ],
411
+ "stateMutability": "view"
412
+ },
413
+ {
414
+ "name": "paused",
415
+ "type": "function",
416
+ "inputs": [],
417
+ "outputs": [
418
+ {
419
+ "name": "",
420
+ "type": "bool",
421
+ "internalType": "bool"
422
+ }
423
+ ],
424
+ "stateMutability": "view"
425
+ },
426
+ {
427
+ "name": "renounceOwnership",
428
+ "type": "function",
429
+ "inputs": [],
430
+ "outputs": [],
431
+ "stateMutability": "nonpayable"
432
+ },
433
+ {
434
+ "name": "revealed",
435
+ "type": "function",
436
+ "inputs": [],
437
+ "outputs": [
438
+ {
439
+ "name": "",
440
+ "type": "bool",
441
+ "internalType": "bool"
442
+ }
443
+ ],
444
+ "stateMutability": "view"
445
+ },
446
+ {
447
+ "name": "safeTransferFrom",
448
+ "type": "function",
449
+ "inputs": [
450
+ {
451
+ "name": "from",
452
+ "type": "address",
453
+ "internalType": "address"
454
+ },
455
+ {
456
+ "name": "to",
457
+ "type": "address",
458
+ "internalType": "address"
459
+ },
460
+ {
461
+ "name": "tokenId",
462
+ "type": "uint256",
463
+ "internalType": "uint256"
464
+ }
465
+ ],
466
+ "outputs": [],
467
+ "stateMutability": "nonpayable"
468
+ },
469
+ {
470
+ "name": "safeTransferFrom",
471
+ "type": "function",
472
+ "inputs": [
473
+ {
474
+ "name": "from",
475
+ "type": "address",
476
+ "internalType": "address"
477
+ },
478
+ {
479
+ "name": "to",
480
+ "type": "address",
481
+ "internalType": "address"
482
+ },
483
+ {
484
+ "name": "tokenId",
485
+ "type": "uint256",
486
+ "internalType": "uint256"
487
+ },
488
+ {
489
+ "name": "_data",
490
+ "type": "bytes",
491
+ "internalType": "bytes"
492
+ }
493
+ ],
494
+ "outputs": [],
495
+ "stateMutability": "nonpayable"
496
+ },
497
+ {
498
+ "name": "setApprovalForAll",
499
+ "type": "function",
500
+ "inputs": [
501
+ {
502
+ "name": "operator",
503
+ "type": "address",
504
+ "internalType": "address"
505
+ },
506
+ {
507
+ "name": "approved",
508
+ "type": "bool",
509
+ "internalType": "bool"
510
+ }
511
+ ],
512
+ "outputs": [],
513
+ "stateMutability": "nonpayable"
514
+ },
515
+ {
516
+ "name": "setCost",
517
+ "type": "function",
518
+ "inputs": [
519
+ {
520
+ "name": "_cost",
521
+ "type": "uint256",
522
+ "internalType": "uint256"
523
+ }
524
+ ],
525
+ "outputs": [],
526
+ "stateMutability": "nonpayable"
527
+ },
528
+ {
529
+ "name": "setHiddenMetadataUri",
530
+ "type": "function",
531
+ "inputs": [
532
+ {
533
+ "name": "_hiddenMetadataUri",
534
+ "type": "string",
535
+ "internalType": "string"
536
+ }
537
+ ],
538
+ "outputs": [],
539
+ "stateMutability": "nonpayable"
540
+ },
541
+ {
542
+ "name": "setMaxMintAmountPerTx",
543
+ "type": "function",
544
+ "inputs": [
545
+ {
546
+ "name": "_maxMintAmountPerTx",
547
+ "type": "uint256",
548
+ "internalType": "uint256"
549
+ }
550
+ ],
551
+ "outputs": [],
552
+ "stateMutability": "nonpayable"
553
+ },
554
+ {
555
+ "name": "setMerkleRoot",
556
+ "type": "function",
557
+ "inputs": [
558
+ {
559
+ "name": "_merkleRoot",
560
+ "type": "bytes32",
561
+ "internalType": "bytes32"
562
+ }
563
+ ],
564
+ "outputs": [],
565
+ "stateMutability": "nonpayable"
566
+ },
567
+ {
568
+ "name": "setPaused",
569
+ "type": "function",
570
+ "inputs": [
571
+ {
572
+ "name": "_state",
573
+ "type": "bool",
574
+ "internalType": "bool"
575
+ }
576
+ ],
577
+ "outputs": [],
578
+ "stateMutability": "nonpayable"
579
+ },
580
+ {
581
+ "name": "setRevealed",
582
+ "type": "function",
583
+ "inputs": [
584
+ {
585
+ "name": "_state",
586
+ "type": "bool",
587
+ "internalType": "bool"
588
+ }
589
+ ],
590
+ "outputs": [],
591
+ "stateMutability": "nonpayable"
592
+ },
593
+ {
594
+ "name": "setUriPrefix",
595
+ "type": "function",
596
+ "inputs": [
597
+ {
598
+ "name": "_uriPrefix",
599
+ "type": "string",
600
+ "internalType": "string"
601
+ }
602
+ ],
603
+ "outputs": [],
604
+ "stateMutability": "nonpayable"
605
+ },
606
+ {
607
+ "name": "setUriSuffix",
608
+ "type": "function",
609
+ "inputs": [
610
+ {
611
+ "name": "_uriSuffix",
612
+ "type": "string",
613
+ "internalType": "string"
614
+ }
615
+ ],
616
+ "outputs": [],
617
+ "stateMutability": "nonpayable"
618
+ },
619
+ {
620
+ "name": "setWhitelistMintEnabled",
621
+ "type": "function",
622
+ "inputs": [
623
+ {
624
+ "name": "_state",
625
+ "type": "bool",
626
+ "internalType": "bool"
627
+ }
628
+ ],
629
+ "outputs": [],
630
+ "stateMutability": "nonpayable"
631
+ },
632
+ {
633
+ "name": "supportsInterface",
634
+ "type": "function",
635
+ "inputs": [
636
+ {
637
+ "name": "interfaceId",
638
+ "type": "bytes4",
639
+ "internalType": "bytes4"
640
+ }
641
+ ],
642
+ "outputs": [
643
+ {
644
+ "name": "",
645
+ "type": "bool",
646
+ "internalType": "bool"
647
+ }
648
+ ],
649
+ "stateMutability": "view"
650
+ },
651
+ {
652
+ "name": "symbol",
653
+ "type": "function",
654
+ "inputs": [],
655
+ "outputs": [
656
+ {
657
+ "name": "",
658
+ "type": "string",
659
+ "internalType": "string"
660
+ }
661
+ ],
662
+ "stateMutability": "view"
663
+ },
664
+ {
665
+ "name": "tokenURI",
666
+ "type": "function",
667
+ "inputs": [
668
+ {
669
+ "name": "_tokenId",
670
+ "type": "uint256",
671
+ "internalType": "uint256"
672
+ }
673
+ ],
674
+ "outputs": [
675
+ {
676
+ "name": "",
677
+ "type": "string",
678
+ "internalType": "string"
679
+ }
680
+ ],
681
+ "stateMutability": "view"
682
+ },
683
+ {
684
+ "name": "totalSupply",
685
+ "type": "function",
686
+ "inputs": [],
687
+ "outputs": [
688
+ {
689
+ "name": "",
690
+ "type": "uint256",
691
+ "internalType": "uint256"
692
+ }
693
+ ],
694
+ "stateMutability": "view"
695
+ },
696
+ {
697
+ "name": "transferFrom",
698
+ "type": "function",
699
+ "inputs": [
700
+ {
701
+ "name": "from",
702
+ "type": "address",
703
+ "internalType": "address"
704
+ },
705
+ {
706
+ "name": "to",
707
+ "type": "address",
708
+ "internalType": "address"
709
+ },
710
+ {
711
+ "name": "tokenId",
712
+ "type": "uint256",
713
+ "internalType": "uint256"
714
+ }
715
+ ],
716
+ "outputs": [],
717
+ "stateMutability": "nonpayable"
718
+ },
719
+ {
720
+ "name": "transferOwnership",
721
+ "type": "function",
722
+ "inputs": [
723
+ {
724
+ "name": "newOwner",
725
+ "type": "address",
726
+ "internalType": "address"
727
+ }
728
+ ],
729
+ "outputs": [],
730
+ "stateMutability": "nonpayable"
731
+ },
732
+ {
733
+ "name": "uriPrefix",
734
+ "type": "function",
735
+ "inputs": [],
736
+ "outputs": [
737
+ {
738
+ "name": "",
739
+ "type": "string",
740
+ "internalType": "string"
741
+ }
742
+ ],
743
+ "stateMutability": "view"
744
+ },
745
+ {
746
+ "name": "uriSuffix",
747
+ "type": "function",
748
+ "inputs": [],
749
+ "outputs": [
750
+ {
751
+ "name": "",
752
+ "type": "string",
753
+ "internalType": "string"
754
+ }
755
+ ],
756
+ "stateMutability": "view"
757
+ },
758
+ {
759
+ "name": "walletOfOwner",
760
+ "type": "function",
761
+ "inputs": [
762
+ {
763
+ "name": "_owner",
764
+ "type": "address",
765
+ "internalType": "address"
766
+ }
767
+ ],
768
+ "outputs": [
769
+ {
770
+ "name": "",
771
+ "type": "uint256[]",
772
+ "internalType": "uint256[]"
773
+ }
774
+ ],
775
+ "stateMutability": "view"
776
+ },
777
+ {
778
+ "name": "whitelistClaimed",
779
+ "type": "function",
780
+ "inputs": [
781
+ {
782
+ "name": "",
783
+ "type": "address",
784
+ "internalType": "address"
785
+ }
786
+ ],
787
+ "outputs": [
788
+ {
789
+ "name": "",
790
+ "type": "bool",
791
+ "internalType": "bool"
792
+ }
793
+ ],
794
+ "stateMutability": "view"
795
+ },
796
+ {
797
+ "name": "whitelistMint",
798
+ "type": "function",
799
+ "inputs": [
800
+ {
801
+ "name": "_mintAmount",
802
+ "type": "uint256",
803
+ "internalType": "uint256"
804
+ },
805
+ {
806
+ "name": "_merkleProof",
807
+ "type": "bytes32[]",
808
+ "internalType": "bytes32[]"
809
+ }
810
+ ],
811
+ "outputs": [],
812
+ "stateMutability": "payable"
813
+ },
814
+ {
815
+ "name": "whitelistMintEnabled",
816
+ "type": "function",
817
+ "inputs": [],
818
+ "outputs": [
819
+ {
820
+ "name": "",
821
+ "type": "bool",
822
+ "internalType": "bool"
823
+ }
824
+ ],
825
+ "stateMutability": "view"
826
+ },
827
+ {
828
+ "name": "withdraw",
829
+ "type": "function",
830
+ "inputs": [],
831
+ "outputs": [],
832
+ "stateMutability": "nonpayable"
833
+ }
834
+ ]
third_party/real_code/rc18/creation.hex ADDED
@@ -0,0 +1 @@
 
 
1
+ 0x60a06040819052600060808190526200001b91600c916200025d565b5060408051808201909152600580825264173539b7b760d91b60209092019182526200004a91600d916200025d565b506012805462ffffff191660011790553480156200006757600080fd5b5060405162002b2238038062002b228339810160408190526200008a91620003d0565b855186908690620000a39060029060208501906200025d565b508051620000b99060039060208401906200025d565b5050600160005550620000cc3362000103565b6001600955620000dc8462000155565b6010839055620000ec82620001a9565b620000f781620001f9565b505050505050620004ba565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6008546001600160a01b03163314620001a45760405162461bcd60e51b8152602060048201819052602482015260008051602062002b0283398151915260448201526064015b60405180910390fd5b600f55565b6008546001600160a01b03163314620001f45760405162461bcd60e51b8152602060048201819052602482015260008051602062002b0283398151915260448201526064016200019b565b601155565b6008546001600160a01b03163314620002445760405162461bcd60e51b8152602060048201819052602482015260008051602062002b0283398151915260448201526064016200019b565b80516200025990600e9060208401906200025d565b5050565b8280546200026b906200047d565b90600052602060002090601f0160209004810192826200028f5760008555620002da565b82601f10620002aa57805160ff1916838001178555620002da565b82800160010185558215620002da579182015b82811115620002da578251825591602001919060010190620002bd565b50620002e8929150620002ec565b5090565b5b80821115620002e85760008155600101620002ed565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200032b57600080fd5b81516001600160401b038082111562000348576200034862000303565b604051601f8301601f19908116603f0116810190828211818310171562000373576200037362000303565b816040528381526020925086838588010111156200039057600080fd5b600091505b83821015620003b4578582018301518183018401529082019062000395565b83821115620003c65760008385830101525b9695505050505050565b60008060008060008060c08789031215620003ea57600080fd5b86516001600160401b03808211156200040257600080fd5b620004108a838b0162000319565b975060208901519150808211156200042757600080fd5b620004358a838b0162000319565b965060408901519550606089015194506080890151935060a08901519150808211156200046157600080fd5b506200047089828a0162000319565b9150509295509295509295565b600181811c908216806200049257607f821691505b60208210811415620004b457634e487b7160e01b600052602260045260246000fd5b50919050565b61263880620004ca6000396000f3fe6080604052600436106102515760003560e01c806370a0823111610139578063b071401b116100b6578063d5abeb011161007a578063d5abeb011461069d578063db4bec44146106b3578063e0a80853146106e3578063e985e9c514610703578063efbd73f41461074c578063f2fde38b1461076c57600080fd5b8063b071401b1461060a578063b767a0981461062a578063b88d4fde1461064a578063c87b56dd1461066a578063d2cab0561461068a57600080fd5b806394354fd0116100fd57806394354fd01461059757806395d89b41146105ad578063a0712d68146105c2578063a22cb465146105d5578063a45ba8e7146105f557600080fd5b806370a0823114610504578063715018a6146105245780637cb64759146105395780637ec4a659146105595780638da5cb5b1461057957600080fd5b80633ccfd60b116101d2578063518302271161019657806351830227146104615780635503a0e8146104815780635c975abb1461049657806362b99ad4146104b05780636352211e146104c55780636caede3d146104e557600080fd5b80633ccfd60b146103bf57806342842e0e146103d4578063438b6300146103f457806344a0d68a146104215780634fdd43cb1461044157600080fd5b806316ba10e01161021957806316ba10e01461032b57806316c38b3c1461034b57806318160ddd1461036b57806323b872dd146103895780632eb4a7ab146103a957600080fd5b806301ffc9a71461025657806306fdde031461028b578063081812fc146102ad578063095ea7b3146102e557806313faede614610307575b600080fd5b34801561026257600080fd5b50610276610271366004611f4c565b61078c565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a06107de565b6040516102829190611fc1565b3480156102b957600080fd5b506102cd6102c8366004611fd4565b610870565b6040516001600160a01b039091168152602001610282565b3480156102f157600080fd5b50610305610300366004612009565b6108b4565b005b34801561031357600080fd5b5061031d600f5481565b604051908152602001610282565b34801561033757600080fd5b506103056103463660046120be565b610942565b34801561035757600080fd5b50610305610366366004612116565b61098c565b34801561037757600080fd5b5061031d600154600054036000190190565b34801561039557600080fd5b506103056103a4366004612131565b6109c9565b3480156103b557600080fd5b5061031d600a5481565b3480156103cb57600080fd5b506103056109d4565b3480156103e057600080fd5b506103056103ef366004612131565b610acf565b34801561040057600080fd5b5061041461040f36600461216d565b610aea565b6040516102829190612188565b34801561042d57600080fd5b5061030561043c366004611fd4565b610c2a565b34801561044d57600080fd5b5061030561045c3660046120be565b610c59565b34801561046d57600080fd5b506012546102769062010000900460ff1681565b34801561048d57600080fd5b506102a0610c96565b3480156104a257600080fd5b506012546102769060ff1681565b3480156104bc57600080fd5b506102a0610d24565b3480156104d157600080fd5b506102cd6104e0366004611fd4565b610d31565b3480156104f157600080fd5b5060125461027690610100900460ff1681565b34801561051057600080fd5b5061031d61051f36600461216d565b610d43565b34801561053057600080fd5b50610305610d91565b34801561054557600080fd5b50610305610554366004611fd4565b610dc7565b34801561056557600080fd5b506103056105743660046120be565b610df6565b34801561058557600080fd5b506008546001600160a01b03166102cd565b3480156105a357600080fd5b5061031d60115481565b3480156105b957600080fd5b506102a0610e33565b6103056105d0366004611fd4565b610e42565b3480156105e157600080fd5b506103056105f03660046121cc565b610f5f565b34801561060157600080fd5b506102a0610ff5565b34801561061657600080fd5b50610305610625366004611fd4565b611002565b34801561063657600080fd5b50610305610645366004612116565b611031565b34801561065657600080fd5b506103056106653660046121ff565b611075565b34801561067657600080fd5b506102a0610685366004611fd4565b6110c6565b61030561069836600461227a565b611236565b3480156106a957600080fd5b5061031d60105481565b3480156106bf57600080fd5b506102766106ce36600461216d565b600b6020526000908152604090205460ff1681565b3480156106ef57600080fd5b506103056106fe366004612116565b61149b565b34801561070f57600080fd5b5061027661071e3660046122f8565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b34801561075857600080fd5b50610305610767366004612322565b6114e1565b34801561077857600080fd5b5061030561078736600461216d565b611581565b60006001600160e01b031982166380ac58cd60e01b14806107bd57506001600160e01b03198216635b5e139f60e01b145b806107d857506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600280546107ed90612345565b80601f016020809104026020016040519081016040528092919081815260200182805461081990612345565b80156108665780601f1061083b57610100808354040283529160200191610866565b820191906000526020600020905b81548152906001019060200180831161084957829003601f168201915b5050505050905090565b600061087b8261161c565b610898576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b60006108bf82610d31565b9050806001600160a01b0316836001600160a01b031614156108f45760405163250fdee360e21b815260040160405180910390fd5b336001600160a01b038216148015906109145750610912813361071e565b155b15610932576040516367d9dca160e11b815260040160405180910390fd5b61093d838383611655565b505050565b6008546001600160a01b031633146109755760405162461bcd60e51b815260040161096c90612380565b60405180910390fd5b805161098890600d906020840190611e9d565b5050565b6008546001600160a01b031633146109b65760405162461bcd60e51b815260040161096c90612380565b6012805460ff1916911515919091179055565b61093d8383836116b1565b6008546001600160a01b031633146109fe5760405162461bcd60e51b815260040161096c90612380565b60026009541415610a515760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161096c565b60026009556000610a6a6008546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610ab4576040519150601f19603f3d011682016040523d82523d6000602084013e610ab9565b606091505b5050905080610ac757600080fd5b506001600955565b61093d83838360405180602001604052806000815250611075565b60606000610af783610d43565b90506000816001600160401b03811115610b1357610b13612033565b604051908082528060200260200182016040528015610b3c578160200160208202803683370190505b50905060016000805b8482108015610b55575060005483105b15610c1f57600083815260046020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff16151591810182905290610c0c5780516001600160a01b031615610bc657805191505b876001600160a01b0316826001600160a01b03161415610c0c5783858481518110610bf357610bf36123b5565b602090810291909101015282610c08816123e1565b9350505b83610c16816123e1565b94505050610b45565b509195945050505050565b6008546001600160a01b03163314610c545760405162461bcd60e51b815260040161096c90612380565b600f55565b6008546001600160a01b03163314610c835760405162461bcd60e51b815260040161096c90612380565b805161098890600e906020840190611e9d565b600d8054610ca390612345565b80601f0160208091040260200160405190810160405280929190818152602001828054610ccf90612345565b8015610d1c5780601f10610cf157610100808354040283529160200191610d1c565b820191906000526020600020905b815481529060010190602001808311610cff57829003601f168201915b505050505081565b600c8054610ca390612345565b6000610d3c8261189f565b5192915050565b60006001600160a01b038216610d6c576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b6008546001600160a01b03163314610dbb5760405162461bcd60e51b815260040161096c90612380565b610dc560006119c6565b565b6008546001600160a01b03163314610df15760405162461bcd60e51b815260040161096c90612380565b600a55565b6008546001600160a01b03163314610e205760405162461bcd60e51b815260040161096c90612380565b805161098890600c906020840190611e9d565b6060600380546107ed90612345565b80600081118015610e5557506011548111155b610e715760405162461bcd60e51b815260040161096c906123fc565b60105481610e86600154600054036000190190565b610e90919061242a565b1115610eae5760405162461bcd60e51b815260040161096c90612442565b8180600f54610ebd9190612470565b341015610f025760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b604482015260640161096c565b60125460ff1615610f555760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e74726163742069732070617573656421000000000000000000604482015260640161096c565b61093d3384611a18565b6001600160a01b038216331415610f895760405163b06307db60e01b815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600e8054610ca390612345565b6008546001600160a01b0316331461102c5760405162461bcd60e51b815260040161096c90612380565b601155565b6008546001600160a01b0316331461105b5760405162461bcd60e51b815260040161096c90612380565b601280549115156101000261ff0019909216919091179055565b6110808484846116b1565b6001600160a01b0383163b151580156110a257506110a084848484611a32565b155b156110c0576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b60606110d18261161c565b6111355760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161096c565b60125462010000900460ff166111d757600e805461115290612345565b80601f016020809104026020016040519081016040528092919081815260200182805461117e90612345565b80156111cb5780601f106111a0576101008083540402835291602001916111cb565b820191906000526020600020905b8154815290600101906020018083116111ae57829003601f168201915b50505050509050919050565b60006111e1611b2a565b90506000815111611201576040518060200160405280600081525061122f565b8061120b84611b39565b600d60405160200161121f9392919061248f565b6040516020818303038152906040525b9392505050565b8260008111801561124957506011548111155b6112655760405162461bcd60e51b815260040161096c906123fc565b6010548161127a600154600054036000190190565b611284919061242a565b11156112a25760405162461bcd60e51b815260040161096c90612442565b8380600f546112b19190612470565b3410156112f65760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b604482015260640161096c565b601254610100900460ff166113585760405162461bcd60e51b815260206004820152602260248201527f5468652077686974656c6973742073616c65206973206e6f7420656e61626c65604482015261642160f01b606482015260840161096c565b336000908152600b602052604090205460ff16156113b85760405162461bcd60e51b815260206004820152601860248201527f4164647265737320616c726561647920636c61696d6564210000000000000000604482015260640161096c565b6040516bffffffffffffffffffffffff193360601b16602082015260009060340160405160208183030381529060405280519060200120905061143285858080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600a549150849050611c36565b61146f5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c69642070726f6f662160901b604482015260640161096c565b336000818152600b60205260409020805460ff191660011790556114939087611a18565b505050505050565b6008546001600160a01b031633146114c55760405162461bcd60e51b815260040161096c90612380565b60128054911515620100000262ff000019909216919091179055565b816000811180156114f457506011548111155b6115105760405162461bcd60e51b815260040161096c906123fc565b60105481611525600154600054036000190190565b61152f919061242a565b111561154d5760405162461bcd60e51b815260040161096c90612442565b6008546001600160a01b031633146115775760405162461bcd60e51b815260040161096c90612380565b61093d8284611a18565b6008546001600160a01b031633146115ab5760405162461bcd60e51b815260040161096c90612380565b6001600160a01b0381166116105760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161096c565b611619816119c6565b50565b600081600111158015611630575060005482105b80156107d8575050600090815260046020526040902054600160e01b900460ff161590565b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006116bc8261189f565b9050836001600160a01b031681600001516001600160a01b0316146116f35760405162a1148160e81b815260040160405180910390fd5b6000336001600160a01b03861614806117115750611711853361071e565b8061172c57503361172184610870565b6001600160a01b0316145b90508061174c57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b03841661177357604051633a954ecd60e21b815260040160405180910390fd5b61177f60008487611655565b6001600160a01b038581166000908152600560209081526040808320805467ffffffffffffffff198082166001600160401b0392831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600490945282852080546001600160e01b031916909417600160a01b4290921691909102178355870180845292208054919390911661185357600054821461185357805460208601516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b038a16171781555b50505082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b604080516060810182526000808252602082018190529181019190915281806001111580156118cf575060005481105b156119ad57600081815260046020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff161515918101829052906119ab5780516001600160a01b031615611942579392505050565b5060001901600081815260046020908152604091829020825160608101845290546001600160a01b038116808352600160a01b82046001600160401b031693830193909352600160e01b900460ff16151592810192909252156119a6579392505050565b611942565b505b604051636f96cda160e11b815260040160405180910390fd5b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610988828260405180602001604052806000815250611c4c565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290611a67903390899088908890600401612553565b602060405180830381600087803b158015611a8157600080fd5b505af1925050508015611ab1575060408051601f3d908101601f19168201909252611aae91810190612590565b60015b611b0c573d808015611adf576040519150601f19603f3d011682016040523d82523d6000602084013e611ae4565b606091505b508051611b04576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b6060600c80546107ed90612345565b606081611b5d5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611b875780611b71816123e1565b9150611b809050600a836125c3565b9150611b61565b6000816001600160401b03811115611ba157611ba1612033565b6040519080825280601f01601f191660200182016040528015611bcb576020820181803683370190505b5090505b8415611b2257611be06001836125d7565b9150611bed600a866125ee565b611bf890603061242a565b60f81b818381518110611c0d57611c0d6123b5565b60200101906001600160f81b031916908160001a905350611c2f600a866125c3565b9450611bcf565b600082611c438584611c59565b14949350505050565b61093d8383836001611ccd565b600081815b8451811015611cc5576000858281518110611c7b57611c7b6123b5565b60200260200101519050808311611ca15760008381526020829052604090209250611cb2565b600081815260208490526040902092505b5080611cbd816123e1565b915050611c5e565b509392505050565b6000546001600160a01b038516611cf657604051622e076360e81b815260040160405180910390fd5b83611d145760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b038516600081815260056020908152604080832080546fffffffffffffffffffffffffffffffff1981166001600160401b038083168c0181169182176801000000000000000067ffffffffffffffff1990941690921783900481168c01811690920217909155858452600490925290912080546001600160e01b031916909217600160a01b429092169190910217905580808501838015611dc557506001600160a01b0387163b15155b15611e4e575b60405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4611e166000888480600101955088611a32565b611e33576040516368d2bf6b60e11b815260040160405180910390fd5b80821415611dcb578260005414611e4957600080fd5b611e94565b5b6040516001830192906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a480821415611e4f575b50600055611898565b828054611ea990612345565b90600052602060002090601f016020900481019282611ecb5760008555611f11565b82601f10611ee457805160ff1916838001178555611f11565b82800160010185558215611f11579182015b82811115611f11578251825591602001919060010190611ef6565b50611f1d929150611f21565b5090565b5b80821115611f1d5760008155600101611f22565b6001600160e01b03198116811461161957600080fd5b600060208284031215611f5e57600080fd5b813561122f81611f36565b60005b83811015611f84578181015183820152602001611f6c565b838111156110c05750506000910152565b60008151808452611fad816020860160208601611f69565b601f01601f19169290920160200192915050565b60208152600061122f6020830184611f95565b600060208284031215611fe657600080fd5b5035919050565b80356001600160a01b038116811461200457600080fd5b919050565b6000806040838503121561201c57600080fd5b61202583611fed565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b038084111561206357612063612033565b604051601f8501601f19908116603f0116810190828211818310171561208b5761208b612033565b816040528093508581528686860111156120a457600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156120d057600080fd5b81356001600160401b038111156120e657600080fd5b8201601f810184136120f757600080fd5b611b2284823560208401612049565b8035801515811461200457600080fd5b60006020828403121561212857600080fd5b61122f82612106565b60008060006060848603121561214657600080fd5b61214f84611fed565b925061215d60208501611fed565b9150604084013590509250925092565b60006020828403121561217f57600080fd5b61122f82611fed565b6020808252825182820181905260009190848201906040850190845b818110156121c0578351835292840192918401916001016121a4565b50909695505050505050565b600080604083850312156121df57600080fd5b6121e883611fed565b91506121f660208401612106565b90509250929050565b6000806000806080858703121561221557600080fd5b61221e85611fed565b935061222c60208601611fed565b92506040850135915060608501356001600160401b0381111561224e57600080fd5b8501601f8101871361225f57600080fd5b61226e87823560208401612049565b91505092959194509250565b60008060006040848603121561228f57600080fd5b8335925060208401356001600160401b03808211156122ad57600080fd5b818601915086601f8301126122c157600080fd5b8135818111156122d057600080fd5b8760208260051b85010111156122e557600080fd5b6020830194508093505050509250925092565b6000806040838503121561230b57600080fd5b61231483611fed565b91506121f660208401611fed565b6000806040838503121561233557600080fd5b823591506121f660208401611fed565b600181811c9082168061235957607f821691505b6020821081141561237a57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156123f5576123f56123cb565b5060010190565b602080825260149082015273496e76616c6964206d696e7420616d6f756e742160601b604082015260600190565b6000821982111561243d5761243d6123cb565b500190565b6020808252601490820152734d617820737570706c792065786365656465642160601b604082015260600190565b600081600019048311821515161561248a5761248a6123cb565b500290565b6000845160206124a28285838a01611f69565b8551918401916124b58184848a01611f69565b8554920191600090600181811c90808316806124d257607f831692505b8583108114156124f057634e487b7160e01b85526022600452602485fd5b808015612504576001811461251557612542565b60ff19851688528388019550612542565b60008b81526020902060005b8581101561253a5781548a820152908401908801612521565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061258690830184611f95565b9695505050505050565b6000602082840312156125a257600080fd5b815161122f81611f36565b634e487b7160e01b600052601260045260246000fd5b6000826125d2576125d26125ad565b500490565b6000828210156125e9576125e96123cb565b500390565b6000826125fd576125fd6125ad565b50069056fea2646970667358221220c3ca97749bd7cfdd11c4f934701a78438fce3dd3d164de5578d12e69cf72bc0d64736f6c634300080900334f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572
third_party/real_code/rc18/provenance.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "rc18",
3
+ "chain": "polygon",
4
+ "address": "0x75e9ba1666f5987e46b33709ae81212d10dfbb8e",
5
+ "is_proxy": false,
6
+ "implementation": "",
7
+ "sourcify_match_type": "exact_match",
8
+ "fetched_utc_time": "2026-06-22T19:02:28Z",
9
+ "creation_hex_sha256": "82dfcac5e8cce3be6fba1e35d1b88158757c514ca4ec896ed07e0779d8422c04"
10
+ }
third_party/real_code/rc18/recipe.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ steps:
2
+ - signer: deployer
3
+ deploy: $target
4
+ args:
5
+ - NFT
6
+ - NFT
7
+ - 0
8
+ - 10000
9
+ - 10000
10
+ - https://uri/
11
+ - signer: deployer
12
+ to: $target
13
+ function: mintForAddress
14
+ args:
15
+ - 1
16
+ - $alice
third_party/real_code/rc18/sources/@openzeppelin/contracts/access/Ownable.sol ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import "../utils/Context.sol";
7
+
8
+ /**
9
+ * @dev Contract module which provides a basic access control mechanism, where
10
+ * there is an account (an owner) that can be granted exclusive access to
11
+ * specific functions.
12
+ *
13
+ * By default, the owner account will be the one that deploys the contract. This
14
+ * can later be changed with {transferOwnership}.
15
+ *
16
+ * This module is used through inheritance. It will make available the modifier
17
+ * `onlyOwner`, which can be applied to your functions to restrict their use to
18
+ * the owner.
19
+ */
20
+ abstract contract Ownable is Context {
21
+ address private _owner;
22
+
23
+ event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
24
+
25
+ /**
26
+ * @dev Initializes the contract setting the deployer as the initial owner.
27
+ */
28
+ constructor() {
29
+ _transferOwnership(_msgSender());
30
+ }
31
+
32
+ /**
33
+ * @dev Returns the address of the current owner.
34
+ */
35
+ function owner() public view virtual returns (address) {
36
+ return _owner;
37
+ }
38
+
39
+ /**
40
+ * @dev Throws if called by any account other than the owner.
41
+ */
42
+ modifier onlyOwner() {
43
+ require(owner() == _msgSender(), "Ownable: caller is not the owner");
44
+ _;
45
+ }
46
+
47
+ /**
48
+ * @dev Leaves the contract without owner. It will not be possible to call
49
+ * `onlyOwner` functions anymore. Can only be called by the current owner.
50
+ *
51
+ * NOTE: Renouncing ownership will leave the contract without an owner,
52
+ * thereby removing any functionality that is only available to the owner.
53
+ */
54
+ function renounceOwnership() public virtual onlyOwner {
55
+ _transferOwnership(address(0));
56
+ }
57
+
58
+ /**
59
+ * @dev Transfers ownership of the contract to a new account (`newOwner`).
60
+ * Can only be called by the current owner.
61
+ */
62
+ function transferOwnership(address newOwner) public virtual onlyOwner {
63
+ require(newOwner != address(0), "Ownable: new owner is the zero address");
64
+ _transferOwnership(newOwner);
65
+ }
66
+
67
+ /**
68
+ * @dev Transfers ownership of the contract to a new account (`newOwner`).
69
+ * Internal function without access restriction.
70
+ */
71
+ function _transferOwnership(address newOwner) internal virtual {
72
+ address oldOwner = _owner;
73
+ _owner = newOwner;
74
+ emit OwnershipTransferred(oldOwner, newOwner);
75
+ }
76
+ }
third_party/real_code/rc18/sources/@openzeppelin/contracts/security/ReentrancyGuard.sol ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ /**
7
+ * @dev Contract module that helps prevent reentrant calls to a function.
8
+ *
9
+ * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
10
+ * available, which can be applied to functions to make sure there are no nested
11
+ * (reentrant) calls to them.
12
+ *
13
+ * Note that because there is a single `nonReentrant` guard, functions marked as
14
+ * `nonReentrant` may not call one another. This can be worked around by making
15
+ * those functions `private`, and then adding `external` `nonReentrant` entry
16
+ * points to them.
17
+ *
18
+ * TIP: If you would like to learn more about reentrancy and alternative ways
19
+ * to protect against it, check out our blog post
20
+ * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
21
+ */
22
+ abstract contract ReentrancyGuard {
23
+ // Booleans are more expensive than uint256 or any type that takes up a full
24
+ // word because each write operation emits an extra SLOAD to first read the
25
+ // slot's contents, replace the bits taken up by the boolean, and then write
26
+ // back. This is the compiler's defense against contract upgrades and
27
+ // pointer aliasing, and it cannot be disabled.
28
+
29
+ // The values being non-zero value makes deployment a bit more expensive,
30
+ // but in exchange the refund on every call to nonReentrant will be lower in
31
+ // amount. Since refunds are capped to a percentage of the total
32
+ // transaction's gas, it is best to keep them low in cases like this one, to
33
+ // increase the likelihood of the full refund coming into effect.
34
+ uint256 private constant _NOT_ENTERED = 1;
35
+ uint256 private constant _ENTERED = 2;
36
+
37
+ uint256 private _status;
38
+
39
+ constructor() {
40
+ _status = _NOT_ENTERED;
41
+ }
42
+
43
+ /**
44
+ * @dev Prevents a contract from calling itself, directly or indirectly.
45
+ * Calling a `nonReentrant` function from another `nonReentrant`
46
+ * function is not supported. It is possible to prevent this from happening
47
+ * by making the `nonReentrant` function external, and making it call a
48
+ * `private` function that does the actual work.
49
+ */
50
+ modifier nonReentrant() {
51
+ // On the first call to nonReentrant, _notEntered will be true
52
+ require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
53
+
54
+ // Any calls to nonReentrant after this point will fail
55
+ _status = _ENTERED;
56
+
57
+ _;
58
+
59
+ // By storing the original value once again, a refund is triggered (see
60
+ // https://eips.ethereum.org/EIPS/eip-2200)
61
+ _status = _NOT_ENTERED;
62
+ }
63
+ }
third_party/real_code/rc18/sources/@openzeppelin/contracts/token/ERC721/IERC721.sol ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import "../../utils/introspection/IERC165.sol";
7
+
8
+ /**
9
+ * @dev Required interface of an ERC721 compliant contract.
10
+ */
11
+ interface IERC721 is IERC165 {
12
+ /**
13
+ * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
14
+ */
15
+ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
16
+
17
+ /**
18
+ * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
19
+ */
20
+ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
21
+
22
+ /**
23
+ * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
24
+ */
25
+ event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
26
+
27
+ /**
28
+ * @dev Returns the number of tokens in ``owner``'s account.
29
+ */
30
+ function balanceOf(address owner) external view returns (uint256 balance);
31
+
32
+ /**
33
+ * @dev Returns the owner of the `tokenId` token.
34
+ *
35
+ * Requirements:
36
+ *
37
+ * - `tokenId` must exist.
38
+ */
39
+ function ownerOf(uint256 tokenId) external view returns (address owner);
40
+
41
+ /**
42
+ * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
43
+ * are aware of the ERC721 protocol to prevent tokens from being forever locked.
44
+ *
45
+ * Requirements:
46
+ *
47
+ * - `from` cannot be the zero address.
48
+ * - `to` cannot be the zero address.
49
+ * - `tokenId` token must exist and be owned by `from`.
50
+ * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
51
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
52
+ *
53
+ * Emits a {Transfer} event.
54
+ */
55
+ function safeTransferFrom(
56
+ address from,
57
+ address to,
58
+ uint256 tokenId
59
+ ) external;
60
+
61
+ /**
62
+ * @dev Transfers `tokenId` token from `from` to `to`.
63
+ *
64
+ * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
65
+ *
66
+ * Requirements:
67
+ *
68
+ * - `from` cannot be the zero address.
69
+ * - `to` cannot be the zero address.
70
+ * - `tokenId` token must be owned by `from`.
71
+ * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
72
+ *
73
+ * Emits a {Transfer} event.
74
+ */
75
+ function transferFrom(
76
+ address from,
77
+ address to,
78
+ uint256 tokenId
79
+ ) external;
80
+
81
+ /**
82
+ * @dev Gives permission to `to` to transfer `tokenId` token to another account.
83
+ * The approval is cleared when the token is transferred.
84
+ *
85
+ * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
86
+ *
87
+ * Requirements:
88
+ *
89
+ * - The caller must own the token or be an approved operator.
90
+ * - `tokenId` must exist.
91
+ *
92
+ * Emits an {Approval} event.
93
+ */
94
+ function approve(address to, uint256 tokenId) external;
95
+
96
+ /**
97
+ * @dev Returns the account approved for `tokenId` token.
98
+ *
99
+ * Requirements:
100
+ *
101
+ * - `tokenId` must exist.
102
+ */
103
+ function getApproved(uint256 tokenId) external view returns (address operator);
104
+
105
+ /**
106
+ * @dev Approve or remove `operator` as an operator for the caller.
107
+ * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
108
+ *
109
+ * Requirements:
110
+ *
111
+ * - The `operator` cannot be the caller.
112
+ *
113
+ * Emits an {ApprovalForAll} event.
114
+ */
115
+ function setApprovalForAll(address operator, bool _approved) external;
116
+
117
+ /**
118
+ * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
119
+ *
120
+ * See {setApprovalForAll}
121
+ */
122
+ function isApprovedForAll(address owner, address operator) external view returns (bool);
123
+
124
+ /**
125
+ * @dev Safely transfers `tokenId` token from `from` to `to`.
126
+ *
127
+ * Requirements:
128
+ *
129
+ * - `from` cannot be the zero address.
130
+ * - `to` cannot be the zero address.
131
+ * - `tokenId` token must exist and be owned by `from`.
132
+ * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
133
+ * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
134
+ *
135
+ * Emits a {Transfer} event.
136
+ */
137
+ function safeTransferFrom(
138
+ address from,
139
+ address to,
140
+ uint256 tokenId,
141
+ bytes calldata data
142
+ ) external;
143
+ }
third_party/real_code/rc18/sources/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ /**
7
+ * @title ERC721 token receiver interface
8
+ * @dev Interface for any contract that wants to support safeTransfers
9
+ * from ERC721 asset contracts.
10
+ */
11
+ interface IERC721Receiver {
12
+ /**
13
+ * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
14
+ * by `operator` from `from`, this function is called.
15
+ *
16
+ * It must return its Solidity selector to confirm the token transfer.
17
+ * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
18
+ *
19
+ * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
20
+ */
21
+ function onERC721Received(
22
+ address operator,
23
+ address from,
24
+ uint256 tokenId,
25
+ bytes calldata data
26
+ ) external returns (bytes4);
27
+ }
third_party/real_code/rc18/sources/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import "../IERC721.sol";
7
+
8
+ /**
9
+ * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
10
+ * @dev See https://eips.ethereum.org/EIPS/eip-721
11
+ */
12
+ interface IERC721Metadata is IERC721 {
13
+ /**
14
+ * @dev Returns the token collection name.
15
+ */
16
+ function name() external view returns (string memory);
17
+
18
+ /**
19
+ * @dev Returns the token collection symbol.
20
+ */
21
+ function symbol() external view returns (string memory);
22
+
23
+ /**
24
+ * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
25
+ */
26
+ function tokenURI(uint256 tokenId) external view returns (string memory);
27
+ }
third_party/real_code/rc18/sources/@openzeppelin/contracts/utils/Address.sol ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
3
+
4
+ pragma solidity ^0.8.1;
5
+
6
+ /**
7
+ * @dev Collection of functions related to the address type
8
+ */
9
+ library Address {
10
+ /**
11
+ * @dev Returns true if `account` is a contract.
12
+ *
13
+ * [IMPORTANT]
14
+ * ====
15
+ * It is unsafe to assume that an address for which this function returns
16
+ * false is an externally-owned account (EOA) and not a contract.
17
+ *
18
+ * Among others, `isContract` will return false for the following
19
+ * types of addresses:
20
+ *
21
+ * - an externally-owned account
22
+ * - a contract in construction
23
+ * - an address where a contract will be created
24
+ * - an address where a contract lived, but was destroyed
25
+ * ====
26
+ *
27
+ * [IMPORTANT]
28
+ * ====
29
+ * You shouldn't rely on `isContract` to protect against flash loan attacks!
30
+ *
31
+ * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
32
+ * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
33
+ * constructor.
34
+ * ====
35
+ */
36
+ function isContract(address account) internal view returns (bool) {
37
+ // This method relies on extcodesize/address.code.length, which returns 0
38
+ // for contracts in construction, since the code is only stored at the end
39
+ // of the constructor execution.
40
+
41
+ return account.code.length > 0;
42
+ }
43
+
44
+ /**
45
+ * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
46
+ * `recipient`, forwarding all available gas and reverting on errors.
47
+ *
48
+ * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
49
+ * of certain opcodes, possibly making contracts go over the 2300 gas limit
50
+ * imposed by `transfer`, making them unable to receive funds via
51
+ * `transfer`. {sendValue} removes this limitation.
52
+ *
53
+ * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
54
+ *
55
+ * IMPORTANT: because control is transferred to `recipient`, care must be
56
+ * taken to not create reentrancy vulnerabilities. Consider using
57
+ * {ReentrancyGuard} or the
58
+ * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
59
+ */
60
+ function sendValue(address payable recipient, uint256 amount) internal {
61
+ require(address(this).balance >= amount, "Address: insufficient balance");
62
+
63
+ (bool success, ) = recipient.call{value: amount}("");
64
+ require(success, "Address: unable to send value, recipient may have reverted");
65
+ }
66
+
67
+ /**
68
+ * @dev Performs a Solidity function call using a low level `call`. A
69
+ * plain `call` is an unsafe replacement for a function call: use this
70
+ * function instead.
71
+ *
72
+ * If `target` reverts with a revert reason, it is bubbled up by this
73
+ * function (like regular Solidity function calls).
74
+ *
75
+ * Returns the raw returned data. To convert to the expected return value,
76
+ * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
77
+ *
78
+ * Requirements:
79
+ *
80
+ * - `target` must be a contract.
81
+ * - calling `target` with `data` must not revert.
82
+ *
83
+ * _Available since v3.1._
84
+ */
85
+ function functionCall(address target, bytes memory data) internal returns (bytes memory) {
86
+ return functionCall(target, data, "Address: low-level call failed");
87
+ }
88
+
89
+ /**
90
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
91
+ * `errorMessage` as a fallback revert reason when `target` reverts.
92
+ *
93
+ * _Available since v3.1._
94
+ */
95
+ function functionCall(
96
+ address target,
97
+ bytes memory data,
98
+ string memory errorMessage
99
+ ) internal returns (bytes memory) {
100
+ return functionCallWithValue(target, data, 0, errorMessage);
101
+ }
102
+
103
+ /**
104
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
105
+ * but also transferring `value` wei to `target`.
106
+ *
107
+ * Requirements:
108
+ *
109
+ * - the calling contract must have an ETH balance of at least `value`.
110
+ * - the called Solidity function must be `payable`.
111
+ *
112
+ * _Available since v3.1._
113
+ */
114
+ function functionCallWithValue(
115
+ address target,
116
+ bytes memory data,
117
+ uint256 value
118
+ ) internal returns (bytes memory) {
119
+ return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
120
+ }
121
+
122
+ /**
123
+ * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
124
+ * with `errorMessage` as a fallback revert reason when `target` reverts.
125
+ *
126
+ * _Available since v3.1._
127
+ */
128
+ function functionCallWithValue(
129
+ address target,
130
+ bytes memory data,
131
+ uint256 value,
132
+ string memory errorMessage
133
+ ) internal returns (bytes memory) {
134
+ require(address(this).balance >= value, "Address: insufficient balance for call");
135
+ require(isContract(target), "Address: call to non-contract");
136
+
137
+ (bool success, bytes memory returndata) = target.call{value: value}(data);
138
+ return verifyCallResult(success, returndata, errorMessage);
139
+ }
140
+
141
+ /**
142
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
143
+ * but performing a static call.
144
+ *
145
+ * _Available since v3.3._
146
+ */
147
+ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
148
+ return functionStaticCall(target, data, "Address: low-level static call failed");
149
+ }
150
+
151
+ /**
152
+ * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
153
+ * but performing a static call.
154
+ *
155
+ * _Available since v3.3._
156
+ */
157
+ function functionStaticCall(
158
+ address target,
159
+ bytes memory data,
160
+ string memory errorMessage
161
+ ) internal view returns (bytes memory) {
162
+ require(isContract(target), "Address: static call to non-contract");
163
+
164
+ (bool success, bytes memory returndata) = target.staticcall(data);
165
+ return verifyCallResult(success, returndata, errorMessage);
166
+ }
167
+
168
+ /**
169
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
170
+ * but performing a delegate call.
171
+ *
172
+ * _Available since v3.4._
173
+ */
174
+ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
175
+ return functionDelegateCall(target, data, "Address: low-level delegate call failed");
176
+ }
177
+
178
+ /**
179
+ * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
180
+ * but performing a delegate call.
181
+ *
182
+ * _Available since v3.4._
183
+ */
184
+ function functionDelegateCall(
185
+ address target,
186
+ bytes memory data,
187
+ string memory errorMessage
188
+ ) internal returns (bytes memory) {
189
+ require(isContract(target), "Address: delegate call to non-contract");
190
+
191
+ (bool success, bytes memory returndata) = target.delegatecall(data);
192
+ return verifyCallResult(success, returndata, errorMessage);
193
+ }
194
+
195
+ /**
196
+ * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
197
+ * revert reason using the provided one.
198
+ *
199
+ * _Available since v4.3._
200
+ */
201
+ function verifyCallResult(
202
+ bool success,
203
+ bytes memory returndata,
204
+ string memory errorMessage
205
+ ) internal pure returns (bytes memory) {
206
+ if (success) {
207
+ return returndata;
208
+ } else {
209
+ // Look for revert reason and bubble it up if present
210
+ if (returndata.length > 0) {
211
+ // The easiest way to bubble the revert reason is using memory via assembly
212
+
213
+ assembly {
214
+ let returndata_size := mload(returndata)
215
+ revert(add(32, returndata), returndata_size)
216
+ }
217
+ } else {
218
+ revert(errorMessage);
219
+ }
220
+ }
221
+ }
222
+ }