@lukso/lsp-smart-contracts 0.11.1 → 0.12.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 +10 -2
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +68 -47
- package/artifacts/LSP0ERC725AccountInit.json +68 -47
- package/artifacts/LSP11BasicSocialRecovery.json +18 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +18 -2
- package/artifacts/LSP16UniversalFactory.json +3 -3
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +27 -46
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +27 -46
- package/artifacts/LSP23LinkedContractsFactory.json +3 -3
- package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
- package/artifacts/LSP6KeyManager.json +34 -6
- package/artifacts/LSP6KeyManagerInit.json +34 -6
- package/artifacts/LSP7CappedSupply.json +64 -4
- package/artifacts/LSP7CappedSupplyInitAbstract.json +64 -4
- package/artifacts/LSP7CompatibleERC20.json +83 -23
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +83 -23
- package/artifacts/LSP7CompatibleERC20Mintable.json +86 -26
- package/artifacts/LSP7CompatibleERC20MintableInit.json +86 -26
- package/artifacts/LSP7DigitalAsset.json +64 -4
- package/artifacts/LSP7DigitalAssetInitAbstract.json +64 -4
- package/artifacts/LSP7Mintable.json +67 -7
- package/artifacts/LSP7MintableInit.json +67 -7
- package/artifacts/LSP8CappedSupply.json +57 -3
- package/artifacts/LSP8CappedSupplyInitAbstract.json +57 -3
- package/artifacts/LSP8CompatibleERC721.json +79 -25
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +79 -25
- package/artifacts/LSP8CompatibleERC721Mintable.json +87 -28
- package/artifacts/LSP8CompatibleERC721MintableInit.json +87 -28
- package/artifacts/LSP8IdentifiableDigitalAsset.json +57 -3
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -3
- package/artifacts/LSP8Mintable.json +65 -6
- package/artifacts/LSP8MintableInit.json +65 -6
- package/artifacts/LSP9Vault.json +51 -35
- package/artifacts/LSP9VaultInit.json +51 -35
- package/artifacts/UniversalProfile.json +68 -47
- package/artifacts/UniversalProfileInit.json +68 -47
- package/contracts/Factories/Create2Factory.sol +1 -1
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +0 -22
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +6 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +12 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +196 -123
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +11 -2
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +5 -3
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +54 -14
- package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +1 -1
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +1 -1
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +2 -2
- package/contracts/LSP14Ownable2Step/LSP14Constants.sol +1 -1
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +9 -3
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +16 -12
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +65 -96
- package/contracts/LSP17ContractExtension/LSP17Errors.sol +1 -1
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +22 -15
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +6 -5
- package/contracts/LSP17Extensions/Extension4337.sol +101 -0
- package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +15 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +1 -2
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +24 -0
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -0
- package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +0 -6
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +49 -33
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +33 -27
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +5 -48
- package/contracts/LSP20CallVerification/ILSP20CallVerifier.sol +13 -9
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +64 -45
- package/contracts/LSP20CallVerification/LSP20Constants.sol +6 -6
- package/contracts/LSP20CallVerification/LSP20Errors.sol +10 -4
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/ILSP23LinkedContractsFactory.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/IPostDeploymentModule.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23Errors.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23LinkedContractsFactory.sol +5 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfileInitPostDeploymentModule.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfilePostDeploymentModule.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +8 -3
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +1 -97
- package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +8 -3
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +8 -3
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +4 -3
- package/contracts/LSP6KeyManager/LSP6Constants.sol +4 -3
- package/contracts/LSP6KeyManager/LSP6Errors.sol +2 -23
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +176 -101
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +1 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteRelayCallModule.sol +27 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +34 -28
- package/contracts/LSP6KeyManager/LSP6Utils.sol +29 -2
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +70 -10
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +2 -2
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +29 -13
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +273 -265
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +28 -12
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +17 -3
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +5 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +7 -7
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +3 -3
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +128 -54
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +129 -54
- package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +1 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -4
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +16 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +20 -6
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +32 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +67 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +143 -137
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +69 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +172 -80
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +178 -91
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +8 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +5 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +13 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +9 -8
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +9 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +10 -8
- package/contracts/LSP9Vault/ILSP9Vault.sol +0 -21
- package/contracts/LSP9Vault/LSP9Constants.sol +6 -1
- package/contracts/LSP9Vault/LSP9Errors.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +11 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +119 -66
- package/contracts/LSP9Vault/LSP9VaultInit.sol +1 -1
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -2
- package/contracts/UniversalProfile.sol +1 -1
- package/contracts/UniversalProfileInit.sol +1 -1
- package/contracts/UniversalProfileInitAbstract.sol +1 -1
- package/contracts/Version.sol +16 -0
- package/devdocs/LSP0ERC725Account.json +86 -52
- package/devdocs/LSP0ERC725AccountInit.json +86 -52
- package/devdocs/LSP11BasicSocialRecovery.json +13 -0
- package/devdocs/LSP11BasicSocialRecoveryInit.json +13 -0
- package/devdocs/LSP16UniversalFactory.json +9 -9
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +7 -6
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +7 -6
- package/devdocs/LSP4DigitalAssetMetadata.json +32 -10
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +32 -10
- package/devdocs/LSP6KeyManager.json +27 -13
- package/devdocs/LSP6KeyManagerInit.json +27 -13
- package/devdocs/LSP7CappedSupply.json +61 -28
- package/devdocs/LSP7CappedSupplyInitAbstract.json +61 -28
- package/devdocs/LSP7CompatibleERC20.json +102 -32
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +102 -32
- package/devdocs/LSP7CompatibleERC20Mintable.json +102 -32
- package/devdocs/LSP7CompatibleERC20MintableInit.json +102 -32
- package/devdocs/LSP7DigitalAsset.json +61 -28
- package/devdocs/LSP7DigitalAssetInitAbstract.json +61 -28
- package/devdocs/LSP7Mintable.json +61 -28
- package/devdocs/LSP7MintableInit.json +61 -28
- package/devdocs/LSP8CappedSupply.json +66 -27
- package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -27
- package/devdocs/LSP8CompatibleERC721.json +93 -33
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +93 -33
- package/devdocs/LSP8CompatibleERC721Mintable.json +95 -35
- package/devdocs/LSP8CompatibleERC721MintableInit.json +96 -36
- package/devdocs/LSP8IdentifiableDigitalAsset.json +70 -28
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -27
- package/devdocs/LSP8Mintable.json +68 -29
- package/devdocs/LSP8MintableInit.json +69 -30
- package/devdocs/LSP9Vault.json +69 -41
- package/devdocs/LSP9VaultInit.json +69 -41
- package/devdocs/UniversalProfile.json +86 -52
- package/devdocs/UniversalProfileInit.json +86 -52
- package/dist/constants.cjs.js +5565 -2846
- package/dist/constants.d.ts +3996 -1182
- package/dist/constants.es.js +5564 -2846
- package/package.json +8 -8
- package/userdocs/LSP0ERC725Account.json +20 -11
- package/userdocs/LSP0ERC725AccountInit.json +20 -11
- package/userdocs/LSP16UniversalFactory.json +26 -1
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +4 -11
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +4 -11
- package/userdocs/LSP4DigitalAssetMetadata.json +7 -4
- package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -4
- package/userdocs/LSP6KeyManager.json +3 -5
- package/userdocs/LSP6KeyManagerInit.json +3 -5
- package/userdocs/LSP7CappedSupply.json +17 -6
- package/userdocs/LSP7CappedSupplyInitAbstract.json +16 -5
- package/userdocs/LSP7CompatibleERC20.json +18 -5
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +18 -5
- package/userdocs/LSP7CompatibleERC20Mintable.json +18 -5
- package/userdocs/LSP7CompatibleERC20MintableInit.json +18 -5
- package/userdocs/LSP7DigitalAsset.json +18 -5
- package/userdocs/LSP7DigitalAssetInitAbstract.json +18 -5
- package/userdocs/LSP7Mintable.json +18 -5
- package/userdocs/LSP7MintableInit.json +18 -5
- package/userdocs/LSP8CappedSupply.json +16 -5
- package/userdocs/LSP8CappedSupplyInitAbstract.json +15 -4
- package/userdocs/LSP8CompatibleERC721.json +30 -17
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +30 -17
- package/userdocs/LSP8CompatibleERC721Mintable.json +31 -18
- package/userdocs/LSP8CompatibleERC721MintableInit.json +32 -19
- package/userdocs/LSP8IdentifiableDigitalAsset.json +18 -5
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +17 -4
- package/userdocs/LSP8Mintable.json +18 -5
- package/userdocs/LSP8MintableInit.json +19 -6
- package/userdocs/LSP9Vault.json +23 -14
- package/userdocs/LSP9VaultInit.json +23 -14
- package/userdocs/UniversalProfile.json +20 -11
- package/userdocs/UniversalProfileInit.json +20 -11
- package/CONTRIBUTING.md +0 -184
- package/artifacts/LSP4Compatibility.json +0 -216
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +0 -25
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +0 -38
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +0 -83
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +0 -175
- package/devdocs/LSP4Compatibility.json +0 -79
- package/userdocs/LSP4Compatibility.json +0 -20
|
@@ -8,9 +8,6 @@ import {
|
|
|
8
8
|
|
|
9
9
|
// modules
|
|
10
10
|
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
11
|
-
import {
|
|
12
|
-
ERC725Y_DataKeysValuesLengthMismatch
|
|
13
|
-
} from "@erc725/smart-contracts/contracts/errors.sol";
|
|
14
11
|
|
|
15
12
|
// libraries
|
|
16
13
|
import {LSP6Utils} from "../LSP6Utils.sol";
|
|
@@ -41,6 +38,9 @@ import {
|
|
|
41
38
|
} from "../../LSP17ContractExtension/LSP17Constants.sol";
|
|
42
39
|
|
|
43
40
|
// errors
|
|
41
|
+
import {
|
|
42
|
+
ERC725Y_DataKeysValuesLengthMismatch
|
|
43
|
+
} from "@erc725/smart-contracts/contracts/errors.sol";
|
|
44
44
|
import {
|
|
45
45
|
NotRecognisedPermissionKey,
|
|
46
46
|
InvalidEncodedAllowedCalls,
|
|
@@ -431,22 +431,26 @@ abstract contract LSP6SetDataModule {
|
|
|
431
431
|
address controlledContract,
|
|
432
432
|
bytes32 inputPermissionDataKey
|
|
433
433
|
) internal view virtual returns (bytes32) {
|
|
434
|
+
// extract the address of the controller from the data key `AddressPermissions:Permissions:<controller>`
|
|
435
|
+
address controller = address(bytes20(inputPermissionDataKey << 96));
|
|
436
|
+
|
|
437
|
+
bytes32 controllerPermissions = ERC725Y(controlledContract)
|
|
438
|
+
.getPermissionsFor(controller);
|
|
439
|
+
|
|
434
440
|
return
|
|
435
441
|
// if there is nothing stored under the data key, we are trying to ADD a new controller.
|
|
436
442
|
// if there are already some permissions set under the data key, we are trying to CHANGE the permissions of a controller.
|
|
437
|
-
bytes32(
|
|
438
|
-
ERC725Y(controlledContract).getData(inputPermissionDataKey)
|
|
439
|
-
) == bytes32(0)
|
|
443
|
+
controllerPermissions == bytes32(0)
|
|
440
444
|
? _PERMISSION_ADDCONTROLLER
|
|
441
445
|
: _PERMISSION_EDITPERMISSIONS;
|
|
442
446
|
}
|
|
443
447
|
|
|
444
448
|
/**
|
|
445
|
-
* @dev
|
|
446
|
-
* @param controlledContract
|
|
447
|
-
* @param dataKey `AddressPermissions:AllowedCalls:<controller-address>`.
|
|
448
|
-
* @param dataValue
|
|
449
|
-
* @return
|
|
449
|
+
* @dev Retrieve the permission required to set some AllowedCalls for a controller.
|
|
450
|
+
* @param controlledContract The address of the ERC725Y contract from which to fetch the value of `dataKey`.
|
|
451
|
+
* @param dataKey A data key ion the format `AddressPermissions:AllowedCalls:<controller-address>`.
|
|
452
|
+
* @param dataValue The updated value for the `dataKey`. MUST be a bytes32[CompactBytesArray] of Allowed Calls.
|
|
453
|
+
* @return Either ADD or EDIT PERMISSIONS.
|
|
450
454
|
*/
|
|
451
455
|
function _getPermissionToSetAllowedCalls(
|
|
452
456
|
address controlledContract,
|
|
@@ -462,23 +466,24 @@ abstract contract LSP6SetDataModule {
|
|
|
462
466
|
// No permission required as CHECK is already done. We don't need to read `target` storage.
|
|
463
467
|
if (hasBothAddControllerAndEditPermissions) return bytes32(0);
|
|
464
468
|
|
|
465
|
-
//
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
// if some
|
|
469
|
-
//
|
|
469
|
+
// extract the address of the controller from the data key `AddressPermissions:AllowedCalls:<controller>`
|
|
470
|
+
address controller = address(bytes20(dataKey << 96));
|
|
471
|
+
|
|
472
|
+
// if the controller exists and has some permissions set, this is considered as EDIT a "sub-set" of its permissions.
|
|
473
|
+
// (even if the controller does not have any allowed calls set).
|
|
470
474
|
return
|
|
471
|
-
ERC725Y(controlledContract).
|
|
475
|
+
ERC725Y(controlledContract).getPermissionsFor(controller) ==
|
|
476
|
+
bytes32(0)
|
|
472
477
|
? _PERMISSION_ADDCONTROLLER
|
|
473
478
|
: _PERMISSION_EDITPERMISSIONS;
|
|
474
479
|
}
|
|
475
480
|
|
|
476
481
|
/**
|
|
477
|
-
* @dev
|
|
478
|
-
* @param controlledContract the address of the ERC725Y contract
|
|
479
|
-
* @param dataKey
|
|
480
|
-
* @param dataValue
|
|
481
|
-
* @return
|
|
482
|
+
* @dev Retrieve the permission required to set some Allowed ERC725Y Data Keys for a controller.
|
|
483
|
+
* @param controlledContract the address of the ERC725Y contract from which to fetch the value of `dataKey`.
|
|
484
|
+
* @param dataKey A data key in the format `AddressPermissions:AllowedERC725YDataKeys:<controller-address>`.
|
|
485
|
+
* @param dataValue The updated value for the `dataKey`. MUST be a bytes[CompactBytesArray] of Allowed ERC725Y Data Keys.
|
|
486
|
+
* @return Either ADD or EDIT PERMISSIONS.
|
|
482
487
|
*/
|
|
483
488
|
function _getPermissionToSetAllowedERC725YDataKeys(
|
|
484
489
|
address controlledContract,
|
|
@@ -497,13 +502,14 @@ abstract contract LSP6SetDataModule {
|
|
|
497
502
|
// CHECK is already done. We don't need to read `target` storage.
|
|
498
503
|
if (hasBothAddControllerAndEditPermissions) return bytes32(0);
|
|
499
504
|
|
|
500
|
-
//
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
// if
|
|
504
|
-
//
|
|
505
|
+
// extract the address of the controller from the data key `AddressPermissions:AllowedERC725YDataKeys:<controller>`
|
|
506
|
+
address controller = address(bytes20(dataKey << 96));
|
|
507
|
+
|
|
508
|
+
// if the controller exists and has some permissions set, this is considered as EDIT a "sub-set" of its permissions.
|
|
509
|
+
// (even if the controller does not have any allowed ERC725Y data keys set).
|
|
505
510
|
return
|
|
506
|
-
ERC725Y(controlledContract).
|
|
511
|
+
ERC725Y(controlledContract).getPermissionsFor(controller) ==
|
|
512
|
+
bytes32(0)
|
|
507
513
|
? _PERMISSION_ADDCONTROLLER
|
|
508
514
|
: _PERMISSION_EDITPERMISSIONS;
|
|
509
515
|
}
|
|
@@ -11,7 +11,27 @@ import {ILSP6KeyManager} from "./ILSP6KeyManager.sol";
|
|
|
11
11
|
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
12
12
|
|
|
13
13
|
// constants
|
|
14
|
-
import
|
|
14
|
+
import {
|
|
15
|
+
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX,
|
|
16
|
+
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDCALLS_PREFIX,
|
|
17
|
+
_LSP6KEY_ADDRESSPERMISSIONS_AllowedERC725YDataKeys_PREFIX,
|
|
18
|
+
_LSP6KEY_ADDRESSPERMISSIONS_ARRAY,
|
|
19
|
+
_PERMISSION_CHANGEOWNER,
|
|
20
|
+
_PERMISSION_EDITPERMISSIONS,
|
|
21
|
+
_PERMISSION_ADDCONTROLLER,
|
|
22
|
+
_PERMISSION_ADDEXTENSIONS,
|
|
23
|
+
_PERMISSION_CHANGEEXTENSIONS,
|
|
24
|
+
_PERMISSION_ADDUNIVERSALRECEIVERDELEGATE,
|
|
25
|
+
_PERMISSION_CHANGEUNIVERSALRECEIVERDELEGATE,
|
|
26
|
+
_PERMISSION_REENTRANCY,
|
|
27
|
+
_PERMISSION_SETDATA,
|
|
28
|
+
_PERMISSION_CALL,
|
|
29
|
+
_PERMISSION_STATICCALL,
|
|
30
|
+
_PERMISSION_DELEGATECALL,
|
|
31
|
+
_PERMISSION_DEPLOY,
|
|
32
|
+
_PERMISSION_TRANSFERVALUE,
|
|
33
|
+
_PERMISSION_SIGN
|
|
34
|
+
} from "./LSP6Constants.sol";
|
|
15
35
|
|
|
16
36
|
/**
|
|
17
37
|
* @title LSP6 Utility library.
|
|
@@ -30,6 +50,9 @@ library LSP6Utils {
|
|
|
30
50
|
* @param caller The controller address to read the permissions from.
|
|
31
51
|
*
|
|
32
52
|
* @return A `bytes32` BitArray containing the permissions of a controller address.
|
|
53
|
+
*
|
|
54
|
+
* @custom:info If the raw value fetched from the ERC725Y storage of `target` is not 32 bytes long, this is considered
|
|
55
|
+
* like _"no permissions are set"_ and will return 32 x `0x00` bytes as `bytes32(0)`.
|
|
33
56
|
*/
|
|
34
57
|
function getPermissionsFor(
|
|
35
58
|
IERC725Y target,
|
|
@@ -42,6 +65,10 @@ library LSP6Utils {
|
|
|
42
65
|
)
|
|
43
66
|
);
|
|
44
67
|
|
|
68
|
+
if (permissions.length != 32) {
|
|
69
|
+
return bytes32(0);
|
|
70
|
+
}
|
|
71
|
+
|
|
45
72
|
return bytes32(permissions);
|
|
46
73
|
}
|
|
47
74
|
|
|
@@ -186,7 +213,7 @@ library LSP6Utils {
|
|
|
186
213
|
bytes32[] memory permissions
|
|
187
214
|
) internal pure returns (bytes32) {
|
|
188
215
|
bytes32 result;
|
|
189
|
-
for (uint256 i
|
|
216
|
+
for (uint256 i; i < permissions.length; i++) {
|
|
190
217
|
result |= permissions[i];
|
|
191
218
|
}
|
|
192
219
|
return result;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.4;
|
|
4
4
|
|
|
@@ -20,7 +20,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
20
20
|
* @param from The address which tokens were sent from (balance decreased by `-amount`).
|
|
21
21
|
* @param to The address that received the tokens (balance increased by `+amount`).
|
|
22
22
|
* @param amount The amount of tokens transferred.
|
|
23
|
-
* @param
|
|
23
|
+
* @param force if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not.
|
|
24
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.
|
|
25
25
|
*/
|
|
26
26
|
event Transfer(
|
|
@@ -28,7 +28,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
28
28
|
address indexed from,
|
|
29
29
|
address indexed to,
|
|
30
30
|
uint256 amount,
|
|
31
|
-
bool
|
|
31
|
+
bool force,
|
|
32
32
|
bytes data
|
|
33
33
|
);
|
|
34
34
|
|
|
@@ -50,11 +50,13 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
50
50
|
* @dev Emitted when `tokenOwner` disables `operator` for `amount` tokens and set its {`authorizedAmountFor(...)`} to `0`.
|
|
51
51
|
* @param operator The address revoked from operating
|
|
52
52
|
* @param tokenOwner The token owner
|
|
53
|
+
* @param notified Bool indicating whether the operator has been notified or not
|
|
53
54
|
* @param operatorNotificationData The data to notify the operator about via LSP1.
|
|
54
55
|
*/
|
|
55
56
|
event RevokedOperator(
|
|
56
57
|
address indexed operator,
|
|
57
58
|
address indexed tokenOwner,
|
|
59
|
+
bool notified,
|
|
58
60
|
bytes operatorNotificationData
|
|
59
61
|
);
|
|
60
62
|
|
|
@@ -101,6 +103,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
101
103
|
|
|
102
104
|
/**
|
|
103
105
|
* @dev Sets an `amount` of tokens that an `operator` has access from the caller's balance (allowance). See {authorizedAmountFor}.
|
|
106
|
+
* Notify the operator based on the LSP1-UniversalReceiver standard
|
|
104
107
|
*
|
|
105
108
|
* @param operator The address to authorize as an operator.
|
|
106
109
|
* @param amount The allowance amount of tokens operator has access to.
|
|
@@ -123,6 +126,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
123
126
|
* on behalf of the token owner (the caller of the function `msg.sender`). See also {authorizedAmountFor}.
|
|
124
127
|
*
|
|
125
128
|
* @param operator The address to revoke as an operator.
|
|
129
|
+
* @param notify Boolean indicating whether to notify the operator or not.
|
|
126
130
|
* @param operatorNotificationData The data to notify the operator about via LSP1.
|
|
127
131
|
*
|
|
128
132
|
* @custom:requirements
|
|
@@ -133,6 +137,62 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
133
137
|
*/
|
|
134
138
|
function revokeOperator(
|
|
135
139
|
address operator,
|
|
140
|
+
bool notify,
|
|
141
|
+
bytes memory operatorNotificationData
|
|
142
|
+
) external;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @custom:info This function in the LSP7 contract can be used as a prevention mechanism
|
|
146
|
+
* against double spending allowance vulnerability.
|
|
147
|
+
*
|
|
148
|
+
* @notice Increase the allowance of `operator` by +`addedAmount`
|
|
149
|
+
*
|
|
150
|
+
* @dev Atomically increases the allowance granted to `operator` by the caller.
|
|
151
|
+
* This is an alternative approach to {authorizeOperator} that can be used as a mitigation
|
|
152
|
+
* for the double spending allowance problem.
|
|
153
|
+
* Notify the operator based on the LSP1-UniversalReceiver standard
|
|
154
|
+
*
|
|
155
|
+
* @param operator The operator to increase the allowance for `msg.sender`
|
|
156
|
+
* @param addedAmount The additional amount to add on top of the current operator's allowance
|
|
157
|
+
*
|
|
158
|
+
* @custom:requirements
|
|
159
|
+
* - `operator` cannot be the same address as `msg.sender`
|
|
160
|
+
* - `operator` cannot be the zero address.
|
|
161
|
+
*
|
|
162
|
+
* @custom:events {AuthorizedOperator} indicating the updated allowance
|
|
163
|
+
*/
|
|
164
|
+
function increaseAllowance(
|
|
165
|
+
address operator,
|
|
166
|
+
uint256 addedAmount,
|
|
167
|
+
bytes memory operatorNotificationData
|
|
168
|
+
) external;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @custom:info This function in the LSP7 contract can be used as a prevention mechanism
|
|
172
|
+
* against the double spending allowance vulnerability.
|
|
173
|
+
*
|
|
174
|
+
* @notice Decrease the allowance of `operator` by -`subtractedAmount`
|
|
175
|
+
*
|
|
176
|
+
* @dev Atomically decreases the allowance granted to `operator` by the caller.
|
|
177
|
+
* This is an alternative approach to {authorizeOperator} that can be used as a mitigation
|
|
178
|
+
* for the double spending allowance problem.
|
|
179
|
+
* Notify the operator based on the LSP1-UniversalReceiver standard
|
|
180
|
+
*
|
|
181
|
+
* @custom:events
|
|
182
|
+
* - {AuthorizedOperator} event indicating the updated allowance after decreasing it.
|
|
183
|
+
* - {RevokeOperator} event if `subtractedAmount` is the full allowance,
|
|
184
|
+
* indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`.
|
|
185
|
+
*
|
|
186
|
+
* @param operator The operator to decrease allowance for `msg.sender`
|
|
187
|
+
* @param subtractedAmount The amount to decrease by in the operator's allowance.
|
|
188
|
+
*
|
|
189
|
+
* @custom:requirements
|
|
190
|
+
* - `operator` cannot be the zero address.
|
|
191
|
+
* - `operator` must have allowance for the caller of at least `subtractedAmount`.
|
|
192
|
+
*/
|
|
193
|
+
function decreaseAllowance(
|
|
194
|
+
address operator,
|
|
195
|
+
uint256 subtractedAmount,
|
|
136
196
|
bytes memory operatorNotificationData
|
|
137
197
|
) external;
|
|
138
198
|
|
|
@@ -173,7 +233,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
173
233
|
* @param from The sender address.
|
|
174
234
|
* @param to The recipient address.
|
|
175
235
|
* @param amount The amount of tokens to transfer.
|
|
176
|
-
* @param
|
|
236
|
+
* @param force 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
237
|
* @param data Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses.
|
|
178
238
|
*
|
|
179
239
|
* @custom:requirements
|
|
@@ -188,19 +248,19 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
188
248
|
* - if the transfer is triggered by an operator, either the {AuthorizedOperator} event will be emitted with the updated allowance or the {RevokedOperator}
|
|
189
249
|
* event will be emitted if the operator has no more allowance left.
|
|
190
250
|
*
|
|
191
|
-
* @custom:hint The `
|
|
251
|
+
* @custom:hint The `force` parameter **MUST be set to `true`** to transfer tokens to Externally Owned Accounts (EOAs)
|
|
192
252
|
* or contracts that do not implement the LSP1 Universal Receiver Standard. Otherwise the function will revert making the transfer fail.
|
|
193
253
|
*
|
|
194
|
-
* @custom:info if the `to` address is a contract that implements LSP1, it will always be notified via its `universalReceiver(...)` function, regardless if `
|
|
254
|
+
* @custom:info if the `to` address is a contract that implements LSP1, it will always be notified via its `universalReceiver(...)` function, regardless if `force` is set to `true` or `false`.
|
|
195
255
|
*
|
|
196
256
|
* @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 `
|
|
257
|
+
* This even if the `force` was set to `true`.
|
|
198
258
|
*/
|
|
199
259
|
function transfer(
|
|
200
260
|
address from,
|
|
201
261
|
address to,
|
|
202
262
|
uint256 amount,
|
|
203
|
-
bool
|
|
263
|
+
bool force,
|
|
204
264
|
bytes memory data
|
|
205
265
|
) external;
|
|
206
266
|
|
|
@@ -212,7 +272,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
212
272
|
* @param from An array of sending addresses.
|
|
213
273
|
* @param to An array of receiving addresses.
|
|
214
274
|
* @param amount An array of amount of tokens to transfer for each `from -> to` transfer.
|
|
215
|
-
* @param
|
|
275
|
+
* @param force 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
276
|
* @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.
|
|
217
277
|
*
|
|
218
278
|
* @custom:requirements
|
|
@@ -228,7 +288,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
228
288
|
address[] memory from,
|
|
229
289
|
address[] memory to,
|
|
230
290
|
uint256[] memory amount,
|
|
231
|
-
bool[] memory
|
|
291
|
+
bool[] memory force,
|
|
232
292
|
bytes[] memory data
|
|
233
293
|
) external;
|
|
234
294
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
@@ -17,8 +17,11 @@ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
|
17
17
|
|
|
18
18
|
// constants
|
|
19
19
|
import {_INTERFACEID_LSP7} from "./LSP7Constants.sol";
|
|
20
|
+
import {LSP7TokenContractCannotHoldValue} from "./LSP7Errors.sol";
|
|
20
21
|
|
|
21
|
-
import
|
|
22
|
+
import {
|
|
23
|
+
_LSP17_EXTENSION_PREFIX
|
|
24
|
+
} from "../LSP17ContractExtension/LSP17Constants.sol";
|
|
22
25
|
|
|
23
26
|
// errors
|
|
24
27
|
|
|
@@ -60,7 +63,6 @@ abstract contract LSP7DigitalAsset is
|
|
|
60
63
|
|
|
61
64
|
// fallback function
|
|
62
65
|
|
|
63
|
-
// solhint-disable no-complex-fallback
|
|
64
66
|
/**
|
|
65
67
|
* @notice The `fallback` function was called with the following amount of native tokens: `msg.value`; and the following calldata: `callData`.
|
|
66
68
|
*
|
|
@@ -80,6 +82,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
80
82
|
*
|
|
81
83
|
* 2. If the data sent to this function is of length less than 4 bytes (not a function selector), revert.
|
|
82
84
|
*/
|
|
85
|
+
// solhint-disable-next-line no-complex-fallback
|
|
83
86
|
fallback(
|
|
84
87
|
bytes calldata callData
|
|
85
88
|
) external payable virtual returns (bytes memory) {
|
|
@@ -89,11 +92,25 @@ abstract contract LSP7DigitalAsset is
|
|
|
89
92
|
return _fallbackLSP17Extendable(callData);
|
|
90
93
|
}
|
|
91
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @dev Reverts whenever someone tries to send native tokens to a LSP7 contract.
|
|
97
|
+
* @notice LSP7 contract cannot receive native tokens.
|
|
98
|
+
*/
|
|
99
|
+
receive() external payable virtual {
|
|
100
|
+
// revert on empty calls with no value
|
|
101
|
+
if (msg.value == 0) {
|
|
102
|
+
revert InvalidFunctionSelector(hex"00000000");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
revert LSP7TokenContractCannotHoldValue();
|
|
106
|
+
}
|
|
107
|
+
|
|
92
108
|
/**
|
|
93
109
|
* @dev Forwards the call with the received value to an extension mapped to a function selector.
|
|
94
110
|
*
|
|
95
|
-
* Calls {
|
|
111
|
+
* Calls {_getExtensionAndForwardValue} to get the address of the extension mapped to the function selector being
|
|
96
112
|
* called on the account. If there is no extension, the address(0) will be returned.
|
|
113
|
+
* Forwards the value if the extension is payable.
|
|
97
114
|
*
|
|
98
115
|
* Reverts if there is no extension for the function being called.
|
|
99
116
|
*
|
|
@@ -101,16 +118,14 @@ abstract contract LSP7DigitalAsset is
|
|
|
101
118
|
* CALL opcode, passing the {msg.data} appended with the 20 bytes of the {msg.sender} and
|
|
102
119
|
* 32 bytes of the {msg.value}
|
|
103
120
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* Otherwise, the codes after _fallbackLSP17Extendable() may never be reached.
|
|
121
|
+
* @custom:info The LSP7 Token contract should not hold any native tokens. Any native tokens received by the contract
|
|
122
|
+
* will be forwarded to the extension address mapped to the selector from `msg.sig`.
|
|
108
123
|
*/
|
|
109
124
|
function _fallbackLSP17Extendable(
|
|
110
125
|
bytes calldata callData
|
|
111
126
|
) internal virtual override returns (bytes memory) {
|
|
112
127
|
// If there is a function selector
|
|
113
|
-
address extension =
|
|
128
|
+
(address extension, ) = _getExtensionAndForwardValue(msg.sig);
|
|
114
129
|
|
|
115
130
|
// if no extension was found, revert
|
|
116
131
|
if (extension == address(0))
|
|
@@ -125,8 +140,8 @@ abstract contract LSP7DigitalAsset is
|
|
|
125
140
|
} else {
|
|
126
141
|
// `mload(result)` -> offset in memory where `result.length` is located
|
|
127
142
|
// `add(result, 32)` -> offset in memory where `result` data starts
|
|
128
|
-
// solhint-disable no-inline-assembly
|
|
129
143
|
/// @solidity memory-safe-assembly
|
|
144
|
+
// solhint-disable-next-line no-inline-assembly
|
|
130
145
|
assembly {
|
|
131
146
|
let resultdata_size := mload(result)
|
|
132
147
|
revert(add(result, 32), resultdata_size)
|
|
@@ -138,10 +153,11 @@ abstract contract LSP7DigitalAsset is
|
|
|
138
153
|
* @dev Returns the extension address stored under the following data key:
|
|
139
154
|
* - {_LSP17_EXTENSION_PREFIX} + `<bytes4>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key).
|
|
140
155
|
* - If no extension is stored, returns the address(0).
|
|
156
|
+
* - we do not check that payable bool as in lsp7 standard we will always forward the value to the extension
|
|
141
157
|
*/
|
|
142
|
-
function
|
|
158
|
+
function _getExtensionAndForwardValue(
|
|
143
159
|
bytes4 functionSelector
|
|
144
|
-
) internal view virtual override returns (address) {
|
|
160
|
+
) internal view virtual override returns (address, bool) {
|
|
145
161
|
// Generate the data key relevant for the functionSelector being called
|
|
146
162
|
bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
|
|
147
163
|
_LSP17_EXTENSION_PREFIX,
|
|
@@ -155,7 +171,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
155
171
|
if (extensionAddress.length != 20 && extensionAddress.length != 0)
|
|
156
172
|
revert InvalidExtensionAddress(extensionAddress);
|
|
157
173
|
|
|
158
|
-
return address(bytes20(extensionAddress));
|
|
174
|
+
return (address(bytes20(extensionAddress)), true);
|
|
159
175
|
}
|
|
160
176
|
|
|
161
177
|
/**
|