@lukso/lsp-smart-contracts 0.12.0 → 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 +19 -19
- package/artifacts/LSP0ERC725AccountInit.json +19 -19
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +15 -15
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +15 -15
- package/artifacts/LSP4DigitalAssetMetadata.json +5 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +5 -0
- package/artifacts/LSP6KeyManager.json +15 -15
- package/artifacts/LSP6KeyManagerInit.json +15 -15
- package/artifacts/LSP7CappedSupply.json +71 -49
- package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -49
- package/artifacts/LSP7CompatibleERC20.json +71 -49
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -49
- package/artifacts/LSP7CompatibleERC20Mintable.json +78 -51
- package/artifacts/LSP7CompatibleERC20MintableInit.json +78 -51
- package/artifacts/LSP7DigitalAsset.json +71 -49
- package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -49
- package/artifacts/LSP7Mintable.json +78 -51
- package/artifacts/LSP7MintableInit.json +78 -51
- package/artifacts/LSP8CappedSupply.json +187 -36
- package/artifacts/LSP8CappedSupplyInitAbstract.json +200 -49
- package/artifacts/LSP8CompatibleERC721.json +187 -36
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +200 -49
- package/artifacts/LSP8CompatibleERC721Mintable.json +195 -39
- package/artifacts/LSP8CompatibleERC721MintableInit.json +208 -52
- package/artifacts/LSP8IdentifiableDigitalAsset.json +187 -36
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +200 -49
- package/artifacts/LSP8Mintable.json +195 -39
- package/artifacts/LSP8MintableInit.json +208 -52
- package/artifacts/LSP9Vault.json +19 -19
- package/artifacts/LSP9VaultInit.json +19 -19
- package/artifacts/UniversalProfile.json +19 -19
- package/artifacts/UniversalProfileInit.json +19 -19
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +7 -3
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +62 -62
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -1
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +11 -10
- package/contracts/LSP17Extensions/Extension4337.sol +26 -1
- package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +2 -1
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +31 -33
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +24 -17
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +1 -5
- 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/LSP6KeyManager.sol +2 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +16 -10
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +2 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +14 -16
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +6 -2
- 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 +129 -36
- 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 +222 -28
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +28 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +16 -8
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +9 -8
- 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/LSP9Constants.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +3 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +22 -37
- package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +1 -1
- package/contracts/UniversalProfile.sol +4 -2
- package/contracts/UniversalProfileInit.sol +8 -5
- package/contracts/UniversalProfileInitAbstract.sol +4 -2
- package/contracts/Version.sol +6 -5
- package/devdocs/LSP0ERC725Account.json +3 -8
- package/devdocs/LSP0ERC725AccountInit.json +2 -7
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +0 -6
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +0 -6
- package/devdocs/LSP4DigitalAssetMetadata.json +11 -5
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -2
- package/devdocs/LSP6KeyManager.json +2 -7
- package/devdocs/LSP6KeyManagerInit.json +2 -7
- package/devdocs/LSP7CappedSupply.json +22 -8
- package/devdocs/LSP7CappedSupplyInitAbstract.json +22 -8
- package/devdocs/LSP7CompatibleERC20.json +23 -8
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +22 -8
- package/devdocs/LSP7CompatibleERC20Mintable.json +23 -8
- package/devdocs/LSP7CompatibleERC20MintableInit.json +24 -9
- package/devdocs/LSP7DigitalAsset.json +27 -12
- package/devdocs/LSP7DigitalAssetInitAbstract.json +22 -8
- package/devdocs/LSP7Mintable.json +24 -8
- package/devdocs/LSP7MintableInit.json +25 -9
- package/devdocs/LSP8CappedSupply.json +66 -10
- package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -10
- package/devdocs/LSP8CompatibleERC721.json +69 -11
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +67 -11
- package/devdocs/LSP8CompatibleERC721Mintable.json +69 -11
- package/devdocs/LSP8CompatibleERC721MintableInit.json +70 -12
- package/devdocs/LSP8IdentifiableDigitalAsset.json +71 -14
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -10
- package/devdocs/LSP8Mintable.json +68 -10
- package/devdocs/LSP8MintableInit.json +69 -11
- package/devdocs/LSP9Vault.json +0 -6
- package/devdocs/LSP9VaultInit.json +0 -6
- package/devdocs/UniversalProfile.json +3 -8
- package/devdocs/UniversalProfileInit.json +4 -9
- package/dist/constants.cjs.js +4552 -1859
- package/dist/constants.d.ts +4143 -1371
- package/dist/constants.es.js +4551 -1859
- package/package.json +2 -2
- package/userdocs/LSP0ERC725Account.json +3 -3
- package/userdocs/LSP0ERC725AccountInit.json +3 -3
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +3 -3
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +3 -3
- package/userdocs/LSP6KeyManager.json +3 -3
- package/userdocs/LSP6KeyManagerInit.json +3 -3
- package/userdocs/LSP7CappedSupply.json +8 -3
- package/userdocs/LSP7CappedSupplyInitAbstract.json +8 -3
- package/userdocs/LSP7CompatibleERC20.json +8 -3
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +8 -3
- package/userdocs/LSP7CompatibleERC20Mintable.json +8 -3
- package/userdocs/LSP7CompatibleERC20MintableInit.json +9 -4
- package/userdocs/LSP7DigitalAsset.json +8 -3
- package/userdocs/LSP7DigitalAssetInitAbstract.json +8 -3
- package/userdocs/LSP7Mintable.json +8 -3
- package/userdocs/LSP7MintableInit.json +9 -4
- package/userdocs/LSP8CappedSupply.json +20 -3
- package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -3
- package/userdocs/LSP8CompatibleERC721.json +20 -3
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +20 -3
- package/userdocs/LSP8CompatibleERC721Mintable.json +20 -3
- package/userdocs/LSP8CompatibleERC721MintableInit.json +21 -4
- package/userdocs/LSP8IdentifiableDigitalAsset.json +20 -3
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +19 -2
- package/userdocs/LSP8Mintable.json +19 -2
- package/userdocs/LSP8MintableInit.json +20 -3
- package/userdocs/LSP9Vault.json +3 -3
- package/userdocs/LSP9VaultInit.json +3 -3
- package/userdocs/UniversalProfile.json +3 -3
- package/userdocs/UniversalProfileInit.json +3 -3
|
@@ -82,8 +82,24 @@ error LSP8TokenOwnerCannotBeOperator();
|
|
|
82
82
|
error LSP8TokenContractCannotHoldValue();
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* @dev Reverts when trying to edit the data key `
|
|
86
|
-
* The `
|
|
85
|
+
* @dev Reverts when trying to edit the data key `LSP8TokenIdSchema` after the identifiable digital asset contract has been deployed.
|
|
86
|
+
* The `LSP8TokenIdSchema` data key is located inside the ERC725Y Data key-value store of the identifiable digital asset contract.
|
|
87
87
|
* It can be set only once inside the constructor/initializer when the identifiable digital asset contract is being deployed.
|
|
88
88
|
*/
|
|
89
|
-
error
|
|
89
|
+
error LSP8TokenIdSchemaNotEditable();
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @dev Reverts when the length of the token IDs data arrays is not equal
|
|
93
|
+
*/
|
|
94
|
+
error LSP8TokenIdsDataLengthMismatch();
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @dev Reverts when empty arrays is passed to the function
|
|
98
|
+
*/
|
|
99
|
+
error LSP8TokenIdsDataEmptyArray();
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @dev Reverts when a batch call failed.
|
|
103
|
+
* @notice Batch call failed.
|
|
104
|
+
*/
|
|
105
|
+
error LSP8BatchCallFailed(uint256 callIndex);
|
|
@@ -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
|
LSP4DigitalAssetMetadata
|
|
14
14
|
} from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.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 {
|
|
@@ -57,29 +61,30 @@ abstract contract LSP8IdentifiableDigitalAsset is
|
|
|
57
61
|
{
|
|
58
62
|
/**
|
|
59
63
|
* @notice Deploying a LSP8IdentifiableDigitalAsset with name `name_`, symbol `symbol_`, owned by address `newOwner_`
|
|
60
|
-
* with tokenId
|
|
64
|
+
* with tokenId schema `lsp8TokenIdSchema_`.
|
|
61
65
|
*
|
|
62
|
-
* @dev Deploy a `LSP8IdentifiableDigitalAsset` contract and set the tokenId
|
|
66
|
+
* @dev Deploy a `LSP8IdentifiableDigitalAsset` contract and set the tokenId schema inside the ERC725Y storage of the contract.
|
|
63
67
|
* This will also set the token `name_` and `symbol_` under the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol`.
|
|
64
68
|
*
|
|
65
69
|
* @param name_ The name of the token
|
|
66
70
|
* @param symbol_ The symbol of the token
|
|
67
71
|
* @param newOwner_ The owner of the the token-Metadata
|
|
68
|
-
* @param
|
|
69
|
-
*
|
|
72
|
+
* @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
|
|
73
|
+
* @param lsp8TokenIdSchema_ The schema of tokenIds (= NFTs) that this contract will create.
|
|
70
74
|
*
|
|
71
|
-
* @custom:warning Make sure the tokenId
|
|
75
|
+
* @custom:warning Make sure the tokenId schema provided on deployment is correct, as it can only be set once
|
|
72
76
|
* and cannot be changed in the ERC725Y storage after the contract has been deployed.
|
|
73
77
|
*/
|
|
74
78
|
constructor(
|
|
75
79
|
string memory name_,
|
|
76
80
|
string memory symbol_,
|
|
77
81
|
address newOwner_,
|
|
78
|
-
uint256
|
|
79
|
-
|
|
82
|
+
uint256 lsp4TokenType_,
|
|
83
|
+
uint256 lsp8TokenIdSchema_
|
|
84
|
+
) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_, lsp4TokenType_) {
|
|
80
85
|
LSP4DigitalAssetMetadata._setData(
|
|
81
|
-
|
|
82
|
-
abi.encode(
|
|
86
|
+
_LSP8_TOKENID_SCHEMA_KEY,
|
|
87
|
+
abi.encode(lsp8TokenIdSchema_)
|
|
83
88
|
);
|
|
84
89
|
}
|
|
85
90
|
|
|
@@ -215,15 +220,19 @@ abstract contract LSP8IdentifiableDigitalAsset is
|
|
|
215
220
|
|
|
216
221
|
/**
|
|
217
222
|
* @inheritdoc LSP4DigitalAssetMetadata
|
|
218
|
-
* @dev The ERC725Y data key `
|
|
223
|
+
* @dev The ERC725Y data key `_LSP8_TOKENID_SCHEMA_KEY` cannot be changed
|
|
219
224
|
* once the identifiable digital asset contract has been deployed.
|
|
220
225
|
*/
|
|
221
226
|
function _setData(
|
|
222
227
|
bytes32 dataKey,
|
|
223
228
|
bytes memory dataValue
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
|
|
229
|
+
)
|
|
230
|
+
internal
|
|
231
|
+
virtual
|
|
232
|
+
override(LSP4DigitalAssetMetadata, LSP4DigitalAssetMetadataCore)
|
|
233
|
+
{
|
|
234
|
+
if (dataKey == _LSP8_TOKENID_SCHEMA_KEY) {
|
|
235
|
+
revert LSP8TokenIdSchemaNotEditable();
|
|
227
236
|
}
|
|
228
237
|
LSP4DigitalAssetMetadata._setData(dataKey, dataValue);
|
|
229
238
|
}
|
|
@@ -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 {
|
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
} from "./ILSP8IdentifiableDigitalAsset.sol";
|
|
11
11
|
|
|
12
12
|
// modules
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
LSP4DigitalAssetMetadataCore
|
|
16
|
+
} from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol";
|
|
14
17
|
|
|
15
18
|
// libraries
|
|
16
19
|
import {
|
|
@@ -35,7 +38,10 @@ import {
|
|
|
35
38
|
LSP8TokenIdAlreadyMinted,
|
|
36
39
|
LSP8CannotSendToSelf,
|
|
37
40
|
LSP8NotifyTokenReceiverContractMissingLSP1Interface,
|
|
38
|
-
LSP8NotifyTokenReceiverIsEOA
|
|
41
|
+
LSP8NotifyTokenReceiverIsEOA,
|
|
42
|
+
LSP8TokenIdsDataLengthMismatch,
|
|
43
|
+
LSP8TokenIdsDataEmptyArray,
|
|
44
|
+
LSP8BatchCallFailed
|
|
39
45
|
} from "./LSP8Errors.sol";
|
|
40
46
|
|
|
41
47
|
// constants
|
|
@@ -52,13 +58,11 @@ import {
|
|
|
52
58
|
* @dev Core Implementation of a LSP8 compliant contract.
|
|
53
59
|
*/
|
|
54
60
|
abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
LSP4DigitalAssetMetadataCore,
|
|
62
|
+
ILSP8IdentifiableDigitalAsset
|
|
57
63
|
{
|
|
58
64
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
59
65
|
using EnumerableSet for EnumerableSet.Bytes32Set;
|
|
60
|
-
using ERC165Checker for address;
|
|
61
|
-
using LSP1Utils for address;
|
|
62
66
|
|
|
63
67
|
// --- Storage
|
|
64
68
|
|
|
@@ -119,6 +123,118 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
119
123
|
return _ownedTokens[tokenOwner].values();
|
|
120
124
|
}
|
|
121
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
|
+
|
|
122
238
|
// --- Operator functionality
|
|
123
239
|
|
|
124
240
|
/**
|
|
@@ -146,7 +262,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
146
262
|
bool isAdded = _operators[tokenId].add(operator);
|
|
147
263
|
if (!isAdded) revert LSP8OperatorAlreadyAuthorized(operator, tokenId);
|
|
148
264
|
|
|
149
|
-
emit
|
|
265
|
+
emit OperatorAuthorizationChanged(
|
|
150
266
|
operator,
|
|
151
267
|
tokenOwner,
|
|
152
268
|
tokenId,
|
|
@@ -160,10 +276,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
160
276
|
operatorNotificationData
|
|
161
277
|
);
|
|
162
278
|
|
|
163
|
-
operator
|
|
164
|
-
_TYPEID_LSP8_TOKENOPERATOR,
|
|
165
|
-
lsp1Data
|
|
166
|
-
);
|
|
279
|
+
_notifyTokenOperator(operator, lsp1Data);
|
|
167
280
|
}
|
|
168
281
|
|
|
169
282
|
/**
|
|
@@ -205,10 +318,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
205
318
|
operatorNotificationData
|
|
206
319
|
);
|
|
207
320
|
|
|
208
|
-
operator
|
|
209
|
-
_TYPEID_LSP8_TOKENOPERATOR,
|
|
210
|
-
lsp1Data
|
|
211
|
-
);
|
|
321
|
+
_notifyTokenOperator(operator, lsp1Data);
|
|
212
322
|
}
|
|
213
323
|
}
|
|
214
324
|
|
|
@@ -308,7 +418,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
308
418
|
bool isRemoved = _operators[tokenId].remove(operator);
|
|
309
419
|
if (!isRemoved) revert LSP8NonExistingOperator(operator, tokenId);
|
|
310
420
|
|
|
311
|
-
emit
|
|
421
|
+
emit OperatorRevoked(
|
|
312
422
|
operator,
|
|
313
423
|
tokenOwner,
|
|
314
424
|
tokenId,
|
|
@@ -413,7 +523,13 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
413
523
|
|
|
414
524
|
_afterTokenTransfer(address(0), to, tokenId, data);
|
|
415
525
|
|
|
416
|
-
bytes memory lsp1Data = abi.encode(
|
|
526
|
+
bytes memory lsp1Data = abi.encode(
|
|
527
|
+
msg.sender,
|
|
528
|
+
address(0),
|
|
529
|
+
to,
|
|
530
|
+
tokenId,
|
|
531
|
+
data
|
|
532
|
+
);
|
|
417
533
|
_notifyTokenReceiver(to, force, lsp1Data);
|
|
418
534
|
}
|
|
419
535
|
|
|
@@ -461,16 +577,14 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
461
577
|
_afterTokenTransfer(tokenOwner, address(0), tokenId, data);
|
|
462
578
|
|
|
463
579
|
bytes memory lsp1Data = abi.encode(
|
|
580
|
+
msg.sender,
|
|
464
581
|
tokenOwner,
|
|
465
582
|
address(0),
|
|
466
583
|
tokenId,
|
|
467
584
|
data
|
|
468
585
|
);
|
|
469
586
|
|
|
470
|
-
tokenOwner
|
|
471
|
-
_TYPEID_LSP8_TOKENSSENDER,
|
|
472
|
-
lsp1Data
|
|
473
|
-
);
|
|
587
|
+
_notifyTokenSender(tokenOwner, lsp1Data);
|
|
474
588
|
}
|
|
475
589
|
|
|
476
590
|
/**
|
|
@@ -534,12 +648,43 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
534
648
|
|
|
535
649
|
_afterTokenTransfer(from, to, tokenId, data);
|
|
536
650
|
|
|
537
|
-
bytes memory lsp1Data = abi.encode(from, to, tokenId, data);
|
|
651
|
+
bytes memory lsp1Data = abi.encode(msg.sender, from, to, tokenId, data);
|
|
538
652
|
|
|
539
|
-
from
|
|
653
|
+
_notifyTokenSender(from, lsp1Data);
|
|
540
654
|
_notifyTokenReceiver(to, force, lsp1Data);
|
|
541
655
|
}
|
|
542
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
|
+
|
|
543
688
|
/**
|
|
544
689
|
* @dev Hook that is called before any token transfer, including minting and burning.
|
|
545
690
|
* Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function.
|
|
@@ -573,17 +718,66 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
573
718
|
) internal virtual {}
|
|
574
719
|
|
|
575
720
|
/**
|
|
576
|
-
* @dev
|
|
577
|
-
*
|
|
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.
|
|
578
761
|
*
|
|
579
|
-
*
|
|
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.
|
|
580
769
|
*/
|
|
581
770
|
function _notifyTokenReceiver(
|
|
582
771
|
address to,
|
|
583
772
|
bool force,
|
|
584
773
|
bytes memory lsp1Data
|
|
585
774
|
) internal virtual {
|
|
586
|
-
if (
|
|
775
|
+
if (
|
|
776
|
+
ERC165Checker.supportsERC165InterfaceUnchecked(
|
|
777
|
+
to,
|
|
778
|
+
_INTERFACEID_LSP1
|
|
779
|
+
)
|
|
780
|
+
) {
|
|
587
781
|
ILSP1(to).universalReceiver(_TYPEID_LSP8_TOKENSRECIPIENT, lsp1Data);
|
|
588
782
|
} else if (!force) {
|
|
589
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,
|
|
@@ -357,10 +368,7 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
357
368
|
tokenId,
|
|
358
369
|
operatorNotificationData
|
|
359
370
|
);
|
|
360
|
-
operator.
|
|
361
|
-
_TYPEID_LSP8_TOKENOPERATOR,
|
|
362
|
-
lsp1Data
|
|
363
|
-
);
|
|
371
|
+
operator.notifyUniversalReceiver(_TYPEID_LSP8_TOKENOPERATOR, lsp1Data);
|
|
364
372
|
}
|
|
365
373
|
|
|
366
374
|
/**
|