@lukso/lsp-smart-contracts 0.11.0-rc.0 → 0.11.1
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 +1 -0
- package/artifacts/LSP0ERC725Account.json +7 -2
- package/artifacts/LSP0ERC725AccountInit.json +7 -2
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +3 -79
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +3 -41
- package/artifacts/LSP23LinkedContractsFactory.json +544 -0
- package/artifacts/LSP6KeyManager.json +24 -19
- package/artifacts/LSP6KeyManagerInit.json +24 -19
- package/artifacts/LSP7CappedSupply.json +88 -0
- package/artifacts/LSP7CappedSupplyInitAbstract.json +88 -0
- package/artifacts/LSP7CompatibleERC20.json +88 -0
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +88 -0
- package/artifacts/LSP7CompatibleERC20Mintable.json +90 -2
- package/artifacts/LSP7CompatibleERC20MintableInit.json +90 -2
- package/artifacts/LSP7DigitalAsset.json +88 -0
- package/artifacts/LSP7DigitalAssetInitAbstract.json +88 -0
- package/artifacts/LSP7Mintable.json +90 -2
- package/artifacts/LSP7MintableInit.json +90 -2
- package/artifacts/LSP8CappedSupply.json +59 -0
- package/artifacts/LSP8CappedSupplyInitAbstract.json +59 -0
- package/artifacts/LSP8CompatibleERC721.json +60 -1
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +60 -1
- package/artifacts/LSP8CompatibleERC721Mintable.json +62 -3
- package/artifacts/LSP8CompatibleERC721MintableInit.json +62 -3
- package/artifacts/LSP8IdentifiableDigitalAsset.json +59 -0
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +59 -0
- package/artifacts/LSP8Mintable.json +61 -2
- package/artifacts/LSP8MintableInit.json +61 -2
- package/artifacts/LSP9Vault.json +7 -2
- package/artifacts/LSP9VaultInit.json +7 -2
- package/artifacts/UniversalProfile.json +7 -2
- package/artifacts/UniversalProfileInit.json +7 -2
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +8 -36
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +15 -30
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +122 -206
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +18 -36
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +8 -34
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +148 -177
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +21 -20
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +13 -2
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +50 -20
- package/contracts/LSP17ContractExtension/LSP17Errors.sol +10 -0
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +16 -34
- package/contracts/LSP17ContractExtension/LSP17Utils.sol +1 -1
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +16 -11
- package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +5 -10
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +192 -177
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +150 -88
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +66 -48
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +1 -1
- package/contracts/LSP23LinkedContractsDeployment/ILSP23LinkedContractsFactory.sol +192 -0
- package/contracts/LSP23LinkedContractsDeployment/IPostDeploymentModule.sol +18 -0
- package/contracts/LSP23LinkedContractsDeployment/LSP23Errors.sol +24 -0
- package/contracts/LSP23LinkedContractsDeployment/LSP23LinkedContractsFactory.sol +392 -0
- package/contracts/{LSP23MultiChainDeployment → LSP23LinkedContractsDeployment}/modules/UniversalProfileInitPostDeploymentModule.sol +5 -1
- package/contracts/LSP23LinkedContractsDeployment/modules/UniversalProfilePostDeploymentModule.sol +61 -0
- package/contracts/LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol +68 -0
- package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +8 -0
- package/contracts/LSP25ExecuteRelayCall/LSP25Errors.sol +17 -0
- package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +143 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +256 -61
- package/contracts/{LSP3UniversalProfile → LSP3ProfileMetadata}/LSP3Constants.sol +3 -3
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +9 -8
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +13 -6
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +4 -4
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +148 -189
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +26 -54
- package/contracts/LSP6KeyManager/LSP6Constants.sol +1 -3
- package/contracts/LSP6KeyManager/LSP6Errors.sol +142 -63
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +7 -4
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +125 -80
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +8 -4
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +1 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +52 -84
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +59 -10
- package/contracts/LSP6KeyManager/LSP6Utils.sol +67 -46
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +116 -78
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +4 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +128 -6
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +212 -80
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +126 -3
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +7 -5
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +27 -14
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +2 -4
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +2 -4
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +29 -11
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +30 -9
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +46 -14
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +43 -12
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +14 -0
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +9 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +7 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +8 -8
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +7 -6
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +10 -2
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +120 -92
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +4 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +135 -6
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +128 -38
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +134 -5
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +83 -41
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +13 -5
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +24 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +30 -12
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +31 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +96 -31
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +98 -23
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +21 -4
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +12 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +21 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +9 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +13 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +15 -6
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +7 -5
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +17 -2
- package/contracts/LSP9Vault/ILSP9Vault.sol +10 -5
- package/contracts/LSP9Vault/LSP9Errors.sol +3 -2
- package/contracts/LSP9Vault/LSP9Vault.sol +12 -4
- package/contracts/LSP9Vault/LSP9VaultCore.sol +245 -182
- package/contracts/LSP9Vault/LSP9VaultInit.sol +10 -3
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -6
- package/contracts/UniversalProfile.sol +8 -6
- package/contracts/UniversalProfileInit.sol +6 -6
- package/contracts/UniversalProfileInitAbstract.sol +10 -3
- package/devdocs/LSP0ERC725Account.json +54 -37
- package/devdocs/LSP0ERC725AccountInit.json +56 -38
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +14 -55
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +9 -33
- package/devdocs/LSP23LinkedContractsFactory.json +81 -0
- package/devdocs/LSP4DigitalAssetMetadata.json +5 -5
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +4 -4
- package/devdocs/LSP6KeyManager.json +109 -70
- package/devdocs/LSP6KeyManagerInit.json +109 -70
- package/devdocs/LSP7CappedSupply.json +90 -42
- package/devdocs/LSP7CappedSupplyInitAbstract.json +86 -40
- package/devdocs/LSP7CompatibleERC20.json +79 -43
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +75 -39
- package/devdocs/LSP7CompatibleERC20Mintable.json +87 -40
- package/devdocs/LSP7CompatibleERC20MintableInit.json +82 -42
- package/devdocs/LSP7DigitalAsset.json +76 -40
- package/devdocs/LSP7DigitalAssetInitAbstract.json +73 -37
- package/devdocs/LSP7Mintable.json +79 -51
- package/devdocs/LSP7MintableInit.json +78 -49
- package/devdocs/LSP8CappedSupply.json +72 -43
- package/devdocs/LSP8CappedSupplyInitAbstract.json +68 -41
- package/devdocs/LSP8CompatibleERC721.json +85 -64
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +81 -60
- package/devdocs/LSP8CompatibleERC721Mintable.json +98 -60
- package/devdocs/LSP8CompatibleERC721MintableInit.json +93 -62
- package/devdocs/LSP8IdentifiableDigitalAsset.json +58 -41
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -40
- package/devdocs/LSP8Mintable.json +65 -48
- package/devdocs/LSP8MintableInit.json +64 -47
- package/devdocs/LSP9Vault.json +61 -18
- package/devdocs/LSP9VaultInit.json +59 -17
- package/devdocs/UniversalProfile.json +53 -35
- package/devdocs/UniversalProfileInit.json +53 -35
- package/dist/constants.cjs.js +6236 -2587
- package/dist/constants.d.ts +3851 -1129
- package/dist/constants.es.js +6236 -2587
- package/package.json +6 -4
- package/userdocs/LSP0ERC725Account.json +40 -8
- package/userdocs/LSP0ERC725AccountInit.json +40 -8
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +18 -2
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +18 -2
- package/userdocs/LSP23LinkedContractsFactory.json +29 -0
- package/userdocs/LSP4DigitalAssetMetadata.json +1 -1
- package/userdocs/LSP6KeyManager.json +144 -6
- package/userdocs/LSP6KeyManagerInit.json +147 -6
- package/userdocs/LSP7CappedSupply.json +18 -3
- package/userdocs/LSP7CappedSupplyInitAbstract.json +17 -2
- package/userdocs/LSP7CompatibleERC20.json +3 -9
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +2 -8
- package/userdocs/LSP7CompatibleERC20Mintable.json +5 -8
- package/userdocs/LSP7CompatibleERC20MintableInit.json +3 -9
- package/userdocs/LSP7DigitalAsset.json +2 -2
- package/userdocs/LSP7DigitalAssetInitAbstract.json +2 -2
- package/userdocs/LSP7Mintable.json +3 -3
- package/userdocs/LSP7MintableInit.json +3 -3
- package/userdocs/LSP8CappedSupply.json +16 -1
- package/userdocs/LSP8CappedSupplyInitAbstract.json +15 -0
- package/userdocs/LSP8CompatibleERC721.json +24 -3
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +23 -2
- package/userdocs/LSP8CompatibleERC721Mintable.json +29 -2
- package/userdocs/LSP8CompatibleERC721MintableInit.json +27 -3
- package/userdocs/LSP8Mintable.json +4 -1
- package/userdocs/LSP8MintableInit.json +4 -1
- package/userdocs/LSP9Vault.json +50 -4
- package/userdocs/LSP9VaultInit.json +50 -4
- package/userdocs/UniversalProfile.json +40 -8
- package/userdocs/UniversalProfileInit.json +40 -8
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +0 -47
- package/contracts/LSP23MultiChainDeployment/IOwnerControlledContractDeployer.sol +0 -174
- package/contracts/LSP23MultiChainDeployment/IPostDeploymentModule.sol +0 -10
- package/contracts/LSP23MultiChainDeployment/LSP23Errors.sol +0 -24
- package/contracts/LSP23MultiChainDeployment/OwnerControlledContractDeployer.sol +0 -388
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
|
+
// interfaces
|
|
5
|
+
import {
|
|
6
|
+
ILSP20CallVerifier as ILSP20
|
|
7
|
+
} from "../../LSP20CallVerification/ILSP20CallVerifier.sol";
|
|
8
|
+
|
|
4
9
|
// modules
|
|
5
10
|
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
6
11
|
import {
|
|
@@ -38,12 +43,13 @@ import {
|
|
|
38
43
|
// errors
|
|
39
44
|
import {
|
|
40
45
|
NotRecognisedPermissionKey,
|
|
41
|
-
AddressPermissionArrayIndexValueNotAnAddress,
|
|
42
46
|
InvalidEncodedAllowedCalls,
|
|
43
47
|
InvalidEncodedAllowedERC725YDataKeys,
|
|
44
48
|
NoERC725YDataKeysAllowed,
|
|
45
49
|
NotAllowedERC725YDataKey,
|
|
46
|
-
NotAuthorised
|
|
50
|
+
NotAuthorised,
|
|
51
|
+
KeyManagerCannotBeSetAsExtensionForLSP20Functions,
|
|
52
|
+
InvalidDataValuesForDataKeys
|
|
47
53
|
} from "../LSP6Errors.sol";
|
|
48
54
|
|
|
49
55
|
abstract contract LSP6SetDataModule {
|
|
@@ -222,6 +228,14 @@ abstract contract LSP6SetDataModule {
|
|
|
222
228
|
bytes12(inputDataKey) ==
|
|
223
229
|
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX
|
|
224
230
|
) {
|
|
231
|
+
// CHECK that `dataValue` contains exactly 32 bytes, which is the required length for a permission BitArray
|
|
232
|
+
if (inputDataValue.length != 32 && inputDataValue.length != 0) {
|
|
233
|
+
revert InvalidDataValuesForDataKeys(
|
|
234
|
+
inputDataKey,
|
|
235
|
+
inputDataValue
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
225
239
|
// controller already has the permissions needed. Do not run internal function.
|
|
226
240
|
if (hasBothAddControllerAndEditPermissions) return (bytes32(0));
|
|
227
241
|
|
|
@@ -280,6 +294,14 @@ abstract contract LSP6SetDataModule {
|
|
|
280
294
|
inputDataKey == _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY ||
|
|
281
295
|
bytes12(inputDataKey) == _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX
|
|
282
296
|
) {
|
|
297
|
+
// CHECK that `dataValue` contains exactly 20 bytes, which corresponds to an address for a LSP1 Delegate contract
|
|
298
|
+
if (inputDataValue.length != 20 && inputDataValue.length != 0) {
|
|
299
|
+
revert InvalidDataValuesForDataKeys(
|
|
300
|
+
inputDataKey,
|
|
301
|
+
inputDataValue
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
283
305
|
// same as above. If controller has both permissions, do not read the `target` storage
|
|
284
306
|
// to save gas by avoiding an extra external `view` call.
|
|
285
307
|
if (
|
|
@@ -299,6 +321,26 @@ abstract contract LSP6SetDataModule {
|
|
|
299
321
|
|
|
300
322
|
// LSP17Extension:<bytes4>
|
|
301
323
|
} else if (bytes12(inputDataKey) == _LSP17_EXTENSION_PREFIX) {
|
|
324
|
+
// CHECK that `dataValue` contains exactly 20 bytes, which corresponds to an address for a LSP17 Extension
|
|
325
|
+
if (inputDataValue.length != 20 && inputDataValue.length != 0) {
|
|
326
|
+
revert InvalidDataValuesForDataKeys(
|
|
327
|
+
inputDataKey,
|
|
328
|
+
inputDataValue
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// reverts when the address of the Key Manager is being set as extensions for lsp20 functions
|
|
333
|
+
bytes4 selector = bytes4(inputDataKey << 96);
|
|
334
|
+
|
|
335
|
+
if (
|
|
336
|
+
(selector == ILSP20.lsp20VerifyCall.selector ||
|
|
337
|
+
selector == ILSP20.lsp20VerifyCallResult.selector)
|
|
338
|
+
) {
|
|
339
|
+
if (address(bytes20(inputDataValue)) == address(this)) {
|
|
340
|
+
revert KeyManagerCannotBeSetAsExtensionForLSP20Functions();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
302
344
|
// same as above. If controller has both permissions, do not read the `target` storage
|
|
303
345
|
// to save gas by avoiding an extra external `view` call.
|
|
304
346
|
if (
|
|
@@ -337,6 +379,14 @@ abstract contract LSP6SetDataModule {
|
|
|
337
379
|
) internal view virtual returns (bytes32) {
|
|
338
380
|
// AddressPermissions[] -> array length
|
|
339
381
|
if (inputDataKey == _LSP6KEY_ADDRESSPERMISSIONS_ARRAY) {
|
|
382
|
+
// CHECK that `dataValue` is exactly 16 bytes long or `0x` (= not set), as the array length of `AddressPermissions[]` MUST be a `uint128` value.
|
|
383
|
+
if (inputDataValue.length != 16 && inputDataValue.length != 0) {
|
|
384
|
+
revert InvalidDataValuesForDataKeys(
|
|
385
|
+
inputDataKey,
|
|
386
|
+
inputDataValue
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
|
|
340
390
|
// if the controller already has both permissions from one of the two required,
|
|
341
391
|
// No permission required as CHECK is already done. We don't need to read `target` storage.
|
|
342
392
|
if (hasBothAddControllerAndEditPermissions) return bytes32(0);
|
|
@@ -358,10 +408,7 @@ abstract contract LSP6SetDataModule {
|
|
|
358
408
|
|
|
359
409
|
// CHECK that we either ADD an address (20 bytes long) or REMOVE an address (0x)
|
|
360
410
|
if (inputDataValue.length != 0 && inputDataValue.length != 20) {
|
|
361
|
-
revert
|
|
362
|
-
inputDataKey,
|
|
363
|
-
inputDataValue
|
|
364
|
-
);
|
|
411
|
+
revert InvalidDataValuesForDataKeys(inputDataKey, inputDataValue);
|
|
365
412
|
}
|
|
366
413
|
|
|
367
414
|
// if the controller already has both permissions from one of the two required below,
|
|
@@ -552,13 +599,14 @@ abstract contract LSP6SetDataModule {
|
|
|
552
599
|
* The length of a data key is 32 bytes.
|
|
553
600
|
* Therefore we can have a fixed allowed data key which has
|
|
554
601
|
* a length of 32 bytes or we can have a dynamic data key
|
|
555
|
-
* which can have a length
|
|
602
|
+
* which can have a length from 1 up to 31 bytes.
|
|
556
603
|
*/
|
|
557
|
-
if (length > 32)
|
|
604
|
+
if (length == 0 || length > 32) {
|
|
558
605
|
revert InvalidEncodedAllowedERC725YDataKeys(
|
|
559
606
|
allowedERC725YDataKeysCompacted,
|
|
560
607
|
"couldn't DECODE from storage"
|
|
561
608
|
);
|
|
609
|
+
}
|
|
562
610
|
|
|
563
611
|
/**
|
|
564
612
|
* The bitmask discard the last `32 - length` bytes of the input data key via ANDing &
|
|
@@ -672,13 +720,14 @@ abstract contract LSP6SetDataModule {
|
|
|
672
720
|
* The length of a data key is 32 bytes.
|
|
673
721
|
* Therefore we can have a fixed allowed data key which has
|
|
674
722
|
* a length of 32 bytes or we can have a dynamic data key
|
|
675
|
-
* which can have a length
|
|
723
|
+
* which can have a length from 1 up to 31 bytes.
|
|
676
724
|
*/
|
|
677
|
-
if (length > 32)
|
|
725
|
+
if (length == 0 || length > 32) {
|
|
678
726
|
revert InvalidEncodedAllowedERC725YDataKeys(
|
|
679
727
|
allowedERC725YDataKeysCompacted,
|
|
680
728
|
"couldn't DECODE from storage"
|
|
681
729
|
);
|
|
730
|
+
}
|
|
682
731
|
|
|
683
732
|
/**
|
|
684
733
|
* The bitmask discard the last `32 - length` bytes of the input data key via ANDing &
|
|
@@ -13,14 +13,23 @@ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
|
13
13
|
// constants
|
|
14
14
|
import "./LSP6Constants.sol";
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @title LSP6 Utility library.
|
|
18
|
+
* @author Yamen Merhi <YamenMerhi>, Jean Cavallera <CJ42>, Maxime Viard <SkimaHarvey>
|
|
19
|
+
* @dev LSP6Utils is a library of utility functions that can be used to retrieve, check and set LSP6 permissions stored under the ERC725Y storage
|
|
20
|
+
* of a smart contract.
|
|
21
|
+
* Based on the LSP6 Key Manager standard.
|
|
22
|
+
*/
|
|
16
23
|
library LSP6Utils {
|
|
17
24
|
using LSP2Utils for bytes12;
|
|
18
25
|
|
|
19
26
|
/**
|
|
20
|
-
* @dev
|
|
21
|
-
*
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
27
|
+
* @dev Read the permissions of a `caller` on an ERC725Y `target` contract.
|
|
28
|
+
*
|
|
29
|
+
* @param target An `IERC725Y` contract where to read the permissions.
|
|
30
|
+
* @param caller The controller address to read the permissions from.
|
|
31
|
+
*
|
|
32
|
+
* @return A `bytes32` BitArray containing the permissions of a controller address.
|
|
24
33
|
*/
|
|
25
34
|
function getPermissionsFor(
|
|
26
35
|
IERC725Y target,
|
|
@@ -50,10 +59,12 @@ library LSP6Utils {
|
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
/**
|
|
53
|
-
* @dev
|
|
54
|
-
*
|
|
55
|
-
* @param
|
|
56
|
-
* @
|
|
62
|
+
* @dev Read the Allowed ERC725Y data keys of a `caller` on an ERC725Y `target` contract.
|
|
63
|
+
*
|
|
64
|
+
* @param target An `IERC725Y` contract where to read the permissions.
|
|
65
|
+
* @param caller The controller address to read the permissions from.
|
|
66
|
+
*
|
|
67
|
+
* @return An abi-encoded array of allowed ERC725 data keys that the controller address is allowed to interact with.
|
|
57
68
|
*/
|
|
58
69
|
function getAllowedERC725YDataKeysFor(
|
|
59
70
|
IERC725Y target,
|
|
@@ -69,24 +80,26 @@ library LSP6Utils {
|
|
|
69
80
|
}
|
|
70
81
|
|
|
71
82
|
/**
|
|
72
|
-
* @dev
|
|
73
|
-
*
|
|
74
|
-
* @param
|
|
75
|
-
* @param permissionToCheck
|
|
76
|
-
*
|
|
83
|
+
* @dev Compare the permissions `controllerPermissions` of a controller address to check if they includes the permissions `permissionToCheck`.
|
|
84
|
+
*
|
|
85
|
+
* @param controllerPermissions The permissions of an address.
|
|
86
|
+
* @param permissionToCheck The permissions to check if the controller has under its `controllerPermissions`.
|
|
87
|
+
*
|
|
88
|
+
* @return `true` if `controllerPermissions` includes `permissionToCheck`, `false` otherwise.
|
|
77
89
|
*/
|
|
78
90
|
function hasPermission(
|
|
79
|
-
bytes32
|
|
91
|
+
bytes32 controllerPermissions,
|
|
80
92
|
bytes32 permissionToCheck
|
|
81
93
|
) internal pure returns (bool) {
|
|
82
|
-
return (
|
|
94
|
+
return (controllerPermissions & permissionToCheck) == permissionToCheck;
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
/**
|
|
86
|
-
* @dev
|
|
98
|
+
* @dev Same as `LSP2Utils.isCompactBytesArray` with the additional requirement that each element must be 32 bytes long.
|
|
87
99
|
*
|
|
88
|
-
* @param allowedCallsCompacted
|
|
89
|
-
*
|
|
100
|
+
* @param allowedCallsCompacted A compact bytes array of tuples `(bytes4,address,bytes4,bytes4)` to check (defined as `(bytes4,address,bytes4,bytes4)[CompactBytesArray]` in LSP6).
|
|
101
|
+
*
|
|
102
|
+
* @return `true` if the value passed is a valid compact bytes array of bytes32 AllowedCalls elements, `false` otherwise.
|
|
90
103
|
*/
|
|
91
104
|
function isCompactBytesArrayOfAllowedCalls(
|
|
92
105
|
bytes memory allowedCallsCompacted
|
|
@@ -112,10 +125,11 @@ library LSP6Utils {
|
|
|
112
125
|
}
|
|
113
126
|
|
|
114
127
|
/**
|
|
115
|
-
* @dev
|
|
128
|
+
* @dev Same as `LSP2Utils.isCompactBytesArray` with the additional requirement that each element must be from 1 to 32 bytes long.
|
|
129
|
+
*
|
|
130
|
+
* @param allowedERC725YDataKeysCompacted a compact bytes array of ERC725Y data Keys (full bytes32 data keys or bytesN prefix) to check (defined as `bytes[CompactBytesArray]`).
|
|
116
131
|
*
|
|
117
|
-
* @
|
|
118
|
-
* @return true if the value passed is a valid compact bytes array of ERC725Y Data Keys, false otherwise.
|
|
132
|
+
* @return `true` if the value passed is a valid compact bytes array of bytes32 Allowed ERC725Y data keys, `false` otherwise.
|
|
119
133
|
*/
|
|
120
134
|
function isCompactBytesArrayOfAllowedERC725YDataKeys(
|
|
121
135
|
bytes memory allowedERC725YDataKeysCompacted
|
|
@@ -142,10 +156,11 @@ library LSP6Utils {
|
|
|
142
156
|
}
|
|
143
157
|
|
|
144
158
|
/**
|
|
145
|
-
* @dev
|
|
146
|
-
*
|
|
147
|
-
* @param
|
|
148
|
-
* @param
|
|
159
|
+
* @dev Use the `setData(bytes32[],bytes[])` function via the KeyManager on the target contract.
|
|
160
|
+
*
|
|
161
|
+
* @param keyManagerAddress The address of the KeyManager.
|
|
162
|
+
* @param keys The array of `bytes32[]` data keys.
|
|
163
|
+
* @param values The array of `bytes[]` data values.
|
|
149
164
|
*/
|
|
150
165
|
function setDataViaKeyManager(
|
|
151
166
|
address keyManagerAddress,
|
|
@@ -161,35 +176,36 @@ library LSP6Utils {
|
|
|
161
176
|
}
|
|
162
177
|
|
|
163
178
|
/**
|
|
164
|
-
* @dev
|
|
165
|
-
* Make sure that the sum of the values of the input array is less than 2^256-1 to avoid overflow.
|
|
166
|
-
*
|
|
167
|
-
* @
|
|
179
|
+
* @dev Combine multiple permissions into a single `bytes32`.
|
|
180
|
+
* Make sure that the sum of the values of the input array is less than `2^256-1 to avoid overflow.
|
|
181
|
+
*
|
|
182
|
+
* @param permissions The array of permissions to combine.
|
|
183
|
+
* @return A `bytes32` value containing the combined permissions.
|
|
168
184
|
*/
|
|
169
185
|
function combinePermissions(
|
|
170
186
|
bytes32[] memory permissions
|
|
171
187
|
) internal pure returns (bytes32) {
|
|
172
|
-
|
|
188
|
+
bytes32 result;
|
|
173
189
|
for (uint256 i = 0; i < permissions.length; i++) {
|
|
174
|
-
result
|
|
190
|
+
result |= permissions[i];
|
|
175
191
|
}
|
|
176
|
-
return
|
|
192
|
+
return result;
|
|
177
193
|
}
|
|
178
194
|
|
|
179
195
|
/**
|
|
180
|
-
* @dev Generate a new set of 3 x LSP6 permission data keys to add a new `controller` on `account
|
|
181
|
-
* @param account
|
|
182
|
-
* @param controller
|
|
183
|
-
* @param permissions
|
|
184
|
-
* @return keys
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
196
|
+
* @dev Generate a new set of 3 x LSP6 permission data keys to add a new `controller` on `account`.
|
|
197
|
+
* @param account The ERC725Y contract to add the controller into (used to fetch the `LSP6Permissions[]` length).
|
|
198
|
+
* @param controller The address of the controller to grant permissions to.
|
|
199
|
+
* @param permissions The `BitArray` of permissions to grant to the controller.
|
|
200
|
+
* @return keys An array of 3 x data keys containing:
|
|
201
|
+
* - `keys[0] = AddressPermissions[]` (array length).
|
|
202
|
+
* - `keys[1] = AddressPermissions[index]` (where to store the controller address).
|
|
203
|
+
* - `keys[2] = AddressPermissions:Permissions:<controller>`.
|
|
188
204
|
*
|
|
189
|
-
* @return values
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
205
|
+
* @return values An array of 3 x data values containing:
|
|
206
|
+
* - `values[0] =` the new array length of `AddressPermissions[]`
|
|
207
|
+
* - `values[1] =` the address of the controller
|
|
208
|
+
* - `values[2] =` the `permissions` passed as param
|
|
193
209
|
*/
|
|
194
210
|
function generateNewPermissionsKeys(
|
|
195
211
|
IERC725Y account,
|
|
@@ -221,11 +237,15 @@ library LSP6Utils {
|
|
|
221
237
|
}
|
|
222
238
|
|
|
223
239
|
/**
|
|
224
|
-
* @dev
|
|
240
|
+
* @dev Returns the name of the permission as a string.
|
|
241
|
+
*
|
|
242
|
+
* @param permission The low-level `bytes32` permission as a `BitArray` to get the permission name from.
|
|
243
|
+
*
|
|
244
|
+
* @return The string name of the `bytes32` permission value.
|
|
225
245
|
*/
|
|
226
246
|
function getPermissionName(
|
|
227
247
|
bytes32 permission
|
|
228
|
-
) internal pure returns (string memory
|
|
248
|
+
) internal pure returns (string memory) {
|
|
229
249
|
if (permission == _PERMISSION_CHANGEOWNER) return "TRANSFEROWNERSHIP";
|
|
230
250
|
if (permission == _PERMISSION_EDITPERMISSIONS) return "EDITPERMISSIONS";
|
|
231
251
|
if (permission == _PERMISSION_ADDCONTROLLER) return "ADDCONTROLLER";
|
|
@@ -244,5 +264,6 @@ library LSP6Utils {
|
|
|
244
264
|
if (permission == _PERMISSION_DEPLOY) return "DEPLOY";
|
|
245
265
|
if (permission == _PERMISSION_TRANSFERVALUE) return "TRANSFERVALUE";
|
|
246
266
|
if (permission == _PERMISSION_SIGN) return "SIGN";
|
|
267
|
+
return "";
|
|
247
268
|
}
|
|
248
269
|
}
|
|
@@ -15,14 +15,13 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
15
15
|
// --- Events
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @dev Emitted when `
|
|
19
|
-
* @param operator The address of operator
|
|
20
|
-
* @param from The address which tokens
|
|
21
|
-
* @param to The
|
|
22
|
-
* @param amount The amount of tokens transferred
|
|
23
|
-
* @param allowNonLSP1Recipient
|
|
24
|
-
*
|
|
25
|
-
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses
|
|
18
|
+
* @dev Emitted when the `from` transferred successfully `amount` of tokens to `to`.
|
|
19
|
+
* @param operator The address of the operator that executed the transfer.
|
|
20
|
+
* @param from The address which tokens were sent from (balance decreased by `-amount`).
|
|
21
|
+
* @param to The address that received the tokens (balance increased by `+amount`).
|
|
22
|
+
* @param amount The amount of tokens transferred.
|
|
23
|
+
* @param allowNonLSP1Recipient if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not.
|
|
24
|
+
* @param data Any additional data included by the caller during the transfer, and sent in the LSP1 hooks to the `from` and `to` addresses.
|
|
26
25
|
*/
|
|
27
26
|
event Transfer(
|
|
28
27
|
address indexed operator,
|
|
@@ -38,123 +37,164 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
38
37
|
* @param operator The address authorized as an operator
|
|
39
38
|
* @param tokenOwner The token owner
|
|
40
39
|
* @param amount The amount of tokens `operator` address has access to from `tokenOwner`
|
|
40
|
+
* @param operatorNotificationData The data to notify the operator about via LSP1.
|
|
41
41
|
*/
|
|
42
42
|
event AuthorizedOperator(
|
|
43
43
|
address indexed operator,
|
|
44
44
|
address indexed tokenOwner,
|
|
45
|
-
uint256 indexed amount
|
|
45
|
+
uint256 indexed amount,
|
|
46
|
+
bytes operatorNotificationData
|
|
46
47
|
);
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
|
-
* @dev Emitted when `tokenOwner` disables `operator` for `amount` tokens
|
|
50
|
+
* @dev Emitted when `tokenOwner` disables `operator` for `amount` tokens and set its {`authorizedAmountFor(...)`} to `0`.
|
|
50
51
|
* @param operator The address revoked from operating
|
|
51
52
|
* @param tokenOwner The token owner
|
|
53
|
+
* @param operatorNotificationData The data to notify the operator about via LSP1.
|
|
52
54
|
*/
|
|
53
|
-
event RevokedOperator(
|
|
55
|
+
event RevokedOperator(
|
|
56
|
+
address indexed operator,
|
|
57
|
+
address indexed tokenOwner,
|
|
58
|
+
bytes operatorNotificationData
|
|
59
|
+
);
|
|
54
60
|
|
|
55
61
|
// --- Token queries
|
|
56
62
|
|
|
57
63
|
/**
|
|
58
|
-
* @dev Returns the number of decimals used to get its user representation
|
|
59
|
-
* If the contract
|
|
64
|
+
* @dev Returns the number of decimals used to get its user representation.
|
|
65
|
+
* If the asset contract has been set to be non-divisible via the `isNonDivisible_` parameter in
|
|
66
|
+
* the `constructor`, the decimals returned wiil be `0`. Otherwise `18` is the common value.
|
|
60
67
|
*
|
|
61
|
-
*
|
|
68
|
+
* @custom:notice This information is only used for _display_ purposes: it in
|
|
62
69
|
* no way affects any of the arithmetic of the contract, including
|
|
63
70
|
* {balanceOf} and {transfer}.
|
|
71
|
+
*
|
|
72
|
+
* @return the number of decimals. If `0` is returned, the asset is non-divisible.
|
|
64
73
|
*/
|
|
65
74
|
function decimals() external view returns (uint8);
|
|
66
75
|
|
|
67
76
|
/**
|
|
68
|
-
* @dev Returns the number of existing tokens.
|
|
69
|
-
* @return The number of existing tokens
|
|
77
|
+
* @dev Returns the number of existing tokens that have been minted in this contract.
|
|
78
|
+
* @return The number of existing tokens.
|
|
70
79
|
*/
|
|
71
80
|
function totalSupply() external view returns (uint256);
|
|
72
81
|
|
|
73
82
|
// --- Token owner queries
|
|
74
83
|
|
|
75
84
|
/**
|
|
76
|
-
* @dev
|
|
77
|
-
*
|
|
78
|
-
*
|
|
85
|
+
* @dev Get the number of tokens owned by `tokenOwner`.
|
|
86
|
+
* If the token is divisible (the {decimals} function returns `18`), the amount returned should be divided
|
|
87
|
+
* by 1e18 to get a better picture of the actual balance of the `tokenOwner`.
|
|
88
|
+
*
|
|
89
|
+
* _Example:_
|
|
90
|
+
*
|
|
91
|
+
* ```
|
|
92
|
+
* balanceOf(someAddress) -> 42_000_000_000_000_000_000 / 1e18 = 42 tokens
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @param tokenOwner The address of the token holder to query the balance for.
|
|
96
|
+
* @return The amount of tokens owned by `tokenOwner`.
|
|
79
97
|
*/
|
|
80
98
|
function balanceOf(address tokenOwner) external view returns (uint256);
|
|
81
99
|
|
|
82
100
|
// --- Operator functionality
|
|
83
101
|
|
|
84
102
|
/**
|
|
85
|
-
* @
|
|
86
|
-
* @param amount The amount of tokens operator has access to.
|
|
87
|
-
* @dev Sets `amount` as the amount of tokens `operator` address has access to from callers tokens.
|
|
88
|
-
*
|
|
89
|
-
* To avoid front-running and Allowance Double-Spend Exploit when
|
|
90
|
-
* increasing or decreasing the authorized amount of an operator,
|
|
91
|
-
* it is advised to:
|
|
92
|
-
* 1. call {revokeOperator} first, and
|
|
93
|
-
* 2. then re-call {authorizeOperator} with the new amount
|
|
103
|
+
* @dev Sets an `amount` of tokens that an `operator` has access from the caller's balance (allowance). See {authorizedAmountFor}.
|
|
94
104
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* See {authorizedAmountFor}.
|
|
100
|
-
*
|
|
101
|
-
* Requirements
|
|
105
|
+
* @param operator The address to authorize as an operator.
|
|
106
|
+
* @param amount The allowance amount of tokens operator has access to.
|
|
107
|
+
* @param operatorNotificationData The data to notify the operator about via LSP1.
|
|
102
108
|
*
|
|
109
|
+
* @custom:requirements
|
|
103
110
|
* - `operator` cannot be the zero address.
|
|
104
111
|
*
|
|
105
|
-
*
|
|
112
|
+
* @custom:events {AuthorizedOperator} when allowance is given to a new operator or
|
|
113
|
+
* an existing operator's allowance is updated.
|
|
106
114
|
*/
|
|
107
|
-
function authorizeOperator(
|
|
115
|
+
function authorizeOperator(
|
|
116
|
+
address operator,
|
|
117
|
+
uint256 amount,
|
|
118
|
+
bytes memory operatorNotificationData
|
|
119
|
+
) external;
|
|
108
120
|
|
|
109
121
|
/**
|
|
110
|
-
* @
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* See {authorizedAmountFor}.
|
|
122
|
+
* @dev Removes the `operator` address as an operator of callers tokens, disallowing it to send any amount of tokens
|
|
123
|
+
* on behalf of the token owner (the caller of the function `msg.sender`). See also {authorizedAmountFor}.
|
|
114
124
|
*
|
|
115
|
-
*
|
|
125
|
+
* @param operator The address to revoke as an operator.
|
|
126
|
+
* @param operatorNotificationData The data to notify the operator about via LSP1.
|
|
116
127
|
*
|
|
128
|
+
* @custom:requirements
|
|
129
|
+
* - `operator` cannot be calling address.
|
|
117
130
|
* - `operator` cannot be the zero address.
|
|
118
131
|
*
|
|
119
|
-
*
|
|
132
|
+
* @custom:events {RevokedOperator} event with address of the operator being revoked for the caller (token holder).
|
|
120
133
|
*/
|
|
121
|
-
function revokeOperator(
|
|
134
|
+
function revokeOperator(
|
|
135
|
+
address operator,
|
|
136
|
+
bytes memory operatorNotificationData
|
|
137
|
+
) external;
|
|
122
138
|
|
|
123
139
|
/**
|
|
124
|
-
* @
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* @
|
|
128
|
-
*
|
|
129
|
-
*
|
|
140
|
+
* @dev Get the amount of tokens `operator` address has access to from `tokenOwner`.
|
|
141
|
+
* Operators can send and burn tokens on behalf of their owners.
|
|
142
|
+
*
|
|
143
|
+
* @param operator The operator's address to query the authorized amount for.
|
|
144
|
+
* @param tokenOwner The token owner that `operator` has allowance on.
|
|
145
|
+
*
|
|
146
|
+
* @return The amount of tokens the `operator`'s address has access on the `tokenOwner`'s balance.
|
|
147
|
+
*
|
|
148
|
+
* @custom:info If this function is called with the same address for `operator` and `tokenOwner`, it will simply read the `tokenOwner`'s balance
|
|
149
|
+
* (since a tokenOwner is its own operator).
|
|
130
150
|
*/
|
|
131
151
|
function authorizedAmountFor(
|
|
132
152
|
address operator,
|
|
133
153
|
address tokenOwner
|
|
134
154
|
) external view returns (uint256);
|
|
135
155
|
|
|
156
|
+
/**
|
|
157
|
+
* @dev Returns all `operator` addresses that are allowed to transfer or burn on behalf of `tokenOwner`.
|
|
158
|
+
*
|
|
159
|
+
* @param tokenOwner The token owner to get the operators for.
|
|
160
|
+
* @return An array of operators allowed to transfer or burn tokens on behalf of `tokenOwner`.
|
|
161
|
+
*/
|
|
162
|
+
function getOperatorsOf(
|
|
163
|
+
address tokenOwner
|
|
164
|
+
) external view returns (address[] memory);
|
|
165
|
+
|
|
136
166
|
// --- Transfer functionality
|
|
137
167
|
|
|
138
168
|
/**
|
|
139
|
-
* @
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* @param allowNonLSP1Recipient When set to TRUE, to may be any address but
|
|
143
|
-
* when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
|
|
144
|
-
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
|
|
169
|
+
* @dev Transfers an `amount` of tokens from the `from` address to the `to` address and notify both sender and recipients via the LSP1 {`universalReceiver(...)`} function.
|
|
170
|
+
* If the tokens are transferred by an operator on behalf of a token holder, the allowance for the operator will be decreased by `amount` once the token transfer
|
|
171
|
+
* has been completed (See {authorizedAmountFor}).
|
|
145
172
|
*
|
|
146
|
-
* @
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
173
|
+
* @param from The sender address.
|
|
174
|
+
* @param to The recipient address.
|
|
175
|
+
* @param amount The amount of tokens to transfer.
|
|
176
|
+
* @param allowNonLSP1Recipient When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard.
|
|
177
|
+
* @param data Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses.
|
|
150
178
|
*
|
|
179
|
+
* @custom:requirements
|
|
151
180
|
* - `from` cannot be the zero address.
|
|
152
181
|
* - `to` cannot be the zero address.
|
|
153
|
-
* - `
|
|
154
|
-
* -
|
|
155
|
-
* `amount` tokens.
|
|
182
|
+
* - `from` and `to` cannot be the same address (`from` cannot send tokens to itself).
|
|
183
|
+
* - `from` MUST have a balance of at least `amount` tokens.
|
|
184
|
+
* - If the caller is not `from`, it must be an operator for `from` with an allowance of at least `amount` of tokens.
|
|
156
185
|
*
|
|
157
|
-
*
|
|
186
|
+
* @custom:events
|
|
187
|
+
* - {Transfer} event when tokens get successfully transferred.
|
|
188
|
+
* - if the transfer is triggered by an operator, either the {AuthorizedOperator} event will be emitted with the updated allowance or the {RevokedOperator}
|
|
189
|
+
* event will be emitted if the operator has no more allowance left.
|
|
190
|
+
*
|
|
191
|
+
* @custom:hint The `allowNonLSP1Recipient` parameter **MUST be set to `true`** to transfer tokens to Externally Owned Accounts (EOAs)
|
|
192
|
+
* or contracts that do not implement the LSP1 Universal Receiver Standard. Otherwise the function will revert making the transfer fail.
|
|
193
|
+
*
|
|
194
|
+
* @custom:info if the `to` address is a contract that implements LSP1, it will always be notified via its `universalReceiver(...)` function, regardless if `allowNonLSP1Recipient` is set to `true` or `false`.
|
|
195
|
+
*
|
|
196
|
+
* @custom:warning Be aware that when either the sender or the recipient can have logic that revert in their `universalReceiver(...)` function when being notified.
|
|
197
|
+
* This even if the `allowNonLSP1Recipient` was set to `true`.
|
|
158
198
|
*/
|
|
159
199
|
function transfer(
|
|
160
200
|
address from,
|
|
@@ -165,26 +205,24 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
165
205
|
) external;
|
|
166
206
|
|
|
167
207
|
/**
|
|
168
|
-
* @
|
|
169
|
-
* @param to The list of receiving addresses.
|
|
170
|
-
* @param amount The amount of tokens to transfer.
|
|
171
|
-
* @param allowNonLSP1Recipient When set to TRUE, to may be any address but
|
|
172
|
-
* when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
|
|
173
|
-
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
|
|
208
|
+
* @dev Same as {`transfer(...)`} but transfer multiple tokens based on the arrays of `from`, `to`, `amount`.
|
|
174
209
|
*
|
|
175
|
-
* @
|
|
176
|
-
* the call will revert.
|
|
210
|
+
* @custom:info If any transfer in the batch fail or revert, the whole call will revert.
|
|
177
211
|
*
|
|
178
|
-
*
|
|
212
|
+
* @param from An array of sending addresses.
|
|
213
|
+
* @param to An array of receiving addresses.
|
|
214
|
+
* @param amount An array of amount of tokens to transfer for each `from -> to` transfer.
|
|
215
|
+
* @param allowNonLSP1Recipient For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard.
|
|
216
|
+
* @param data An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
|
|
179
217
|
*
|
|
180
|
-
*
|
|
218
|
+
* @custom:requirements
|
|
219
|
+
* - `from`, `to`, `amount` lists MUST be of the same length.
|
|
181
220
|
* - no values in `from` can be the zero address.
|
|
182
221
|
* - no values in `to` can be the zero address.
|
|
183
|
-
* - each `amount` tokens
|
|
184
|
-
* -
|
|
185
|
-
* `amount` tokens.
|
|
222
|
+
* - each `amount` tokens MUST be owned by `from`.
|
|
223
|
+
* - for each transfer, if the caller is not `from`, it MUST be an operator for `from` with access to at least `amount` tokens.
|
|
186
224
|
*
|
|
187
|
-
*
|
|
225
|
+
* @custom:events {Transfer} event **for each token transfer**.
|
|
188
226
|
*/
|
|
189
227
|
function transferBatch(
|
|
190
228
|
address[] memory from,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// --- ERC165 interface ids
|
|
5
|
-
bytes4 constant _INTERFACEID_LSP7 =
|
|
5
|
+
bytes4 constant _INTERFACEID_LSP7 = 0x05519512;
|
|
6
6
|
|
|
7
7
|
// --- Token Hooks
|
|
8
8
|
|
|
@@ -11,3 +11,6 @@ bytes32 constant _TYPEID_LSP7_TOKENSSENDER = 0x429ac7a06903dbc9c13dfcb3c9d11df81
|
|
|
11
11
|
|
|
12
12
|
// keccak256('LSP7Tokens_RecipientNotification')
|
|
13
13
|
bytes32 constant _TYPEID_LSP7_TOKENSRECIPIENT = 0x20804611b3e2ea21c480dc465142210acf4a2485947541770ec1fb87dee4a55c;
|
|
14
|
+
|
|
15
|
+
// keccak256('LSP7Tokens_OperatorNotification')
|
|
16
|
+
bytes32 constant _TYPEID_LSP7_TOKENOPERATOR = 0x386072cc5a58e61263b434c722725f21031cd06e7c552cfaa06db5de8a320dbc;
|