@lukso/lsp-smart-contracts 0.10.1 → 0.10.2

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 (124) hide show
  1. package/README.md +0 -1
  2. package/artifacts/Create2Factory.json +2 -2
  3. package/artifacts/LSP0ERC725Account.json +3 -3
  4. package/artifacts/LSP0ERC725AccountInit.json +3 -3
  5. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  6. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  7. package/artifacts/LSP16UniversalFactory.json +2 -2
  8. package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
  9. package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
  10. package/artifacts/LSP6KeyManager.json +2 -2
  11. package/artifacts/LSP6KeyManagerInit.json +2 -2
  12. package/artifacts/LSP7CompatibleERC20Mintable.json +2 -2
  13. package/artifacts/LSP7CompatibleERC20MintableInit.json +2 -2
  14. package/artifacts/LSP7Mintable.json +2 -2
  15. package/artifacts/LSP7MintableInit.json +2 -2
  16. package/artifacts/LSP8CompatibleERC721Mintable.json +2 -2
  17. package/artifacts/LSP8CompatibleERC721MintableInit.json +2 -2
  18. package/artifacts/LSP8Mintable.json +2 -2
  19. package/artifacts/LSP8MintableInit.json +2 -2
  20. package/artifacts/LSP9Vault.json +2 -2
  21. package/artifacts/LSP9VaultInit.json +2 -2
  22. package/artifacts/UniversalProfile.json +3 -3
  23. package/artifacts/UniversalProfileInit.json +3 -3
  24. package/artifacts/UniversalReceiverAddressStore.json +2 -2
  25. package/contracts/Factories/Create2Factory.sol +11 -3
  26. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +13 -5
  27. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +5 -5
  28. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +256 -186
  29. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +6 -2
  30. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +13 -4
  31. package/contracts/LSP0ERC725Account/LSP0Utils.sol +3 -5
  32. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +25 -10
  33. package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +4 -2
  34. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +3 -1
  35. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +65 -23
  36. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +7 -2
  37. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +14 -4
  38. package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +4 -1
  39. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +17 -16
  40. package/contracts/LSP14Ownable2Step/LSP14Errors.sol +4 -1
  41. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +22 -11
  42. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +85 -27
  43. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +38 -16
  44. package/contracts/LSP17ContractExtension/LSP17Extension.sol +20 -8
  45. package/contracts/LSP17ContractExtension/LSP17Utils.sol +4 -5
  46. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
  47. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +38 -14
  48. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +31 -11
  49. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +34 -9
  50. package/contracts/LSP20CallVerification/{ILSP20CallVerification.sol → ILSP20CallVerifier.sol} +7 -2
  51. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +24 -9
  52. package/contracts/LSP20CallVerification/LSP20Errors.sol +1 -1
  53. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +62 -36
  54. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +3 -1
  55. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +15 -4
  56. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +18 -5
  57. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +32 -12
  58. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +17 -8
  59. package/contracts/LSP6KeyManager/LSP6Constants.sol +3 -9
  60. package/contracts/LSP6KeyManager/LSP6Errors.sol +4 -1
  61. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +114 -72
  62. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +7 -2
  63. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +96 -46
  64. package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +10 -5
  65. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +98 -32
  66. package/contracts/LSP6KeyManager/LSP6Utils.sol +42 -34
  67. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +8 -6
  68. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +13 -10
  69. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +96 -26
  70. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +11 -9
  71. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +8 -2
  72. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +9 -2
  73. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +1 -5
  74. package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -6
  75. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +6 -2
  76. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +32 -12
  77. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +28 -7
  78. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +8 -2
  79. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +6 -2
  80. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +6 -1
  81. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +13 -3
  82. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +14 -5
  83. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +3 -1
  84. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +12 -10
  85. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +95 -28
  86. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +14 -10
  87. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +23 -10
  88. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +3 -1
  89. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +3 -1
  90. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +6 -2
  91. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +72 -30
  92. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +77 -27
  93. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +6 -2
  94. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +6 -2
  95. package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -1
  96. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +8 -2
  97. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +6 -2
  98. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +3 -1
  99. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +5 -1
  100. package/contracts/LSP9Vault/ILSP9Vault.sol +13 -5
  101. package/contracts/LSP9Vault/LSP9Vault.sol +7 -2
  102. package/contracts/LSP9Vault/LSP9VaultCore.sol +108 -51
  103. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +10 -3
  104. package/contracts/Legacy/Registries/AddressRegistry.sol +13 -4
  105. package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +6 -2
  106. package/contracts/Legacy/UniversalReceiverAddressStore.sol +17 -6
  107. package/contracts/UniversalProfile.sol +4 -1
  108. package/contracts/UniversalProfileInit.sol +3 -1
  109. package/contracts/UniversalProfileInitAbstract.sol +13 -4
  110. package/devdocs/LSP0ERC725Account.json +33 -19
  111. package/devdocs/LSP0ERC725AccountInit.json +30 -17
  112. package/devdocs/LSP9Vault.json +3 -3
  113. package/devdocs/LSP9VaultInit.json +3 -3
  114. package/devdocs/UniversalProfile.json +30 -17
  115. package/devdocs/UniversalProfileInit.json +30 -17
  116. package/dist/constants.cjs.js +142 -102
  117. package/dist/constants.d.ts +62 -10
  118. package/dist/constants.es.js +142 -102
  119. package/package.json +17 -16
  120. package/userdocs/LSP0ERC725Account.json +2 -2
  121. package/userdocs/LSP0ERC725AccountInit.json +2 -2
  122. package/userdocs/UniversalProfile.json +2 -2
  123. package/userdocs/UniversalProfileInit.json +2 -2
  124. package/contracts/Custom/EIP191Signer.sol +0 -12
@@ -99,15 +99,23 @@ contract LSP16UniversalFactory {
99
99
  *
100
100
  * @return The address of the deployed contract
101
101
  */
102
- function deployCreate2(bytes calldata byteCode, bytes32 providedSalt)
103
- public
104
- payable
105
- virtual
106
- returns (address)
107
- {
102
+ function deployCreate2(
103
+ bytes calldata byteCode,
104
+ bytes32 providedSalt
105
+ ) public payable virtual returns (address) {
108
106
  bytes32 generatedSalt = generateSalt(providedSalt, false, _EMPTY_BYTE);
109
- address contractCreated = Create2.deploy(msg.value, generatedSalt, byteCode);
110
- emit ContractCreated(contractCreated, providedSalt, generatedSalt, false, _EMPTY_BYTE);
107
+ address contractCreated = Create2.deploy(
108
+ msg.value,
109
+ generatedSalt,
110
+ byteCode
111
+ );
112
+ emit ContractCreated(
113
+ contractCreated,
114
+ providedSalt,
115
+ generatedSalt,
116
+ false,
117
+ _EMPTY_BYTE
118
+ );
111
119
 
112
120
  return contractCreated;
113
121
  }
@@ -148,10 +156,19 @@ contract LSP16UniversalFactory {
148
156
  uint256 constructorMsgValue,
149
157
  uint256 initializeCalldataMsgValue
150
158
  ) public payable virtual returns (address) {
151
- if (constructorMsgValue + initializeCalldataMsgValue != msg.value) revert InvalidValueSum();
159
+ if (constructorMsgValue + initializeCalldataMsgValue != msg.value)
160
+ revert InvalidValueSum();
152
161
 
153
- bytes32 generatedSalt = generateSalt(providedSalt, true, initializeCalldata);
154
- address contractCreated = Create2.deploy(constructorMsgValue, generatedSalt, byteCode);
162
+ bytes32 generatedSalt = generateSalt(
163
+ providedSalt,
164
+ true,
165
+ initializeCalldata
166
+ );
167
+ address contractCreated = Create2.deploy(
168
+ constructorMsgValue,
169
+ generatedSalt,
170
+ byteCode
171
+ );
155
172
  emit ContractCreated(
156
173
  contractCreated,
157
174
  providedSalt,
@@ -190,15 +207,23 @@ contract LSP16UniversalFactory {
190
207
  *
191
208
  * @return The address of the minimal proxy deployed
192
209
  */
193
- function deployERC1167Proxy(address implementationContract, bytes32 providedSalt)
194
- public
195
- virtual
196
- returns (address)
197
- {
210
+ function deployERC1167Proxy(
211
+ address implementationContract,
212
+ bytes32 providedSalt
213
+ ) public virtual returns (address) {
198
214
  bytes32 generatedSalt = generateSalt(providedSalt, false, _EMPTY_BYTE);
199
215
 
200
- address proxy = Clones.cloneDeterministic(implementationContract, generatedSalt);
201
- emit ContractCreated(proxy, providedSalt, generatedSalt, false, _EMPTY_BYTE);
216
+ address proxy = Clones.cloneDeterministic(
217
+ implementationContract,
218
+ generatedSalt
219
+ );
220
+ emit ContractCreated(
221
+ proxy,
222
+ providedSalt,
223
+ generatedSalt,
224
+ false,
225
+ _EMPTY_BYTE
226
+ );
202
227
 
203
228
  return proxy;
204
229
  }
@@ -232,12 +257,27 @@ contract LSP16UniversalFactory {
232
257
  bytes32 providedSalt,
233
258
  bytes calldata initializeCalldata
234
259
  ) public payable virtual returns (address) {
235
- bytes32 generatedSalt = generateSalt(providedSalt, true, initializeCalldata);
260
+ bytes32 generatedSalt = generateSalt(
261
+ providedSalt,
262
+ true,
263
+ initializeCalldata
264
+ );
236
265
 
237
- address proxy = Clones.cloneDeterministic(implementationContract, generatedSalt);
238
- emit ContractCreated(proxy, providedSalt, generatedSalt, true, initializeCalldata);
266
+ address proxy = Clones.cloneDeterministic(
267
+ implementationContract,
268
+ generatedSalt
269
+ );
270
+ emit ContractCreated(
271
+ proxy,
272
+ providedSalt,
273
+ generatedSalt,
274
+ true,
275
+ initializeCalldata
276
+ );
239
277
 
240
- (bool success, bytes memory returndata) = proxy.call{value: msg.value}(initializeCalldata);
278
+ (bool success, bytes memory returndata) = proxy.call{value: msg.value}(
279
+ initializeCalldata
280
+ );
241
281
  _verifyCallResult(success, returndata);
242
282
 
243
283
  return proxy;
@@ -263,7 +303,11 @@ contract LSP16UniversalFactory {
263
303
  bool initializable,
264
304
  bytes calldata initializeCalldata
265
305
  ) public view virtual returns (address) {
266
- bytes32 generatedSalt = generateSalt(providedSalt, initializable, initializeCalldata);
306
+ bytes32 generatedSalt = generateSalt(
307
+ providedSalt,
308
+ initializable,
309
+ initializeCalldata
310
+ );
267
311
  return Create2.computeAddress(generatedSalt, byteCodeHash);
268
312
  }
269
313
 
@@ -287,8 +331,16 @@ contract LSP16UniversalFactory {
287
331
  bool initializable,
288
332
  bytes calldata initializeCalldata
289
333
  ) public view virtual returns (address) {
290
- bytes32 generatedSalt = generateSalt(providedSalt, initializable, initializeCalldata);
291
- return Clones.predictDeterministicAddress(implementationContract, generatedSalt);
334
+ bytes32 generatedSalt = generateSalt(
335
+ providedSalt,
336
+ initializable,
337
+ initializeCalldata
338
+ );
339
+ return
340
+ Clones.predictDeterministicAddress(
341
+ implementationContract,
342
+ generatedSalt
343
+ );
292
344
  }
293
345
 
294
346
  /**
@@ -364,7 +416,10 @@ contract LSP16UniversalFactory {
364
416
  bytes memory initializeCalldata
365
417
  ) public pure virtual returns (bytes32) {
366
418
  if (initializable) {
367
- return keccak256(abi.encodePacked(true, initializeCalldata, providedSalt));
419
+ return
420
+ keccak256(
421
+ abi.encodePacked(true, initializeCalldata, providedSalt)
422
+ );
368
423
  } else {
369
424
  return keccak256(abi.encodePacked(false, providedSalt));
370
425
  }
@@ -374,7 +429,10 @@ contract LSP16UniversalFactory {
374
429
  * @dev Verifies that the contract created was initialized correctly.
375
430
  * Bubble the revert reason if present, revert with `ContractInitializationFailed` otherwise.
376
431
  */
377
- function _verifyCallResult(bool success, bytes memory returndata) internal pure virtual {
432
+ function _verifyCallResult(
433
+ bool success,
434
+ bytes memory returndata
435
+ ) internal pure virtual {
378
436
  if (!success) {
379
437
  // Look for revert reason and bubble it up if present
380
438
  if (returndata.length != 0) {
@@ -3,7 +3,9 @@ pragma solidity ^0.8.4;
3
3
 
4
4
  // modules
5
5
  import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
6
- import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
6
+ import {
7
+ ERC165Checker
8
+ } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
7
9
 
8
10
  // constants
9
11
  import {_INTERFACEID_LSP17_EXTENDABLE} from "./LSP17Constants.sol";
@@ -12,8 +14,10 @@ import {_INTERFACEID_LSP17_EXTENDABLE} from "./LSP17Constants.sol";
12
14
  import "./LSP17Errors.sol";
13
15
 
14
16
  /**
15
- * @title Implementation of the fallback logic according to LSP17ContractExtension
16
- * @dev Module to be inherited used to extend the functionality of the parent contract when
17
+ * @title Module to add more functionalities to a contract using extensions.
18
+ *
19
+ * @dev Implementation of the `fallback(...)` logic according to LSP17 - Contract Extension standard.
20
+ * This module can be inherited to extend the functionality of the parent contract when
17
21
  * calling a function that doesn't exist on the parent contract via forwarding the call
18
22
  * to an extension mapped to the function selector being called, set originally by the parent contract
19
23
  */
@@ -21,8 +25,12 @@ abstract contract LSP17Extendable is ERC165 {
21
25
  /**
22
26
  * @dev See {IERC165-supportsInterface}.
23
27
  */
24
- function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
25
- return interfaceId == _INTERFACEID_LSP17_EXTENDABLE || super.supportsInterface(interfaceId);
28
+ function supportsInterface(
29
+ bytes4 interfaceId
30
+ ) public view virtual override returns (bool) {
31
+ return
32
+ interfaceId == _INTERFACEID_LSP17_EXTENDABLE ||
33
+ super.supportsInterface(interfaceId);
26
34
  }
27
35
 
28
36
  /**
@@ -33,16 +41,19 @@ abstract contract LSP17Extendable is ERC165 {
33
41
  * supported by reading whether the interfaceId queried is supported in the `supportsInterface`
34
42
  * extension if the extension is set, if not it returns false.
35
43
  */
36
- function _supportsInterfaceInERC165Extension(bytes4 interfaceId)
37
- internal
38
- view
39
- virtual
40
- returns (bool)
41
- {
42
- address erc165Extension = _getExtension(ERC165.supportsInterface.selector);
44
+ function _supportsInterfaceInERC165Extension(
45
+ bytes4 interfaceId
46
+ ) internal view virtual returns (bool) {
47
+ address erc165Extension = _getExtension(
48
+ ERC165.supportsInterface.selector
49
+ );
43
50
  if (erc165Extension == address(0)) return false;
44
51
 
45
- return ERC165Checker.supportsERC165InterfaceUnchecked(erc165Extension, interfaceId);
52
+ return
53
+ ERC165Checker.supportsERC165InterfaceUnchecked(
54
+ erc165Extension,
55
+ interfaceId
56
+ );
46
57
  }
47
58
 
48
59
  /**
@@ -51,7 +62,9 @@ abstract contract LSP17Extendable is ERC165 {
51
62
  * To be overrided.
52
63
  * Up to the implementor contract to return an extension based on a function selector
53
64
  */
54
- function _getExtension(bytes4 functionSelector) internal view virtual returns (address);
65
+ function _getExtension(
66
+ bytes4 functionSelector
67
+ ) internal view virtual returns (address);
55
68
 
56
69
  /**
57
70
  * @dev Forwards the call to an extension mapped to a function selector.
@@ -75,7 +88,8 @@ abstract contract LSP17Extendable is ERC165 {
75
88
  address extension = _getExtension(msg.sig);
76
89
 
77
90
  // if no extension was found, revert
78
- if (extension == address(0)) revert NoExtensionFoundForFunctionSelector(msg.sig);
91
+ if (extension == address(0))
92
+ revert NoExtensionFoundForFunctionSelector(msg.sig);
79
93
 
80
94
  // solhint-disable no-inline-assembly
81
95
  // if the extension was found, call the extension with the msg.data
@@ -91,7 +105,15 @@ abstract contract LSP17Extendable is ERC165 {
91
105
  mstore(add(calldatasize(), 20), callvalue())
92
106
 
93
107
  // Add 52 bytes for the msg.sender and msg.value appended at the end of the calldata
94
- let success := call(gas(), extension, 0, 0, add(calldatasize(), 52), 0, 0)
108
+ let success := call(
109
+ gas(),
110
+ extension,
111
+ 0,
112
+ 0,
113
+ add(calldatasize(), 52),
114
+ 0,
115
+ 0
116
+ )
95
117
 
96
118
  // Copy the returned data
97
119
  returndatacopy(0, 0, returndatasize())
@@ -8,24 +8,33 @@ import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
8
8
  import {_INTERFACEID_LSP17_EXTENSION} from "./LSP17Constants.sol";
9
9
 
10
10
  /**
11
- * @title Implementation of the extension logic according to LSP17ContractExtension
12
- * @dev To be inherited to provide context of the msg variable related to the extendable contract
11
+ * @title Module to create a contract that can act as an extension.
12
+ *
13
+ * @dev Implementation of the extension logic according to LSP17ContractExtension.
14
+ * This module can be inherited to provide context of the msg variable related to the extendable contract
13
15
  */
14
16
  abstract contract LSP17Extension is ERC165 {
15
- // solhint-disable
16
-
17
17
  /**
18
18
  * @dev See {IERC165-supportsInterface}.
19
19
  */
20
- function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
21
- return interfaceId == _INTERFACEID_LSP17_EXTENSION || super.supportsInterface(interfaceId);
20
+ function supportsInterface(
21
+ bytes4 interfaceId
22
+ ) public view virtual override returns (bool) {
23
+ return
24
+ interfaceId == _INTERFACEID_LSP17_EXTENSION ||
25
+ super.supportsInterface(interfaceId);
22
26
  }
23
27
 
24
28
  /**
25
29
  * @dev Returns the original msg.data passed to the extendable contract
26
30
  * without the appended msg.sender and msg.value
27
31
  */
28
- function _extendableMsgData() internal view virtual returns (bytes calldata) {
32
+ function _extendableMsgData()
33
+ internal
34
+ view
35
+ virtual
36
+ returns (bytes calldata)
37
+ {
29
38
  return msg.data[:msg.data.length - 52];
30
39
  }
31
40
 
@@ -33,7 +42,10 @@ abstract contract LSP17Extension is ERC165 {
33
42
  * @dev Returns the original msg.sender calling the extendable contract
34
43
  */
35
44
  function _extendableMsgSender() internal view virtual returns (address) {
36
- return address(bytes20(msg.data[msg.data.length - 52:msg.data.length - 32]));
45
+ return
46
+ address(
47
+ bytes20(msg.data[msg.data.length - 52:msg.data.length - 32])
48
+ );
37
49
  }
38
50
 
39
51
  /**
@@ -10,11 +10,10 @@ library LSP17Utils {
10
10
  * the parametersLength with offset with an additional of 52 bytes supposed msg.sender
11
11
  * and msg.value appended is equal to the msgDataLength
12
12
  */
13
- function isExtension(uint256 parametersLengthWithOffset, uint256 msgDataLength)
14
- internal
15
- pure
16
- returns (bool)
17
- {
13
+ function isExtension(
14
+ uint256 parametersLengthWithOffset,
15
+ uint256 msgDataLength
16
+ ) internal pure returns (bool) {
18
17
  return (parametersLengthWithOffset + 52) == msgDataLength;
19
18
  }
20
19
  }
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  /**
5
- * @title The interface for LSP1UniversalReceiver
5
+ * @title Interface of the LSP1 - Universal Receiver standard, an entry function for a contract to receive arbitrary information.
6
6
  * @dev LSP1UniversalReceiver allows to receive arbitrary messages and to be informed when assets are sent or received
7
7
  */
8
8
  interface ILSP1UniversalReceiver {
@@ -29,8 +29,8 @@ interface ILSP1UniversalReceiver {
29
29
  *
30
30
  * Emits a {UniversalReceiver} event
31
31
  */
32
- function universalReceiver(bytes32 typeId, bytes calldata data)
33
- external
34
- payable
35
- returns (bytes memory);
32
+ function universalReceiver(
33
+ bytes32 typeId,
34
+ bytes calldata data
35
+ ) external payable returns (bytes memory);
36
36
  }
@@ -2,7 +2,9 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  // interfaces
5
- import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
5
+ import {
6
+ IERC725Y
7
+ } from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
8
  import {ILSP1UniversalReceiver} from "../ILSP1UniversalReceiver.sol";
7
9
  import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
8
10
 
@@ -10,7 +12,9 @@ import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
10
12
  import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
11
13
 
12
14
  // libraries
13
- import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
15
+ import {
16
+ ERC165Checker
17
+ } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
14
18
  import {LSP1Utils} from "../LSP1Utils.sol";
15
19
  import {LSP2Utils} from "../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
16
20
  import {LSP5Utils} from "../../LSP5ReceivedAssets/LSP5Utils.sol";
@@ -83,8 +87,12 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
83
87
  address notifier = address(bytes20(msg.data[msg.data.length - 52:]));
84
88
 
85
89
  // Get the supposed mapPrefix and interfaceId based on the typeID
86
- (bool invalid, bytes10 mapPrefix, bytes4 interfaceID, bool isReceiving) = LSP1Utils
87
- .getTransferDetails(typeId);
90
+ (
91
+ bool invalid,
92
+ bytes10 mapPrefix,
93
+ bytes4 interfaceID,
94
+ bool isReceiving
95
+ ) = LSP1Utils.getTransferDetails(typeId);
88
96
 
89
97
  // If it's a typeId different than LSP7/LSP8/LSP9 typeIds
90
98
  if (invalid) return "LSP1: typeId out of scope";
@@ -95,19 +103,26 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
95
103
  if (notifier == tx.origin) revert CannotRegisterEOAsAsAssets(notifier);
96
104
 
97
105
  // Generate the LSP5ReceivedAssetsMap/LSP10VaultsMap based on the prefix and the notifier
98
- bytes32 notifierMapKey = LSP2Utils.generateMappingKey(mapPrefix, bytes20(notifier));
106
+ bytes32 notifierMapKey = LSP2Utils.generateMappingKey(
107
+ mapPrefix,
108
+ bytes20(notifier)
109
+ );
99
110
 
100
111
  // Query the ERC725Y storage of the LSP0-ERC725Account
101
- bytes memory notifierMapValue = IERC725Y(msg.sender).getData(notifierMapKey);
112
+ bytes memory notifierMapValue = IERC725Y(msg.sender).getData(
113
+ notifierMapKey
114
+ );
102
115
 
103
116
  bool isMapValueSet = bytes20(notifierMapValue) != bytes20(0);
104
117
 
105
118
  if (isReceiving) {
106
119
  // If the mapValue is set, we assume that all other data keys relevant to the asset/vault
107
120
  // are registered in the account, we don't need to re register the asset being received
108
- if (isMapValueSet) return "LSP1: asset received is already registered";
121
+ if (isMapValueSet)
122
+ return "LSP1: asset received is already registered";
109
123
 
110
- return _whenReceiving(typeId, notifier, notifierMapKey, interfaceID);
124
+ return
125
+ _whenReceiving(typeId, notifier, notifierMapKey, interfaceID);
111
126
  } else {
112
127
  // If the mapValue is not set, we assume that all other data keys relevant to the asset/vault
113
128
  // are not registered in the account, we cannot remove non-existing data keys for the asset being sent
@@ -115,7 +130,8 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
115
130
 
116
131
  // if the value under the `LSP5ReceivedAssetsMap:<asset-address>` or `LSP10VaultsMap:<vault-address>`
117
132
  // is not a valid tuple as `(bytes4,uint128)`
118
- if (notifierMapValue.length < 20) return "LSP1: asset data corrupted";
133
+ if (notifierMapValue.length < 20)
134
+ return "LSP1: asset data corrupted";
119
135
 
120
136
  // Identify where the asset/vault is located in the `LSP5ReceivedAssets[]` / `LSP10Vaults[]` Array
121
137
  // by extracting the index from the tuple value `(bytes4,uint128)`
@@ -148,7 +164,9 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
148
164
  // not when tokens are being transferred on deployment through the `constructor`
149
165
  if (notifier.code.length > 0) {
150
166
  // if the amount sent is 0, then do not update the keys
151
- uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(msg.sender);
167
+ uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(
168
+ msg.sender
169
+ );
152
170
  if (balance == 0) return "LSP1: balance not updated";
153
171
  }
154
172
 
@@ -206,7 +224,8 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
206
224
  * - the index returned from the data key `notifierMapKey` is bigger than
207
225
  * the length of the `LSP5ReceivedAssets[]`, meaning, index is out of bounds.
208
226
  */
209
- if (dataKeys.length == 0 && dataValues.length == 0) return "LSP1: asset data corrupted";
227
+ if (dataKeys.length == 0 && dataValues.length == 0)
228
+ return "LSP1: asset data corrupted";
210
229
 
211
230
  // Set the LSP5 generated data keys on the account
212
231
  IERC725Y(msg.sender).setDataBatch(dataKeys, dataValues);
@@ -223,7 +242,8 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
223
242
  * - the index returned from the data key `notifierMapKey` is bigger than
224
243
  * the length of the `LSP10Vaults[]`, meaning, index is out of bounds.
225
244
  */
226
- if (dataKeys.length == 0 && dataValues.length == 0) return "LSP1: asset data corrupted";
245
+ if (dataKeys.length == 0 && dataValues.length == 0)
246
+ return "LSP1: asset data corrupted";
227
247
 
228
248
  // Set the LSP10 generated data keys on the account
229
249
  IERC725Y(msg.sender).setDataBatch(dataKeys, dataValues);
@@ -236,7 +256,11 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
236
256
  /**
237
257
  * @inheritdoc ERC165
238
258
  */
239
- function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
240
- return interfaceId == _INTERFACEID_LSP1 || super.supportsInterface(interfaceId);
259
+ function supportsInterface(
260
+ bytes4 interfaceId
261
+ ) public view virtual override returns (bool) {
262
+ return
263
+ interfaceId == _INTERFACEID_LSP1 ||
264
+ super.supportsInterface(interfaceId);
241
265
  }
242
266
  }
@@ -2,7 +2,9 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  // interfaces
5
- import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
5
+ import {
6
+ IERC725Y
7
+ } from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
8
  import {ILSP1UniversalReceiver} from "../ILSP1UniversalReceiver.sol";
7
9
  import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
8
10
 
@@ -44,16 +46,26 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
44
46
  // Check https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-9-Vault.md#universalreceiver
45
47
  address notifier = address(bytes20(msg.data[msg.data.length - 52:]));
46
48
 
47
- (bool invalid, bytes10 mapPrefix, bytes4 interfaceID, bool isReceiving) = LSP1Utils
48
- .getTransferDetails(typeId);
49
+ (
50
+ bool invalid,
51
+ bytes10 mapPrefix,
52
+ bytes4 interfaceID,
53
+ bool isReceiving
54
+ ) = LSP1Utils.getTransferDetails(typeId);
49
55
 
50
- if (invalid || interfaceID == _INTERFACEID_LSP9) return "LSP1: typeId out of scope";
56
+ if (invalid || interfaceID == _INTERFACEID_LSP9)
57
+ return "LSP1: typeId out of scope";
51
58
 
52
59
  // solhint-disable avoid-tx-origin
53
60
  if (notifier == tx.origin) revert CannotRegisterEOAsAsAssets(notifier);
54
61
 
55
- bytes32 notifierMapKey = LSP2Utils.generateMappingKey(mapPrefix, bytes20(notifier));
56
- bytes memory notifierMapValue = IERC725Y(msg.sender).getData(notifierMapKey);
62
+ bytes32 notifierMapKey = LSP2Utils.generateMappingKey(
63
+ mapPrefix,
64
+ bytes20(notifier)
65
+ );
66
+ bytes memory notifierMapValue = IERC725Y(msg.sender).getData(
67
+ notifierMapKey
68
+ );
57
69
 
58
70
  bytes32[] memory dataKeys;
59
71
  bytes[] memory dataValues;
@@ -67,7 +79,9 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
67
79
  // not when tokens are being transferred on deployment through the `constructor`
68
80
  if (notifier.code.length > 0) {
69
81
  // if the amount sent is 0, then do not update the keys
70
- uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(msg.sender);
82
+ uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(
83
+ msg.sender
84
+ );
71
85
  if (balance == 0) return "LSP1: balance not updated";
72
86
  }
73
87
 
@@ -90,7 +104,8 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
90
104
 
91
105
  // if the value under the `LSP5ReceivedAssetsMap:<asset-address>`
92
106
  // is not a valid tuple as `(bytes4,uint128)`
93
- if (notifierMapValue.length < 20) return "LSP1: asset data corrupted";
107
+ if (notifierMapValue.length < 20)
108
+ return "LSP1: asset data corrupted";
94
109
 
95
110
  // Identify where the asset is located in the `LSP5ReceivedAssets[]` Array
96
111
  // by extracting the index from the tuple value `(bytes4,uint128)`
@@ -108,7 +123,8 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
108
123
  * - the index returned from the data key `notifierMapKey` is bigger than
109
124
  * the length of the `LSP5ReceivedAssets[]`, meaning, index is out of bounds.
110
125
  */
111
- if (dataKeys.length == 0 && dataValues.length == 0) return "LSP1: asset data corrupted";
126
+ if (dataKeys.length == 0 && dataValues.length == 0)
127
+ return "LSP1: asset data corrupted";
112
128
 
113
129
  IERC725Y(msg.sender).setDataBatch(dataKeys, dataValues);
114
130
  }
@@ -119,7 +135,11 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
119
135
  /**
120
136
  * @inheritdoc ERC165
121
137
  */
122
- function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
123
- return interfaceId == _INTERFACEID_LSP1 || super.supportsInterface(interfaceId);
138
+ function supportsInterface(
139
+ bytes4 interfaceId
140
+ ) public view virtual override returns (bool) {
141
+ return
142
+ interfaceId == _INTERFACEID_LSP1 ||
143
+ super.supportsInterface(interfaceId);
124
144
  }
125
145
  }
@@ -3,7 +3,9 @@ pragma solidity ^0.8.4;
3
3
 
4
4
  // libraries
5
5
  import {Address} from "@openzeppelin/contracts/utils/Address.sol";
6
- import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
6
+ import {
7
+ ERC165Checker
8
+ } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
7
9
 
8
10
  // constants
9
11
  import "./ILSP1UniversalReceiver.sol";
@@ -22,8 +24,16 @@ library LSP1Utils {
22
24
  bytes32 typeId,
23
25
  bytes memory data
24
26
  ) internal {
25
- if (ERC165Checker.supportsERC165InterfaceUnchecked(lsp1Implementation, _INTERFACEID_LSP1)) {
26
- ILSP1UniversalReceiver(lsp1Implementation).universalReceiver(typeId, data);
27
+ if (
28
+ ERC165Checker.supportsERC165InterfaceUnchecked(
29
+ lsp1Implementation,
30
+ _INTERFACEID_LSP1
31
+ )
32
+ ) {
33
+ ILSP1UniversalReceiver(lsp1Implementation).universalReceiver(
34
+ typeId,
35
+ data
36
+ );
27
37
  }
28
38
  }
29
39
 
@@ -44,8 +54,14 @@ library LSP1Utils {
44
54
  msgValue
45
55
  );
46
56
 
47
- (bool success, bytes memory result) = universalReceiverDelegate.call(callData);
48
- Address.verifyCallResult(success, result, "Call to universalReceiver failed");
57
+ (bool success, bytes memory result) = universalReceiverDelegate.call(
58
+ callData
59
+ );
60
+ Address.verifyCallResult(
61
+ success,
62
+ result,
63
+ "Call to universalReceiver failed"
64
+ );
49
65
  return result.length != 0 ? abi.decode(result, (bytes)) : result;
50
66
  }
51
67
 
@@ -53,7 +69,9 @@ library LSP1Utils {
53
69
  * @dev Gets all the transfer details depending on the `typeId`
54
70
  * @param typeId A unique identifier for a specific action
55
71
  */
56
- function getTransferDetails(bytes32 typeId)
72
+ function getTransferDetails(
73
+ bytes32 typeId
74
+ )
57
75
  internal
58
76
  pure
59
77
  returns (
@@ -63,11 +81,17 @@ library LSP1Utils {
63
81
  bool isReceiving
64
82
  )
65
83
  {
66
- if (typeId == _TYPEID_LSP7_TOKENSSENDER || typeId == _TYPEID_LSP7_TOKENSRECIPIENT) {
84
+ if (
85
+ typeId == _TYPEID_LSP7_TOKENSSENDER ||
86
+ typeId == _TYPEID_LSP7_TOKENSRECIPIENT
87
+ ) {
67
88
  mapPrefix = _LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX;
68
89
  interfaceId = _INTERFACEID_LSP7;
69
90
  isReceiving = typeId == _TYPEID_LSP7_TOKENSRECIPIENT ? true : false;
70
- } else if (typeId == _TYPEID_LSP8_TOKENSSENDER || typeId == _TYPEID_LSP8_TOKENSRECIPIENT) {
91
+ } else if (
92
+ typeId == _TYPEID_LSP8_TOKENSSENDER ||
93
+ typeId == _TYPEID_LSP8_TOKENSRECIPIENT
94
+ ) {
71
95
  mapPrefix = _LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX;
72
96
  interfaceId = _INTERFACEID_LSP8;
73
97
  isReceiving = typeId == _TYPEID_LSP8_TOKENSRECIPIENT ? true : false;
@@ -77,7 +101,8 @@ library LSP1Utils {
77
101
  ) {
78
102
  mapPrefix = _LSP10_VAULTS_MAP_KEY_PREFIX;
79
103
  interfaceId = _INTERFACEID_LSP9;
80
- isReceiving = (typeId == _TYPEID_LSP9_OwnershipTransferred_RecipientNotification)
104
+ isReceiving = (typeId ==
105
+ _TYPEID_LSP9_OwnershipTransferred_RecipientNotification)
81
106
  ? true
82
107
  : false;
83
108
  } else {