@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
package/constants.js CHANGED
@@ -17,14 +17,14 @@ const INTERFACE_IDS = {
17
17
  ERC1155: '0xd9b67a26',
18
18
  ERC725X: '0x44c028fe',
19
19
  ERC725Y: '0x714df77c',
20
- LSP0ERC725Account: '0x9a3bfe88',
20
+ LSP0ERC725Account: '0xeb6be62e',
21
21
  LSP1UniversalReceiver: '0x6bb56a14',
22
22
  LSP1UniversalReceiverDelegate: '0xa245bbda',
23
23
  LSP6KeyManager: '0xc403d48f',
24
- LSP7DigitalAsset: '0xe33f65c3',
24
+ LSP7DigitalAsset: '0x5fcaac27',
25
25
  LSP8IdentifiableDigitalAsset: '0x49399145',
26
- LSP9Vault: '0x8c1d44f6',
27
- ClaimOwnership: '0xd225f160',
26
+ LSP9Vault: '0xfd4d5c50',
27
+ ClaimOwnership: '0xa375e9c6',
28
28
  };
29
29
 
30
30
  // ERC1271
@@ -69,22 +69,26 @@ const SupportedStandards = {
69
69
  * @see https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md
70
70
  */
71
71
  const ERC725YKeys = {
72
- LSP0: {
72
+ LSP1: {
73
73
  // keccak256('LSP1UniversalReceiverDelegate')
74
74
  LSP1UniversalReceiverDelegate:
75
75
  '0x0cfc51aec37c55a4d0b1a65c6255c4bf2fbdf6277f3cc0730c45b828b6db8b47',
76
76
  },
77
77
  LSP3: {
78
+ SupportedStandards_LSP3: SupportedStandards.LSP3UniversalProfile,
78
79
  // keccak256('LSP3Profile')
79
80
  LSP3Profile: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
80
81
  },
81
82
  LSP4: {
83
+ SupportedStandards_LSP4: SupportedStandards.LSP4DigitalAsset,
82
84
  // keccak256('LSP4TokenName')
83
85
  LSP4TokenName: '0xdeba1e292f8ba88238e10ab3c7f88bd4be4fac56cad5194b6ecceaf653468af1',
84
86
  // keccak256('LSP4TokenSymbol')
85
87
  LSP4TokenSymbol: '0x2f0a68ab07768e01943a599e73362a0e17a63a72e94dd2e384d2c1d4db932756',
86
88
  // keccak256('LSP4Metadata')
87
89
  LSP4Metadata: '0x9afb95cacc9f95858ec44aa8c3b685511002e30ae54415823f406128b85b238e',
90
+ // LSP4CreatorsMap:<address>
91
+ LSP4CreatorsMap: '0x6de85eaf5d982b4e5da00000',
88
92
  // keccak256('"LSP4Creators[]')
89
93
  'LSP4Creators[]': {
90
94
  // use this key to get the number of elements in the array
@@ -119,6 +123,9 @@ const ERC725YKeys = {
119
123
  // AddressPermissions:AllowedERC725YKeys:<address>
120
124
  'AddressPermissions:AllowedERC725YKeys': '0x4b80742de2bf90b8b4850000',
121
125
  },
126
+ LSP9: {
127
+ SupportedStandards_LSP9: SupportedStandards.LSP9Vault,
128
+ },
122
129
  LSP10: {
123
130
  // keccak256('LSP10VaultsMap')
124
131
  LSP10VaultsMap: '0x192448c3c0f88c7f238c0000',
@@ -149,7 +156,7 @@ const BasicUPSetup_Schema = [
149
156
  },
150
157
  {
151
158
  name: 'LSP1UniversalReceiverDelegate',
152
- key: ERC725YKeys.LSP0['LSP1UniversalReceiverDelegate'],
159
+ key: ERC725YKeys.LSP1.LSP1UniversalReceiverDelegate,
153
160
  keyType: 'Singleton',
154
161
  valueContent: 'Address',
155
162
  valueType: 'address',
@@ -181,11 +188,12 @@ const PERMISSIONS = {
181
188
  DEPLOY: "0x0000000000000000000000000000000000000000000000000000000000000080", // .... .... 1000 ....
182
189
  TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000000100", // .... 0001 .... ....
183
190
  SIGN: "0x0000000000000000000000000000000000000000000000000000000000000200", // .... 0010 .... ....
184
- SUPER_SETDATA: "0x0000000000000000000000000000000000000000000000000000000000000400", // .... 0100 .... ....
185
- SUPER_TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000000800", // .... 1000 .... ....
186
- SUPER_CALL: "0x0000000000000000000000000000000000000000000000000000000000001000", // 0001 .... .... ....
187
- SUPER_STATICCALL: "0x0000000000000000000000000000000000000000000000000000000000002000", // 0010 .... .... ....
188
- SUPER_DELEGATECALL: "0x0000000000000000000000000000000000000000000000000000000000004000", // 0100 .... .... ....
191
+ ENCRYPT: "0x0000000000000000000000000000000000000000000000000000000000000400", // .... 0100 .... ....
192
+ SUPER_SETDATA: "0x0000000000000000000000000000000000000000000000000000000000000800", // .... 1000 .... ....
193
+ SUPER_TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000001000", // 0001 .... .... ....
194
+ SUPER_CALL: "0x0000000000000000000000000000000000000000000000000000000000002000", // 0010 .... .... ....
195
+ SUPER_STATICCALL: "0x0000000000000000000000000000000000000000000000000000000000004000", // 0100 .... .... ....
196
+ SUPER_DELEGATECALL: "0x0000000000000000000000000000000000000000000000000000000000008000", // 1000 .... .... ....
189
197
  }
190
198
 
191
199
  const LSP1_TYPE_IDS = {
@@ -201,11 +209,23 @@ const LSP1_TYPE_IDS = {
201
209
  LSP9_VAULTSENDER: '0x3ca9f769340018257ac15b3a00e502e8fb730d66086f774210f84d0205af31e7',
202
210
  // keccak256("LSP9VaultRecipient")
203
211
  LSP9_VAULTRECIPIENT: '0x09aaf55960715d8d86b57af40be36b0bfd469c9a3643445d8c65d39e27b4c56f',
212
+ // keccak256("LSP9VaultPendingOwner")
213
+ LSP9_VAULTPENDINGOWNER: '0x50d401f7017708f51f2a7a1c24146f786926c831079107140037b8ebef9fd326',
204
214
  };
205
215
 
206
216
  // ----------
207
217
 
208
218
  const Errors = {
219
+ ClaimOwnership: {
220
+ '0x8b9bf507': {
221
+ error: 'NotInRenounceOwnershipInterval(uint256,uint256)',
222
+ message: 'ClaimOwnership: Second renounce ownership call available after 100 block delay from the first call',
223
+ },
224
+ '0x43b248cd': {
225
+ error: 'CannotTransferOwnershipToSelf()',
226
+ message: 'ClaimOwnership: Cannot transfer ownership to address(this)',
227
+ },
228
+ },
209
229
  LSP2: {
210
230
  '0xb614e91e': {
211
231
  error: 'InvalidABIEncodedArray(bytes,string)',
@@ -254,6 +274,14 @@ const Errors = {
254
274
  error: 'NotAllowedERC725YKey(address,bytes32)',
255
275
  message: 'LSP6: not allowed to set the ERC725Y data key.',
256
276
  },
277
+ '0x0f7d735b': {
278
+ error: 'NotRecognisedPermissionKey(bytes32)',
279
+ message: 'LSP6: could not recognise the permission data key being set.',
280
+ },
281
+ '0xfc854579': {
282
+ error: 'InvalidLSP6Target()',
283
+ message: 'LSP6: cannot linked the Key Manager to address(0).',
284
+ },
257
285
  '0xc9bd9eb9': {
258
286
  error: 'InvalidRelayNonce(address,uint256,bytes)',
259
287
  message: 'LSP6: invalid nonce provided for signer address',
@@ -280,6 +308,10 @@ const Errors = {
280
308
  error: 'LSP7CannotSendWithAddressZero()',
281
309
  message: 'LSP7: cannot send token with address(0).',
282
310
  },
311
+ '0xb9afb000': {
312
+ error: 'LSP7CannotSendToSelf()',
313
+ message: 'LSP7: `from` and `to` address cannot be the same',
314
+ },
283
315
  '0x263eee8d': {
284
316
  error: 'LSP7InvalidTransferBatch()',
285
317
  message: 'LSP7: invalid transfer batch.',
@@ -324,6 +356,10 @@ const Errors = {
324
356
  error: 'LSP8CannotSendToAddressZero()',
325
357
  message: 'LSP8: cannot send to address(0).',
326
358
  },
359
+ '0x5d67d6c1': {
360
+ error: 'LSP8CannotSendToSelf()',
361
+ message: 'LSP8: the `from` and `to` address cannot be the same on transfer.',
362
+ },
327
363
  '0x34c7b511': {
328
364
  error: 'LSP8TokenIdAlreadyMinted(bytes32)',
329
365
  message: 'LSP8: tokenId already exist (= already minted).',
@@ -367,6 +403,15 @@ const EventSignatures = {
367
403
  */
368
404
  OwnershipTransfered: '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0',
369
405
  },
406
+ ClaimOwnership: {
407
+ /**
408
+ * event RenounceOwnershipInitiated();
409
+ *
410
+ * signature = keccak256('RenounceOwnershipInitiated()')
411
+ */
412
+ RenounceOwnershipInitiated:
413
+ '0X56272768d104766ae5e663c58927d0a9e47effb40b9a8f6644ac5dfbc9e56f84',
414
+ },
370
415
  ERC725X: {
371
416
  /**
372
417
  * event ContractCreated(
@@ -392,11 +437,14 @@ const EventSignatures = {
392
437
  },
393
438
  ERC725Y: {
394
439
  /**
395
- * event DataChanged(bytes32 indexed key);
440
+ * event DataChanged(
441
+ * bytes32 indexed dataKey,
442
+ * bytes dataValue
443
+ * );
396
444
  *
397
- * signature = keccak256('DataChanged(bytes32)')
445
+ * signature = keccak256('DataChanged(bytes32,bytes)')
398
446
  */
399
- DataChanged: '0xcdf4e344c0d23d4cdd0474039d176c55b19d531070dbe17856bfb993a5b5720b',
447
+ DataChanged: '0xece574603820d07bc9b91f2a932baadf4628aabcb8afba49776529c14a6104b2',
400
448
  },
401
449
  // ERC725Account
402
450
  LSP0: {
@@ -504,6 +552,17 @@ const EventSignatures = {
504
552
  */
505
553
  RevokedOperator: '17d5389f6ab6adb2647dfa0aa365c323d37adacc30b33a65310b6158ce1373d5',
506
554
  },
555
+ LSP9: {
556
+ /**
557
+ * event ValueReceived(
558
+ * address indexed sender,
559
+ * uint256 indexed value
560
+ * );
561
+ *
562
+ * signature = keccak256('ValueReceived(address,uint256)')
563
+ */
564
+ ValueReceived: '0x7e71433ddf847725166244795048ecf3e3f9f35628254ecbf736056664233493',
565
+ },
507
566
  Helpers: {
508
567
  /**
509
568
  * event ReceivedERC777(
@@ -1,17 +1,51 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- // This contract is a modified version of the OwnableUnset implementation, where we transfer Ownership as a 2 step
5
- // process, this allows to prevent for mistakes during ownership transfer,and so prevent control of a contract from
6
- // potentially being lost forever.
7
-
8
4
  // interfaces
9
5
  import {IClaimOwnership} from "./IClaimOwnership.sol";
10
6
 
11
7
  // modules
12
8
  import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
13
9
 
10
+ /**
11
+ * @dev reverts when trying to renounce ownership before the initial confirmation delay
12
+ */
13
+ error NotInRenounceOwnershipInterval(uint256 renounceOwnershipStart, uint256 renounceOwnershipEnd);
14
+
15
+ /**
16
+ * @dev reverts when trying to transfer ownership to the address(this)
17
+ */
18
+ error CannotTransferOwnershipToSelf();
19
+
20
+ /**
21
+ * @title ClaimOwnership
22
+ * @author Fabian Vogelsteller <fabian@lukso.network>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi), Daniel Afteni (B00ste)
23
+ * @dev This contract is a modified version of the OwnableUnset implementation, where transferring and renouncing ownership
24
+ * works as a 2 steps process. This can be used as a confirmation mechanism to prevent potential mistakes when
25
+ * transferring ownership of the contract, where the control of the contract could be lost forever.
26
+ */
14
27
  abstract contract ClaimOwnership is IClaimOwnership, OwnableUnset {
28
+
29
+ /**
30
+ * @dev The number of block that need to pass before one is able to
31
+ * confirm renouncing ownership
32
+ */
33
+ uint256 private constant _RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY = 100;
34
+
35
+ /**
36
+ * @dev The number of blocks during which one can renounce ownership
37
+ */
38
+ uint256 private constant _RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD = 100;
39
+
40
+ /**
41
+ * @dev The block number saved when initiating the process of
42
+ * renouncing ownerhsip
43
+ */
44
+ uint256 private _renounceOwnershipStartedAt;
45
+
46
+ /**
47
+ * @dev The address that may use `claimOwnership()`
48
+ */
15
49
  address public override pendingOwner;
16
50
 
17
51
  function claimOwnership() public virtual override {
@@ -22,13 +56,41 @@ abstract contract ClaimOwnership is IClaimOwnership, OwnableUnset {
22
56
  _transferOwnership(newOwner);
23
57
  }
24
58
 
59
+ function renounceOwnership() public virtual override onlyOwner {
60
+ _renounceOwnership();
61
+ }
62
+
25
63
  function _claimOwnership() internal virtual {
26
- require(msg.sender == pendingOwner, "OwnableClaim: caller is not the pendingOwner");
64
+ require(msg.sender == pendingOwner, "ClaimOwnership: caller is not the pendingOwner");
27
65
  _setOwner(pendingOwner);
28
66
  pendingOwner = address(0);
29
67
  }
30
68
 
31
69
  function _transferOwnership(address newOwner) internal virtual {
70
+ if (newOwner == address(this)) revert CannotTransferOwnershipToSelf();
32
71
  pendingOwner = newOwner;
33
72
  }
73
+
74
+ /**
75
+ * @dev This method is used to initiate or confirm the process of
76
+ * renouncing ownership.
77
+ */
78
+ function _renounceOwnership() internal virtual {
79
+ uint256 currentBlock = block.number;
80
+ uint256 confirmationPeriodStart = _renounceOwnershipStartedAt + _RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY;
81
+ uint256 confirmationPeriodEnd = confirmationPeriodStart + _RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD;
82
+
83
+ if (currentBlock > confirmationPeriodEnd) {
84
+ _renounceOwnershipStartedAt = currentBlock;
85
+ emit RenounceOwnershipInitiated();
86
+ return;
87
+ }
88
+
89
+ if (currentBlock < confirmationPeriodStart) {
90
+ revert NotInRenounceOwnershipInterval(confirmationPeriodStart, confirmationPeriodEnd);
91
+ }
92
+
93
+ _setOwner(address(0));
94
+ delete _renounceOwnershipStartedAt;
95
+ }
34
96
  }
@@ -125,6 +125,6 @@ library ERC165Checker {
125
125
  );
126
126
  (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);
127
127
  if (result.length < 32) return false;
128
- return success && abi.decode(result, (bool));
128
+ return success && abi.decode(result, (uint256)) > 0;
129
129
  }
130
130
  }
@@ -1,9 +1,11 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- bytes4 constant _INTERFACEID_CLAIM_OWNERSHIP = 0xd225f160;
4
+ bytes4 constant _INTERFACEID_CLAIM_OWNERSHIP = 0xa375e9c6;
5
5
 
6
6
  interface IClaimOwnership {
7
+ event RenounceOwnershipInitiated();
8
+
7
9
  function pendingOwner() external view returns (address);
8
10
 
9
11
  function claimOwnership() external;
@@ -90,7 +90,7 @@ contract UniversalFactory {
90
90
  bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
91
91
  contractCreated = Create2.deploy(msg.value, generatedSalt, byteCode);
92
92
 
93
- if (initializeCallData.length > 0) {
93
+ if (initializeCallData.length != 0) {
94
94
  // solhint-disable avoid-low-level-calls
95
95
  (bool success, bytes memory returnData) = contractCreated.call(initializeCallData);
96
96
  Address.verifyCallResult(
@@ -121,7 +121,7 @@ contract UniversalFactory {
121
121
  bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
122
122
  proxy = Clones.cloneDeterministic(baseContract, generatedSalt);
123
123
 
124
- if (initializeCallData.length > 0) {
124
+ if (initializeCallData.length != 0) {
125
125
  // solhint-disable avoid-low-level-calls
126
126
  (bool success, bytes memory returnData) = proxy.call{value: msg.value}(
127
127
  initializeCallData
@@ -132,15 +132,10 @@ contract UniversalFactory {
132
132
  "UniversalFactory: could not initialize the created contract"
133
133
  );
134
134
  } else {
135
- // @todo check if this part make sense
136
- // Return value sent
137
- if (msg.value > 0) {
138
- // solhint-disable avoid-low-level-calls
139
- (bool success, bytes memory returnData) = payable(msg.sender).call{
140
- value: msg.value
141
- }("");
142
- Address.verifyCallResult(success, returnData, "UniversalFactory: Unknow Error");
143
- }
135
+ require(
136
+ msg.value == 0,
137
+ "UniversalFactory: value cannot be sent to the factory if initializeCallData is empty"
138
+ );
144
139
  }
145
140
  }
146
141
 
@@ -154,7 +149,7 @@ contract UniversalFactory {
154
149
  pure
155
150
  returns (bytes32)
156
151
  {
157
- bool initializable = initializeCallData.length > 0;
152
+ bool initializable = initializeCallData.length != 0;
158
153
  if (initializable) {
159
154
  return keccak256(abi.encodePacked(initializable, initializeCallData, salt));
160
155
  } else {
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.0;
3
3
 
4
4
  // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_LSP0 = 0x9a3bfe88;
5
+ bytes4 constant _INTERFACEID_LSP0 = 0xeb6be62e;
6
6
  bytes4 constant _INTERFACEID_ERC1271 = 0x1626ba7e;
7
7
 
8
8
  // ERC1271 - Standard Signature Validation
@@ -9,6 +9,7 @@ import {
9
9
  } from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
10
10
 
11
11
  // libraries
12
+ import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
12
13
  import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
13
14
  import {ERC165Checker} from "../Custom/ERC165Checker.sol";
14
15
 
@@ -54,24 +55,9 @@ abstract contract LSP0ERC725AccountCore is
54
55
  * @dev Emits an event when receiving native tokens
55
56
  */
56
57
  fallback() external payable virtual {
57
- if (msg.value > 0) emit ValueReceived(msg.sender, msg.value);
58
+ if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
58
59
  }
59
60
 
60
- // TODO to be discussed
61
- // function fallback()
62
- // public
63
- // {
64
- // address to = owner();
65
- // assembly {
66
- // calldatacopy(0, 0, calldatasize())
67
- // let result := staticcall(gas(), to, 0, calldatasize(), 0, 0)
68
- // returndatacopy(0, 0, returndatasize())
69
- // switch result
70
- // case 0 { revert (0, returndatasize()) }
71
- // default { return (0, returndatasize()) }
72
- // }
73
- // }
74
-
75
61
  // ERC165
76
62
 
77
63
  /**
@@ -106,6 +92,13 @@ abstract contract LSP0ERC725AccountCore is
106
92
  ClaimOwnership._transferOwnership(_newOwner);
107
93
  }
108
94
 
95
+ /**
96
+ * @dev Renounce ownership of the contract in a 2-step process
97
+ */
98
+ function renounceOwnership() public virtual override(ClaimOwnership, OwnableUnset) onlyOwner {
99
+ ClaimOwnership._renounceOwnership();
100
+ }
101
+
109
102
  // ERC1271
110
103
 
111
104
  /**
@@ -118,7 +111,6 @@ abstract contract LSP0ERC725AccountCore is
118
111
  function isValidSignature(bytes32 dataHash, bytes memory signature)
119
112
  public
120
113
  view
121
- override
122
114
  returns (bytes4 magicValue)
123
115
  {
124
116
  address _owner = owner();
@@ -149,7 +141,6 @@ abstract contract LSP0ERC725AccountCore is
149
141
  public
150
142
  payable
151
143
  virtual
152
- override
153
144
  returns (bytes memory returnValue)
154
145
  {
155
146
  bytes memory lsp1DelegateValue = _getData(_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY);
@@ -169,4 +160,15 @@ abstract contract LSP0ERC725AccountCore is
169
160
  }
170
161
  emit UniversalReceiver(msg.sender, msg.value, typeId, returnValue, data);
171
162
  }
163
+
164
+ /**
165
+ * @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
166
+ */
167
+ function _setData(bytes32 dataKey, bytes memory dataValue) internal virtual override {
168
+ store[dataKey] = dataValue;
169
+ emit DataChanged(
170
+ dataKey,
171
+ dataValue.length <= 256 ? dataValue : BytesLib.slice(dataValue, 0, 256)
172
+ );
173
+ }
172
174
  }
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
3
3
 
4
4
  // modules
5
5
  import {LSP0ERC725AccountCore} from "./LSP0ERC725AccountCore.sol";
6
- import {Initializable} from "@erc725/smart-contracts/contracts/custom/Initializable.sol";
6
+ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
7
7
  import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
8
8
 
9
9
  /**
@@ -6,5 +6,5 @@ pragma solidity ^0.8.0;
6
6
  // keccak256('LSP10Vaults[]')
7
7
  bytes32 constant _LSP10_VAULTS_ARRAY_KEY = 0x55482936e01da86729a45d2b87a6b1d3bc582bea0ec00e38bdb340e3af6f9f06;
8
8
 
9
- // bytes10(keccak256('LSP10VaultsMap')) + bytes2(0)
10
- bytes12 constant _LSP10_VAULTS_MAP_KEY_PREFIX = 0x192448c3c0f88c7f238c0000;
9
+ // bytes10(keccak256('LSP10VaultsMap'))
10
+ bytes10 constant _LSP10_VAULTS_MAP_KEY_PREFIX = 0x192448c3c0f88c7f238c;
@@ -28,9 +28,6 @@ abstract contract TokenAndVaultHandling {
28
28
  internal
29
29
  returns (bytes memory result)
30
30
  {
31
- // avoid EOAs spamming the storage
32
- if (caller.code.length == 0) return "";
33
-
34
31
  address keyManager = ERC725Y(msg.sender).owner();
35
32
  if (!ERC165Checker.supportsERC165Interface(keyManager, _INTERFACEID_LSP6)) return "";
36
33
 
@@ -42,7 +39,7 @@ abstract contract TokenAndVaultHandling {
42
39
  (
43
40
  bool isReceiving,
44
41
  bytes32 arrayLengthKey,
45
- bytes12 mapPrefix,
42
+ bytes10 mapPrefix,
46
43
  bytes4 interfaceID
47
44
  ) = LSP1Utils.getTransferDetails(typeId);
48
45
 
@@ -45,10 +45,10 @@ contract LSP1UniversalReceiverDelegateUP is
45
45
  */
46
46
  function universalReceiverDelegate(
47
47
  address sender,
48
- uint256 value,
48
+ uint256 value, // solhint-disable no-unused-vars
49
49
  bytes32 typeId,
50
50
  bytes memory data // solhint-disable no-unused-vars
51
- ) public virtual override returns (bytes memory result) {
51
+ ) public virtual returns (bytes memory result) {
52
52
  if (
53
53
  typeId == _TYPEID_LSP7_TOKENSSENDER ||
54
54
  typeId == _TYPEID_LSP7_TOKENSRECIPIENT ||
@@ -59,12 +59,6 @@ contract LSP1UniversalReceiverDelegateUP is
59
59
  ) {
60
60
  result = _tokenAndVaultHandling(sender, typeId);
61
61
  }
62
-
63
- /* @TODO
64
- else if() {
65
- result = FollowerHandling(sender, typeId, data);
66
- }
67
- */
68
62
  }
69
63
 
70
64
  // --- Overrides
@@ -24,15 +24,12 @@ import "../../../LSP9Vault/LSP9Constants.sol";
24
24
  */
25
25
  abstract contract TokenHandling {
26
26
  function _tokenHandling(address caller, bytes32 typeId) internal returns (bytes memory result) {
27
- // avoid EOAs spamming the storage
28
- if (caller.code.length == 0) return "";
29
-
30
27
  if (!ERC165Checker.supportsERC165Interface(msg.sender, _INTERFACEID_LSP9)) return "";
31
28
 
32
29
  (
33
30
  bool isReceiving,
34
31
  bytes32 arrayLengthKey,
35
- bytes12 mapPrefix,
32
+ bytes10 mapPrefix,
36
33
  bytes4 interfaceID
37
34
  ) = LSP1Utils.getTransferDetails(typeId);
38
35
 
@@ -38,10 +38,10 @@ contract LSP1UniversalReceiverDelegateVault is
38
38
  */
39
39
  function universalReceiverDelegate(
40
40
  address sender,
41
- uint256 value,
41
+ uint256 value, // solhint-disable no-unused-vars
42
42
  bytes32 typeId,
43
43
  bytes memory data // solhint-disable no-unused-vars
44
- ) public virtual override returns (bytes memory result) {
44
+ ) public virtual returns (bytes memory result) {
45
45
  if (
46
46
  typeId == _TYPEID_LSP7_TOKENSSENDER ||
47
47
  typeId == _TYPEID_LSP7_TOKENSRECIPIENT ||
@@ -32,7 +32,7 @@ library LSP1Utils {
32
32
  returns (
33
33
  bool isReceiving,
34
34
  bytes32 arrayKey,
35
- bytes12 mapPrefix,
35
+ bytes10 mapPrefix,
36
36
  bytes4 interfaceId
37
37
  )
38
38
  {