@lukso/lsp-smart-contracts 0.9.0 → 0.10.1

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 (177) hide show
  1. package/README.md +29 -7
  2. package/artifacts/LSP0ERC725Account.json +63 -69
  3. package/artifacts/LSP0ERC725AccountInit.json +63 -69
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP16UniversalFactory.json +27 -21
  7. package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
  8. package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
  9. package/artifacts/LSP4Compatibility.json +32 -38
  10. package/artifacts/LSP4DigitalAssetMetadata.json +32 -38
  11. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +32 -38
  12. package/artifacts/LSP6KeyManager.json +29 -15
  13. package/artifacts/LSP6KeyManagerInit.json +29 -15
  14. package/artifacts/LSP7CappedSupply.json +71 -36
  15. package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -36
  16. package/artifacts/LSP7CompatibleERC20.json +71 -36
  17. package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -36
  18. package/artifacts/LSP7CompatibleERC20Mintable.json +73 -38
  19. package/artifacts/LSP7CompatibleERC20MintableInit.json +73 -38
  20. package/artifacts/LSP7DigitalAsset.json +71 -36
  21. package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -36
  22. package/artifacts/LSP7Mintable.json +73 -38
  23. package/artifacts/LSP7MintableInit.json +73 -38
  24. package/artifacts/LSP8CappedSupply.json +32 -38
  25. package/artifacts/LSP8CappedSupplyInitAbstract.json +32 -38
  26. package/artifacts/LSP8CompatibleERC721.json +35 -41
  27. package/artifacts/LSP8CompatibleERC721InitAbstract.json +35 -41
  28. package/artifacts/LSP8CompatibleERC721Mintable.json +37 -43
  29. package/artifacts/LSP8CompatibleERC721MintableInit.json +37 -43
  30. package/artifacts/LSP8IdentifiableDigitalAsset.json +32 -38
  31. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +32 -38
  32. package/artifacts/LSP8Mintable.json +34 -40
  33. package/artifacts/LSP8MintableInit.json +34 -40
  34. package/artifacts/LSP9Vault.json +61 -67
  35. package/artifacts/LSP9VaultInit.json +61 -67
  36. package/artifacts/UniversalProfile.json +63 -69
  37. package/artifacts/UniversalProfileInit.json +63 -69
  38. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +45 -10
  39. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  40. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +43 -8
  41. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +361 -124
  42. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +44 -8
  43. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +45 -6
  44. package/contracts/LSP0ERC725Account/LSP0Utils.sol +0 -1
  45. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +30 -15
  46. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +0 -1
  47. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +0 -1
  48. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +5 -7
  49. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +262 -115
  50. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +10 -5
  51. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +0 -4
  52. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +91 -34
  53. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +27 -8
  54. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +18 -9
  55. package/contracts/LSP20CallVerification/LSP20Constants.sol +17 -0
  56. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +26 -12
  57. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +0 -1
  58. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +32 -16
  59. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +11 -2
  60. package/contracts/LSP6KeyManager/LSP6Constants.sol +5 -5
  61. package/contracts/LSP6KeyManager/LSP6Errors.sol +10 -6
  62. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +140 -68
  63. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
  64. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +30 -38
  65. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +153 -60
  66. package/contracts/LSP6KeyManager/LSP6Utils.sol +1 -5
  67. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +67 -13
  68. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +5 -0
  69. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +2 -2
  70. package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +24 -0
  71. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +1 -2
  72. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +1 -2
  73. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +3 -5
  74. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +3 -5
  75. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +15 -12
  76. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +1 -1
  77. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +1 -2
  78. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +1 -2
  79. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +5 -5
  80. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +6 -6
  81. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +2 -2
  82. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +2 -2
  83. package/contracts/LSP9Vault/ILSP9Vault.sol +9 -1
  84. package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
  85. package/contracts/LSP9Vault/LSP9Vault.sol +0 -6
  86. package/contracts/LSP9Vault/LSP9VaultCore.sol +17 -15
  87. package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
  88. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +8 -5
  89. package/contracts/UniversalProfile.sol +10 -4
  90. package/contracts/UniversalProfileInit.sol +15 -5
  91. package/contracts/UniversalProfileInitAbstract.sol +7 -3
  92. package/devdocs/Create2Factory.json +16 -0
  93. package/devdocs/LSP0ERC725Account.json +200 -0
  94. package/devdocs/LSP0ERC725AccountInit.json +203 -0
  95. package/devdocs/LSP11BasicSocialRecovery.json +146 -0
  96. package/devdocs/LSP11BasicSocialRecoveryInit.json +146 -0
  97. package/devdocs/LSP16UniversalFactory.json +116 -0
  98. package/devdocs/LSP1UniversalReceiverDelegateUP.json +80 -0
  99. package/devdocs/LSP1UniversalReceiverDelegateVault.json +62 -0
  100. package/devdocs/LSP4Compatibility.json +79 -0
  101. package/devdocs/LSP4DigitalAssetMetadata.json +84 -0
  102. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +77 -0
  103. package/devdocs/LSP6KeyManager.json +257 -0
  104. package/devdocs/LSP6KeyManagerInit.json +260 -0
  105. package/devdocs/LSP7CappedSupply.json +211 -0
  106. package/devdocs/LSP7CappedSupplyInitAbstract.json +206 -0
  107. package/devdocs/LSP7CompatibleERC20.json +225 -0
  108. package/devdocs/LSP7CompatibleERC20InitAbstract.json +218 -0
  109. package/devdocs/LSP7CompatibleERC20Mintable.json +217 -0
  110. package/devdocs/LSP7CompatibleERC20MintableInit.json +227 -0
  111. package/devdocs/LSP7DigitalAsset.json +210 -0
  112. package/devdocs/LSP7DigitalAssetInitAbstract.json +202 -0
  113. package/devdocs/LSP7Mintable.json +219 -0
  114. package/devdocs/LSP7MintableInit.json +220 -0
  115. package/devdocs/LSP8CappedSupply.json +232 -0
  116. package/devdocs/LSP8CappedSupplyInitAbstract.json +227 -0
  117. package/devdocs/LSP8CompatibleERC721.json +298 -0
  118. package/devdocs/LSP8CompatibleERC721InitAbstract.json +291 -0
  119. package/devdocs/LSP8CompatibleERC721Mintable.json +290 -0
  120. package/devdocs/LSP8CompatibleERC721MintableInit.json +300 -0
  121. package/devdocs/LSP8IdentifiableDigitalAsset.json +230 -0
  122. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +223 -0
  123. package/devdocs/LSP8Mintable.json +242 -0
  124. package/devdocs/LSP8MintableInit.json +245 -0
  125. package/devdocs/LSP9Vault.json +171 -0
  126. package/devdocs/LSP9VaultInit.json +175 -0
  127. package/devdocs/UniversalProfile.json +200 -0
  128. package/devdocs/UniversalProfileInit.json +203 -0
  129. package/devdocs/UniversalReceiverAddressStore.json +9 -0
  130. package/dist/constants.cjs.js +31657 -0
  131. package/dist/constants.d.ts +31759 -0
  132. package/dist/constants.es.js +31638 -0
  133. package/package.json +71 -53
  134. package/userdocs/Create2Factory.json +5 -0
  135. package/userdocs/LSP0ERC725Account.json +50 -0
  136. package/userdocs/LSP0ERC725AccountInit.json +53 -0
  137. package/userdocs/LSP11BasicSocialRecovery.json +29 -0
  138. package/userdocs/LSP11BasicSocialRecoveryInit.json +29 -0
  139. package/userdocs/LSP16UniversalFactory.json +5 -0
  140. package/userdocs/LSP1UniversalReceiverDelegateUP.json +10 -0
  141. package/userdocs/LSP1UniversalReceiverDelegateVault.json +10 -0
  142. package/userdocs/LSP4Compatibility.json +20 -0
  143. package/userdocs/LSP4DigitalAssetMetadata.json +23 -0
  144. package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +20 -0
  145. package/userdocs/LSP6KeyManager.json +18 -0
  146. package/userdocs/LSP6KeyManagerInit.json +18 -0
  147. package/userdocs/LSP7CappedSupply.json +29 -0
  148. package/userdocs/LSP7CappedSupplyInitAbstract.json +26 -0
  149. package/userdocs/LSP7CompatibleERC20.json +35 -0
  150. package/userdocs/LSP7CompatibleERC20InitAbstract.json +32 -0
  151. package/userdocs/LSP7CompatibleERC20Mintable.json +32 -0
  152. package/userdocs/LSP7CompatibleERC20MintableInit.json +35 -0
  153. package/userdocs/LSP7DigitalAsset.json +29 -0
  154. package/userdocs/LSP7DigitalAssetInitAbstract.json +26 -0
  155. package/userdocs/LSP7Mintable.json +29 -0
  156. package/userdocs/LSP7MintableInit.json +29 -0
  157. package/userdocs/LSP8CappedSupply.json +23 -0
  158. package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -0
  159. package/userdocs/LSP8CompatibleERC721.json +29 -0
  160. package/userdocs/LSP8CompatibleERC721InitAbstract.json +26 -0
  161. package/userdocs/LSP8CompatibleERC721Mintable.json +26 -0
  162. package/userdocs/LSP8CompatibleERC721MintableInit.json +29 -0
  163. package/userdocs/LSP8IdentifiableDigitalAsset.json +23 -0
  164. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +20 -0
  165. package/userdocs/LSP8Mintable.json +23 -0
  166. package/userdocs/LSP8MintableInit.json +23 -0
  167. package/userdocs/LSP9Vault.json +38 -0
  168. package/userdocs/LSP9VaultInit.json +38 -0
  169. package/userdocs/UniversalProfile.json +50 -0
  170. package/userdocs/UniversalProfileInit.json +53 -0
  171. package/userdocs/UniversalReceiverAddressStore.json +5 -0
  172. package/CONTRIBUTING.md +0 -57
  173. package/common/constants.d.ts +0 -461
  174. package/common/constants.js +0 -789
  175. package/contracts/Utils/GasLib.sol +0 -17
  176. package/module/constants.d.ts +0 -461
  177. package/module/constants.js +0 -786
@@ -5,23 +5,59 @@ pragma solidity ^0.8.4;
5
5
  import {LSP0ERC725AccountInitAbstract} from "./LSP0ERC725AccountInitAbstract.sol";
6
6
 
7
7
  /**
8
- * @title Deployable Proxy Implementation of ERC725Account
9
- * @author Fabian Vogelsteller <fabian@lukso.network>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
10
- * @dev Bundles ERC725X and ERC725Y, ERC1271 and LSP1UniversalReceiver and allows receiving native tokens
8
+ * @title Deployable Proxy Implementation of LSP0-ERC725Account Standard
9
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-0-ERC725Account.md
10
+ *
11
+ * @author Fabian Vogelsteller <fabian@lukso.network>, Jean Cavallera (CJ42)
12
+ * @dev A smart contract account including basic functionalities such as:
13
+ *
14
+ * - Detecting supported standards using ERC165
15
+ * https://eips.ethereum.org/EIPS/eip-165
16
+ *
17
+ * - Executing several operation on other addresses including creating contracts using ERC725X
18
+ * https://github.com/ERC725Alliance/ERC725/blob/develop/docs/ERC-725.md
19
+ *
20
+ * - Storing data in a generic way using ERC725Y
21
+ * https://github.com/ERC725Alliance/ERC725/blob/develop/docs/ERC-725.md
22
+ *
23
+ * - Validating signatures using ERC1271
24
+ * https://eips.ethereum.org/EIPS/eip-1271
25
+ *
26
+ * - Receiving notification and react on them using LSP1
27
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-1-UniversalReceiver.md
28
+ *
29
+ * - Secure ownership management using LSP14
30
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-14-Ownable2Step.md
31
+ *
32
+ * - Extending the account with new functions and interfaceIds of future standards using LSP17
33
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-17-ContractExtension.md
34
+ *
35
+ * - Verifying calls on the owner to allow unified and standard interaction with the account using LSP20
36
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-20-CallVerification.md
11
37
  */
12
38
  contract LSP0ERC725AccountInit is LSP0ERC725AccountInitAbstract {
13
39
  /**
14
- * @dev initialize (= lock) base implementation contract on deployment
40
+ * @notice deploying a `LSP0ERC725AccountInit` base contract to be used behind proxy
41
+ * @dev Locks the base contract on deployment, so that it cannot be initialized, owned and controlled by anyone
42
+ * after it has been deployed. This is intended so that the sole purpose of this contract is to be used as a base
43
+ * contract behind a proxy.
15
44
  */
16
45
  constructor() {
17
46
  _disableInitializers();
18
47
  }
19
48
 
20
49
  /**
21
- * @notice Sets the owner of the contract
22
- * @param newOwner the owner of the contract
50
+ * @notice Initializing the contract owner to: `initialOwner`
51
+ * @dev Set `initialOwner` as the contract owner.
52
+ * The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.
53
+ * The `initialize(address)` function also allows funding the contract on initialization.
54
+ *
55
+ * Emitted Events:
56
+ * - ValueReceived: when the contract is funded on initialization.
57
+ *
58
+ * @param initialOwner the owner of the contract
23
59
  */
24
- function initialize(address newOwner) external payable virtual initializer {
25
- LSP0ERC725AccountInitAbstract._initialize(newOwner);
60
+ function initialize(address initialOwner) external payable virtual initializer {
61
+ LSP0ERC725AccountInitAbstract._initialize(initialOwner);
26
62
  }
27
63
  }
@@ -7,13 +7,52 @@ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Ini
7
7
  import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
8
8
 
9
9
  /**
10
- * @title Inheritable Proxy Implementation of ERC725Account
11
- * @author Fabian Vogelsteller <fabian@lukso.network>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
12
- * @dev Bundles ERC725X and ERC725Y, ERC1271 and LSP1UniversalReceiver and allows receiving native tokens
10
+ * @title Inheritable Proxy Implementation of LSP0-ERC725Account Standard
11
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-0-ERC725Account.md
12
+ *
13
+ * @author Fabian Vogelsteller <fabian@lukso.network>, Jean Cavallera (CJ42)
14
+ * @dev A smart contract account including basic functionalities such as:
15
+ *
16
+ * - Detecting supported standards using ERC165
17
+ * https://eips.ethereum.org/EIPS/eip-165
18
+ *
19
+ * - Executing several operation on other addresses including creating contracts using ERC725X
20
+ * https://github.com/ERC725Alliance/ERC725/blob/develop/docs/ERC-725.md
21
+ *
22
+ * - Storing data in a generic way using ERC725Y
23
+ * https://github.com/ERC725Alliance/ERC725/blob/develop/docs/ERC-725.md
24
+ *
25
+ * - Validating signatures using ERC1271
26
+ * https://eips.ethereum.org/EIPS/eip-1271
27
+ *
28
+ * - Receiving notification and react on them using LSP1
29
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-1-UniversalReceiver.md
30
+ *
31
+ * - Secure ownership management using LSP14
32
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-14-Ownable2Step.md
33
+ *
34
+ * - Extending the account with new functions and interfaceIds of future standards using LSP17
35
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-17-ContractExtension.md
36
+ *
37
+ * - Verifying calls on the owner to allow unified and standard interaction with the account using LSP20
38
+ * https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-20-CallVerification.md
13
39
  */
14
40
  abstract contract LSP0ERC725AccountInitAbstract is Initializable, LSP0ERC725AccountCore {
15
- function _initialize(address newOwner) internal virtual onlyInitializing {
16
- if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
17
- OwnableUnset._setOwner(newOwner);
41
+ /**
42
+ * @dev Set `initialOwner` as the contract owner. ERC725X & ERC725Y parent contracts
43
+ * are not initialised as they don't have non-zero initial state.
44
+ * If you decide to add non-zero initial state to any of those
45
+ * contracts, you MUST initialize them here
46
+ *
47
+ * Emitted Events:
48
+ * - ValueReceived: if the transaction that triggered this internal `_initialize` function contained some `msg.value`.
49
+ *
50
+ * @param initialOwner the owner of the contract
51
+ */
52
+ function _initialize(address initialOwner) internal virtual onlyInitializing {
53
+ if (msg.value != 0) {
54
+ emit ValueReceived(msg.sender, msg.value);
55
+ }
56
+ OwnableUnset._setOwner(initialOwner);
18
57
  }
19
58
  }
@@ -6,7 +6,6 @@ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
6
6
 
7
7
  // constants
8
8
  import {
9
- _INTERFACEID_LSP1,
10
9
  _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
11
10
  _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
12
11
  } from "../LSP1UniversalReceiver/LSP1Constants.sol";
@@ -83,12 +83,16 @@ library LSP10Utils {
83
83
 
84
84
  uint128 newArrayLength = oldArrayLength + 1;
85
85
 
86
+ // store the number of received vaults incremented by 1
86
87
  keys[0] = _LSP10_VAULTS_ARRAY_KEY;
87
88
  values[0] = bytes.concat(bytes16(newArrayLength));
88
89
 
90
+ // store the address of the vault under the element key in the array
89
91
  keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(_LSP10_VAULTS_ARRAY_KEY, oldArrayLength);
90
92
  values[1] = bytes.concat(bytes20(vault));
91
93
 
94
+ // store the interfaceId and the location in the array of the asset
95
+ // under the LSP5ReceivedAssetMap key
92
96
  keys[2] = vaultMapKey;
93
97
  values[2] = bytes.concat(_INTERFACEID_LSP9, bytes16(oldArrayLength));
94
98
  }
@@ -98,12 +102,12 @@ library LSP10Utils {
98
102
  * @param sender The address sending the vault and where the Keys should be updated
99
103
  * @param vaultMapKey The map key of the vault being sent containing the interfaceId of the
100
104
  * vault and the index in the array
101
- * @param vaultInterfaceIdAndIndex The value of the map key of the vault being sent
105
+ * @param vaultIndex The index where the vault address is stored under `LSP10Vaults[]` Array
102
106
  */
103
107
  function generateSentVaultKeys(
104
108
  address sender,
105
109
  bytes32 vaultMapKey,
106
- bytes memory vaultInterfaceIdAndIndex
110
+ uint128 vaultIndex
107
111
  ) internal view returns (bytes32[] memory keys, bytes[] memory values) {
108
112
  IERC725Y account = IERC725Y(sender);
109
113
  bytes memory lsp10VaultsCountValue = getLSP10ReceivedVaultsCount(account);
@@ -122,15 +126,17 @@ library LSP10Utils {
122
126
  revert VaultIndexSuperiorToUint128(oldArrayLength);
123
127
  }
124
128
 
129
+ // Updating the number of the received vaults (decrementing by 1
125
130
  uint128 newArrayLength = oldArrayLength - 1;
126
131
 
127
- uint128 index = extractIndexFromMap(vaultInterfaceIdAndIndex);
132
+ // Generate the element key in the array of the vault
128
133
  bytes32 vaultInArrayKey = LSP2Utils.generateArrayElementKeyAtIndex(
129
134
  _LSP10_VAULTS_ARRAY_KEY,
130
- index
135
+ vaultIndex
131
136
  );
132
137
 
133
- if (index == newArrayLength) {
138
+ // If the asset to remove is the last element in the array
139
+ if (vaultIndex == newArrayLength) {
134
140
  /**
135
141
  * We will be updating/removing 3 keys:
136
142
  * - Keys[0]: [Update] The arrayLengthKey to contain the new number of the received vaults
@@ -140,18 +146,21 @@ library LSP10Utils {
140
146
  keys = new bytes32[](3);
141
147
  values = new bytes[](3);
142
148
 
149
+ // store the number of received vaults decremented by 1
143
150
  keys[0] = _LSP10_VAULTS_ARRAY_KEY;
144
151
  values[0] = bytes.concat(bytes16(newArrayLength));
145
152
 
153
+ // remove the address of the vault from the element key
146
154
  keys[1] = vaultInArrayKey;
147
155
  values[1] = "";
148
156
 
157
+ // remove the interfaceId and the location in the array of the vault
149
158
  keys[2] = vaultMapKey;
150
159
  values[2] = "";
151
160
 
152
161
  // Swapping last element in ArrayKey with the element in ArrayKey to remove || {Swap and pop} method;
153
162
  // check https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/EnumerableSet.sol#L80
154
- } else {
163
+ } else if (vaultIndex < newArrayLength) {
155
164
  /**
156
165
  * We will be updating/removing 5 keys:
157
166
  * - Keys[0]: [Update] The arrayLengthKey to contain the new number of the received vaults
@@ -163,46 +172,52 @@ library LSP10Utils {
163
172
  keys = new bytes32[](5);
164
173
  values = new bytes[](5);
165
174
 
175
+ // store the number of received vaults decremented by 1
166
176
  keys[0] = _LSP10_VAULTS_ARRAY_KEY;
167
177
  values[0] = bytes.concat(bytes16(newArrayLength));
168
178
 
179
+ // remove the interfaceId and the location in the array of the vault
169
180
  keys[1] = vaultMapKey;
170
181
  values[1] = "";
171
182
 
172
183
  // Generate all data Keys/values of the last element in Array to swap
173
184
  // with data Keys/values of the vault to remove
185
+
186
+ // Generate the element key of the last vault in the array
174
187
  bytes32 lastVaultInArrayKey = LSP2Utils.generateArrayElementKeyAtIndex(
175
188
  _LSP10_VAULTS_ARRAY_KEY,
176
189
  newArrayLength
177
190
  );
178
191
 
192
+ // Get the address of the vault from the element key of the last vault in the array
179
193
  bytes20 lastVaultInArrayAddress = bytes20(account.getData(lastVaultInArrayKey));
180
194
 
195
+ // Generate the map key of the last vault in the array
181
196
  bytes32 lastVaultInArrayMapKey = LSP2Utils.generateMappingKey(
182
197
  _LSP10_VAULTS_MAP_KEY_PREFIX,
183
198
  lastVaultInArrayAddress
184
199
  );
185
200
 
201
+ // Set the address of the last vault instead of the asset to be sent
202
+ // under the element data key in the array
186
203
  keys[2] = vaultInArrayKey;
187
204
  values[2] = bytes.concat(lastVaultInArrayAddress);
188
205
 
206
+ // Remove the address swapped (last vault in the array) from the last element data key in the array
189
207
  keys[3] = lastVaultInArrayKey;
190
208
  values[3] = "";
191
209
 
210
+ // Update the index and the interfaceId of the address swapped (last vault in the array)
211
+ // to point to the new location in the LSP10Vaults array
192
212
  keys[4] = lastVaultInArrayMapKey;
193
- values[4] = bytes.concat(_INTERFACEID_LSP9, bytes16(index));
213
+ values[4] = bytes.concat(_INTERFACEID_LSP9, bytes16(vaultIndex));
214
+ } else {
215
+ // If index is bigger than the array length, out of bounds
216
+ return (keys, values);
194
217
  }
195
218
  }
196
219
 
197
220
  function getLSP10ReceivedVaultsCount(IERC725Y account) internal view returns (bytes memory) {
198
221
  return account.getData(_LSP10_VAULTS_ARRAY_KEY);
199
222
  }
200
-
201
- /**
202
- * @dev returns the index from the LSP10VaultMap
203
- */
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);
207
- }
208
223
  }
@@ -12,7 +12,6 @@ import {ERC725} from "@erc725/smart-contracts/contracts/ERC725.sol";
12
12
  import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
13
13
  import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
14
14
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
15
- import {LSP6KeyManager} from "../LSP6KeyManager/LSP6KeyManager.sol";
16
15
 
17
16
  // constants
18
17
  import {ALL_REGULAR_PERMISSIONS} from "../LSP6KeyManager/LSP6Constants.sol";
@@ -2,7 +2,6 @@
2
2
  pragma solidity ^0.8.0;
3
3
 
4
4
  // modules
5
- import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
6
5
  import {LSP11BasicSocialRecoveryInitAbstract} from "./LSP11BasicSocialRecoveryInitAbstract.sol";
7
6
 
8
7
  /**
@@ -3,11 +3,9 @@ pragma solidity ^0.8.4;
3
3
 
4
4
  // interfaces
5
5
  import {ILSP14Ownable2Step} from "./ILSP14Ownable2Step.sol";
6
- import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
7
6
 
8
7
  // modules
9
8
  import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
10
- import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
11
9
 
12
10
  // libraries
13
11
  import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
@@ -21,7 +19,6 @@ import {
21
19
  _TYPEID_LSP14_OwnershipTransferred_SenderNotification,
22
20
  _TYPEID_LSP14_OwnershipTransferred_RecipientNotification
23
21
  } from "./LSP14Constants.sol";
24
- import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
25
22
 
26
23
  /**
27
24
  * @title LSP14Ownable2Step
@@ -37,12 +34,12 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
37
34
  * @dev The number of block that MUST pass before one is able to
38
35
  * confirm renouncing ownership
39
36
  */
40
- uint256 public constant RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY = 100;
37
+ uint256 public constant RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY = 200;
41
38
 
42
39
  /**
43
40
  * @dev The number of blocks during which one can renounce ownership
44
41
  */
45
- uint256 public constant RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD = 100;
42
+ uint256 public constant RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD = 200;
46
43
 
47
44
  /**
48
45
  * @dev The block number saved when initiating the process of renouncing ownerhsip
@@ -152,7 +149,9 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
152
149
  uint256 confirmationPeriodEnd = confirmationPeriodStart +
153
150
  RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD;
154
151
 
155
- if (currentBlock > confirmationPeriodEnd) {
152
+ // On the creation of a new network, `currentBlock` will be smaller than `confirmationPeriodEnd`,
153
+ // `_renounceOwnershipStartedAt == 0` will indicate that a renounceOwnership call is happening for the first time
154
+ if (currentBlock > confirmationPeriodEnd || _renounceOwnershipStartedAt == 0) {
156
155
  _renounceOwnershipStartedAt = currentBlock;
157
156
  delete _pendingOwner;
158
157
  emit RenounceOwnershipStarted();
@@ -165,7 +164,6 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
165
164
 
166
165
  _setOwner(address(0));
167
166
  delete _renounceOwnershipStartedAt;
168
- delete _pendingOwner;
169
167
  emit OwnershipRenounced();
170
168
  }
171
169
  }