@lukso/lsp-smart-contracts 0.11.0-rc.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +1 -0
  2. package/artifacts/LSP0ERC725Account.json +7 -2
  3. package/artifacts/LSP0ERC725AccountInit.json +7 -2
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateUP.json +3 -79
  7. package/artifacts/LSP1UniversalReceiverDelegateVault.json +3 -41
  8. package/artifacts/LSP23LinkedContractsFactory.json +544 -0
  9. package/artifacts/LSP6KeyManager.json +24 -19
  10. package/artifacts/LSP6KeyManagerInit.json +24 -19
  11. package/artifacts/LSP7CappedSupply.json +88 -0
  12. package/artifacts/LSP7CappedSupplyInitAbstract.json +88 -0
  13. package/artifacts/LSP7CompatibleERC20.json +88 -0
  14. package/artifacts/LSP7CompatibleERC20InitAbstract.json +88 -0
  15. package/artifacts/LSP7CompatibleERC20Mintable.json +90 -2
  16. package/artifacts/LSP7CompatibleERC20MintableInit.json +90 -2
  17. package/artifacts/LSP7DigitalAsset.json +88 -0
  18. package/artifacts/LSP7DigitalAssetInitAbstract.json +88 -0
  19. package/artifacts/LSP7Mintable.json +90 -2
  20. package/artifacts/LSP7MintableInit.json +90 -2
  21. package/artifacts/LSP8CappedSupply.json +59 -0
  22. package/artifacts/LSP8CappedSupplyInitAbstract.json +59 -0
  23. package/artifacts/LSP8CompatibleERC721.json +60 -1
  24. package/artifacts/LSP8CompatibleERC721InitAbstract.json +60 -1
  25. package/artifacts/LSP8CompatibleERC721Mintable.json +62 -3
  26. package/artifacts/LSP8CompatibleERC721MintableInit.json +62 -3
  27. package/artifacts/LSP8IdentifiableDigitalAsset.json +59 -0
  28. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +59 -0
  29. package/artifacts/LSP8Mintable.json +61 -2
  30. package/artifacts/LSP8MintableInit.json +61 -2
  31. package/artifacts/LSP9Vault.json +7 -2
  32. package/artifacts/LSP9VaultInit.json +7 -2
  33. package/artifacts/UniversalProfile.json +7 -2
  34. package/artifacts/UniversalProfileInit.json +7 -2
  35. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +8 -36
  36. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  37. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +15 -30
  38. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +122 -206
  39. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +18 -36
  40. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +8 -34
  41. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +148 -177
  42. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +21 -20
  43. package/contracts/LSP14Ownable2Step/LSP14Errors.sol +13 -2
  44. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +50 -20
  45. package/contracts/LSP17ContractExtension/LSP17Errors.sol +10 -0
  46. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +16 -34
  47. package/contracts/LSP17ContractExtension/LSP17Utils.sol +1 -1
  48. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +16 -11
  49. package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +5 -10
  50. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +192 -177
  51. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +150 -88
  52. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +66 -48
  53. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +1 -1
  54. package/contracts/LSP23LinkedContractsDeployment/ILSP23LinkedContractsFactory.sol +192 -0
  55. package/contracts/LSP23LinkedContractsDeployment/IPostDeploymentModule.sol +18 -0
  56. package/contracts/LSP23LinkedContractsDeployment/LSP23Errors.sol +24 -0
  57. package/contracts/LSP23LinkedContractsDeployment/LSP23LinkedContractsFactory.sol +392 -0
  58. package/contracts/{LSP23MultiChainDeployment → LSP23LinkedContractsDeployment}/modules/UniversalProfileInitPostDeploymentModule.sol +5 -1
  59. package/contracts/LSP23LinkedContractsDeployment/modules/UniversalProfilePostDeploymentModule.sol +61 -0
  60. package/contracts/LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol +68 -0
  61. package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +8 -0
  62. package/contracts/LSP25ExecuteRelayCall/LSP25Errors.sol +17 -0
  63. package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +143 -0
  64. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +256 -61
  65. package/contracts/{LSP3UniversalProfile → LSP3ProfileMetadata}/LSP3Constants.sol +3 -3
  66. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +9 -8
  67. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +13 -6
  68. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +4 -4
  69. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +148 -189
  70. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +26 -54
  71. package/contracts/LSP6KeyManager/LSP6Constants.sol +1 -3
  72. package/contracts/LSP6KeyManager/LSP6Errors.sol +142 -63
  73. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +7 -4
  74. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +125 -80
  75. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +8 -4
  76. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +1 -1
  77. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +52 -84
  78. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +59 -10
  79. package/contracts/LSP6KeyManager/LSP6Utils.sol +67 -46
  80. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +116 -78
  81. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +4 -1
  82. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +128 -6
  83. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +212 -80
  84. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +126 -3
  85. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +7 -5
  86. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +27 -14
  87. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +2 -4
  88. package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +2 -4
  89. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +29 -11
  90. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +30 -9
  91. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +46 -14
  92. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +43 -12
  93. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +14 -0
  94. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +9 -4
  95. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +7 -1
  96. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +8 -8
  97. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +7 -6
  98. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +10 -2
  99. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +120 -92
  100. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +4 -1
  101. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +135 -6
  102. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +128 -38
  103. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +134 -5
  104. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +83 -41
  105. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +13 -5
  106. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +24 -0
  107. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +30 -12
  108. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +31 -10
  109. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +96 -31
  110. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +98 -23
  111. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +21 -4
  112. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +12 -2
  113. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +21 -0
  114. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +9 -4
  115. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +13 -0
  116. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +15 -6
  117. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +7 -5
  118. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +17 -2
  119. package/contracts/LSP9Vault/ILSP9Vault.sol +10 -5
  120. package/contracts/LSP9Vault/LSP9Errors.sol +3 -2
  121. package/contracts/LSP9Vault/LSP9Vault.sol +12 -4
  122. package/contracts/LSP9Vault/LSP9VaultCore.sol +245 -182
  123. package/contracts/LSP9Vault/LSP9VaultInit.sol +10 -3
  124. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -6
  125. package/contracts/UniversalProfile.sol +8 -6
  126. package/contracts/UniversalProfileInit.sol +6 -6
  127. package/contracts/UniversalProfileInitAbstract.sol +10 -3
  128. package/devdocs/LSP0ERC725Account.json +54 -37
  129. package/devdocs/LSP0ERC725AccountInit.json +56 -38
  130. package/devdocs/LSP1UniversalReceiverDelegateUP.json +14 -55
  131. package/devdocs/LSP1UniversalReceiverDelegateVault.json +9 -33
  132. package/devdocs/LSP23LinkedContractsFactory.json +81 -0
  133. package/devdocs/LSP4DigitalAssetMetadata.json +5 -5
  134. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +4 -4
  135. package/devdocs/LSP6KeyManager.json +109 -70
  136. package/devdocs/LSP6KeyManagerInit.json +109 -70
  137. package/devdocs/LSP7CappedSupply.json +90 -42
  138. package/devdocs/LSP7CappedSupplyInitAbstract.json +86 -40
  139. package/devdocs/LSP7CompatibleERC20.json +79 -43
  140. package/devdocs/LSP7CompatibleERC20InitAbstract.json +75 -39
  141. package/devdocs/LSP7CompatibleERC20Mintable.json +87 -40
  142. package/devdocs/LSP7CompatibleERC20MintableInit.json +82 -42
  143. package/devdocs/LSP7DigitalAsset.json +76 -40
  144. package/devdocs/LSP7DigitalAssetInitAbstract.json +73 -37
  145. package/devdocs/LSP7Mintable.json +79 -51
  146. package/devdocs/LSP7MintableInit.json +78 -49
  147. package/devdocs/LSP8CappedSupply.json +72 -43
  148. package/devdocs/LSP8CappedSupplyInitAbstract.json +68 -41
  149. package/devdocs/LSP8CompatibleERC721.json +85 -64
  150. package/devdocs/LSP8CompatibleERC721InitAbstract.json +81 -60
  151. package/devdocs/LSP8CompatibleERC721Mintable.json +98 -60
  152. package/devdocs/LSP8CompatibleERC721MintableInit.json +93 -62
  153. package/devdocs/LSP8IdentifiableDigitalAsset.json +58 -41
  154. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -40
  155. package/devdocs/LSP8Mintable.json +65 -48
  156. package/devdocs/LSP8MintableInit.json +64 -47
  157. package/devdocs/LSP9Vault.json +61 -18
  158. package/devdocs/LSP9VaultInit.json +59 -17
  159. package/devdocs/UniversalProfile.json +53 -35
  160. package/devdocs/UniversalProfileInit.json +53 -35
  161. package/dist/constants.cjs.js +6236 -2587
  162. package/dist/constants.d.ts +3851 -1129
  163. package/dist/constants.es.js +6236 -2587
  164. package/package.json +6 -4
  165. package/userdocs/LSP0ERC725Account.json +40 -8
  166. package/userdocs/LSP0ERC725AccountInit.json +40 -8
  167. package/userdocs/LSP1UniversalReceiverDelegateUP.json +18 -2
  168. package/userdocs/LSP1UniversalReceiverDelegateVault.json +18 -2
  169. package/userdocs/LSP23LinkedContractsFactory.json +29 -0
  170. package/userdocs/LSP4DigitalAssetMetadata.json +1 -1
  171. package/userdocs/LSP6KeyManager.json +144 -6
  172. package/userdocs/LSP6KeyManagerInit.json +147 -6
  173. package/userdocs/LSP7CappedSupply.json +18 -3
  174. package/userdocs/LSP7CappedSupplyInitAbstract.json +17 -2
  175. package/userdocs/LSP7CompatibleERC20.json +3 -9
  176. package/userdocs/LSP7CompatibleERC20InitAbstract.json +2 -8
  177. package/userdocs/LSP7CompatibleERC20Mintable.json +5 -8
  178. package/userdocs/LSP7CompatibleERC20MintableInit.json +3 -9
  179. package/userdocs/LSP7DigitalAsset.json +2 -2
  180. package/userdocs/LSP7DigitalAssetInitAbstract.json +2 -2
  181. package/userdocs/LSP7Mintable.json +3 -3
  182. package/userdocs/LSP7MintableInit.json +3 -3
  183. package/userdocs/LSP8CappedSupply.json +16 -1
  184. package/userdocs/LSP8CappedSupplyInitAbstract.json +15 -0
  185. package/userdocs/LSP8CompatibleERC721.json +24 -3
  186. package/userdocs/LSP8CompatibleERC721InitAbstract.json +23 -2
  187. package/userdocs/LSP8CompatibleERC721Mintable.json +29 -2
  188. package/userdocs/LSP8CompatibleERC721MintableInit.json +27 -3
  189. package/userdocs/LSP8Mintable.json +4 -1
  190. package/userdocs/LSP8MintableInit.json +4 -1
  191. package/userdocs/LSP9Vault.json +50 -4
  192. package/userdocs/LSP9VaultInit.json +50 -4
  193. package/userdocs/UniversalProfile.json +40 -8
  194. package/userdocs/UniversalProfileInit.json +40 -8
  195. package/contracts/LSP0ERC725Account/LSP0Utils.sol +0 -47
  196. package/contracts/LSP23MultiChainDeployment/IOwnerControlledContractDeployer.sol +0 -174
  197. package/contracts/LSP23MultiChainDeployment/IPostDeploymentModule.sol +0 -10
  198. package/contracts/LSP23MultiChainDeployment/LSP23Errors.sol +0 -24
  199. package/contracts/LSP23MultiChainDeployment/OwnerControlledContractDeployer.sol +0 -388
@@ -1,6 +1,11 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.5;
3
3
 
4
+ // interfaces
5
+ import {
6
+ ILSP20CallVerifier as ILSP20
7
+ } from "../../LSP20CallVerification/ILSP20CallVerifier.sol";
8
+
4
9
  // modules
5
10
  import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
6
11
  import {
@@ -38,12 +43,13 @@ import {
38
43
  // errors
39
44
  import {
40
45
  NotRecognisedPermissionKey,
41
- AddressPermissionArrayIndexValueNotAnAddress,
42
46
  InvalidEncodedAllowedCalls,
43
47
  InvalidEncodedAllowedERC725YDataKeys,
44
48
  NoERC725YDataKeysAllowed,
45
49
  NotAllowedERC725YDataKey,
46
- NotAuthorised
50
+ NotAuthorised,
51
+ KeyManagerCannotBeSetAsExtensionForLSP20Functions,
52
+ InvalidDataValuesForDataKeys
47
53
  } from "../LSP6Errors.sol";
48
54
 
49
55
  abstract contract LSP6SetDataModule {
@@ -222,6 +228,14 @@ abstract contract LSP6SetDataModule {
222
228
  bytes12(inputDataKey) ==
223
229
  _LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX
224
230
  ) {
231
+ // CHECK that `dataValue` contains exactly 32 bytes, which is the required length for a permission BitArray
232
+ if (inputDataValue.length != 32 && inputDataValue.length != 0) {
233
+ revert InvalidDataValuesForDataKeys(
234
+ inputDataKey,
235
+ inputDataValue
236
+ );
237
+ }
238
+
225
239
  // controller already has the permissions needed. Do not run internal function.
226
240
  if (hasBothAddControllerAndEditPermissions) return (bytes32(0));
227
241
 
@@ -280,6 +294,14 @@ abstract contract LSP6SetDataModule {
280
294
  inputDataKey == _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY ||
281
295
  bytes12(inputDataKey) == _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX
282
296
  ) {
297
+ // CHECK that `dataValue` contains exactly 20 bytes, which corresponds to an address for a LSP1 Delegate contract
298
+ if (inputDataValue.length != 20 && inputDataValue.length != 0) {
299
+ revert InvalidDataValuesForDataKeys(
300
+ inputDataKey,
301
+ inputDataValue
302
+ );
303
+ }
304
+
283
305
  // same as above. If controller has both permissions, do not read the `target` storage
284
306
  // to save gas by avoiding an extra external `view` call.
285
307
  if (
@@ -299,6 +321,26 @@ abstract contract LSP6SetDataModule {
299
321
 
300
322
  // LSP17Extension:<bytes4>
301
323
  } else if (bytes12(inputDataKey) == _LSP17_EXTENSION_PREFIX) {
324
+ // CHECK that `dataValue` contains exactly 20 bytes, which corresponds to an address for a LSP17 Extension
325
+ if (inputDataValue.length != 20 && inputDataValue.length != 0) {
326
+ revert InvalidDataValuesForDataKeys(
327
+ inputDataKey,
328
+ inputDataValue
329
+ );
330
+ }
331
+
332
+ // reverts when the address of the Key Manager is being set as extensions for lsp20 functions
333
+ bytes4 selector = bytes4(inputDataKey << 96);
334
+
335
+ if (
336
+ (selector == ILSP20.lsp20VerifyCall.selector ||
337
+ selector == ILSP20.lsp20VerifyCallResult.selector)
338
+ ) {
339
+ if (address(bytes20(inputDataValue)) == address(this)) {
340
+ revert KeyManagerCannotBeSetAsExtensionForLSP20Functions();
341
+ }
342
+ }
343
+
302
344
  // same as above. If controller has both permissions, do not read the `target` storage
303
345
  // to save gas by avoiding an extra external `view` call.
304
346
  if (
@@ -337,6 +379,14 @@ abstract contract LSP6SetDataModule {
337
379
  ) internal view virtual returns (bytes32) {
338
380
  // AddressPermissions[] -> array length
339
381
  if (inputDataKey == _LSP6KEY_ADDRESSPERMISSIONS_ARRAY) {
382
+ // CHECK that `dataValue` is exactly 16 bytes long or `0x` (= not set), as the array length of `AddressPermissions[]` MUST be a `uint128` value.
383
+ if (inputDataValue.length != 16 && inputDataValue.length != 0) {
384
+ revert InvalidDataValuesForDataKeys(
385
+ inputDataKey,
386
+ inputDataValue
387
+ );
388
+ }
389
+
340
390
  // if the controller already has both permissions from one of the two required,
341
391
  // No permission required as CHECK is already done. We don't need to read `target` storage.
342
392
  if (hasBothAddControllerAndEditPermissions) return bytes32(0);
@@ -358,10 +408,7 @@ abstract contract LSP6SetDataModule {
358
408
 
359
409
  // CHECK that we either ADD an address (20 bytes long) or REMOVE an address (0x)
360
410
  if (inputDataValue.length != 0 && inputDataValue.length != 20) {
361
- revert AddressPermissionArrayIndexValueNotAnAddress(
362
- inputDataKey,
363
- inputDataValue
364
- );
411
+ revert InvalidDataValuesForDataKeys(inputDataKey, inputDataValue);
365
412
  }
366
413
 
367
414
  // if the controller already has both permissions from one of the two required below,
@@ -552,13 +599,14 @@ abstract contract LSP6SetDataModule {
552
599
  * The length of a data key is 32 bytes.
553
600
  * Therefore we can have a fixed allowed data key which has
554
601
  * a length of 32 bytes or we can have a dynamic data key
555
- * which can have a length of up to 31 bytes.
602
+ * which can have a length from 1 up to 31 bytes.
556
603
  */
557
- if (length > 32)
604
+ if (length == 0 || length > 32) {
558
605
  revert InvalidEncodedAllowedERC725YDataKeys(
559
606
  allowedERC725YDataKeysCompacted,
560
607
  "couldn't DECODE from storage"
561
608
  );
609
+ }
562
610
 
563
611
  /**
564
612
  * The bitmask discard the last `32 - length` bytes of the input data key via ANDing &
@@ -672,13 +720,14 @@ abstract contract LSP6SetDataModule {
672
720
  * The length of a data key is 32 bytes.
673
721
  * Therefore we can have a fixed allowed data key which has
674
722
  * a length of 32 bytes or we can have a dynamic data key
675
- * which can have a length of up to 31 bytes.
723
+ * which can have a length from 1 up to 31 bytes.
676
724
  */
677
- if (length > 32)
725
+ if (length == 0 || length > 32) {
678
726
  revert InvalidEncodedAllowedERC725YDataKeys(
679
727
  allowedERC725YDataKeysCompacted,
680
728
  "couldn't DECODE from storage"
681
729
  );
730
+ }
682
731
 
683
732
  /**
684
733
  * The bitmask discard the last `32 - length` bytes of the input data key via ANDing &
@@ -13,14 +13,23 @@ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
13
13
  // constants
14
14
  import "./LSP6Constants.sol";
15
15
 
16
+ /**
17
+ * @title LSP6 Utility library.
18
+ * @author Yamen Merhi <YamenMerhi>, Jean Cavallera <CJ42>, Maxime Viard <SkimaHarvey>
19
+ * @dev LSP6Utils is a library of utility functions that can be used to retrieve, check and set LSP6 permissions stored under the ERC725Y storage
20
+ * of a smart contract.
21
+ * Based on the LSP6 Key Manager standard.
22
+ */
16
23
  library LSP6Utils {
17
24
  using LSP2Utils for bytes12;
18
25
 
19
26
  /**
20
- * @dev read the permissions of a `caller` on an ERC725Y `target` contract.
21
- * @param target an `IERC725Y` contract where to read the permissions.
22
- * @param caller the controller address to read the permissions from.
23
- * @return a `bytes32` BitArray containing the permissions of a controller address.
27
+ * @dev Read the permissions of a `caller` on an ERC725Y `target` contract.
28
+ *
29
+ * @param target An `IERC725Y` contract where to read the permissions.
30
+ * @param caller The controller address to read the permissions from.
31
+ *
32
+ * @return A `bytes32` BitArray containing the permissions of a controller address.
24
33
  */
25
34
  function getPermissionsFor(
26
35
  IERC725Y target,
@@ -50,10 +59,12 @@ library LSP6Utils {
50
59
  }
51
60
 
52
61
  /**
53
- * @dev read the Allowed ERC725Y data keys of a `caller` on an ERC725Y `target` contract.
54
- * @param target an `IERC725Y` contract where to read the permissions.
55
- * @param caller the controller address to read the permissions from.
56
- * @return an abi-encoded array of allowed ERC725 keys that the controller address is allowed to interact with.
62
+ * @dev Read the Allowed ERC725Y data keys of a `caller` on an ERC725Y `target` contract.
63
+ *
64
+ * @param target An `IERC725Y` contract where to read the permissions.
65
+ * @param caller The controller address to read the permissions from.
66
+ *
67
+ * @return An abi-encoded array of allowed ERC725 data keys that the controller address is allowed to interact with.
57
68
  */
58
69
  function getAllowedERC725YDataKeysFor(
59
70
  IERC725Y target,
@@ -69,24 +80,26 @@ library LSP6Utils {
69
80
  }
70
81
 
71
82
  /**
72
- * @dev compare the permissions `addressPermissions` of an address
73
- * to check if they includes the permissions `permissionToCheck`
74
- * @param addressPermission the permissions of an address stored on an ERC725 account
75
- * @param permissionToCheck the permissions to check
76
- * @return true if `addressPermissions` includes `permissionToCheck`, false otherwise
83
+ * @dev Compare the permissions `controllerPermissions` of a controller address to check if they includes the permissions `permissionToCheck`.
84
+ *
85
+ * @param controllerPermissions The permissions of an address.
86
+ * @param permissionToCheck The permissions to check if the controller has under its `controllerPermissions`.
87
+ *
88
+ * @return `true` if `controllerPermissions` includes `permissionToCheck`, `false` otherwise.
77
89
  */
78
90
  function hasPermission(
79
- bytes32 addressPermission,
91
+ bytes32 controllerPermissions,
80
92
  bytes32 permissionToCheck
81
93
  ) internal pure returns (bool) {
82
- return (addressPermission & permissionToCheck) == permissionToCheck;
94
+ return (controllerPermissions & permissionToCheck) == permissionToCheck;
83
95
  }
84
96
 
85
97
  /**
86
- * @dev same as LSP2Utils.isCompactBytesArray with the additional requirement that each element must be 28 bytes long.
98
+ * @dev Same as `LSP2Utils.isCompactBytesArray` with the additional requirement that each element must be 32 bytes long.
87
99
  *
88
- * @param allowedCallsCompacted a compact bytes array of tuples (bytes4,address,bytes4) to check.
89
- * @return true if the value passed is a valid compact bytes array of bytes28 elements according to LSP2, false otherwise.
100
+ * @param allowedCallsCompacted A compact bytes array of tuples `(bytes4,address,bytes4,bytes4)` to check (defined as `(bytes4,address,bytes4,bytes4)[CompactBytesArray]` in LSP6).
101
+ *
102
+ * @return `true` if the value passed is a valid compact bytes array of bytes32 AllowedCalls elements, `false` otherwise.
90
103
  */
91
104
  function isCompactBytesArrayOfAllowedCalls(
92
105
  bytes memory allowedCallsCompacted
@@ -112,10 +125,11 @@ library LSP6Utils {
112
125
  }
113
126
 
114
127
  /**
115
- * @dev same as LSP2Utils.isCompactBytesArray with the additional requirement that each element must be from 1 to 32 bytes long.
128
+ * @dev Same as `LSP2Utils.isCompactBytesArray` with the additional requirement that each element must be from 1 to 32 bytes long.
129
+ *
130
+ * @param allowedERC725YDataKeysCompacted a compact bytes array of ERC725Y data Keys (full bytes32 data keys or bytesN prefix) to check (defined as `bytes[CompactBytesArray]`).
116
131
  *
117
- * @param allowedERC725YDataKeysCompacted a compact bytes array of ERC725Y Data Keys (full bytes32 data keys or bytesN prefix) to check.
118
- * @return true if the value passed is a valid compact bytes array of ERC725Y Data Keys, false otherwise.
132
+ * @return `true` if the value passed is a valid compact bytes array of bytes32 Allowed ERC725Y data keys, `false` otherwise.
119
133
  */
120
134
  function isCompactBytesArrayOfAllowedERC725YDataKeys(
121
135
  bytes memory allowedERC725YDataKeysCompacted
@@ -142,10 +156,11 @@ library LSP6Utils {
142
156
  }
143
157
 
144
158
  /**
145
- * @dev use the `setData(bytes32[],bytes[])` via the KeyManager of the target
146
- * @param keyManagerAddress the address of the KeyManager
147
- * @param keys the array of data keys
148
- * @param values the array of data values
159
+ * @dev Use the `setData(bytes32[],bytes[])` function via the KeyManager on the target contract.
160
+ *
161
+ * @param keyManagerAddress The address of the KeyManager.
162
+ * @param keys The array of `bytes32[]` data keys.
163
+ * @param values The array of `bytes[]` data values.
149
164
  */
150
165
  function setDataViaKeyManager(
151
166
  address keyManagerAddress,
@@ -161,35 +176,36 @@ library LSP6Utils {
161
176
  }
162
177
 
163
178
  /**
164
- * @dev combine multiple permissions into a single bytes32
165
- * Make sure that the sum of the values of the input array is less than 2^256-1 to avoid overflow.
166
- * @param permissions the array of permissions to combine
167
- * @return a bytes32 containing the combined permissions
179
+ * @dev Combine multiple permissions into a single `bytes32`.
180
+ * Make sure that the sum of the values of the input array is less than `2^256-1 to avoid overflow.
181
+ *
182
+ * @param permissions The array of permissions to combine.
183
+ * @return A `bytes32` value containing the combined permissions.
168
184
  */
169
185
  function combinePermissions(
170
186
  bytes32[] memory permissions
171
187
  ) internal pure returns (bytes32) {
172
- uint256 result = 0;
188
+ bytes32 result;
173
189
  for (uint256 i = 0; i < permissions.length; i++) {
174
- result += uint256(permissions[i]);
190
+ result |= permissions[i];
175
191
  }
176
- return bytes32(result);
192
+ return result;
177
193
  }
178
194
 
179
195
  /**
180
- * @dev Generate a new set of 3 x LSP6 permission data keys to add a new `controller` on `account`
181
- * @param account the ERC725Y contract to add the controller into (used to fetch the `LSP6Permissions[]` length)
182
- * @param controller the address of the controller to grant permissions to
183
- * @param permissions the BitArray of permissions to grant to the controller
184
- * @return keys an array of 3 x data keys containing:
185
- * - keys[0] = `AddressPermissions[]` (array length)
186
- * - keys[1] = `AddressPermissions[index]` (where to store the controller address)
187
- * - keys[2] = `AddressPermissions:Permissions:<controller>`
196
+ * @dev Generate a new set of 3 x LSP6 permission data keys to add a new `controller` on `account`.
197
+ * @param account The ERC725Y contract to add the controller into (used to fetch the `LSP6Permissions[]` length).
198
+ * @param controller The address of the controller to grant permissions to.
199
+ * @param permissions The `BitArray` of permissions to grant to the controller.
200
+ * @return keys An array of 3 x data keys containing:
201
+ * - `keys[0] = AddressPermissions[]` (array length).
202
+ * - `keys[1] = AddressPermissions[index]` (where to store the controller address).
203
+ * - `keys[2] = AddressPermissions:Permissions:<controller>`.
188
204
  *
189
- * @return values : an array of 3 x data values containing:
190
- * - values[0] = the new array length of `AddressPermissions[]`
191
- * - values[1] = the address of the controller
192
- * - values[2] = the `permissions` passed as param
205
+ * @return values An array of 3 x data values containing:
206
+ * - `values[0] =` the new array length of `AddressPermissions[]`
207
+ * - `values[1] =` the address of the controller
208
+ * - `values[2] =` the `permissions` passed as param
193
209
  */
194
210
  function generateNewPermissionsKeys(
195
211
  IERC725Y account,
@@ -221,11 +237,15 @@ library LSP6Utils {
221
237
  }
222
238
 
223
239
  /**
224
- * @dev returns the name of the permission as a string
240
+ * @dev Returns the name of the permission as a string.
241
+ *
242
+ * @param permission The low-level `bytes32` permission as a `BitArray` to get the permission name from.
243
+ *
244
+ * @return The string name of the `bytes32` permission value.
225
245
  */
226
246
  function getPermissionName(
227
247
  bytes32 permission
228
- ) internal pure returns (string memory errorMessage) {
248
+ ) internal pure returns (string memory) {
229
249
  if (permission == _PERMISSION_CHANGEOWNER) return "TRANSFEROWNERSHIP";
230
250
  if (permission == _PERMISSION_EDITPERMISSIONS) return "EDITPERMISSIONS";
231
251
  if (permission == _PERMISSION_ADDCONTROLLER) return "ADDCONTROLLER";
@@ -244,5 +264,6 @@ library LSP6Utils {
244
264
  if (permission == _PERMISSION_DEPLOY) return "DEPLOY";
245
265
  if (permission == _PERMISSION_TRANSFERVALUE) return "TRANSFERVALUE";
246
266
  if (permission == _PERMISSION_SIGN) return "SIGN";
267
+ return "";
247
268
  }
248
269
  }
@@ -15,14 +15,13 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
15
15
  // --- Events
16
16
 
17
17
  /**
18
- * @dev Emitted when `amount` tokens is transferred from `from` to `to`.
19
- * @param operator The address of operator sending tokens
20
- * @param from The address which tokens are sent
21
- * @param to The receiving address
22
- * @param amount The amount of tokens transferred
23
- * @param allowNonLSP1Recipient When set to TRUE, `to` may be any address but
24
- * when set to FALSE `to` must be a contract that supports LSP1 UniversalReceiver
25
- * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses
18
+ * @dev Emitted when the `from` transferred successfully `amount` of tokens to `to`.
19
+ * @param operator The address of the operator that executed the transfer.
20
+ * @param from The address which tokens were sent from (balance decreased by `-amount`).
21
+ * @param to The address that received the tokens (balance increased by `+amount`).
22
+ * @param amount The amount of tokens transferred.
23
+ * @param allowNonLSP1Recipient if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not.
24
+ * @param data Any additional data included by the caller during the transfer, and sent in the LSP1 hooks to the `from` and `to` addresses.
26
25
  */
27
26
  event Transfer(
28
27
  address indexed operator,
@@ -38,123 +37,164 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
38
37
  * @param operator The address authorized as an operator
39
38
  * @param tokenOwner The token owner
40
39
  * @param amount The amount of tokens `operator` address has access to from `tokenOwner`
40
+ * @param operatorNotificationData The data to notify the operator about via LSP1.
41
41
  */
42
42
  event AuthorizedOperator(
43
43
  address indexed operator,
44
44
  address indexed tokenOwner,
45
- uint256 indexed amount
45
+ uint256 indexed amount,
46
+ bytes operatorNotificationData
46
47
  );
47
48
 
48
49
  /**
49
- * @dev Emitted when `tokenOwner` disables `operator` for `amount` tokens.
50
+ * @dev Emitted when `tokenOwner` disables `operator` for `amount` tokens and set its {`authorizedAmountFor(...)`} to `0`.
50
51
  * @param operator The address revoked from operating
51
52
  * @param tokenOwner The token owner
53
+ * @param operatorNotificationData The data to notify the operator about via LSP1.
52
54
  */
53
- event RevokedOperator(address indexed operator, address indexed tokenOwner);
55
+ event RevokedOperator(
56
+ address indexed operator,
57
+ address indexed tokenOwner,
58
+ bytes operatorNotificationData
59
+ );
54
60
 
55
61
  // --- Token queries
56
62
 
57
63
  /**
58
- * @dev Returns the number of decimals used to get its user representation
59
- * If the contract represents a NFT then 0 SHOULD be used, otherwise 18 is the common value
64
+ * @dev Returns the number of decimals used to get its user representation.
65
+ * If the asset contract has been set to be non-divisible via the `isNonDivisible_` parameter in
66
+ * the `constructor`, the decimals returned wiil be `0`. Otherwise `18` is the common value.
60
67
  *
61
- * NOTE: This information is only used for _display_ purposes: it in
68
+ * @custom:notice This information is only used for _display_ purposes: it in
62
69
  * no way affects any of the arithmetic of the contract, including
63
70
  * {balanceOf} and {transfer}.
71
+ *
72
+ * @return the number of decimals. If `0` is returned, the asset is non-divisible.
64
73
  */
65
74
  function decimals() external view returns (uint8);
66
75
 
67
76
  /**
68
- * @dev Returns the number of existing tokens.
69
- * @return The number of existing tokens
77
+ * @dev Returns the number of existing tokens that have been minted in this contract.
78
+ * @return The number of existing tokens.
70
79
  */
71
80
  function totalSupply() external view returns (uint256);
72
81
 
73
82
  // --- Token owner queries
74
83
 
75
84
  /**
76
- * @dev Returns the number of tokens owned by `tokenOwner`.
77
- * @param tokenOwner The address to query
78
- * @return The number of tokens owned by this address
85
+ * @dev Get the number of tokens owned by `tokenOwner`.
86
+ * If the token is divisible (the {decimals} function returns `18`), the amount returned should be divided
87
+ * by 1e18 to get a better picture of the actual balance of the `tokenOwner`.
88
+ *
89
+ * _Example:_
90
+ *
91
+ * ```
92
+ * balanceOf(someAddress) -> 42_000_000_000_000_000_000 / 1e18 = 42 tokens
93
+ * ```
94
+ *
95
+ * @param tokenOwner The address of the token holder to query the balance for.
96
+ * @return The amount of tokens owned by `tokenOwner`.
79
97
  */
80
98
  function balanceOf(address tokenOwner) external view returns (uint256);
81
99
 
82
100
  // --- Operator functionality
83
101
 
84
102
  /**
85
- * @param operator The address to authorize as an operator.
86
- * @param amount The amount of tokens operator has access to.
87
- * @dev Sets `amount` as the amount of tokens `operator` address has access to from callers tokens.
88
- *
89
- * To avoid front-running and Allowance Double-Spend Exploit when
90
- * increasing or decreasing the authorized amount of an operator,
91
- * it is advised to:
92
- * 1. call {revokeOperator} first, and
93
- * 2. then re-call {authorizeOperator} with the new amount
103
+ * @dev Sets an `amount` of tokens that an `operator` has access from the caller's balance (allowance). See {authorizedAmountFor}.
94
104
  *
95
- * for more information, see:
96
- * https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/
97
- *
98
- *
99
- * See {authorizedAmountFor}.
100
- *
101
- * Requirements
105
+ * @param operator The address to authorize as an operator.
106
+ * @param amount The allowance amount of tokens operator has access to.
107
+ * @param operatorNotificationData The data to notify the operator about via LSP1.
102
108
  *
109
+ * @custom:requirements
103
110
  * - `operator` cannot be the zero address.
104
111
  *
105
- * Emits an {AuthorizedOperator} event.
112
+ * @custom:events {AuthorizedOperator} when allowance is given to a new operator or
113
+ * an existing operator's allowance is updated.
106
114
  */
107
- function authorizeOperator(address operator, uint256 amount) external;
115
+ function authorizeOperator(
116
+ address operator,
117
+ uint256 amount,
118
+ bytes memory operatorNotificationData
119
+ ) external;
108
120
 
109
121
  /**
110
- * @param operator The address to revoke as an operator.
111
- * @dev Removes `operator` address as an operator of callers tokens.
112
- *
113
- * See {authorizedAmountFor}.
122
+ * @dev Removes the `operator` address as an operator of callers tokens, disallowing it to send any amount of tokens
123
+ * on behalf of the token owner (the caller of the function `msg.sender`). See also {authorizedAmountFor}.
114
124
  *
115
- * Requirements
125
+ * @param operator The address to revoke as an operator.
126
+ * @param operatorNotificationData The data to notify the operator about via LSP1.
116
127
  *
128
+ * @custom:requirements
129
+ * - `operator` cannot be calling address.
117
130
  * - `operator` cannot be the zero address.
118
131
  *
119
- * Emits a {RevokedOperator} event.
132
+ * @custom:events {RevokedOperator} event with address of the operator being revoked for the caller (token holder).
120
133
  */
121
- function revokeOperator(address operator) external;
134
+ function revokeOperator(
135
+ address operator,
136
+ bytes memory operatorNotificationData
137
+ ) external;
122
138
 
123
139
  /**
124
- * @param operator The address to query operator status for.
125
- * @param tokenOwner The token owner.
126
- * @return The amount of tokens `operator` address has access to from `tokenOwner`.
127
- * @dev Returns amount of tokens `operator` address has access to from `tokenOwner`.
128
- * Operators can send and burn tokens on behalf of their owners. The tokenOwner is their own
129
- * operator.
140
+ * @dev Get the amount of tokens `operator` address has access to from `tokenOwner`.
141
+ * Operators can send and burn tokens on behalf of their owners.
142
+ *
143
+ * @param operator The operator's address to query the authorized amount for.
144
+ * @param tokenOwner The token owner that `operator` has allowance on.
145
+ *
146
+ * @return The amount of tokens the `operator`'s address has access on the `tokenOwner`'s balance.
147
+ *
148
+ * @custom:info If this function is called with the same address for `operator` and `tokenOwner`, it will simply read the `tokenOwner`'s balance
149
+ * (since a tokenOwner is its own operator).
130
150
  */
131
151
  function authorizedAmountFor(
132
152
  address operator,
133
153
  address tokenOwner
134
154
  ) external view returns (uint256);
135
155
 
156
+ /**
157
+ * @dev Returns all `operator` addresses that are allowed to transfer or burn on behalf of `tokenOwner`.
158
+ *
159
+ * @param tokenOwner The token owner to get the operators for.
160
+ * @return An array of operators allowed to transfer or burn tokens on behalf of `tokenOwner`.
161
+ */
162
+ function getOperatorsOf(
163
+ address tokenOwner
164
+ ) external view returns (address[] memory);
165
+
136
166
  // --- Transfer functionality
137
167
 
138
168
  /**
139
- * @param from The sending address.
140
- * @param to The receiving address.
141
- * @param amount The amount of tokens to transfer.
142
- * @param allowNonLSP1Recipient When set to TRUE, to may be any address but
143
- * when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
144
- * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
169
+ * @dev Transfers an `amount` of tokens from the `from` address to the `to` address and notify both sender and recipients via the LSP1 {`universalReceiver(...)`} function.
170
+ * If the tokens are transferred by an operator on behalf of a token holder, the allowance for the operator will be decreased by `amount` once the token transfer
171
+ * has been completed (See {authorizedAmountFor}).
145
172
  *
146
- * @dev Transfers `amount` of tokens from `from` to `to`. The `allowNonLSP1Recipient` parameter will be used
147
- * when notifying the token sender and receiver.
148
- *
149
- * Requirements:
173
+ * @param from The sender address.
174
+ * @param to The recipient address.
175
+ * @param amount The amount of tokens to transfer.
176
+ * @param allowNonLSP1Recipient When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard.
177
+ * @param data Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses.
150
178
  *
179
+ * @custom:requirements
151
180
  * - `from` cannot be the zero address.
152
181
  * - `to` cannot be the zero address.
153
- * - `amount` tokens must be owned by `from`.
154
- * - If the caller is not `from`, it must be an operator for `from` with access to at least
155
- * `amount` tokens.
182
+ * - `from` and `to` cannot be the same address (`from` cannot send tokens to itself).
183
+ * - `from` MUST have a balance of at least `amount` tokens.
184
+ * - If the caller is not `from`, it must be an operator for `from` with an allowance of at least `amount` of tokens.
156
185
  *
157
- * Emits a {Transfer} event.
186
+ * @custom:events
187
+ * - {Transfer} event when tokens get successfully transferred.
188
+ * - if the transfer is triggered by an operator, either the {AuthorizedOperator} event will be emitted with the updated allowance or the {RevokedOperator}
189
+ * event will be emitted if the operator has no more allowance left.
190
+ *
191
+ * @custom:hint The `allowNonLSP1Recipient` parameter **MUST be set to `true`** to transfer tokens to Externally Owned Accounts (EOAs)
192
+ * or contracts that do not implement the LSP1 Universal Receiver Standard. Otherwise the function will revert making the transfer fail.
193
+ *
194
+ * @custom:info if the `to` address is a contract that implements LSP1, it will always be notified via its `universalReceiver(...)` function, regardless if `allowNonLSP1Recipient` is set to `true` or `false`.
195
+ *
196
+ * @custom:warning Be aware that when either the sender or the recipient can have logic that revert in their `universalReceiver(...)` function when being notified.
197
+ * This even if the `allowNonLSP1Recipient` was set to `true`.
158
198
  */
159
199
  function transfer(
160
200
  address from,
@@ -165,26 +205,24 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
165
205
  ) external;
166
206
 
167
207
  /**
168
- * @param from The list of sending addresses.
169
- * @param to The list of receiving addresses.
170
- * @param amount The amount of tokens to transfer.
171
- * @param allowNonLSP1Recipient When set to TRUE, to may be any address but
172
- * when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
173
- * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
208
+ * @dev Same as {`transfer(...)`} but transfer multiple tokens based on the arrays of `from`, `to`, `amount`.
174
209
  *
175
- * @dev Transfers many tokens based on the list `from`, `to`, `amount`. If any transfer fails
176
- * the call will revert.
210
+ * @custom:info If any transfer in the batch fail or revert, the whole call will revert.
177
211
  *
178
- * Requirements:
212
+ * @param from An array of sending addresses.
213
+ * @param to An array of receiving addresses.
214
+ * @param amount An array of amount of tokens to transfer for each `from -> to` transfer.
215
+ * @param allowNonLSP1Recipient For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard.
216
+ * @param data An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
179
217
  *
180
- * - `from`, `to`, `amount` lists are the same length.
218
+ * @custom:requirements
219
+ * - `from`, `to`, `amount` lists MUST be of the same length.
181
220
  * - no values in `from` can be the zero address.
182
221
  * - no values in `to` can be the zero address.
183
- * - each `amount` tokens must be owned by `from`.
184
- * - If the caller is not `from`, it must be an operator for `from` with access to at least
185
- * `amount` tokens.
222
+ * - each `amount` tokens MUST be owned by `from`.
223
+ * - for each transfer, if the caller is not `from`, it MUST be an operator for `from` with access to at least `amount` tokens.
186
224
  *
187
- * Emits {Transfer} events.
225
+ * @custom:events {Transfer} event **for each token transfer**.
188
226
  */
189
227
  function transferBatch(
190
228
  address[] memory from,
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_LSP7 = 0xda1f85e4;
5
+ bytes4 constant _INTERFACEID_LSP7 = 0x05519512;
6
6
 
7
7
  // --- Token Hooks
8
8
 
@@ -11,3 +11,6 @@ bytes32 constant _TYPEID_LSP7_TOKENSSENDER = 0x429ac7a06903dbc9c13dfcb3c9d11df81
11
11
 
12
12
  // keccak256('LSP7Tokens_RecipientNotification')
13
13
  bytes32 constant _TYPEID_LSP7_TOKENSRECIPIENT = 0x20804611b3e2ea21c480dc465142210acf4a2485947541770ec1fb87dee4a55c;
14
+
15
+ // keccak256('LSP7Tokens_OperatorNotification')
16
+ bytes32 constant _TYPEID_LSP7_TOKENOPERATOR = 0x386072cc5a58e61263b434c722725f21031cd06e7c552cfaa06db5de8a320dbc;