@lukso/lsp-smart-contracts 0.12.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +3 -2
  2. package/artifacts/LSP0ERC725Account.json +6 -6
  3. package/artifacts/LSP0ERC725AccountInit.json +6 -6
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
  7. package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
  8. package/artifacts/LSP4DigitalAssetMetadata.json +5 -0
  9. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +5 -0
  10. package/artifacts/LSP6KeyManager.json +2 -2
  11. package/artifacts/LSP6KeyManagerInit.json +2 -2
  12. package/artifacts/LSP7CappedSupply.json +71 -36
  13. package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -36
  14. package/artifacts/LSP7CompatibleERC20.json +71 -36
  15. package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -36
  16. package/artifacts/LSP7CompatibleERC20Mintable.json +78 -38
  17. package/artifacts/LSP7CompatibleERC20MintableInit.json +78 -38
  18. package/artifacts/LSP7DigitalAsset.json +71 -36
  19. package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -36
  20. package/artifacts/LSP7Mintable.json +78 -38
  21. package/artifacts/LSP7MintableInit.json +78 -38
  22. package/artifacts/LSP8CappedSupply.json +187 -23
  23. package/artifacts/LSP8CappedSupplyInitAbstract.json +200 -36
  24. package/artifacts/LSP8CompatibleERC721.json +187 -23
  25. package/artifacts/LSP8CompatibleERC721InitAbstract.json +200 -36
  26. package/artifacts/LSP8CompatibleERC721Mintable.json +195 -26
  27. package/artifacts/LSP8CompatibleERC721MintableInit.json +208 -39
  28. package/artifacts/LSP8IdentifiableDigitalAsset.json +187 -23
  29. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +200 -36
  30. package/artifacts/LSP8Mintable.json +195 -26
  31. package/artifacts/LSP8MintableInit.json +208 -39
  32. package/artifacts/LSP9Vault.json +6 -6
  33. package/artifacts/LSP9VaultInit.json +6 -6
  34. package/artifacts/UniversalProfile.json +6 -6
  35. package/artifacts/UniversalProfileInit.json +6 -6
  36. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +1 -22
  37. package/contracts/LSP17Extensions/Extension4337.sol +26 -1
  38. package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -1
  39. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +10 -2
  40. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +20 -34
  41. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol +47 -0
  42. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +19 -31
  43. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +13 -6
  44. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +1 -1
  45. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +2 -2
  46. package/contracts/LSP6KeyManager/LSP6Utils.sol +1 -1
  47. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +20 -9
  48. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
  49. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +7 -5
  50. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +128 -25
  51. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -2
  52. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +6 -0
  53. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +4 -2
  54. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +7 -4
  55. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -2
  56. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +5 -2
  57. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +8 -2
  58. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +12 -1
  59. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +4 -0
  60. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -0
  61. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +77 -5
  62. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +15 -12
  63. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +19 -3
  64. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +25 -16
  65. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +223 -19
  66. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +28 -15
  67. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -1
  68. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -1
  69. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +1 -2
  70. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +1 -2
  71. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +15 -4
  72. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +8 -4
  73. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +1 -2
  74. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +1 -2
  75. package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +0 -1
  76. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +13 -2
  77. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +6 -2
  78. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +4 -2
  79. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +14 -4
  80. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +7 -4
  81. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +7 -4
  82. package/contracts/LSP9Vault/LSP9VaultCore.sol +0 -22
  83. package/contracts/Version.sol +1 -1
  84. package/devdocs/LSP4DigitalAssetMetadata.json +11 -5
  85. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -2
  86. package/devdocs/LSP6KeyManager.json +1 -1
  87. package/devdocs/LSP6KeyManagerInit.json +1 -1
  88. package/devdocs/LSP7CappedSupply.json +22 -2
  89. package/devdocs/LSP7CappedSupplyInitAbstract.json +22 -2
  90. package/devdocs/LSP7CompatibleERC20.json +23 -2
  91. package/devdocs/LSP7CompatibleERC20InitAbstract.json +22 -2
  92. package/devdocs/LSP7CompatibleERC20Mintable.json +23 -2
  93. package/devdocs/LSP7CompatibleERC20MintableInit.json +24 -3
  94. package/devdocs/LSP7DigitalAsset.json +27 -6
  95. package/devdocs/LSP7DigitalAssetInitAbstract.json +22 -2
  96. package/devdocs/LSP7Mintable.json +24 -2
  97. package/devdocs/LSP7MintableInit.json +25 -3
  98. package/devdocs/LSP8CappedSupply.json +66 -4
  99. package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -4
  100. package/devdocs/LSP8CompatibleERC721.json +69 -5
  101. package/devdocs/LSP8CompatibleERC721InitAbstract.json +67 -5
  102. package/devdocs/LSP8CompatibleERC721Mintable.json +69 -5
  103. package/devdocs/LSP8CompatibleERC721MintableInit.json +70 -6
  104. package/devdocs/LSP8IdentifiableDigitalAsset.json +71 -8
  105. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -4
  106. package/devdocs/LSP8Mintable.json +68 -4
  107. package/devdocs/LSP8MintableInit.json +69 -5
  108. package/dist/constants.cjs.js +4406 -1319
  109. package/dist/constants.d.ts +4158 -818
  110. package/dist/constants.es.js +4405 -1319
  111. package/package.json +2 -2
  112. package/userdocs/LSP7CappedSupply.json +8 -0
  113. package/userdocs/LSP7CappedSupplyInitAbstract.json +8 -0
  114. package/userdocs/LSP7CompatibleERC20.json +8 -0
  115. package/userdocs/LSP7CompatibleERC20InitAbstract.json +8 -0
  116. package/userdocs/LSP7CompatibleERC20Mintable.json +8 -0
  117. package/userdocs/LSP7CompatibleERC20MintableInit.json +9 -1
  118. package/userdocs/LSP7DigitalAsset.json +8 -0
  119. package/userdocs/LSP7DigitalAssetInitAbstract.json +8 -0
  120. package/userdocs/LSP7Mintable.json +8 -0
  121. package/userdocs/LSP7MintableInit.json +9 -1
  122. package/userdocs/LSP8CappedSupply.json +20 -0
  123. package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -0
  124. package/userdocs/LSP8CompatibleERC721.json +20 -0
  125. package/userdocs/LSP8CompatibleERC721InitAbstract.json +20 -0
  126. package/userdocs/LSP8CompatibleERC721Mintable.json +20 -0
  127. package/userdocs/LSP8CompatibleERC721MintableInit.json +21 -1
  128. package/userdocs/LSP8IdentifiableDigitalAsset.json +21 -1
  129. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +20 -0
  130. package/userdocs/LSP8Mintable.json +20 -0
  131. package/userdocs/LSP8MintableInit.json +21 -1
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.4;
2
+ pragma solidity ^0.8.12;
3
3
 
4
4
  // interfaces
5
5
  import {
@@ -9,6 +9,12 @@ import {
9
9
  ILSP8IdentifiableDigitalAsset
10
10
  } from "./ILSP8IdentifiableDigitalAsset.sol";
11
11
 
12
+ // modules
13
+
14
+ import {
15
+ LSP4DigitalAssetMetadataCore
16
+ } from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol";
17
+
12
18
  // libraries
13
19
  import {
14
20
  EnumerableSet
@@ -32,7 +38,10 @@ import {
32
38
  LSP8TokenIdAlreadyMinted,
33
39
  LSP8CannotSendToSelf,
34
40
  LSP8NotifyTokenReceiverContractMissingLSP1Interface,
35
- LSP8NotifyTokenReceiverIsEOA
41
+ LSP8NotifyTokenReceiverIsEOA,
42
+ LSP8TokenIdsDataLengthMismatch,
43
+ LSP8TokenIdsDataEmptyArray,
44
+ LSP8BatchCallFailed
36
45
  } from "./LSP8Errors.sol";
37
46
 
38
47
  // constants
@@ -49,12 +58,11 @@ import {
49
58
  * @dev Core Implementation of a LSP8 compliant contract.
50
59
  */
51
60
  abstract contract LSP8IdentifiableDigitalAssetCore is
61
+ LSP4DigitalAssetMetadataCore,
52
62
  ILSP8IdentifiableDigitalAsset
53
63
  {
54
64
  using EnumerableSet for EnumerableSet.AddressSet;
55
65
  using EnumerableSet for EnumerableSet.Bytes32Set;
56
- using ERC165Checker for address;
57
- using LSP1Utils for address;
58
66
 
59
67
  // --- Storage
60
68
 
@@ -115,6 +123,118 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
115
123
  return _ownedTokens[tokenOwner].values();
116
124
  }
117
125
 
126
+ // --- TokenId Metadata functionality
127
+
128
+ /**
129
+ * @inheritdoc ILSP8IdentifiableDigitalAsset
130
+ */
131
+ function getDataForTokenId(
132
+ bytes32 tokenId,
133
+ bytes32 dataKey
134
+ ) public view virtual override returns (bytes memory dataValue) {
135
+ return _getDataForTokenId(tokenId, dataKey);
136
+ }
137
+
138
+ /**
139
+ * @inheritdoc ILSP8IdentifiableDigitalAsset
140
+ */
141
+ function getDataBatchForTokenIds(
142
+ bytes32[] memory tokenIds,
143
+ bytes32[] memory dataKeys
144
+ ) public view virtual override returns (bytes[] memory dataValues) {
145
+ dataValues = new bytes[](tokenIds.length);
146
+
147
+ for (uint256 i; i < tokenIds.length; ) {
148
+ dataValues[i] = _getDataForTokenId(tokenIds[i], dataKeys[i]);
149
+
150
+ // Increment the iterator in unchecked block to save gas
151
+ unchecked {
152
+ ++i;
153
+ }
154
+ }
155
+
156
+ return dataValues;
157
+ }
158
+
159
+ /**
160
+ * @inheritdoc ILSP8IdentifiableDigitalAsset
161
+ */
162
+ function setDataForTokenId(
163
+ bytes32 tokenId,
164
+ bytes32 dataKey,
165
+ bytes memory dataValue
166
+ ) public virtual override onlyOwner {
167
+ _setDataForTokenId(tokenId, dataKey, dataValue);
168
+ }
169
+
170
+ /**
171
+ * @inheritdoc ILSP8IdentifiableDigitalAsset
172
+ */
173
+ function setDataBatchForTokenIds(
174
+ bytes32[] memory tokenIds,
175
+ bytes32[] memory dataKeys,
176
+ bytes[] memory dataValues
177
+ ) public virtual override onlyOwner {
178
+ if (
179
+ tokenIds.length != dataKeys.length ||
180
+ dataKeys.length != dataValues.length
181
+ ) {
182
+ revert LSP8TokenIdsDataLengthMismatch();
183
+ }
184
+
185
+ if (tokenIds.length == 0) {
186
+ revert LSP8TokenIdsDataEmptyArray();
187
+ }
188
+
189
+ for (uint256 i; i < tokenIds.length; ) {
190
+ _setDataForTokenId(tokenIds[i], dataKeys[i], dataValues[i]);
191
+
192
+ // Increment the iterator in unchecked block to save gas
193
+ unchecked {
194
+ ++i;
195
+ }
196
+ }
197
+ }
198
+
199
+ // --- General functionality
200
+
201
+ /**
202
+ * @inheritdoc ILSP8IdentifiableDigitalAsset
203
+ *
204
+ * @custom:info It's not possible to send value along the functions call due to the use of `delegatecall`.
205
+ */
206
+ function batchCalls(
207
+ bytes[] calldata data
208
+ ) public virtual override returns (bytes[] memory results) {
209
+ results = new bytes[](data.length);
210
+ for (uint256 i; i < data.length; ) {
211
+ (bool success, bytes memory result) = address(this).delegatecall(
212
+ data[i]
213
+ );
214
+
215
+ if (!success) {
216
+ // Look for revert reason and bubble it up if present
217
+ if (result.length != 0) {
218
+ // The easiest way to bubble the revert reason is using memory via assembly
219
+ // solhint-disable no-inline-assembly
220
+ /// @solidity memory-safe-assembly
221
+ assembly {
222
+ let returndata_size := mload(result)
223
+ revert(add(32, result), returndata_size)
224
+ }
225
+ } else {
226
+ revert LSP8BatchCallFailed({callIndex: i});
227
+ }
228
+ }
229
+
230
+ results[i] = result;
231
+
232
+ unchecked {
233
+ ++i;
234
+ }
235
+ }
236
+ }
237
+
118
238
  // --- Operator functionality
119
239
 
120
240
  /**
@@ -142,7 +262,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
142
262
  bool isAdded = _operators[tokenId].add(operator);
143
263
  if (!isAdded) revert LSP8OperatorAlreadyAuthorized(operator, tokenId);
144
264
 
145
- emit AuthorizedOperator(
265
+ emit OperatorAuthorizationChanged(
146
266
  operator,
147
267
  tokenOwner,
148
268
  tokenId,
@@ -156,7 +276,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
156
276
  operatorNotificationData
157
277
  );
158
278
 
159
- operator.notifyUniversalReceiver(_TYPEID_LSP8_TOKENOPERATOR, lsp1Data);
279
+ _notifyTokenOperator(operator, lsp1Data);
160
280
  }
161
281
 
162
282
  /**
@@ -198,10 +318,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
198
318
  operatorNotificationData
199
319
  );
200
320
 
201
- operator.notifyUniversalReceiver(
202
- _TYPEID_LSP8_TOKENOPERATOR,
203
- lsp1Data
204
- );
321
+ _notifyTokenOperator(operator, lsp1Data);
205
322
  }
206
323
  }
207
324
 
@@ -301,7 +418,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
301
418
  bool isRemoved = _operators[tokenId].remove(operator);
302
419
  if (!isRemoved) revert LSP8NonExistingOperator(operator, tokenId);
303
420
 
304
- emit RevokedOperator(
421
+ emit OperatorRevoked(
305
422
  operator,
306
423
  tokenOwner,
307
424
  tokenId,
@@ -406,7 +523,13 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
406
523
 
407
524
  _afterTokenTransfer(address(0), to, tokenId, data);
408
525
 
409
- bytes memory lsp1Data = abi.encode(address(0), to, tokenId, data);
526
+ bytes memory lsp1Data = abi.encode(
527
+ msg.sender,
528
+ address(0),
529
+ to,
530
+ tokenId,
531
+ data
532
+ );
410
533
  _notifyTokenReceiver(to, force, lsp1Data);
411
534
  }
412
535
 
@@ -454,13 +577,14 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
454
577
  _afterTokenTransfer(tokenOwner, address(0), tokenId, data);
455
578
 
456
579
  bytes memory lsp1Data = abi.encode(
580
+ msg.sender,
457
581
  tokenOwner,
458
582
  address(0),
459
583
  tokenId,
460
584
  data
461
585
  );
462
586
 
463
- tokenOwner.notifyUniversalReceiver(_TYPEID_LSP8_TOKENSSENDER, lsp1Data);
587
+ _notifyTokenSender(tokenOwner, lsp1Data);
464
588
  }
465
589
 
466
590
  /**
@@ -524,12 +648,43 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
524
648
 
525
649
  _afterTokenTransfer(from, to, tokenId, data);
526
650
 
527
- bytes memory lsp1Data = abi.encode(from, to, tokenId, data);
651
+ bytes memory lsp1Data = abi.encode(msg.sender, from, to, tokenId, data);
528
652
 
529
- from.notifyUniversalReceiver(_TYPEID_LSP8_TOKENSSENDER, lsp1Data);
653
+ _notifyTokenSender(from, lsp1Data);
530
654
  _notifyTokenReceiver(to, force, lsp1Data);
531
655
  }
532
656
 
657
+ /**
658
+ * @dev Sets data for a specific `tokenId` and `dataKey` in the ERC725Y storage
659
+ * The ERC725Y data key is the hash of the `tokenId` and `dataKey` concatenated
660
+ * @param tokenId The unique identifier for a token.
661
+ * @param dataKey The key for the data to set.
662
+ * @param dataValue The value to set for the given data key.
663
+ * @custom:events {TokenIdDataChanged} event.
664
+ */
665
+ function _setDataForTokenId(
666
+ bytes32 tokenId,
667
+ bytes32 dataKey,
668
+ bytes memory dataValue
669
+ ) internal virtual {
670
+ _store[keccak256(bytes.concat(tokenId, dataKey))] = dataValue;
671
+ emit TokenIdDataChanged(tokenId, dataKey, dataValue);
672
+ }
673
+
674
+ /**
675
+ * @dev Retrieves data for a specific `tokenId` and `dataKey` from the ERC725Y storage
676
+ * The ERC725Y data key is the hash of the `tokenId` and `dataKey` concatenated
677
+ * @param tokenId The unique identifier for a token.
678
+ * @param dataKey The key for the data to retrieve.
679
+ * @return dataValues The data value associated with the given `tokenId` and `dataKey`.
680
+ */
681
+ function _getDataForTokenId(
682
+ bytes32 tokenId,
683
+ bytes32 dataKey
684
+ ) internal view virtual returns (bytes memory dataValues) {
685
+ return _store[keccak256(bytes.concat(tokenId, dataKey))];
686
+ }
687
+
533
688
  /**
534
689
  * @dev Hook that is called before any token transfer, including minting and burning.
535
690
  * Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function.
@@ -563,17 +718,66 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
563
718
  ) internal virtual {}
564
719
 
565
720
  /**
566
- * @dev An attempt is made to notify the token receiver about the `tokenId` changing owners
567
- * using LSP1 interface. When force is FALSE the token receiver MUST support LSP1.
721
+ * @dev Attempt to notify the operator `operator` about the `tokenId` being authorized.
722
+ * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP8_TOKENOPERATOR` as typeId, if `operator` is a contract that supports the LSP1 interface.
723
+ * If `operator` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
724
+
725
+ * @param operator The address to call the {universalReceiver} function on.
726
+ * @param lsp1Data the data to be sent to the `operator` address in the `universalReceiver` call.
727
+ */
728
+ function _notifyTokenOperator(
729
+ address operator,
730
+ bytes memory lsp1Data
731
+ ) internal virtual {
732
+ LSP1Utils.notifyUniversalReceiver(
733
+ operator,
734
+ _TYPEID_LSP8_TOKENOPERATOR,
735
+ lsp1Data
736
+ );
737
+ }
738
+
739
+ /**
740
+ * @dev Attempt to notify the token sender `from` about the `tokenId` being transferred.
741
+ * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP8_TOKENSSENDER` as typeId, if `from` is a contract that supports the LSP1 interface.
742
+ * If `from` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
743
+
744
+ * @param from The address to call the {universalReceiver} function on.
745
+ * @param lsp1Data the data to be sent to the `from` address in the `universalReceiver` call.
746
+ */
747
+ function _notifyTokenSender(
748
+ address from,
749
+ bytes memory lsp1Data
750
+ ) internal virtual {
751
+ LSP1Utils.notifyUniversalReceiver(
752
+ from,
753
+ _TYPEID_LSP8_TOKENSSENDER,
754
+ lsp1Data
755
+ );
756
+ }
757
+
758
+ /**
759
+ * @dev Attempt to notify the token receiver `to` about the `tokenId` being received.
760
+ * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP8_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface.
568
761
  *
569
- * The receiver may revert when the token being sent is not wanted.
762
+ * If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `force` boolean flag.
763
+ * - if `force` is set to `true`, nothing will happen and no notification will be sent.
764
+ * - if `force` is set to `false, the transaction will revert.
765
+ *
766
+ * @param to The address to call the {universalReceiver} function on.
767
+ * @param force A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not.
768
+ * @param lsp1Data The data to be sent to the `to` address in the `universalReceiver(...)` call.
570
769
  */
571
770
  function _notifyTokenReceiver(
572
771
  address to,
573
772
  bool force,
574
773
  bytes memory lsp1Data
575
774
  ) internal virtual {
576
- if (to.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP1)) {
775
+ if (
776
+ ERC165Checker.supportsERC165InterfaceUnchecked(
777
+ to,
778
+ _INTERFACEID_LSP1
779
+ )
780
+ ) {
577
781
  ILSP1(to).universalReceiver(_TYPEID_LSP8_TOKENSRECIPIENT, lsp1Data);
578
782
  } else if (!force) {
579
783
  if (to.code.length != 0) {
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.4;
2
+ pragma solidity ^0.8.12;
3
3
 
4
4
  // interfaces
5
5
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
@@ -13,18 +13,22 @@ import {
13
13
  LSP4DigitalAssetMetadataInitAbstract
14
14
  } from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol";
15
15
 
16
+ import {
17
+ LSP4DigitalAssetMetadataCore
18
+ } from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol";
19
+
16
20
  import {LSP17Extendable} from "../LSP17ContractExtension/LSP17Extendable.sol";
17
21
 
18
22
  // libraries
19
23
  import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
20
24
 
21
25
  // constants
22
- import {_INTERFACEID_LSP8, _LSP8_TOKENID_TYPE_KEY} from "./LSP8Constants.sol";
26
+ import {_INTERFACEID_LSP8, _LSP8_TOKENID_FORMAT_KEY} from "./LSP8Constants.sol";
23
27
 
24
28
  // errors
25
29
  import {
26
30
  LSP8TokenContractCannotHoldValue,
27
- LSP8TokenIdTypeNotEditable
31
+ LSP8TokenIdFormatNotEditable
28
32
  } from "./LSP8Errors.sol";
29
33
 
30
34
  import {
@@ -56,33 +60,35 @@ abstract contract LSP8IdentifiableDigitalAssetInitAbstract is
56
60
  LSP17Extendable
57
61
  {
58
62
  /**
59
- * @dev Initialize a `LSP8IdentifiableDigitalAsset` contract and set the tokenId type inside the ERC725Y storage of the contract.
63
+ * @dev Initialize a `LSP8IdentifiableDigitalAsset` contract and set the tokenId format inside the ERC725Y storage of the contract.
60
64
  * This will also set the token `name_` and `symbol_` under the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol`.
61
65
  *
62
66
  * @param name_ The name of the token
63
67
  * @param symbol_ The symbol of the token
64
68
  * @param newOwner_ The owner of the the token-Metadata
65
- * @param tokenIdType_ The type of tokenIds (= NFTs) that this contract will create.
66
- * Available options are: NUMBER = `0`; STRING = `1`; UNIQUE_ID = `2`; HASH = `3`; ADDRESS = `4`.
69
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
70
+ * @param lsp8TokenIdFormat_ The format of tokenIds (= NFTs) that this contract will create.
67
71
  *
68
- * @custom:warning Make sure the tokenId type provided on deployment is correct, as it can only be set once
72
+ * @custom:warning Make sure the tokenId format provided on deployment is correct, as it can only be set once
69
73
  * and cannot be changed in the ERC725Y storage after the contract has been initialized.
70
74
  */
71
75
  function _initialize(
72
76
  string memory name_,
73
77
  string memory symbol_,
74
78
  address newOwner_,
75
- uint256 tokenIdType_
79
+ uint256 lsp4TokenType_,
80
+ uint256 lsp8TokenIdFormat_
76
81
  ) internal virtual onlyInitializing {
77
82
  LSP4DigitalAssetMetadataInitAbstract._initialize(
78
83
  name_,
79
84
  symbol_,
80
- newOwner_
85
+ newOwner_,
86
+ lsp4TokenType_
81
87
  );
82
88
 
83
89
  LSP4DigitalAssetMetadataInitAbstract._setData(
84
- _LSP8_TOKENID_TYPE_KEY,
85
- abi.encode(tokenIdType_)
90
+ _LSP8_TOKENID_FORMAT_KEY,
91
+ abi.encode(lsp8TokenIdFormat_)
86
92
  );
87
93
  }
88
94
 
@@ -218,15 +224,22 @@ abstract contract LSP8IdentifiableDigitalAssetInitAbstract is
218
224
 
219
225
  /**
220
226
  * @inheritdoc LSP4DigitalAssetMetadataInitAbstract
221
- * @dev The ERC725Y data key `_LSP8_TOKENID_TYPE_KEY` cannot be changed
227
+ * @dev The ERC725Y data key `_LSP8_TOKENID_FORMAT_KEY` cannot be changed
222
228
  * once the identifiable digital asset contract has been deployed.
223
229
  */
224
230
  function _setData(
225
231
  bytes32 dataKey,
226
232
  bytes memory dataValue
227
- ) internal virtual override {
228
- if (dataKey == _LSP8_TOKENID_TYPE_KEY) {
229
- revert LSP8TokenIdTypeNotEditable();
233
+ )
234
+ internal
235
+ virtual
236
+ override(
237
+ LSP4DigitalAssetMetadataInitAbstract,
238
+ LSP4DigitalAssetMetadataCore
239
+ )
240
+ {
241
+ if (dataKey == _LSP8_TOKENID_FORMAT_KEY) {
242
+ revert LSP8TokenIdFormatNotEditable();
230
243
  }
231
244
  LSP4DigitalAssetMetadataInitAbstract._setData(dataKey, dataValue);
232
245
  }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.4;
2
+ pragma solidity ^0.8.12;
3
3
 
4
4
  import {
5
5
  LSP8IdentifiableDigitalAsset
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.4;
2
+ pragma solidity ^0.8.12;
3
3
 
4
4
  import {
5
5
  LSP8IdentifiableDigitalAssetInitAbstract
@@ -1,6 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
-
3
- pragma solidity ^0.8.4;
2
+ pragma solidity ^0.8.12;
4
3
 
5
4
  // modules
6
5
  import {
@@ -1,6 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
-
3
- pragma solidity ^0.8.4;
2
+ pragma solidity ^0.8.12;
4
3
 
5
4
  // modules
6
5
  import {
@@ -64,13 +64,24 @@ abstract contract LSP8CompatibleERC721 is
64
64
  * @param name_ The name of the token.
65
65
  * @param symbol_ The symbol of the token.
66
66
  * @param newOwner_ The owner of the token contract.
67
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
68
+ * @param lsp8TokenIdFormat_ The format of tokenIds (= NFTs) that this contract will create.
67
69
  */
68
70
  constructor(
69
71
  string memory name_,
70
72
  string memory symbol_,
71
73
  address newOwner_,
72
- uint256 tokenIdType_
73
- ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_, tokenIdType_) {}
74
+ uint256 lsp4TokenType_,
75
+ uint256 lsp8TokenIdFormat_
76
+ )
77
+ LSP8IdentifiableDigitalAsset(
78
+ name_,
79
+ symbol_,
80
+ newOwner_,
81
+ lsp4TokenType_,
82
+ lsp8TokenIdFormat_
83
+ )
84
+ {}
74
85
 
75
86
  /**
76
87
  * @inheritdoc IERC721Metadata
@@ -316,7 +327,7 @@ abstract contract LSP8CompatibleERC721 is
316
327
  * @inheritdoc LSP8IdentifiableDigitalAssetCore
317
328
  *
318
329
  * @custom:events
319
- * - LSP7 {AuthorizedOperator} event.
330
+ * - LSP7 {OperatorAuthorizationChanged} event.
320
331
  * - ERC721 {Approval} event.
321
332
  */
322
333
  function authorizeOperator(
@@ -344,7 +355,7 @@ abstract contract LSP8CompatibleERC721 is
344
355
  bool isAdded = _operators[tokenId].add(operator);
345
356
  if (!isAdded) revert LSP8OperatorAlreadyAuthorized(operator, tokenId);
346
357
 
347
- emit AuthorizedOperator(
358
+ emit OperatorAuthorizationChanged(
348
359
  operator,
349
360
  tokenOwner,
350
361
  tokenId,
@@ -64,19 +64,23 @@ abstract contract LSP8CompatibleERC721InitAbstract is
64
64
  * @param name_ The name of the token.
65
65
  * @param symbol_ The symbol of the token.
66
66
  * @param newOwner_ The owner of the token contract.
67
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
68
+ * @param lsp8TokenIdFormat_ The format of tokenIds (= NFTs) that this contract will create.
67
69
  */
68
70
 
69
71
  function _initialize(
70
72
  string memory name_,
71
73
  string memory symbol_,
72
74
  address newOwner_,
73
- uint256 tokenIdType_
75
+ uint256 lsp4TokenType_,
76
+ uint256 lsp8TokenIdFormat_
74
77
  ) internal virtual override onlyInitializing {
75
78
  LSP8IdentifiableDigitalAssetInitAbstract._initialize(
76
79
  name_,
77
80
  symbol_,
78
81
  newOwner_,
79
- tokenIdType_
82
+ lsp4TokenType_,
83
+ lsp8TokenIdFormat_
80
84
  );
81
85
  }
82
86
 
@@ -325,7 +329,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is
325
329
  * @inheritdoc LSP8IdentifiableDigitalAssetCore
326
330
  *
327
331
  * @custom:events
328
- * - LSP7 {AuthorizedOperator} event.
332
+ * - LSP7 {OperatorAuthorizationChanged} event.
329
333
  * - ERC721 {Approval} event.
330
334
  */
331
335
  function authorizeOperator(
@@ -353,7 +357,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is
353
357
  bool isAdded = _operators[tokenId].add(operator);
354
358
  if (!isAdded) revert LSP8OperatorAlreadyAuthorized(operator, tokenId);
355
359
 
356
- emit AuthorizedOperator(
360
+ emit OperatorAuthorizationChanged(
357
361
  operator,
358
362
  tokenOwner,
359
363
  tokenId,
@@ -1,6 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
-
3
- pragma solidity ^0.8.4;
2
+ pragma solidity ^0.8.12;
4
3
 
5
4
  // modules
6
5
  import {
@@ -1,6 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
-
3
- pragma solidity ^0.8.4;
2
+ pragma solidity ^0.8.12;
4
3
 
5
4
  // modules
6
5
  import {
@@ -1,5 +1,4 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
-
3
2
  pragma solidity ^0.8.4;
4
3
 
5
4
  // interfaces
@@ -14,13 +14,24 @@ contract LSP8CompatibleERC721Mintable is LSP8CompatibleERC721 {
14
14
  * @param name_ The name of the token.
15
15
  * @param symbol_ The symbol of the token.
16
16
  * @param newOwner_ The owner of the token contract.
17
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
18
+ * @param lsp8TokenIdFormat_ The format of tokenIds (= NFTs) that this contract will create.
17
19
  */
18
20
  constructor(
19
21
  string memory name_,
20
22
  string memory symbol_,
21
23
  address newOwner_,
22
- uint256 tokenIdType_
23
- ) LSP8CompatibleERC721(name_, symbol_, newOwner_, tokenIdType_) {}
24
+ uint256 lsp4TokenType_,
25
+ uint256 lsp8TokenIdFormat_
26
+ )
27
+ LSP8CompatibleERC721(
28
+ name_,
29
+ symbol_,
30
+ newOwner_,
31
+ lsp4TokenType_,
32
+ lsp8TokenIdFormat_
33
+ )
34
+ {}
24
35
 
25
36
  /**
26
37
  * @notice Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `force`).
@@ -26,18 +26,22 @@ contract LSP8CompatibleERC721MintableInit is
26
26
  * @param name_ The name of the token.
27
27
  * @param symbol_ The symbol of the token.
28
28
  * @param newOwner_ The owner of the token contract.
29
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
30
+ * @param lsp8TokenIdFormat_ The format of tokenIds (= NFTs) that this contract will create.
29
31
  */
30
32
  function initialize(
31
33
  string memory name_,
32
34
  string memory symbol_,
33
35
  address newOwner_,
34
- uint256 tokenIdType_
36
+ uint256 lsp4TokenType_,
37
+ uint256 lsp8TokenIdFormat_
35
38
  ) external virtual initializer {
36
39
  LSP8CompatibleERC721MintableInitAbstract._initialize(
37
40
  name_,
38
41
  symbol_,
39
42
  newOwner_,
40
- tokenIdType_
43
+ lsp4TokenType_,
44
+ lsp8TokenIdFormat_
41
45
  );
42
46
  }
43
47
  }
@@ -19,13 +19,15 @@ contract LSP8CompatibleERC721MintableInitAbstract is
19
19
  string memory name_,
20
20
  string memory symbol_,
21
21
  address newOwner_,
22
- uint256 tokenIdType_
22
+ uint256 lsp4TokenType_,
23
+ uint256 lsp8TokenIdFormat_
23
24
  ) internal virtual override onlyInitializing {
24
25
  LSP8CompatibleERC721InitAbstract._initialize(
25
26
  name_,
26
27
  symbol_,
27
28
  newOwner_,
28
- tokenIdType_
29
+ lsp4TokenType_,
30
+ lsp8TokenIdFormat_
29
31
  );
30
32
  }
31
33