@lukso/lsp-smart-contracts 0.6.0 → 0.7.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 (140) hide show
  1. package/README.md +13 -12
  2. package/artifacts/Create2Factory.json +2 -2
  3. package/artifacts/LSP0ERC725Account.json +66 -27
  4. package/artifacts/LSP0ERC725AccountInit.json +71 -53
  5. package/artifacts/LSP1UniversalReceiverDelegateUP.json +23 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateVault.json +23 -2
  7. package/artifacts/LSP4Compatibility.json +15 -9
  8. package/artifacts/LSP4DigitalAssetMetadata.json +25 -9
  9. package/artifacts/{LSP4DigitalAssetMetadataInit.json → LSP4DigitalAssetMetadataInitAbstract.json} +27 -60
  10. package/artifacts/LSP6KeyManager.json +93 -13
  11. package/artifacts/LSP6KeyManagerInit.json +98 -13
  12. package/artifacts/LSP7CappedSupply.json +56 -35
  13. package/artifacts/{LSP7CappedSupplyInit.json → LSP7CappedSupplyInitAbstract.json} +58 -104
  14. package/artifacts/LSP7CompatibleERC20.json +704 -0
  15. package/artifacts/LSP7CompatibleERC20InitAbstract.json +717 -0
  16. package/artifacts/LSP7CompatibleERC20Mintable.json +753 -0
  17. package/artifacts/LSP7CompatibleERC20MintableInit.json +773 -0
  18. package/artifacts/LSP7DigitalAsset.json +56 -61
  19. package/artifacts/LSP7DigitalAssetInitAbstract.json +540 -0
  20. package/artifacts/LSP7Mintable.json +59 -38
  21. package/artifacts/LSP7MintableInit.json +64 -64
  22. package/artifacts/LSP8CappedSupply.json +62 -9
  23. package/artifacts/{LSP8CappedSupplyInit.json → LSP8CappedSupplyInitAbstract.json} +64 -73
  24. package/artifacts/LSP8CompatibleERC721.json +907 -0
  25. package/artifacts/LSP8CompatibleERC721InitAbstract.json +920 -0
  26. package/artifacts/LSP8CompatibleERC721Mintable.json +967 -0
  27. package/artifacts/LSP8CompatibleERC721MintableInit.json +987 -0
  28. package/artifacts/LSP8IdentifiableDigitalAsset.json +62 -30
  29. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +628 -0
  30. package/artifacts/LSP8Mintable.json +64 -11
  31. package/artifacts/LSP8MintableInit.json +69 -37
  32. package/artifacts/LSP9Vault.json +63 -24
  33. package/artifacts/LSP9VaultInit.json +68 -50
  34. package/artifacts/UniversalFactory.json +2 -2
  35. package/artifacts/UniversalProfile.json +66 -27
  36. package/artifacts/UniversalProfileInit.json +71 -53
  37. package/artifacts/UniversalReceiverAddressStore.json +7 -2
  38. package/constants.js +273 -31
  39. package/contracts/Custom/ClaimOwnership.sol +74 -9
  40. package/contracts/Custom/ERC165Checker.sol +1 -1
  41. package/contracts/Custom/IClaimOwnership.sol +3 -1
  42. package/contracts/Factories/Create2Factory.sol +3 -13
  43. package/contracts/Factories/UniversalFactory.sol +20 -16
  44. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  45. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +3 -3
  46. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +49 -37
  47. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +10 -3
  48. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -3
  49. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
  50. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +3 -0
  51. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +4 -2
  52. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -1
  53. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +22 -16
  54. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +14 -10
  55. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +35 -29
  56. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +10 -3
  57. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +24 -9
  58. package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +9 -0
  59. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +157 -75
  60. package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
  61. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
  62. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +24 -4
  63. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +26 -5
  64. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +16 -0
  65. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
  66. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +151 -77
  67. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +16 -16
  68. package/contracts/LSP6KeyManager/LSP6Constants.sol +16 -21
  69. package/contracts/LSP6KeyManager/LSP6Errors.sol +42 -5
  70. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +6 -4
  71. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +293 -284
  72. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +11 -4
  73. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +5 -3
  74. package/contracts/LSP6KeyManager/LSP6Utils.sol +24 -27
  75. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +18 -5
  76. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
  77. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +8 -4
  78. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +35 -24
  79. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -3
  80. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +2 -0
  81. package/contracts/LSP7DigitalAsset/extensions/{ILSP7CompatibilityForERC20.sol → ILSP7CompatibleERC20.sol} +6 -6
  82. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +1 -1
  83. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +5 -2
  84. package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20.sol → LSP7CompatibleERC20.sol} +6 -7
  85. package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20Core.sol → LSP7CompatibleERC20Core.sol} +23 -19
  86. package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20InitAbstract.sol → LSP7CompatibleERC20InitAbstract.sol} +11 -10
  87. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +22 -0
  88. package/contracts/{LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol → LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol} +12 -7
  89. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +27 -0
  90. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +9 -7
  91. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +11 -4
  92. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +8 -7
  93. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +3 -1
  94. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +4 -4
  95. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +6 -0
  96. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +1 -1
  97. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +31 -30
  98. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +3 -1
  99. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{ILSP8CompatibilityForERC721.sol → ILSP8CompatibleERC721.sol} +16 -2
  100. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +17 -0
  101. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +1 -1
  102. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +4 -2
  103. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityConstants.sol → LSP8CompatibleConstants.sol} +0 -0
  104. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721.sol → LSP8CompatibleERC721.sol} +12 -11
  105. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Core.sol → LSP8CompatibleERC721Core.sol} +61 -37
  106. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721InitAbstract.sol → LSP8CompatibleERC721InitAbstract.sol} +13 -9
  107. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +21 -0
  108. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +50 -0
  109. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +24 -0
  110. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +22 -0
  111. package/contracts/{LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Init.sol → LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol} +12 -4
  112. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +27 -0
  113. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +6 -4
  114. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +7 -0
  115. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +8 -5
  116. package/contracts/LSP9Vault/LSP9Constants.sol +6 -3
  117. package/contracts/LSP9Vault/LSP9Vault.sol +9 -5
  118. package/contracts/LSP9Vault/LSP9VaultCore.sol +152 -69
  119. package/contracts/LSP9Vault/LSP9VaultInit.sol +10 -3
  120. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +9 -5
  121. package/contracts/Legacy/UniversalReceiverAddressStore.sol +6 -2
  122. package/contracts/UniversalProfile.sol +3 -4
  123. package/contracts/UniversalProfileInit.sol +10 -3
  124. package/contracts/UniversalProfileInitAbstract.sol +3 -5
  125. package/contracts/Utils/GasLib.sol +17 -0
  126. package/contracts/Utils/UtilsLib.sol +6 -34
  127. package/package.json +27 -30
  128. package/artifacts/LSP7CompatibilityForERC20.json +0 -686
  129. package/artifacts/LSP7CompatibilityForERC20Init.json +0 -727
  130. package/artifacts/LSP7DigitalAssetInit.json +0 -573
  131. package/artifacts/LSP8CompatibilityForERC721.json +0 -832
  132. package/artifacts/LSP8CompatibilityForERC721Init.json +0 -873
  133. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +0 -624
  134. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +0 -26
  135. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +0 -28
  136. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +0 -19
  137. package/contracts/LSP7DigitalAsset/presets/LSP7MintableCore.sol +0 -26
  138. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +0 -26
  139. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +0 -19
  140. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableCore.sol +0 -26
@@ -8,7 +8,7 @@ import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.so
8
8
  /**
9
9
  * @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
10
10
  */
11
- interface ILSP8CompatibilityForERC721 is ILSP8IdentifiableDigitalAsset {
11
+ interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
12
12
  /**
13
13
  * @notice To provide compatibility with indexing ERC721 events.
14
14
  * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
@@ -27,6 +27,12 @@ interface ILSP8CompatibilityForERC721 is ILSP8IdentifiableDigitalAsset {
27
27
  */
28
28
  event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
29
29
 
30
+ /**
31
+ * @dev This emits when an operator is enabled or disabled for an owner.
32
+ * The operator can manage all NFTs of the owner.
33
+ */
34
+ event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
35
+
30
36
  /**
31
37
  * @dev Compatible with ERC721 transferFrom.
32
38
  * @param from The sending address
@@ -74,11 +80,19 @@ interface ILSP8CompatibilityForERC721 is ILSP8IdentifiableDigitalAsset {
74
80
 
75
81
  /**
76
82
  * @dev Compatible with ERC721 approve.
77
- * @param operator The address to approve for `amount`
83
+ * @param operator The address to approve for `tokenId`
78
84
  * @param tokenId The tokenId to approve
79
85
  */
80
86
  function approve(address operator, uint256 tokenId) external;
81
87
 
88
+ /**
89
+ * @notice Enable or disable approval for a third party ("operator") to manage all of `msg.sender`'s assets
90
+ * @dev Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
91
+ * @param _operator Address to add to the set of authorized operators
92
+ * @param _approved True if the operator is approved, false to revoke approval
93
+ */
94
+ function setApprovalForAll(address _operator, bool _approved) external;
95
+
82
96
  /**
83
97
  * @dev Compatible with ERC721 getApproved.
84
98
  * @param tokenId The tokenId to query
@@ -0,0 +1,17 @@
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 access to a token id by an index.
10
+ */
11
+ interface ILSP8Enumerable is ILSP8IdentifiableDigitalAsset {
12
+ /**
13
+ * @dev Returns a token id at index. See totalSupply() to get total number of minted tokens.
14
+ * @return TokenId or 0x00 if no token exist at the index `index`
15
+ */
16
+ function tokenAt(uint256 index) external view returns (bytes32);
17
+ }
@@ -26,7 +26,7 @@ abstract contract LSP8CappedSupplyCore is LSP8IdentifiableDigitalAssetCore, ILSP
26
26
  /**
27
27
  * @inheritdoc ILSP8CappedSupply
28
28
  */
29
- function tokenSupplyCap() public view virtual override returns (uint256) {
29
+ function tokenSupplyCap() public view virtual returns (uint256) {
30
30
  return _tokenSupplyCap;
31
31
  }
32
32
 
@@ -4,14 +4,16 @@ pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
6
  import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
7
- import {LSP8IdentifiableDigitalAssetInit} from "../LSP8IdentifiableDigitalAssetInit.sol";
7
+ import {
8
+ LSP8IdentifiableDigitalAssetInitAbstract
9
+ } from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
8
10
  import {LSP8CappedSupplyCore} from "./LSP8CappedSupplyCore.sol";
9
11
 
10
12
  /**
11
13
  * @dev LSP8 extension, adds token supply cap.
12
14
  */
13
15
  abstract contract LSP8CappedSupplyInitAbstract is
14
- LSP8IdentifiableDigitalAssetInit,
16
+ LSP8IdentifiableDigitalAssetInitAbstract,
15
17
  LSP8CappedSupplyCore
16
18
  {
17
19
  function _initialize(uint256 tokenSupplyCap_) internal virtual onlyInitializing {
@@ -9,20 +9,21 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
9
9
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
10
10
 
11
11
  // modules
12
- import {LSP8IdentifiableDigitalAsset, LSP4DigitalAssetMetadata, ERC725YCore} from "../LSP8IdentifiableDigitalAsset.sol";
12
+ import {
13
+ LSP8IdentifiableDigitalAsset,
14
+ LSP4DigitalAssetMetadata,
15
+ ERC725YCore
16
+ } from "../LSP8IdentifiableDigitalAsset.sol";
13
17
  import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
14
- import {LSP8CompatibilityForERC721Core} from "./LSP8CompatibilityForERC721Core.sol";
18
+ import {LSP8CompatibleERC721Core} from "./LSP8CompatibleERC721Core.sol";
15
19
 
16
20
  // constants
17
- import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./LSP8CompatibilityConstants.sol";
21
+ import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./LSP8CompatibleConstants.sol";
18
22
 
19
23
  /**
20
24
  * @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
21
25
  */
22
- contract LSP8CompatibilityForERC721 is
23
- LSP8IdentifiableDigitalAsset,
24
- LSP8CompatibilityForERC721Core
25
- {
26
+ abstract contract LSP8CompatibleERC721 is LSP8IdentifiableDigitalAsset, LSP8CompatibleERC721Core {
26
27
  using EnumerableSet for EnumerableSet.AddressSet;
27
28
 
28
29
  /**
@@ -42,7 +43,7 @@ contract LSP8CompatibilityForERC721 is
42
43
  function authorizeOperator(address operator, bytes32 tokenId)
43
44
  public
44
45
  virtual
45
- override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
46
+ override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
46
47
  {
47
48
  super.authorizeOperator(operator, tokenId);
48
49
  }
@@ -53,7 +54,7 @@ contract LSP8CompatibilityForERC721 is
53
54
  bytes32 tokenId,
54
55
  bool force,
55
56
  bytes memory data
56
- ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
57
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core) {
57
58
  super._transfer(from, to, tokenId, force, data);
58
59
  }
59
60
 
@@ -62,14 +63,14 @@ contract LSP8CompatibilityForERC721 is
62
63
  bytes32 tokenId,
63
64
  bool force,
64
65
  bytes memory data
65
- ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
66
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core) {
66
67
  super._mint(to, tokenId, force, data);
67
68
  }
68
69
 
69
70
  function _burn(bytes32 tokenId, bytes memory data)
70
71
  internal
71
72
  virtual
72
- override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
73
+ override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
73
74
  {
74
75
  super._burn(tokenId, data);
75
76
  }
@@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
4
4
 
5
5
  // interfaces
6
6
  import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
7
- import {ILSP8CompatibilityForERC721} from "./ILSP8CompatibilityForERC721.sol";
7
+ import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";
8
8
 
9
9
  // libraries
10
10
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
@@ -14,26 +14,34 @@ import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
14
14
  import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
15
15
  import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
16
16
 
17
+ // errors
18
+ import "../LSP8Errors.sol";
19
+
17
20
  // constants
18
21
  import {_LSP4_METADATA_KEY} from "../../LSP4DigitalAssetMetadata/LSP4Constants.sol";
19
22
 
20
23
  /**
21
24
  * @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
22
25
  */
23
- abstract contract LSP8CompatibilityForERC721Core is
26
+ abstract contract LSP8CompatibleERC721Core is
24
27
  LSP4Compatibility,
25
28
  LSP8IdentifiableDigitalAssetCore,
26
- ILSP8CompatibilityForERC721
29
+ ILSP8CompatibleERC721
27
30
  {
28
31
  using EnumerableSet for EnumerableSet.AddressSet;
29
32
 
30
- /*
31
- * @inheritdoc ILSP8CompatibilityForERC721
33
+ /**
34
+ * Mapping from owner to operator approvals
35
+ * @dev for backward compatibility with ERC721
32
36
  */
33
- function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
34
- // silence compiler warning about unused variable
35
- tokenId;
37
+ mapping(address => mapping(address => bool)) private _operatorApprovals;
36
38
 
39
+ /*
40
+ * @inheritdoc ILSP8CompatibleERC721
41
+ */
42
+ function tokenURI(
43
+ uint256 tokenId // solhint-disable no-unused-vars
44
+ ) public view virtual returns (string memory) {
37
45
  bytes memory data = _getData(_LSP4_METADATA_KEY);
38
46
 
39
47
  // offset = bytes4(hashSig) + bytes32(contentHash) -> 4 + 32 = 36
@@ -44,25 +52,29 @@ abstract contract LSP8CompatibilityForERC721Core is
44
52
  }
45
53
 
46
54
  /**
47
- * @inheritdoc ILSP8CompatibilityForERC721
55
+ * @inheritdoc ILSP8CompatibleERC721
48
56
  */
49
- function ownerOf(uint256 tokenId) external view virtual override returns (address) {
57
+ function ownerOf(uint256 tokenId) public view virtual returns (address) {
50
58
  return tokenOwnerOf(bytes32(tokenId));
51
59
  }
52
60
 
53
61
  /**
54
- * @inheritdoc ILSP8CompatibilityForERC721
62
+ * @inheritdoc ILSP8CompatibleERC721
55
63
  */
56
- function approve(address operator, uint256 tokenId) external virtual override {
64
+ function approve(address operator, uint256 tokenId) public virtual {
57
65
  authorizeOperator(operator, bytes32(tokenId));
58
66
 
59
67
  emit Approval(tokenOwnerOf(bytes32(tokenId)), operator, tokenId);
60
68
  }
61
69
 
70
+ function setApprovalForAll(address operator, bool approved) public virtual {
71
+ _setApprovalForAll(msg.sender, operator, approved);
72
+ }
73
+
62
74
  /**
63
- * @inheritdoc ILSP8CompatibilityForERC721
75
+ * @inheritdoc ILSP8CompatibleERC721
64
76
  */
65
- function getApproved(uint256 tokenId) external view virtual override returns (address) {
77
+ function getApproved(uint256 tokenId) public view virtual returns (address) {
66
78
  bytes32 tokenIdAsBytes32 = bytes32(tokenId);
67
79
  _existsOrError(tokenIdAsBytes32);
68
80
 
@@ -83,24 +95,19 @@ abstract contract LSP8CompatibilityForERC721Core is
83
95
  }
84
96
 
85
97
  /*
86
- * @inheritdoc ILSP8CompatibilityForERC721
98
+ * @inheritdoc ILSP8CompatibleERC721
87
99
  */
88
100
  function isApprovedForAll(address tokenOwner, address operator)
89
101
  public
90
102
  view
91
103
  virtual
92
- override
93
104
  returns (bool)
94
105
  {
95
- // silence compiler warning about unused variable
96
- tokenOwner;
97
- operator;
98
-
99
- return false;
106
+ return _operatorApprovals[tokenOwner][operator];
100
107
  }
101
108
 
102
109
  /**
103
- * @inheritdoc ILSP8CompatibilityForERC721
110
+ * @inheritdoc ILSP8CompatibleERC721
104
111
  * @dev Compatible with ERC721 transferFrom.
105
112
  * Using force=true so that EOA and any contract may receive the tokenId.
106
113
  */
@@ -108,12 +115,12 @@ abstract contract LSP8CompatibilityForERC721Core is
108
115
  address from,
109
116
  address to,
110
117
  uint256 tokenId
111
- ) external virtual override {
112
- return transfer(from, to, bytes32(tokenId), true, "");
118
+ ) public virtual {
119
+ return _transfer(from, to, bytes32(tokenId), true, "");
113
120
  }
114
121
 
115
122
  /**
116
- * @inheritdoc ILSP8CompatibilityForERC721
123
+ * @inheritdoc ILSP8CompatibleERC721
117
124
  * @dev Compatible with ERC721 safeTransferFrom.
118
125
  * Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
119
126
  */
@@ -121,8 +128,8 @@ abstract contract LSP8CompatibilityForERC721Core is
121
128
  address from,
122
129
  address to,
123
130
  uint256 tokenId
124
- ) external virtual override {
125
- return transfer(from, to, bytes32(tokenId), false, "");
131
+ ) public virtual {
132
+ return _transfer(from, to, bytes32(tokenId), false, "");
126
133
  }
127
134
 
128
135
  /*
@@ -134,8 +141,8 @@ abstract contract LSP8CompatibilityForERC721Core is
134
141
  address to,
135
142
  uint256 tokenId,
136
143
  bytes memory data
137
- ) external virtual override {
138
- return transfer(from, to, bytes32(tokenId), false, data);
144
+ ) public virtual {
145
+ return _transfer(from, to, bytes32(tokenId), false, data);
139
146
  }
140
147
 
141
148
  // --- Overrides
@@ -147,11 +154,7 @@ abstract contract LSP8CompatibilityForERC721Core is
147
154
  {
148
155
  super.authorizeOperator(operator, tokenId);
149
156
 
150
- emit Approval(
151
- tokenOwnerOf(tokenId),
152
- operator,
153
- abi.decode(abi.encodePacked(tokenId), (uint256))
154
- );
157
+ emit Approval(tokenOwnerOf(tokenId), operator, uint256(tokenId));
155
158
  }
156
159
 
157
160
  function _transfer(
@@ -161,9 +164,15 @@ abstract contract LSP8CompatibilityForERC721Core is
161
164
  bool force,
162
165
  bytes memory data
163
166
  ) internal virtual override {
167
+ address operator = msg.sender;
168
+
169
+ if (!isApprovedForAll(from, operator) && !_isOperatorOrOwner(operator, tokenId)) {
170
+ revert LSP8NotTokenOperator(tokenId, operator);
171
+ }
172
+
164
173
  super._transfer(from, to, tokenId, force, data);
165
174
 
166
- emit Transfer(from, to, abi.decode(abi.encodePacked(tokenId), (uint256)));
175
+ emit Transfer(from, to, uint256(tokenId));
167
176
  }
168
177
 
169
178
  function _mint(
@@ -174,7 +183,7 @@ abstract contract LSP8CompatibilityForERC721Core is
174
183
  ) internal virtual override {
175
184
  super._mint(to, tokenId, force, data);
176
185
 
177
- emit Transfer(address(0), to, abi.decode(abi.encodePacked(tokenId), (uint256)));
186
+ emit Transfer(address(0), to, uint256(tokenId));
178
187
  }
179
188
 
180
189
  function _burn(bytes32 tokenId, bytes memory data) internal virtual override {
@@ -182,6 +191,21 @@ abstract contract LSP8CompatibilityForERC721Core is
182
191
 
183
192
  super._burn(tokenId, data);
184
193
 
185
- emit Transfer(tokenOwner, address(0), abi.decode(abi.encodePacked(tokenId), (uint256)));
194
+ emit Transfer(tokenOwner, address(0), uint256(tokenId));
195
+ }
196
+
197
+ /**
198
+ * @dev Approve `operator` to operate on all of `owner` tokens
199
+ *
200
+ * Emits an {ApprovalForAll} event.
201
+ */
202
+ function _setApprovalForAll(
203
+ address tokensOwner,
204
+ address operator,
205
+ bool approved
206
+ ) internal virtual {
207
+ require(tokensOwner != operator, "LSP8CompatibleERC721: approve to caller");
208
+ _operatorApprovals[tokensOwner][operator] = approved;
209
+ emit ApprovalForAll(tokensOwner, operator, approved);
186
210
  }
187
211
  }
@@ -6,19 +6,23 @@ pragma solidity ^0.8.0;
6
6
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
7
7
 
8
8
  // modules
9
- import {LSP8IdentifiableDigitalAssetInitAbstract, LSP4DigitalAssetMetadataInitAbstract, ERC725YCore} from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
9
+ import {
10
+ LSP8IdentifiableDigitalAssetInitAbstract,
11
+ LSP4DigitalAssetMetadataInitAbstract,
12
+ ERC725YCore
13
+ } from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
10
14
  import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
11
- import {LSP8CompatibilityForERC721Core} from "./LSP8CompatibilityForERC721Core.sol";
15
+ import {LSP8CompatibleERC721Core} from "./LSP8CompatibleERC721Core.sol";
12
16
 
13
17
  // constants
14
- import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./LSP8CompatibilityConstants.sol";
18
+ import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./LSP8CompatibleConstants.sol";
15
19
 
16
20
  /**
17
21
  * @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
18
22
  */
19
- contract LSP8CompatibilityForERC721InitAbstract is
23
+ contract LSP8CompatibleERC721InitAbstract is
20
24
  LSP8IdentifiableDigitalAssetInitAbstract,
21
- LSP8CompatibilityForERC721Core
25
+ LSP8CompatibleERC721Core
22
26
  {
23
27
  function _initialize(
24
28
  string memory name_,
@@ -31,7 +35,7 @@ contract LSP8CompatibilityForERC721InitAbstract is
31
35
  function authorizeOperator(address operator, bytes32 tokenId)
32
36
  public
33
37
  virtual
34
- override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
38
+ override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
35
39
  {
36
40
  super.authorizeOperator(operator, tokenId);
37
41
  }
@@ -42,7 +46,7 @@ contract LSP8CompatibilityForERC721InitAbstract is
42
46
  bytes32 tokenId,
43
47
  bool force,
44
48
  bytes memory data
45
- ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
49
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core) {
46
50
  super._transfer(from, to, tokenId, force, data);
47
51
  }
48
52
 
@@ -51,14 +55,14 @@ contract LSP8CompatibilityForERC721InitAbstract is
51
55
  bytes32 tokenId,
52
56
  bool force,
53
57
  bytes memory data
54
- ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
58
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core) {
55
59
  super._mint(to, tokenId, force, data);
56
60
  }
57
61
 
58
62
  function _burn(bytes32 tokenId, bytes memory data)
59
63
  internal
60
64
  virtual
61
- override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
65
+ override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
62
66
  {
63
67
  super._burn(tokenId, data);
64
68
  }
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import {LSP8IdentifiableDigitalAsset} from "../LSP8IdentifiableDigitalAsset.sol";
7
+ import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
8
+ import {LSP8EnumerableCore} from "./LSP8EnumerableCore.sol";
9
+
10
+ /**
11
+ * @dev LSP8 extension.
12
+ */
13
+ abstract contract LSP8Enumerable is LSP8IdentifiableDigitalAsset, LSP8EnumerableCore {
14
+ function _beforeTokenTransfer(
15
+ address from,
16
+ address to,
17
+ bytes32 tokenId
18
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8EnumerableCore) {
19
+ super._beforeTokenTransfer(from, to, tokenId);
20
+ }
21
+ }
@@ -0,0 +1,50 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // interfaces
6
+ import {ILSP8Enumerable} from "./ILSP8Enumerable.sol";
7
+
8
+ // modules
9
+ import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
10
+
11
+ /**
12
+ * @dev LSP8 extension, adds access to a token id by an index.
13
+ */
14
+ abstract contract LSP8EnumerableCore is LSP8IdentifiableDigitalAssetCore, ILSP8Enumerable {
15
+ // Mapping from token index to token id
16
+ mapping(uint256 => bytes32) private _indexToken;
17
+
18
+ // Mapping from token id to index
19
+ mapping(bytes32 => uint256) private _tokenIndex;
20
+
21
+ /**
22
+ * @inheritdoc ILSP8Enumerable
23
+ */
24
+ function tokenAt(uint256 index) public view returns (bytes32) {
25
+ return _indexToken[index];
26
+ }
27
+
28
+ function _beforeTokenTransfer(
29
+ address from,
30
+ address to,
31
+ bytes32 tokenId
32
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore) {
33
+ if (from == address(0)) {
34
+ uint256 index = _existingTokens;
35
+ _indexToken[index] = tokenId;
36
+ _tokenIndex[tokenId] = index;
37
+ } else if (to == address(0)) {
38
+ uint256 lastIndex = _existingTokens - 1;
39
+ uint256 index = _tokenIndex[tokenId];
40
+ if (index < lastIndex) {
41
+ bytes32 lastTokenId = _indexToken[lastIndex];
42
+ _indexToken[index] = lastTokenId;
43
+ _tokenIndex[lastTokenId] = index;
44
+ }
45
+ delete _indexToken[lastIndex];
46
+ delete _tokenIndex[tokenId];
47
+ }
48
+ super._beforeTokenTransfer(from, to, tokenId);
49
+ }
50
+ }
@@ -0,0 +1,24 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import {LSP8IdentifiableDigitalAssetInitAbstract} from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
7
+ import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
8
+ import {LSP8EnumerableCore} from "./LSP8EnumerableCore.sol";
9
+
10
+ /**
11
+ * @dev LSP8 extension.
12
+ */
13
+ abstract contract LSP8EnumerableInitAbstract is
14
+ LSP8IdentifiableDigitalAssetInitAbstract,
15
+ LSP8EnumerableCore
16
+ {
17
+ function _beforeTokenTransfer(
18
+ address from,
19
+ address to,
20
+ bytes32 tokenId
21
+ ) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8EnumerableCore) {
22
+ super._beforeTokenTransfer(from, to, tokenId);
23
+ }
24
+ }
@@ -0,0 +1,22 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {LSP8CompatibleERC721} from "../extensions/LSP8CompatibleERC721.sol";
5
+
6
+ contract LSP8CompatibleERC721Mintable is LSP8CompatibleERC721 {
7
+ /* solhint-disable no-empty-blocks */
8
+ constructor(
9
+ string memory name_,
10
+ string memory symbol_,
11
+ address newOwner_
12
+ ) LSP8CompatibleERC721(name_, symbol_, newOwner_) {}
13
+
14
+ function mint(
15
+ address to,
16
+ bytes32 tokenId,
17
+ bool force,
18
+ bytes memory data
19
+ ) public onlyOwner {
20
+ _mint(to, tokenId, force, data);
21
+ }
22
+ }
@@ -1,11 +1,19 @@
1
1
  // SPDX-License-Identifier: MIT
2
-
3
2
  pragma solidity ^0.8.0;
4
3
 
5
4
  // modules
6
- import {LSP7CompatibilityForERC20InitAbstract} from "./LSP7CompatibilityForERC20InitAbstract.sol";
5
+ import {
6
+ LSP8CompatibleERC721MintableInitAbstract
7
+ } from "./LSP8CompatibleERC721MintableInitAbstract.sol";
7
8
 
8
- contract LSP7CompatibilityForERC20Init is LSP7CompatibilityForERC20InitAbstract {
9
+ contract LSP8CompatibleERC721MintableInit is LSP8CompatibleERC721MintableInitAbstract {
10
+ /**
11
+ * @dev initialize (= lock) base implementation contract on deployment
12
+ */
13
+ constructor() {
14
+ _disableInitializers();
15
+ }
16
+
9
17
  /**
10
18
  * @notice Sets the name, the symbol and the owner of the token
11
19
  * @param name_ The name of the token
@@ -17,6 +25,6 @@ contract LSP7CompatibilityForERC20Init is LSP7CompatibilityForERC20InitAbstract
17
25
  string memory symbol_,
18
26
  address newOwner_
19
27
  ) public virtual initializer {
20
- LSP7CompatibilityForERC20InitAbstract._initialize(name_, symbol_, newOwner_);
28
+ LSP8CompatibleERC721MintableInitAbstract._initialize(name_, symbol_, newOwner_);
21
29
  }
22
30
  }
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ // modules
5
+ import {LSP8CompatibleERC721InitAbstract} from "../extensions/LSP8CompatibleERC721InitAbstract.sol";
6
+
7
+ contract LSP8CompatibleERC721MintableInitAbstract is LSP8CompatibleERC721InitAbstract {
8
+ /**
9
+ * @inheritdoc LSP8CompatibleERC721InitAbstract
10
+ */
11
+ function _initialize(
12
+ string memory name_,
13
+ string memory symbol_,
14
+ address newOwner_
15
+ ) internal virtual override onlyInitializing {
16
+ LSP8CompatibleERC721InitAbstract._initialize(name_, symbol_, newOwner_);
17
+ }
18
+
19
+ function mint(
20
+ address to,
21
+ bytes32 tokenId,
22
+ bool force,
23
+ bytes memory data
24
+ ) public onlyOwner {
25
+ _mint(to, tokenId, force, data);
26
+ }
27
+ }
@@ -2,14 +2,16 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
+ // interfaces
6
+ import {ILSP8Mintable} from "./ILSP8Mintable.sol";
7
+
5
8
  // modules
6
9
  import {LSP8IdentifiableDigitalAsset} from "../LSP8IdentifiableDigitalAsset.sol";
7
- import {LSP8MintableCore} from "./LSP8MintableCore.sol";
8
10
 
9
11
  /**
10
12
  * @dev LSP8 extension.
11
13
  */
12
- contract LSP8Mintable is LSP8IdentifiableDigitalAsset, LSP8MintableCore {
14
+ contract LSP8Mintable is LSP8IdentifiableDigitalAsset, ILSP8Mintable {
13
15
  // solhint-disable no-empty-blocks
14
16
  /**
15
17
  * @notice Sets the token-Metadata and register LSP8InterfaceId
@@ -24,14 +26,14 @@ contract LSP8Mintable is LSP8IdentifiableDigitalAsset, LSP8MintableCore {
24
26
  ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {}
25
27
 
26
28
  /**
27
- * @inheritdoc LSP8MintableCore
29
+ * @inheritdoc ILSP8Mintable
28
30
  */
29
31
  function mint(
30
32
  address to,
31
33
  bytes32 tokenId,
32
34
  bool force,
33
35
  bytes memory data
34
- ) public override onlyOwner {
36
+ ) public virtual onlyOwner {
35
37
  _mint(to, tokenId, force, data);
36
38
  }
37
39
  }
@@ -9,6 +9,13 @@ import {LSP8MintableInitAbstract} from "./LSP8MintableInitAbstract.sol";
9
9
  * @dev LSP8 extension.
10
10
  */
11
11
  contract LSP8MintableInit is LSP8MintableInitAbstract {
12
+ /**
13
+ * @dev initialize (= lock) base implementation contract on deployment
14
+ */
15
+ constructor() {
16
+ _disableInitializers();
17
+ }
18
+
12
19
  /**
13
20
  * @notice Sets the token-Metadata and register LSP8InterfaceId
14
21
  * @param name_ The name of the token