@lukso/lsp-smart-contracts 0.12.0 → 0.13.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 (160) hide show
  1. package/README.md +2 -2
  2. package/artifacts/LSP0ERC725Account.json +19 -19
  3. package/artifacts/LSP0ERC725AccountInit.json +19 -19
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateUP.json +15 -15
  7. package/artifacts/LSP1UniversalReceiverDelegateVault.json +15 -15
  8. package/artifacts/LSP4DigitalAssetMetadata.json +5 -0
  9. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +5 -0
  10. package/artifacts/LSP6KeyManager.json +15 -15
  11. package/artifacts/LSP6KeyManagerInit.json +15 -15
  12. package/artifacts/LSP7CappedSupply.json +71 -49
  13. package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -49
  14. package/artifacts/LSP7CompatibleERC20.json +71 -49
  15. package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -49
  16. package/artifacts/LSP7CompatibleERC20Mintable.json +78 -51
  17. package/artifacts/LSP7CompatibleERC20MintableInit.json +78 -51
  18. package/artifacts/LSP7DigitalAsset.json +71 -49
  19. package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -49
  20. package/artifacts/LSP7Mintable.json +78 -51
  21. package/artifacts/LSP7MintableInit.json +78 -51
  22. package/artifacts/LSP8CappedSupply.json +187 -36
  23. package/artifacts/LSP8CappedSupplyInitAbstract.json +200 -49
  24. package/artifacts/LSP8CompatibleERC721.json +187 -36
  25. package/artifacts/LSP8CompatibleERC721InitAbstract.json +200 -49
  26. package/artifacts/LSP8CompatibleERC721Mintable.json +195 -39
  27. package/artifacts/LSP8CompatibleERC721MintableInit.json +208 -52
  28. package/artifacts/LSP8IdentifiableDigitalAsset.json +187 -36
  29. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +200 -49
  30. package/artifacts/LSP8Mintable.json +195 -39
  31. package/artifacts/LSP8MintableInit.json +208 -52
  32. package/artifacts/LSP9Vault.json +19 -19
  33. package/artifacts/LSP9VaultInit.json +19 -19
  34. package/artifacts/UniversalProfile.json +19 -19
  35. package/artifacts/UniversalProfileInit.json +19 -19
  36. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  37. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +7 -3
  38. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +62 -62
  39. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -1
  40. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -1
  41. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +11 -10
  42. package/contracts/LSP17Extensions/Extension4337.sol +26 -1
  43. package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +2 -1
  44. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +31 -33
  45. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +24 -17
  46. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +1 -1
  47. package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +1 -5
  48. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +9 -0
  49. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +20 -34
  50. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol +47 -0
  51. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +19 -31
  52. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +13 -6
  53. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
  54. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +16 -10
  55. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +2 -1
  56. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +14 -16
  57. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +6 -2
  58. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +20 -9
  59. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
  60. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +7 -5
  61. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +129 -36
  62. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -2
  63. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +6 -0
  64. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +4 -2
  65. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +7 -4
  66. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -2
  67. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +5 -2
  68. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +8 -2
  69. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +12 -1
  70. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +4 -0
  71. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -0
  72. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +77 -4
  73. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +15 -12
  74. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +19 -3
  75. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +25 -16
  76. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +222 -28
  77. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +28 -15
  78. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +16 -8
  79. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +9 -8
  80. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +13 -2
  81. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +6 -2
  82. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +4 -2
  83. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +13 -2
  84. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +6 -2
  85. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +6 -2
  86. package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
  87. package/contracts/LSP9Vault/LSP9Vault.sol +3 -2
  88. package/contracts/LSP9Vault/LSP9VaultCore.sol +22 -37
  89. package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
  90. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +1 -1
  91. package/contracts/UniversalProfile.sol +4 -2
  92. package/contracts/UniversalProfileInit.sol +8 -5
  93. package/contracts/UniversalProfileInitAbstract.sol +4 -2
  94. package/contracts/Version.sol +6 -5
  95. package/devdocs/LSP0ERC725Account.json +3 -8
  96. package/devdocs/LSP0ERC725AccountInit.json +2 -7
  97. package/devdocs/LSP1UniversalReceiverDelegateUP.json +0 -6
  98. package/devdocs/LSP1UniversalReceiverDelegateVault.json +0 -6
  99. package/devdocs/LSP4DigitalAssetMetadata.json +11 -5
  100. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -2
  101. package/devdocs/LSP6KeyManager.json +2 -7
  102. package/devdocs/LSP6KeyManagerInit.json +2 -7
  103. package/devdocs/LSP7CappedSupply.json +22 -8
  104. package/devdocs/LSP7CappedSupplyInitAbstract.json +22 -8
  105. package/devdocs/LSP7CompatibleERC20.json +23 -8
  106. package/devdocs/LSP7CompatibleERC20InitAbstract.json +22 -8
  107. package/devdocs/LSP7CompatibleERC20Mintable.json +23 -8
  108. package/devdocs/LSP7CompatibleERC20MintableInit.json +24 -9
  109. package/devdocs/LSP7DigitalAsset.json +27 -12
  110. package/devdocs/LSP7DigitalAssetInitAbstract.json +22 -8
  111. package/devdocs/LSP7Mintable.json +24 -8
  112. package/devdocs/LSP7MintableInit.json +25 -9
  113. package/devdocs/LSP8CappedSupply.json +66 -10
  114. package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -10
  115. package/devdocs/LSP8CompatibleERC721.json +69 -11
  116. package/devdocs/LSP8CompatibleERC721InitAbstract.json +67 -11
  117. package/devdocs/LSP8CompatibleERC721Mintable.json +69 -11
  118. package/devdocs/LSP8CompatibleERC721MintableInit.json +70 -12
  119. package/devdocs/LSP8IdentifiableDigitalAsset.json +71 -14
  120. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -10
  121. package/devdocs/LSP8Mintable.json +68 -10
  122. package/devdocs/LSP8MintableInit.json +69 -11
  123. package/devdocs/LSP9Vault.json +0 -6
  124. package/devdocs/LSP9VaultInit.json +0 -6
  125. package/devdocs/UniversalProfile.json +3 -8
  126. package/devdocs/UniversalProfileInit.json +4 -9
  127. package/dist/constants.cjs.js +4552 -1859
  128. package/dist/constants.d.ts +4143 -1371
  129. package/dist/constants.es.js +4551 -1859
  130. package/package.json +2 -2
  131. package/userdocs/LSP0ERC725Account.json +3 -3
  132. package/userdocs/LSP0ERC725AccountInit.json +3 -3
  133. package/userdocs/LSP1UniversalReceiverDelegateUP.json +3 -3
  134. package/userdocs/LSP1UniversalReceiverDelegateVault.json +3 -3
  135. package/userdocs/LSP6KeyManager.json +3 -3
  136. package/userdocs/LSP6KeyManagerInit.json +3 -3
  137. package/userdocs/LSP7CappedSupply.json +8 -3
  138. package/userdocs/LSP7CappedSupplyInitAbstract.json +8 -3
  139. package/userdocs/LSP7CompatibleERC20.json +8 -3
  140. package/userdocs/LSP7CompatibleERC20InitAbstract.json +8 -3
  141. package/userdocs/LSP7CompatibleERC20Mintable.json +8 -3
  142. package/userdocs/LSP7CompatibleERC20MintableInit.json +9 -4
  143. package/userdocs/LSP7DigitalAsset.json +8 -3
  144. package/userdocs/LSP7DigitalAssetInitAbstract.json +8 -3
  145. package/userdocs/LSP7Mintable.json +8 -3
  146. package/userdocs/LSP7MintableInit.json +9 -4
  147. package/userdocs/LSP8CappedSupply.json +20 -3
  148. package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -3
  149. package/userdocs/LSP8CompatibleERC721.json +20 -3
  150. package/userdocs/LSP8CompatibleERC721InitAbstract.json +20 -3
  151. package/userdocs/LSP8CompatibleERC721Mintable.json +20 -3
  152. package/userdocs/LSP8CompatibleERC721MintableInit.json +21 -4
  153. package/userdocs/LSP8IdentifiableDigitalAsset.json +20 -3
  154. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +19 -2
  155. package/userdocs/LSP8Mintable.json +19 -2
  156. package/userdocs/LSP8MintableInit.json +20 -3
  157. package/userdocs/LSP9Vault.json +3 -3
  158. package/userdocs/LSP9VaultInit.json +3 -3
  159. package/userdocs/UniversalProfile.json +3 -3
  160. package/userdocs/UniversalProfileInit.json +3 -3
@@ -8,7 +8,6 @@ import {
8
8
  import {ILSP7DigitalAsset} from "./ILSP7DigitalAsset.sol";
9
9
 
10
10
  // modules
11
- import {Version} from "../Version.sol";
12
11
 
13
12
  // libraries
14
13
  import {
@@ -31,7 +30,8 @@ import {
31
30
  LSP7CannotSendWithAddressZero,
32
31
  LSP7NotifyTokenReceiverContractMissingLSP1Interface,
33
32
  LSP7NotifyTokenReceiverIsEOA,
34
- OperatorAllowanceCannotBeIncreasedFromZero
33
+ OperatorAllowanceCannotBeIncreasedFromZero,
34
+ LSP7BatchCallFailed
35
35
  } from "./LSP7Errors.sol";
36
36
 
37
37
  // constants
@@ -52,10 +52,8 @@ import {
52
52
  * Similar to ERC20, the non-standard {increaseAllowance} and {decreaseAllowance} functions
53
53
  * have been added to mitigate the well-known issues around setting allowances.
54
54
  */
55
- abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
55
+ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
56
56
  using EnumerableSet for EnumerableSet.AddressSet;
57
- using ERC165Checker for address;
58
- using LSP1Utils for address;
59
57
 
60
58
  // --- Storage
61
59
 
@@ -100,6 +98,45 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
100
98
  return _tokenOwnerBalances[tokenOwner];
101
99
  }
102
100
 
101
+ // --- General functionality
102
+
103
+ /**
104
+ * @inheritdoc ILSP7DigitalAsset
105
+ *
106
+ * @custom:info It's not possible to send value along the functions call due to the use of `delegatecall`.
107
+ */
108
+ function batchCalls(
109
+ bytes[] calldata data
110
+ ) public virtual override returns (bytes[] memory results) {
111
+ results = new bytes[](data.length);
112
+ for (uint256 i; i < data.length; ) {
113
+ (bool success, bytes memory result) = address(this).delegatecall(
114
+ data[i]
115
+ );
116
+
117
+ if (!success) {
118
+ // Look for revert reason and bubble it up if present
119
+ if (result.length != 0) {
120
+ // The easiest way to bubble the revert reason is using memory via assembly
121
+ // solhint-disable no-inline-assembly
122
+ /// @solidity memory-safe-assembly
123
+ assembly {
124
+ let returndata_size := mload(result)
125
+ revert(add(32, result), returndata_size)
126
+ }
127
+ } else {
128
+ revert LSP7BatchCallFailed({callIndex: i});
129
+ }
130
+ }
131
+
132
+ results[i] = result;
133
+
134
+ unchecked {
135
+ ++i;
136
+ }
137
+ }
138
+ }
139
+
103
140
  // --- Operator functionality
104
141
 
105
142
  /**
@@ -133,10 +170,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
133
170
  operatorNotificationData
134
171
  );
135
172
 
136
- operator.tryNotifyUniversalReceiver(
137
- _TYPEID_LSP7_TOKENOPERATOR,
138
- lsp1Data
139
- );
173
+ _notifyTokenOperator(operator, lsp1Data);
140
174
  }
141
175
 
142
176
  /**
@@ -162,10 +196,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
162
196
  operatorNotificationData
163
197
  );
164
198
 
165
- operator.tryNotifyUniversalReceiver(
166
- _TYPEID_LSP7_TOKENOPERATOR,
167
- lsp1Data
168
- );
199
+ _notifyTokenOperator(operator, lsp1Data);
169
200
  }
170
201
  }
171
202
 
@@ -220,10 +251,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
220
251
  operatorNotificationData
221
252
  );
222
253
 
223
- operator.tryNotifyUniversalReceiver(
224
- _TYPEID_LSP7_TOKENOPERATOR,
225
- lsp1Data
226
- );
254
+ _notifyTokenOperator(operator, lsp1Data);
227
255
  }
228
256
 
229
257
  /**
@@ -257,10 +285,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
257
285
  operatorNotificationData
258
286
  );
259
287
 
260
- operator.tryNotifyUniversalReceiver(
261
- _TYPEID_LSP7_TOKENOPERATOR,
262
- lsp1Data
263
- );
288
+ _notifyTokenOperator(operator, lsp1Data);
264
289
  }
265
290
 
266
291
  // --- Transfer functionality
@@ -330,8 +355,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
330
355
  * @param operatorNotificationData The data to send to the universalReceiver function of the operator in case of notifying
331
356
  *
332
357
  * @custom:events
333
- * - {RevokedOperator} event when operator's allowance is set to `0`.
334
- * - {AuthorizedOperator} event when operator's allowance is set to any other amount.
358
+ * - {OperatorRevoked} event when operator's allowance is set to `0`.
359
+ * - {OperatorAuthorizationChanged} event when operator's allowance is set to any other amount.
335
360
  *
336
361
  * @custom:requirements
337
362
  * - `operator` cannot be the zero address.
@@ -356,7 +381,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
356
381
 
357
382
  if (allowance != 0) {
358
383
  _operators[tokenOwner].add(operator);
359
- emit AuthorizedOperator(
384
+ emit OperatorAuthorizationChanged(
360
385
  operator,
361
386
  tokenOwner,
362
387
  allowance,
@@ -364,7 +389,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
364
389
  );
365
390
  } else {
366
391
  _operators[tokenOwner].remove(operator);
367
- emit RevokedOperator(
392
+ emit OperatorRevoked(
368
393
  operator,
369
394
  tokenOwner,
370
395
  notified,
@@ -407,11 +432,24 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
407
432
 
408
433
  _tokenOwnerBalances[to] += amount;
409
434
 
410
- emit Transfer(msg.sender, address(0), to, amount, force, data);
435
+ emit Transfer({
436
+ operator: msg.sender,
437
+ from: address(0),
438
+ to: to,
439
+ amount: amount,
440
+ force: force,
441
+ data: data
442
+ });
411
443
 
412
444
  _afterTokenTransfer(address(0), to, amount, data);
413
445
 
414
- bytes memory lsp1Data = abi.encode(address(0), to, amount, data);
446
+ bytes memory lsp1Data = abi.encode(
447
+ msg.sender,
448
+ address(0),
449
+ to,
450
+ amount,
451
+ data
452
+ );
415
453
  _notifyTokenReceiver(to, force, lsp1Data);
416
454
  }
417
455
 
@@ -461,7 +499,6 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
461
499
 
462
500
  _tokenOwnerBalances[from] -= amount;
463
501
 
464
- emit Transfer(msg.sender, from, address(0), amount, false, data);
465
502
  emit Transfer({
466
503
  operator: msg.sender,
467
504
  from: from,
@@ -473,8 +510,14 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
473
510
 
474
511
  _afterTokenTransfer(from, address(0), amount, data);
475
512
 
476
- bytes memory lsp1Data = abi.encode(from, address(0), amount, data);
477
- from.tryNotifyUniversalReceiver(_TYPEID_LSP7_TOKENSSENDER, lsp1Data);
513
+ bytes memory lsp1Data = abi.encode(
514
+ msg.sender,
515
+ from,
516
+ address(0),
517
+ amount,
518
+ data
519
+ );
520
+ _notifyTokenSender(from, lsp1Data);
478
521
  }
479
522
 
480
523
  /**
@@ -485,8 +528,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
485
528
  * @param amountToSpend The amount of tokens to substract in allowance of `operator`.
486
529
  *
487
530
  * @custom:events
488
- * - {RevokedOperator} event when operator's allowance is set to `0`.
489
- * - {AuthorizedOperator} event when operator's allowance is set to any other amount.
531
+ * - {OperatorRevoked} event when operator's allowance is set to `0`.
532
+ * - {OperatorAuthorizationChanged} event when operator's allowance is set to any other amount.
490
533
  *
491
534
  * @custom:requirements
492
535
  * - The `amountToSpend` MUST be at least the allowance granted to `operator` (accessible via {`authorizedAmountFor}`)
@@ -566,13 +609,20 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
566
609
  _tokenOwnerBalances[from] -= amount;
567
610
  _tokenOwnerBalances[to] += amount;
568
611
 
569
- emit Transfer(msg.sender, from, to, amount, force, data);
612
+ emit Transfer({
613
+ operator: msg.sender,
614
+ from: from,
615
+ to: to,
616
+ amount: amount,
617
+ force: force,
618
+ data: data
619
+ });
570
620
 
571
621
  _afterTokenTransfer(from, to, amount, data);
572
622
 
573
- bytes memory lsp1Data = abi.encode(from, to, amount, data);
623
+ bytes memory lsp1Data = abi.encode(msg.sender, from, to, amount, data);
574
624
 
575
- from.tryNotifyUniversalReceiver(_TYPEID_LSP7_TOKENSSENDER, lsp1Data);
625
+ _notifyTokenSender(from, lsp1Data);
576
626
  _notifyTokenReceiver(to, force, lsp1Data);
577
627
  }
578
628
 
@@ -608,6 +658,44 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
608
658
  bytes memory data // solhint-disable-next-line no-empty-blocks
609
659
  ) internal virtual {}
610
660
 
661
+ /**
662
+ * @dev Attempt to notify the operator `operator` about the `amount` tokens being authorized with.
663
+ * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENOPERATOR` as typeId, if `operator` is a contract that supports the LSP1 interface.
664
+ * If `operator` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
665
+
666
+ * @param operator The address to call the {universalReceiver} function on.
667
+ * @param lsp1Data the data to be sent to the `operator` address in the `universalReceiver` call.
668
+ */
669
+ function _notifyTokenOperator(
670
+ address operator,
671
+ bytes memory lsp1Data
672
+ ) internal virtual {
673
+ LSP1Utils.notifyUniversalReceiver(
674
+ operator,
675
+ _TYPEID_LSP7_TOKENOPERATOR,
676
+ lsp1Data
677
+ );
678
+ }
679
+
680
+ /**
681
+ * @dev Attempt to notify the token sender `from` about the `amount` of tokens being transferred.
682
+ * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENSSENDER` as typeId, if `from` is a contract that supports the LSP1 interface.
683
+ * If `from` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
684
+
685
+ * @param from The address to call the {universalReceiver} function on.
686
+ * @param lsp1Data the data to be sent to the `from` address in the `universalReceiver` call.
687
+ */
688
+ function _notifyTokenSender(
689
+ address from,
690
+ bytes memory lsp1Data
691
+ ) internal virtual {
692
+ LSP1Utils.notifyUniversalReceiver(
693
+ from,
694
+ _TYPEID_LSP7_TOKENSSENDER,
695
+ lsp1Data
696
+ );
697
+ }
698
+
611
699
  /**
612
700
  * @dev Attempt to notify the token receiver `to` about the `amount` tokens being received.
613
701
  * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface.
@@ -625,7 +713,12 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
625
713
  bool force,
626
714
  bytes memory lsp1Data
627
715
  ) internal virtual {
628
- if (to.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP1)) {
716
+ if (
717
+ ERC165Checker.supportsERC165InterfaceUnchecked(
718
+ to,
719
+ _INTERFACEID_LSP1
720
+ )
721
+ ) {
629
722
  ILSP1(to).universalReceiver(_TYPEID_LSP7_TOKENSRECIPIENT, lsp1Data);
630
723
  } else if (!force) {
631
724
  if (to.code.length != 0) {
@@ -46,14 +46,17 @@ abstract contract LSP7DigitalAssetInitAbstract is
46
46
  string memory name_,
47
47
  string memory symbol_,
48
48
  address newOwner_,
49
+ uint256 lsp4TokenType_,
49
50
  bool isNonDivisible_
50
51
  ) internal virtual onlyInitializing {
51
- _isNonDivisible = isNonDivisible_;
52
52
  LSP4DigitalAssetMetadataInitAbstract._initialize(
53
53
  name_,
54
54
  symbol_,
55
- newOwner_
55
+ newOwner_,
56
+ lsp4TokenType_
56
57
  );
58
+
59
+ _isNonDivisible = isNonDivisible_;
57
60
  }
58
61
 
59
62
  // fallback function
@@ -82,3 +82,9 @@ error LSP7TokenContractCannotHoldValue();
82
82
  * @dev Reverts when token owner call {increaseAllowance} for an operator that does not have any allowance
83
83
  */
84
84
  error OperatorAllowanceCannotBeIncreasedFromZero(address operator);
85
+
86
+ /**
87
+ * @dev Reverts when a batch call failed.
88
+ * @notice Batch call failed.
89
+ */
90
+ error LSP7BatchCallFailed(uint256 callIndex);
@@ -27,12 +27,14 @@ abstract contract LSP7CompatibleERC20 is IERC20Metadata, LSP7DigitalAsset {
27
27
  * @param name_ The name of the token.
28
28
  * @param symbol_ The symbol of the token.
29
29
  * @param newOwner_ The owner of the token contract.
30
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
30
31
  */
31
32
  constructor(
32
33
  string memory name_,
33
34
  string memory symbol_,
34
- address newOwner_
35
- ) LSP7DigitalAsset(name_, symbol_, newOwner_, false) {}
35
+ address newOwner_,
36
+ uint256 lsp4TokenType_
37
+ ) LSP7DigitalAsset(name_, symbol_, newOwner_, lsp4TokenType_, false) {}
36
38
 
37
39
  /**
38
40
  * @inheritdoc IERC20Metadata
@@ -30,19 +30,22 @@ abstract contract LSP7CompatibleERC20InitAbstract is
30
30
  * @notice Initializing a `LSP7CompatibleERC20` token contract with: token name = `name_`, token symbol = `symbol_`, and
31
31
  * address `newOwner_` as the token contract owner.
32
32
  *
33
- * @param name_ The name of the token
34
- * @param symbol_ The symbol of the token
35
- * @param newOwner_ The owner of the token
33
+ * @param name_ The name of the token.
34
+ * @param symbol_ The symbol of the token.
35
+ * @param newOwner_ The owner of the token.
36
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
36
37
  */
37
38
  function _initialize(
38
39
  string memory name_,
39
40
  string memory symbol_,
40
- address newOwner_
41
+ address newOwner_,
42
+ uint256 lsp4TokenType_
41
43
  ) internal virtual override onlyInitializing {
42
44
  LSP7DigitalAssetInitAbstract._initialize(
43
45
  name_,
44
46
  symbol_,
45
47
  newOwner_,
48
+ lsp4TokenType_,
46
49
  false
47
50
  );
48
51
  }
@@ -14,12 +14,14 @@ contract LSP7CompatibleERC20Mintable is LSP7CompatibleERC20 {
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 (`1` = Token, `2` = NFT, `3` = Collection).
17
18
  */
18
19
  constructor(
19
20
  string memory name_,
20
21
  string memory symbol_,
21
- address newOwner_
22
- ) LSP7CompatibleERC20(name_, symbol_, newOwner_) {}
22
+ address newOwner_,
23
+ uint256 lsp4TokenType_
24
+ ) LSP7CompatibleERC20(name_, symbol_, newOwner_, lsp4TokenType_) {}
23
25
 
24
26
  /**
25
27
  * @dev Public {_mint} function only callable by the {owner}.
@@ -26,16 +26,19 @@ contract LSP7CompatibleERC20MintableInit 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 (`1` = Token, `2` = NFT, `3` = Collection).
29
30
  */
30
31
  function initialize(
31
32
  string memory name_,
32
33
  string memory symbol_,
33
- address newOwner_
34
+ address newOwner_,
35
+ uint256 lsp4TokenType_
34
36
  ) external virtual initializer {
35
37
  LSP7CompatibleERC20MintableInitAbstract._initialize(
36
38
  name_,
37
39
  symbol_,
38
- newOwner_
40
+ newOwner_,
41
+ lsp4TokenType_
39
42
  );
40
43
  }
41
44
  }
@@ -18,9 +18,15 @@ abstract contract LSP7CompatibleERC20MintableInitAbstract is
18
18
  function _initialize(
19
19
  string memory name_,
20
20
  string memory symbol_,
21
- address newOwner_
21
+ address newOwner_,
22
+ uint256 lsp4TokenType_
22
23
  ) internal virtual override onlyInitializing {
23
- LSP7CompatibleERC20InitAbstract._initialize(name_, symbol_, newOwner_);
24
+ LSP7CompatibleERC20InitAbstract._initialize(
25
+ name_,
26
+ symbol_,
27
+ newOwner_,
28
+ lsp4TokenType_
29
+ );
24
30
  }
25
31
 
26
32
  /**
@@ -20,13 +20,24 @@ contract LSP7Mintable is LSP7DigitalAsset, ILSP7Mintable {
20
20
  * @param name_ The name of the token.
21
21
  * @param symbol_ The symbol of the token.
22
22
  * @param newOwner_ The owner of the token contract.
23
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
24
+ * @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token.
23
25
  */
24
26
  constructor(
25
27
  string memory name_,
26
28
  string memory symbol_,
27
29
  address newOwner_,
30
+ uint256 lsp4TokenType_,
28
31
  bool isNonDivisible_
29
- ) LSP7DigitalAsset(name_, symbol_, newOwner_, isNonDivisible_) {}
32
+ )
33
+ LSP7DigitalAsset(
34
+ name_,
35
+ symbol_,
36
+ newOwner_,
37
+ lsp4TokenType_,
38
+ isNonDivisible_
39
+ )
40
+ {}
30
41
 
31
42
  /**
32
43
  * @dev Public {_mint} function only callable by the {owner}.
@@ -23,17 +23,21 @@ contract LSP7MintableInit is LSP7MintableInitAbstract {
23
23
  * @param name_ The name of the token.
24
24
  * @param symbol_ The symbol of the token.
25
25
  * @param newOwner_ The owner of the token contract.
26
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
27
+ * @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token.
26
28
  */
27
29
  function initialize(
28
30
  string memory name_,
29
31
  string memory symbol_,
30
32
  address newOwner_,
33
+ uint256 lsp4TokenType_,
31
34
  bool isNonDivisible_
32
35
  ) external virtual initializer {
33
36
  LSP7MintableInitAbstract._initialize(
34
37
  name_,
35
38
  symbol_,
36
39
  newOwner_,
40
+ lsp4TokenType_,
37
41
  isNonDivisible_
38
42
  );
39
43
  }
@@ -24,17 +24,21 @@ abstract contract LSP7MintableInitAbstract is
24
24
  * @param name_ The name of the token.
25
25
  * @param symbol_ The symbol of the token.
26
26
  * @param newOwner_ The owner of the token contract.
27
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
28
+ * @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token.
27
29
  */
28
30
  function _initialize(
29
31
  string memory name_,
30
32
  string memory symbol_,
31
33
  address newOwner_,
34
+ uint256 lsp4TokenType_,
32
35
  bool isNonDivisible_
33
36
  ) internal virtual override onlyInitializing {
34
37
  LSP7DigitalAssetInitAbstract._initialize(
35
38
  name_,
36
39
  symbol_,
37
40
  newOwner_,
41
+ lsp4TokenType_,
38
42
  isNonDivisible_
39
43
  );
40
44
  }
@@ -39,7 +39,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
39
39
  * @param tokenId The tokenId `operator` address has access on behalf of `tokenOwner`.
40
40
  * @param operatorNotificationData The data to notify the operator about via LSP1.
41
41
  */
42
- event AuthorizedOperator(
42
+ event OperatorAuthorizationChanged(
43
43
  address indexed operator,
44
44
  address indexed tokenOwner,
45
45
  bytes32 indexed tokenId,
@@ -54,7 +54,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
54
54
  * @param notified Bool indicating whether the operator has been notified or not
55
55
  * @param operatorNotificationData The data to notify the operator about via LSP1.
56
56
  */
57
- event RevokedOperator(
57
+ event OperatorRevoked(
58
58
  address indexed operator,
59
59
  address indexed tokenOwner,
60
60
  bytes32 indexed tokenId,
@@ -62,6 +62,18 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
62
62
  bytes operatorNotificationData
63
63
  );
64
64
 
65
+ /**
66
+ * @dev Emitted when setting data for `tokenId`.
67
+ * @param tokenId The tokenId which data is set for.
68
+ * @param dataKey The data key for which a bytes value is set.
69
+ * @param dataValue The value to set for the given data key.
70
+ */
71
+ event TokenIdDataChanged(
72
+ bytes32 indexed tokenId,
73
+ bytes32 indexed dataKey,
74
+ bytes dataValue
75
+ );
76
+
65
77
  // --- Token queries
66
78
 
67
79
  /**
@@ -100,6 +112,56 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
100
112
  address tokenOwner
101
113
  ) external view returns (bytes32[] memory);
102
114
 
115
+ // --- TokenId Metadata functionality
116
+
117
+ /**
118
+ * @notice Sets data for a specific `tokenId` and `dataKey`.
119
+ * @param tokenId The unique identifier for a token.
120
+ * @param dataKey The key for the data to set.
121
+ * @param dataValue The value to set for the given data key.
122
+ * @custom:events {TokenIdDataChanged} event.
123
+ */
124
+ function setTokenIdData(
125
+ bytes32 tokenId,
126
+ bytes32 dataKey,
127
+ bytes memory dataValue
128
+ ) external;
129
+
130
+ /**
131
+ * @notice Sets data in batch for multiple `tokenId` and `dataKey` pairs.
132
+ * @param tokenId An array of token IDs.
133
+ * @param dataKey An array of data keys corresponding to the token IDs.
134
+ * @param dataValue An array of values to set for the given data keys.
135
+ * @custom:events {TokenIdDataChanged} event for each pair.
136
+ */
137
+ function setTokenIdDataBatch(
138
+ bytes32[] memory tokenId,
139
+ bytes32[] memory dataKey,
140
+ bytes[] memory dataValue
141
+ ) external;
142
+
143
+ /**
144
+ * @notice Retrieves data for a specific `tokenId` and `dataKey`.
145
+ * @param tokenId The unique identifier for a token.
146
+ * @param dataKey The key for the data to retrieve.
147
+ * @return dataValues The data value associated with the given `tokenId` and `dataKey`.
148
+ */
149
+ function getTokenIdData(
150
+ bytes32 tokenId,
151
+ bytes32 dataKey
152
+ ) external returns (bytes memory dataValues);
153
+
154
+ /**
155
+ * @notice Retrieves data in batch for multiple `tokenId` and `dataKey` pairs.
156
+ * @param tokenId An array of token IDs.
157
+ * @param dataKey An array of data keys corresponding to the token IDs.
158
+ * @return dataValues An array of data values for each pair of `tokenId` and `dataKey`.
159
+ */
160
+ function getTokenIdDataBatch(
161
+ bytes32[] memory tokenId,
162
+ bytes32[] memory dataKey
163
+ ) external returns (bytes[] memory dataValues);
164
+
103
165
  // --- Operator functionality
104
166
 
105
167
  /**
@@ -116,7 +178,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
116
178
  * - the owner of a `tokenId` cannot grant itself as an `operator` (`operator` cannot be the calling address).
117
179
  * - `operator` cannot be the zero address.
118
180
  *
119
- * @custom:events {AuthorizedOperator} event.
181
+ * @custom:events {OperatorAuthorizationChanged} event.
120
182
  */
121
183
  function authorizeOperator(
122
184
  address operator,
@@ -139,7 +201,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
139
201
  * - the owner of a `tokenId` cannot grant revoke itself as an `operator` (`operator` cannot be the calling address).
140
202
  * - `operator` cannot be the zero address.
141
203
  *
142
- * @custom:events {RevokedOperator} event with address of the operator being revoked for the caller (token owner)..
204
+ * @custom:events {OperatorRevoked} event with address of the operator being revoked for the caller (token owner)..
143
205
  */
144
206
  function revokeOperator(
145
207
  address operator,
@@ -253,4 +315,15 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
253
315
  bool[] memory force,
254
316
  bytes[] memory data
255
317
  ) external;
318
+
319
+ /**
320
+ * @notice Executing the following batch of abi-encoded function calls on the contract: `data`.
321
+ *
322
+ * @dev Allows a caller to batch different function calls in one call. Perform a `delegatecall` on self, to call different functions with preserving the context.
323
+ * @param data An array of ABI encoded function calls to be called on the contract.
324
+ * @return results An array of abi-encoded data returned by the functions executed.
325
+ */
326
+ function batchCalls(
327
+ bytes[] calldata data
328
+ ) external returns (bytes[] memory results);
256
329
  }
@@ -2,15 +2,12 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_LSP8 = 0x30dc5278;
5
+ bytes4 constant _INTERFACEID_LSP8 = 0xecad9f75;
6
6
 
7
7
  // --- ERC725Y Data Keys
8
8
 
9
- // keccak256('LSP8TokenIdType')
10
- bytes32 constant _LSP8_TOKENID_TYPE_KEY = 0x715f248956de7ce65e94d9d836bfead479f7e70d69b718d47bfe7b00e05b4fe4;
11
-
12
- // bytes10(keccak256('LSP8MetadataTokenURI')) + bytes2(0)
13
- bytes12 constant _LSP8_METADATA_TOKEN_URI_PREFIX = 0x1339e76a390b7b9ec9010000;
9
+ // keccak256('LSP8TokenIdSchema')
10
+ bytes32 constant _LSP8_TOKENID_SCHEMA_KEY = 0x341bc44e55234544c70af9d37b2cb8cc7ba74685b58526221de2cc977f469924;
14
11
 
15
12
  // keccak256('LSP8TokenMetadataBaseURI')
16
13
  bytes32 constant _LSP8_TOKEN_METADATA_BASE_URI = 0x1a7628600c3bac7101f53697f48df381ddc36b9015e7d7c9c5633d1252aa2843;
@@ -29,10 +26,16 @@ bytes32 constant _TYPEID_LSP8_TOKENSRECIPIENT = 0x0b084a55ebf70fd3c06fd755269dac
29
26
  // keccak256('LSP8Tokens_OperatorNotification')
30
27
  bytes32 constant _TYPEID_LSP8_TOKENOPERATOR = 0x8a1c15a8799f71b547e08e2bcb2e85257e81b0a07eee2ce6712549eef1f00970;
31
28
 
32
- // --- Types of token IDs
29
+ // --- Token IDs Schema
30
+
31
+ uint256 constant _LSP8_TOKENID_SCHEMA_NUMBER = 0;
32
+ uint256 constant _LSP8_TOKENID_SCHEMA_STRING = 1;
33
+ uint256 constant _LSP8_TOKENID_SCHEMA_ADDRESS = 2;
34
+ uint256 constant _LSP8_TOKENID_SCHEMA_UNIQUE_ID = 3;
35
+ uint256 constant _LSP8_TOKENID_SCHEMA_HASH = 4;
33
36
 
34
- uint256 constant _LSP8_TOKENID_TYPE_NUMBER = 0;
35
- uint256 constant _LSP8_TOKENID_TYPE_STRING = 1;
36
- uint256 constant _LSP8_TOKENID_TYPE_UNIQUE_ID = 2;
37
- uint256 constant _LSP8_TOKENID_TYPE_HASH = 3;
38
- uint256 constant _LSP8_TOKENID_TYPE_ADDRESS = 4;
37
+ uint256 constant _LSP8_TOKENID_SCHEMA_MIXED_DEFAULT_NUMBER = 100;
38
+ uint256 constant _LSP8_TOKENID_SCHEMA_MIXED_DEFAULT_STRING = 101;
39
+ uint256 constant _LSP8_TOKENID_SCHEMA_MIXED_DEFAULT_ADDRESS = 102;
40
+ uint256 constant _LSP8_TOKENID_SCHEMA_MIXED_DEFAULT_UNIQUE_ID = 103;
41
+ uint256 constant _LSP8_TOKENID_SCHEMA_MIXED_DEFAULT_HASH = 104;