@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
@@ -0,0 +1,50 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.4;
3
+
4
+ // libraries
5
+ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
6
+
7
+ // constants
8
+ import {
9
+ _INTERFACEID_LSP1,
10
+ _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
11
+ _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
12
+ } from "../LSP1UniversalReceiver/LSP1Constants.sol";
13
+
14
+ /**
15
+ * @title Utility functions to query the storage of an LSP0ERC725Account
16
+ * @author Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
17
+ */
18
+ library LSP0Utils {
19
+ /**
20
+ * @dev query internally the ERC725Y storage of a LSP0ERC725YContract to retrieve
21
+ * the value set for the `LSP1UniversalReceiverDelegate` data key.
22
+ * @param erc725YStorage a reference to the ERC725Y storage mapping.
23
+ * @return the bytes value stored under the `LSP1UniversalReceiverDelegate` data key.
24
+ */
25
+ function getLSP1DelegateValue(mapping(bytes32 => bytes) storage erc725YStorage)
26
+ internal
27
+ view
28
+ returns (bytes memory)
29
+ {
30
+ return erc725YStorage[_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY];
31
+ }
32
+
33
+ /**
34
+ * @dev query internally the storage of a LSP0ERC725Account to retrieve
35
+ * the value set for the `LSP1UniversalReceiverDelegate:<bytes32>` data key for a specific typeId.
36
+ * @param erc725YStorage a reference to the ERC725Y storage mapping.
37
+ * @param typeId a bytes32 typeId;
38
+ * @return the bytes value stored under the `LSP1UniversalReceiverDelegate:<bytes32>` data key.
39
+ */
40
+ function getLSP1DelegateValueForTypeId(
41
+ mapping(bytes32 => bytes) storage erc725YStorage,
42
+ bytes32 typeId
43
+ ) internal view returns (bytes memory) {
44
+ bytes32 lsp1TypeIdDataKey = LSP2Utils.generateMappingKey(
45
+ _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
46
+ bytes20(typeId)
47
+ );
48
+ return erc725YStorage[lsp1TypeIdDataKey];
49
+ }
50
+ }
@@ -14,25 +14,25 @@ import "../LSP9Vault/LSP9Constants.sol";
14
14
 
15
15
  /**
16
16
  * @dev reverts when the value stored under the 'LSP10ReceivedVaults[]' data key is not valid.
17
- * The value stored under this data key should be exactly 32 bytes long.
17
+ * The value stored under this data key should be exactly 16 bytes long.
18
18
  *
19
19
  * Only possible valid values are:
20
- * - any valid uint256 values
21
- * i.e. 0x0000000000000000000000000000000000000000000000000000000000000000 (zero), meaning empty array, no vaults received.
22
- * i.e. 0x0000000000000000000000000000000000000000000000000000000000000005 (non-zero), meaning 5 array elements, 5 vaults received.
20
+ * - any valid uint128 values
21
+ * i.e. 0x00000000000000000000000000000000 (zero), meaning empty array, no vaults received.
22
+ * i.e. 0x00000000000000000000000000000005 (non-zero), meaning 5 array elements, 5 vaults received.
23
23
  *
24
24
  * - 0x (nothing stored under this data key, equivalent to empty array)
25
25
  *
26
- * @param invalidValue the invalid value stored under the LSP10ReceivedVaults[] data key
27
- * @param invalidValueLength the invalid number of bytes stored under the LSP10ReceivedVaults[] data key (MUST be 32)
26
+ * @param invalidValueStored the invalid value stored under the LSP10ReceivedVaults[] data key
27
+ * @param invalidValueLength the invalid number of bytes stored under the LSP10ReceivedVaults[] data key (MUST be 16 bytes long)
28
28
  */
29
- error InvalidLSP10ReceivedVaultsArrayLength(bytes invalidValue, uint256 invalidValueLength);
29
+ error InvalidLSP10ReceivedVaultsArrayLength(bytes invalidValueStored, uint256 invalidValueLength);
30
30
 
31
31
  /**
32
- * @dev reverts when the vault index is superior to uint64
33
- * @param index the vault index
32
+ * @dev reverts when the `LSP10Vaults[]` array reaches its maximum limit (max(uint128))
33
+ * @param notRegisteredVault the address of the vault that could not be registered
34
34
  */
35
- error VaultIndexSuperiorToUint64(uint256 index);
35
+ error MaxLSP10VaultsCountReached(address notRegisteredVault);
36
36
 
37
37
  /**
38
38
  * @dev reverts when the vault index is superior to uint128
@@ -54,13 +54,11 @@ library LSP10Utils {
54
54
  * @param vault The address of the vault being received
55
55
  * @param vaultMapKey The map key of the vault being received containing the interfaceId of the
56
56
  * vault and the index in the array
57
- * @param interfaceID The interfaceID of the vault being received
58
57
  */
59
58
  function generateReceivedVaultKeys(
60
59
  address receiver,
61
60
  address vault,
62
- bytes32 vaultMapKey,
63
- bytes4 interfaceID
61
+ bytes32 vaultMapKey
64
62
  ) internal view returns (bytes32[] memory keys, bytes[] memory values) {
65
63
  keys = new bytes32[](3);
66
64
  values = new bytes[](3);
@@ -68,43 +66,31 @@ library LSP10Utils {
68
66
  IERC725Y account = IERC725Y(receiver);
69
67
  bytes memory encodedArrayLength = getLSP10ReceivedVaultsCount(account);
70
68
 
71
- // If it's the first vault to receive
72
- if (encodedArrayLength.length == 0) {
73
- keys[0] = _LSP10_VAULTS_ARRAY_KEY;
74
- values[0] = bytes.concat(bytes32(uint256(1)));
75
-
76
- keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(_LSP10_VAULTS_ARRAY_KEY, 0);
77
- values[1] = bytes.concat(bytes20(vault));
69
+ // CHECK it's either the first vault received,
70
+ // or the storage is already set with a valid `uint128` value
71
+ if (encodedArrayLength.length != 0 && encodedArrayLength.length != 16) {
72
+ revert InvalidLSP10ReceivedVaultsArrayLength({
73
+ invalidValueStored: encodedArrayLength,
74
+ invalidValueLength: encodedArrayLength.length
75
+ });
76
+ }
78
77
 
79
- keys[2] = vaultMapKey;
80
- values[2] = bytes.concat(interfaceID, bytes8(0));
78
+ uint128 oldArrayLength = uint128(bytes16(encodedArrayLength));
81
79
 
82
- // If the storage is already initiated
83
- } else if (encodedArrayLength.length == 32) {
84
- uint256 oldArrayLength = uint256(bytes32(encodedArrayLength));
85
- uint256 newArrayLength = oldArrayLength + 1;
80
+ if (oldArrayLength == type(uint128).max) {
81
+ revert MaxLSP10VaultsCountReached({notRegisteredVault: vault});
82
+ }
86
83
 
87
- if (newArrayLength > type(uint64).max) {
88
- revert VaultIndexSuperiorToUint64(newArrayLength);
89
- }
84
+ uint128 newArrayLength = oldArrayLength + 1;
90
85
 
91
- keys[0] = _LSP10_VAULTS_ARRAY_KEY;
92
- values[0] = bytes.concat(bytes32(newArrayLength));
86
+ keys[0] = _LSP10_VAULTS_ARRAY_KEY;
87
+ values[0] = bytes.concat(bytes16(newArrayLength));
93
88
 
94
- keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(
95
- _LSP10_VAULTS_ARRAY_KEY,
96
- uint128(oldArrayLength)
97
- );
98
- values[1] = bytes.concat(bytes20(vault));
89
+ keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(_LSP10_VAULTS_ARRAY_KEY, oldArrayLength);
90
+ values[1] = bytes.concat(bytes20(vault));
99
91
 
100
- keys[2] = vaultMapKey;
101
- values[2] = bytes.concat(interfaceID, bytes8(uint64(oldArrayLength)));
102
- } else {
103
- revert InvalidLSP10ReceivedVaultsArrayLength(
104
- encodedArrayLength,
105
- encodedArrayLength.length
106
- );
107
- }
92
+ keys[2] = vaultMapKey;
93
+ values[2] = bytes.concat(_INTERFACEID_LSP9, bytes16(oldArrayLength));
108
94
  }
109
95
 
110
96
  /**
@@ -120,17 +106,25 @@ library LSP10Utils {
120
106
  bytes memory vaultInterfaceIdAndIndex
121
107
  ) internal view returns (bytes32[] memory keys, bytes[] memory values) {
122
108
  IERC725Y account = IERC725Y(sender);
109
+ bytes memory lsp10VaultsCountValue = getLSP10ReceivedVaultsCount(account);
110
+
111
+ if (lsp10VaultsCountValue.length != 16) {
112
+ revert InvalidLSP10ReceivedVaultsArrayLength({
113
+ invalidValueStored: lsp10VaultsCountValue,
114
+ invalidValueLength: lsp10VaultsCountValue.length
115
+ });
116
+ }
123
117
 
124
118
  // Updating the number of the received vaults
125
- uint256 oldArrayLength = uint256(bytes32(account.getData(_LSP10_VAULTS_ARRAY_KEY)));
119
+ uint128 oldArrayLength = uint128(bytes16(lsp10VaultsCountValue));
126
120
 
127
121
  if (oldArrayLength > type(uint128).max) {
128
122
  revert VaultIndexSuperiorToUint128(oldArrayLength);
129
123
  }
130
124
 
131
- uint128 newArrayLength = uint128(oldArrayLength) - 1;
125
+ uint128 newArrayLength = oldArrayLength - 1;
132
126
 
133
- uint64 index = extractIndexFromMap(vaultInterfaceIdAndIndex);
127
+ uint128 index = extractIndexFromMap(vaultInterfaceIdAndIndex);
134
128
  bytes32 vaultInArrayKey = LSP2Utils.generateArrayElementKeyAtIndex(
135
129
  _LSP10_VAULTS_ARRAY_KEY,
136
130
  index
@@ -147,7 +141,7 @@ library LSP10Utils {
147
141
  values = new bytes[](3);
148
142
 
149
143
  keys[0] = _LSP10_VAULTS_ARRAY_KEY;
150
- values[0] = bytes.concat(bytes32(oldArrayLength - 1));
144
+ values[0] = bytes.concat(bytes16(newArrayLength));
151
145
 
152
146
  keys[1] = vaultInArrayKey;
153
147
  values[1] = "";
@@ -170,7 +164,7 @@ library LSP10Utils {
170
164
  values = new bytes[](5);
171
165
 
172
166
  keys[0] = _LSP10_VAULTS_ARRAY_KEY;
173
- values[0] = bytes.concat(bytes32(oldArrayLength - 1));
167
+ values[0] = bytes.concat(bytes16(newArrayLength));
174
168
 
175
169
  keys[1] = vaultMapKey;
176
170
  values[1] = "";
@@ -196,7 +190,7 @@ library LSP10Utils {
196
190
  values[3] = "";
197
191
 
198
192
  keys[4] = lastVaultInArrayMapKey;
199
- values[4] = bytes.concat(_INTERFACEID_LSP9, bytes8(index));
193
+ values[4] = bytes.concat(_INTERFACEID_LSP9, bytes16(index));
200
194
  }
201
195
  }
202
196
 
@@ -205,10 +199,10 @@ library LSP10Utils {
205
199
  }
206
200
 
207
201
  /**
208
- * @dev returns the index from a maping
202
+ * @dev returns the index from the LSP10VaultMap
209
203
  */
210
- function extractIndexFromMap(bytes memory mapValue) internal pure returns (uint64) {
211
- bytes memory val = BytesLib.slice(mapValue, 4, 8);
212
- return BytesLib.toUint64(val, 0);
204
+ function extractIndexFromMap(bytes memory mapValue) internal pure returns (uint128) {
205
+ bytes memory val = BytesLib.slice(mapValue, 4, 16);
206
+ return BytesLib.toUint128(val, 0);
213
207
  }
214
208
  }
@@ -191,12 +191,11 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
191
191
  address keyManager = ERC725(target_).owner();
192
192
 
193
193
  // Setting permissions for `recoverer`
194
- (bytes32[] memory keys, bytes[] memory values) = LSP6Utils
195
- .generatePermissionsKeysForController(
196
- ERC725(target_),
197
- recoverer,
198
- ALL_REGULAR_PERMISSIONS
199
- );
194
+ (bytes32[] memory keys, bytes[] memory values) = LSP6Utils.generateNewPermissionsKeys(
195
+ ERC725(target_),
196
+ recoverer,
197
+ ALL_REGULAR_PERMISSIONS
198
+ );
200
199
 
201
200
  LSP6Utils.setDataViaKeyManager(keyManager, keys, values);
202
201
 
@@ -32,22 +32,45 @@ interface ILSP14Ownable2Step {
32
32
  */
33
33
 
34
34
  /**
35
- * @dev Returns the address of the current pending owner.
35
+ * @dev The address that ownership of the contract is transferred to.
36
+ * This address may use `acceptOwnership()` to gain ownership of the contract.
36
37
  */
37
38
  function pendingOwner() external view returns (address);
38
39
 
39
40
  /**
40
- * @dev Initiate the process of transferring ownership of the contract by setting the pending owner.
41
+ * @dev Initiate the process of transferring ownership of the contract by setting the new owner as the pending owner.
42
+ *
43
+ * If the new owner is a contract that supports + implements LSP1, this will also attempt to notify the new owner that
44
+ * ownership has been transferred to them by calling the `universalReceiver(...)` function on the `newOwner` contract.
45
+ *
46
+ * @param newOwner the address of the new owner.
47
+ *
48
+ * Requirements:
49
+ * - `newOwner` MUST NOT accept ownership of the contract in the same transaction.
41
50
  */
42
51
  function transferOwnership(address newOwner) external;
43
52
 
44
53
  /**
45
- * @dev Complete the process of transferring ownership. MUST be called by the pendingOwner.
54
+ * @dev Transfer ownership of the contract from the current `owner()` to the `pendingOwner()`.
55
+ *
56
+ * Once this function is called:
57
+ * - the current `owner()` will loose access to the functions restricted to the `owner()` only.
58
+ * - the `pendingOwner()` will gain access to the functions restricted to the `owner()` only.
59
+ *
60
+ * Requirements:
61
+ * - MUST be called by the pendingOwner.
46
62
  */
47
63
  function acceptOwnership() external;
48
64
 
49
65
  /**
50
- * @dev Initiate the process of renouncing ownerhsip on the first call and confirm the renouncement of the ownership on the second call.
66
+ * @dev Renounce ownership of the contract in a 2-step process.
67
+ *
68
+ * 1. the first call will initiate the process of renouncing ownership.
69
+ * 2. the second is used as a confirmation and will leave the contract without an owner.
70
+ *
71
+ * WARNING: once ownership of the contract has been renounced, any functions
72
+ * that are restricted to be called by the owner will be permanently inaccessible,
73
+ * making these functions not callable anymore and unusable.
51
74
  */
52
75
  function renounceOwnership() external;
53
76
  }
@@ -9,6 +9,9 @@ import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalRec
9
9
  import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
10
10
  import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
11
11
 
12
+ // libraries
13
+ import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
14
+
12
15
  // errors
13
16
  import "./LSP14Errors.sol";
14
17
 
@@ -28,6 +31,8 @@ import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
28
31
  * transferring ownership of the contract, where the control of the contract could be lost forever.
29
32
  */
30
33
  abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
34
+ using LSP1Utils for address;
35
+
31
36
  /**
32
37
  * @dev The number of block that MUST pass before one is able to
33
38
  * confirm renouncing ownership
@@ -40,21 +45,15 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
40
45
  uint256 public constant RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD = 100;
41
46
 
42
47
  /**
43
- * @dev The block number saved when initiating the process of
44
- * renouncing ownerhsip
48
+ * @dev The block number saved when initiating the process of renouncing ownerhsip
45
49
  */
46
50
  uint256 private _renounceOwnershipStartedAt;
47
51
 
48
52
  /**
49
- * @dev The address that ownership of the contract is transferred to.
50
- * This address may use `acceptOwnership()` to gain ownership of the contract.
51
- * Meaning that the current owner will lose access to the methods marked as
52
- * `onlyOwner` in favor to the `_pendingOwner`.
53
+ * @dev see `pendingOwner()`
53
54
  */
54
55
  address private _pendingOwner;
55
56
 
56
- // --- General Methods
57
-
58
57
  /**
59
58
  * @inheritdoc ILSP14Ownable2Step
60
59
  */
@@ -72,13 +71,34 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
72
71
  onlyOwner
73
72
  {
74
73
  _transferOwnership(newOwner);
74
+
75
+ address currentOwner = owner();
76
+ emit OwnershipTransferStarted(currentOwner, newOwner);
77
+
78
+ newOwner.tryNotifyUniversalReceiver(_TYPEID_LSP14_OwnershipTransferStarted, "");
79
+ require(
80
+ currentOwner == owner(),
81
+ "LSP14: newOwner MUST accept ownership in a separate transaction"
82
+ );
75
83
  }
76
84
 
77
85
  /**
78
86
  * @inheritdoc ILSP14Ownable2Step
79
87
  */
80
88
  function acceptOwnership() public virtual {
89
+ address previousOwner = owner();
90
+
81
91
  _acceptOwnership();
92
+
93
+ previousOwner.tryNotifyUniversalReceiver(
94
+ _TYPEID_LSP14_OwnershipTransferred_SenderNotification,
95
+ ""
96
+ );
97
+
98
+ msg.sender.tryNotifyUniversalReceiver(
99
+ _TYPEID_LSP14_OwnershipTransferred_RecipientNotification,
100
+ ""
101
+ );
82
102
  }
83
103
 
84
104
  /**
@@ -96,45 +116,34 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
96
116
  // --- Internal methods
97
117
 
98
118
  /**
99
- * @dev Start the process of transferring ownership of the contract
100
- * and notify the new owner about it.
119
+ * @dev set the pending owner of the contract and cancel any renounce ownership
120
+ * process that was previously started.
121
+ *
122
+ * @param newOwner The address of the new pending owner.
101
123
  *
102
124
  * Requirements:
103
- * - `newOwner` MUST NOT accept ownership of the contract in the same transaction.
125
+ * - `newOwner` cannot be the address of the contract itself.
104
126
  */
105
127
  function _transferOwnership(address newOwner) internal virtual {
106
128
  if (newOwner == address(this)) revert CannotTransferOwnershipToSelf();
107
129
 
108
130
  _pendingOwner = newOwner;
109
131
  delete _renounceOwnershipStartedAt;
110
- address currentOwner = owner();
111
- emit OwnershipTransferStarted(currentOwner, newOwner);
112
-
113
- _notifyLSP1SenderOnOwnershipTransferStart(newOwner, "");
114
- require(
115
- currentOwner == owner(),
116
- "LSP14: newOwner MUST accept ownership in a separate transaction"
117
- );
118
132
  }
119
133
 
120
134
  /**
121
- * @dev Accept ownership of the contract and notify
122
- * previous owner and the new owner that ownership has been transferred.
135
+ * @dev set the pending owner of the contract as the new owner.
123
136
  */
124
137
  function _acceptOwnership() internal virtual {
125
138
  require(msg.sender == pendingOwner(), "LSP14: caller is not the pendingOwner");
126
139
 
127
- address previousOwner = owner();
128
140
  _setOwner(msg.sender);
129
141
  delete _pendingOwner;
130
-
131
- _notifyLSP1SenderOnOwnershipTransferCompletion(previousOwner, "");
132
- _notifyLSP1RecipientOnOwnershipTransferCompletion(msg.sender, "");
133
142
  }
134
143
 
135
144
  /**
136
- * @dev initiate or confirm the process of renouncing ownership. Leaves the contract
137
- * without an owner, making functions marked as `onlyOwner` not callable anymore.
145
+ * @dev initiate or confirm the process of renouncing ownership
146
+ * after a specific delay of blocks have passed.
138
147
  */
139
148
  function _renounceOwnership() internal virtual {
140
149
  uint256 currentBlock = block.number;
@@ -159,54 +168,4 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
159
168
  delete _pendingOwner;
160
169
  emit OwnershipRenounced();
161
170
  }
162
-
163
- // --- URD Hooks
164
-
165
- /**
166
- * @dev Calls the universalReceiver function of the sender when ownership transfer starts
167
- * if supports LSP1 InterfaceId
168
- */
169
- function _notifyLSP1SenderOnOwnershipTransferStart(address notifiedContract, bytes memory data)
170
- internal
171
- virtual
172
- {
173
- if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
174
- ILSP1UniversalReceiver(notifiedContract).universalReceiver(
175
- _TYPEID_LSP14_OwnershipTransferStarted,
176
- data
177
- );
178
- }
179
- }
180
-
181
- /**
182
- * @dev Calls the universalReceiver function of the sender when ownerhsip transfer is complete
183
- * if supports LSP1 InterfaceId
184
- */
185
- function _notifyLSP1SenderOnOwnershipTransferCompletion(
186
- address notifiedContract,
187
- bytes memory data
188
- ) internal virtual {
189
- if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
190
- ILSP1UniversalReceiver(notifiedContract).universalReceiver(
191
- _TYPEID_LSP14_OwnershipTransferred_SenderNotification,
192
- data
193
- );
194
- }
195
- }
196
-
197
- /**
198
- * @dev Calls the universalReceiver function of the recipient when ownerhsip transfer is complete
199
- * if supports LSP1 InterfaceId
200
- */
201
- function _notifyLSP1RecipientOnOwnershipTransferCompletion(
202
- address notifiedContract,
203
- bytes memory data
204
- ) internal virtual {
205
- if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
206
- ILSP1UniversalReceiver(notifiedContract).universalReceiver(
207
- _TYPEID_LSP14_OwnershipTransferred_RecipientNotification,
208
- data
209
- );
210
- }
211
- }
212
171
  }
@@ -64,7 +64,7 @@ contract LSP16UniversalFactory {
64
64
  bool initializable,
65
65
  bytes calldata initializeCallData
66
66
  ) public view virtual returns (address) {
67
- bytes32 generatedSalt = _generateSalt(initializable, initializeCallData, providedSalt);
67
+ bytes32 generatedSalt = generateSalt(initializable, initializeCallData, providedSalt);
68
68
  return Create2.computeAddress(generatedSalt, byteCodeHash);
69
69
  }
70
70
 
@@ -78,7 +78,7 @@ contract LSP16UniversalFactory {
78
78
  bool initializable,
79
79
  bytes calldata initializeCallData
80
80
  ) public view virtual returns (address) {
81
- bytes32 generatedSalt = _generateSalt(initializable, initializeCallData, providedSalt);
81
+ bytes32 generatedSalt = generateSalt(initializable, initializeCallData, providedSalt);
82
82
  return Clones.predictDeterministicAddress(baseContract, generatedSalt);
83
83
  }
84
84
 
@@ -99,7 +99,7 @@ contract LSP16UniversalFactory {
99
99
  virtual
100
100
  returns (address)
101
101
  {
102
- bytes32 generatedSalt = _generateSalt(false, _EMPTY_BYTE, providedSalt);
102
+ bytes32 generatedSalt = generateSalt(false, _EMPTY_BYTE, providedSalt);
103
103
  address contractCreated = Create2.deploy(msg.value, generatedSalt, byteCode);
104
104
  emit ContractCreated(contractCreated, providedSalt, false, _EMPTY_BYTE);
105
105
 
@@ -132,7 +132,7 @@ contract LSP16UniversalFactory {
132
132
  if (constructorMsgValue + initializeCalldataMsgValue != msg.value)
133
133
  revert InvalidMsgValueDistribution();
134
134
 
135
- bytes32 generatedSalt = _generateSalt(true, initializeCalldata, providedSalt);
135
+ bytes32 generatedSalt = generateSalt(true, initializeCalldata, providedSalt);
136
136
  address contractCreated = Create2.deploy(constructorMsgValue, generatedSalt, byteCode);
137
137
  emit ContractCreated(contractCreated, providedSalt, true, initializeCalldata);
138
138
 
@@ -163,7 +163,7 @@ contract LSP16UniversalFactory {
163
163
  virtual
164
164
  returns (address)
165
165
  {
166
- bytes32 generatedSalt = _generateSalt(false, _EMPTY_BYTE, providedSalt);
166
+ bytes32 generatedSalt = generateSalt(false, _EMPTY_BYTE, providedSalt);
167
167
 
168
168
  address proxy = Clones.cloneDeterministic(baseContract, generatedSalt);
169
169
  emit ContractCreated(proxy, providedSalt, false, _EMPTY_BYTE);
@@ -190,7 +190,7 @@ contract LSP16UniversalFactory {
190
190
  bytes32 providedSalt,
191
191
  bytes calldata initializeCalldata
192
192
  ) public payable virtual returns (address) {
193
- bytes32 generatedSalt = _generateSalt(true, initializeCalldata, providedSalt);
193
+ bytes32 generatedSalt = generateSalt(true, initializeCalldata, providedSalt);
194
194
 
195
195
  address proxy = Clones.cloneDeterministic(baseContract, generatedSalt);
196
196
  emit ContractCreated(proxy, providedSalt, true, initializeCalldata);
@@ -211,11 +211,11 @@ contract LSP16UniversalFactory {
211
211
  * to deploy the same bytecode + the same salt to get the same address of the contract on
212
212
  * another chain without applying the effect of initializing.
213
213
  */
214
- function _generateSalt(
214
+ function generateSalt(
215
215
  bool initializable,
216
216
  bytes memory initializeCallData,
217
217
  bytes32 providedSalt
218
- ) internal pure virtual returns (bytes32) {
218
+ ) public pure virtual returns (bytes32) {
219
219
  if (initializable) {
220
220
  return keccak256(abi.encodePacked(initializable, initializeCallData, providedSalt));
221
221
  } else {