@lukso/lsp-smart-contracts 0.8.0 → 0.9.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 (81) hide show
  1. package/CONTRIBUTING.md +8 -0
  2. package/README.md +34 -21
  3. package/artifacts/LSP0ERC725Account.json +51 -5
  4. package/artifacts/LSP0ERC725AccountInit.json +51 -5
  5. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  6. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  7. package/artifacts/LSP16UniversalFactory.json +31 -2
  8. package/artifacts/LSP1UniversalReceiverDelegateUP.json +19 -35
  9. package/artifacts/LSP1UniversalReceiverDelegateVault.json +13 -13
  10. package/artifacts/LSP4Compatibility.json +7 -2
  11. package/artifacts/LSP4DigitalAssetMetadata.json +7 -2
  12. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +7 -2
  13. package/artifacts/LSP6KeyManager.json +91 -6
  14. package/artifacts/LSP6KeyManagerInit.json +103 -18
  15. package/artifacts/LSP7CappedSupply.json +12 -2
  16. package/artifacts/LSP7CappedSupplyInitAbstract.json +12 -2
  17. package/artifacts/LSP7CompatibleERC20.json +12 -2
  18. package/artifacts/LSP7CompatibleERC20InitAbstract.json +12 -2
  19. package/artifacts/LSP7CompatibleERC20Mintable.json +14 -4
  20. package/artifacts/LSP7CompatibleERC20MintableInit.json +14 -4
  21. package/artifacts/LSP7DigitalAsset.json +12 -2
  22. package/artifacts/LSP7DigitalAssetInitAbstract.json +12 -2
  23. package/artifacts/LSP7Mintable.json +14 -4
  24. package/artifacts/LSP7MintableInit.json +14 -4
  25. package/artifacts/LSP8CappedSupply.json +12 -2
  26. package/artifacts/LSP8CappedSupplyInitAbstract.json +12 -2
  27. package/artifacts/LSP8CompatibleERC721.json +12 -2
  28. package/artifacts/LSP8CompatibleERC721InitAbstract.json +12 -2
  29. package/artifacts/LSP8CompatibleERC721Mintable.json +14 -4
  30. package/artifacts/LSP8CompatibleERC721MintableInit.json +14 -4
  31. package/artifacts/LSP8IdentifiableDigitalAsset.json +12 -2
  32. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +12 -2
  33. package/artifacts/LSP8Mintable.json +14 -4
  34. package/artifacts/LSP8MintableInit.json +14 -4
  35. package/artifacts/LSP9Vault.json +29 -5
  36. package/artifacts/LSP9VaultInit.json +29 -5
  37. package/artifacts/UniversalProfile.json +51 -5
  38. package/artifacts/UniversalProfileInit.json +51 -5
  39. package/common/constants.d.ts +461 -0
  40. package/common/constants.js +789 -0
  41. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +27 -0
  42. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  43. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +353 -145
  44. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -1
  45. package/contracts/LSP0ERC725Account/LSP0Utils.sol +50 -0
  46. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +48 -54
  47. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +5 -6
  48. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +27 -4
  49. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +36 -77
  50. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +8 -8
  51. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +50 -57
  52. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +18 -8
  53. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +12 -0
  54. package/contracts/LSP20CallVerification/ILSP20CallVerification.sol +30 -0
  55. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +74 -0
  56. package/contracts/LSP20CallVerification/LSP20Errors.sol +15 -0
  57. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +7 -7
  58. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +50 -56
  59. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +1 -1
  60. package/contracts/LSP6KeyManager/LSP6Constants.sol +8 -2
  61. package/contracts/LSP6KeyManager/LSP6Errors.sol +18 -1
  62. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +126 -745
  63. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +407 -0
  64. package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +25 -0
  65. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +633 -0
  66. package/contracts/LSP6KeyManager/LSP6Utils.sol +60 -15
  67. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +14 -23
  68. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +5 -0
  69. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +5 -0
  70. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +19 -30
  71. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +1 -3
  72. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +1 -3
  73. package/contracts/LSP9Vault/ILSP9Vault.sol +19 -0
  74. package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
  75. package/contracts/LSP9Vault/LSP9Vault.sol +11 -2
  76. package/contracts/LSP9Vault/LSP9VaultCore.sol +166 -83
  77. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -2
  78. package/module/constants.d.ts +461 -0
  79. package/module/constants.js +786 -0
  80. package/package.json +30 -6
  81. package/constants.js +0 -856
@@ -10,7 +10,10 @@ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
10
10
 
11
11
  // constants
12
12
  import {SETDATA_ARRAY_SELECTOR} from "@erc725/smart-contracts/contracts/constants.sol";
13
- import "../LSP6KeyManager/LSP6Constants.sol";
13
+ import "./LSP6Constants.sol";
14
+
15
+ // errors
16
+ import {NotAuthorised} from "./LSP6Errors.sol";
14
17
 
15
18
  library LSP6Utils {
16
19
  using LSP2Utils for bytes12;
@@ -104,8 +107,8 @@ library LSP6Utils {
104
107
  )
105
108
  )
106
109
  );
107
- // each entries in the allowedCalls (compact) array must be 28 bytes long
108
- if (elementLength != 28) return false;
110
+ // each entries in the allowedCalls (compact) array must be 32 bytes long
111
+ if (elementLength != 32) return false;
109
112
  pointer += elementLength + 2;
110
113
  }
111
114
  if (pointer == allowedCallsCompacted.length) return true;
@@ -159,41 +162,83 @@ library LSP6Utils {
159
162
  /**
160
163
  * @dev combine multiple permissions into a single bytes32
161
164
  * Make sure that the sum of the values of the input array is less than 2^256-1 to avoid overflow.
162
- * @param _permissions the array of permissions to combine
165
+ * @param permissions the array of permissions to combine
163
166
  * @return a bytes32 containing the combined permissions
164
167
  */
165
- function combinePermissions(bytes32[] memory _permissions) internal pure returns (bytes32) {
168
+ function combinePermissions(bytes32[] memory permissions) internal pure returns (bytes32) {
166
169
  uint256 result = 0;
167
- for (uint256 i = 0; i < _permissions.length; i++) {
168
- result += uint256(_permissions[i]);
170
+ for (uint256 i = 0; i < permissions.length; i++) {
171
+ result += uint256(permissions[i]);
169
172
  }
170
173
  return bytes32(result);
171
174
  }
172
175
 
173
- function generatePermissionsKeysForController(
174
- IERC725Y _account,
175
- address _address,
176
+ /**
177
+ * @dev Generate a new set of 3 x LSP6 permission data keys to add a new `controller` on `account`
178
+ * @param account the ERC725Y contract to add the controller into (used to fetch the `LSP6Permissions[]` length)
179
+ * @param controller the address of the controller to grant permissions to
180
+ * @param permissions the BitArray of permissions to grant to the controller
181
+ * @return keys an array of 3 x data keys containing:
182
+ * - keys[0] = `AddressPermissions[]` (array length)
183
+ * - keys[1] = `AddressPermissions[index]` (where to store the controller address)
184
+ * - keys[2] = `AddressPermissions:Permissions:<controller>`
185
+ *
186
+ * @return values : an array of 3 x data values containing:
187
+ * - values[0] = the new array length of `AddressPermissions[]`
188
+ * - values[1] = the address of the controller
189
+ * - values[2] = the `permissions` passed as param
190
+ */
191
+ function generateNewPermissionsKeys(
192
+ IERC725Y account,
193
+ address controller,
176
194
  bytes32 permissions
177
195
  ) internal view returns (bytes32[] memory keys, bytes[] memory values) {
178
196
  keys = new bytes32[](3);
179
197
  values = new bytes[](3);
180
198
 
181
- uint256 arrayLength = uint256(bytes32(_account.getData(_LSP6KEY_ADDRESSPERMISSIONS_ARRAY)));
182
- uint256 newArrayLength = arrayLength + 1;
199
+ uint128 arrayLength = uint128(bytes16(account.getData(_LSP6KEY_ADDRESSPERMISSIONS_ARRAY)));
200
+ uint128 newArrayLength = arrayLength + 1;
183
201
 
184
202
  keys[0] = _LSP6KEY_ADDRESSPERMISSIONS_ARRAY;
185
203
  values[0] = abi.encodePacked(newArrayLength);
186
204
 
187
205
  keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(
188
206
  _LSP6KEY_ADDRESSPERMISSIONS_ARRAY,
189
- uint128(arrayLength)
207
+ arrayLength
190
208
  );
191
- values[1] = abi.encodePacked(_address);
209
+ values[1] = abi.encodePacked(controller);
192
210
 
193
211
  keys[2] = LSP2Utils.generateMappingWithGroupingKey(
194
212
  _LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX,
195
- bytes20(_address)
213
+ bytes20(controller)
196
214
  );
197
215
  values[2] = abi.encodePacked(permissions);
198
216
  }
217
+
218
+ /**
219
+ * @dev returns the name of the permission as a string
220
+ */
221
+ function getPermissionName(bytes32 permission)
222
+ internal
223
+ pure
224
+ returns (string memory errorMessage)
225
+ {
226
+ if (permission == _PERMISSION_CHANGEOWNER) return "TRANSFEROWNERSHIP";
227
+ if (permission == _PERMISSION_EDITPERMISSIONS) return "EDITPERMISSIONS";
228
+ if (permission == _PERMISSION_ADDCONTROLLER) return "ADDCONTROLLER";
229
+ if (permission == _PERMISSION_ADDEXTENSIONS) return "ADDEXTENSIONS";
230
+ if (permission == _PERMISSION_CHANGEEXTENSIONS) return "CHANGEEXTENSIONS";
231
+ if (permission == _PERMISSION_ADDUNIVERSALRECEIVERDELEGATE)
232
+ return "ADDUNIVERSALRECEIVERDELEGATE";
233
+ if (permission == _PERMISSION_CHANGEUNIVERSALRECEIVERDELEGATE)
234
+ return "CHANGEUNIVERSALRECEIVERDELEGATE";
235
+ if (permission == _PERMISSION_REENTRANCY) return "REENTRANCY";
236
+ if (permission == _PERMISSION_SETDATA) return "SETDATA";
237
+ if (permission == _PERMISSION_CALL) return "CALL";
238
+ if (permission == _PERMISSION_STATICCALL) return "STATICCALL";
239
+ if (permission == _PERMISSION_DELEGATECALL) return "DELEGATECALL";
240
+ if (permission == _PERMISSION_DEPLOY) return "DEPLOY";
241
+ if (permission == _PERMISSION_TRANSFERVALUE) return "TRANSFERVALUE";
242
+ if (permission == _PERMISSION_SIGN) return "SIGN";
243
+ }
199
244
  }
@@ -6,7 +6,6 @@ import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalRec
6
6
  import {ILSP7DigitalAsset} from "./ILSP7DigitalAsset.sol";
7
7
 
8
8
  // libraries
9
- import {Address} from "@openzeppelin/contracts/utils/Address.sol";
10
9
  import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
11
10
  import {GasLib} from "../Utils/GasLib.sol";
12
11
 
@@ -30,8 +29,6 @@ import {_TYPEID_LSP7_TOKENSSENDER, _TYPEID_LSP7_TOKENSRECIPIENT} from "./LSP7Con
30
29
  * This contract implement the core logic of the functions for the {ILSP7DigitalAsset} interface.
31
30
  */
32
31
  abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
33
- using Address for address;
34
-
35
32
  // --- Storage
36
33
 
37
34
  bool internal _isNonDivisible;
@@ -186,9 +183,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
186
183
  revert LSP7CannotUseAddressZeroAsOperator();
187
184
  }
188
185
 
189
- // tokenOwner is always their own operator, no update required
190
186
  if (operator == tokenOwner) {
191
- return;
187
+ revert LSP7TokenOwnerCannotBeOperator();
192
188
  }
193
189
 
194
190
  _operatorAuthorizedAmount[tokenOwner][operator] = amount;
@@ -230,7 +226,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
230
226
 
231
227
  emit Transfer(operator, address(0), to, amount, allowNonLSP1Recipient, data);
232
228
 
233
- _notifyTokenReceiver(address(0), to, amount, allowNonLSP1Recipient, data);
229
+ bytes memory lsp1Data = abi.encodePacked(address(0), to, amount, data);
230
+ _notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
234
231
  }
235
232
 
236
233
  /**
@@ -277,7 +274,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
277
274
 
278
275
  emit Transfer(operator, from, address(0), amount, false, data);
279
276
 
280
- _notifyTokenSender(from, address(0), amount, data);
277
+ bytes memory lsp1Data = abi.encodePacked(from, address(0), amount, data);
278
+ _notifyTokenSender(from, lsp1Data);
281
279
  }
282
280
 
283
281
  /**
@@ -318,8 +316,10 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
318
316
 
319
317
  emit Transfer(operator, from, to, amount, allowNonLSP1Recipient, data);
320
318
 
321
- _notifyTokenSender(from, to, amount, data);
322
- _notifyTokenReceiver(from, to, amount, allowNonLSP1Recipient, data);
319
+ bytes memory lsp1Data = abi.encodePacked(from, to, amount, data);
320
+
321
+ _notifyTokenSender(from, lsp1Data);
322
+ _notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
323
323
  }
324
324
 
325
325
  /**
@@ -344,15 +344,9 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
344
344
  * @dev An attempt is made to notify the token sender about the `amount` tokens changing owners using
345
345
  * LSP1 interface.
346
346
  */
347
- function _notifyTokenSender(
348
- address from,
349
- address to,
350
- uint256 amount,
351
- bytes memory data
352
- ) internal virtual {
347
+ function _notifyTokenSender(address from, bytes memory lsp1Data) internal virtual {
353
348
  if (ERC165Checker.supportsERC165InterfaceUnchecked(from, _INTERFACEID_LSP1)) {
354
- bytes memory packedData = abi.encodePacked(from, to, amount, data);
355
- ILSP1UniversalReceiver(from).universalReceiver(_TYPEID_LSP7_TOKENSSENDER, packedData);
349
+ ILSP1UniversalReceiver(from).universalReceiver(_TYPEID_LSP7_TOKENSSENDER, lsp1Data);
356
350
  }
357
351
  }
358
352
 
@@ -363,17 +357,14 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
363
357
  * The receiver may revert when the token being sent is not wanted.
364
358
  */
365
359
  function _notifyTokenReceiver(
366
- address from,
367
360
  address to,
368
- uint256 amount,
369
361
  bool allowNonLSP1Recipient,
370
- bytes memory data
362
+ bytes memory lsp1Data
371
363
  ) internal virtual {
372
364
  if (ERC165Checker.supportsERC165InterfaceUnchecked(to, _INTERFACEID_LSP1)) {
373
- bytes memory packedData = abi.encodePacked(from, to, amount, data);
374
- ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP7_TOKENSRECIPIENT, packedData);
365
+ ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP7_TOKENSRECIPIENT, lsp1Data);
375
366
  } else if (!allowNonLSP1Recipient) {
376
- if (to.isContract()) {
367
+ if (to.code.length > 0) {
377
368
  revert LSP7NotifyTokenReceiverContractMissingLSP1Interface(to);
378
369
  } else {
379
370
  revert LSP7NotifyTokenReceiverIsEOA(to);
@@ -50,3 +50,8 @@ error LSP7NotifyTokenReceiverContractMissingLSP1Interface(address tokenReceiver)
50
50
  * when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`.
51
51
  */
52
52
  error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
53
+
54
+ /**
55
+ * @dev reverts when trying to authorize or revoke the token's owner as an operator.
56
+ */
57
+ error LSP7TokenOwnerCannotBeOperator();
@@ -64,3 +64,8 @@ error LSP8NotifyTokenReceiverContractMissingLSP1Interface(address tokenReceiver)
64
64
  * when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`.
65
65
  */
66
66
  error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver);
67
+
68
+ /**
69
+ * @dev reverts when trying to authorize or revoke the token's owner as an operator.
70
+ */
71
+ error LSP8TokenOwnerCannotBeOperator();
@@ -6,7 +6,6 @@ import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalRec
6
6
  import {ILSP8IdentifiableDigitalAsset} from "./ILSP8IdentifiableDigitalAsset.sol";
7
7
 
8
8
  // libraries
9
- import {Address} from "@openzeppelin/contracts/utils/Address.sol";
10
9
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
11
10
  import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
12
11
  import {GasLib} from "../Utils/GasLib.sol";
@@ -30,7 +29,6 @@ import {_TYPEID_LSP8_TOKENSSENDER, _TYPEID_LSP8_TOKENSRECIPIENT} from "./LSP8Con
30
29
  abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAsset {
31
30
  using EnumerableSet for EnumerableSet.AddressSet;
32
31
  using EnumerableSet for EnumerableSet.Bytes32Set;
33
- using Address for address;
34
32
 
35
33
  // --- Storage
36
34
 
@@ -92,19 +90,17 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
92
90
  */
93
91
  function authorizeOperator(address operator, bytes32 tokenId) public virtual {
94
92
  address tokenOwner = tokenOwnerOf(tokenId);
95
- address caller = msg.sender;
96
93
 
97
- if (tokenOwner != caller) {
98
- revert LSP8NotTokenOwner(tokenOwner, tokenId, caller);
94
+ if (tokenOwner != msg.sender) {
95
+ revert LSP8NotTokenOwner(tokenOwner, tokenId, msg.sender);
99
96
  }
100
97
 
101
98
  if (operator == address(0)) {
102
99
  revert LSP8CannotUseAddressZeroAsOperator();
103
100
  }
104
101
 
105
- // tokenOwner is always their own operator, no update required
106
102
  if (tokenOwner == operator) {
107
- return;
103
+ revert LSP8TokenOwnerCannotBeOperator();
108
104
  }
109
105
 
110
106
  bool isAdded = _operators[tokenId].add(operator);
@@ -118,19 +114,17 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
118
114
  */
119
115
  function revokeOperator(address operator, bytes32 tokenId) public virtual {
120
116
  address tokenOwner = tokenOwnerOf(tokenId);
121
- address caller = msg.sender;
122
117
 
123
- if (tokenOwner != caller) {
124
- revert LSP8NotTokenOwner(tokenOwner, tokenId, caller);
118
+ if (tokenOwner != msg.sender) {
119
+ revert LSP8NotTokenOwner(tokenOwner, tokenId, msg.sender);
125
120
  }
126
121
 
127
122
  if (operator == address(0)) {
128
123
  revert LSP8CannotUseAddressZeroAsOperator();
129
124
  }
130
125
 
131
- // tokenOwner is always their own operator, no update required
132
126
  if (tokenOwner == operator) {
133
- return;
127
+ revert LSP8TokenOwnerCannotBeOperator();
134
128
  }
135
129
 
136
130
  _revokeOperator(operator, tokenOwner, tokenId);
@@ -303,7 +297,8 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
303
297
 
304
298
  emit Transfer(operator, address(0), to, tokenId, allowNonLSP1Recipient, data);
305
299
 
306
- _notifyTokenReceiver(address(0), to, tokenId, allowNonLSP1Recipient, data);
300
+ bytes memory lsp1Data = abi.encodePacked(address(0), to, tokenId, data);
301
+ _notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
307
302
  }
308
303
 
309
304
  /**
@@ -331,7 +326,8 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
331
326
 
332
327
  emit Transfer(operator, tokenOwner, address(0), tokenId, false, data);
333
328
 
334
- _notifyTokenSender(tokenOwner, address(0), tokenId, data);
329
+ bytes memory lsp1Data = abi.encodePacked(tokenOwner, address(0), tokenId, data);
330
+ _notifyTokenSender(tokenOwner, lsp1Data);
335
331
  }
336
332
 
337
333
  /**
@@ -376,8 +372,10 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
376
372
 
377
373
  emit Transfer(operator, from, to, tokenId, allowNonLSP1Recipient, data);
378
374
 
379
- _notifyTokenSender(from, to, tokenId, data);
380
- _notifyTokenReceiver(from, to, tokenId, allowNonLSP1Recipient, data);
375
+ bytes memory lsp1Data = abi.encodePacked(from, to, tokenId, data);
376
+
377
+ _notifyTokenSender(from, lsp1Data);
378
+ _notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
381
379
  }
382
380
 
383
381
  /**
@@ -402,15 +400,9 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
402
400
  * @dev An attempt is made to notify the token sender about the `tokenId` changing owners using
403
401
  * LSP1 interface.
404
402
  */
405
- function _notifyTokenSender(
406
- address from,
407
- address to,
408
- bytes32 tokenId,
409
- bytes memory data
410
- ) internal virtual {
403
+ function _notifyTokenSender(address from, bytes memory lsp1Data) internal virtual {
411
404
  if (ERC165Checker.supportsERC165InterfaceUnchecked(from, _INTERFACEID_LSP1)) {
412
- bytes memory packedData = abi.encodePacked(from, to, tokenId, data);
413
- ILSP1UniversalReceiver(from).universalReceiver(_TYPEID_LSP8_TOKENSSENDER, packedData);
405
+ ILSP1UniversalReceiver(from).universalReceiver(_TYPEID_LSP8_TOKENSSENDER, lsp1Data);
414
406
  }
415
407
  }
416
408
 
@@ -421,17 +413,14 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
421
413
  * The receiver may revert when the token being sent is not wanted.
422
414
  */
423
415
  function _notifyTokenReceiver(
424
- address from,
425
416
  address to,
426
- bytes32 tokenId,
427
417
  bool allowNonLSP1Recipient,
428
- bytes memory data
418
+ bytes memory lsp1Data
429
419
  ) internal virtual {
430
420
  if (ERC165Checker.supportsERC165InterfaceUnchecked(to, _INTERFACEID_LSP1)) {
431
- bytes memory packedData = abi.encodePacked(from, to, tokenId, data);
432
- ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP8_TOKENSRECIPIENT, packedData);
421
+ ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP8_TOKENSRECIPIENT, lsp1Data);
433
422
  } else if (!allowNonLSP1Recipient) {
434
- if (to.isContract()) {
423
+ if (to.code.length > 0) {
435
424
  revert LSP8NotifyTokenReceiverContractMissingLSP1Interface(to);
436
425
  } else {
437
426
  revert LSP8NotifyTokenReceiverIsEOA(to);
@@ -8,7 +8,6 @@ import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";
8
8
  import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
9
9
 
10
10
  // libraries
11
- import {Address} from "@openzeppelin/contracts/utils/Address.sol";
12
11
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
13
12
  import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
14
13
 
@@ -36,7 +35,6 @@ abstract contract LSP8CompatibleERC721 is
36
35
  LSP4Compatibility,
37
36
  LSP8IdentifiableDigitalAsset
38
37
  {
39
- using Address for address;
40
38
  using EnumerableSet for EnumerableSet.AddressSet;
41
39
 
42
40
  /**
@@ -276,7 +274,7 @@ abstract contract LSP8CompatibleERC721 is
276
274
  uint256 tokenId,
277
275
  bytes memory data
278
276
  ) private returns (bool) {
279
- if (to.isContract()) {
277
+ if (to.code.length > 0) {
280
278
  try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data) returns (
281
279
  bytes4 retval
282
280
  ) {
@@ -8,7 +8,6 @@ import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";
8
8
  import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
9
9
 
10
10
  // libraries
11
- import {Address} from "@openzeppelin/contracts/utils/Address.sol";
12
11
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
13
12
  import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
14
13
 
@@ -36,7 +35,6 @@ abstract contract LSP8CompatibleERC721InitAbstract is
36
35
  LSP8IdentifiableDigitalAssetInitAbstract,
37
36
  LSP4Compatibility
38
37
  {
39
- using Address for address;
40
38
  using EnumerableSet for EnumerableSet.AddressSet;
41
39
 
42
40
  /**
@@ -272,7 +270,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is
272
270
  uint256 tokenId,
273
271
  bytes memory data
274
272
  ) private returns (bool) {
275
- if (to.isContract()) {
273
+ if (to.code.length > 0) {
276
274
  try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data) returns (
277
275
  bytes4 retval
278
276
  ) {
@@ -0,0 +1,19 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.4;
3
+
4
+ // interfaces
5
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
+ import {IERC725X} from "@erc725/smart-contracts/contracts/interfaces/IERC725X.sol";
7
+ import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
8
+ import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
9
+ import {ILSP14Ownable2Step} from "../LSP14Ownable2Step/ILSP14Ownable2Step.sol";
10
+
11
+ /**
12
+ * @title Interface of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
13
+ */
14
+ interface ILSP9Vault is IERC165, IERC725X, IERC725Y, ILSP1UniversalReceiver, ILSP14Ownable2Step {
15
+ /**
16
+ * @dev Receives and executes a batch of function calls on this contract.
17
+ */
18
+ function batchCalls(bytes[] calldata data) external returns (bytes[] memory results);
19
+ }
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_LSP9 = 0x7050cee9;
5
+ bytes4 constant _INTERFACEID_LSP9 = 0x19331ad1;
6
6
 
7
7
  // --- ERC725Y Data Keys
8
8
 
@@ -9,12 +9,16 @@ import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnse
9
9
  import {ERC725} from "@erc725/smart-contracts/contracts/ERC725.sol";
10
10
  import {LSP9VaultCore} from "./LSP9VaultCore.sol";
11
11
 
12
+ // libraries
13
+ import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
14
+
12
15
  // constants
13
16
  import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
14
17
  import {
15
18
  _INTERFACEID_LSP9,
16
19
  _LSP9_SUPPORTED_STANDARDS_KEY,
17
- _LSP9_SUPPORTED_STANDARDS_VALUE
20
+ _LSP9_SUPPORTED_STANDARDS_VALUE,
21
+ _TYPEID_LSP9_OwnershipTransferred_RecipientNotification
18
22
  } from "../LSP9Vault/LSP9Constants.sol";
19
23
 
20
24
  /**
@@ -23,6 +27,8 @@ import {
23
27
  * @dev Could be owned by a UniversalProfile and able to register received asset with UniversalReceiverDelegateVault
24
28
  */
25
29
  contract LSP9Vault is LSP9VaultCore {
30
+ using LSP1Utils for address;
31
+
26
32
  /**
27
33
  * @notice Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key
28
34
  * @param newOwner the owner of the contract
@@ -35,6 +41,9 @@ contract LSP9Vault is LSP9VaultCore {
35
41
  // set key SupportedStandards:LSP9Vault
36
42
  _setData(_LSP9_SUPPORTED_STANDARDS_KEY, _LSP9_SUPPORTED_STANDARDS_VALUE);
37
43
 
38
- _notifyLSP1RecipientOnOwnershipTransferCompletion(newOwner, "");
44
+ newOwner.tryNotifyUniversalReceiver(
45
+ _TYPEID_LSP9_OwnershipTransferred_RecipientNotification,
46
+ ""
47
+ );
39
48
  }
40
49
  }