@lukso/lsp-smart-contracts 0.6.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/CONTRIBUTING.md +31 -0
  2. package/README.md +73 -28
  3. package/artifacts/Create2Factory.json +2 -2
  4. package/artifacts/LSP0ERC725Account.json +227 -15
  5. package/artifacts/LSP0ERC725AccountInit.json +227 -41
  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 +22 -0
  12. package/artifacts/LSP4DigitalAssetMetadata.json +22 -0
  13. package/artifacts/{LSP4DigitalAssetMetadataInit.json → LSP4DigitalAssetMetadataInitAbstract.json} +24 -51
  14. package/artifacts/LSP6KeyManager.json +188 -33
  15. package/artifacts/LSP6KeyManagerInit.json +188 -33
  16. package/artifacts/LSP7CappedSupply.json +58 -31
  17. package/artifacts/{LSP7CappedSupplyInit.json → LSP7CappedSupplyInitAbstract.json} +60 -72
  18. package/artifacts/LSP7CompatibleERC20.json +52 -46
  19. package/artifacts/LSP7CompatibleERC20InitAbstract.json +733 -0
  20. package/artifacts/LSP7CompatibleERC20Mintable.json +61 -34
  21. package/artifacts/LSP7CompatibleERC20MintableInit.json +66 -60
  22. package/artifacts/LSP7DigitalAsset.json +52 -51
  23. package/artifacts/LSP7DigitalAssetInitAbstract.json +556 -0
  24. package/artifacts/LSP7Mintable.json +62 -35
  25. package/artifacts/LSP7MintableInit.json +62 -61
  26. package/artifacts/LSP8CappedSupply.json +64 -5
  27. package/artifacts/LSP8CappedSupplyInitAbstract.json +667 -0
  28. package/artifacts/LSP8CompatibleERC721.json +102 -21
  29. package/artifacts/LSP8CompatibleERC721InitAbstract.json +936 -0
  30. package/artifacts/LSP8CompatibleERC721Mintable.json +111 -9
  31. package/artifacts/LSP8CompatibleERC721MintableInit.json +116 -35
  32. package/artifacts/LSP8IdentifiableDigitalAsset.json +58 -20
  33. package/artifacts/{LSP8CappedSupplyInit.json → LSP8IdentifiableDigitalAssetInitAbstract.json} +62 -65
  34. package/artifacts/LSP8Mintable.json +67 -8
  35. package/artifacts/LSP8MintableInit.json +67 -34
  36. package/artifacts/LSP9Vault.json +235 -17
  37. package/artifacts/LSP9VaultInit.json +235 -43
  38. package/artifacts/UniversalProfile.json +227 -15
  39. package/artifacts/UniversalProfileInit.json +227 -41
  40. package/artifacts/UniversalReceiverAddressStore.json +3 -3
  41. package/constants.js +416 -95
  42. package/contracts/Custom/EIP191Signer.sol +12 -0
  43. package/contracts/Factories/Create2Factory.sol +1 -3
  44. package/contracts/LSP0ERC725Account/LSP0Constants.sol +13 -2
  45. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +2 -1
  46. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +274 -74
  47. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
  48. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -2
  49. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +4 -4
  50. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +214 -0
  51. package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +177 -0
  52. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +23 -0
  53. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +258 -0
  54. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +26 -0
  55. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +19 -0
  56. package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +6 -0
  57. package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +60 -0
  58. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +53 -0
  59. package/contracts/LSP14Ownable2Step/LSP14Constants.sol +15 -0
  60. package/contracts/LSP14Ownable2Step/LSP14Errors.sol +12 -0
  61. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +212 -0
  62. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +246 -0
  63. package/contracts/LSP17ContractExtension/LSP17Constants.sol +17 -0
  64. package/contracts/LSP17ContractExtension/LSP17Errors.sol +7 -0
  65. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +104 -0
  66. package/contracts/LSP17ContractExtension/LSP17Extension.sol +45 -0
  67. package/contracts/LSP17ContractExtension/LSP17Utils.sol +20 -0
  68. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
  69. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +5 -3
  70. package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +21 -0
  71. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +156 -42
  72. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +64 -31
  73. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +54 -41
  74. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +136 -28
  75. package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
  76. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
  77. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +1 -1
  78. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
  79. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +16 -7
  80. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +16 -7
  81. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +3 -3
  82. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +4 -4
  83. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +103 -115
  84. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +26 -8
  85. package/contracts/LSP6KeyManager/LSP6Constants.sol +45 -45
  86. package/contracts/LSP6KeyManager/LSP6Errors.sol +97 -20
  87. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +3 -2
  88. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +786 -359
  89. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +2 -2
  90. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +4 -3
  91. package/contracts/LSP6KeyManager/LSP6Utils.sol +127 -35
  92. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +26 -13
  93. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +6 -6
  94. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +5 -5
  95. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +65 -52
  96. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +3 -3
  97. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +30 -1
  98. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +1 -1
  99. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +24 -0
  100. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +28 -8
  101. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +28 -11
  102. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +87 -20
  103. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +97 -19
  104. package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
  105. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +3 -4
  106. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +9 -2
  107. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +3 -3
  108. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +12 -12
  109. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +5 -5
  110. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +11 -10
  111. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +10 -8
  112. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +11 -11
  113. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +45 -1
  114. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +3 -3
  115. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +75 -71
  116. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -1
  117. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +20 -3
  118. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +20 -0
  119. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +27 -7
  120. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +27 -10
  121. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +236 -30
  122. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +240 -30
  123. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +49 -0
  124. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +51 -0
  125. package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
  126. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +3 -4
  127. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +9 -2
  128. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +3 -3
  129. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +9 -8
  130. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +2 -2
  131. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +8 -7
  132. package/contracts/LSP9Vault/LSP9Constants.sol +11 -8
  133. package/contracts/LSP9Vault/LSP9Errors.sol +8 -0
  134. package/contracts/LSP9Vault/LSP9Vault.sol +6 -4
  135. package/contracts/LSP9Vault/LSP9VaultCore.sol +324 -90
  136. package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -2
  137. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +5 -4
  138. package/contracts/Legacy/Registries/AddressRegistry.sol +1 -1
  139. package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +1 -1
  140. package/contracts/Legacy/UniversalReceiverAddressStore.sol +4 -13
  141. package/contracts/UniversalProfile.sol +2 -2
  142. package/contracts/UniversalProfileInit.sol +2 -2
  143. package/contracts/UniversalProfileInitAbstract.sol +1 -1
  144. package/contracts/Utils/GasLib.sol +17 -0
  145. package/package.json +37 -32
  146. package/artifacts/LSP7CompatibleERC20Init.json +0 -760
  147. package/artifacts/LSP7DigitalAssetInit.json +0 -588
  148. package/artifacts/LSP8CompatibleERC721Init.json +0 -883
  149. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +0 -639
  150. package/artifacts/UniversalFactory.json +0 -127
  151. package/contracts/Custom/ClaimOwnership.sol +0 -34
  152. package/contracts/Custom/ERC165Checker.sol +0 -130
  153. package/contracts/Custom/IClaimOwnership.sol +0 -10
  154. package/contracts/Factories/UniversalFactory.sol +0 -164
  155. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +0 -24
  156. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +0 -85
  157. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +0 -76
  158. package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +0 -9
  159. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +0 -26
  160. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +0 -39
  161. package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +0 -17
  162. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +0 -57
  163. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +0 -19
  164. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Core.sol +0 -112
  165. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Init.sol +0 -29
  166. package/contracts/LSP7DigitalAsset/presets/LSP7MintableCore.sol +0 -26
  167. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +0 -35
  168. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +0 -17
  169. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +0 -58
  170. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +0 -19
  171. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleConstants.sol +0 -6
  172. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Core.sol +0 -187
  173. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Init.sol +0 -25
  174. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableCore.sol +0 -26
  175. package/contracts/Utils/UtilsLib.sol +0 -31
@@ -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,26 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.0;
3
-
4
- // modules
5
- import {LSP4DigitalAssetMetadataInitAbstract} from "./LSP4DigitalAssetMetadataInitAbstract.sol";
6
-
7
- /**
8
- * @title LSP4DigitalAssetMetadata
9
- * @author Matthew Stevens
10
- * @dev Deployable Proxy Implementation of a LSP8 compliant contract.
11
- */
12
- abstract contract LSP4DigitalAssetMetadataInit is LSP4DigitalAssetMetadataInitAbstract {
13
- /**
14
- * @notice Sets the name, symbol of the token and the owner, and sets the SupportedStandards:LSP4DigitalAsset key
15
- * @param name_ The name of the token
16
- * @param symbol_ The symbol of the token
17
- * @param newOwner_ The owner of the token contract
18
- */
19
- function initialize(
20
- string memory name_,
21
- string memory symbol_,
22
- address newOwner_
23
- ) public virtual initializer {
24
- LSP4DigitalAssetMetadataInitAbstract._initialize(name_, symbol_, newOwner_);
25
- }
26
- }
@@ -1,39 +0,0 @@
1
- // SPDX-License-Identifier: CC0-1.0
2
- pragma solidity ^0.8.0;
3
-
4
- // modules
5
- import {LSP7DigitalAssetInitAbstract} from "./LSP7DigitalAssetInitAbstract.sol";
6
-
7
- /**
8
- * @title LSP7DigitalAsset contract
9
- * @author Matthew Stevens
10
- * @dev Proxy Implementation of a LSP7 compliant contract.
11
- *
12
- * This implementation is agnostic to the way tokens are created.
13
- * A supply mechanism has to be added in a derived contract using {_mint}
14
- * For a generic mechanism, see {LSP7Mintable}.
15
- */
16
- contract LSP7DigitalAssetInit is LSP7DigitalAssetInitAbstract {
17
- /**
18
- * @dev initialize (= lock) base implementation contract on deployment
19
- */
20
- constructor() {
21
- _disableInitializers();
22
- }
23
-
24
- /**
25
- * @notice Sets the token-Metadata
26
- * @param name_ The name of the token
27
- * @param symbol_ The symbol of the token
28
- * @param newOwner_ The owner of the the token-Metadata
29
- * @param isNFT_ Specify if the LSP7 token is a fungible or non-fungible token
30
- */
31
- function initialize(
32
- string memory name_,
33
- string memory symbol_,
34
- address newOwner_,
35
- bool isNFT_
36
- ) public virtual initializer {
37
- LSP7DigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_, isNFT_);
38
- }
39
- }
@@ -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 override 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,19 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // modules
6
- import {LSP7CappedSupplyInitAbstract} from "./LSP7CappedSupplyInitAbstract.sol";
7
-
8
- /**
9
- * @dev LSP7 extension, adds token supply cap.
10
- */
11
- abstract contract LSP7CappedSupplyInit is LSP7CappedSupplyInitAbstract {
12
- /**
13
- * @notice Sets the token max supply
14
- * @param tokenSupplyCap_ The Token max supply
15
- */
16
- function initialize(uint256 tokenSupplyCap_) public virtual initializer {
17
- LSP7CappedSupplyInitAbstract._initialize(tokenSupplyCap_);
18
- }
19
- }
@@ -1,112 +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 override 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
- override
39
- returns (uint256)
40
- {
41
- return isOperatorFor(operator, tokenOwner);
42
- }
43
-
44
- /**
45
- * @inheritdoc ILSP7CompatibleERC20
46
- * @dev Compatible with ERC20 transfer.
47
- * Using force=true so that EOA and any contract may receive the tokens.
48
- */
49
- function transfer(address to, uint256 amount) public virtual override returns (bool) {
50
- transfer(_msgSender(), to, amount, true, "");
51
- return true;
52
- }
53
-
54
- /**
55
- * @inheritdoc ILSP7CompatibleERC20
56
- * @dev Compatible with ERC20 transferFrom.
57
- * Using force=true so that EOA and any contract may receive the tokens.
58
- */
59
- function transferFrom(
60
- address from,
61
- address to,
62
- uint256 amount
63
- ) public virtual override returns (bool) {
64
- transfer(from, to, amount, true, "");
65
- return true;
66
- }
67
-
68
- function authorizeOperator(address operator, uint256 amount)
69
- public
70
- virtual
71
- override(ILSP7DigitalAsset, LSP7DigitalAssetCore)
72
- {
73
- super.authorizeOperator(operator, amount);
74
-
75
- emit Approval(_msgSender(), operator, amount);
76
- }
77
-
78
- // --- Internals
79
-
80
- function _transfer(
81
- address from,
82
- address to,
83
- uint256 amount,
84
- bool force,
85
- bytes memory data
86
- ) internal virtual override {
87
- super._transfer(from, to, amount, force, data);
88
-
89
- emit Transfer(from, to, amount);
90
- }
91
-
92
- function _mint(
93
- address to,
94
- uint256 amount,
95
- bool force,
96
- bytes memory data
97
- ) internal virtual override {
98
- super._mint(to, amount, force, data);
99
-
100
- emit Transfer(address(0), to, amount);
101
- }
102
-
103
- function _burn(
104
- address from,
105
- uint256 amount,
106
- bytes memory data
107
- ) internal virtual override {
108
- super._burn(from, amount, data);
109
-
110
- emit Transfer(from, address(0), amount);
111
- }
112
- }
@@ -1,29 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // modules
6
- import {LSP7CompatibleERC20InitAbstract} from "./LSP7CompatibleERC20InitAbstract.sol";
7
-
8
- contract LSP7CompatibleERC20Init is LSP7CompatibleERC20InitAbstract {
9
- /**
10
- * @dev initialize (= lock) base implementation contract on deployment
11
- */
12
- constructor() {
13
- _disableInitializers();
14
- }
15
-
16
- /**
17
- * @notice Sets the name, the symbol and the owner of the token
18
- * @param name_ The name of the token
19
- * @param symbol_ The symbol of the token
20
- * @param newOwner_ The owner of the token
21
- */
22
- function initialize(
23
- string memory name_,
24
- string memory symbol_,
25
- address newOwner_
26
- ) public virtual initializer {
27
- LSP7CompatibleERC20InitAbstract._initialize(name_, symbol_, newOwner_);
28
- }
29
- }
@@ -1,26 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // interfaces
6
- import {ILSP7Mintable} from "./ILSP7Mintable.sol";
7
-
8
- // modules
9
- import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
10
-
11
- /**
12
- * @dev LSP7 extension, mintable .
13
- */
14
- abstract contract LSP7MintableCore is LSP7DigitalAssetCore, ILSP7Mintable {
15
- /**
16
- * @inheritdoc ILSP7Mintable
17
- */
18
- function mint(
19
- address to,
20
- uint256 amount,
21
- bool force,
22
- bytes memory data
23
- ) public virtual override {
24
- _mint(to, amount, force, data);
25
- }
26
- }
@@ -1,35 +0,0 @@
1
- // SPDX-License-Identifier: CC0-1.0
2
- pragma solidity ^0.8.0;
3
-
4
- // modules
5
- import {
6
- LSP8IdentifiableDigitalAssetInitAbstract
7
- } from "./LSP8IdentifiableDigitalAssetInitAbstract.sol";
8
-
9
- /**
10
- * @title LSP8IdentifiableDigitalAsset contract
11
- * @author Matthew Stevens
12
- * @dev Proxy Implementation of a LSP8 compliant contract.
13
- */
14
- contract LSP8IdentifiableDigitalAssetInit is LSP8IdentifiableDigitalAssetInitAbstract {
15
- /**
16
- * @dev initialize (= lock) base implementation contract on deployment
17
- */
18
- constructor() {
19
- _disableInitializers();
20
- }
21
-
22
- /**
23
- * @notice Sets the token-Metadata
24
- * @param name_ The name of the token
25
- * @param symbol_ The symbol of the token
26
- * @param newOwner_ The owner of the the token-Metadata
27
- */
28
- function initialize(
29
- string memory name_,
30
- string memory symbol_,
31
- address newOwner_
32
- ) public virtual initializer {
33
- LSP8IdentifiableDigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_);
34
- }
35
- }
@@ -1,17 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // interfaces
6
- import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
7
-
8
- /**
9
- * @dev LSP8 extension, adds token supply cap.
10
- */
11
- interface ILSP8CappedSupply is ILSP8IdentifiableDigitalAsset {
12
- /**
13
- * @dev Returns the number of tokens that can be minted.
14
- * @return The token max supply
15
- */
16
- function tokenSupplyCap() external view returns (uint256);
17
- }
@@ -1,58 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // interfaces
6
- import {ILSP8CappedSupply} from "./ILSP8CappedSupply.sol";
7
-
8
- // modules
9
- import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
10
-
11
- /**
12
- * @dev LSP8 extension, adds token supply cap.
13
- */
14
- abstract contract LSP8CappedSupplyCore is LSP8IdentifiableDigitalAssetCore, ILSP8CappedSupply {
15
- // --- Errors
16
-
17
- error LSP8CappedSupplyRequired();
18
- error LSP8CappedSupplyCannotMintOverCap();
19
-
20
- // --- Storage
21
-
22
- uint256 internal _tokenSupplyCap;
23
-
24
- // --- Token queries
25
-
26
- /**
27
- * @inheritdoc ILSP8CappedSupply
28
- */
29
- function tokenSupplyCap() public view virtual override returns (uint256) {
30
- return _tokenSupplyCap;
31
- }
32
-
33
- // --- Transfer functionality
34
-
35
- /**
36
- * @dev Mints `tokenId` and transfers it to `to`.
37
- *
38
- * Requirements:
39
- *
40
- * - `tokenSupplyCap() - totalSupply()` must be greater than zero.
41
- * - `tokenId` must not exist.
42
- * - `to` cannot be the zero address.
43
- *
44
- * Emits a {Transfer} event.
45
- */
46
- function _mint(
47
- address to,
48
- bytes32 tokenId,
49
- bool force,
50
- bytes memory data
51
- ) internal virtual override {
52
- if (totalSupply() + 1 > tokenSupplyCap()) {
53
- revert LSP8CappedSupplyCannotMintOverCap();
54
- }
55
-
56
- super._mint(to, tokenId, force, data);
57
- }
58
- }
@@ -1,19 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // modules
6
- import {LSP8CappedSupplyInitAbstract} from "./LSP8CappedSupplyInitAbstract.sol";
7
-
8
- /**
9
- * @dev LSP8 extension, adds token supply cap.
10
- */
11
- abstract contract LSP8CappedSupplyInit is LSP8CappedSupplyInitAbstract {
12
- /**
13
- * @notice Sets the token max supply
14
- * @param tokenSupplyCap_ The Token max supply
15
- */
16
- function initialize(uint256 tokenSupplyCap_) public virtual initializer {
17
- LSP8CappedSupplyInitAbstract._initialize(tokenSupplyCap_);
18
- }
19
- }
@@ -1,6 +0,0 @@
1
- // SPDX-License-Identifier: CC0-1.0
2
- pragma solidity ^0.8.0;
3
-
4
- // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_ERC721 = 0x80ac58cd;
6
- bytes4 constant _INTERFACEID_ERC721METADATA = 0x5b5e139f;
@@ -1,187 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma solidity ^0.8.0;
4
-
5
- // interfaces
6
- import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
7
- import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";
8
-
9
- // libraries
10
- import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
11
- import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
12
-
13
- // modules
14
- import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
15
- import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
16
-
17
- // constants
18
- import {_LSP4_METADATA_KEY} from "../../LSP4DigitalAssetMetadata/LSP4Constants.sol";
19
-
20
- /**
21
- * @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
22
- */
23
- abstract contract LSP8CompatibleERC721Core is
24
- LSP4Compatibility,
25
- LSP8IdentifiableDigitalAssetCore,
26
- ILSP8CompatibleERC721
27
- {
28
- using EnumerableSet for EnumerableSet.AddressSet;
29
-
30
- /*
31
- * @inheritdoc ILSP8CompatibleERC721
32
- */
33
- function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
34
- // silence compiler warning about unused variable
35
- tokenId;
36
-
37
- bytes memory data = _getData(_LSP4_METADATA_KEY);
38
-
39
- // offset = bytes4(hashSig) + bytes32(contentHash) -> 4 + 32 = 36
40
- uint256 offset = 36;
41
-
42
- bytes memory uriBytes = BytesLib.slice(data, offset, data.length - offset);
43
- return string(uriBytes);
44
- }
45
-
46
- /**
47
- * @inheritdoc ILSP8CompatibleERC721
48
- */
49
- function ownerOf(uint256 tokenId) public view virtual override returns (address) {
50
- return tokenOwnerOf(bytes32(tokenId));
51
- }
52
-
53
- /**
54
- * @inheritdoc ILSP8CompatibleERC721
55
- */
56
- function approve(address operator, uint256 tokenId) public virtual override {
57
- authorizeOperator(operator, bytes32(tokenId));
58
-
59
- emit Approval(tokenOwnerOf(bytes32(tokenId)), operator, tokenId);
60
- }
61
-
62
- /**
63
- * @inheritdoc ILSP8CompatibleERC721
64
- */
65
- function getApproved(uint256 tokenId) public view virtual override returns (address) {
66
- bytes32 tokenIdAsBytes32 = bytes32(tokenId);
67
- _existsOrError(tokenIdAsBytes32);
68
-
69
- EnumerableSet.AddressSet storage operatorsForTokenId = _operators[tokenIdAsBytes32];
70
- uint256 operatorListLength = operatorsForTokenId.length();
71
-
72
- if (operatorListLength == 0) {
73
- return address(0);
74
- } else {
75
- // Read the last added operator authorized to provide "best" compatibility.
76
- // In ERC721 there is one operator address at a time for a tokenId, so multiple calls to
77
- // `approve` would cause `getApproved` to return the last added operator. In this
78
- // compatibility version the same is true, when the authorized operators were not previously
79
- // authorized. If addresses are removed, then `getApproved` returned address can change due
80
- // to implementation of `EnumberableSet._remove`.
81
- return operatorsForTokenId.at(operatorListLength - 1);
82
- }
83
- }
84
-
85
- /*
86
- * @inheritdoc ILSP8CompatibleERC721
87
- */
88
- function isApprovedForAll(address tokenOwner, address operator)
89
- public
90
- view
91
- virtual
92
- override
93
- returns (bool)
94
- {
95
- // silence compiler warning about unused variable
96
- tokenOwner;
97
- operator;
98
-
99
- return false;
100
- }
101
-
102
- /**
103
- * @inheritdoc ILSP8CompatibleERC721
104
- * @dev Compatible with ERC721 transferFrom.
105
- * Using force=true so that EOA and any contract may receive the tokenId.
106
- */
107
- function transferFrom(
108
- address from,
109
- address to,
110
- uint256 tokenId
111
- ) public virtual override {
112
- return transfer(from, to, bytes32(tokenId), true, "");
113
- }
114
-
115
- /**
116
- * @inheritdoc ILSP8CompatibleERC721
117
- * @dev Compatible with ERC721 safeTransferFrom.
118
- * Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
119
- */
120
- function safeTransferFrom(
121
- address from,
122
- address to,
123
- uint256 tokenId
124
- ) public virtual override {
125
- return transfer(from, to, bytes32(tokenId), false, "");
126
- }
127
-
128
- /*
129
- * @dev Compatible with ERC721 safeTransferFrom.
130
- * Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
131
- */
132
- function safeTransferFrom(
133
- address from,
134
- address to,
135
- uint256 tokenId,
136
- bytes memory data
137
- ) public virtual override {
138
- return transfer(from, to, bytes32(tokenId), false, data);
139
- }
140
-
141
- // --- Overrides
142
-
143
- function authorizeOperator(address operator, bytes32 tokenId)
144
- public
145
- virtual
146
- override(ILSP8IdentifiableDigitalAsset, LSP8IdentifiableDigitalAssetCore)
147
- {
148
- super.authorizeOperator(operator, tokenId);
149
-
150
- emit Approval(
151
- tokenOwnerOf(tokenId),
152
- operator,
153
- abi.decode(abi.encodePacked(tokenId), (uint256))
154
- );
155
- }
156
-
157
- function _transfer(
158
- address from,
159
- address to,
160
- bytes32 tokenId,
161
- bool force,
162
- bytes memory data
163
- ) internal virtual override {
164
- super._transfer(from, to, tokenId, force, data);
165
-
166
- emit Transfer(from, to, abi.decode(abi.encodePacked(tokenId), (uint256)));
167
- }
168
-
169
- function _mint(
170
- address to,
171
- bytes32 tokenId,
172
- bool force,
173
- bytes memory data
174
- ) internal virtual override {
175
- super._mint(to, tokenId, force, data);
176
-
177
- emit Transfer(address(0), to, abi.decode(abi.encodePacked(tokenId), (uint256)));
178
- }
179
-
180
- function _burn(bytes32 tokenId, bytes memory data) internal virtual override {
181
- address tokenOwner = tokenOwnerOf(tokenId);
182
-
183
- super._burn(tokenId, data);
184
-
185
- emit Transfer(tokenOwner, address(0), abi.decode(abi.encodePacked(tokenId), (uint256)));
186
- }
187
- }