@lukso/lsp-smart-contracts 0.11.0-rc.0 → 0.11.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 (199) hide show
  1. package/README.md +1 -0
  2. package/artifacts/LSP0ERC725Account.json +7 -2
  3. package/artifacts/LSP0ERC725AccountInit.json +7 -2
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateUP.json +3 -79
  7. package/artifacts/LSP1UniversalReceiverDelegateVault.json +3 -41
  8. package/artifacts/LSP23LinkedContractsFactory.json +544 -0
  9. package/artifacts/LSP6KeyManager.json +24 -19
  10. package/artifacts/LSP6KeyManagerInit.json +24 -19
  11. package/artifacts/LSP7CappedSupply.json +88 -0
  12. package/artifacts/LSP7CappedSupplyInitAbstract.json +88 -0
  13. package/artifacts/LSP7CompatibleERC20.json +88 -0
  14. package/artifacts/LSP7CompatibleERC20InitAbstract.json +88 -0
  15. package/artifacts/LSP7CompatibleERC20Mintable.json +90 -2
  16. package/artifacts/LSP7CompatibleERC20MintableInit.json +90 -2
  17. package/artifacts/LSP7DigitalAsset.json +88 -0
  18. package/artifacts/LSP7DigitalAssetInitAbstract.json +88 -0
  19. package/artifacts/LSP7Mintable.json +90 -2
  20. package/artifacts/LSP7MintableInit.json +90 -2
  21. package/artifacts/LSP8CappedSupply.json +59 -0
  22. package/artifacts/LSP8CappedSupplyInitAbstract.json +59 -0
  23. package/artifacts/LSP8CompatibleERC721.json +60 -1
  24. package/artifacts/LSP8CompatibleERC721InitAbstract.json +60 -1
  25. package/artifacts/LSP8CompatibleERC721Mintable.json +62 -3
  26. package/artifacts/LSP8CompatibleERC721MintableInit.json +62 -3
  27. package/artifacts/LSP8IdentifiableDigitalAsset.json +59 -0
  28. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +59 -0
  29. package/artifacts/LSP8Mintable.json +61 -2
  30. package/artifacts/LSP8MintableInit.json +61 -2
  31. package/artifacts/LSP9Vault.json +7 -2
  32. package/artifacts/LSP9VaultInit.json +7 -2
  33. package/artifacts/UniversalProfile.json +7 -2
  34. package/artifacts/UniversalProfileInit.json +7 -2
  35. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +8 -36
  36. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  37. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +15 -30
  38. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +122 -206
  39. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +18 -36
  40. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +8 -34
  41. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +148 -177
  42. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +21 -20
  43. package/contracts/LSP14Ownable2Step/LSP14Errors.sol +13 -2
  44. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +50 -20
  45. package/contracts/LSP17ContractExtension/LSP17Errors.sol +10 -0
  46. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +16 -34
  47. package/contracts/LSP17ContractExtension/LSP17Utils.sol +1 -1
  48. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +16 -11
  49. package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +5 -10
  50. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +192 -177
  51. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +150 -88
  52. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +66 -48
  53. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +1 -1
  54. package/contracts/LSP23LinkedContractsDeployment/ILSP23LinkedContractsFactory.sol +192 -0
  55. package/contracts/LSP23LinkedContractsDeployment/IPostDeploymentModule.sol +18 -0
  56. package/contracts/LSP23LinkedContractsDeployment/LSP23Errors.sol +24 -0
  57. package/contracts/LSP23LinkedContractsDeployment/LSP23LinkedContractsFactory.sol +392 -0
  58. package/contracts/{LSP23MultiChainDeployment → LSP23LinkedContractsDeployment}/modules/UniversalProfileInitPostDeploymentModule.sol +5 -1
  59. package/contracts/LSP23LinkedContractsDeployment/modules/UniversalProfilePostDeploymentModule.sol +61 -0
  60. package/contracts/LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol +68 -0
  61. package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +8 -0
  62. package/contracts/LSP25ExecuteRelayCall/LSP25Errors.sol +17 -0
  63. package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +143 -0
  64. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +256 -61
  65. package/contracts/{LSP3UniversalProfile → LSP3ProfileMetadata}/LSP3Constants.sol +3 -3
  66. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +9 -8
  67. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +13 -6
  68. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +4 -4
  69. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +148 -189
  70. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +26 -54
  71. package/contracts/LSP6KeyManager/LSP6Constants.sol +1 -3
  72. package/contracts/LSP6KeyManager/LSP6Errors.sol +142 -63
  73. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +7 -4
  74. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +125 -80
  75. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +8 -4
  76. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +1 -1
  77. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +52 -84
  78. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +59 -10
  79. package/contracts/LSP6KeyManager/LSP6Utils.sol +67 -46
  80. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +116 -78
  81. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +4 -1
  82. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +128 -6
  83. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +212 -80
  84. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +126 -3
  85. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +7 -5
  86. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +27 -14
  87. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +2 -4
  88. package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +2 -4
  89. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +29 -11
  90. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +30 -9
  91. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +46 -14
  92. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +43 -12
  93. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +14 -0
  94. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +9 -4
  95. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +7 -1
  96. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +8 -8
  97. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +7 -6
  98. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +10 -2
  99. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +120 -92
  100. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +4 -1
  101. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +135 -6
  102. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +128 -38
  103. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +134 -5
  104. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +83 -41
  105. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +13 -5
  106. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +24 -0
  107. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +30 -12
  108. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +31 -10
  109. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +96 -31
  110. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +98 -23
  111. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +21 -4
  112. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +12 -2
  113. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +21 -0
  114. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +9 -4
  115. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +13 -0
  116. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +15 -6
  117. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +7 -5
  118. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +17 -2
  119. package/contracts/LSP9Vault/ILSP9Vault.sol +10 -5
  120. package/contracts/LSP9Vault/LSP9Errors.sol +3 -2
  121. package/contracts/LSP9Vault/LSP9Vault.sol +12 -4
  122. package/contracts/LSP9Vault/LSP9VaultCore.sol +245 -182
  123. package/contracts/LSP9Vault/LSP9VaultInit.sol +10 -3
  124. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -6
  125. package/contracts/UniversalProfile.sol +8 -6
  126. package/contracts/UniversalProfileInit.sol +6 -6
  127. package/contracts/UniversalProfileInitAbstract.sol +10 -3
  128. package/devdocs/LSP0ERC725Account.json +54 -37
  129. package/devdocs/LSP0ERC725AccountInit.json +56 -38
  130. package/devdocs/LSP1UniversalReceiverDelegateUP.json +14 -55
  131. package/devdocs/LSP1UniversalReceiverDelegateVault.json +9 -33
  132. package/devdocs/LSP23LinkedContractsFactory.json +81 -0
  133. package/devdocs/LSP4DigitalAssetMetadata.json +5 -5
  134. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +4 -4
  135. package/devdocs/LSP6KeyManager.json +109 -70
  136. package/devdocs/LSP6KeyManagerInit.json +109 -70
  137. package/devdocs/LSP7CappedSupply.json +90 -42
  138. package/devdocs/LSP7CappedSupplyInitAbstract.json +86 -40
  139. package/devdocs/LSP7CompatibleERC20.json +79 -43
  140. package/devdocs/LSP7CompatibleERC20InitAbstract.json +75 -39
  141. package/devdocs/LSP7CompatibleERC20Mintable.json +87 -40
  142. package/devdocs/LSP7CompatibleERC20MintableInit.json +82 -42
  143. package/devdocs/LSP7DigitalAsset.json +76 -40
  144. package/devdocs/LSP7DigitalAssetInitAbstract.json +73 -37
  145. package/devdocs/LSP7Mintable.json +79 -51
  146. package/devdocs/LSP7MintableInit.json +78 -49
  147. package/devdocs/LSP8CappedSupply.json +72 -43
  148. package/devdocs/LSP8CappedSupplyInitAbstract.json +68 -41
  149. package/devdocs/LSP8CompatibleERC721.json +85 -64
  150. package/devdocs/LSP8CompatibleERC721InitAbstract.json +81 -60
  151. package/devdocs/LSP8CompatibleERC721Mintable.json +98 -60
  152. package/devdocs/LSP8CompatibleERC721MintableInit.json +93 -62
  153. package/devdocs/LSP8IdentifiableDigitalAsset.json +58 -41
  154. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -40
  155. package/devdocs/LSP8Mintable.json +65 -48
  156. package/devdocs/LSP8MintableInit.json +64 -47
  157. package/devdocs/LSP9Vault.json +61 -18
  158. package/devdocs/LSP9VaultInit.json +59 -17
  159. package/devdocs/UniversalProfile.json +53 -35
  160. package/devdocs/UniversalProfileInit.json +53 -35
  161. package/dist/constants.cjs.js +6236 -2587
  162. package/dist/constants.d.ts +3851 -1129
  163. package/dist/constants.es.js +6236 -2587
  164. package/package.json +6 -4
  165. package/userdocs/LSP0ERC725Account.json +40 -8
  166. package/userdocs/LSP0ERC725AccountInit.json +40 -8
  167. package/userdocs/LSP1UniversalReceiverDelegateUP.json +18 -2
  168. package/userdocs/LSP1UniversalReceiverDelegateVault.json +18 -2
  169. package/userdocs/LSP23LinkedContractsFactory.json +29 -0
  170. package/userdocs/LSP4DigitalAssetMetadata.json +1 -1
  171. package/userdocs/LSP6KeyManager.json +144 -6
  172. package/userdocs/LSP6KeyManagerInit.json +147 -6
  173. package/userdocs/LSP7CappedSupply.json +18 -3
  174. package/userdocs/LSP7CappedSupplyInitAbstract.json +17 -2
  175. package/userdocs/LSP7CompatibleERC20.json +3 -9
  176. package/userdocs/LSP7CompatibleERC20InitAbstract.json +2 -8
  177. package/userdocs/LSP7CompatibleERC20Mintable.json +5 -8
  178. package/userdocs/LSP7CompatibleERC20MintableInit.json +3 -9
  179. package/userdocs/LSP7DigitalAsset.json +2 -2
  180. package/userdocs/LSP7DigitalAssetInitAbstract.json +2 -2
  181. package/userdocs/LSP7Mintable.json +3 -3
  182. package/userdocs/LSP7MintableInit.json +3 -3
  183. package/userdocs/LSP8CappedSupply.json +16 -1
  184. package/userdocs/LSP8CappedSupplyInitAbstract.json +15 -0
  185. package/userdocs/LSP8CompatibleERC721.json +24 -3
  186. package/userdocs/LSP8CompatibleERC721InitAbstract.json +23 -2
  187. package/userdocs/LSP8CompatibleERC721Mintable.json +29 -2
  188. package/userdocs/LSP8CompatibleERC721MintableInit.json +27 -3
  189. package/userdocs/LSP8Mintable.json +4 -1
  190. package/userdocs/LSP8MintableInit.json +4 -1
  191. package/userdocs/LSP9Vault.json +50 -4
  192. package/userdocs/LSP9VaultInit.json +50 -4
  193. package/userdocs/UniversalProfile.json +40 -8
  194. package/userdocs/UniversalProfileInit.json +40 -8
  195. package/contracts/LSP0ERC725Account/LSP0Utils.sol +0 -47
  196. package/contracts/LSP23MultiChainDeployment/IOwnerControlledContractDeployer.sol +0 -174
  197. package/contracts/LSP23MultiChainDeployment/IPostDeploymentModule.sol +0 -10
  198. package/contracts/LSP23MultiChainDeployment/LSP23Errors.sol +0 -24
  199. package/contracts/LSP23MultiChainDeployment/OwnerControlledContractDeployer.sol +0 -388
@@ -11,9 +11,24 @@ import {
11
11
  } from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol";
12
12
  import {LSP7DigitalAssetCore} from "./LSP7DigitalAssetCore.sol";
13
13
 
14
+ import {LSP17Extendable} from "../LSP17ContractExtension/LSP17Extendable.sol";
15
+
16
+ // libraries
17
+ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
18
+
14
19
  // constants
15
20
  import {_INTERFACEID_LSP7} from "./LSP7Constants.sol";
16
21
 
22
+ import "../LSP17ContractExtension/LSP17Constants.sol";
23
+
24
+ // errors
25
+
26
+ import {
27
+ NoExtensionFoundForFunctionSelector,
28
+ InvalidFunctionSelector,
29
+ InvalidExtensionAddress
30
+ } from "../LSP17ContractExtension/LSP17Errors.sol";
31
+
17
32
  /**
18
33
  * @title LSP7DigitalAsset contract
19
34
  * @author Matthew Stevens
@@ -21,7 +36,8 @@ import {_INTERFACEID_LSP7} from "./LSP7Constants.sol";
21
36
  */
22
37
  abstract contract LSP7DigitalAssetInitAbstract is
23
38
  LSP4DigitalAssetMetadataInitAbstract,
24
- LSP7DigitalAssetCore
39
+ LSP7DigitalAssetCore,
40
+ LSP17Extendable
25
41
  {
26
42
  function _initialize(
27
43
  string memory name_,
@@ -37,14 +53,121 @@ abstract contract LSP7DigitalAssetInitAbstract is
37
53
  );
38
54
  }
39
55
 
56
+ // fallback function
57
+
58
+ // solhint-disable no-complex-fallback
59
+ /**
60
+ * @notice The `fallback` function was called with the following amount of native tokens: `msg.value`; and the following calldata: `callData`.
61
+ *
62
+ * @dev Achieves the goal of [LSP-17-ContractExtension] standard by extending the contract to handle calls of functions that do not exist natively,
63
+ * forwarding the function call to the extension address mapped to the function being called.
64
+ *
65
+ * This function is executed when:
66
+ * - Sending data of length less than 4 bytes to the contract.
67
+ * - The first 4 bytes of the calldata do not match any publicly callable functions from the contract ABI.
68
+ * - Receiving native tokens
69
+ *
70
+ * 1. If the data is equal or longer than 4 bytes, the [ERC-725Y] storage is queried with the following data key: [_LSP17_EXTENSION_PREFIX] + `bytes4(msg.sig)` (Check [LSP-2-ERC725YJSONSchema] for encoding the data key)
71
+ *
72
+ * - If there is no address stored under the following data key, revert with {NoExtensionFoundForFunctionSelector(bytes4)}. The data key relative to `bytes4(0)` is an exception, where no reverts occurs if there is no extension address stored under. This exception is made to allow users to send random data (graffiti) to the account and to be able to react on it.
73
+ *
74
+ * - If there is an address, forward the `msg.data` to the extension using the CALL opcode, appending 52 bytes (20 bytes of `msg.sender` and 32 bytes of `msg.value`). Return what the calls returns, or revert if the call failed.
75
+ *
76
+ * 2. If the data sent to this function is of length less than 4 bytes (not a function selector), revert.
77
+ */
78
+ fallback(
79
+ bytes calldata callData
80
+ ) external payable virtual returns (bytes memory) {
81
+ if (msg.data.length < 4) {
82
+ revert InvalidFunctionSelector(callData);
83
+ }
84
+ return _fallbackLSP17Extendable(callData);
85
+ }
86
+
87
+ /**
88
+ * @dev Forwards the call with the received value to an extension mapped to a function selector.
89
+ *
90
+ * Calls {_getExtension} to get the address of the extension mapped to the function selector being
91
+ * called on the account. If there is no extension, the address(0) will be returned.
92
+ *
93
+ * Reverts if there is no extension for the function being called.
94
+ *
95
+ * If there is an extension for the function selector being called, it calls the extension with the
96
+ * CALL opcode, passing the {msg.data} appended with the 20 bytes of the {msg.sender} and
97
+ * 32 bytes of the {msg.value}
98
+ *
99
+ * Because the function uses assembly {return()/revert()} to terminate the call, it cannot be
100
+ * called before other codes in fallback().
101
+ *
102
+ * Otherwise, the codes after _fallbackLSP17Extendable() may never be reached.
103
+ */
104
+ function _fallbackLSP17Extendable(
105
+ bytes calldata callData
106
+ ) internal virtual override returns (bytes memory) {
107
+ // If there is a function selector
108
+ address extension = _getExtension(msg.sig);
109
+
110
+ // if no extension was found, revert
111
+ if (extension == address(0))
112
+ revert NoExtensionFoundForFunctionSelector(msg.sig);
113
+
114
+ (bool success, bytes memory result) = extension.call{value: msg.value}(
115
+ abi.encodePacked(callData, msg.sender, msg.value)
116
+ );
117
+
118
+ if (success) {
119
+ return result;
120
+ } else {
121
+ // `mload(result)` -> offset in memory where `result.length` is located
122
+ // `add(result, 32)` -> offset in memory where `result` data starts
123
+ // solhint-disable no-inline-assembly
124
+ /// @solidity memory-safe-assembly
125
+ assembly {
126
+ let resultdata_size := mload(result)
127
+ revert(add(result, 32), resultdata_size)
128
+ }
129
+ }
130
+ }
131
+
132
+ /**
133
+ * @dev Returns the extension address stored under the following data key:
134
+ * - {_LSP17_EXTENSION_PREFIX} + `<bytes4>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key).
135
+ * - If no extension is stored, returns the address(0).
136
+ */
137
+ function _getExtension(
138
+ bytes4 functionSelector
139
+ ) internal view virtual override returns (address) {
140
+ // Generate the data key relevant for the functionSelector being called
141
+ bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
142
+ _LSP17_EXTENSION_PREFIX,
143
+ functionSelector
144
+ );
145
+
146
+ // Check if there is an extension stored under the generated data key
147
+ bytes memory extensionAddress = ERC725YCore._getData(
148
+ mappedExtensionDataKey
149
+ );
150
+ if (extensionAddress.length != 20 && extensionAddress.length != 0)
151
+ revert InvalidExtensionAddress(extensionAddress);
152
+
153
+ return address(bytes20(extensionAddress));
154
+ }
155
+
40
156
  /**
41
157
  * @dev See {IERC165-supportsInterface}.
42
158
  */
43
159
  function supportsInterface(
44
160
  bytes4 interfaceId
45
- ) public view virtual override(IERC165, ERC725YCore) returns (bool) {
161
+ )
162
+ public
163
+ view
164
+ virtual
165
+ override(IERC165, ERC725YCore, LSP17Extendable)
166
+ returns (bool)
167
+ {
46
168
  return
47
169
  interfaceId == _INTERFACEID_LSP7 ||
48
- super.supportsInterface(interfaceId);
170
+ super.supportsInterface(interfaceId) ||
171
+ LSP17Extendable._supportsInterfaceInERC165Extension(interfaceId);
49
172
  }
50
173
  }
@@ -29,7 +29,10 @@ error LSP7AmountExceedsAuthorizedAmount(
29
29
  error LSP7CannotUseAddressZeroAsOperator();
30
30
 
31
31
  /**
32
- * @dev reverts when one tries to send tokens to or from the zero address.
32
+ * @dev reverts when trying to:
33
+ * - mint tokens to the zero address.
34
+ * - burn tokens from the zero address.
35
+ * - transfer tokens from or to the zero address.
33
36
  */
34
37
  error LSP7CannotSendWithAddressZero();
35
38
 
@@ -39,7 +42,7 @@ error LSP7CannotSendWithAddressZero();
39
42
  error LSP7CannotSendToSelf();
40
43
 
41
44
  /**
42
- * @dev reverts when the parameters used for `transferBatch` have different lengths.
45
+ * @dev reverts when the array parameters used in {transferBatch} have different lengths.
43
46
  */
44
47
  error LSP7InvalidTransferBatch();
45
48
 
@@ -52,8 +55,7 @@ error LSP7NotifyTokenReceiverContractMissingLSP1Interface(
52
55
  );
53
56
 
54
57
  /**
55
- * @dev reverts if the `tokenReceiver` is an EOA
56
- * when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`.
58
+ * @dev reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`.
57
59
  */
58
60
  error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
59
61
 
@@ -63,6 +65,6 @@ error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
63
65
  error LSP7TokenOwnerCannotBeOperator();
64
66
 
65
67
  /**
66
- * @dev Reverts when trying to decrease an operator's allowance to more than his current allowance
68
+ * @dev Reverts when trying to decrease an operator's allowance to more than its current allowance.
67
69
  */
68
70
  error LSP7DecreasedAllowanceBelowZero();
@@ -10,8 +10,9 @@ import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
10
10
  */
11
11
  interface ILSP7CompatibleERC20 is ILSP7DigitalAsset {
12
12
  /**
13
- * @notice To provide compatibility with indexing ERC20 events.
14
- * @dev Emitted when `amount` tokens is transferred from `from` to `to`.
13
+ * @dev ERC20 `Transfer` event emitted when `amount` tokens is transferred from `from` to `to`.
14
+ * To provide compatibility with indexing ERC20 events.
15
+ *
15
16
  * @param from The sending address
16
17
  * @param to The receiving address
17
18
  * @param value The amount of tokens transfered.
@@ -19,8 +20,9 @@ interface ILSP7CompatibleERC20 is ILSP7DigitalAsset {
19
20
  event Transfer(address indexed from, address indexed to, uint256 value);
20
21
 
21
22
  /**
22
- * @notice To provide compatibility with indexing ERC20 events.
23
- * @dev Emitted when `owner` enables `spender` for `value` tokens.
23
+ * @dev ERC20 `Approval` event emitted when `owner` enables `spender` for `value` tokens.
24
+ * To provide compatibility with indexing ERC20 events.
25
+ *
24
26
  * @param owner The account giving approval
25
27
  * @param spender The account receiving approval
26
28
  * @param value The amount of tokens `spender` has access to from `owner`
@@ -32,17 +34,23 @@ interface ILSP7CompatibleERC20 is ILSP7DigitalAsset {
32
34
  );
33
35
 
34
36
  /*
35
- * @dev Compatible with ERC20 transfer
36
- * @param to The receiving address
37
- * @param amount The amount of tokens to transfer
37
+ * @dev Transfer function from the ERC20 standard interface.
38
+
39
+ * @param to The address receiving tokens.
40
+ * @param amount The amount of tokens to transfer.
41
+ *
42
+ * @return `true` on successful transfer.
38
43
  */
39
44
  function transfer(address to, uint256 amount) external returns (bool);
40
45
 
41
46
  /*
42
- * @dev Compatible with ERC20 transferFrom
43
- * @param from The sending address
44
- * @param to The receiving address
45
- * @param amount The amount of tokens to transfer
47
+ * @dev Transfer functions for operators from the ERC20 standard interface.
48
+
49
+ * @param from The address sending tokens.
50
+ * @param to The address receiving tokens.
51
+ * @param amount The amount of tokens to transfer.
52
+ *
53
+ * @return `true` on successful transfer.
46
54
  */
47
55
  function transferFrom(
48
56
  address from,
@@ -51,16 +59,21 @@ interface ILSP7CompatibleERC20 is ILSP7DigitalAsset {
51
59
  ) external returns (bool);
52
60
 
53
61
  /*
54
- * @dev Compatible with ERC20 approve
62
+ * @dev Approval function from th ERC20 standard interface.
63
+
55
64
  * @param operator The address to approve for `amount`
56
- * @param amount The amount to approve
65
+ * @param amount The amount to approve.
66
+ *
67
+ * @return `true` on successful approval.
57
68
  */
58
69
  function approve(address operator, uint256 amount) external returns (bool);
59
70
 
60
71
  /*
61
- * @dev Compatible with ERC20 allowance
72
+ * @dev Function to get operator allowance allowed to spend on behalf of `tokenOwner` from the ERC20 standard interface.
73
+
62
74
  * @param tokenOwner The address of the token owner
63
75
  * @param operator The address approved by the `tokenOwner`
76
+ *
64
77
  * @return The amount `operator` is approved by `tokenOwner`
65
78
  */
66
79
  function allowance(
@@ -5,14 +5,12 @@ pragma solidity ^0.8.4;
5
5
  import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
6
6
 
7
7
  /**
8
- * @dev LSP7 extension that allows token holders to destroy both
8
+ * @title LSP7 token extension that allows token holders to destroy both
9
9
  * their own tokens and those that they have an allowance for as an operator.
10
10
  */
11
11
  abstract contract LSP7Burnable is LSP7DigitalAsset {
12
12
  /**
13
- * @dev Destroys `amount` tokens from the `from` address.
14
- *
15
- * See internal _burn function for more details
13
+ * @dev See internal {_burn} function for details.
16
14
  */
17
15
  function burn(
18
16
  address from,
@@ -7,14 +7,12 @@ import {
7
7
  } from "../LSP7DigitalAssetInitAbstract.sol";
8
8
 
9
9
  /**
10
- * @dev LSP7 extension that allows token holders to destroy both
10
+ * @title LSP7 token extension that allows token holders to destroy both
11
11
  * their own tokens and those that they have an allowance for as an operator.
12
12
  */
13
13
  abstract contract LSP7BurnableInitAbstract is LSP7DigitalAssetInitAbstract {
14
14
  /**
15
- * @dev Destroys `amount` tokens from the `from` address.
16
- *
17
- * See internal _burn function for more details
15
+ * @dev See internal {_burn} function for details.
18
16
  */
19
17
  function burn(
20
18
  address from,
@@ -6,19 +6,35 @@ pragma solidity ^0.8.4;
6
6
  import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
7
7
 
8
8
  /**
9
- * @dev LSP7 extension, adds token supply cap.
9
+ * @dev LSP7 token extension to add a max token supply cap.
10
10
  */
11
11
  abstract contract LSP7CappedSupply is LSP7DigitalAsset {
12
12
  // --- Errors
13
+
14
+ /**
15
+ * @notice The `tokenSupplyCap` must be set and cannot be `0`.
16
+ * @dev Reverts when setting `0` for the {tokenSupplyCap}. The max token supply MUST be set to a number greater than 0.
17
+ */
13
18
  error LSP7CappedSupplyRequired();
19
+
20
+ /**
21
+ * @notice Cannot mint anymore as total supply reached the maximum cap.
22
+ * @dev Reverts when trying to mint tokens but the {totalSupply} has reached the maximum {tokenSupplyCap}.
23
+ */
14
24
  error LSP7CappedSupplyCannotMintOverCap();
15
25
 
16
26
  // --- Storage
17
27
  uint256 private immutable _tokenSupplyCap;
18
28
 
19
29
  /**
20
- * @notice Sets the token max supply
21
- * @param tokenSupplyCap_ The Token max supply
30
+ * @notice Deploying a `LSP7CappedSupply` token contract with max token supply cap set to `tokenSupplyCap_`.
31
+ * @dev Deploy a `LSP7CappedSupply` token contract and set the maximum token supply token cap up to which
32
+ * it is not possible to mint more tokens.
33
+ *
34
+ * @param tokenSupplyCap_ The maximum token supply.
35
+ *
36
+ * @custom:requirements
37
+ * - `tokenSupplyCap_` MUST NOT be 0.
22
38
  */
23
39
  constructor(uint256 tokenSupplyCap_) {
24
40
  if (tokenSupplyCap_ == 0) {
@@ -31,8 +47,12 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset {
31
47
  // --- Token queries
32
48
 
33
49
  /**
34
- * @dev Returns the number of tokens that can be minted
35
- * @return The number of tokens that can be minted
50
+ * @notice The maximum supply amount of tokens allowed to exist is `_tokenSupplyCap`.
51
+ *
52
+ * @dev Get the maximum number of tokens that can exist to circulate. Once {totalSupply} reaches
53
+ * reaches {totalSuuplyCap}, it is not possible to mint more tokens.
54
+ *
55
+ * @return The maximum number of tokens that can exist in the contract.
36
56
  */
37
57
  function tokenSupplyCap() public view virtual returns (uint256) {
38
58
  return _tokenSupplyCap;
@@ -41,14 +61,12 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset {
41
61
  // --- Transfer functionality
42
62
 
43
63
  /**
44
- * @dev Mints `amount` and transfers it to `to`.
45
- *
46
- * Requirements:
64
+ * @dev Same as {_mint} but allows to mint only if the {totalSupply} does not exceed the {tokenSupplyCap}
65
+ * after `amount` of tokens have been minted.
47
66
  *
48
- * - `tokenSupplyCap() - totalSupply()` must be greater than zero.
67
+ * @custom:requirements
68
+ * - {tokenSupplyCap} - {totalSupply} must be greater than zero.
49
69
  * - `to` cannot be the zero address.
50
- *
51
- * Emits a {Transfer} event.
52
70
  */
53
71
  function _mint(
54
72
  address to,
@@ -8,16 +8,36 @@ import {
8
8
  } from "../LSP7DigitalAssetInitAbstract.sol";
9
9
 
10
10
  /**
11
- * @dev LSP7 extension, adds token supply cap.
11
+ * @dev LSP7 token extension to add a max token supply cap (proxy version).
12
12
  */
13
13
  abstract contract LSP7CappedSupplyInitAbstract is LSP7DigitalAssetInitAbstract {
14
14
  // --- Errors
15
+
16
+ /**
17
+ * @notice The `tokenSupplyCap` must be set and cannot be `0`.
18
+ * @dev Reverts when setting `0` for the {tokenSupplyCap}. The max token supply MUST be set to a number greater than 0.
19
+ */
15
20
  error LSP7CappedSupplyRequired();
21
+
22
+ /**
23
+ * @notice Cannot mint anymore as total supply reached the maximum cap.
24
+ * @dev Reverts when trying to mint tokens but the {totalSupply} has reached the maximum {tokenSupplyCap}.
25
+ */
16
26
  error LSP7CappedSupplyCannotMintOverCap();
17
27
 
18
28
  // --- Storage
19
29
  uint256 private _tokenSupplyCap;
20
30
 
31
+ /**
32
+ * @notice Deploying a `LSP7CappedSupply` token contract with max token supply cap set to `tokenSupplyCap_`.
33
+ * @dev Deploy a `LSP7CappedSupply` token contract and set the maximum token supply token cap up to which
34
+ * it is not possible to mint more tokens.
35
+ *
36
+ * @param tokenSupplyCap_ The maximum token supply.
37
+ *
38
+ * @custom:requirements
39
+ * - `tokenSupplyCap_` MUST NOT be 0.
40
+ */
21
41
  function _initialize(
22
42
  uint256 tokenSupplyCap_
23
43
  ) internal virtual onlyInitializing {
@@ -31,8 +51,11 @@ abstract contract LSP7CappedSupplyInitAbstract is LSP7DigitalAssetInitAbstract {
31
51
  // --- Token queries
32
52
 
33
53
  /**
34
- * @dev Returns the number of tokens that can be minted
35
- * @return The number of tokens that can be minted
54
+ * @notice The maximum supply amount of tokens allowed to exist is `_tokenSupplyCap`.
55
+ * @dev Get the maximum number of tokens that can exist to circulate. Once {totalSupply} reaches
56
+ * reaches {totalSuuplyCap}, it is not possible to mint more tokens.
57
+ *
58
+ * @return The maximum number of tokens that can exist in the contract.
36
59
  */
37
60
  function tokenSupplyCap() public view virtual returns (uint256) {
38
61
  return _tokenSupplyCap;
@@ -41,14 +64,12 @@ abstract contract LSP7CappedSupplyInitAbstract is LSP7DigitalAssetInitAbstract {
41
64
  // --- Transfer functionality
42
65
 
43
66
  /**
44
- * @dev Mints `amount` and transfers it to `to`.
45
- *
46
- * Requirements:
67
+ * @dev Same as {_mint} but allows to mint only if the {totalSupply} does not exceed the {tokenSupplyCap}
68
+ * after `amount` of tokens have been minted.
47
69
  *
48
- * - `tokenSupplyCap() - totalSupply()` must be greater than zero.
70
+ * @custom:requirements
71
+ * - {tokenSupplyCap} - {totalSupply} must be greater than zero.
49
72
  * - `to` cannot be the zero address.
50
- *
51
- * Emits a {Transfer} event.
52
73
  */
53
74
  function _mint(
54
75
  address to,
@@ -11,6 +11,7 @@ import {
11
11
  } from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
12
12
  import {
13
13
  LSP7DigitalAsset,
14
+ LSP7DigitalAssetCore,
14
15
  LSP4DigitalAssetMetadata,
15
16
  ERC725YCore
16
17
  } from "../LSP7DigitalAsset.sol";
@@ -24,10 +25,12 @@ abstract contract LSP7CompatibleERC20 is
24
25
  LSP7DigitalAsset
25
26
  {
26
27
  /**
27
- * @notice Sets the name, the symbol and the owner of the token
28
- * @param name_ The name of the token
29
- * @param symbol_ The symbol of the token
30
- * @param newOwner_ The owner of the token
28
+ * @notice Deploying a `LSP7CompatibleERC20` token contract with: token name = `name_`, token symbol = `symbol_`, and
29
+ * address `newOwner_` as the token contract owner.
30
+ *
31
+ * @param name_ The name of the token.
32
+ * @param symbol_ The symbol of the token.
33
+ * @param newOwner_ The owner of the token contract.
31
34
  */
32
35
  constructor(
33
36
  string memory name_,
@@ -36,7 +39,7 @@ abstract contract LSP7CompatibleERC20 is
36
39
  ) LSP7DigitalAsset(name_, symbol_, newOwner_, false) {}
37
40
 
38
41
  /**
39
- * @dev See {IERC165-supportsInterface}.
42
+ * @inheritdoc LSP7DigitalAsset
40
43
  */
41
44
  function supportsInterface(
42
45
  bytes4 interfaceId
@@ -67,14 +70,14 @@ abstract contract LSP7CompatibleERC20 is
67
70
  address operator,
68
71
  uint256 amount
69
72
  ) public virtual returns (bool) {
70
- authorizeOperator(operator, amount);
73
+ authorizeOperator(operator, amount, "");
71
74
  return true;
72
75
  }
73
76
 
74
77
  /**
75
78
  * @inheritdoc ILSP7CompatibleERC20
76
- * @dev Compatible with ERC20 transferFrom.
77
- * Using allowNonLSP1Recipient=true so that EOA and any contract may receive the tokens.
79
+ *
80
+ * @custom:info This function uses the `allowNonLSP1Recipient` parameter as `true` so that EOA and any contract can receive tokens.
78
81
  */
79
82
  function transferFrom(
80
83
  address from,
@@ -89,8 +92,8 @@ abstract contract LSP7CompatibleERC20 is
89
92
 
90
93
  /**
91
94
  * @inheritdoc ILSP7CompatibleERC20
92
- * @dev Compatible with ERC20 transfer.
93
- * Using allowNonLSP1Recipient=true so that EOA and any contract may receive the tokens.
95
+ *
96
+ * @custom:info This function uses the `allowNonLSP1Recipient` parameter as `true` so that EOA and any contract can receive tokens.
94
97
  */
95
98
  function transfer(
96
99
  address to,
@@ -101,18 +104,30 @@ abstract contract LSP7CompatibleERC20 is
101
104
  }
102
105
 
103
106
  /**
104
- * @dev same behaviour as LSP7DigitalAssetCore
105
- * with the addition of emitting ERC20 Approval event.
107
+ * @inheritdoc LSP7DigitalAssetCore
106
108
  */
107
109
  function _updateOperator(
108
110
  address tokenOwner,
109
111
  address operator,
110
- uint256 amount
112
+ uint256 amount,
113
+ bytes memory operatorNotificationData
111
114
  ) internal virtual override {
112
- super._updateOperator(tokenOwner, operator, amount);
115
+ super._updateOperator(
116
+ tokenOwner,
117
+ operator,
118
+ amount,
119
+ operatorNotificationData
120
+ );
113
121
  emit Approval(tokenOwner, operator, amount);
114
122
  }
115
123
 
124
+ /**
125
+ * @inheritdoc LSP7DigitalAssetCore
126
+ *
127
+ * @custom:events
128
+ * - LSP7 {Transfer} event.
129
+ * - ERC20 {Transfer} event.
130
+ */
116
131
  function _transfer(
117
132
  address from,
118
133
  address to,
@@ -124,6 +139,13 @@ abstract contract LSP7CompatibleERC20 is
124
139
  super._transfer(from, to, amount, allowNonLSP1Recipient, data);
125
140
  }
126
141
 
142
+ /**
143
+ * @inheritdoc LSP7DigitalAssetCore
144
+ *
145
+ * @custom:events
146
+ * - LSP7 {Transfer} event with `address(0)` as `from`.
147
+ * - ERC20 {Transfer} event with `address(0)` as `from`.
148
+ */
127
149
  function _mint(
128
150
  address to,
129
151
  uint256 amount,
@@ -134,6 +156,13 @@ abstract contract LSP7CompatibleERC20 is
134
156
  super._mint(to, amount, allowNonLSP1Recipient, data);
135
157
  }
136
158
 
159
+ /**
160
+ * @inheritdoc LSP7DigitalAssetCore
161
+ *
162
+ * @custom:events
163
+ * - LSP7 {Transfer} event with `address(0)` as the `to` address.
164
+ * - ERC20 {Transfer} event with `address(0)` as the `to` address.
165
+ */
137
166
  function _burn(
138
167
  address from,
139
168
  uint256 amount,
@@ -143,6 +172,9 @@ abstract contract LSP7CompatibleERC20 is
143
172
  super._burn(from, amount, data);
144
173
  }
145
174
 
175
+ /**
176
+ * @inheritdoc LSP4DigitalAssetMetadata
177
+ */
146
178
  function _setData(
147
179
  bytes32 key,
148
180
  bytes memory value