@lukso/lsp-smart-contracts 0.8.2 → 0.10.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 +29 -8
- package/artifacts/LSP0ERC725Account.json +90 -50
- package/artifacts/LSP0ERC725AccountInit.json +90 -50
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP16UniversalFactory.json +31 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +19 -35
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +13 -13
- package/artifacts/LSP4Compatibility.json +39 -40
- package/artifacts/LSP4DigitalAssetMetadata.json +39 -40
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +39 -40
- package/artifacts/LSP6KeyManager.json +107 -8
- package/artifacts/LSP6KeyManagerInit.json +119 -20
- package/artifacts/LSP7CappedSupply.json +78 -38
- package/artifacts/LSP7CappedSupplyInitAbstract.json +78 -38
- package/artifacts/LSP7CompatibleERC20.json +78 -38
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +78 -38
- package/artifacts/LSP7CompatibleERC20Mintable.json +80 -40
- package/artifacts/LSP7CompatibleERC20MintableInit.json +80 -40
- package/artifacts/LSP7DigitalAsset.json +78 -38
- package/artifacts/LSP7DigitalAssetInitAbstract.json +78 -38
- package/artifacts/LSP7Mintable.json +80 -40
- package/artifacts/LSP7MintableInit.json +80 -40
- package/artifacts/LSP8CappedSupply.json +39 -40
- package/artifacts/LSP8CappedSupplyInitAbstract.json +39 -40
- package/artifacts/LSP8CompatibleERC721.json +42 -43
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +42 -43
- package/artifacts/LSP8CompatibleERC721Mintable.json +44 -45
- package/artifacts/LSP8CompatibleERC721MintableInit.json +44 -45
- package/artifacts/LSP8IdentifiableDigitalAsset.json +39 -40
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +39 -40
- package/artifacts/LSP8Mintable.json +41 -42
- package/artifacts/LSP8MintableInit.json +41 -42
- package/artifacts/LSP9Vault.json +73 -55
- package/artifacts/LSP9VaultInit.json +73 -55
- package/artifacts/UniversalProfile.json +90 -50
- package/artifacts/UniversalProfileInit.json +90 -50
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +62 -0
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +36 -6
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +605 -219
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +31 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +37 -3
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +0 -1
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +71 -60
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +5 -7
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +0 -1
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +27 -4
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +41 -84
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +8 -8
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +10 -5
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +0 -4
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +129 -77
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +45 -16
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +12 -0
- package/contracts/LSP20CallVerification/ILSP20CallVerification.sol +30 -0
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +83 -0
- package/contracts/LSP20CallVerification/LSP20Constants.sol +17 -0
- package/contracts/LSP20CallVerification/LSP20Errors.sol +15 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +26 -12
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +0 -1
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +76 -66
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +12 -3
- package/contracts/LSP6KeyManager/LSP6Constants.sol +9 -3
- package/contracts/LSP6KeyManager/LSP6Errors.sol +22 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +172 -29
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +270 -100
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +187 -67
- package/contracts/LSP6KeyManager/LSP6Utils.sol +31 -20
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +79 -30
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +5 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +2 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +24 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +1 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +1 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +3 -5
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +3 -5
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +27 -29
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +1 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +1 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +5 -5
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +6 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +2 -2
- package/contracts/LSP9Vault/ILSP9Vault.sol +27 -0
- package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +11 -8
- package/contracts/LSP9Vault/LSP9VaultCore.sol +96 -71
- package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +19 -7
- package/contracts/UniversalProfileInitAbstract.sol +5 -0
- package/devdocs/Create2Factory.json +16 -0
- package/devdocs/LSP0ERC725Account.json +200 -0
- package/devdocs/LSP0ERC725AccountInit.json +203 -0
- package/devdocs/LSP11BasicSocialRecovery.json +146 -0
- package/devdocs/LSP11BasicSocialRecoveryInit.json +146 -0
- package/devdocs/LSP16UniversalFactory.json +51 -0
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +80 -0
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +62 -0
- package/devdocs/LSP4Compatibility.json +79 -0
- package/devdocs/LSP4DigitalAssetMetadata.json +84 -0
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +77 -0
- package/devdocs/LSP6KeyManager.json +257 -0
- package/devdocs/LSP6KeyManagerInit.json +260 -0
- package/devdocs/LSP7CappedSupply.json +211 -0
- package/devdocs/LSP7CappedSupplyInitAbstract.json +206 -0
- package/devdocs/LSP7CompatibleERC20.json +225 -0
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +218 -0
- package/devdocs/LSP7CompatibleERC20Mintable.json +217 -0
- package/devdocs/LSP7CompatibleERC20MintableInit.json +227 -0
- package/devdocs/LSP7DigitalAsset.json +210 -0
- package/devdocs/LSP7DigitalAssetInitAbstract.json +202 -0
- package/devdocs/LSP7Mintable.json +219 -0
- package/devdocs/LSP7MintableInit.json +220 -0
- package/devdocs/LSP8CappedSupply.json +232 -0
- package/devdocs/LSP8CappedSupplyInitAbstract.json +227 -0
- package/devdocs/LSP8CompatibleERC721.json +298 -0
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +291 -0
- package/devdocs/LSP8CompatibleERC721Mintable.json +290 -0
- package/devdocs/LSP8CompatibleERC721MintableInit.json +300 -0
- package/devdocs/LSP8IdentifiableDigitalAsset.json +230 -0
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +223 -0
- package/devdocs/LSP8Mintable.json +242 -0
- package/devdocs/LSP8MintableInit.json +245 -0
- package/devdocs/LSP9Vault.json +171 -0
- package/devdocs/LSP9VaultInit.json +175 -0
- package/devdocs/UniversalProfile.json +199 -0
- package/devdocs/UniversalProfileInit.json +202 -0
- package/devdocs/UniversalReceiverAddressStore.json +9 -0
- package/dist/constants.cjs.js +31569 -0
- package/dist/constants.d.ts +31681 -0
- package/dist/constants.es.js +31550 -0
- package/package.json +70 -52
- package/userdocs/Create2Factory.json +5 -0
- package/userdocs/LSP0ERC725Account.json +47 -0
- package/userdocs/LSP0ERC725AccountInit.json +47 -0
- package/userdocs/LSP11BasicSocialRecovery.json +29 -0
- package/userdocs/LSP11BasicSocialRecoveryInit.json +29 -0
- package/userdocs/LSP16UniversalFactory.json +5 -0
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +10 -0
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +10 -0
- package/userdocs/LSP4Compatibility.json +20 -0
- package/userdocs/LSP4DigitalAssetMetadata.json +23 -0
- package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +20 -0
- package/userdocs/LSP6KeyManager.json +18 -0
- package/userdocs/LSP6KeyManagerInit.json +18 -0
- package/userdocs/LSP7CappedSupply.json +29 -0
- package/userdocs/LSP7CappedSupplyInitAbstract.json +26 -0
- package/userdocs/LSP7CompatibleERC20.json +35 -0
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +32 -0
- package/userdocs/LSP7CompatibleERC20Mintable.json +32 -0
- package/userdocs/LSP7CompatibleERC20MintableInit.json +35 -0
- package/userdocs/LSP7DigitalAsset.json +29 -0
- package/userdocs/LSP7DigitalAssetInitAbstract.json +26 -0
- package/userdocs/LSP7Mintable.json +29 -0
- package/userdocs/LSP7MintableInit.json +29 -0
- package/userdocs/LSP8CappedSupply.json +23 -0
- package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -0
- package/userdocs/LSP8CompatibleERC721.json +29 -0
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +26 -0
- package/userdocs/LSP8CompatibleERC721Mintable.json +26 -0
- package/userdocs/LSP8CompatibleERC721MintableInit.json +29 -0
- package/userdocs/LSP8IdentifiableDigitalAsset.json +23 -0
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +20 -0
- package/userdocs/LSP8Mintable.json +23 -0
- package/userdocs/LSP8MintableInit.json +23 -0
- package/userdocs/LSP9Vault.json +38 -0
- package/userdocs/LSP9VaultInit.json +38 -0
- package/userdocs/UniversalProfile.json +50 -0
- package/userdocs/UniversalProfileInit.json +50 -0
- package/userdocs/UniversalReceiverAddressStore.json +5 -0
- package/CONTRIBUTING.md +0 -57
- package/common/constants.d.ts +0 -738
- package/common/constants.js +0 -785
- package/contracts/Utils/GasLib.sol +0 -17
- package/module/constants.d.ts +0 -738
- package/module/constants.js +0 -782
|
@@ -7,12 +7,6 @@ import {ILSP7DigitalAsset} from "./ILSP7DigitalAsset.sol";
|
|
|
7
7
|
|
|
8
8
|
// libraries
|
|
9
9
|
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
10
|
-
import {GasLib} from "../Utils/GasLib.sol";
|
|
11
|
-
|
|
12
|
-
// modules
|
|
13
|
-
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
14
|
-
|
|
15
|
-
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
16
10
|
|
|
17
11
|
// errors
|
|
18
12
|
import "./LSP7Errors.sol";
|
|
@@ -27,19 +21,22 @@ import {_TYPEID_LSP7_TOKENSSENDER, _TYPEID_LSP7_TOKENSRECIPIENT} from "./LSP7Con
|
|
|
27
21
|
* @dev Core Implementation of a LSP7 compliant contract.
|
|
28
22
|
*
|
|
29
23
|
* This contract implement the core logic of the functions for the {ILSP7DigitalAsset} interface.
|
|
24
|
+
*
|
|
25
|
+
* Similar to ERC20, the non-standard {decreaseAllowance} and {increaseAllowance}
|
|
26
|
+
* functions have been added to mitigate the well-known issues around setting allowances.
|
|
30
27
|
*/
|
|
31
28
|
abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
32
29
|
// --- Storage
|
|
33
30
|
|
|
34
|
-
bool internal _isNonDivisible;
|
|
35
|
-
|
|
36
|
-
uint256 internal _existingTokens;
|
|
37
|
-
|
|
38
31
|
// Mapping from `tokenOwner` to an `amount` of tokens
|
|
39
|
-
mapping(address => uint256)
|
|
32
|
+
mapping(address => uint256) private _tokenOwnerBalances;
|
|
40
33
|
|
|
41
34
|
// Mapping a `tokenOwner` to an `operator` to `amount` of tokens.
|
|
42
|
-
mapping(address => mapping(address => uint256))
|
|
35
|
+
mapping(address => mapping(address => uint256)) private _operatorAuthorizedAmount;
|
|
36
|
+
|
|
37
|
+
uint256 private _existingTokens;
|
|
38
|
+
|
|
39
|
+
bool internal _isNonDivisible;
|
|
43
40
|
|
|
44
41
|
// --- Token queries
|
|
45
42
|
|
|
@@ -155,9 +152,66 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
155
152
|
revert LSP7InvalidTransferBatch();
|
|
156
153
|
}
|
|
157
154
|
|
|
158
|
-
for (uint256 i = 0; i < fromLength;
|
|
155
|
+
for (uint256 i = 0; i < fromLength; ) {
|
|
159
156
|
// using the public transfer function to handle updates to operator authorized amounts
|
|
160
157
|
transfer(from[i], to[i], amount[i], allowNonLSP1Recipient[i], data[i]);
|
|
158
|
+
|
|
159
|
+
unchecked {
|
|
160
|
+
++i;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @notice Increase the allowance of `operator` by +`addedAmount`
|
|
167
|
+
* @dev Atomically increases the allowance granted to `operator` by the caller.
|
|
168
|
+
*
|
|
169
|
+
* This is an alternative approach to {authorizeOperator} that can be used as a mitigation
|
|
170
|
+
* for problems described in {ILSP7DigitalAsset}.
|
|
171
|
+
*
|
|
172
|
+
* Emits an {AuthorizedOperator} event indicating the updated allowance.
|
|
173
|
+
*
|
|
174
|
+
* @param operator the operator to increase the allowance for `msg.sender`
|
|
175
|
+
* @param addedAmount the additional amount to add on top of the current operator's allowance
|
|
176
|
+
*
|
|
177
|
+
* @dev Requirements:
|
|
178
|
+
* - `operator` cannot be the same address as `msg.sender`
|
|
179
|
+
* - `operator` cannot be the zero address.
|
|
180
|
+
*/
|
|
181
|
+
function increaseAllowance(address operator, uint256 addedAmount) public virtual {
|
|
182
|
+
_updateOperator(
|
|
183
|
+
msg.sender,
|
|
184
|
+
operator,
|
|
185
|
+
authorizedAmountFor(operator, msg.sender) + addedAmount
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @notice Decrease the allowance of `operator` by -`substractedAmount`
|
|
191
|
+
* @dev Atomically decreases the allowance granted to `operator` by the caller.
|
|
192
|
+
* This is an alternative approach to {authorizeOperator} that can be used as a mitigation
|
|
193
|
+
* for problems described in {ILSP7DigitalAsset}
|
|
194
|
+
*
|
|
195
|
+
* Emits:
|
|
196
|
+
* - an {AuthorizedOperator} event indicating the updated allowance after decreasing it.
|
|
197
|
+
* - a {RevokeOperator} event if `substractedAmount` is the full allowance,
|
|
198
|
+
* indicating `operator` does not have any allowance left for `msg.sender`.
|
|
199
|
+
*
|
|
200
|
+
* @param operator the operator to decrease allowance for `msg.sender`
|
|
201
|
+
* @param substractedAmount the amount to decrease by in the operator's allowance.
|
|
202
|
+
*
|
|
203
|
+
* @dev Requirements:
|
|
204
|
+
* - `operator` cannot be the zero address.
|
|
205
|
+
* - operator` must have allowance for the caller of at least `substractedAmount`.
|
|
206
|
+
*/
|
|
207
|
+
function decreaseAllowance(address operator, uint256 substractedAmount) public virtual {
|
|
208
|
+
uint256 currentAllowance = authorizedAmountFor(operator, msg.sender);
|
|
209
|
+
if (currentAllowance < substractedAmount) {
|
|
210
|
+
revert LSP7DecreasedAllowanceBelowZero();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
unchecked {
|
|
214
|
+
_updateOperator(msg.sender, operator, currentAllowance - substractedAmount);
|
|
161
215
|
}
|
|
162
216
|
}
|
|
163
217
|
|
|
@@ -226,7 +280,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
226
280
|
|
|
227
281
|
emit Transfer(operator, address(0), to, amount, allowNonLSP1Recipient, data);
|
|
228
282
|
|
|
229
|
-
|
|
283
|
+
bytes memory lsp1Data = abi.encodePacked(address(0), to, amount, data);
|
|
284
|
+
_notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
|
|
230
285
|
}
|
|
231
286
|
|
|
232
287
|
/**
|
|
@@ -273,7 +328,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
273
328
|
|
|
274
329
|
emit Transfer(operator, from, address(0), amount, false, data);
|
|
275
330
|
|
|
276
|
-
|
|
331
|
+
bytes memory lsp1Data = abi.encodePacked(from, address(0), amount, data);
|
|
332
|
+
_notifyTokenSender(from, lsp1Data);
|
|
277
333
|
}
|
|
278
334
|
|
|
279
335
|
/**
|
|
@@ -314,8 +370,10 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
314
370
|
|
|
315
371
|
emit Transfer(operator, from, to, amount, allowNonLSP1Recipient, data);
|
|
316
372
|
|
|
317
|
-
|
|
318
|
-
|
|
373
|
+
bytes memory lsp1Data = abi.encodePacked(from, to, amount, data);
|
|
374
|
+
|
|
375
|
+
_notifyTokenSender(from, lsp1Data);
|
|
376
|
+
_notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
|
|
319
377
|
}
|
|
320
378
|
|
|
321
379
|
/**
|
|
@@ -340,15 +398,9 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
340
398
|
* @dev An attempt is made to notify the token sender about the `amount` tokens changing owners using
|
|
341
399
|
* LSP1 interface.
|
|
342
400
|
*/
|
|
343
|
-
function _notifyTokenSender(
|
|
344
|
-
address from,
|
|
345
|
-
address to,
|
|
346
|
-
uint256 amount,
|
|
347
|
-
bytes memory data
|
|
348
|
-
) internal virtual {
|
|
401
|
+
function _notifyTokenSender(address from, bytes memory lsp1Data) internal virtual {
|
|
349
402
|
if (ERC165Checker.supportsERC165InterfaceUnchecked(from, _INTERFACEID_LSP1)) {
|
|
350
|
-
|
|
351
|
-
ILSP1UniversalReceiver(from).universalReceiver(_TYPEID_LSP7_TOKENSSENDER, packedData);
|
|
403
|
+
ILSP1UniversalReceiver(from).universalReceiver(_TYPEID_LSP7_TOKENSSENDER, lsp1Data);
|
|
352
404
|
}
|
|
353
405
|
}
|
|
354
406
|
|
|
@@ -359,15 +411,12 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
359
411
|
* The receiver may revert when the token being sent is not wanted.
|
|
360
412
|
*/
|
|
361
413
|
function _notifyTokenReceiver(
|
|
362
|
-
address from,
|
|
363
414
|
address to,
|
|
364
|
-
uint256 amount,
|
|
365
415
|
bool allowNonLSP1Recipient,
|
|
366
|
-
bytes memory
|
|
416
|
+
bytes memory lsp1Data
|
|
367
417
|
) internal virtual {
|
|
368
418
|
if (ERC165Checker.supportsERC165InterfaceUnchecked(to, _INTERFACEID_LSP1)) {
|
|
369
|
-
|
|
370
|
-
ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP7_TOKENSRECIPIENT, packedData);
|
|
419
|
+
ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP7_TOKENSRECIPIENT, lsp1Data);
|
|
371
420
|
} else if (!allowNonLSP1Recipient) {
|
|
372
421
|
if (to.code.length > 0) {
|
|
373
422
|
revert LSP7NotifyTokenReceiverContractMissingLSP1Interface(to);
|
|
@@ -55,3 +55,8 @@ error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
|
|
|
55
55
|
* @dev reverts when trying to authorize or revoke the token's owner as an operator.
|
|
56
56
|
*/
|
|
57
57
|
error LSP7TokenOwnerCannotBeOperator();
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @dev Reverts when trying to decrease an operator's allowance to more than his current allowance
|
|
61
|
+
*/
|
|
62
|
+
error LSP7DecreasedAllowanceBelowZero();
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {
|
|
5
|
+
import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @dev LSP7 extension that allows token holders to destroy both
|
|
9
9
|
* their own tokens and those that they have an allowance for as an operator.
|
|
10
10
|
*/
|
|
11
|
-
abstract contract LSP7Burnable is
|
|
11
|
+
abstract contract LSP7Burnable is LSP7DigitalAsset {
|
|
12
12
|
/**
|
|
13
13
|
* @dev Destroys `amount` tokens from the `from` address.
|
|
14
14
|
*
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
// modules
|
|
5
|
+
import {LSP7DigitalAssetInitAbstract} from "../LSP7DigitalAssetInitAbstract.sol";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @dev LSP7 extension that allows token holders to destroy both
|
|
9
|
+
* their own tokens and those that they have an allowance for as an operator.
|
|
10
|
+
*/
|
|
11
|
+
abstract contract LSP7BurnableInitAbstract is LSP7DigitalAssetInitAbstract {
|
|
12
|
+
/**
|
|
13
|
+
* @dev Destroys `amount` tokens from the `from` address.
|
|
14
|
+
*
|
|
15
|
+
* See internal _burn function for more details
|
|
16
|
+
*/
|
|
17
|
+
function burn(
|
|
18
|
+
address from,
|
|
19
|
+
uint256 amount,
|
|
20
|
+
bytes memory data
|
|
21
|
+
) public {
|
|
22
|
+
_burn(from, amount, data);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -4,7 +4,6 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
|
|
5
5
|
// modules
|
|
6
6
|
import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
|
|
7
|
-
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @dev LSP7 extension, adds token supply cap.
|
|
@@ -15,7 +14,7 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset {
|
|
|
15
14
|
error LSP7CappedSupplyCannotMintOverCap();
|
|
16
15
|
|
|
17
16
|
// --- Storage
|
|
18
|
-
uint256
|
|
17
|
+
uint256 private immutable _tokenSupplyCap;
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* @notice Sets the token max supply
|
|
@@ -4,7 +4,6 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
|
|
5
5
|
// modules
|
|
6
6
|
import {LSP7DigitalAssetInitAbstract} from "../LSP7DigitalAssetInitAbstract.sol";
|
|
7
|
-
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @dev LSP7 extension, adds token supply cap.
|
|
@@ -15,7 +14,7 @@ abstract contract LSP7CappedSupplyInitAbstract is LSP7DigitalAssetInitAbstract {
|
|
|
15
14
|
error LSP7CappedSupplyCannotMintOverCap();
|
|
16
15
|
|
|
17
16
|
// --- Storage
|
|
18
|
-
uint256
|
|
17
|
+
uint256 private _tokenSupplyCap;
|
|
19
18
|
|
|
20
19
|
function _initialize(uint256 tokenSupplyCap_) internal virtual onlyInitializing {
|
|
21
20
|
if (tokenSupplyCap_ == 0) {
|
|
@@ -4,12 +4,10 @@ pragma solidity ^0.8.12;
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
6
|
import {ILSP7CompatibleERC20} from "./ILSP7CompatibleERC20.sol";
|
|
7
|
-
import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
|
|
8
7
|
|
|
9
8
|
// modules
|
|
10
9
|
import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
|
|
11
10
|
import {LSP7DigitalAsset, LSP4DigitalAssetMetadata, ERC725YCore} from "../LSP7DigitalAsset.sol";
|
|
12
|
-
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
|
|
@@ -101,8 +99,8 @@ abstract contract LSP7CompatibleERC20 is ILSP7CompatibleERC20, LSP4Compatibility
|
|
|
101
99
|
bool allowNonLSP1Recipient,
|
|
102
100
|
bytes memory data
|
|
103
101
|
) internal virtual override {
|
|
104
|
-
super._transfer(from, to, amount, allowNonLSP1Recipient, data);
|
|
105
102
|
emit Transfer(from, to, amount);
|
|
103
|
+
super._transfer(from, to, amount, allowNonLSP1Recipient, data);
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
function _mint(
|
|
@@ -111,8 +109,8 @@ abstract contract LSP7CompatibleERC20 is ILSP7CompatibleERC20, LSP4Compatibility
|
|
|
111
109
|
bool allowNonLSP1Recipient,
|
|
112
110
|
bytes memory data
|
|
113
111
|
) internal virtual override {
|
|
114
|
-
super._mint(to, amount, allowNonLSP1Recipient, data);
|
|
115
112
|
emit Transfer(address(0), to, amount);
|
|
113
|
+
super._mint(to, amount, allowNonLSP1Recipient, data);
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
function _burn(
|
|
@@ -120,8 +118,8 @@ abstract contract LSP7CompatibleERC20 is ILSP7CompatibleERC20, LSP4Compatibility
|
|
|
120
118
|
uint256 amount,
|
|
121
119
|
bytes memory data
|
|
122
120
|
) internal virtual override {
|
|
123
|
-
super._burn(from, amount, data);
|
|
124
121
|
emit Transfer(from, address(0), amount);
|
|
122
|
+
super._burn(from, amount, data);
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
function _setData(bytes32 key, bytes memory value)
|
|
@@ -4,7 +4,6 @@ pragma solidity ^0.8.12;
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
6
|
import {ILSP7CompatibleERC20} from "./ILSP7CompatibleERC20.sol";
|
|
7
|
-
import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
|
|
8
7
|
|
|
9
8
|
// modules
|
|
10
9
|
import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
|
|
@@ -13,7 +12,6 @@ import {
|
|
|
13
12
|
LSP4DigitalAssetMetadataInitAbstract,
|
|
14
13
|
ERC725YCore
|
|
15
14
|
} from "../LSP7DigitalAssetInitAbstract.sol";
|
|
16
|
-
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
|
|
@@ -112,8 +110,8 @@ abstract contract LSP7CompatibleERC20InitAbstract is
|
|
|
112
110
|
bool allowNonLSP1Recipient,
|
|
113
111
|
bytes memory data
|
|
114
112
|
) internal virtual override {
|
|
115
|
-
super._transfer(from, to, amount, allowNonLSP1Recipient, data);
|
|
116
113
|
emit Transfer(from, to, amount);
|
|
114
|
+
super._transfer(from, to, amount, allowNonLSP1Recipient, data);
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
function _mint(
|
|
@@ -122,8 +120,8 @@ abstract contract LSP7CompatibleERC20InitAbstract is
|
|
|
122
120
|
bool allowNonLSP1Recipient,
|
|
123
121
|
bytes memory data
|
|
124
122
|
) internal virtual override {
|
|
125
|
-
super._mint(to, amount, allowNonLSP1Recipient, data);
|
|
126
123
|
emit Transfer(address(0), to, amount);
|
|
124
|
+
super._mint(to, amount, allowNonLSP1Recipient, data);
|
|
127
125
|
}
|
|
128
126
|
|
|
129
127
|
function _burn(
|
|
@@ -131,8 +129,8 @@ abstract contract LSP7CompatibleERC20InitAbstract is
|
|
|
131
129
|
uint256 amount,
|
|
132
130
|
bytes memory data
|
|
133
131
|
) internal virtual override {
|
|
134
|
-
super._burn(from, amount, data);
|
|
135
132
|
emit Transfer(from, address(0), amount);
|
|
133
|
+
super._burn(from, amount, data);
|
|
136
134
|
}
|
|
137
135
|
|
|
138
136
|
function _setData(bytes32 key, bytes memory value)
|
|
@@ -8,11 +8,6 @@ import {ILSP8IdentifiableDigitalAsset} from "./ILSP8IdentifiableDigitalAsset.sol
|
|
|
8
8
|
// libraries
|
|
9
9
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
10
10
|
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
11
|
-
import {GasLib} from "../Utils/GasLib.sol";
|
|
12
|
-
|
|
13
|
-
// modules
|
|
14
|
-
|
|
15
|
-
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
16
11
|
|
|
17
12
|
// errors
|
|
18
13
|
import "./LSP8Errors.sol";
|
|
@@ -32,18 +27,18 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
32
27
|
|
|
33
28
|
// --- Storage
|
|
34
29
|
|
|
35
|
-
uint256
|
|
30
|
+
uint256 private _existingTokens;
|
|
36
31
|
|
|
37
32
|
// Mapping from `tokenId` to `tokenOwner`
|
|
38
|
-
mapping(bytes32 => address)
|
|
33
|
+
mapping(bytes32 => address) private _tokenOwners;
|
|
39
34
|
|
|
40
35
|
// Mapping `tokenOwner` to owned tokenIds
|
|
41
|
-
mapping(address => EnumerableSet.Bytes32Set)
|
|
36
|
+
mapping(address => EnumerableSet.Bytes32Set) private _ownedTokens;
|
|
42
37
|
|
|
43
38
|
// Mapping a `tokenId` to its authorized operator addresses.
|
|
44
|
-
mapping(bytes32 => EnumerableSet.AddressSet)
|
|
39
|
+
mapping(bytes32 => EnumerableSet.AddressSet) private _operators;
|
|
45
40
|
|
|
46
|
-
mapping(address => EnumerableSet.Bytes32Set)
|
|
41
|
+
mapping(address => EnumerableSet.Bytes32Set) private _tokenIdsForOperator;
|
|
47
42
|
|
|
48
43
|
// --- Token queries
|
|
49
44
|
|
|
@@ -204,8 +199,12 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
204
199
|
revert LSP8InvalidTransferBatch();
|
|
205
200
|
}
|
|
206
201
|
|
|
207
|
-
for (uint256 i = 0; i < fromLength;
|
|
202
|
+
for (uint256 i = 0; i < fromLength; ) {
|
|
208
203
|
transfer(from[i], to[i], tokenId[i], allowNonLSP1Recipient[i], data[i]);
|
|
204
|
+
|
|
205
|
+
unchecked {
|
|
206
|
+
++i;
|
|
207
|
+
}
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
|
|
@@ -235,10 +234,14 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
235
234
|
EnumerableSet.AddressSet storage operatorsForTokenId = _operators[tokenId];
|
|
236
235
|
|
|
237
236
|
uint256 operatorListLength = operatorsForTokenId.length();
|
|
238
|
-
for (uint256 i = 0; i < operatorListLength;
|
|
237
|
+
for (uint256 i = 0; i < operatorListLength; ) {
|
|
239
238
|
// we are emptying the list, always remove from index 0
|
|
240
239
|
address operator = operatorsForTokenId.at(0);
|
|
241
240
|
_revokeOperator(operator, tokenOwner, tokenId);
|
|
241
|
+
|
|
242
|
+
unchecked {
|
|
243
|
+
++i;
|
|
244
|
+
}
|
|
242
245
|
}
|
|
243
246
|
}
|
|
244
247
|
|
|
@@ -297,7 +300,8 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
297
300
|
|
|
298
301
|
emit Transfer(operator, address(0), to, tokenId, allowNonLSP1Recipient, data);
|
|
299
302
|
|
|
300
|
-
|
|
303
|
+
bytes memory lsp1Data = abi.encodePacked(address(0), to, tokenId, data);
|
|
304
|
+
_notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
|
|
301
305
|
}
|
|
302
306
|
|
|
303
307
|
/**
|
|
@@ -325,7 +329,8 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
325
329
|
|
|
326
330
|
emit Transfer(operator, tokenOwner, address(0), tokenId, false, data);
|
|
327
331
|
|
|
328
|
-
|
|
332
|
+
bytes memory lsp1Data = abi.encodePacked(tokenOwner, address(0), tokenId, data);
|
|
333
|
+
_notifyTokenSender(tokenOwner, lsp1Data);
|
|
329
334
|
}
|
|
330
335
|
|
|
331
336
|
/**
|
|
@@ -370,8 +375,10 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
370
375
|
|
|
371
376
|
emit Transfer(operator, from, to, tokenId, allowNonLSP1Recipient, data);
|
|
372
377
|
|
|
373
|
-
|
|
374
|
-
|
|
378
|
+
bytes memory lsp1Data = abi.encodePacked(from, to, tokenId, data);
|
|
379
|
+
|
|
380
|
+
_notifyTokenSender(from, lsp1Data);
|
|
381
|
+
_notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
|
|
375
382
|
}
|
|
376
383
|
|
|
377
384
|
/**
|
|
@@ -396,15 +403,9 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
396
403
|
* @dev An attempt is made to notify the token sender about the `tokenId` changing owners using
|
|
397
404
|
* LSP1 interface.
|
|
398
405
|
*/
|
|
399
|
-
function _notifyTokenSender(
|
|
400
|
-
address from,
|
|
401
|
-
address to,
|
|
402
|
-
bytes32 tokenId,
|
|
403
|
-
bytes memory data
|
|
404
|
-
) internal virtual {
|
|
406
|
+
function _notifyTokenSender(address from, bytes memory lsp1Data) internal virtual {
|
|
405
407
|
if (ERC165Checker.supportsERC165InterfaceUnchecked(from, _INTERFACEID_LSP1)) {
|
|
406
|
-
|
|
407
|
-
ILSP1UniversalReceiver(from).universalReceiver(_TYPEID_LSP8_TOKENSSENDER, packedData);
|
|
408
|
+
ILSP1UniversalReceiver(from).universalReceiver(_TYPEID_LSP8_TOKENSSENDER, lsp1Data);
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
411
|
|
|
@@ -415,15 +416,12 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
415
416
|
* The receiver may revert when the token being sent is not wanted.
|
|
416
417
|
*/
|
|
417
418
|
function _notifyTokenReceiver(
|
|
418
|
-
address from,
|
|
419
419
|
address to,
|
|
420
|
-
bytes32 tokenId,
|
|
421
420
|
bool allowNonLSP1Recipient,
|
|
422
|
-
bytes memory
|
|
421
|
+
bytes memory lsp1Data
|
|
423
422
|
) internal virtual {
|
|
424
423
|
if (ERC165Checker.supportsERC165InterfaceUnchecked(to, _INTERFACEID_LSP1)) {
|
|
425
|
-
|
|
426
|
-
ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP8_TOKENSRECIPIENT, packedData);
|
|
424
|
+
ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP8_TOKENSRECIPIENT, lsp1Data);
|
|
427
425
|
} else if (!allowNonLSP1Recipient) {
|
|
428
426
|
if (to.code.length > 0) {
|
|
429
427
|
revert LSP8NotifyTokenReceiverContractMissingLSP1Interface(to);
|
|
@@ -34,7 +34,7 @@ interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
|
|
|
34
34
|
* @dev This emits when an operator is enabled or disabled for an owner.
|
|
35
35
|
* The operator can manage all NFTs of the owner.
|
|
36
36
|
*/
|
|
37
|
-
event ApprovalForAll(address indexed
|
|
37
|
+
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* @dev Compatible with ERC721 transferFrom.
|
|
@@ -4,7 +4,6 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
|
|
5
5
|
// modules
|
|
6
6
|
import {LSP8IdentifiableDigitalAsset} from "../LSP8IdentifiableDigitalAsset.sol";
|
|
7
|
-
import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @dev LSP8 extension, adds token supply cap.
|
|
@@ -15,7 +14,7 @@ abstract contract LSP8CappedSupply is LSP8IdentifiableDigitalAsset {
|
|
|
15
14
|
error LSP8CappedSupplyCannotMintOverCap();
|
|
16
15
|
|
|
17
16
|
// --- Storage
|
|
18
|
-
uint256
|
|
17
|
+
uint256 private immutable _tokenSupplyCap;
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* @notice Sets the token max supply
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
pragma solidity ^0.8.4;
|
|
4
4
|
|
|
5
5
|
// modules
|
|
6
|
-
import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
|
|
7
6
|
import {
|
|
8
7
|
LSP8IdentifiableDigitalAssetInitAbstract
|
|
9
8
|
} from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
|
|
@@ -17,7 +16,7 @@ abstract contract LSP8CappedSupplyInitAbstract is LSP8IdentifiableDigitalAssetIn
|
|
|
17
16
|
error LSP8CappedSupplyCannotMintOverCap();
|
|
18
17
|
|
|
19
18
|
// --- Storage
|
|
20
|
-
uint256
|
|
19
|
+
uint256 private _tokenSupplyCap;
|
|
21
20
|
|
|
22
21
|
function _initialize(uint256 tokenSupplyCap_) internal virtual onlyInitializing {
|
|
23
22
|
if (tokenSupplyCap_ == 0) {
|
|
@@ -100,8 +100,8 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
100
100
|
bytes32 tokenIdAsBytes32 = bytes32(tokenId);
|
|
101
101
|
_existsOrError(tokenIdAsBytes32);
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
uint256 operatorListLength = operatorsForTokenId.length
|
|
103
|
+
address[] memory operatorsForTokenId = getOperatorsOf(tokenIdAsBytes32);
|
|
104
|
+
uint256 operatorListLength = operatorsForTokenId.length;
|
|
105
105
|
|
|
106
106
|
if (operatorListLength == 0) {
|
|
107
107
|
return address(0);
|
|
@@ -112,7 +112,7 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
112
112
|
// compatibility version the same is true, when the authorized operators were not previously
|
|
113
113
|
// authorized. If addresses are removed, then `getApproved` returned address can change due
|
|
114
114
|
// to implementation of `EnumberableSet._remove`.
|
|
115
|
-
return operatorsForTokenId
|
|
115
|
+
return operatorsForTokenId[operatorListLength - 1];
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -232,15 +232,15 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
232
232
|
bool allowNonLSP1Recipient,
|
|
233
233
|
bytes memory data
|
|
234
234
|
) internal virtual override {
|
|
235
|
-
super._mint(to, tokenId, allowNonLSP1Recipient, data);
|
|
236
235
|
emit Transfer(address(0), to, uint256(tokenId));
|
|
236
|
+
super._mint(to, tokenId, allowNonLSP1Recipient, data);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
function _burn(bytes32 tokenId, bytes memory data) internal virtual override {
|
|
240
240
|
address tokenOwner = tokenOwnerOf(tokenId);
|
|
241
241
|
|
|
242
|
-
super._burn(tokenId, data);
|
|
243
242
|
emit Transfer(tokenOwner, address(0), uint256(tokenId));
|
|
243
|
+
super._burn(tokenId, data);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/**
|
package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol
CHANGED
|
@@ -96,8 +96,8 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
96
96
|
bytes32 tokenIdAsBytes32 = bytes32(tokenId);
|
|
97
97
|
_existsOrError(tokenIdAsBytes32);
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
uint256 operatorListLength = operatorsForTokenId.length
|
|
99
|
+
address[] memory operatorsForTokenId = getOperatorsOf(tokenIdAsBytes32);
|
|
100
|
+
uint256 operatorListLength = operatorsForTokenId.length;
|
|
101
101
|
|
|
102
102
|
if (operatorListLength == 0) {
|
|
103
103
|
return address(0);
|
|
@@ -108,7 +108,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
108
108
|
// compatibility version the same is true, when the authorized operators were not previously
|
|
109
109
|
// authorized. If addresses are removed, then `getApproved` returned address can change due
|
|
110
110
|
// to implementation of `EnumberableSet._remove`.
|
|
111
|
-
return operatorsForTokenId
|
|
111
|
+
return operatorsForTokenId[operatorListLength - 1];
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -205,8 +205,8 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
205
205
|
revert LSP8NotTokenOperator(tokenId, operator);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
super._transfer(from, to, tokenId, allowNonLSP1Recipient, data);
|
|
209
208
|
emit Transfer(from, to, uint256(tokenId));
|
|
209
|
+
super._transfer(from, to, tokenId, allowNonLSP1Recipient, data);
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
function _safeTransfer(
|
|
@@ -228,15 +228,15 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
228
228
|
bool allowNonLSP1Recipient,
|
|
229
229
|
bytes memory data
|
|
230
230
|
) internal virtual override {
|
|
231
|
-
super._mint(to, tokenId, allowNonLSP1Recipient, data);
|
|
232
231
|
emit Transfer(address(0), to, uint256(tokenId));
|
|
232
|
+
super._mint(to, tokenId, allowNonLSP1Recipient, data);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
function _burn(bytes32 tokenId, bytes memory data) internal virtual override {
|
|
236
236
|
address tokenOwner = tokenOwnerOf(tokenId);
|
|
237
237
|
|
|
238
|
-
super._burn(tokenId, data);
|
|
239
238
|
emit Transfer(tokenOwner, address(0), uint256(tokenId));
|
|
239
|
+
super._burn(tokenId, data);
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
/**
|
|
@@ -30,11 +30,11 @@ abstract contract LSP8Enumerable is LSP8IdentifiableDigitalAsset {
|
|
|
30
30
|
bytes32 tokenId
|
|
31
31
|
) internal virtual override(LSP8IdentifiableDigitalAssetCore) {
|
|
32
32
|
if (from == address(0)) {
|
|
33
|
-
uint256 index =
|
|
33
|
+
uint256 index = totalSupply();
|
|
34
34
|
_indexToken[index] = tokenId;
|
|
35
35
|
_tokenIndex[tokenId] = index;
|
|
36
36
|
} else if (to == address(0)) {
|
|
37
|
-
uint256 lastIndex =
|
|
37
|
+
uint256 lastIndex = totalSupply() - 1;
|
|
38
38
|
uint256 index = _tokenIndex[tokenId];
|
|
39
39
|
if (index < lastIndex) {
|
|
40
40
|
bytes32 lastTokenId = _indexToken[lastIndex];
|
|
@@ -32,11 +32,11 @@ abstract contract LSP8EnumerableInitAbstract is LSP8IdentifiableDigitalAssetInit
|
|
|
32
32
|
bytes32 tokenId
|
|
33
33
|
) internal virtual override(LSP8IdentifiableDigitalAssetCore) {
|
|
34
34
|
if (from == address(0)) {
|
|
35
|
-
uint256 index =
|
|
35
|
+
uint256 index = totalSupply();
|
|
36
36
|
_indexToken[index] = tokenId;
|
|
37
37
|
_tokenIndex[tokenId] = index;
|
|
38
38
|
} else if (to == address(0)) {
|
|
39
|
-
uint256 lastIndex =
|
|
39
|
+
uint256 lastIndex = totalSupply() - 1;
|
|
40
40
|
uint256 index = _tokenIndex[tokenId];
|
|
41
41
|
if (index < lastIndex) {
|
|
42
42
|
bytes32 lastTokenId = _indexToken[lastIndex];
|