@lukso/lsp-smart-contracts 0.5.0 → 0.6.2

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 (161) hide show
  1. package/README.md +38 -9
  2. package/artifacts/Create2Factory.json +2 -2
  3. package/artifacts/LSP0ERC725Account.json +398 -0
  4. package/artifacts/LSP0ERC725AccountInit.json +444 -0
  5. package/artifacts/LSP1UniversalReceiverDelegateUP.json +21 -5
  6. package/artifacts/LSP1UniversalReceiverDelegateVault.json +21 -5
  7. package/artifacts/LSP4Compatibility.json +195 -0
  8. package/artifacts/LSP4DigitalAssetMetadata.json +179 -0
  9. package/artifacts/LSP4DigitalAssetMetadataInit.json +241 -0
  10. package/artifacts/LSP6KeyManager.json +110 -35
  11. package/artifacts/LSP6KeyManagerInit.json +123 -30
  12. package/artifacts/LSP7CappedSupply.json +146 -11
  13. package/artifacts/LSP7CappedSupplyInit.json +167 -57
  14. package/artifacts/LSP7CompatibleERC20.json +714 -0
  15. package/artifacts/LSP7CompatibleERC20Init.json +760 -0
  16. package/artifacts/LSP7CompatibleERC20Mintable.json +742 -0
  17. package/artifacts/LSP7CompatibleERC20MintableInit.json +783 -0
  18. package/artifacts/LSP7DigitalAsset.json +138 -13
  19. package/artifacts/LSP7DigitalAssetInit.json +167 -34
  20. package/artifacts/LSP7Mintable.json +139 -14
  21. package/artifacts/LSP7MintableInit.json +168 -35
  22. package/artifacts/LSP8CappedSupply.json +147 -11
  23. package/artifacts/LSP8CappedSupplyInit.json +176 -37
  24. package/artifacts/LSP8CompatibleERC721.json +842 -0
  25. package/artifacts/LSP8CompatibleERC721Init.json +883 -0
  26. package/artifacts/LSP8CompatibleERC721Mintable.json +881 -0
  27. package/artifacts/LSP8CompatibleERC721MintableInit.json +922 -0
  28. package/artifacts/LSP8IdentifiableDigitalAsset.json +139 -13
  29. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +176 -19
  30. package/artifacts/LSP8Mintable.json +151 -14
  31. package/artifacts/LSP8MintableInit.json +188 -20
  32. package/artifacts/LSP9Vault.json +374 -0
  33. package/artifacts/LSP9VaultInit.json +420 -0
  34. package/artifacts/UniversalFactory.json +127 -0
  35. package/artifacts/UniversalProfile.json +89 -32
  36. package/artifacts/UniversalProfileInit.json +133 -32
  37. package/artifacts/UniversalReceiverAddressStore.json +209 -0
  38. package/constants.js +535 -0
  39. package/contracts/Custom/ClaimOwnership.sol +34 -0
  40. package/contracts/Custom/ERC165Checker.sol +130 -0
  41. package/contracts/Custom/IClaimOwnership.sol +10 -0
  42. package/contracts/Factories/Create2Factory.sol +3 -13
  43. package/contracts/Factories/UniversalFactory.sol +164 -0
  44. package/contracts/LSP0ERC725Account/LSP0Constants.sol +5 -9
  45. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +7 -9
  46. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +108 -55
  47. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +11 -4
  48. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +6 -21
  49. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +10 -0
  50. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +3 -0
  51. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +4 -2
  52. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +3 -9
  53. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +67 -184
  54. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +58 -6
  55. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +51 -89
  56. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +46 -6
  57. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +62 -0
  58. package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +9 -0
  59. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +201 -0
  60. package/contracts/LSP3UniversalProfile/LSP3Constants.sol +11 -0
  61. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
  62. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +5 -14
  63. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +10 -4
  64. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +22 -8
  65. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +9 -13
  66. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +26 -20
  67. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +16 -0
  68. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +10 -0
  69. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +231 -0
  70. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +28 -25
  71. package/contracts/LSP6KeyManager/LSP6Constants.sol +61 -25
  72. package/contracts/LSP6KeyManager/LSP6Errors.sol +66 -0
  73. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +7 -6
  74. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +465 -378
  75. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +13 -5
  76. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +9 -15
  77. package/contracts/LSP6KeyManager/LSP6Utils.sol +107 -0
  78. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +3 -8
  79. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +5 -4
  80. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +27 -9
  81. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +73 -95
  82. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +19 -9
  83. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +27 -23
  84. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +23 -0
  85. package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +1 -1
  86. package/contracts/LSP7DigitalAsset/extensions/{ILSP7CompatibilityForERC20.sol → ILSP7CompatibleERC20.sol} +7 -9
  87. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +8 -7
  88. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +14 -12
  89. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +3 -8
  90. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +10 -15
  91. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +67 -0
  92. package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20Core.sol → LSP7CompatibleERC20Core.sol} +36 -50
  93. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Init.sol +29 -0
  94. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +67 -0
  95. package/contracts/LSP7DigitalAsset/{extensions → presets}/ILSP7Mintable.sol +1 -1
  96. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +22 -0
  97. package/contracts/LSP7DigitalAsset/{extensions/LSP7CompatibilityForERC20Init.sol → presets/LSP7CompatibleERC20MintableInit.sol} +6 -5
  98. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +27 -0
  99. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7Mintable.sol +4 -3
  100. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableCore.sol +5 -5
  101. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableInit.sol +11 -3
  102. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +34 -0
  103. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +5 -16
  104. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +6 -3
  105. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +22 -0
  106. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +23 -10
  107. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +103 -136
  108. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +17 -11
  109. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +26 -21
  110. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +1 -1
  111. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{ILSP8CompatibilityForERC721.sol → ILSP8CompatibleERC721.sol} +4 -12
  112. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +9 -15
  113. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +14 -12
  114. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +3 -8
  115. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +13 -20
  116. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityConstants.sol → LSP8CompatibleConstants.sol} +0 -0
  117. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +101 -0
  118. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Core.sol → LSP8CompatibleERC721Core.sol} +38 -95
  119. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Init.sol → LSP8CompatibleERC721Init.sol} +4 -6
  120. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +93 -0
  121. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/ILSP8Mintable.sol +1 -1
  122. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +22 -0
  123. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +23 -0
  124. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +27 -0
  125. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8Mintable.sol +4 -3
  126. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableCore.sol +5 -8
  127. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableInit.sol +11 -3
  128. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +37 -0
  129. package/contracts/LSP9Vault/LSP9Constants.sol +14 -5
  130. package/contracts/LSP9Vault/LSP9Vault.sol +20 -38
  131. package/contracts/LSP9Vault/LSP9VaultCore.sol +123 -92
  132. package/contracts/LSP9Vault/LSP9VaultInit.sol +12 -4
  133. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +20 -46
  134. package/contracts/Legacy/Registries/AddressRegistry.sol +43 -0
  135. package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +33 -0
  136. package/contracts/Legacy/UniversalReceiverAddressStore.sol +62 -0
  137. package/contracts/UniversalProfile.sol +11 -7
  138. package/contracts/UniversalProfileInit.sol +12 -4
  139. package/contracts/UniversalProfileInitAbstract.sol +12 -20
  140. package/contracts/Utils/UtilsLib.sol +21 -13
  141. package/package.json +23 -9
  142. package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +0 -66
  143. package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +0 -66
  144. package/artifacts/LSP7CompatibilityForERC20.json +0 -571
  145. package/artifacts/LSP8CompatibilityForERC721.json +0 -716
  146. package/constants.ts +0 -356
  147. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPCore.sol +0 -52
  148. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInit.sol +0 -26
  149. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInitAbstract.sol +0 -28
  150. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultCore.sol +0 -41
  151. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInit.sol +0 -23
  152. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInitAbstract.sol +0 -25
  153. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +0 -56
  154. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20InitAbstract.sol +0 -55
  155. package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInitAbstract.sol +0 -47
  156. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +0 -92
  157. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721InitAbstract.sol +0 -90
  158. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInitAbstract.sol +0 -44
  159. package/contracts/Utils/ERC725Utils.sol +0 -169
  160. package/contracts/Utils/LSP2Utils.sol +0 -127
  161. package/contracts/Utils/LSP6Utils.sol +0 -63
@@ -2,12 +2,20 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
- import "./LSP8MintableInitAbstract.sol";
5
+ // modules
6
+ import {LSP8MintableInitAbstract} from "./LSP8MintableInitAbstract.sol";
6
7
 
7
8
  /**
8
9
  * @dev LSP8 extension.
9
10
  */
10
11
  contract LSP8MintableInit is LSP8MintableInitAbstract {
12
+ /**
13
+ * @dev initialize (= lock) base implementation contract on deployment
14
+ */
15
+ constructor() {
16
+ _disableInitializers();
17
+ }
18
+
11
19
  /**
12
20
  * @notice Sets the token-Metadata and register LSP8InterfaceId
13
21
  * @param name_ The name of the token
@@ -18,7 +26,7 @@ contract LSP8MintableInit is LSP8MintableInitAbstract {
18
26
  string memory name_,
19
27
  string memory symbol_,
20
28
  address newOwner_
21
- ) public virtual override initializer {
22
- LSP8MintableInitAbstract.initialize(name_, symbol_, newOwner_);
29
+ ) public virtual initializer {
30
+ LSP8MintableInitAbstract._initialize(name_, symbol_, newOwner_);
23
31
  }
24
32
  }
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import {
7
+ LSP8IdentifiableDigitalAssetInitAbstract
8
+ } from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
9
+ import {LSP8MintableCore} from "./LSP8MintableCore.sol";
10
+
11
+ /**
12
+ * @dev LSP8 extension.
13
+ */
14
+ abstract contract LSP8MintableInitAbstract is
15
+ LSP8IdentifiableDigitalAssetInitAbstract,
16
+ LSP8MintableCore
17
+ {
18
+ function _initialize(
19
+ string memory name_,
20
+ string memory symbol_,
21
+ address newOwner_
22
+ ) internal virtual override onlyInitializing {
23
+ LSP8IdentifiableDigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_);
24
+ }
25
+
26
+ /**
27
+ * @inheritdoc LSP8MintableCore
28
+ */
29
+ function mint(
30
+ address to,
31
+ bytes32 tokenId,
32
+ bool force,
33
+ bytes memory data
34
+ ) public virtual override onlyOwner {
35
+ _mint(to, tokenId, force, data);
36
+ }
37
+ }
@@ -2,11 +2,20 @@
2
2
  pragma solidity ^0.8.0;
3
3
 
4
4
  // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_LSP9 = 0x75edcee5;
5
+ bytes4 constant _INTERFACEID_LSP9 = 0x8c1d44f6;
6
6
 
7
- // --- ERC725Y entries
7
+ // --- ERC725Y Keys
8
8
 
9
- // --- Token Hooks
10
- bytes32 constant _TYPEID_LSP9_VAULTSENDER = 0x3ca9f769340018257ac15b3a00e502e8fb730d66086f774210f84d0205af31e7; // keccak256("LSP9VaultSender")
9
+ // bytes10(keccak256('SupportedStandards')) + bytes2(0) + bytes20(keccak256('LSP9Vault'))
10
+ bytes32 constant _LSP9_SUPPORTED_STANDARDS_KEY = 0xeafec4d89fa9619884b600007c0334a14085fefa8b51ae5a40895018882bdb90;
11
11
 
12
- bytes32 constant _TYPEID_LSP9_VAULTRECIPIENT = 0x09aaf55960715d8d86b57af40be36b0bfd469c9a3643445d8c65d39e27b4c56f; // keccak256("LSP9VaultRecipient")
12
+ // bytes4(keccak256('LSP9Vault'))
13
+ bytes constant _LSP9_SUPPORTED_STANDARDS_VALUE = hex"7c0334a1";
14
+
15
+ // --- Vault Hooks
16
+
17
+ // keccak256("LSP9VaultSender")
18
+ bytes32 constant _TYPEID_LSP9_VAULTSENDER = 0x3ca9f769340018257ac15b3a00e502e8fb730d66086f774210f84d0205af31e7;
19
+
20
+ // keccak256("LSP9VaultRecipient")
21
+ bytes32 constant _TYPEID_LSP9_VAULTRECIPIENT = 0x09aaf55960715d8d86b57af40be36b0bfd469c9a3643445d8c65d39e27b4c56f;
@@ -1,56 +1,38 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.0;
3
3
 
4
+ // interfaces
5
+ import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
+
4
7
  // modules
5
- import "@erc725/smart-contracts/contracts/ERC725.sol";
6
- import "./LSP9VaultCore.sol";
8
+ import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
9
+ import {ERC725} from "@erc725/smart-contracts/contracts/ERC725.sol";
10
+ import {LSP9VaultCore, ClaimOwnership} from "./LSP9VaultCore.sol";
7
11
 
8
12
  // constants
9
- import "../LSP1UniversalReceiver/LSP1Constants.sol";
13
+ import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
14
+ import {
15
+ _INTERFACEID_LSP9,
16
+ _LSP9_SUPPORTED_STANDARDS_KEY,
17
+ _LSP9_SUPPORTED_STANDARDS_VALUE
18
+ } from "../LSP9Vault/LSP9Constants.sol";
10
19
 
11
20
  /**
12
21
  * @title Implementation of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
13
22
  * @author Fabian Vogelsteller, Yamen Merhi, Jean Cavallera
14
23
  * @dev Could be owned by a UniversalProfile and able to register received asset with UniversalReceiverDelegateVault
15
24
  */
16
- contract LSP9Vault is LSP9VaultCore, ERC725 {
25
+ contract LSP9Vault is LSP9VaultCore {
17
26
  /**
18
- * @notice Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key and register
19
- * LSP1UniversalReceiver and LSP9Vault InterfaceId
20
- * @param _newOwner the owner of the contract
27
+ * @notice Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key
28
+ * @param newOwner the owner of the contract
21
29
  */
22
- constructor(address _newOwner) ERC725(_newOwner) {
23
- // set SupportedStandards:LSP9Vault
24
- bytes32 key = 0xeafec4d89fa9619884b6b891356264550000000000000000000000007c0334a1;
25
- bytes memory value = hex"7c0334a1";
26
- _setData(key, value);
27
-
28
- _notifyVaultReceiver(_newOwner);
30
+ constructor(address newOwner) {
31
+ OwnableUnset._setOwner(newOwner);
29
32
 
30
- _registerInterface(_INTERFACEID_LSP1);
31
- _registerInterface(_INTERFACEID_LSP9);
32
- }
33
+ // set key SupportedStandards:LSP9Vault
34
+ _setData(_LSP9_SUPPORTED_STANDARDS_KEY, _LSP9_SUPPORTED_STANDARDS_VALUE);
33
35
 
34
- /**
35
- * @inheritdoc OwnableUnset
36
- */
37
- function transferOwnership(address newOwner)
38
- public
39
- override(OwnableUnset, LSP9VaultCore)
40
- onlyOwner
41
- {
42
- LSP9VaultCore.transferOwnership(newOwner);
43
- }
44
-
45
- /**
46
- * @inheritdoc LSP9VaultCore
47
- */
48
- function setData(bytes32[] memory _keys, bytes[] memory _values)
49
- public
50
- virtual
51
- override(ERC725YCore, LSP9VaultCore)
52
- onlyAllowed
53
- {
54
- LSP9VaultCore.setData(_keys, _values);
36
+ _notifyVaultReceiver(newOwner);
55
37
  }
56
38
  }
@@ -1,32 +1,43 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- // modules
5
- import "@erc725/smart-contracts/contracts/ERC725X.sol";
6
- import "@erc725/smart-contracts/contracts/ERC725Y.sol";
7
-
8
4
  // interfaces
9
- import "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
10
- import "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
5
+ import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
+ import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
7
+ import {
8
+ ILSP1UniversalReceiverDelegate
9
+ } from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
11
10
 
12
- // library
13
- import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
14
- import "../Utils/ERC725Utils.sol";
11
+ // libraries
12
+ import {ERC165Checker} from "../Custom/ERC165Checker.sol";
13
+
14
+ // modules
15
+ import {ERC725XCore} from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
16
+ import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
17
+ import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
18
+ import {ClaimOwnership} from "../Custom/ClaimOwnership.sol";
15
19
 
16
20
  // constants
17
- import "../LSP1UniversalReceiver/LSP1Constants.sol";
18
- import "./LSP9Constants.sol";
21
+ import {_INTERFACEID_CLAIM_OWNERSHIP} from "../Custom/IClaimOwnership.sol";
22
+ import {
23
+ _INTERFACEID_LSP1,
24
+ _INTERFACEID_LSP1_DELEGATE,
25
+ _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
26
+ } from "../LSP1UniversalReceiver/LSP1Constants.sol";
27
+ import {
28
+ _INTERFACEID_LSP9,
29
+ _TYPEID_LSP9_VAULTRECIPIENT,
30
+ _TYPEID_LSP9_VAULTSENDER
31
+ } from "./LSP9Constants.sol";
19
32
 
20
33
  /**
21
34
  * @title Core Implementation of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
22
35
  * @author Fabian Vogelsteller, Yamen Merhi, Jean Cavallera
23
36
  * @dev Could be owned by a UniversalProfile and able to register received asset with UniversalReceiverDelegateVault
24
37
  */
25
- contract LSP9VaultCore is ILSP1UniversalReceiver, ERC725XCore, ERC725YCore {
26
- using ERC725Utils for IERC725Y;
27
-
38
+ contract LSP9VaultCore is ERC725XCore, ERC725YCore, ClaimOwnership, ILSP1UniversalReceiver {
28
39
  /**
29
- * @notice Emitted when a native token is received
40
+ * @notice Emitted when receiving native tokens
30
41
  * @param sender The address of the sender
31
42
  * @param value The amount of value sent
32
43
  */
@@ -40,17 +51,11 @@ contract LSP9VaultCore is ILSP1UniversalReceiver, ERC725XCore, ERC725YCore {
40
51
  modifier onlyAllowed() {
41
52
  if (msg.sender != owner()) {
42
53
  address universalReceiverAddress = address(
43
- bytes20(
44
- IERC725Y(this).getDataSingle(
45
- _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
46
- )
47
- )
54
+ bytes20(_getData(_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY))
48
55
  );
49
56
  require(
50
- ERC165Checker.supportsInterface(
51
- msg.sender,
52
- _INTERFACEID_LSP1_DELEGATE
53
- ) && msg.sender == universalReceiverAddress,
57
+ ERC165Checker.supportsERC165Interface(msg.sender, _INTERFACEID_LSP1_DELEGATE) &&
58
+ msg.sender == universalReceiverAddress,
54
59
  "Only Owner or Universal Receiver Delegate allowed"
55
60
  );
56
61
  }
@@ -60,13 +65,70 @@ contract LSP9VaultCore is ILSP1UniversalReceiver, ERC725XCore, ERC725YCore {
60
65
  // public functions
61
66
 
62
67
  /**
63
- * @dev Emits an event when a native token is received
68
+ * @dev Emits an event when receiving native tokens
64
69
  */
65
- receive() external payable {
66
- emit ValueReceived(_msgSender(), msg.value);
70
+ fallback() external payable virtual {
71
+ if (msg.value > 0) emit ValueReceived(msg.sender, msg.value);
67
72
  }
68
73
 
69
- // ERC725Y
74
+ // ERC165
75
+
76
+ /**
77
+ * @dev See {IERC165-supportsInterface}.
78
+ */
79
+ function supportsInterface(bytes4 interfaceId)
80
+ public
81
+ view
82
+ virtual
83
+ override(ERC725XCore, ERC725YCore)
84
+ returns (bool)
85
+ {
86
+ return
87
+ interfaceId == _INTERFACEID_LSP9 ||
88
+ interfaceId == _INTERFACEID_LSP1 ||
89
+ interfaceId == _INTERFACEID_CLAIM_OWNERSHIP ||
90
+ super.supportsInterface(interfaceId);
91
+ }
92
+
93
+ // ERC173 - Modified ClaimOwnership
94
+
95
+ /**
96
+ * @dev Sets the pending owner
97
+ */
98
+ function transferOwnership(address newOwner)
99
+ public
100
+ virtual
101
+ override(ClaimOwnership, OwnableUnset)
102
+ onlyOwner
103
+ {
104
+ ClaimOwnership._transferOwnership(newOwner);
105
+ }
106
+
107
+ /**
108
+ * @dev Transfer the ownership and notify the vault sender and vault receiver
109
+ */
110
+ function claimOwnership() public virtual override {
111
+ address previousOwner = owner();
112
+
113
+ _claimOwnership();
114
+
115
+ _notifyVaultSender(previousOwner);
116
+ _notifyVaultReceiver(msg.sender);
117
+ }
118
+
119
+ // ERC725
120
+
121
+ /**
122
+ * @inheritdoc IERC725Y
123
+ * @dev Sets data as bytes in the vault storage for a single key.
124
+ * SHOULD only be callable by the owner of the contract set via ERC173
125
+ * and the UniversalReceiverDelegate
126
+ *
127
+ * Emits a {DataChanged} event.
128
+ */
129
+ function setData(bytes32 dataKey, bytes memory dataValue) public virtual override onlyAllowed {
130
+ _setData(dataKey, dataValue);
131
+ }
70
132
 
71
133
  /**
72
134
  * @inheritdoc IERC725Y
@@ -76,99 +138,68 @@ contract LSP9VaultCore is ILSP1UniversalReceiver, ERC725XCore, ERC725YCore {
76
138
  *
77
139
  * Emits a {DataChanged} event.
78
140
  */
79
- function setData(bytes32[] memory _keys, bytes[] memory _values)
141
+ function setData(bytes32[] memory dataKeys, bytes[] memory dataValues)
80
142
  public
81
143
  virtual
82
144
  override
83
145
  onlyAllowed
84
146
  {
85
- require(
86
- _keys.length == _values.length,
87
- "Keys length not equal to values length"
88
- );
89
- for (uint256 i = 0; i < _keys.length; i++) {
90
- _setData(_keys[i], _values[i]);
147
+ require(dataKeys.length == dataValues.length, "Keys length not equal to values length");
148
+ for (uint256 i = 0; i < dataKeys.length; i++) {
149
+ _setData(dataKeys[i], dataValues[i]);
91
150
  }
92
151
  }
93
152
 
94
153
  // LSP1
95
154
 
96
- function universalReceiver(bytes32 _typeId, bytes calldata _data)
97
- external
155
+ /**
156
+ * @notice Triggers the UniversalReceiver event when this function gets executed successfully.
157
+ * @dev Forwards the call to the UniversalReceiverDelegate if set.
158
+ * @param typeId The type of call received.
159
+ * @param data The data received.
160
+ */
161
+ function universalReceiver(bytes32 typeId, bytes calldata data)
162
+ public
163
+ payable
98
164
  virtual
99
165
  override
100
166
  returns (bytes memory returnValue)
101
167
  {
102
- bytes memory receiverData = IERC725Y(this).getDataSingle(
103
- _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
104
- );
105
- returnValue = "";
106
-
107
- // call external contract
108
- if (receiverData.length == 20) {
109
- address universalReceiverAddress = BytesLib.toAddress(
110
- receiverData,
111
- 0
112
- );
168
+ bytes memory lsp1DelegateValue = _getData(_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY);
169
+
170
+ if (lsp1DelegateValue.length >= 20) {
171
+ address universalReceiverDelegate = address(bytes20(lsp1DelegateValue));
113
172
 
114
173
  if (
115
- ERC165(universalReceiverAddress).supportsInterface(
174
+ ERC165Checker.supportsERC165Interface(
175
+ universalReceiverDelegate,
116
176
  _INTERFACEID_LSP1_DELEGATE
117
177
  )
118
178
  ) {
119
- returnValue = ILSP1UniversalReceiverDelegate(
120
- universalReceiverAddress
121
- ).universalReceiverDelegate(_msgSender(), _typeId, _data);
179
+ returnValue = ILSP1UniversalReceiverDelegate(universalReceiverDelegate)
180
+ .universalReceiverDelegate(msg.sender, msg.value, typeId, data);
122
181
  }
123
182
  }
124
-
125
- emit UniversalReceiver(_msgSender(), _typeId, returnValue, _data);
126
-
127
- return returnValue;
183
+ emit UniversalReceiver(msg.sender, msg.value, typeId, returnValue, data);
128
184
  }
129
185
 
130
- // ERC173
186
+ // internal functions
131
187
 
132
188
  /**
133
- * @inheritdoc OwnableUnset
134
- * @dev Transfer the ownership and notify the vault sender and vault receiver
189
+ * @dev Calls the universalReceiver function of the sender if supports LSP1 InterfaceId
135
190
  */
136
- function transferOwnership(address newOwner)
137
- public
138
- virtual
139
- override
140
- onlyOwner
141
- {
142
- _notifyVaultSender(msg.sender);
143
-
144
- OwnableUnset.transferOwnership(newOwner);
145
-
146
- _notifyVaultReceiver(newOwner);
147
- }
148
-
149
- // internal functions
150
-
151
- function _notifyVaultSender(address _sender) internal virtual {
152
- if (
153
- ERC165Checker.supportsERC165(_sender) &&
154
- ERC165Checker.supportsInterface(_sender, _INTERFACEID_LSP1)
155
- ) {
156
- ILSP1UniversalReceiver(_sender).universalReceiver(
157
- _TYPEID_LSP9_VAULTSENDER,
158
- ""
159
- );
191
+ function _notifyVaultSender(address sender) internal virtual {
192
+ if (ERC165Checker.supportsERC165Interface(sender, _INTERFACEID_LSP1)) {
193
+ ILSP1UniversalReceiver(sender).universalReceiver(_TYPEID_LSP9_VAULTSENDER, "");
160
194
  }
161
195
  }
162
196
 
163
- function _notifyVaultReceiver(address _receiver) internal virtual {
164
- if (
165
- ERC165Checker.supportsERC165(_receiver) &&
166
- ERC165Checker.supportsInterface(_receiver, _INTERFACEID_LSP1)
167
- ) {
168
- ILSP1UniversalReceiver(_receiver).universalReceiver(
169
- _TYPEID_LSP9_VAULTRECIPIENT,
170
- ""
171
- );
197
+ /**
198
+ * @dev Calls the universalReceiver function of the recipient if supports LSP1 InterfaceId
199
+ */
200
+ function _notifyVaultReceiver(address receiver) internal virtual {
201
+ if (ERC165Checker.supportsERC165Interface(receiver, _INTERFACEID_LSP1)) {
202
+ ILSP1UniversalReceiver(receiver).universalReceiver(_TYPEID_LSP9_VAULTRECIPIENT, "");
172
203
  }
173
204
  }
174
205
  }
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.0;
3
3
 
4
4
  // modules
5
- import "./LSP9VaultInitAbstract.sol";
5
+ import {LSP9VaultInitAbstract} from "./LSP9VaultInitAbstract.sol";
6
6
 
7
7
  /**
8
8
  * @title Deployable Proxy Implementation of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
@@ -11,9 +11,17 @@ import "./LSP9VaultInitAbstract.sol";
11
11
  */
12
12
  contract LSP9VaultInit is LSP9VaultInitAbstract {
13
13
  /**
14
- * @inheritdoc LSP9VaultInitAbstract
14
+ * @dev initialize (= lock) base implementation contract on deployment
15
15
  */
16
- function initialize(address _newOwner) public override initializer {
17
- LSP9VaultInitAbstract.initialize(_newOwner);
16
+ constructor() {
17
+ _disableInitializers();
18
+ }
19
+
20
+ /**
21
+ * @notice Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key
22
+ * @param newOwner the owner of the contract
23
+ */
24
+ function initialize(address newOwner) public virtual initializer {
25
+ LSP9VaultInitAbstract._initialize(newOwner);
18
26
  }
19
27
  }
@@ -1,60 +1,34 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.0;
3
3
 
4
+ // interfaces
5
+ import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
+
4
7
  // modules
5
- import "@erc725/smart-contracts/contracts/ERC725InitAbstract.sol";
6
- import "./LSP9VaultCore.sol";
8
+ import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
9
+ import {Initializable} from "@erc725/smart-contracts/contracts/custom/Initializable.sol";
10
+ import {LSP9VaultCore, ClaimOwnership} from "./LSP9VaultCore.sol";
11
+
12
+ // constants
13
+ import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
14
+ import {
15
+ _INTERFACEID_LSP9,
16
+ _LSP9_SUPPORTED_STANDARDS_KEY,
17
+ _LSP9_SUPPORTED_STANDARDS_VALUE
18
+ } from "../LSP9Vault/LSP9Constants.sol";
7
19
 
8
20
  /**
9
21
  * @title Inheritable Proxy Implementation of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
10
22
  * @author Fabian Vogelsteller, Yamen Merhi, Jean Cavallera
11
23
  * @dev Could be owned by a UniversalProfile and able to register received asset with UniversalReceiverDelegateVault
12
24
  */
13
- abstract contract LSP9VaultInitAbstract is LSP9VaultCore, ERC725InitAbstract {
14
- /**
15
- * @notice Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key and register
16
- * LSP1UniversalReceiver and LSP9Vault InterfaceId
17
- * @param _newOwner the owner of the contract
18
- */
19
- function initialize(address _newOwner)
20
- public
21
- virtual
22
- override
23
- onlyInitializing
24
- {
25
- ERC725InitAbstract.initialize(_newOwner);
26
-
27
- // set SupportedStandards:LSP9Vault
28
- bytes32 key = 0xeafec4d89fa9619884b6b891356264550000000000000000000000007c0334a1;
29
- bytes memory value = hex"7c0334a1";
30
- _setData(key, value);
31
-
32
- _notifyVaultReceiver(_newOwner);
25
+ abstract contract LSP9VaultInitAbstract is Initializable, LSP9VaultCore {
26
+ function _initialize(address newOwner) internal virtual onlyInitializing {
27
+ OwnableUnset._setOwner(newOwner);
33
28
 
34
- _registerInterface(_INTERFACEID_LSP1);
35
- _registerInterface(_INTERFACEID_LSP9);
36
- }
37
-
38
- /**
39
- * @inheritdoc OwnableUnset
40
- */
41
- function transferOwnership(address newOwner)
42
- public
43
- override(OwnableUnset, LSP9VaultCore)
44
- onlyOwner
45
- {
46
- LSP9VaultCore.transferOwnership(newOwner);
47
- }
29
+ // set key SupportedStandards:LSP9Vault
30
+ _setData(_LSP9_SUPPORTED_STANDARDS_KEY, _LSP9_SUPPORTED_STANDARDS_VALUE);
48
31
 
49
- /**
50
- * @inheritdoc LSP9VaultCore
51
- */
52
- function setData(bytes32[] memory _keys, bytes[] memory _values)
53
- public
54
- virtual
55
- override(ERC725YCore, LSP9VaultCore)
56
- onlyAllowed
57
- {
58
- LSP9VaultCore.setData(_keys, _values);
32
+ _notifyVaultReceiver(newOwner);
59
33
  }
60
34
  }
@@ -0,0 +1,43 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.0;
3
+
4
+ // libraries
5
+ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
6
+
7
+ // modules
8
+ import {ERC165Storage} from "@openzeppelin/contracts/utils/introspection/ERC165Storage.sol";
9
+
10
+ contract AddressRegistry is ERC165Storage {
11
+ using EnumerableSet for EnumerableSet.AddressSet;
12
+
13
+ EnumerableSet.AddressSet internal _addressStore;
14
+
15
+ function addAddress(address _address) public virtual returns (bool) {
16
+ return _addressStore.add(_address);
17
+ }
18
+
19
+ function removeAddress(address _address) public virtual returns (bool) {
20
+ return _addressStore.remove(_address);
21
+ }
22
+
23
+ function getAddress(uint256 _index) public view returns (address) {
24
+ return _addressStore.at(_index);
25
+ }
26
+
27
+ function getIndex(address _address) public view returns (uint256) {
28
+ require(_addressStore.contains(_address), "EnumerableSet: Index not found");
29
+ return _addressStore._inner._indexes[bytes32(uint256(uint160(_address)))] - 1;
30
+ }
31
+
32
+ function getAllRawValues() public view returns (bytes32[] memory) {
33
+ return _addressStore._inner._values;
34
+ }
35
+
36
+ function containsAddress(address _address) public view returns (bool) {
37
+ return _addressStore.contains(_address);
38
+ }
39
+
40
+ function length() public view returns (uint256) {
41
+ return _addressStore.length();
42
+ }
43
+ }
@@ -0,0 +1,33 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.0;
3
+
4
+ // libraries
5
+ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
6
+
7
+ // modules
8
+ import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
9
+ import {AddressRegistry} from "./AddressRegistry.sol";
10
+
11
+ // constants
12
+ import {_INTERFACEID_ERC725Y} from "@erc725/smart-contracts/contracts/constants.sol";
13
+
14
+ contract AddressRegistryRequiresERC725 is AddressRegistry {
15
+ using EnumerableSet for EnumerableSet.AddressSet;
16
+
17
+ function addAddress(address _address) public override returns (bool) {
18
+ require(
19
+ ERC165(_address).supportsInterface(_INTERFACEID_ERC725Y),
20
+ "Only ERC725Y addresses can be added"
21
+ );
22
+ return _addressStore.add(_address);
23
+ }
24
+
25
+ function removeAddress(address _address) public override returns (bool) {
26
+ require(
27
+ ERC165(msg.sender).supportsInterface(_INTERFACEID_ERC725Y),
28
+ "Only ERC725Y can call this function"
29
+ );
30
+ require(msg.sender == _address, "Only an address can remove itself.");
31
+ return _addressStore.remove(_address);
32
+ }
33
+ }