@lukso/lsp-smart-contracts 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +2 -10
  2. package/artifacts/Create2Factory.json +2 -2
  3. package/artifacts/LSP0ERC725Account.json +36 -3
  4. package/artifacts/LSP0ERC725AccountInit.json +36 -29
  5. package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
  7. package/artifacts/LSP4Compatibility.json +6 -0
  8. package/artifacts/LSP4DigitalAssetMetadata.json +6 -0
  9. package/artifacts/{LSP4DigitalAssetMetadataInit.json → LSP4DigitalAssetMetadataInitAbstract.json} +8 -51
  10. package/artifacts/LSP6KeyManager.json +13 -2
  11. package/artifacts/LSP6KeyManagerInit.json +13 -2
  12. package/artifacts/LSP7CappedSupply.json +37 -26
  13. package/artifacts/{LSP7CappedSupplyInit.json → LSP7CappedSupplyInitAbstract.json} +39 -67
  14. package/artifacts/LSP7CompatibleERC20.json +39 -49
  15. package/artifacts/LSP7CompatibleERC20InitAbstract.json +717 -0
  16. package/artifacts/LSP7CompatibleERC20Mintable.json +39 -28
  17. package/artifacts/LSP7CompatibleERC20MintableInit.json +44 -54
  18. package/artifacts/LSP7DigitalAsset.json +39 -54
  19. package/artifacts/LSP7DigitalAssetInitAbstract.json +540 -0
  20. package/artifacts/LSP7Mintable.json +40 -29
  21. package/artifacts/LSP7MintableInit.json +40 -55
  22. package/artifacts/LSP8CappedSupply.json +43 -0
  23. package/artifacts/{LSP8CappedSupplyInit.json → LSP8CappedSupplyInitAbstract.json} +45 -41
  24. package/artifacts/LSP8CompatibleERC721.json +88 -23
  25. package/artifacts/LSP8CompatibleERC721InitAbstract.json +920 -0
  26. package/artifacts/LSP8CompatibleERC721Mintable.json +88 -2
  27. package/artifacts/LSP8CompatibleERC721MintableInit.json +93 -28
  28. package/artifacts/LSP8IdentifiableDigitalAsset.json +45 -23
  29. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +628 -0
  30. package/artifacts/LSP8Mintable.json +45 -2
  31. package/artifacts/LSP8MintableInit.json +45 -28
  32. package/artifacts/LSP9Vault.json +36 -3
  33. package/artifacts/LSP9VaultInit.json +36 -29
  34. package/artifacts/UniversalFactory.json +2 -2
  35. package/artifacts/UniversalProfile.json +36 -3
  36. package/artifacts/UniversalProfileInit.json +36 -29
  37. package/artifacts/UniversalReceiverAddressStore.json +2 -2
  38. package/constants.js +73 -14
  39. package/contracts/Custom/ClaimOwnership.sol +67 -5
  40. package/contracts/Custom/ERC165Checker.sol +1 -1
  41. package/contracts/Custom/IClaimOwnership.sol +3 -1
  42. package/contracts/Factories/UniversalFactory.sol +7 -12
  43. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  44. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +20 -18
  45. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +1 -1
  46. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
  47. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +1 -4
  48. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +2 -8
  49. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +1 -4
  50. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +2 -2
  51. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +1 -1
  52. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +92 -6
  53. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +15 -6
  54. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +15 -6
  55. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
  56. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +3 -3
  57. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +1 -1
  58. package/contracts/LSP6KeyManager/LSP6Constants.sol +16 -21
  59. package/contracts/LSP6KeyManager/LSP6Errors.sol +8 -0
  60. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +1 -1
  61. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +103 -84
  62. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -1
  63. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +1 -1
  64. package/contracts/LSP6KeyManager/LSP6Utils.sol +2 -1
  65. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +18 -5
  66. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
  67. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +4 -4
  68. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +33 -24
  69. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +2 -2
  70. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +2 -0
  71. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +1 -1
  72. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +1 -1
  73. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Core.sol +5 -6
  74. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +7 -0
  75. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +9 -7
  76. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +3 -3
  77. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +8 -7
  78. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +3 -1
  79. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +4 -4
  80. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +6 -0
  81. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +1 -1
  82. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +31 -30
  83. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +15 -1
  84. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +17 -0
  85. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +1 -1
  86. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +1 -1
  87. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Core.sol +51 -27
  88. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +21 -0
  89. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +50 -0
  90. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +24 -0
  91. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +7 -0
  92. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +6 -4
  93. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +5 -4
  94. package/contracts/LSP9Vault/LSP9Constants.sol +4 -1
  95. package/contracts/LSP9Vault/LSP9VaultCore.sol +117 -46
  96. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +1 -1
  97. package/contracts/Legacy/UniversalReceiverAddressStore.sol +1 -0
  98. package/contracts/Utils/GasLib.sol +17 -0
  99. package/package.json +27 -30
  100. package/artifacts/LSP7CompatibleERC20Init.json +0 -760
  101. package/artifacts/LSP7DigitalAssetInit.json +0 -588
  102. package/artifacts/LSP8CompatibleERC721Init.json +0 -883
  103. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +0 -639
  104. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +0 -26
  105. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +0 -39
  106. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +0 -19
  107. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Init.sol +0 -29
  108. package/contracts/LSP7DigitalAsset/presets/LSP7MintableCore.sol +0 -26
  109. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +0 -35
  110. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +0 -19
  111. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Init.sol +0 -25
  112. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableCore.sol +0 -26
@@ -16,10 +16,20 @@ library LSP2Utils {
16
16
 
17
17
  /* solhint-disable no-inline-assembly */
18
18
 
19
+ /**
20
+ * @dev Generates a data key of keyType Singleton
21
+ * @param keyName The string to hash to generate a Singleton data key
22
+ * @return a bytes32 dataKey
23
+ *
24
+ */
19
25
  function generateSingletonKey(string memory keyName) internal pure returns (bytes32) {
20
26
  return keccak256(bytes(keyName));
21
27
  }
22
28
 
29
+ /**
30
+ * @dev Generates a data key of keyType Array by hashing `keyName`.
31
+ * @param keyName The string that will be used to generate an data key of keyType Array
32
+ */
23
33
  function generateArrayKey(string memory keyName) internal pure returns (bytes32) {
24
34
  bytes memory dataKey = bytes(keyName);
25
35
 
@@ -32,6 +42,12 @@ library LSP2Utils {
32
42
  return keccak256(dataKey);
33
43
  }
34
44
 
45
+ /**
46
+ * @dev Generates a Array index data key by concatenating the first 16 bytes of `arrayKey`
47
+ * and `index` transformed from uint256 to bytes16 (uint256 -> uint128 -> bytes16)
48
+ * @param arrayKey The key from which we're getting the first half of the Array index data key from
49
+ * @param index Used to generate the second half of the Array index data key
50
+ */
35
51
  function generateArrayElementKeyAtIndex(bytes32 arrayKey, uint256 index)
36
52
  internal
37
53
  pure
@@ -44,6 +60,14 @@ library LSP2Utils {
44
60
  return bytes32(elementInArray);
45
61
  }
46
62
 
63
+ /**
64
+ * @dev @dev Generates a data key of keyType Mapping by hashing two strings:
65
+ * <bytes10(keccak256(firstWord))>:<bytes2(0)>:<bytes20(keccak256(firstWord))>
66
+ * @param firstWord Used to generate a hash and its first 10 bytes
67
+ * are used for the first part of the data key of keyType Mapping
68
+ * @param lastWord Used to generate a hash and its first 20 bytes
69
+ * are used for the last part of the data key of keyType Mapping
70
+ */
47
71
  function generateMappingKey(string memory firstWord, string memory lastWord)
48
72
  internal
49
73
  pure
@@ -61,6 +85,13 @@ library LSP2Utils {
61
85
  return bytes32(temporaryBytes);
62
86
  }
63
87
 
88
+ /**
89
+ * @dev Generates a data key of keyType Mapping by hashing a string and concatenating it with an address:
90
+ * <bytes10(keccak256(firstWord))>:<bytes2(0)>:<bytes20(addr)>
91
+ * @param firstWord Used to generate a hash and its first 10 bytes
92
+ * are used for the first part of the data key of keyType Mapping
93
+ * @param addr used for the last part of the data key of keyType Mapping
94
+ */
64
95
  function generateMappingKey(string memory firstWord, address addr)
65
96
  internal
66
97
  pure
@@ -77,15 +108,30 @@ library LSP2Utils {
77
108
  return bytes32(temporaryBytes);
78
109
  }
79
110
 
80
- function generateMappingKey(bytes12 keyPrefix, bytes20 bytes20Value)
111
+ /**
112
+ * @dev Generate a data key of keyType Mapping
113
+ * <bytes10keyPrefix>:<bytes2(0)>:<bytes20Value>
114
+ * @param keyPrefix First part of the data key of keyType Mapping
115
+ * @param bytes20Value Second part of the data key of keyType Mapping
116
+ */
117
+ function generateMappingKey(bytes10 keyPrefix, bytes20 bytes20Value)
81
118
  internal
82
119
  pure
83
120
  returns (bytes32)
84
121
  {
85
- bytes memory generatedKey = bytes.concat(keyPrefix, bytes20Value);
122
+ bytes memory generatedKey = bytes.concat(keyPrefix, bytes2(0), bytes20Value);
86
123
  return bytes32(generatedKey);
87
124
  }
88
125
 
126
+ /**
127
+ * @dev Generate a data key of keyType MappingWithGrouping by using two strings and an address
128
+ * <bytes6(keccak256(firstWord))>:<bytes4(keccak256(secondWord))>:<bytes2(0)>:<bytes20(addr)>
129
+ * @param firstWord Used to generate a hash and its first 6 bytes
130
+ * are used for the first part of the data key of keyType MappingWithGrouping
131
+ * @param secondWord Used to generate a hash and its first 4 bytes
132
+ * are used for the second part of the data key of keyType MappingWithGrouping
133
+ * @param addr Used for the last part of the data key of keyType MappingWithGrouping
134
+ */
89
135
  function generateMappingWithGroupingKey(
90
136
  string memory firstWord,
91
137
  string memory secondWord,
@@ -104,15 +150,27 @@ library LSP2Utils {
104
150
  return bytes32(temporaryBytes);
105
151
  }
106
152
 
107
- function generateMappingWithGroupingKey(bytes12 keyPrefix, bytes20 bytes20Value)
153
+ /**
154
+ * @dev Generate a data key of keyType MappingWithGrouping
155
+ * <bytes10keyPrefix>:<bytes2(0)>:<bytes20Value>
156
+ * @param keyPrefix Used for the first part of the data key of keyType MappingWithGrouping
157
+ * @param bytes20Value Used for the first last of the data key of keyType MappingWithGrouping
158
+ */
159
+ function generateMappingWithGroupingKey(bytes10 keyPrefix, bytes20 bytes20Value)
108
160
  internal
109
161
  pure
110
162
  returns (bytes32)
111
163
  {
112
- bytes memory generatedKey = bytes.concat(keyPrefix, bytes20Value);
164
+ bytes memory generatedKey = bytes.concat(keyPrefix, bytes2(0), bytes20Value);
113
165
  return bytes32(generatedKey);
114
166
  }
115
167
 
168
+ /**
169
+ * @dev Generate a JSONURL valueContent
170
+ * @param hashFunction The function used to hash the JSON file
171
+ * @param json Bytes value of the JSON file
172
+ * @param url The URL where the JSON file is hosted
173
+ */
116
174
  function generateJSONURLValue(
117
175
  string memory hashFunction,
118
176
  string memory json,
@@ -124,6 +182,12 @@ library LSP2Utils {
124
182
  key = abi.encodePacked(bytes4(hashFunctionDigest), jsonDigest, url);
125
183
  }
126
184
 
185
+ /**
186
+ * @dev Generate a ASSETURL valueContent
187
+ * @param hashFunction The function used to hash the JSON file
188
+ * @param assetBytes Bytes value of the JSON file
189
+ * @param url The URL where the JSON file is hosted
190
+ */
127
191
  function generateASSETURLValue(
128
192
  string memory hashFunction,
129
193
  string memory assetBytes,
@@ -135,6 +199,10 @@ library LSP2Utils {
135
199
  key = abi.encodePacked(bytes4(hashFunctionDigest), jsonDigest, url);
136
200
  }
137
201
 
202
+ /**
203
+ * Verifing if `data` is an encoded array
204
+ * @param data The value that is to be verified
205
+ */
138
206
  function isEncodedArray(bytes memory data) internal pure returns (bool) {
139
207
  uint256 nbOfBytes = data.length;
140
208
 
@@ -157,6 +225,10 @@ library LSP2Utils {
157
225
  return true;
158
226
  }
159
227
 
228
+ /**
229
+ * Verifing if `data` is an encoded array of addresses (address[])
230
+ * @param data The value that is to be verified
231
+ */
160
232
  function isEncodedArrayOfAddresses(bytes memory data) internal pure returns (bool) {
161
233
  if (!isEncodedArray(data)) return false;
162
234
 
@@ -165,7 +237,7 @@ library LSP2Utils {
165
237
 
166
238
  uint256 pointer = offset + 32;
167
239
 
168
- for (uint256 ii = 0; ii < arrayLength; ii++) {
240
+ for (uint256 ii = 0; ii < arrayLength; ii = uncheckedIncrement(ii)) {
169
241
  bytes32 key = data.toBytes32(pointer);
170
242
 
171
243
  // check that the leading bytes are zero bytes "00"
@@ -179,6 +251,10 @@ library LSP2Utils {
179
251
  return true;
180
252
  }
181
253
 
254
+ /**
255
+ * @dev verify that `data` is an array of bytes4 (bytes4[]) encoded according to the Solidity ABI specs.
256
+ * @param data The value that is to be verified
257
+ */
182
258
  function isBytes4EncodedArray(bytes memory data) internal pure returns (bool) {
183
259
  if (!isEncodedArray(data)) return false;
184
260
 
@@ -186,7 +262,7 @@ library LSP2Utils {
186
262
  uint256 arrayLength = data.toUint256(offset);
187
263
  uint256 pointer = offset + 32;
188
264
 
189
- for (uint256 ii = 0; ii < arrayLength; ii++) {
265
+ for (uint256 ii = 0; ii < arrayLength; ii = uncheckedIncrement(ii)) {
190
266
  bytes32 key = data.toBytes32(pointer);
191
267
 
192
268
  // check that the trailing bytes are zero bytes "00"
@@ -198,4 +274,14 @@ library LSP2Utils {
198
274
 
199
275
  return true;
200
276
  }
277
+
278
+ /**
279
+ * @dev Will return unchecked incremented uint256
280
+ * can be used to save gas when iterating over loops
281
+ */
282
+ function uncheckedIncrement(uint256 i) internal pure returns (uint256) {
283
+ unchecked {
284
+ return i + 1;
285
+ }
286
+ }
201
287
  }
@@ -4,6 +4,9 @@ pragma solidity ^0.8.0;
4
4
  // modules
5
5
  import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
6
6
 
7
+ // libraries
8
+ import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
9
+
7
10
  // constants
8
11
  import "./LSP4Constants.sol";
9
12
 
@@ -35,16 +38,22 @@ abstract contract LSP4DigitalAssetMetadata is ERC725Y {
35
38
  }
36
39
 
37
40
  /**
38
- * @dev the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed via this function
39
- * once the digital asset contract has been deployed
41
+ * @dev The ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed
42
+ * via this function once the digital asset contract has been deployed.
43
+ *
44
+ * @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
40
45
  */
41
- function _setData(bytes32 key, bytes memory value) internal virtual override {
42
- if (key == _LSP4_TOKEN_NAME_KEY) {
46
+ function _setData(bytes32 dataKey, bytes memory dataValue) internal virtual override {
47
+ if (dataKey == _LSP4_TOKEN_NAME_KEY) {
43
48
  revert LSP4TokenNameNotEditable();
44
- } else if (key == _LSP4_TOKEN_SYMBOL_KEY) {
49
+ } else if (dataKey == _LSP4_TOKEN_SYMBOL_KEY) {
45
50
  revert LSP4TokenSymbolNotEditable();
46
51
  } else {
47
- super._setData(key, value);
52
+ store[dataKey] = dataValue;
53
+ emit DataChanged(
54
+ dataKey,
55
+ dataValue.length <= 256 ? dataValue : BytesLib.slice(dataValue, 0, 256)
56
+ );
48
57
  }
49
58
  }
50
59
  }
@@ -5,6 +5,9 @@ pragma solidity ^0.8.0;
5
5
  import {ERC725YInitAbstract} from "@erc725/smart-contracts/contracts/ERC725YInitAbstract.sol";
6
6
  import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
7
7
 
8
+ // libraries
9
+ import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
10
+
8
11
  // constants
9
12
  import "./LSP4Constants.sol";
10
13
 
@@ -32,16 +35,22 @@ abstract contract LSP4DigitalAssetMetadataInitAbstract is ERC725YInitAbstract {
32
35
  }
33
36
 
34
37
  /**
35
- * @dev the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed via this function
36
- * once the digital asset contract has been deployed
38
+ * @dev the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed
39
+ * via this function once the digital asset contract has been deployed.
40
+ *
41
+ * @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
37
42
  */
38
- function _setData(bytes32 key, bytes memory value) internal virtual override {
39
- if (key == _LSP4_TOKEN_NAME_KEY) {
43
+ function _setData(bytes32 dataKey, bytes memory dataValue) internal virtual override {
44
+ if (dataKey == _LSP4_TOKEN_NAME_KEY) {
40
45
  revert LSP4TokenNameNotEditable();
41
- } else if (key == _LSP4_TOKEN_SYMBOL_KEY) {
46
+ } else if (dataKey == _LSP4_TOKEN_SYMBOL_KEY) {
42
47
  revert LSP4TokenSymbolNotEditable();
43
48
  } else {
44
- super._setData(key, value);
49
+ store[dataKey] = dataValue;
50
+ emit DataChanged(
51
+ dataKey,
52
+ dataValue.length <= 256 ? dataValue : BytesLib.slice(dataValue, 0, 256)
53
+ );
45
54
  }
46
55
  }
47
56
  }
@@ -6,5 +6,5 @@ pragma solidity ^0.8.0;
6
6
  // keccak256('LSP5ReceivedAssets[]')
7
7
  bytes32 constant _LSP5_RECEIVED_ASSETS_ARRAY_KEY = 0x6460ee3c0aac563ccbf76d6e1d07bada78e3a9514e6382b736ed3f478ab7b90b;
8
8
 
9
- // bytes10(keccak256('LSP5ReceivedAssetsMap')) + bytes2(0)
10
- bytes12 constant _LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX = 0x812c4334633eb816c80d0000;
9
+ // bytes10(keccak256('LSP5ReceivedAssetsMap'))
10
+ bytes10 constant _LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX = 0x812c4334633eb816c80d;
@@ -108,7 +108,7 @@ library LSP5Utils {
108
108
  function removeMapAndArrayKey(
109
109
  IERC725Y account,
110
110
  bytes32 arrayLengthKey,
111
- bytes12 mapKeyPrefix,
111
+ bytes10 mapKeyPrefix,
112
112
  bytes32 mapKeyToRemove,
113
113
  bytes memory mapValue
114
114
  ) internal view returns (bytes32[] memory keys, bytes[] memory values) {
@@ -142,7 +142,7 @@ library LSP5Utils {
142
142
  keys[2] = arrayElementKeyToRemove;
143
143
  values[2] = "";
144
144
 
145
- // Swapping last element in ArrayKey with the elemnt in ArrayKey to remove || {Swap and pop} method;
145
+ // Swapping last element in ArrayKey with the element in ArrayKey to remove || {Swap and pop} method;
146
146
  // check https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/EnumerableSet.sol#L80
147
147
  } else {
148
148
  /**
@@ -209,7 +209,7 @@ library LSP5Utils {
209
209
  function removeMapAndArrayKeyViaKeyManager(
210
210
  IERC725Y account,
211
211
  bytes32 arrayLengthKey,
212
- bytes12 mapKeyPrefix,
212
+ bytes10 mapKeyPrefix,
213
213
  bytes32 mapKeyToRemove,
214
214
  bytes memory mapValue,
215
215
  address keyManager
@@ -33,7 +33,7 @@ interface ILSP6KeyManager is
33
33
  function getNonce(address from, uint256 channelId) external view returns (uint256);
34
34
 
35
35
  /**
36
- * @notice execute the following payload on the ERC725Account: `_calldata`
36
+ * @notice execute the following payload on the ERC725Account: `payload`
37
37
  * @dev the ERC725Account will return some data on successful call, or revert on failure
38
38
  * @param payload the payload to execute. Obtained in web3 via encodeABI()
39
39
  * @return the data being returned by the ERC725 Account
@@ -17,20 +17,20 @@ bytes16 constant _LSP6KEY_ADDRESSPERMISSIONS_ARRAY_PREFIX = 0xdf30dba06db6a30e65
17
17
  // AddressPermissions:...
18
18
  bytes6 constant _LSP6KEY_ADDRESSPERMISSIONS_PREFIX = 0x4b80742de2bf;
19
19
 
20
- // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('Permissions')) + bytes2(0)
21
- bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX = 0x4b80742de2bf82acb3630000; // AddressPermissions:Permissions:<address> --> bytes32
20
+ // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('Permissions'))
21
+ bytes10 constant _LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX = 0x4b80742de2bf82acb363; // AddressPermissions:Permissions:<address> --> bytes32
22
22
 
23
- // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedAddresses')) + bytes2(0)
24
- bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDADDRESSES_PREFIX = 0x4b80742de2bfc6dd6b3c0000; // AddressPermissions:AllowedAddresses:<address> --> address[]
23
+ // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedAddresses'))
24
+ bytes10 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDADDRESSES_PREFIX = 0x4b80742de2bfc6dd6b3c; // AddressPermissions:AllowedAddresses:<address> --> address[]
25
25
 
26
- // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedFunctions')) + bytes2(0)
27
- bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDFUNCTIONS_PREFIX = 0x4b80742de2bf8efea1e80000; // AddressPermissions:AllowedFunctions:<address> --> bytes4[]
26
+ // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedFunctions'))
27
+ bytes10 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDFUNCTIONS_PREFIX = 0x4b80742de2bf8efea1e8; // AddressPermissions:AllowedFunctions:<address> --> bytes4[]
28
28
 
29
- // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedStandards')) + bytes2(0)
30
- bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDSTANDARDS_PREFIX = 0x4b80742de2bf3efa94a30000; // AddressPermissions:AllowedStandards:<address> --> bytes4[]
29
+ // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedStandards'))
30
+ bytes10 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDSTANDARDS_PREFIX = 0x4b80742de2bf3efa94a3; // AddressPermissions:AllowedStandards:<address> --> bytes4[]
31
31
 
32
- // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedERC725YKeys')) + bytes2(0)
33
- bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDERC725YKEYS_PREFIX = 0x4b80742de2bf90b8b4850000; // AddressPermissions:AllowedERC725YKeys:<address> --> bytes32[]
32
+ // bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedERC725YKeys'))
33
+ bytes10 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDERC725YKEYS_PREFIX = 0x4b80742de2bf90b8b485; // AddressPermissions:AllowedERC725YKeys:<address> --> bytes32[]
34
34
 
35
35
  // DEFAULT PERMISSIONS VALUES
36
36
  bytes32 constant _PERMISSION_CHANGEOWNER = 0x0000000000000000000000000000000000000000000000000000000000000001;
@@ -43,23 +43,18 @@ bytes32 constant _PERMISSION_DELEGATECALL = 0x0000000000000000000000000000
43
43
  bytes32 constant _PERMISSION_DEPLOY = 0x0000000000000000000000000000000000000000000000000000000000000080;
44
44
  bytes32 constant _PERMISSION_TRANSFERVALUE = 0x0000000000000000000000000000000000000000000000000000000000000100;
45
45
  bytes32 constant _PERMISSION_SIGN = 0x0000000000000000000000000000000000000000000000000000000000000200;
46
+ bytes32 constant _PERMISSION_ENCRYPT = 0x0000000000000000000000000000000000000000000000000000000000000400;
46
47
 
47
48
  // SUPER PERMISSIONS
48
49
  // -----
49
50
  // allow to not check for AddressPermissions:AllowedERC725YKeys:...
50
- bytes32 constant _PERMISSION_SUPER_SETDATA = 0x0000000000000000000000000000000000000000000000000000000000000400;
51
+ bytes32 constant _PERMISSION_SUPER_SETDATA = 0x0000000000000000000000000000000000000000000000000000000000000800;
51
52
 
52
53
  // allow to not check for:
53
54
  // - AddressPermissions:AllowedAddress:...
54
55
  // - AddressPermissions:AllowedStandards:...
55
56
  // - AddressPermissions:AllowedFunctions:...
56
- bytes32 constant _PERMISSION_SUPER_TRANSFERVALUE = 0x0000000000000000000000000000000000000000000000000000000000000800;
57
- bytes32 constant _PERMISSION_SUPER_CALL = 0x0000000000000000000000000000000000000000000000000000000000001000;
58
- bytes32 constant _PERMISSION_SUPER_STATICCALL = 0x0000000000000000000000000000000000000000000000000000000000002000;
59
- bytes32 constant _PERMISSION_SUPER_DELEGATECALL = 0x0000000000000000000000000000000000000000000000000000000000004000;
60
-
61
-
62
- /// @dev see IERC725Y interface
63
- /// https://github.com/ERC725Alliance/ERC725/blob/main/implementations/contracts/interfaces/IERC725Y.sol
64
- bytes4 constant setDataSingleSelector = bytes4(keccak256("setData(bytes32,bytes)"));
65
- bytes4 constant setDataMultipleSelector = bytes4(keccak256("setData(bytes32[],bytes[])"));
57
+ bytes32 constant _PERMISSION_SUPER_TRANSFERVALUE = 0x0000000000000000000000000000000000000000000000000000000000001000;
58
+ bytes32 constant _PERMISSION_SUPER_CALL = 0x0000000000000000000000000000000000000000000000000000000000002000;
59
+ bytes32 constant _PERMISSION_SUPER_STATICCALL = 0x0000000000000000000000000000000000000000000000000000000000004000;
60
+ bytes32 constant _PERMISSION_SUPER_DELEGATECALL = 0x0000000000000000000000000000000000000000000000000000000000008000;
@@ -45,6 +45,14 @@ error NotAllowedFunction(address from, bytes4 disallowedFunction);
45
45
  */
46
46
  error NotAllowedERC725YKey(address from, bytes32 disallowedKey);
47
47
 
48
+ /**
49
+ * @dev reverts when `dataKey` is a bytes32 that does not adhere to any of the
50
+ * permission data keys specified by the LSP6 standard
51
+ *
52
+ * @param dataKey the dataKey that does not match with any of the standard LSP6 permission data keys
53
+ */
54
+ error NotRecognisedPermissionKey(bytes32 dataKey);
55
+
48
56
  /**
49
57
  * @dev reverts when the address provided as a target (= account) linked to this KeyManager is invalid
50
58
  * e.g. address(0)
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.6;
2
+ pragma solidity ^0.8.5;
3
3
 
4
4
  // modules
5
5
  import {LSP6KeyManagerCore} from "./LSP6KeyManagerCore.sol";