@lukso/lsp-smart-contracts 0.12.1 → 0.13.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.
- package/README.md +2 -2
- package/artifacts/LSP0ERC725Account.json +6 -6
- package/artifacts/LSP0ERC725AccountInit.json +6 -6
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
- package/artifacts/LSP4DigitalAssetMetadata.json +5 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +5 -0
- package/artifacts/LSP6KeyManager.json +2 -2
- package/artifacts/LSP6KeyManagerInit.json +2 -2
- package/artifacts/LSP7CappedSupply.json +71 -36
- package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -36
- package/artifacts/LSP7CompatibleERC20.json +71 -36
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -36
- package/artifacts/LSP7CompatibleERC20Mintable.json +78 -38
- package/artifacts/LSP7CompatibleERC20MintableInit.json +78 -38
- package/artifacts/LSP7DigitalAsset.json +71 -36
- package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -36
- package/artifacts/LSP7Mintable.json +78 -38
- package/artifacts/LSP7MintableInit.json +78 -38
- package/artifacts/LSP8CappedSupply.json +187 -23
- package/artifacts/LSP8CappedSupplyInitAbstract.json +200 -36
- package/artifacts/LSP8CompatibleERC721.json +187 -23
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +200 -36
- package/artifacts/LSP8CompatibleERC721Mintable.json +195 -26
- package/artifacts/LSP8CompatibleERC721MintableInit.json +208 -39
- package/artifacts/LSP8IdentifiableDigitalAsset.json +187 -23
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +200 -36
- package/artifacts/LSP8Mintable.json +195 -26
- package/artifacts/LSP8MintableInit.json +208 -39
- package/artifacts/LSP9Vault.json +6 -6
- package/artifacts/LSP9VaultInit.json +6 -6
- package/artifacts/UniversalProfile.json +6 -6
- package/artifacts/UniversalProfileInit.json +6 -6
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +1 -22
- package/contracts/LSP17Extensions/Extension4337.sol +26 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +9 -0
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +20 -34
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol +47 -0
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +19 -31
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +13 -6
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +1 -1
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +20 -9
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +7 -5
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +128 -25
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -2
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +6 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +4 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +7 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +5 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +8 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +12 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +4 -0
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -0
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +77 -4
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +15 -12
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +19 -3
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +25 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +223 -19
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +28 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +15 -4
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +8 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +13 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +4 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +13 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +6 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +0 -22
- package/contracts/Version.sol +1 -1
- package/devdocs/LSP4DigitalAssetMetadata.json +11 -5
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -2
- package/devdocs/LSP6KeyManager.json +1 -1
- package/devdocs/LSP6KeyManagerInit.json +1 -1
- package/devdocs/LSP7CappedSupply.json +22 -2
- package/devdocs/LSP7CappedSupplyInitAbstract.json +22 -2
- package/devdocs/LSP7CompatibleERC20.json +23 -2
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +22 -2
- package/devdocs/LSP7CompatibleERC20Mintable.json +23 -2
- package/devdocs/LSP7CompatibleERC20MintableInit.json +24 -3
- package/devdocs/LSP7DigitalAsset.json +27 -6
- package/devdocs/LSP7DigitalAssetInitAbstract.json +22 -2
- package/devdocs/LSP7Mintable.json +24 -2
- package/devdocs/LSP7MintableInit.json +25 -3
- package/devdocs/LSP8CappedSupply.json +66 -4
- package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -4
- package/devdocs/LSP8CompatibleERC721.json +69 -5
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +67 -5
- package/devdocs/LSP8CompatibleERC721Mintable.json +69 -5
- package/devdocs/LSP8CompatibleERC721MintableInit.json +70 -6
- package/devdocs/LSP8IdentifiableDigitalAsset.json +71 -8
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -4
- package/devdocs/LSP8Mintable.json +68 -4
- package/devdocs/LSP8MintableInit.json +69 -5
- package/dist/constants.cjs.js +4406 -1319
- package/dist/constants.d.ts +4184 -844
- package/dist/constants.es.js +4405 -1319
- package/package.json +2 -2
- package/userdocs/LSP7CappedSupply.json +8 -0
- package/userdocs/LSP7CappedSupplyInitAbstract.json +8 -0
- package/userdocs/LSP7CompatibleERC20.json +8 -0
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +8 -0
- package/userdocs/LSP7CompatibleERC20Mintable.json +8 -0
- package/userdocs/LSP7CompatibleERC20MintableInit.json +9 -1
- package/userdocs/LSP7DigitalAsset.json +8 -0
- package/userdocs/LSP7DigitalAssetInitAbstract.json +8 -0
- package/userdocs/LSP7Mintable.json +8 -0
- package/userdocs/LSP7MintableInit.json +9 -1
- package/userdocs/LSP8CappedSupply.json +20 -0
- package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -0
- package/userdocs/LSP8CompatibleERC721.json +20 -0
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +20 -0
- package/userdocs/LSP8CompatibleERC721Mintable.json +20 -0
- package/userdocs/LSP8CompatibleERC721MintableInit.json +21 -1
- package/userdocs/LSP8IdentifiableDigitalAsset.json +21 -1
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +20 -0
- package/userdocs/LSP8Mintable.json +20 -0
- package/userdocs/LSP8MintableInit.json +21 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.12;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {
|
|
@@ -9,6 +9,12 @@ import {
|
|
|
9
9
|
ILSP8IdentifiableDigitalAsset
|
|
10
10
|
} from "./ILSP8IdentifiableDigitalAsset.sol";
|
|
11
11
|
|
|
12
|
+
// modules
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
LSP4DigitalAssetMetadataCore
|
|
16
|
+
} from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol";
|
|
17
|
+
|
|
12
18
|
// libraries
|
|
13
19
|
import {
|
|
14
20
|
EnumerableSet
|
|
@@ -32,7 +38,10 @@ import {
|
|
|
32
38
|
LSP8TokenIdAlreadyMinted,
|
|
33
39
|
LSP8CannotSendToSelf,
|
|
34
40
|
LSP8NotifyTokenReceiverContractMissingLSP1Interface,
|
|
35
|
-
LSP8NotifyTokenReceiverIsEOA
|
|
41
|
+
LSP8NotifyTokenReceiverIsEOA,
|
|
42
|
+
LSP8TokenIdsDataLengthMismatch,
|
|
43
|
+
LSP8TokenIdsDataEmptyArray,
|
|
44
|
+
LSP8BatchCallFailed
|
|
36
45
|
} from "./LSP8Errors.sol";
|
|
37
46
|
|
|
38
47
|
// constants
|
|
@@ -49,12 +58,11 @@ import {
|
|
|
49
58
|
* @dev Core Implementation of a LSP8 compliant contract.
|
|
50
59
|
*/
|
|
51
60
|
abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
61
|
+
LSP4DigitalAssetMetadataCore,
|
|
52
62
|
ILSP8IdentifiableDigitalAsset
|
|
53
63
|
{
|
|
54
64
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
55
65
|
using EnumerableSet for EnumerableSet.Bytes32Set;
|
|
56
|
-
using ERC165Checker for address;
|
|
57
|
-
using LSP1Utils for address;
|
|
58
66
|
|
|
59
67
|
// --- Storage
|
|
60
68
|
|
|
@@ -115,6 +123,118 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
115
123
|
return _ownedTokens[tokenOwner].values();
|
|
116
124
|
}
|
|
117
125
|
|
|
126
|
+
// --- TokenId Metadata functionality
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @inheritdoc ILSP8IdentifiableDigitalAsset
|
|
130
|
+
*/
|
|
131
|
+
function setTokenIdData(
|
|
132
|
+
bytes32 tokenId,
|
|
133
|
+
bytes32 dataKey,
|
|
134
|
+
bytes memory dataValue
|
|
135
|
+
) public virtual override onlyOwner {
|
|
136
|
+
_setTokenIdData(tokenId, dataKey, dataValue);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @inheritdoc ILSP8IdentifiableDigitalAsset
|
|
141
|
+
*/
|
|
142
|
+
function setTokenIdDataBatch(
|
|
143
|
+
bytes32[] memory tokenIds,
|
|
144
|
+
bytes32[] memory dataKeys,
|
|
145
|
+
bytes[] memory dataValues
|
|
146
|
+
) public virtual override onlyOwner {
|
|
147
|
+
if (
|
|
148
|
+
tokenIds.length != dataKeys.length ||
|
|
149
|
+
dataKeys.length != dataValues.length
|
|
150
|
+
) {
|
|
151
|
+
revert LSP8TokenIdsDataLengthMismatch();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (tokenIds.length == 0) {
|
|
155
|
+
revert LSP8TokenIdsDataEmptyArray();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
for (uint256 i; i < tokenIds.length; ) {
|
|
159
|
+
_setTokenIdData(tokenIds[i], dataKeys[i], dataValues[i]);
|
|
160
|
+
|
|
161
|
+
// Increment the iterator in unchecked block to save gas
|
|
162
|
+
unchecked {
|
|
163
|
+
++i;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// --- General functionality
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @inheritdoc ILSP8IdentifiableDigitalAsset
|
|
172
|
+
*
|
|
173
|
+
* @custom:info It's not possible to send value along the functions call due to the use of `delegatecall`.
|
|
174
|
+
*/
|
|
175
|
+
function batchCalls(
|
|
176
|
+
bytes[] calldata data
|
|
177
|
+
) public virtual override returns (bytes[] memory results) {
|
|
178
|
+
results = new bytes[](data.length);
|
|
179
|
+
for (uint256 i; i < data.length; ) {
|
|
180
|
+
(bool success, bytes memory result) = address(this).delegatecall(
|
|
181
|
+
data[i]
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
if (!success) {
|
|
185
|
+
// Look for revert reason and bubble it up if present
|
|
186
|
+
if (result.length != 0) {
|
|
187
|
+
// The easiest way to bubble the revert reason is using memory via assembly
|
|
188
|
+
// solhint-disable no-inline-assembly
|
|
189
|
+
/// @solidity memory-safe-assembly
|
|
190
|
+
assembly {
|
|
191
|
+
let returndata_size := mload(result)
|
|
192
|
+
revert(add(32, result), returndata_size)
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
revert LSP8BatchCallFailed({callIndex: i});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
results[i] = result;
|
|
200
|
+
|
|
201
|
+
unchecked {
|
|
202
|
+
++i;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @inheritdoc ILSP8IdentifiableDigitalAsset
|
|
209
|
+
*/
|
|
210
|
+
function getTokenIdData(
|
|
211
|
+
bytes32 tokenId,
|
|
212
|
+
bytes32 dataKey
|
|
213
|
+
) public view virtual override returns (bytes memory dataValues) {
|
|
214
|
+
return _getTokenIdData(tokenId, dataKey);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @inheritdoc ILSP8IdentifiableDigitalAsset
|
|
219
|
+
*/
|
|
220
|
+
function getTokenIdDataBatch(
|
|
221
|
+
bytes32[] memory tokenIds,
|
|
222
|
+
bytes32[] memory dataKeys
|
|
223
|
+
) public view virtual override returns (bytes[] memory dataValues) {
|
|
224
|
+
dataValues = new bytes[](tokenIds.length);
|
|
225
|
+
|
|
226
|
+
for (uint256 i; i < tokenIds.length; ) {
|
|
227
|
+
dataValues[i] = _getTokenIdData(tokenIds[i], dataKeys[i]);
|
|
228
|
+
|
|
229
|
+
// Increment the iterator in unchecked block to save gas
|
|
230
|
+
unchecked {
|
|
231
|
+
++i;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return dataValues;
|
|
236
|
+
}
|
|
237
|
+
|
|
118
238
|
// --- Operator functionality
|
|
119
239
|
|
|
120
240
|
/**
|
|
@@ -142,7 +262,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
142
262
|
bool isAdded = _operators[tokenId].add(operator);
|
|
143
263
|
if (!isAdded) revert LSP8OperatorAlreadyAuthorized(operator, tokenId);
|
|
144
264
|
|
|
145
|
-
emit
|
|
265
|
+
emit OperatorAuthorizationChanged(
|
|
146
266
|
operator,
|
|
147
267
|
tokenOwner,
|
|
148
268
|
tokenId,
|
|
@@ -156,7 +276,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
156
276
|
operatorNotificationData
|
|
157
277
|
);
|
|
158
278
|
|
|
159
|
-
operator
|
|
279
|
+
_notifyTokenOperator(operator, lsp1Data);
|
|
160
280
|
}
|
|
161
281
|
|
|
162
282
|
/**
|
|
@@ -198,10 +318,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
198
318
|
operatorNotificationData
|
|
199
319
|
);
|
|
200
320
|
|
|
201
|
-
operator
|
|
202
|
-
_TYPEID_LSP8_TOKENOPERATOR,
|
|
203
|
-
lsp1Data
|
|
204
|
-
);
|
|
321
|
+
_notifyTokenOperator(operator, lsp1Data);
|
|
205
322
|
}
|
|
206
323
|
}
|
|
207
324
|
|
|
@@ -301,7 +418,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
301
418
|
bool isRemoved = _operators[tokenId].remove(operator);
|
|
302
419
|
if (!isRemoved) revert LSP8NonExistingOperator(operator, tokenId);
|
|
303
420
|
|
|
304
|
-
emit
|
|
421
|
+
emit OperatorRevoked(
|
|
305
422
|
operator,
|
|
306
423
|
tokenOwner,
|
|
307
424
|
tokenId,
|
|
@@ -406,7 +523,13 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
406
523
|
|
|
407
524
|
_afterTokenTransfer(address(0), to, tokenId, data);
|
|
408
525
|
|
|
409
|
-
bytes memory lsp1Data = abi.encode(
|
|
526
|
+
bytes memory lsp1Data = abi.encode(
|
|
527
|
+
msg.sender,
|
|
528
|
+
address(0),
|
|
529
|
+
to,
|
|
530
|
+
tokenId,
|
|
531
|
+
data
|
|
532
|
+
);
|
|
410
533
|
_notifyTokenReceiver(to, force, lsp1Data);
|
|
411
534
|
}
|
|
412
535
|
|
|
@@ -454,13 +577,14 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
454
577
|
_afterTokenTransfer(tokenOwner, address(0), tokenId, data);
|
|
455
578
|
|
|
456
579
|
bytes memory lsp1Data = abi.encode(
|
|
580
|
+
msg.sender,
|
|
457
581
|
tokenOwner,
|
|
458
582
|
address(0),
|
|
459
583
|
tokenId,
|
|
460
584
|
data
|
|
461
585
|
);
|
|
462
586
|
|
|
463
|
-
tokenOwner
|
|
587
|
+
_notifyTokenSender(tokenOwner, lsp1Data);
|
|
464
588
|
}
|
|
465
589
|
|
|
466
590
|
/**
|
|
@@ -524,12 +648,43 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
524
648
|
|
|
525
649
|
_afterTokenTransfer(from, to, tokenId, data);
|
|
526
650
|
|
|
527
|
-
bytes memory lsp1Data = abi.encode(from, to, tokenId, data);
|
|
651
|
+
bytes memory lsp1Data = abi.encode(msg.sender, from, to, tokenId, data);
|
|
528
652
|
|
|
529
|
-
from
|
|
653
|
+
_notifyTokenSender(from, lsp1Data);
|
|
530
654
|
_notifyTokenReceiver(to, force, lsp1Data);
|
|
531
655
|
}
|
|
532
656
|
|
|
657
|
+
/**
|
|
658
|
+
* @dev Sets data for a specific `tokenId` and `dataKey` in the ERC725Y storage
|
|
659
|
+
* The ERC725Y data key is the hash of the `tokenId` and `dataKey` concatenated
|
|
660
|
+
* @param tokenId The unique identifier for a token.
|
|
661
|
+
* @param dataKey The key for the data to set.
|
|
662
|
+
* @param dataValue The value to set for the given data key.
|
|
663
|
+
* @custom:events {TokenIdDataChanged} event.
|
|
664
|
+
*/
|
|
665
|
+
function _setTokenIdData(
|
|
666
|
+
bytes32 tokenId,
|
|
667
|
+
bytes32 dataKey,
|
|
668
|
+
bytes memory dataValue
|
|
669
|
+
) internal virtual {
|
|
670
|
+
_store[keccak256(bytes.concat(tokenId, dataKey))] = dataValue;
|
|
671
|
+
emit TokenIdDataChanged(tokenId, dataKey, dataValue);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* @dev Retrieves data for a specific `tokenId` and `dataKey` from the ERC725Y storage
|
|
676
|
+
* The ERC725Y data key is the hash of the `tokenId` and `dataKey` concatenated
|
|
677
|
+
* @param tokenId The unique identifier for a token.
|
|
678
|
+
* @param dataKey The key for the data to retrieve.
|
|
679
|
+
* @return dataValues The data value associated with the given `tokenId` and `dataKey`.
|
|
680
|
+
*/
|
|
681
|
+
function _getTokenIdData(
|
|
682
|
+
bytes32 tokenId,
|
|
683
|
+
bytes32 dataKey
|
|
684
|
+
) internal view virtual returns (bytes memory dataValues) {
|
|
685
|
+
return _store[keccak256(bytes.concat(tokenId, dataKey))];
|
|
686
|
+
}
|
|
687
|
+
|
|
533
688
|
/**
|
|
534
689
|
* @dev Hook that is called before any token transfer, including minting and burning.
|
|
535
690
|
* Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function.
|
|
@@ -563,17 +718,66 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
563
718
|
) internal virtual {}
|
|
564
719
|
|
|
565
720
|
/**
|
|
566
|
-
* @dev
|
|
567
|
-
*
|
|
721
|
+
* @dev Attempt to notify the operator `operator` about the `tokenId` being authorized.
|
|
722
|
+
* This is done by calling its {universalReceiver} function with the `_TYPEID_LSP8_TOKENOPERATOR` as typeId, if `operator` is a contract that supports the LSP1 interface.
|
|
723
|
+
* If `operator` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
|
|
724
|
+
|
|
725
|
+
* @param operator The address to call the {universalReceiver} function on.
|
|
726
|
+
* @param lsp1Data the data to be sent to the `operator` address in the `universalReceiver` call.
|
|
727
|
+
*/
|
|
728
|
+
function _notifyTokenOperator(
|
|
729
|
+
address operator,
|
|
730
|
+
bytes memory lsp1Data
|
|
731
|
+
) internal virtual {
|
|
732
|
+
LSP1Utils.notifyUniversalReceiver(
|
|
733
|
+
operator,
|
|
734
|
+
_TYPEID_LSP8_TOKENOPERATOR,
|
|
735
|
+
lsp1Data
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* @dev Attempt to notify the token sender `from` about the `tokenId` being transferred.
|
|
741
|
+
* This is done by calling its {universalReceiver} function with the `_TYPEID_LSP8_TOKENSSENDER` as typeId, if `from` is a contract that supports the LSP1 interface.
|
|
742
|
+
* If `from` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
|
|
743
|
+
|
|
744
|
+
* @param from The address to call the {universalReceiver} function on.
|
|
745
|
+
* @param lsp1Data the data to be sent to the `from` address in the `universalReceiver` call.
|
|
746
|
+
*/
|
|
747
|
+
function _notifyTokenSender(
|
|
748
|
+
address from,
|
|
749
|
+
bytes memory lsp1Data
|
|
750
|
+
) internal virtual {
|
|
751
|
+
LSP1Utils.notifyUniversalReceiver(
|
|
752
|
+
from,
|
|
753
|
+
_TYPEID_LSP8_TOKENSSENDER,
|
|
754
|
+
lsp1Data
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* @dev Attempt to notify the token receiver `to` about the `tokenId` being received.
|
|
760
|
+
* This is done by calling its {universalReceiver} function with the `_TYPEID_LSP8_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface.
|
|
568
761
|
*
|
|
569
|
-
*
|
|
762
|
+
* If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `force` boolean flag.
|
|
763
|
+
* - if `force` is set to `true`, nothing will happen and no notification will be sent.
|
|
764
|
+
* - if `force` is set to `false, the transaction will revert.
|
|
765
|
+
*
|
|
766
|
+
* @param to The address to call the {universalReceiver} function on.
|
|
767
|
+
* @param force A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not.
|
|
768
|
+
* @param lsp1Data The data to be sent to the `to` address in the `universalReceiver(...)` call.
|
|
570
769
|
*/
|
|
571
770
|
function _notifyTokenReceiver(
|
|
572
771
|
address to,
|
|
573
772
|
bool force,
|
|
574
773
|
bytes memory lsp1Data
|
|
575
774
|
) internal virtual {
|
|
576
|
-
if (
|
|
775
|
+
if (
|
|
776
|
+
ERC165Checker.supportsERC165InterfaceUnchecked(
|
|
777
|
+
to,
|
|
778
|
+
_INTERFACEID_LSP1
|
|
779
|
+
)
|
|
780
|
+
) {
|
|
577
781
|
ILSP1(to).universalReceiver(_TYPEID_LSP8_TOKENSRECIPIENT, lsp1Data);
|
|
578
782
|
} else if (!force) {
|
|
579
783
|
if (to.code.length != 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.12;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
@@ -13,18 +13,22 @@ import {
|
|
|
13
13
|
LSP4DigitalAssetMetadataInitAbstract
|
|
14
14
|
} from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol";
|
|
15
15
|
|
|
16
|
+
import {
|
|
17
|
+
LSP4DigitalAssetMetadataCore
|
|
18
|
+
} from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol";
|
|
19
|
+
|
|
16
20
|
import {LSP17Extendable} from "../LSP17ContractExtension/LSP17Extendable.sol";
|
|
17
21
|
|
|
18
22
|
// libraries
|
|
19
23
|
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
20
24
|
|
|
21
25
|
// constants
|
|
22
|
-
import {_INTERFACEID_LSP8,
|
|
26
|
+
import {_INTERFACEID_LSP8, _LSP8_TOKENID_SCHEMA_KEY} from "./LSP8Constants.sol";
|
|
23
27
|
|
|
24
28
|
// errors
|
|
25
29
|
import {
|
|
26
30
|
LSP8TokenContractCannotHoldValue,
|
|
27
|
-
|
|
31
|
+
LSP8TokenIdSchemaNotEditable
|
|
28
32
|
} from "./LSP8Errors.sol";
|
|
29
33
|
|
|
30
34
|
import {
|
|
@@ -56,33 +60,35 @@ abstract contract LSP8IdentifiableDigitalAssetInitAbstract is
|
|
|
56
60
|
LSP17Extendable
|
|
57
61
|
{
|
|
58
62
|
/**
|
|
59
|
-
* @dev Initialize a `LSP8IdentifiableDigitalAsset` contract and set the tokenId
|
|
63
|
+
* @dev Initialize a `LSP8IdentifiableDigitalAsset` contract and set the tokenId schema inside the ERC725Y storage of the contract.
|
|
60
64
|
* This will also set the token `name_` and `symbol_` under the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol`.
|
|
61
65
|
*
|
|
62
66
|
* @param name_ The name of the token
|
|
63
67
|
* @param symbol_ The symbol of the token
|
|
64
68
|
* @param newOwner_ The owner of the the token-Metadata
|
|
65
|
-
* @param
|
|
66
|
-
*
|
|
69
|
+
* @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
|
|
70
|
+
* @param lsp8TokenIdSchema_ The schema of tokenIds (= NFTs) that this contract will create.
|
|
67
71
|
*
|
|
68
|
-
* @custom:warning Make sure the tokenId
|
|
72
|
+
* @custom:warning Make sure the tokenId schema provided on deployment is correct, as it can only be set once
|
|
69
73
|
* and cannot be changed in the ERC725Y storage after the contract has been initialized.
|
|
70
74
|
*/
|
|
71
75
|
function _initialize(
|
|
72
76
|
string memory name_,
|
|
73
77
|
string memory symbol_,
|
|
74
78
|
address newOwner_,
|
|
75
|
-
uint256
|
|
79
|
+
uint256 lsp4TokenType_,
|
|
80
|
+
uint256 lsp8TokenIdSchema_
|
|
76
81
|
) internal virtual onlyInitializing {
|
|
77
82
|
LSP4DigitalAssetMetadataInitAbstract._initialize(
|
|
78
83
|
name_,
|
|
79
84
|
symbol_,
|
|
80
|
-
newOwner_
|
|
85
|
+
newOwner_,
|
|
86
|
+
lsp4TokenType_
|
|
81
87
|
);
|
|
82
88
|
|
|
83
89
|
LSP4DigitalAssetMetadataInitAbstract._setData(
|
|
84
|
-
|
|
85
|
-
abi.encode(
|
|
90
|
+
_LSP8_TOKENID_SCHEMA_KEY,
|
|
91
|
+
abi.encode(lsp8TokenIdSchema_)
|
|
86
92
|
);
|
|
87
93
|
}
|
|
88
94
|
|
|
@@ -218,15 +224,22 @@ abstract contract LSP8IdentifiableDigitalAssetInitAbstract is
|
|
|
218
224
|
|
|
219
225
|
/**
|
|
220
226
|
* @inheritdoc LSP4DigitalAssetMetadataInitAbstract
|
|
221
|
-
* @dev The ERC725Y data key `
|
|
227
|
+
* @dev The ERC725Y data key `_LSP8_TOKENID_SCHEMA_KEY` cannot be changed
|
|
222
228
|
* once the identifiable digital asset contract has been deployed.
|
|
223
229
|
*/
|
|
224
230
|
function _setData(
|
|
225
231
|
bytes32 dataKey,
|
|
226
232
|
bytes memory dataValue
|
|
227
|
-
)
|
|
228
|
-
|
|
229
|
-
|
|
233
|
+
)
|
|
234
|
+
internal
|
|
235
|
+
virtual
|
|
236
|
+
override(
|
|
237
|
+
LSP4DigitalAssetMetadataInitAbstract,
|
|
238
|
+
LSP4DigitalAssetMetadataCore
|
|
239
|
+
)
|
|
240
|
+
{
|
|
241
|
+
if (dataKey == _LSP8_TOKENID_SCHEMA_KEY) {
|
|
242
|
+
revert LSP8TokenIdSchemaNotEditable();
|
|
230
243
|
}
|
|
231
244
|
LSP4DigitalAssetMetadataInitAbstract._setData(dataKey, dataValue);
|
|
232
245
|
}
|
|
@@ -64,13 +64,24 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
64
64
|
* @param name_ The name of the token.
|
|
65
65
|
* @param symbol_ The symbol of the token.
|
|
66
66
|
* @param newOwner_ The owner of the token contract.
|
|
67
|
+
* @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
|
|
68
|
+
* @param lsp8TokenIdSchema_ The schema of tokenIds (= NFTs) that this contract will create.
|
|
67
69
|
*/
|
|
68
70
|
constructor(
|
|
69
71
|
string memory name_,
|
|
70
72
|
string memory symbol_,
|
|
71
73
|
address newOwner_,
|
|
72
|
-
uint256
|
|
73
|
-
|
|
74
|
+
uint256 lsp4TokenType_,
|
|
75
|
+
uint256 lsp8TokenIdSchema_
|
|
76
|
+
)
|
|
77
|
+
LSP8IdentifiableDigitalAsset(
|
|
78
|
+
name_,
|
|
79
|
+
symbol_,
|
|
80
|
+
newOwner_,
|
|
81
|
+
lsp4TokenType_,
|
|
82
|
+
lsp8TokenIdSchema_
|
|
83
|
+
)
|
|
84
|
+
{}
|
|
74
85
|
|
|
75
86
|
/**
|
|
76
87
|
* @inheritdoc IERC721Metadata
|
|
@@ -316,7 +327,7 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
316
327
|
* @inheritdoc LSP8IdentifiableDigitalAssetCore
|
|
317
328
|
*
|
|
318
329
|
* @custom:events
|
|
319
|
-
* - LSP7 {
|
|
330
|
+
* - LSP7 {OperatorAuthorizationChanged} event.
|
|
320
331
|
* - ERC721 {Approval} event.
|
|
321
332
|
*/
|
|
322
333
|
function authorizeOperator(
|
|
@@ -344,7 +355,7 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
344
355
|
bool isAdded = _operators[tokenId].add(operator);
|
|
345
356
|
if (!isAdded) revert LSP8OperatorAlreadyAuthorized(operator, tokenId);
|
|
346
357
|
|
|
347
|
-
emit
|
|
358
|
+
emit OperatorAuthorizationChanged(
|
|
348
359
|
operator,
|
|
349
360
|
tokenOwner,
|
|
350
361
|
tokenId,
|
package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol
CHANGED
|
@@ -64,19 +64,23 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
64
64
|
* @param name_ The name of the token.
|
|
65
65
|
* @param symbol_ The symbol of the token.
|
|
66
66
|
* @param newOwner_ The owner of the token contract.
|
|
67
|
+
* @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
|
|
68
|
+
* @param lsp8TokenIdSchema_ The schema of tokenIds (= NFTs) that this contract will create.
|
|
67
69
|
*/
|
|
68
70
|
|
|
69
71
|
function _initialize(
|
|
70
72
|
string memory name_,
|
|
71
73
|
string memory symbol_,
|
|
72
74
|
address newOwner_,
|
|
73
|
-
uint256
|
|
75
|
+
uint256 lsp4TokenType_,
|
|
76
|
+
uint256 lsp8TokenIdSchema_
|
|
74
77
|
) internal virtual override onlyInitializing {
|
|
75
78
|
LSP8IdentifiableDigitalAssetInitAbstract._initialize(
|
|
76
79
|
name_,
|
|
77
80
|
symbol_,
|
|
78
81
|
newOwner_,
|
|
79
|
-
|
|
82
|
+
lsp4TokenType_,
|
|
83
|
+
lsp8TokenIdSchema_
|
|
80
84
|
);
|
|
81
85
|
}
|
|
82
86
|
|
|
@@ -325,7 +329,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
325
329
|
* @inheritdoc LSP8IdentifiableDigitalAssetCore
|
|
326
330
|
*
|
|
327
331
|
* @custom:events
|
|
328
|
-
* - LSP7 {
|
|
332
|
+
* - LSP7 {OperatorAuthorizationChanged} event.
|
|
329
333
|
* - ERC721 {Approval} event.
|
|
330
334
|
*/
|
|
331
335
|
function authorizeOperator(
|
|
@@ -353,7 +357,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
353
357
|
bool isAdded = _operators[tokenId].add(operator);
|
|
354
358
|
if (!isAdded) revert LSP8OperatorAlreadyAuthorized(operator, tokenId);
|
|
355
359
|
|
|
356
|
-
emit
|
|
360
|
+
emit OperatorAuthorizationChanged(
|
|
357
361
|
operator,
|
|
358
362
|
tokenOwner,
|
|
359
363
|
tokenId,
|
|
@@ -14,13 +14,24 @@ contract LSP8CompatibleERC721Mintable is LSP8CompatibleERC721 {
|
|
|
14
14
|
* @param name_ The name of the token.
|
|
15
15
|
* @param symbol_ The symbol of the token.
|
|
16
16
|
* @param newOwner_ The owner of the token contract.
|
|
17
|
+
* @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
|
|
18
|
+
* @param lsp8TokenIdSchema_ The schema of tokenIds (= NFTs) that this contract will create.
|
|
17
19
|
*/
|
|
18
20
|
constructor(
|
|
19
21
|
string memory name_,
|
|
20
22
|
string memory symbol_,
|
|
21
23
|
address newOwner_,
|
|
22
|
-
uint256
|
|
23
|
-
|
|
24
|
+
uint256 lsp4TokenType_,
|
|
25
|
+
uint256 lsp8TokenIdSchema_
|
|
26
|
+
)
|
|
27
|
+
LSP8CompatibleERC721(
|
|
28
|
+
name_,
|
|
29
|
+
symbol_,
|
|
30
|
+
newOwner_,
|
|
31
|
+
lsp4TokenType_,
|
|
32
|
+
lsp8TokenIdSchema_
|
|
33
|
+
)
|
|
34
|
+
{}
|
|
24
35
|
|
|
25
36
|
/**
|
|
26
37
|
* @notice Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `force`).
|
|
@@ -26,18 +26,22 @@ contract LSP8CompatibleERC721MintableInit is
|
|
|
26
26
|
* @param name_ The name of the token.
|
|
27
27
|
* @param symbol_ The symbol of the token.
|
|
28
28
|
* @param newOwner_ The owner of the token contract.
|
|
29
|
+
* @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
|
|
30
|
+
* @param lsp8TokenIdSchema_ The schema of tokenIds (= NFTs) that this contract will create.
|
|
29
31
|
*/
|
|
30
32
|
function initialize(
|
|
31
33
|
string memory name_,
|
|
32
34
|
string memory symbol_,
|
|
33
35
|
address newOwner_,
|
|
34
|
-
uint256
|
|
36
|
+
uint256 lsp4TokenType_,
|
|
37
|
+
uint256 lsp8TokenIdSchema_
|
|
35
38
|
) external virtual initializer {
|
|
36
39
|
LSP8CompatibleERC721MintableInitAbstract._initialize(
|
|
37
40
|
name_,
|
|
38
41
|
symbol_,
|
|
39
42
|
newOwner_,
|
|
40
|
-
|
|
43
|
+
lsp4TokenType_,
|
|
44
|
+
lsp8TokenIdSchema_
|
|
41
45
|
);
|
|
42
46
|
}
|
|
43
47
|
}
|
package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol
CHANGED
|
@@ -19,13 +19,15 @@ contract LSP8CompatibleERC721MintableInitAbstract is
|
|
|
19
19
|
string memory name_,
|
|
20
20
|
string memory symbol_,
|
|
21
21
|
address newOwner_,
|
|
22
|
-
uint256
|
|
22
|
+
uint256 lsp4TokenType_,
|
|
23
|
+
uint256 lsp8TokenIdSchema_
|
|
23
24
|
) internal virtual override onlyInitializing {
|
|
24
25
|
LSP8CompatibleERC721InitAbstract._initialize(
|
|
25
26
|
name_,
|
|
26
27
|
symbol_,
|
|
27
28
|
newOwner_,
|
|
28
|
-
|
|
29
|
+
lsp4TokenType_,
|
|
30
|
+
lsp8TokenIdSchema_
|
|
29
31
|
);
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -21,13 +21,24 @@ contract LSP8Mintable is LSP8IdentifiableDigitalAsset, ILSP8Mintable {
|
|
|
21
21
|
* @param name_ The name of the token.
|
|
22
22
|
* @param symbol_ The symbol of the token.
|
|
23
23
|
* @param newOwner_ The owner of the token contract.
|
|
24
|
+
* @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
|
|
25
|
+
* @param lsp8TokenIdSchema_ The schema of tokenIds (= NFTs) that this contract will create.
|
|
24
26
|
*/
|
|
25
27
|
constructor(
|
|
26
28
|
string memory name_,
|
|
27
29
|
string memory symbol_,
|
|
28
30
|
address newOwner_,
|
|
29
|
-
uint256
|
|
30
|
-
|
|
31
|
+
uint256 lsp4TokenType_,
|
|
32
|
+
uint256 lsp8TokenIdSchema_
|
|
33
|
+
)
|
|
34
|
+
LSP8IdentifiableDigitalAsset(
|
|
35
|
+
name_,
|
|
36
|
+
symbol_,
|
|
37
|
+
newOwner_,
|
|
38
|
+
lsp4TokenType_,
|
|
39
|
+
lsp8TokenIdSchema_
|
|
40
|
+
)
|
|
41
|
+
{}
|
|
31
42
|
|
|
32
43
|
/**
|
|
33
44
|
* @notice Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `force`).
|
|
@@ -23,18 +23,22 @@ contract LSP8MintableInit is LSP8MintableInitAbstract {
|
|
|
23
23
|
* @param name_ The name of the token.
|
|
24
24
|
* @param symbol_ The symbol of the token.
|
|
25
25
|
* @param newOwner_ The owner of the token contract.
|
|
26
|
+
* @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
|
|
27
|
+
* @param lsp8TokenIdSchema_ The schema of tokenIds (= NFTs) that this contract will create.
|
|
26
28
|
*/
|
|
27
29
|
function initialize(
|
|
28
30
|
string memory name_,
|
|
29
31
|
string memory symbol_,
|
|
30
32
|
address newOwner_,
|
|
31
|
-
uint256
|
|
33
|
+
uint256 lsp4TokenType_,
|
|
34
|
+
uint256 lsp8TokenIdSchema_
|
|
32
35
|
) external virtual initializer {
|
|
33
36
|
LSP8MintableInitAbstract._initialize(
|
|
34
37
|
name_,
|
|
35
38
|
symbol_,
|
|
36
39
|
newOwner_,
|
|
37
|
-
|
|
40
|
+
lsp4TokenType_,
|
|
41
|
+
lsp8TokenIdSchema_
|
|
38
42
|
);
|
|
39
43
|
}
|
|
40
44
|
}
|