@lukso/lsp-smart-contracts 0.10.1 → 0.10.3

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 +26 -23
  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
@@ -2,9 +2,11 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  /**
5
+ * @title Interface for the LSP20 Call Verification standard, a set of functions intended to perform verifications on behalf of another contract.
6
+ *
5
7
  * @dev Interface to be inherited for contract supporting LSP20-CallVerification
6
8
  */
7
- interface ILSP20CallVerification {
9
+ interface ILSP20CallVerifier {
8
10
  /**
9
11
  * @return magicValue MUST return the first 3 bytes of `lsp20VerifyCall(address,uint256,bytes)` function selector if the call to
10
12
  * the function is allowed, concatened with a byte that determines if the lsp20VerifyCallResult function should
@@ -26,5 +28,8 @@ interface ILSP20CallVerification {
26
28
  * @param callHash The keccak256 of the parameters of {lsp20VerifyCall} concatenated
27
29
  * @param result The value result of the function called on the msg.sender
28
30
  */
29
- function lsp20VerifyCallResult(bytes32 callHash, bytes memory result) external returns (bytes4);
31
+ function lsp20VerifyCallResult(
32
+ bytes32 callHash,
33
+ bytes memory result
34
+ ) external returns (bytes4);
30
35
  }
@@ -3,13 +3,14 @@ pragma solidity ^0.8.4;
3
3
 
4
4
  // interfaces
5
5
 
6
- import {ILSP20CallVerification as ILSP20} from "./ILSP20CallVerification.sol";
6
+ import {ILSP20CallVerifier as ILSP20} from "./ILSP20CallVerifier.sol";
7
7
 
8
8
  // errors
9
9
  import "./LSP20Errors.sol";
10
10
 
11
11
  /**
12
- * @title Implementation of contract calling the verification functions according to LSP20CallVerification
12
+ * @title Implementation of a contract calling the verification functions according to LSP20 - Call Verification standard.
13
+ *
13
14
  * @dev Module to be inherited used to verify the execution of functions according to a verifier address.
14
15
  * Verification can happen before or after execution based on a magicValue.
15
16
  */
@@ -19,9 +20,16 @@ abstract contract LSP20CallVerification {
19
20
  * Reverts in case the value returned does not match the magic value (lsp20VerifyCall selector)
20
21
  * Returns whether a verification after the execution should happen based on the last byte of the magicValue
21
22
  */
22
- function _verifyCall(address logicVerifier) internal virtual returns (bool verifyAfter) {
23
+ function _verifyCall(
24
+ address logicVerifier
25
+ ) internal virtual returns (bool verifyAfter) {
23
26
  (bool success, bytes memory returnedData) = logicVerifier.call(
24
- abi.encodeWithSelector(ILSP20.lsp20VerifyCall.selector, msg.sender, msg.value, msg.data)
27
+ abi.encodeWithSelector(
28
+ ILSP20.lsp20VerifyCall.selector,
29
+ msg.sender,
30
+ msg.value,
31
+ msg.data
32
+ )
25
33
  );
26
34
 
27
35
  _validateCall(false, success, returnedData);
@@ -38,7 +46,10 @@ abstract contract LSP20CallVerification {
38
46
  * @dev Calls {lsp20VerifyCallResult} function on the logicVerifier.
39
47
  * Reverts in case the value returned does not match the magic value (lsp20VerifyCallResult selector)
40
48
  */
41
- function _verifyCallResult(address logicVerifier, bytes memory callResult) internal virtual {
49
+ function _verifyCallResult(
50
+ address logicVerifier,
51
+ bytes memory callResult
52
+ ) internal virtual {
42
53
  (bool success, bytes memory returnedData) = logicVerifier.call(
43
54
  abi.encodeWithSelector(
44
55
  ILSP20.lsp20VerifyCallResult.selector,
@@ -49,8 +60,10 @@ abstract contract LSP20CallVerification {
49
60
 
50
61
  _validateCall(true, success, returnedData);
51
62
 
52
- if (abi.decode(returnedData, (bytes4)) != ILSP20.lsp20VerifyCallResult.selector)
53
- revert LSP20InvalidMagicValue(true, returnedData);
63
+ if (
64
+ abi.decode(returnedData, (bytes4)) !=
65
+ ILSP20.lsp20VerifyCallResult.selector
66
+ ) revert LSP20InvalidMagicValue(true, returnedData);
54
67
  }
55
68
 
56
69
  function _validateCall(
@@ -62,8 +75,10 @@ abstract contract LSP20CallVerification {
62
75
 
63
76
  // check if the returned data contains at least 32 bytes, potentially an abi encoded bytes4 value
64
77
  // check if the returned data has in the first 32 bytes an abi encoded bytes4 value
65
- if (returnedData.length < 32 || bytes28(bytes32(returnedData) << 32) != bytes28(0))
66
- revert LSP20InvalidMagicValue(postCall, returnedData);
78
+ if (
79
+ returnedData.length < 32 ||
80
+ bytes28(bytes32(returnedData) << 32) != bytes28(0)
81
+ ) revert LSP20InvalidMagicValue(postCall, returnedData);
67
82
  }
68
83
 
69
84
  function _revert(bool postCall, bytes memory returnedData) internal pure {
@@ -10,6 +10,6 @@ error LSP20CallingVerifierFailed(bool postCall);
10
10
  /**
11
11
  * @dev reverts when the call to the owner does not return the magic value
12
12
  * @param postCall True if the execution call was done, False otherwise
13
- * @param postCall The data returned by the call to the logic verifier
13
+ * @param returnedData The data returned by the call to the logic verifier
14
14
  */
15
15
  error LSP20InvalidMagicValue(bool postCall, bytes returnedData);
@@ -19,7 +19,9 @@ library LSP2Utils {
19
19
  * @return a bytes32 dataKey
20
20
  *
21
21
  */
22
- function generateSingletonKey(string memory keyName) internal pure returns (bytes32) {
22
+ function generateSingletonKey(
23
+ string memory keyName
24
+ ) internal pure returns (bytes32) {
23
25
  return keccak256(bytes(keyName));
24
26
  }
25
27
 
@@ -27,7 +29,9 @@ library LSP2Utils {
27
29
  * @dev Generates a data key of keyType Array by hashing `keyName`.
28
30
  * @param keyName The string that will be used to generate an data key of keyType Array
29
31
  */
30
- function generateArrayKey(string memory keyName) internal pure returns (bytes32) {
32
+ function generateArrayKey(
33
+ string memory keyName
34
+ ) internal pure returns (bytes32) {
31
35
  bytes memory dataKey = bytes(keyName);
32
36
  require(dataKey.length >= 2, "MUST be longer than 2 characters");
33
37
  require(
@@ -45,12 +49,14 @@ library LSP2Utils {
45
49
  * @param arrayKey The key from which we're getting the first half of the Array index data key from
46
50
  * @param index Used to generate the second half of the Array index data key
47
51
  */
48
- function generateArrayElementKeyAtIndex(bytes32 arrayKey, uint128 index)
49
- internal
50
- pure
51
- returns (bytes32)
52
- {
53
- bytes memory elementInArray = bytes.concat(bytes16(arrayKey), bytes16(index));
52
+ function generateArrayElementKeyAtIndex(
53
+ bytes32 arrayKey,
54
+ uint128 index
55
+ ) internal pure returns (bytes32) {
56
+ bytes memory elementInArray = bytes.concat(
57
+ bytes16(arrayKey),
58
+ bytes16(index)
59
+ );
54
60
  return bytes32(elementInArray);
55
61
  }
56
62
 
@@ -62,11 +68,10 @@ library LSP2Utils {
62
68
  * @param lastWord Used to generate a hash and its first 20 bytes
63
69
  * are used for the last part of the data key of keyType Mapping
64
70
  */
65
- function generateMappingKey(string memory firstWord, string memory lastWord)
66
- internal
67
- pure
68
- returns (bytes32)
69
- {
71
+ function generateMappingKey(
72
+ string memory firstWord,
73
+ string memory lastWord
74
+ ) internal pure returns (bytes32) {
70
75
  bytes32 firstWordHash = keccak256(bytes(firstWord));
71
76
  bytes32 lastWordHash = keccak256(bytes(lastWord));
72
77
 
@@ -86,11 +91,10 @@ library LSP2Utils {
86
91
  * are used for the first part of the data key of keyType Mapping
87
92
  * @param addr used for the last part of the data key of keyType Mapping
88
93
  */
89
- function generateMappingKey(string memory firstWord, address addr)
90
- internal
91
- pure
92
- returns (bytes32)
93
- {
94
+ function generateMappingKey(
95
+ string memory firstWord,
96
+ address addr
97
+ ) internal pure returns (bytes32) {
94
98
  bytes32 firstWordHash = keccak256(bytes(firstWord));
95
99
 
96
100
  bytes memory temporaryBytes = bytes.concat(
@@ -108,12 +112,15 @@ library LSP2Utils {
108
112
  * @param keyPrefix First part of the data key of keyType Mapping
109
113
  * @param bytes20Value Second part of the data key of keyType Mapping
110
114
  */
111
- function generateMappingKey(bytes10 keyPrefix, bytes20 bytes20Value)
112
- internal
113
- pure
114
- returns (bytes32)
115
- {
116
- bytes memory generatedKey = bytes.concat(keyPrefix, bytes2(0), bytes20Value);
115
+ function generateMappingKey(
116
+ bytes10 keyPrefix,
117
+ bytes20 bytes20Value
118
+ ) internal pure returns (bytes32) {
119
+ bytes memory generatedKey = bytes.concat(
120
+ keyPrefix,
121
+ bytes2(0),
122
+ bytes20Value
123
+ );
117
124
  return bytes32(generatedKey);
118
125
  }
119
126
 
@@ -156,7 +163,12 @@ library LSP2Utils {
156
163
  bytes4 mapPrefix,
157
164
  bytes20 subMapKey
158
165
  ) internal pure returns (bytes32) {
159
- bytes memory generatedKey = bytes.concat(keyPrefix, mapPrefix, bytes2(0), subMapKey);
166
+ bytes memory generatedKey = bytes.concat(
167
+ keyPrefix,
168
+ mapPrefix,
169
+ bytes2(0),
170
+ subMapKey
171
+ );
160
172
  return bytes32(generatedKey);
161
173
  }
162
174
 
@@ -166,12 +178,15 @@ library LSP2Utils {
166
178
  * @param keyPrefix Used for the first part of the data key of keyType MappingWithGrouping
167
179
  * @param bytes20Value Used for the first last of the data key of keyType MappingWithGrouping
168
180
  */
169
- function generateMappingWithGroupingKey(bytes10 keyPrefix, bytes20 bytes20Value)
170
- internal
171
- pure
172
- returns (bytes32)
173
- {
174
- bytes memory generatedKey = bytes.concat(keyPrefix, bytes2(0), bytes20Value);
181
+ function generateMappingWithGroupingKey(
182
+ bytes10 keyPrefix,
183
+ bytes20 bytes20Value
184
+ ) internal pure returns (bytes32) {
185
+ bytes memory generatedKey = bytes.concat(
186
+ keyPrefix,
187
+ bytes2(0),
188
+ bytes20Value
189
+ );
175
190
  return bytes32(generatedKey);
176
191
  }
177
192
 
@@ -233,7 +248,9 @@ library LSP2Utils {
233
248
  * Verifing if `data` is an encoded array of addresses (address[])
234
249
  * @param data The value that is to be verified
235
250
  */
236
- function isEncodedArrayOfAddresses(bytes memory data) internal pure returns (bool) {
251
+ function isEncodedArrayOfAddresses(
252
+ bytes memory data
253
+ ) internal pure returns (bool) {
237
254
  if (!isEncodedArray(data)) return false;
238
255
 
239
256
  uint256 offset = uint256(bytes32(data));
@@ -263,7 +280,9 @@ library LSP2Utils {
263
280
  * @dev verify that `data` is an array of bytes4 (bytes4[]) encoded according to the Solidity ABI specs.
264
281
  * @param data The value that is to be verified
265
282
  */
266
- function isBytes4EncodedArray(bytes memory data) internal pure returns (bool) {
283
+ function isBytes4EncodedArray(
284
+ bytes memory data
285
+ ) internal pure returns (bool) {
267
286
  if (!isEncodedArray(data)) return false;
268
287
 
269
288
  uint256 offset = uint256(bytes32(data));
@@ -290,7 +309,9 @@ library LSP2Utils {
290
309
  /**
291
310
  * @dev Verify the validity of the `compactBytesArray` according to LSP2
292
311
  */
293
- function isCompactBytesArray(bytes memory compactBytesArray) internal pure returns (bool) {
312
+ function isCompactBytesArray(
313
+ bytes memory compactBytesArray
314
+ ) internal pure returns (bool) {
294
315
  /**
295
316
  * Pointer will always land on these values:
296
317
  *
@@ -304,7 +325,7 @@ library LSP2Utils {
304
325
  *
305
326
  * The pointer can only land on the length of the following bytes value.
306
327
  */
307
- uint256 pointer;
328
+ uint256 pointer = 0;
308
329
 
309
330
  /**
310
331
  * Check each length byte and make sure that when you reach the last length byte.
@@ -313,7 +334,12 @@ library LSP2Utils {
313
334
  while (pointer < compactBytesArray.length) {
314
335
  if (pointer + 1 >= compactBytesArray.length) return false;
315
336
  uint256 elementLength = uint16(
316
- bytes2(abi.encodePacked(compactBytesArray[pointer], compactBytesArray[pointer + 1]))
337
+ bytes2(
338
+ abi.encodePacked(
339
+ compactBytesArray[pointer],
340
+ compactBytesArray[pointer + 1]
341
+ )
342
+ )
317
343
  );
318
344
  pointer += elementLength + 2;
319
345
  }
@@ -3,7 +3,9 @@
3
3
  pragma solidity ^0.8.4;
4
4
 
5
5
  // interfaces
6
- import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
+ import {
7
+ IERC725Y
8
+ } from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
7
9
 
8
10
  /**
9
11
  * @dev LSP4 extension, for compatibility with clients & tools that expect ERC20/721.
@@ -11,7 +11,10 @@ import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
11
11
  import "./LSP4Constants.sol";
12
12
 
13
13
  // errors
14
- import {LSP4TokenNameNotEditable, LSP4TokenSymbolNotEditable} from "./LSP4Errors.sol";
14
+ import {
15
+ LSP4TokenNameNotEditable,
16
+ LSP4TokenSymbolNotEditable
17
+ } from "./LSP4Errors.sol";
15
18
 
16
19
  /**
17
20
  * @title LSP4DigitalAssetMetadata
@@ -31,7 +34,10 @@ abstract contract LSP4DigitalAssetMetadata is ERC725Y {
31
34
  address newOwner_
32
35
  ) ERC725Y(newOwner_) {
33
36
  // set key SupportedStandards:LSP4DigitalAsset
34
- super._setData(_LSP4_SUPPORTED_STANDARDS_KEY, _LSP4_SUPPORTED_STANDARDS_VALUE);
37
+ super._setData(
38
+ _LSP4_SUPPORTED_STANDARDS_KEY,
39
+ _LSP4_SUPPORTED_STANDARDS_VALUE
40
+ );
35
41
 
36
42
  super._setData(_LSP4_TOKEN_NAME_KEY, bytes(name_));
37
43
  super._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
@@ -43,7 +49,10 @@ abstract contract LSP4DigitalAssetMetadata is ERC725Y {
43
49
  *
44
50
  * @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
45
51
  */
46
- function _setData(bytes32 dataKey, bytes memory dataValue) internal virtual override {
52
+ function _setData(
53
+ bytes32 dataKey,
54
+ bytes memory dataValue
55
+ ) internal virtual override {
47
56
  if (dataKey == _LSP4_TOKEN_NAME_KEY) {
48
57
  revert LSP4TokenNameNotEditable();
49
58
  } else if (dataKey == _LSP4_TOKEN_SYMBOL_KEY) {
@@ -52,7 +61,9 @@ abstract contract LSP4DigitalAssetMetadata is ERC725Y {
52
61
  _store[dataKey] = dataValue;
53
62
  emit DataChanged(
54
63
  dataKey,
55
- dataValue.length <= 256 ? dataValue : BytesLib.slice(dataValue, 0, 256)
64
+ dataValue.length <= 256
65
+ ? dataValue
66
+ : BytesLib.slice(dataValue, 0, 256)
56
67
  );
57
68
  }
58
69
  }
@@ -2,7 +2,9 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  // modules
5
- import {ERC725YInitAbstract} from "@erc725/smart-contracts/contracts/ERC725YInitAbstract.sol";
5
+ import {
6
+ ERC725YInitAbstract
7
+ } from "@erc725/smart-contracts/contracts/ERC725YInitAbstract.sol";
6
8
 
7
9
  // libraries
8
10
  import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
@@ -11,7 +13,10 @@ import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
11
13
  import "./LSP4Constants.sol";
12
14
 
13
15
  // errors
14
- import {LSP4TokenNameNotEditable, LSP4TokenSymbolNotEditable} from "./LSP4Errors.sol";
16
+ import {
17
+ LSP4TokenNameNotEditable,
18
+ LSP4TokenSymbolNotEditable
19
+ } from "./LSP4Errors.sol";
15
20
 
16
21
  /**
17
22
  * @title LSP4DigitalAssetMetadata
@@ -27,7 +32,10 @@ abstract contract LSP4DigitalAssetMetadataInitAbstract is ERC725YInitAbstract {
27
32
  ERC725YInitAbstract._initialize(newOwner_);
28
33
 
29
34
  // set SupportedStandards:LSP4DigitalAsset
30
- super._setData(_LSP4_SUPPORTED_STANDARDS_KEY, _LSP4_SUPPORTED_STANDARDS_VALUE);
35
+ super._setData(
36
+ _LSP4_SUPPORTED_STANDARDS_KEY,
37
+ _LSP4_SUPPORTED_STANDARDS_VALUE
38
+ );
31
39
 
32
40
  super._setData(_LSP4_TOKEN_NAME_KEY, bytes(name_));
33
41
  super._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
@@ -39,7 +47,10 @@ abstract contract LSP4DigitalAssetMetadataInitAbstract is ERC725YInitAbstract {
39
47
  *
40
48
  * @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
41
49
  */
42
- function _setData(bytes32 dataKey, bytes memory dataValue) internal virtual override {
50
+ function _setData(
51
+ bytes32 dataKey,
52
+ bytes memory dataValue
53
+ ) internal virtual override {
43
54
  if (dataKey == _LSP4_TOKEN_NAME_KEY) {
44
55
  revert LSP4TokenNameNotEditable();
45
56
  } else if (dataKey == _LSP4_TOKEN_SYMBOL_KEY) {
@@ -48,7 +59,9 @@ abstract contract LSP4DigitalAssetMetadataInitAbstract is ERC725YInitAbstract {
48
59
  _store[dataKey] = dataValue;
49
60
  emit DataChanged(
50
61
  dataKey,
51
- dataValue.length <= 256 ? dataValue : BytesLib.slice(dataValue, 0, 256)
62
+ dataValue.length <= 256
63
+ ? dataValue
64
+ : BytesLib.slice(dataValue, 0, 256)
52
65
  );
53
66
  }
54
67
  }
@@ -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
 
7
9
  // libraries
8
10
  import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
@@ -26,7 +28,10 @@ import "../LSP7DigitalAsset/LSP7Constants.sol";
26
28
  * @param invalidValueStored the invalid value stored under the LSP5ReceivedAssets[] data key
27
29
  * @param invalidValueLength the invalid number of bytes stored under the LSP5ReceivedAssets[] data key (MUST be exactly 16 bytes long)
28
30
  */
29
- error InvalidLSP5ReceivedAssetsArrayLength(bytes invalidValueStored, uint256 invalidValueLength);
31
+ error InvalidLSP5ReceivedAssetsArrayLength(
32
+ bytes invalidValueStored,
33
+ uint256 invalidValueLength
34
+ );
30
35
 
31
36
  /**
32
37
  * @dev reverts when the `LSP5ReceivedAssets[]` array reaches its maximum limit (max(uint128))
@@ -80,7 +85,9 @@ library LSP5Utils {
80
85
  uint128 oldArrayLength = uint128(bytes16(encodedArrayLength));
81
86
 
82
87
  if (oldArrayLength == type(uint128).max) {
83
- revert MaxLSP5ReceivedAssetsCountReached({notRegisteredAsset: asset});
88
+ revert MaxLSP5ReceivedAssetsCountReached({
89
+ notRegisteredAsset: asset
90
+ });
84
91
  }
85
92
 
86
93
  // store the number of received assets incremented by 1
@@ -113,7 +120,9 @@ library LSP5Utils {
113
120
  uint128 assetIndex
114
121
  ) internal view returns (bytes32[] memory keys, bytes[] memory values) {
115
122
  IERC725Y account = IERC725Y(sender);
116
- bytes memory lsp5ReceivedAssetsCountValue = getLSP5ReceivedAssetsCount(account);
123
+ bytes memory lsp5ReceivedAssetsCountValue = getLSP5ReceivedAssetsCount(
124
+ account
125
+ );
117
126
 
118
127
  if (lsp5ReceivedAssetsCountValue.length != 16) {
119
128
  revert InvalidLSP5ReceivedAssetsArrayLength({
@@ -186,13 +195,16 @@ library LSP5Utils {
186
195
  // with data Keys/values of the asset to remove
187
196
 
188
197
  // Generate the element key of the last asset in the array
189
- bytes32 lastAssetInArrayKey = LSP2Utils.generateArrayElementKeyAtIndex(
190
- _LSP5_RECEIVED_ASSETS_ARRAY_KEY,
191
- newArrayLength
192
- );
198
+ bytes32 lastAssetInArrayKey = LSP2Utils
199
+ .generateArrayElementKeyAtIndex(
200
+ _LSP5_RECEIVED_ASSETS_ARRAY_KEY,
201
+ newArrayLength
202
+ );
193
203
 
194
204
  // Get the address of the asset from the element key of the last asset in the array
195
- bytes20 lastAssetInArrayAddress = bytes20(account.getData(lastAssetInArrayKey));
205
+ bytes20 lastAssetInArrayAddress = bytes20(
206
+ account.getData(lastAssetInArrayKey)
207
+ );
196
208
 
197
209
  // Generate the map key of the last asset in the array
198
210
  bytes32 lastAssetInArrayMapKey = LSP2Utils.generateMappingKey(
@@ -201,8 +213,14 @@ library LSP5Utils {
201
213
  );
202
214
 
203
215
  // Get the interfaceId and the location in the array of the last asset
204
- bytes memory lastAssetInterfaceIdAndIndex = account.getData(lastAssetInArrayMapKey);
205
- bytes memory interfaceID = BytesLib.slice(lastAssetInterfaceIdAndIndex, 0, 4);
216
+ bytes memory lastAssetInterfaceIdAndIndex = account.getData(
217
+ lastAssetInArrayMapKey
218
+ );
219
+ bytes memory interfaceID = BytesLib.slice(
220
+ lastAssetInterfaceIdAndIndex,
221
+ 0,
222
+ 4
223
+ );
206
224
 
207
225
  // Set the address of the last asset instead of the asset to be sent
208
226
  // under the element data key in the array
@@ -223,7 +241,9 @@ library LSP5Utils {
223
241
  }
224
242
  }
225
243
 
226
- function getLSP5ReceivedAssetsCount(IERC725Y account) internal view returns (bytes memory) {
244
+ function getLSP5ReceivedAssetsCount(
245
+ IERC725Y account
246
+ ) internal view returns (bytes memory) {
227
247
  return account.getData(_LSP5_RECEIVED_ASSETS_ARRAY_KEY);
228
248
  }
229
249
  }
@@ -5,7 +5,7 @@ pragma solidity ^0.8.4;
5
5
  import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
6
6
 
7
7
  /**
8
- * @dev Contract acting as a controller of an ERC725 Account, using permissions stored in the ERC725Y storage
8
+ * @title Interface of the LSP6 - Key Manager standard, a contract acting as a controller of an ERC725 Account using predfined permissions.
9
9
  */
10
10
  interface ILSP6KeyManager is
11
11
  IERC1271
@@ -17,7 +17,11 @@ interface ILSP6KeyManager is
17
17
  * @param value the amount of native token to be transferred in the calldata payload.
18
18
  * @param selector the bytes4 function of the function to run in the calldata payload.
19
19
  */
20
- event VerifiedCall(address indexed signer, uint256 indexed value, bytes4 indexed selector);
20
+ event VerifiedCall(
21
+ address indexed signer,
22
+ uint256 indexed value,
23
+ bytes4 indexed selector
24
+ );
21
25
 
22
26
  /**
23
27
  * @notice returns the address of the account linked to this KeyManager
@@ -36,7 +40,10 @@ interface ILSP6KeyManager is
36
40
  * @param from the caller or signer address
37
41
  * @param channelId the channel id to retrieve the nonce from
38
42
  */
39
- function getNonce(address from, uint128 channelId) external view returns (uint256);
43
+ function getNonce(
44
+ address from,
45
+ uint128 channelId
46
+ ) external view returns (uint256);
40
47
 
41
48
  /**
42
49
  * @notice execute the following payload on the ERC725Account: `payload`
@@ -44,15 +51,17 @@ interface ILSP6KeyManager is
44
51
  * @param payload the payload to execute. Obtained in web3 via encodeABI()
45
52
  * @return the data being returned by the ERC725 Account
46
53
  */
47
- function execute(bytes calldata payload) external payable returns (bytes memory);
54
+ function execute(
55
+ bytes calldata payload
56
+ ) external payable returns (bytes memory);
48
57
 
49
58
  /**
50
59
  * @dev batch `execute(bytes)`
51
60
  */
52
- function executeBatch(uint256[] calldata values, bytes[] calldata payloads)
53
- external
54
- payable
55
- returns (bytes[] memory);
61
+ function executeBatch(
62
+ uint256[] calldata values,
63
+ bytes[] calldata payloads
64
+ ) external payable returns (bytes[] memory);
56
65
 
57
66
  /**
58
67
  * @dev allows anybody to execute given they have a signed message from an executor
@@ -58,14 +58,8 @@ bytes32 constant _PERMISSION_SIGN = 0x000000000000000
58
58
  // All Permissions currently exclude REENTRANCY, DELEGATECALL and SUPER_DELEGATECALL for security
59
59
  bytes32 constant ALL_REGULAR_PERMISSIONS = 0x00000000000000000000000000000000000000000000000000000000003f3f7f;
60
60
 
61
- // LSP6 overloaded function selectors
62
- bytes4 constant _LSP6_EXECUTE_SELECTOR = 0x09c5eabe;
63
- bytes4 constant _LSP6_EXECUTE_BATCH_SELECTOR = 0xbf3e1f7b;
64
- bytes4 constant _LSP6_EXECUTE_RELAYCALL_SELECTOR = 0x902d5fa0;
65
- bytes4 constant _LSP6_EXECUTE_RELAYCALL_BATCH_SELECTOR = 0xbd68663a;
66
-
67
61
  // AllowedCalls types
68
62
  bytes4 constant _ALLOWEDCALLS_TRANSFERVALUE = 0x00000001; // 0000 0001
69
- bytes4 constant _ALLOWEDCALLS_CALL = 0x00000002; // 0000 0010
70
- bytes4 constant _ALLOWEDCALLS_STATICCALL = 0x00000004; // 0000 0100
71
- bytes4 constant _ALLOWEDCALLS_DELEGATECALL = 0x00000008; // 0000 1000
63
+ bytes4 constant _ALLOWEDCALLS_CALL = 0x00000002; // 0000 0010
64
+ bytes4 constant _ALLOWEDCALLS_STATICCALL = 0x00000004; // 0000 0100
65
+ bytes4 constant _ALLOWEDCALLS_DELEGATECALL = 0x00000008; // 0000 1000
@@ -71,7 +71,10 @@ error InvalidEncodedAllowedCalls(bytes allowedCallsValue);
71
71
  * @param dataKey the AddressPermissions[index] data key
72
72
  * @param invalidValue the invalid value that was attempted to be set under AddressPermissions[index]
73
73
  */
74
- error AddressPermissionArrayIndexValueNotAnAddress(bytes32 dataKey, bytes invalidValue);
74
+ error AddressPermissionArrayIndexValueNotAnAddress(
75
+ bytes32 dataKey,
76
+ bytes invalidValue
77
+ );
75
78
 
76
79
  /**
77
80
  * @dev reverts if there are no AllowedERC725YDataKeys set for the caller