@lukso/lsp-smart-contracts 0.7.0 → 0.8.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 (172) hide show
  1. package/CONTRIBUTING.md +39 -0
  2. package/README.md +93 -40
  3. package/artifacts/Create2Factory.json +2 -2
  4. package/artifacts/LSP0ERC725Account.json +194 -15
  5. package/artifacts/LSP0ERC725AccountInit.json +194 -15
  6. package/artifacts/LSP11BasicSocialRecovery.json +493 -0
  7. package/artifacts/LSP11BasicSocialRecoveryInit.json +513 -0
  8. package/artifacts/LSP16UniversalFactory.json +236 -0
  9. package/artifacts/LSP1UniversalReceiverDelegateUP.json +134 -15
  10. package/artifacts/LSP1UniversalReceiverDelegateVault.json +80 -15
  11. package/artifacts/LSP4Compatibility.json +16 -0
  12. package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
  13. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
  14. package/artifacts/LSP6KeyManager.json +177 -33
  15. package/artifacts/LSP6KeyManagerInit.json +177 -33
  16. package/artifacts/LSP7CappedSupply.json +26 -5
  17. package/artifacts/LSP7CappedSupplyInitAbstract.json +26 -5
  18. package/artifacts/LSP7CompatibleERC20.json +26 -5
  19. package/artifacts/LSP7CompatibleERC20InitAbstract.json +28 -7
  20. package/artifacts/LSP7CompatibleERC20Mintable.json +29 -8
  21. package/artifacts/LSP7CompatibleERC20MintableInit.json +29 -8
  22. package/artifacts/LSP7DigitalAsset.json +26 -5
  23. package/artifacts/LSP7DigitalAssetInitAbstract.json +26 -5
  24. package/artifacts/LSP7Mintable.json +29 -8
  25. package/artifacts/LSP7MintableInit.json +29 -8
  26. package/artifacts/LSP8CappedSupply.json +27 -6
  27. package/artifacts/LSP8CappedSupplyInitAbstract.json +27 -6
  28. package/artifacts/LSP8CompatibleERC721.json +28 -7
  29. package/artifacts/LSP8CompatibleERC721InitAbstract.json +30 -9
  30. package/artifacts/LSP8CompatibleERC721Mintable.json +31 -10
  31. package/artifacts/LSP8CompatibleERC721MintableInit.json +31 -10
  32. package/artifacts/LSP8IdentifiableDigitalAsset.json +27 -6
  33. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +27 -6
  34. package/artifacts/LSP8Mintable.json +30 -9
  35. package/artifacts/LSP8MintableInit.json +30 -9
  36. package/artifacts/LSP9Vault.json +202 -17
  37. package/artifacts/LSP9VaultInit.json +202 -17
  38. package/artifacts/UniversalProfile.json +194 -15
  39. package/artifacts/UniversalProfileInit.json +194 -15
  40. package/artifacts/UniversalReceiverAddressStore.json +3 -3
  41. package/common/constants.d.ts +738 -0
  42. package/common/constants.js +785 -0
  43. package/contracts/Custom/EIP191Signer.sol +12 -0
  44. package/contracts/Factories/Create2Factory.sol +1 -3
  45. package/contracts/LSP0ERC725Account/LSP0Constants.sol +13 -2
  46. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +2 -1
  47. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +320 -63
  48. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
  49. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +2 -1
  50. package/contracts/LSP0ERC725Account/LSP0Utils.sol +50 -0
  51. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
  52. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +212 -0
  53. package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +177 -0
  54. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +23 -0
  55. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +258 -0
  56. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +26 -0
  57. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +19 -0
  58. package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +6 -0
  59. package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +60 -0
  60. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +53 -0
  61. package/contracts/LSP14Ownable2Step/LSP14Constants.sol +15 -0
  62. package/contracts/LSP14Ownable2Step/LSP14Errors.sol +12 -0
  63. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +212 -0
  64. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +246 -0
  65. package/contracts/LSP17ContractExtension/LSP17Constants.sol +17 -0
  66. package/contracts/LSP17ContractExtension/LSP17Errors.sol +7 -0
  67. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +104 -0
  68. package/contracts/LSP17ContractExtension/LSP17Extension.sol +45 -0
  69. package/contracts/LSP17ContractExtension/LSP17Utils.sol +20 -0
  70. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
  71. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +5 -3
  72. package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +21 -0
  73. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +155 -37
  74. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +64 -31
  75. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +53 -40
  76. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +45 -23
  77. package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
  78. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
  79. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +1 -1
  80. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
  81. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +2 -2
  82. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +2 -2
  83. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +3 -3
  84. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
  85. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +102 -114
  86. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +25 -7
  87. package/contracts/LSP6KeyManager/LSP6Constants.sol +43 -38
  88. package/contracts/LSP6KeyManager/LSP6Errors.sol +90 -21
  89. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
  90. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +224 -506
  91. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -1
  92. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +3 -2
  93. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +229 -0
  94. package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +25 -0
  95. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +606 -0
  96. package/contracts/LSP6KeyManager/LSP6Utils.sol +156 -35
  97. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +8 -8
  98. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +6 -6
  99. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +1 -1
  100. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +36 -36
  101. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +1 -1
  102. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +33 -1
  103. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +1 -1
  104. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +24 -0
  105. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +28 -8
  106. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +28 -11
  107. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +87 -20
  108. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +97 -19
  109. package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
  110. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +3 -4
  111. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
  112. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +3 -3
  113. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +3 -5
  114. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +2 -2
  115. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +3 -3
  116. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +7 -7
  117. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +7 -7
  118. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +45 -2
  119. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +2 -2
  120. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +57 -60
  121. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -1
  122. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +5 -2
  123. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +20 -0
  124. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +27 -7
  125. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +27 -10
  126. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +234 -30
  127. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +238 -30
  128. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +32 -4
  129. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +35 -8
  130. package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
  131. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +3 -4
  132. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +3 -3
  133. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +3 -3
  134. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +3 -4
  135. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +2 -2
  136. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +3 -3
  137. package/contracts/LSP9Vault/LSP9Constants.sol +10 -10
  138. package/contracts/LSP9Vault/LSP9Errors.sol +8 -0
  139. package/contracts/LSP9Vault/LSP9Vault.sol +6 -4
  140. package/contracts/LSP9Vault/LSP9VaultCore.sol +350 -127
  141. package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -2
  142. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +4 -3
  143. package/contracts/Legacy/Registries/AddressRegistry.sol +1 -1
  144. package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +1 -1
  145. package/contracts/Legacy/UniversalReceiverAddressStore.sol +4 -14
  146. package/contracts/UniversalProfile.sol +2 -2
  147. package/contracts/UniversalProfileInit.sol +2 -2
  148. package/contracts/UniversalProfileInitAbstract.sol +1 -1
  149. package/contracts/Utils/GasLib.sol +1 -1
  150. package/module/constants.d.ts +738 -0
  151. package/module/constants.js +782 -0
  152. package/package.json +42 -12
  153. package/artifacts/UniversalFactory.json +0 -127
  154. package/constants.js +0 -594
  155. package/contracts/Custom/ClaimOwnership.sol +0 -96
  156. package/contracts/Custom/ERC165Checker.sol +0 -130
  157. package/contracts/Custom/IClaimOwnership.sol +0 -12
  158. package/contracts/Factories/UniversalFactory.sol +0 -159
  159. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +0 -24
  160. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +0 -82
  161. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +0 -73
  162. package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +0 -9
  163. package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +0 -17
  164. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +0 -57
  165. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Core.sol +0 -111
  166. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +0 -17
  167. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +0 -17
  168. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +0 -58
  169. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleConstants.sol +0 -6
  170. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Core.sol +0 -211
  171. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +0 -50
  172. package/contracts/Utils/UtilsLib.sol +0 -31
@@ -1,130 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol)
3
-
4
- pragma solidity ^0.8.0;
5
-
6
- // This contract is a modified version of OpenZeppelin implementation, where we modify the visibility of
7
- // `supportsERC165Interface`, which check the given interfaceId, to internal and to be used in contract implementations,
8
- // instead of `supportsInterface` to save gas, as the latter check for 3 interfaceIds; InterfaceId of ERC165, 0xffffffff
9
- // and the given interfaceId.
10
-
11
- // interfaces
12
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
13
-
14
- /**
15
- * @dev Library used to query support of an interface declared via {IERC165}.
16
- *
17
- * Note that these functions return the actual result of the query: they do not
18
- * `revert` if an interface is not supported. It is up to the caller to decide
19
- * what to do in these cases.
20
- */
21
- library ERC165Checker {
22
- // As per the EIP-165 spec, no interface should ever match 0xffffffff
23
- bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
24
-
25
- /**
26
- * @dev Returns true if `account` supports the {IERC165} interface,
27
- */
28
- function supportsERC165(address account) internal view returns (bool) {
29
- // Any contract that implements ERC165 must explicitly indicate support of
30
- // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
31
- return
32
- supportsERC165Interface(account, type(IERC165).interfaceId) &&
33
- !supportsERC165Interface(account, _INTERFACE_ID_INVALID);
34
- }
35
-
36
- /**
37
- * @dev Returns true if `account` supports the interface defined by
38
- * `interfaceId`. Support for {IERC165} itself is queried automatically.
39
- *
40
- * See {IERC165-supportsInterface}.
41
- */
42
- function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
43
- // query support of both ERC165 as per the spec and support of _interfaceId
44
- return supportsERC165(account) && supportsERC165Interface(account, interfaceId);
45
- }
46
-
47
- /**
48
- * @dev Returns a boolean array where each value corresponds to the
49
- * interfaces passed in and whether they're supported or not. This allows
50
- * you to batch check interfaces for a contract where your expectation
51
- * is that some interfaces may not be supported.
52
- *
53
- * See {IERC165-supportsInterface}.
54
- *
55
- * _Available since v3.4._
56
- */
57
- function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
58
- internal
59
- view
60
- returns (bool[] memory)
61
- {
62
- // an array of booleans corresponding to interfaceIds and whether they're supported or not
63
- bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
64
-
65
- // query support of ERC165 itself
66
- if (supportsERC165(account)) {
67
- // query support of each interface in interfaceIds
68
- for (uint256 i = 0; i < interfaceIds.length; i++) {
69
- interfaceIdsSupported[i] = supportsERC165Interface(account, interfaceIds[i]);
70
- }
71
- }
72
-
73
- return interfaceIdsSupported;
74
- }
75
-
76
- /**
77
- * @dev Returns true if `account` supports all the interfaces defined in
78
- * `interfaceIds`. Support for {IERC165} itself is queried automatically.
79
- *
80
- * Batch-querying can lead to gas savings by skipping repeated checks for
81
- * {IERC165} support.
82
- *
83
- * See {IERC165-supportsInterface}.
84
- */
85
- function supportsAllInterfaces(address account, bytes4[] memory interfaceIds)
86
- internal
87
- view
88
- returns (bool)
89
- {
90
- // query support of ERC165 itself
91
- if (!supportsERC165(account)) {
92
- return false;
93
- }
94
-
95
- // query support of each interface in _interfaceIds
96
- for (uint256 i = 0; i < interfaceIds.length; i++) {
97
- if (!supportsERC165Interface(account, interfaceIds[i])) {
98
- return false;
99
- }
100
- }
101
-
102
- // all interfaces supported
103
- return true;
104
- }
105
-
106
- /**
107
- * @notice Query if a contract implements an interface, does not check ERC165 support
108
- * @param account The address of the contract to query for support of an interface
109
- * @param interfaceId The interface identifier, as specified in ERC-165
110
- * @return true if the contract at account indicates support of the interface with
111
- * identifier interfaceId, false otherwise
112
- * @dev Assumes that account contains a contract that supports ERC165, otherwise
113
- * the behavior of this method is undefined. This precondition can be checked
114
- * with {supportsERC165}.
115
- * Interface identification is specified in ERC-165.
116
- */
117
- function supportsERC165Interface(address account, bytes4 interfaceId)
118
- internal
119
- view
120
- returns (bool)
121
- {
122
- bytes memory encodedParams = abi.encodeWithSelector(
123
- IERC165.supportsInterface.selector,
124
- interfaceId
125
- );
126
- (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);
127
- if (result.length < 32) return false;
128
- return success && abi.decode(result, (uint256)) > 0;
129
- }
130
- }
@@ -1,12 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.0;
3
-
4
- bytes4 constant _INTERFACEID_CLAIM_OWNERSHIP = 0xa375e9c6;
5
-
6
- interface IClaimOwnership {
7
- event RenounceOwnershipInitiated();
8
-
9
- function pendingOwner() external view returns (address);
10
-
11
- function claimOwnership() external;
12
- }
@@ -1,159 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.0;
3
-
4
- // libraries
5
- import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
6
- import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
7
- import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
8
- import {Address} from "@openzeppelin/contracts/utils/Address.sol";
9
-
10
- /**
11
- * @dev UniversalFactory contract can be used to deploy CREATE2 contracts; normal contracts and minimal
12
- * proxies (EIP-1167) with the ability to deploy the same contract at the same address on different chains.
13
- * If the contract has a constructor, the arguments will be part of the byteCode
14
- * If the contract has an `initialize` function, the parameters of this function will be included in
15
- * the salt to ensure that the parameters of the contract should be the same on each chain.
16
- *
17
- * Security measures were taken to avoid deploying proxies from the `deployCreate2(..)` function
18
- * to prevent the problem mentioned above.
19
- *
20
- * This contract should be deployed using Nick's Method.
21
- * More information: https://weka.medium.com/how-to-send-ether-to-11-440-people-187e332566b7
22
- */
23
- contract UniversalFactory {
24
- using BytesLib for bytes;
25
-
26
- // The bytecode hash of EIP-1167 Minimal Proxy
27
- bytes32 private constant _MINIMAL_PROXY_BYTECODE_HASH_PT1 =
28
- 0x72307939328b75c6e301a012c75e0a4e690a99036b95f6e6f4f1b5aba02a9ce4;
29
-
30
- bytes32 private constant _MINIMAL_PROXY_BYTECODE_HASH_PT2 =
31
- 0x11a195f66c9175f46895bae2006d40848a680c7068b9fc4af248ff9a54a47e45;
32
-
33
- /**
34
- * @dev Throws if the `byteCode` passed to the function is the EIP-1167 Minimal Proxy bytecode
35
- */
36
- modifier notMinimalProxy(bytes memory byteCode) virtual {
37
- if (byteCode.length == 55) {
38
- if (
39
- keccak256(byteCode.slice(0, 20)) == _MINIMAL_PROXY_BYTECODE_HASH_PT1 &&
40
- keccak256(byteCode.slice(40, 15)) == _MINIMAL_PROXY_BYTECODE_HASH_PT2
41
- ) {
42
- revert("Minimal Proxies deployment not allowed");
43
- }
44
- }
45
- _;
46
- }
47
-
48
- /**
49
- * @dev Returns the address where a contract will be stored if deployed via `CREATE2`. The address is
50
- * constructed using the parameters below. Any change in one of them will result in a new destination address.
51
- */
52
- function calculateAddress(
53
- bytes32 byteCodeHash,
54
- bytes32 salt,
55
- bytes memory initializeCallData
56
- ) public view returns (address) {
57
- bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
58
- return Create2.computeAddress(generatedSalt, byteCodeHash);
59
- }
60
-
61
- /**
62
- * @dev Returns the address of an EIP1167 proxy contract. The address is constructed using
63
- * the parameters below. Any change in one of them will result in a new destination address.
64
- */
65
- function calculateProxyAddress(
66
- address baseContract,
67
- bytes32 salt,
68
- bytes memory initializeCallData
69
- ) public view returns (address) {
70
- bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
71
- return Clones.predictDeterministicAddress(baseContract, generatedSalt);
72
- }
73
-
74
- /**
75
- * @dev Deploys a contract using `CREATE2`. The address where the contract will be deployed
76
- * can be known in advance via {calculateAddress}. The salt is a combination between an initializable
77
- * boolean, `salt` and the `initializeCallData` if the contract is initializable. This method allow users
78
- * to have the same contracts at the same address across different chains with the same parameters.
79
- *
80
- * Using the same `byteCode` and salt multiple time will revert, since
81
- * the contract cannot be deployed twice at the same address.
82
- *
83
- * Deploying a minimal proxy from this function will revert.
84
- */
85
- function deployCreate2(
86
- bytes memory byteCode,
87
- bytes32 salt,
88
- bytes memory initializeCallData
89
- ) public payable notMinimalProxy(byteCode) returns (address contractCreated) {
90
- bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
91
- contractCreated = Create2.deploy(msg.value, generatedSalt, byteCode);
92
-
93
- if (initializeCallData.length != 0) {
94
- // solhint-disable avoid-low-level-calls
95
- (bool success, bytes memory returnData) = contractCreated.call(initializeCallData);
96
- Address.verifyCallResult(
97
- success,
98
- returnData,
99
- "UniversalFactory: could not initialize the created contract"
100
- );
101
- }
102
- }
103
-
104
- /**
105
- * @dev Deploys and returns the address of a clone that mimics the behaviour of `baseContract`.
106
- * The address where the contract will be deployed can be known in advance via {calculateProxyAddress}.
107
- *
108
- * This function uses the CREATE2 opcode and a salt to deterministically deploy
109
- * the clone. The salt is a combination between an initializable boolean, `salt`
110
- * and the `initializeCallData` if the contract is initializable. This method allow users
111
- * to have the same contracts at the same address across different chains with the same parameters.
112
- *
113
- * Using the same `baseContract` and salt multiple time will revert, since
114
- * the clones cannot be deployed twice at the same address.
115
- */
116
- function deployCreate2Proxy(
117
- address baseContract,
118
- bytes32 salt,
119
- bytes memory initializeCallData
120
- ) public payable returns (address proxy) {
121
- bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
122
- proxy = Clones.cloneDeterministic(baseContract, generatedSalt);
123
-
124
- if (initializeCallData.length != 0) {
125
- // solhint-disable avoid-low-level-calls
126
- (bool success, bytes memory returnData) = proxy.call{value: msg.value}(
127
- initializeCallData
128
- );
129
- Address.verifyCallResult(
130
- success,
131
- returnData,
132
- "UniversalFactory: could not initialize the created contract"
133
- );
134
- } else {
135
- require(
136
- msg.value == 0,
137
- "UniversalFactory: value cannot be sent to the factory if initializeCallData is empty"
138
- );
139
- }
140
- }
141
-
142
- /** internal functions */
143
-
144
- /**
145
- * @dev Calculates the salt including the initializeCallData, or without but hashing it with a zero bytes padding.
146
- */
147
- function _generateSalt(bytes memory initializeCallData, bytes32 salt)
148
- internal
149
- pure
150
- returns (bytes32)
151
- {
152
- bool initializable = initializeCallData.length != 0;
153
- if (initializable) {
154
- return keccak256(abi.encodePacked(initializable, initializeCallData, salt));
155
- } else {
156
- return keccak256(abi.encodePacked(initializable, salt));
157
- }
158
- }
159
- }
@@ -1,24 +0,0 @@
1
- // SPDX-License-Identifier: CC0-1.0
2
- pragma solidity ^0.8.0;
3
-
4
- /**
5
- * @title The interface for LSP1UniversalReceiverDelegate
6
- * @dev LSP1UniversalReceiverDelegate allows for an external universal receiver smart contract,
7
- * that is the delegate of the initial universal receiver
8
- */
9
- interface ILSP1UniversalReceiverDelegate {
10
- /**
11
- * @dev Get called by the universalReceiver function, can be customized to have a specific logic
12
- * @param caller The address calling the universalReceiver function
13
- * @param value The amount sent to the universalReceiver function
14
- * @param typeId The hash of a specific standard or a hook
15
- * @param data The arbitrary data received with the call
16
- * @return result Any useful data could be returned
17
- */
18
- function universalReceiverDelegate(
19
- address caller,
20
- uint256 value,
21
- bytes32 typeId,
22
- bytes memory data
23
- ) external returns (bytes memory result);
24
- }
@@ -1,82 +0,0 @@
1
- // SPDX-License-Identifier: CC0-1.0
2
- pragma solidity ^0.8.0;
3
-
4
- // interfaces
5
- import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
- import {ILSP7DigitalAsset} from "../../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
7
- import {ILSP6KeyManager} from "../../../LSP6KeyManager/ILSP6KeyManager.sol";
8
-
9
- // libraries
10
- import {ERC165Checker} from "../../../Custom/ERC165Checker.sol";
11
- import {LSP1Utils} from "../../LSP1Utils.sol";
12
- import {LSP2Utils} from "../../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
13
- import {LSP5Utils} from "../../../LSP5ReceivedAssets/LSP5Utils.sol";
14
-
15
- // modules
16
- import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
17
- import {LSP6KeyManager} from "../../../LSP6KeyManager/LSP6KeyManager.sol";
18
-
19
- // constants
20
- import {_INTERFACEID_LSP6} from "../../../LSP6KeyManager/LSP6Constants.sol";
21
- import {_TYPEID_LSP9_VAULTSENDER} from "../../../LSP9Vault/LSP9Constants.sol";
22
-
23
- /**
24
- * @dev Function logic to add and remove the MapAndArrayKey of incoming assets and vaults
25
- */
26
- abstract contract TokenAndVaultHandling {
27
- function _tokenAndVaultHandling(address caller, bytes32 typeId)
28
- internal
29
- returns (bytes memory result)
30
- {
31
- address keyManager = ERC725Y(msg.sender).owner();
32
- if (!ERC165Checker.supportsERC165Interface(keyManager, _INTERFACEID_LSP6)) return "";
33
-
34
- address target = ILSP6KeyManager(keyManager).target();
35
-
36
- // check if the caller is the same account controlled by the keyManager
37
- if (msg.sender != target) return "";
38
-
39
- (
40
- bool isReceiving,
41
- bytes32 arrayLengthKey,
42
- bytes10 mapPrefix,
43
- bytes4 interfaceID
44
- ) = LSP1Utils.getTransferDetails(typeId);
45
-
46
- bytes32 mapKey = LSP2Utils.generateMappingKey(mapPrefix, bytes20(caller));
47
- bytes memory mapValue = IERC725Y(msg.sender).getData(mapKey);
48
-
49
- if (isReceiving) {
50
- // if the map value is already set, then do nothing
51
- if (bytes12(mapValue) != bytes12(0)) return "";
52
-
53
- result = LSP5Utils.addMapAndArrayKeyViaKeyManager(
54
- IERC725Y(msg.sender),
55
- arrayLengthKey,
56
- mapKey,
57
- caller,
58
- interfaceID,
59
- keyManager
60
- );
61
- } else {
62
- // if there is no map value for the asset to remove, then do nothing
63
- if (bytes12(mapValue) == bytes12(0)) return "";
64
-
65
- // if it's a token transfer (LSP7/LSP8)
66
- if (typeId != _TYPEID_LSP9_VAULTSENDER) {
67
- // if the amount sent is not the full balance, then do not remove the keys
68
- uint256 balance = ILSP7DigitalAsset(caller).balanceOf(msg.sender);
69
- if (balance != 0) return "";
70
- }
71
-
72
- result = LSP5Utils.removeMapAndArrayKeyViaKeyManager(
73
- IERC725Y(msg.sender),
74
- arrayLengthKey,
75
- mapPrefix,
76
- mapKey,
77
- mapValue,
78
- keyManager
79
- );
80
- }
81
- }
82
- }
@@ -1,73 +0,0 @@
1
- // SPDX-License-Identifier: CC0-1.0
2
- pragma solidity ^0.8.0;
3
-
4
- // interfaces
5
- import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
- import {ILSP7DigitalAsset} from "../../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
7
-
8
- // libraries
9
- import {ERC165Checker} from "../../../Custom/ERC165Checker.sol";
10
- import {LSP1Utils} from "../../LSP1Utils.sol";
11
- import {LSP2Utils} from "../../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
12
- import {LSP5Utils} from "../../../LSP5ReceivedAssets/LSP5Utils.sol";
13
-
14
- // modules
15
- import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
16
- import {LSP6KeyManager} from "../../../LSP6KeyManager/LSP6KeyManager.sol";
17
-
18
- // constants
19
- import "../../LSP1Constants.sol";
20
- import "../../../LSP9Vault/LSP9Constants.sol";
21
-
22
- /**
23
- * @dev Function logic to add and remove the MapAndArrayKey of incoming assets and vaults
24
- */
25
- abstract contract TokenHandling {
26
- function _tokenHandling(address caller, bytes32 typeId) internal returns (bytes memory result) {
27
- if (!ERC165Checker.supportsERC165Interface(msg.sender, _INTERFACEID_LSP9)) return "";
28
-
29
- (
30
- bool isReceiving,
31
- bytes32 arrayLengthKey,
32
- bytes10 mapPrefix,
33
- bytes4 interfaceID
34
- ) = LSP1Utils.getTransferDetails(typeId);
35
-
36
- bytes32 mapKey = LSP2Utils.generateMappingKey(mapPrefix, bytes20(caller));
37
- bytes memory mapValue = IERC725Y(msg.sender).getData(mapKey);
38
-
39
- if (isReceiving) {
40
- // if the map value is already set, then do nothing
41
- if (bytes12(mapValue) != bytes12(0)) return "";
42
-
43
- (bytes32[] memory receiverDataKeys, bytes[] memory receiverDataValues) = LSP5Utils
44
- .addMapAndArrayKey(
45
- IERC725Y(msg.sender),
46
- arrayLengthKey,
47
- mapKey,
48
- caller,
49
- interfaceID
50
- );
51
-
52
- IERC725Y(msg.sender).setData(receiverDataKeys, receiverDataValues);
53
- } else {
54
- // if there is no map value for the asset to remove, then do nothing
55
- if (bytes12(mapValue) == bytes12(0)) return "";
56
-
57
- // if the amount sent is not the full balance, then do not remove the keys
58
- uint256 balance = ILSP7DigitalAsset(caller).balanceOf(msg.sender);
59
- if (balance != 0) return "";
60
-
61
- (bytes32[] memory senderDataKeys, bytes[] memory senderDataValues) = LSP5Utils
62
- .removeMapAndArrayKey(
63
- IERC725Y(msg.sender),
64
- arrayLengthKey,
65
- mapPrefix,
66
- mapKey,
67
- mapValue
68
- );
69
-
70
- IERC725Y(msg.sender).setData(senderDataKeys, senderDataValues);
71
- }
72
- }
73
- }
@@ -1,9 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.0;
3
-
4
- /**
5
- * @dev reverts when `value` is not a properly ABI encoded array
6
- * @param value the value to check for an abi-encoded array
7
- * @param valueType the type of the value to check for an abi-encoded array
8
- */
9
- error InvalidABIEncodedArray(bytes value, string valueType);
@@ -1,17 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // interfaces
6
- import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
7
-
8
- /**
9
- * @dev LSP7 extension, adds token supply cap.
10
- */
11
- interface ILSP7CappedSupply is ILSP7DigitalAsset {
12
- /**
13
- * @dev Returns the number of tokens that can be minted
14
- * @return The number of tokens that can be minted
15
- */
16
- function tokenSupplyCap() external view returns (uint256);
17
- }
@@ -1,57 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // interfaces
6
- import {ILSP7CappedSupply} from "./ILSP7CappedSupply.sol";
7
-
8
- // modules
9
- import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
10
-
11
- /**
12
- * @dev LSP7 extension, adds token supply cap.
13
- */
14
- abstract contract LSP7CappedSupplyCore is LSP7DigitalAssetCore, ILSP7CappedSupply {
15
- // --- Errors
16
-
17
- error LSP7CappedSupplyRequired();
18
- error LSP7CappedSupplyCannotMintOverCap();
19
-
20
- // --- Storage
21
-
22
- uint256 internal _tokenSupplyCap;
23
-
24
- // --- Token queries
25
-
26
- /**
27
- * @inheritdoc ILSP7CappedSupply
28
- */
29
- function tokenSupplyCap() public view virtual returns (uint256) {
30
- return _tokenSupplyCap;
31
- }
32
-
33
- // --- Transfer functionality
34
-
35
- /**
36
- * @dev Mints `amount` and transfers it to `to`.
37
- *
38
- * Requirements:
39
- *
40
- * - `tokenSupplyCap() - totalSupply()` must be greater than zero.
41
- * - `to` cannot be the zero address.
42
- *
43
- * Emits a {Transfer} event.
44
- */
45
- function _mint(
46
- address to,
47
- uint256 amount,
48
- bool force,
49
- bytes memory data
50
- ) internal virtual override {
51
- if (totalSupply() + amount > tokenSupplyCap()) {
52
- revert LSP7CappedSupplyCannotMintOverCap();
53
- }
54
-
55
- super._mint(to, amount, force, data);
56
- }
57
- }
@@ -1,111 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // interfaces
6
- import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
7
- import {ILSP7CompatibleERC20} from "./ILSP7CompatibleERC20.sol";
8
-
9
- // modules
10
- import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
11
- import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
12
-
13
- /**
14
- * @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
15
- */
16
- abstract contract LSP7CompatibleERC20Core is
17
- LSP4Compatibility,
18
- LSP7DigitalAssetCore,
19
- ILSP7CompatibleERC20
20
- {
21
- // --- Overrides
22
-
23
- /**
24
- * @inheritdoc ILSP7CompatibleERC20
25
- */
26
- function approve(address operator, uint256 amount) public virtual returns (bool) {
27
- authorizeOperator(operator, amount);
28
- return true;
29
- }
30
-
31
- /**
32
- * @inheritdoc ILSP7CompatibleERC20
33
- */
34
- function allowance(address tokenOwner, address operator)
35
- public
36
- view
37
- virtual
38
- returns (uint256)
39
- {
40
- return authorizedAmountFor(operator, tokenOwner);
41
- }
42
-
43
- /**
44
- * @inheritdoc ILSP7CompatibleERC20
45
- * @dev Compatible with ERC20 transfer.
46
- * Using force=true so that EOA and any contract may receive the tokens.
47
- */
48
- function transfer(address to, uint256 amount) public virtual override returns (bool) {
49
- transfer(msg.sender, to, amount, true, "");
50
- return true;
51
- }
52
-
53
- /**
54
- * @inheritdoc ILSP7CompatibleERC20
55
- * @dev Compatible with ERC20 transferFrom.
56
- * Using force=true so that EOA and any contract may receive the tokens.
57
- */
58
- function transferFrom(
59
- address from,
60
- address to,
61
- uint256 amount
62
- ) public virtual returns (bool) {
63
- transfer(from, to, amount, true, "");
64
- return true;
65
- }
66
-
67
- function authorizeOperator(address operator, uint256 amount)
68
- public
69
- virtual
70
- override(ILSP7DigitalAsset, LSP7DigitalAssetCore)
71
- {
72
- super.authorizeOperator(operator, amount);
73
-
74
- emit Approval(msg.sender, operator, amount);
75
- }
76
-
77
- // --- Internals
78
-
79
- function _transfer(
80
- address from,
81
- address to,
82
- uint256 amount,
83
- bool force,
84
- bytes memory data
85
- ) internal virtual override {
86
- super._transfer(from, to, amount, force, data);
87
-
88
- emit Transfer(from, to, amount);
89
- }
90
-
91
- function _mint(
92
- address to,
93
- uint256 amount,
94
- bool force,
95
- bytes memory data
96
- ) internal virtual override {
97
- super._mint(to, amount, force, data);
98
-
99
- emit Transfer(address(0), to, amount);
100
- }
101
-
102
- function _burn(
103
- address from,
104
- uint256 amount,
105
- bytes memory data
106
- ) internal virtual override {
107
- super._burn(from, amount, data);
108
-
109
- emit Transfer(from, address(0), amount);
110
- }
111
- }