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