@lukso/lsp-smart-contracts 0.4.3 → 0.6.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 (141) hide show
  1. package/README.md +38 -9
  2. package/artifacts/LSP0ERC725Account.json +398 -0
  3. package/artifacts/LSP0ERC725AccountInit.json +439 -0
  4. package/artifacts/LSP1UniversalReceiverDelegateUP.json +7 -7
  5. package/artifacts/LSP1UniversalReceiverDelegateVault.json +7 -7
  6. package/artifacts/LSP4Compatibility.json +195 -0
  7. package/artifacts/LSP4DigitalAssetMetadata.json +169 -0
  8. package/artifacts/LSP4DigitalAssetMetadataInit.json +231 -0
  9. package/artifacts/LSP6KeyManager.json +50 -28
  10. package/artifacts/LSP6KeyManagerInit.json +58 -23
  11. package/artifacts/LSP7CappedSupply.json +136 -11
  12. package/artifacts/LSP7CappedSupplyInit.json +163 -35
  13. package/artifacts/LSP7CompatibilityForERC20.json +204 -13
  14. package/artifacts/LSP7CompatibilityForERC20Init.json +727 -0
  15. package/artifacts/LSP7DigitalAsset.json +128 -13
  16. package/artifacts/LSP7DigitalAssetInit.json +152 -34
  17. package/artifacts/LSP7Mintable.json +129 -14
  18. package/artifacts/LSP7MintableInit.json +153 -35
  19. package/artifacts/LSP8CappedSupply.json +137 -11
  20. package/artifacts/LSP8CappedSupplyInit.json +172 -20
  21. package/artifacts/LSP8CompatibilityForERC721.json +138 -17
  22. package/artifacts/LSP8CompatibilityForERC721Init.json +873 -0
  23. package/artifacts/LSP8IdentifiableDigitalAsset.json +129 -13
  24. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +161 -19
  25. package/artifacts/LSP8Mintable.json +141 -14
  26. package/artifacts/LSP8MintableInit.json +173 -20
  27. package/artifacts/LSP9Vault.json +374 -0
  28. package/artifacts/LSP9VaultInit.json +415 -0
  29. package/artifacts/UniversalFactory.json +127 -0
  30. package/artifacts/UniversalProfile.json +78 -53
  31. package/artifacts/UniversalProfileInit.json +117 -53
  32. package/artifacts/UniversalReceiverAddressStore.json +209 -0
  33. package/constants.js +500 -0
  34. package/contracts/Custom/ClaimOwnership.sol +31 -0
  35. package/contracts/Custom/ERC165Checker.sol +130 -0
  36. package/contracts/Custom/IClaimOwnership.sol +10 -0
  37. package/contracts/Factories/UniversalFactory.sol +155 -0
  38. package/contracts/LSP0ERC725Account/LSP0Constants.sol +5 -9
  39. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +6 -8
  40. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +92 -48
  41. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +5 -5
  42. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +6 -21
  43. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +10 -0
  44. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +3 -0
  45. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +4 -2
  46. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +3 -9
  47. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +61 -165
  48. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +49 -6
  49. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +50 -90
  50. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +40 -6
  51. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +48 -0
  52. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +205 -0
  53. package/contracts/LSP3UniversalProfile/LSP3Constants.sol +11 -0
  54. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
  55. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +6 -15
  56. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +10 -4
  57. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +11 -8
  58. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +9 -13
  59. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +14 -20
  60. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +10 -0
  61. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +205 -0
  62. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +21 -18
  63. package/contracts/LSP6KeyManager/LSP6Constants.sol +61 -24
  64. package/contracts/LSP6KeyManager/LSP6Errors.sol +37 -0
  65. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +3 -4
  66. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +475 -260
  67. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +6 -5
  68. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +7 -15
  69. package/contracts/LSP6KeyManager/LSP6Utils.sol +111 -0
  70. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +3 -8
  71. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +5 -4
  72. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +22 -8
  73. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +70 -96
  74. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +8 -9
  75. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +23 -21
  76. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +23 -0
  77. package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +1 -1
  78. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibilityForERC20.sol +22 -6
  79. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +7 -6
  80. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +14 -12
  81. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +3 -8
  82. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +9 -17
  83. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +37 -45
  84. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Core.sol +107 -0
  85. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Init.sol +22 -0
  86. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20InitAbstract.sol +66 -0
  87. package/contracts/LSP7DigitalAsset/{extensions → presets}/ILSP7Mintable.sol +1 -1
  88. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7Mintable.sol +4 -3
  89. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableCore.sol +5 -5
  90. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableInit.sol +3 -2
  91. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +34 -0
  92. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +5 -16
  93. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +6 -3
  94. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +22 -0
  95. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +21 -8
  96. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +102 -135
  97. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +8 -11
  98. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +22 -19
  99. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +1 -1
  100. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibilityForERC721.sol +17 -22
  101. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +9 -15
  102. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +14 -12
  103. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +3 -8
  104. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +9 -18
  105. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +37 -189
  106. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Core.sol +187 -0
  107. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol +25 -0
  108. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721InitAbstract.sol +89 -0
  109. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/ILSP8Mintable.sol +1 -1
  110. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8Mintable.sol +4 -3
  111. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableCore.sol +5 -8
  112. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableInit.sol +4 -3
  113. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +35 -0
  114. package/contracts/LSP9Vault/LSP9Constants.sol +14 -5
  115. package/contracts/LSP9Vault/LSP9Vault.sol +15 -37
  116. package/contracts/LSP9Vault/LSP9VaultCore.sol +105 -85
  117. package/contracts/LSP9Vault/LSP9VaultInit.sol +5 -4
  118. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +15 -45
  119. package/contracts/Legacy/Registries/AddressRegistry.sol +43 -0
  120. package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +33 -0
  121. package/contracts/Legacy/UniversalReceiverAddressStore.sol +60 -0
  122. package/contracts/UniversalProfile.sol +11 -20
  123. package/contracts/UniversalProfileInit.sol +5 -4
  124. package/contracts/UniversalProfileInitAbstract.sol +14 -35
  125. package/contracts/Utils/UtilsLib.sol +47 -11
  126. package/package.json +23 -9
  127. package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +0 -66
  128. package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +0 -66
  129. package/constants.ts +0 -350
  130. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPCore.sol +0 -52
  131. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInit.sol +0 -26
  132. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInitAbstract.sol +0 -28
  133. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultCore.sol +0 -41
  134. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInit.sol +0 -23
  135. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInitAbstract.sol +0 -25
  136. package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInitAbstract.sol +0 -47
  137. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInitAbstract.sol +0 -44
  138. package/contracts/UniversalProfileCore.sol +0 -56
  139. package/contracts/Utils/ERC725Utils.sol +0 -169
  140. package/contracts/Utils/LSP2Utils.sol +0 -127
  141. package/contracts/Utils/LSP6Utils.sol +0 -77
@@ -3,38 +3,32 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // interfaces
6
- import "../ILSP8IdentifiableDigitalAsset.sol";
6
+ import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
7
7
 
8
8
  /**
9
9
  * @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
10
10
  */
11
11
  interface ILSP8CompatibilityForERC721 is ILSP8IdentifiableDigitalAsset {
12
12
  /**
13
- * @dev To provide compatibility with indexing ERC721 events
13
+ * @notice To provide compatibility with indexing ERC721 events.
14
+ * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
14
15
  * @param from The sending address
15
16
  * @param to The receiving address
16
17
  * @param tokenId The tokenId to transfer
17
18
  */
18
- event Transfer(
19
- address indexed from,
20
- address indexed to,
21
- uint256 indexed tokenId
22
- );
19
+ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
23
20
 
24
21
  /**
25
- * @dev To provide compatibility with indexing ERC721 events.
22
+ * @notice To provide compatibility with indexing ERC721 events.
23
+ * @dev Emitted when `owner` enables `approved` for `tokenId`.
26
24
  * @param owner The address of the owner of the `tokenId`
27
25
  * @param approved The address set as operator
28
26
  * @param tokenId The approved tokenId
29
27
  */
30
- event Approval(
31
- address indexed owner,
32
- address indexed approved,
33
- uint256 indexed tokenId
34
- );
28
+ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
35
29
 
36
30
  /**
37
- * @dev Compatible with ERC721 tranferFrom.
31
+ * @dev Compatible with ERC721 transferFrom.
38
32
  * @param from The sending address
39
33
  * @param to The receiving address
40
34
  * @param tokenId The tokenId to transfer
@@ -46,7 +40,7 @@ interface ILSP8CompatibilityForERC721 is ILSP8IdentifiableDigitalAsset {
46
40
  ) external;
47
41
 
48
42
  /**
49
- * @dev Compatible with ERC721 tranferFrom.
43
+ * @dev Compatible with ERC721 transferFrom.
50
44
  * @param from The sending address
51
45
  * @param to The receiving address
52
46
  * @param tokenId The tokenId to transfer
@@ -76,7 +70,7 @@ interface ILSP8CompatibilityForERC721 is ILSP8IdentifiableDigitalAsset {
76
70
  * @param tokenId The tokenId to query
77
71
  * @return The owner of the tokenId
78
72
  */
79
- function ownerOf(uint256 tokenId) external returns (address);
73
+ function ownerOf(uint256 tokenId) external view returns (address);
80
74
 
81
75
  /**
82
76
  * @dev Compatible with ERC721 approve.
@@ -90,18 +84,19 @@ interface ILSP8CompatibilityForERC721 is ILSP8IdentifiableDigitalAsset {
90
84
  * @param tokenId The tokenId to query
91
85
  * @return The address of the operator for `tokenId`
92
86
  */
93
- function getApproved(uint256 tokenId) external returns (address);
87
+ function getApproved(uint256 tokenId) external view returns (address);
94
88
 
95
89
  /*
96
- * @dev Compatible with ERC721 tokenURI.
97
- * @param tokenId The tokenId to query.
98
- * @return True if all tokenId are approved, false otherwise.
90
+ * @dev Compatible with ERC721 isApprovedForAll.
91
+ * @param owner The tokenOwner address to query
92
+ * @param operator The operator address to query
93
+ * @return Returns if the `operator` is allowed to manage all of the assets of `owner`
99
94
  */
100
- function isApprovedForAll(uint256 tokenId) external returns (bool);
95
+ function isApprovedForAll(address owner, address operator) external view returns (bool);
101
96
 
102
97
  /*
103
98
  * @dev Compatible with ERC721Metadata tokenURI.
104
- * @param tokenId The tokenId to query.
99
+ * @param tokenId The tokenId to query
105
100
  * @return The token URI
106
101
  */
107
102
  function tokenURI(uint256 tokenId) external returns (string memory);
@@ -3,25 +3,23 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
- import "./LSP8CappedSupplyCore.sol";
7
- import "../LSP8IdentifiableDigitalAsset.sol";
6
+ import {LSP8IdentifiableDigitalAsset} from "../LSP8IdentifiableDigitalAsset.sol";
7
+ import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
8
+ import {LSP8CappedSupplyCore} from "./LSP8CappedSupplyCore.sol";
8
9
 
9
10
  /**
10
11
  * @dev LSP8 extension, adds token supply cap.
11
12
  */
12
- abstract contract LSP8CappedSupply is
13
- LSP8IdentifiableDigitalAsset,
14
- LSP8CappedSupplyCore
15
- {
13
+ abstract contract LSP8CappedSupply is LSP8IdentifiableDigitalAsset, LSP8CappedSupplyCore {
16
14
  /**
17
15
  * @notice Sets the token max supply
18
16
  * @param tokenSupplyCap_ The Token max supply
19
17
  */
20
18
  constructor(uint256 tokenSupplyCap_) {
21
- require(
22
- tokenSupplyCap_ > 0,
23
- "LSP8CappedSupply: tokenSupplyCap is zero"
24
- );
19
+ if (tokenSupplyCap_ == 0) {
20
+ revert LSP8CappedSupplyRequired();
21
+ }
22
+
25
23
  _tokenSupplyCap = tokenSupplyCap_;
26
24
  }
27
25
 
@@ -43,11 +41,7 @@ abstract contract LSP8CappedSupply is
43
41
  bytes32 tokenId,
44
42
  bool force,
45
43
  bytes memory data
46
- )
47
- internal
48
- virtual
49
- override(LSP8IdentifiableDigitalAssetCore, LSP8CappedSupplyCore)
50
- {
44
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CappedSupplyCore) {
51
45
  super._mint(to, tokenId, force, data);
52
46
  }
53
47
  }
@@ -2,19 +2,21 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
- // modules
6
- import "../LSP8IdentifiableDigitalAssetCore.sol";
7
-
8
5
  // interfaces
9
- import "./ILSP8CappedSupply.sol";
6
+ import {ILSP8CappedSupply} from "./ILSP8CappedSupply.sol";
7
+
8
+ // modules
9
+ import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
10
10
 
11
11
  /**
12
12
  * @dev LSP8 extension, adds token supply cap.
13
13
  */
14
- abstract contract LSP8CappedSupplyCore is
15
- ILSP8CappedSupply,
16
- LSP8IdentifiableDigitalAssetCore
17
- {
14
+ abstract contract LSP8CappedSupplyCore is LSP8IdentifiableDigitalAssetCore, ILSP8CappedSupply {
15
+ // --- Errors
16
+
17
+ error LSP8CappedSupplyRequired();
18
+ error LSP8CappedSupplyCannotMintOverCap();
19
+
18
20
  // --- Storage
19
21
 
20
22
  uint256 internal _tokenSupplyCap;
@@ -47,10 +49,10 @@ abstract contract LSP8CappedSupplyCore is
47
49
  bool force,
48
50
  bytes memory data
49
51
  ) internal virtual override {
50
- require(
51
- totalSupply() + 1 <= tokenSupplyCap(),
52
- "LSP8CappedSupply: tokenSupplyCap reached"
53
- );
52
+ if (totalSupply() + 1 > tokenSupplyCap()) {
53
+ revert LSP8CappedSupplyCannotMintOverCap();
54
+ }
55
+
54
56
  super._mint(to, tokenId, force, data);
55
57
  }
56
58
  }
@@ -3,7 +3,7 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
- import "./LSP8CappedSupplyInitAbstract.sol";
6
+ import {LSP8CappedSupplyInitAbstract} from "./LSP8CappedSupplyInitAbstract.sol";
7
7
 
8
8
  /**
9
9
  * @dev LSP8 extension, adds token supply cap.
@@ -13,12 +13,7 @@ abstract contract LSP8CappedSupplyInit is LSP8CappedSupplyInitAbstract {
13
13
  * @notice Sets the token max supply
14
14
  * @param tokenSupplyCap_ The Token max supply
15
15
  */
16
- function initialize(uint256 tokenSupplyCap_)
17
- public
18
- virtual
19
- override
20
- initializer
21
- {
22
- LSP8CappedSupplyInitAbstract.initialize(tokenSupplyCap_);
16
+ function initialize(uint256 tokenSupplyCap_) public virtual initializer {
17
+ LSP8CappedSupplyInitAbstract._initialize(tokenSupplyCap_);
23
18
  }
24
19
  }
@@ -3,27 +3,22 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
- import "./LSP8CappedSupplyCore.sol";
7
- import "../LSP8IdentifiableDigitalAssetInit.sol";
6
+ import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
7
+ import {LSP8IdentifiableDigitalAssetInit} from "../LSP8IdentifiableDigitalAssetInit.sol";
8
+ import {LSP8CappedSupplyCore} from "./LSP8CappedSupplyCore.sol";
8
9
 
9
10
  /**
10
11
  * @dev LSP8 extension, adds token supply cap.
11
12
  */
12
13
  abstract contract LSP8CappedSupplyInitAbstract is
13
- Initializable,
14
14
  LSP8IdentifiableDigitalAssetInit,
15
15
  LSP8CappedSupplyCore
16
16
  {
17
- /**
18
- * @notice Sets the token max supply
19
- * @param tokenSupplyCap_ The Token max supply
20
- */
21
- function initialize(uint256 tokenSupplyCap_)
22
- public
23
- virtual
24
- onlyInitializing
25
- {
26
- require(tokenSupplyCap_ > 0, "LSP8Capped: tokenSupplyCap is zero");
17
+ function _initialize(uint256 tokenSupplyCap_) internal virtual onlyInitializing {
18
+ if (tokenSupplyCap_ == 0) {
19
+ revert LSP8CappedSupplyRequired();
20
+ }
21
+
27
22
  _tokenSupplyCap = tokenSupplyCap_;
28
23
  }
29
24
 
@@ -45,11 +40,7 @@ abstract contract LSP8CappedSupplyInitAbstract is
45
40
  bytes32 tokenId,
46
41
  bool force,
47
42
  bytes memory data
48
- )
49
- internal
50
- virtual
51
- override(LSP8IdentifiableDigitalAssetCore, LSP8CappedSupplyCore)
52
- {
43
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CappedSupplyCore) {
53
44
  super._mint(to, tokenId, force, data);
54
45
  }
55
46
  }
@@ -2,31 +2,29 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
- // modules
6
- import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
7
- import "../LSP8IdentifiableDigitalAsset.sol";
8
- import "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
5
+ // interfaces
6
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
9
7
 
10
8
  // libraries
11
- import "solidity-bytes-utils/contracts/BytesLib.sol";
9
+ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
12
10
 
13
- // interfaces
14
- import "./ILSP8CompatibilityForERC721.sol";
11
+ // modules
12
+ import {LSP8IdentifiableDigitalAsset, LSP4DigitalAssetMetadata, ERC725YCore} from "../LSP8IdentifiableDigitalAsset.sol";
13
+ import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
14
+ import {LSP8CompatibilityForERC721Core} from "./LSP8CompatibilityForERC721Core.sol";
15
15
 
16
16
  // constants
17
- import "./LSP8CompatibilityConstants.sol";
17
+ import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./LSP8CompatibilityConstants.sol";
18
18
 
19
19
  /**
20
20
  * @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
21
21
  */
22
22
  contract LSP8CompatibilityForERC721 is
23
- ILSP8CompatibilityForERC721,
24
23
  LSP8IdentifiableDigitalAsset,
25
- LSP4Compatibility
24
+ LSP8CompatibilityForERC721Core
26
25
  {
27
26
  using EnumerableSet for EnumerableSet.AddressSet;
28
27
 
29
- /* solhint-disable no-empty-blocks */
30
28
  /**
31
29
  * @notice Sets the name, the symbol and the owner of the token
32
30
  * @param name_ The name of the token
@@ -37,171 +35,16 @@ contract LSP8CompatibilityForERC721 is
37
35
  string memory name_,
38
36
  string memory symbol_,
39
37
  address newOwner_
40
- ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {
41
- _registerInterface(_INTERFACEID_ERC721);
42
- _registerInterface(_INTERFACEID_ERC721METADATA);
43
- }
44
-
45
- // solhint-disable no-unused-vars
46
- /*
47
- * @inheritdoc ILSP8CompatibilityForERC721
48
- */
49
- function tokenURI(uint256 tokenId)
50
- public
51
- view
52
- virtual
53
- override
54
- returns (string memory)
55
- {
56
- bytes memory data = ERC725Utils.getDataSingle(this, _LSP4_METADATA_KEY);
57
-
58
- // offset = bytes4(hashSig) + bytes32(contentHash) -> 4 + 32 = 36
59
- uint256 offset = 36;
60
-
61
- bytes memory uriBytes = BytesLib.slice(
62
- data,
63
- offset,
64
- data.length - offset
65
- );
66
- return string(uriBytes);
67
- }
68
-
69
- /**
70
- * @inheritdoc ILSP8CompatibilityForERC721
71
- */
72
- function ownerOf(uint256 tokenId)
73
- external
74
- view
75
- virtual
76
- override
77
- returns (address)
78
- {
79
- return tokenOwnerOf(bytes32(tokenId));
80
- }
81
-
82
- /**
83
- * @inheritdoc ILSP8CompatibilityForERC721
84
- */
85
- function approve(address operator, uint256 tokenId)
86
- external
87
- virtual
88
- override
89
- {
90
- authorizeOperator(operator, bytes32(tokenId));
91
-
92
- emit Approval(tokenOwnerOf(bytes32(tokenId)), operator, tokenId);
93
- }
94
-
95
- /**
96
- * @inheritdoc ILSP8CompatibilityForERC721
97
- */
98
- function getApproved(uint256 tokenId)
99
- external
100
- view
101
- virtual
102
- override
103
- returns (address)
104
- {
105
- require(
106
- _exists(bytes32(tokenId)),
107
- "LSP8: can not query operator for non existent token"
108
- );
109
-
110
- EnumerableSet.AddressSet storage operatorsForTokenId = _operators[
111
- bytes32(tokenId)
112
- ];
113
- uint256 operatorListLength = operatorsForTokenId.length();
114
-
115
- if (operatorListLength == 0) {
116
- return address(0);
117
- } else {
118
- // Read the last added operator authorized to provide "best" compatibility.
119
- // In ERC721 there is one operator address at a time for a tokenId, so multiple calls to
120
- // `approve` would cause `getApproved` to return the last added operator. In this
121
- // compatibility version the same is true, when the authorized operators were not previously
122
- // authorized. If addresses are removed, then `getApproved` returned address can change due
123
- // to implementation of `EnumberableSet._remove`.
124
- return operatorsForTokenId.at(operatorListLength - 1);
125
- }
126
- }
127
-
128
- // solhint-disable no-unused-vars
129
- /*
130
- * @inheritdoc ILSP8CompatibilityForERC721
131
- */
132
- function isApprovedForAll(uint256 tokenId)
133
- public
134
- virtual
135
- override
136
- returns (bool)
137
- {
138
- return false;
139
- }
140
-
141
- /**
142
- * @inheritdoc ILSP8CompatibilityForERC721
143
- * @dev Compatible with ERC721 transferFrom.
144
- * Using force=true so that EOA and any contract may receive the tokenId.
145
- */
146
- function transferFrom(
147
- address from,
148
- address to,
149
- uint256 tokenId
150
- ) external virtual override {
151
- return
152
- transfer(from, to, bytes32(tokenId), true, "compat-transferFrom");
153
- }
154
-
155
- /**
156
- * @inheritdoc ILSP8CompatibilityForERC721
157
- * @dev Compatible with ERC721 safeTransferFrom.
158
- * Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
159
- */
160
- function safeTransferFrom(
161
- address from,
162
- address to,
163
- uint256 tokenId
164
- ) external virtual override {
165
- return
166
- transfer(
167
- from,
168
- to,
169
- bytes32(tokenId),
170
- false,
171
- "compat-safeTransferFrom"
172
- );
173
- }
174
-
175
- /*
176
- * @dev Compatible with ERC721 safeTransferFrom.
177
- * Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
178
- */
179
- function safeTransferFrom(
180
- address from,
181
- address to,
182
- uint256 tokenId,
183
- bytes memory data
184
- ) external virtual override {
185
- return transfer(from, to, bytes32(tokenId), false, data);
186
- }
38
+ ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {} // solhint-disable no-empty-blocks
187
39
 
188
40
  // --- Overrides
189
41
 
190
42
  function authorizeOperator(address operator, bytes32 tokenId)
191
43
  public
192
44
  virtual
193
- override(
194
- ILSP8IdentifiableDigitalAsset,
195
- LSP8IdentifiableDigitalAssetCore
196
- )
45
+ override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
197
46
  {
198
47
  super.authorizeOperator(operator, tokenId);
199
-
200
- emit Approval(
201
- tokenOwnerOf(tokenId),
202
- operator,
203
- abi.decode(abi.encodePacked(tokenId), (uint256))
204
- );
205
48
  }
206
49
 
207
50
  function _transfer(
@@ -210,14 +53,8 @@ contract LSP8CompatibilityForERC721 is
210
53
  bytes32 tokenId,
211
54
  bool force,
212
55
  bytes memory data
213
- ) internal virtual override {
56
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
214
57
  super._transfer(from, to, tokenId, force, data);
215
-
216
- emit Transfer(
217
- from,
218
- to,
219
- abi.decode(abi.encodePacked(tokenId), (uint256))
220
- );
221
58
  }
222
59
 
223
60
  function _mint(
@@ -225,28 +62,39 @@ contract LSP8CompatibilityForERC721 is
225
62
  bytes32 tokenId,
226
63
  bool force,
227
64
  bytes memory data
228
- ) internal virtual override {
65
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
229
66
  super._mint(to, tokenId, force, data);
230
-
231
- emit Transfer(
232
- address(0),
233
- to,
234
- abi.decode(abi.encodePacked(tokenId), (uint256))
235
- );
236
67
  }
237
68
 
238
69
  function _burn(bytes32 tokenId, bytes memory data)
239
70
  internal
240
71
  virtual
241
- override
72
+ override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
242
73
  {
243
74
  super._burn(tokenId, data);
75
+ }
76
+
77
+ /**
78
+ * @dev See {IERC165-supportsInterface}.
79
+ */
80
+ function supportsInterface(bytes4 interfaceId)
81
+ public
82
+ view
83
+ virtual
84
+ override(IERC165, LSP8IdentifiableDigitalAsset)
85
+ returns (bool)
86
+ {
87
+ return
88
+ interfaceId == _INTERFACEID_ERC721 ||
89
+ interfaceId == _INTERFACEID_ERC721METADATA ||
90
+ super.supportsInterface(interfaceId);
91
+ }
244
92
 
245
- address tokenOwner = tokenOwnerOf(tokenId);
246
- emit Transfer(
247
- tokenOwner,
248
- address(0),
249
- abi.decode(abi.encodePacked(tokenId), (uint256))
250
- );
93
+ function _setData(bytes32 key, bytes memory value)
94
+ internal
95
+ virtual
96
+ override(LSP4DigitalAssetMetadata, ERC725YCore)
97
+ {
98
+ super._setData(key, value);
251
99
  }
252
100
  }