@lukso/lsp-smart-contracts 0.14.0 → 0.15.0-rc.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 +2 -192
- package/artifacts/LSP0ERC725Account.json +3 -3
- package/artifacts/LSP0ERC725AccountInit.json +3 -3
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +3 -3
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +3 -3
- package/artifacts/LSP23LinkedContractsFactory.json +3 -3
- package/artifacts/LSP4DigitalAssetMetadata.json +1 -1
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +1 -1
- package/artifacts/LSP6KeyManager.json +3 -3
- package/artifacts/LSP6KeyManagerInit.json +3 -3
- package/artifacts/LSP7CappedSupply.json +53 -6
- package/artifacts/LSP7CappedSupplyInitAbstract.json +53 -6
- package/artifacts/LSP7DigitalAsset.json +52 -5
- package/artifacts/LSP7DigitalAssetInitAbstract.json +52 -5
- package/artifacts/LSP7Mintable.json +54 -7
- package/artifacts/LSP7MintableInit.json +54 -7
- package/artifacts/LSP8CappedSupply.json +43 -6
- package/artifacts/LSP8CappedSupplyInitAbstract.json +43 -6
- package/artifacts/LSP8IdentifiableDigitalAsset.json +43 -6
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +43 -6
- package/artifacts/LSP8Mintable.json +45 -8
- package/artifacts/LSP8MintableInit.json +45 -8
- package/artifacts/LSP9Vault.json +3 -3
- package/artifacts/LSP9VaultInit.json +3 -3
- package/artifacts/UniversalProfile.json +3 -3
- package/artifacts/UniversalProfileInit.json +3 -3
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +1 -17
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -23
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +1 -53
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +1 -873
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -47
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +1 -49
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +1 -7
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +1 -208
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +4 -2
- package/contracts/LSP12IssuedAssets/LSP12Constants.sol +4 -0
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +1 -75
- package/contracts/LSP14Ownable2Step/LSP14Constants.sol +1 -12
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +1 -29
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +1 -212
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +1 -417
- package/contracts/LSP17ContractExtension/LSP17Constants.sol +1 -14
- package/contracts/LSP17ContractExtension/LSP17Errors.sol +1 -14
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +1 -117
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +1 -55
- package/contracts/LSP17ContractExtension/LSP17Utils.sol +1 -16
- package/contracts/LSP17Extensions/Extension4337.sol +1 -123
- package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +1 -13
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +1 -37
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +1 -21
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -11
- package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +1 -7
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +1 -292
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +1 -217
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +1 -84
- package/contracts/LSP20CallVerification/ILSP20CallVerifier.sol +1 -36
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +1 -117
- package/contracts/LSP20CallVerification/LSP20Constants.sol +1 -14
- package/contracts/LSP20CallVerification/LSP20Errors.sol +1 -18
- package/contracts/LSP23LinkedContractsFactory/ILSP23LinkedContractsFactory.sol +1 -189
- package/contracts/LSP23LinkedContractsFactory/IPostDeploymentModule.sol +1 -15
- package/contracts/LSP23LinkedContractsFactory/LSP23Errors.sol +1 -21
- package/contracts/LSP23LinkedContractsFactory/LSP23LinkedContractsFactory.sol +1 -393
- package/contracts/LSP23LinkedContractsFactory/modules/README.md +23 -0
- package/contracts/LSP23LinkedContractsFactory/modules/UniversalProfileInitPostDeploymentModule.sol +1 -60
- package/contracts/LSP23LinkedContractsFactory/modules/UniversalProfilePostDeploymentModule.sol +1 -58
- package/contracts/LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol +1 -65
- package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +1 -5
- package/contracts/LSP25ExecuteRelayCall/LSP25Errors.sol +1 -14
- package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +1 -141
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +1 -445
- package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -8
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -30
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +1 -59
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol +1 -44
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +1 -65
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +1 -20
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +1 -7
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +1 -206
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +1 -60
- package/contracts/LSP6KeyManager/LSP6Constants.sol +1 -61
- package/contracts/LSP6KeyManager/LSP6Errors.sol +1 -222
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +1 -23
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +1 -694
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -29
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +1 -21
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +1 -411
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteRelayCallModule.sol +1 -24
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +1 -27
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +1 -848
- package/contracts/LSP6KeyManager/LSP6Utils.sol +1 -293
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +1 -302
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -13
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +1 -193
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +1 -728
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +1 -189
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +1 -87
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +1 -23
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +1 -24
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +1 -80
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +1 -83
- package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +1 -29
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +1 -50
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +1 -41
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +1 -54
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +1 -325
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +1 -38
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +1 -102
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +1 -236
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +1 -787
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -243
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -27
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -21
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +1 -82
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +1 -85
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +1 -66
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +1 -61
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +1 -30
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +1 -57
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +1 -40
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +1 -59
- package/contracts/LSP9Vault/ILSP9Vault.sol +1 -16
- package/contracts/LSP9Vault/LSP9Constants.sol +1 -26
- package/contracts/LSP9Vault/LSP9Errors.sol +1 -6
- package/contracts/LSP9Vault/LSP9Vault.sol +1 -63
- package/contracts/LSP9Vault/LSP9VaultCore.sol +1 -684
- package/contracts/LSP9Vault/LSP9VaultInit.sol +1 -33
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +1 -65
- package/contracts/UniversalProfile.sol +1 -37
- package/contracts/UniversalProfileInit.sol +1 -39
- package/contracts/UniversalProfileInitAbstract.sol +1 -44
- package/dist/constants.cjs +75 -0
- package/dist/constants.d.cts +121 -0
- package/dist/constants.d.mts +121 -0
- package/dist/constants.d.ts +107 -40105
- package/dist/constants.mjs +70 -0
- package/package.json +58 -116
- package/types/@lukso/lsp0-contracts/contracts/LSP0ERC725Account.ts +694 -0
- package/types/@lukso/lsp0-contracts/contracts/LSP0ERC725AccountInit.ts +740 -0
- package/types/@lukso/lsp1delegate-contracts/contracts/LSP1UniversalReceiverDelegateUP.ts +139 -0
- package/types/@lukso/lsp1delegate-contracts/contracts/LSP1UniversalReceiverDelegateVault.ts +139 -0
- package/types/@lukso/lsp23-contracts/contracts/LSP23LinkedContractsFactory.ts +448 -0
- package/types/@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadata.ts +274 -0
- package/types/@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadataInitAbstract.ts +309 -0
- package/types/@lukso/lsp6-contracts/contracts/LSP6KeyManager.ts +355 -0
- package/types/@lukso/lsp6-contracts/contracts/LSP6KeyManagerInit.ts +398 -0
- package/types/@lukso/lsp7-contracts/contracts/LSP7DigitalAsset.ts +698 -0
- package/types/@lukso/lsp7-contracts/contracts/LSP7DigitalAssetInitAbstract.ts +729 -0
- package/types/@lukso/lsp7-contracts/contracts/extensions/LSP7CappedSupply.ts +712 -0
- package/types/@lukso/lsp7-contracts/contracts/extensions/LSP7CappedSupplyInitAbstract.ts +743 -0
- package/types/@lukso/lsp7-contracts/contracts/presets/LSP7Mintable.ts +717 -0
- package/types/@lukso/lsp7-contracts/contracts/presets/LSP7MintableInit.ts +779 -0
- package/types/@lukso/lsp8-contracts/contracts/LSP8IdentifiableDigitalAsset.ts +778 -0
- package/types/@lukso/lsp8-contracts/contracts/LSP8IdentifiableDigitalAssetInitAbstract.ts +813 -0
- package/types/@lukso/lsp8-contracts/contracts/extensions/LSP8CappedSupply.ts +792 -0
- package/types/@lukso/lsp8-contracts/contracts/extensions/LSP8CappedSupplyInitAbstract.ts +824 -0
- package/types/@lukso/lsp8-contracts/contracts/presets/LSP8Mintable.ts +797 -0
- package/types/@lukso/lsp8-contracts/contracts/presets/LSP8MintableInit.ts +860 -0
- package/types/@lukso/lsp9-contracts/contracts/LSP9Vault.ts +672 -0
- package/types/@lukso/lsp9-contracts/contracts/LSP9VaultInit.ts +714 -0
- package/types/@lukso/universalprofile-contracts/contracts/UniversalProfile.ts +694 -0
- package/types/@lukso/universalprofile-contracts/contracts/UniversalProfileInit.ts +740 -0
- package/types/common.ts +131 -0
- package/types/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.ts +596 -0
- package/types/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.ts +646 -0
- package/types/index.ts +18446 -0
- package/LICENSE +0 -201
- package/artifacts/Create2Factory.json +0 -107
- package/artifacts/LSP16UniversalFactory.json +0 -271
- package/artifacts/LSP7CompatibleERC20.json +0 -935
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +0 -948
- package/artifacts/LSP7CompatibleERC20Mintable.json +0 -989
- package/artifacts/LSP7CompatibleERC20MintableInit.json +0 -1009
- package/artifacts/LSP8CompatibleERC721.json +0 -1191
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +0 -1204
- package/artifacts/LSP8CompatibleERC721Mintable.json +0 -1261
- package/artifacts/LSP8CompatibleERC721MintableInit.json +0 -1281
- package/artifacts/UniversalReceiverAddressStore.json +0 -209
- package/contracts/Factories/Create2Factory.sol +0 -88
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +0 -260
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +0 -273
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +0 -37
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +0 -44
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +0 -43
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +0 -512
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +0 -514
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +0 -54
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +0 -47
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +0 -52
- package/contracts/Legacy/Registries/AddressRegistry.sol +0 -52
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +0 -37
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +0 -64
- package/contracts/Version.sol +0 -17
- package/devdocs/Create2Factory.json +0 -16
- package/devdocs/LSP0ERC725Account.json +0 -260
- package/devdocs/LSP0ERC725AccountInit.json +0 -263
- package/devdocs/LSP11BasicSocialRecovery.json +0 -159
- package/devdocs/LSP11BasicSocialRecoveryInit.json +0 -159
- package/devdocs/LSP16UniversalFactory.json +0 -116
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +0 -34
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +0 -33
- package/devdocs/LSP23LinkedContractsFactory.json +0 -81
- package/devdocs/LSP4DigitalAssetMetadata.json +0 -112
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +0 -104
- package/devdocs/LSP6KeyManager.json +0 -305
- package/devdocs/LSP6KeyManagerInit.json +0 -308
- package/devdocs/LSP7CappedSupply.json +0 -306
- package/devdocs/LSP7CappedSupplyInitAbstract.json +0 -299
- package/devdocs/LSP7CompatibleERC20.json +0 -346
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +0 -338
- package/devdocs/LSP7CompatibleERC20Mintable.json +0 -349
- package/devdocs/LSP7CompatibleERC20MintableInit.json +0 -352
- package/devdocs/LSP7DigitalAsset.json +0 -294
- package/devdocs/LSP7DigitalAssetInitAbstract.json +0 -285
- package/devdocs/LSP7Mintable.json +0 -296
- package/devdocs/LSP7MintableInit.json +0 -298
- package/devdocs/LSP8CappedSupply.json +0 -356
- package/devdocs/LSP8CappedSupplyInitAbstract.json +0 -349
- package/devdocs/LSP8CompatibleERC721.json +0 -437
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +0 -428
- package/devdocs/LSP8CompatibleERC721Mintable.json +0 -446
- package/devdocs/LSP8CompatibleERC721MintableInit.json +0 -449
- package/devdocs/LSP8IdentifiableDigitalAsset.json +0 -346
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +0 -335
- package/devdocs/LSP8Mintable.json +0 -356
- package/devdocs/LSP8MintableInit.json +0 -359
- package/devdocs/LSP9Vault.json +0 -236
- package/devdocs/LSP9VaultInit.json +0 -239
- package/devdocs/UniversalProfile.json +0 -260
- package/devdocs/UniversalProfileInit.json +0 -263
- package/devdocs/UniversalReceiverAddressStore.json +0 -9
- package/dist/constants.cjs.js +0 -40758
- package/dist/constants.es.js +0 -40737
- package/userdocs/Create2Factory.json +0 -5
- package/userdocs/LSP0ERC725Account.json +0 -91
- package/userdocs/LSP0ERC725AccountInit.json +0 -94
- package/userdocs/LSP11BasicSocialRecovery.json +0 -29
- package/userdocs/LSP11BasicSocialRecoveryInit.json +0 -29
- package/userdocs/LSP16UniversalFactory.json +0 -30
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +0 -19
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +0 -19
- package/userdocs/LSP23LinkedContractsFactory.json +0 -29
- package/userdocs/LSP4DigitalAssetMetadata.json +0 -26
- package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +0 -23
- package/userdocs/LSP6KeyManager.json +0 -154
- package/userdocs/LSP6KeyManagerInit.json +0 -157
- package/userdocs/LSP7CappedSupply.json +0 -60
- package/userdocs/LSP7CappedSupplyInitAbstract.json +0 -57
- package/userdocs/LSP7CompatibleERC20.json +0 -47
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +0 -44
- package/userdocs/LSP7CompatibleERC20Mintable.json +0 -47
- package/userdocs/LSP7CompatibleERC20MintableInit.json +0 -47
- package/userdocs/LSP7DigitalAsset.json +0 -47
- package/userdocs/LSP7DigitalAssetInitAbstract.json +0 -44
- package/userdocs/LSP7Mintable.json +0 -47
- package/userdocs/LSP7MintableInit.json +0 -47
- package/userdocs/LSP8CappedSupply.json +0 -66
- package/userdocs/LSP8CappedSupplyInitAbstract.json +0 -63
- package/userdocs/LSP8CompatibleERC721.json +0 -80
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +0 -77
- package/userdocs/LSP8CompatibleERC721Mintable.json +0 -83
- package/userdocs/LSP8CompatibleERC721MintableInit.json +0 -83
- package/userdocs/LSP8IdentifiableDigitalAsset.json +0 -53
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +0 -50
- package/userdocs/LSP8Mintable.json +0 -56
- package/userdocs/LSP8MintableInit.json +0 -56
- package/userdocs/LSP9Vault.json +0 -93
- package/userdocs/LSP9VaultInit.json +0 -93
- package/userdocs/UniversalProfile.json +0 -91
- package/userdocs/UniversalProfileInit.json +0 -94
- package/userdocs/UniversalReceiverAddressStore.json +0 -5
|
@@ -1,697 +1,4 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
|
|
6
|
-
import {
|
|
7
|
-
IERC725X
|
|
8
|
-
} from "@erc725/smart-contracts/contracts/interfaces/IERC725X.sol";
|
|
9
|
-
import {
|
|
10
|
-
IERC725Y
|
|
11
|
-
} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
12
|
-
import {ILSP6KeyManager as ILSP6} from "./ILSP6KeyManager.sol";
|
|
13
|
-
import {
|
|
14
|
-
ILSP20CallVerifier as ILSP20
|
|
15
|
-
} from "../LSP20CallVerification/ILSP20CallVerifier.sol";
|
|
16
|
-
import {
|
|
17
|
-
ILSP25ExecuteRelayCall as ILSP25
|
|
18
|
-
} from "../LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol";
|
|
19
|
-
|
|
20
|
-
// modules
|
|
21
|
-
import {ILSP14Ownable2Step} from "../LSP14Ownable2Step/ILSP14Ownable2Step.sol";
|
|
22
|
-
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
23
|
-
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
24
|
-
import {LSP6SetDataModule} from "./LSP6Modules/LSP6SetDataModule.sol";
|
|
25
|
-
import {LSP6ExecuteModule} from "./LSP6Modules/LSP6ExecuteModule.sol";
|
|
26
|
-
import {
|
|
27
|
-
LSP6ExecuteRelayCallModule
|
|
28
|
-
} from "./LSP6Modules/LSP6ExecuteRelayCallModule.sol";
|
|
29
|
-
import {LSP6OwnershipModule} from "./LSP6Modules/LSP6OwnershipModule.sol";
|
|
30
|
-
import {
|
|
31
|
-
LSP25MultiChannelNonce
|
|
32
|
-
} from "../LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol";
|
|
33
|
-
|
|
34
|
-
// libraries
|
|
35
|
-
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
36
|
-
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
37
|
-
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
38
|
-
import {LSP6Utils} from "./LSP6Utils.sol";
|
|
39
|
-
|
|
40
|
-
// errors
|
|
41
|
-
import {
|
|
42
|
-
ERC725X_ExecuteParametersLengthMismatch,
|
|
43
|
-
ERC725X_ExecuteParametersEmptyArray
|
|
44
|
-
} from "@erc725/smart-contracts/contracts/errors.sol";
|
|
45
|
-
import {
|
|
46
|
-
BatchExecuteParamsLengthMismatch,
|
|
47
|
-
BatchExecuteRelayCallParamsLengthMismatch,
|
|
48
|
-
LSP6BatchExcessiveValueSent,
|
|
49
|
-
LSP6BatchInsufficientValueSent,
|
|
50
|
-
InvalidPayload,
|
|
51
|
-
InvalidRelayNonce,
|
|
52
|
-
NoPermissionsSet,
|
|
53
|
-
InvalidERC725Function
|
|
54
|
-
} from "./LSP6Errors.sol";
|
|
55
|
-
|
|
56
|
-
import {
|
|
57
|
-
_INTERFACEID_ERC1271,
|
|
58
|
-
_ERC1271_SUCCESSVALUE,
|
|
59
|
-
_ERC1271_FAILVALUE
|
|
60
|
-
} from "../LSP0ERC725Account/LSP0Constants.sol";
|
|
61
|
-
import {
|
|
62
|
-
_INTERFACEID_LSP6,
|
|
63
|
-
_PERMISSION_SIGN,
|
|
64
|
-
_PERMISSION_REENTRANCY
|
|
65
|
-
} from "./LSP6Constants.sol";
|
|
66
|
-
import {
|
|
67
|
-
_INTERFACEID_LSP20_CALL_VERIFIER,
|
|
68
|
-
_LSP20_VERIFY_CALL_SUCCESS_VALUE_WITHOUT_POST_VERIFICATION,
|
|
69
|
-
_LSP20_VERIFY_CALL_SUCCESS_VALUE_WITH_POST_VERIFICATION,
|
|
70
|
-
_LSP20_VERIFY_CALL_RESULT_SUCCESS_VALUE
|
|
71
|
-
} from "../LSP20CallVerification/LSP20Constants.sol";
|
|
72
|
-
import {_INTERFACEID_LSP25} from "../LSP25ExecuteRelayCall/LSP25Constants.sol";
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @title Core implementation of the LSP6 Key Manager standard.
|
|
76
|
-
* @author Fabian Vogelsteller <frozeman>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
|
|
77
|
-
* @dev This contract acts as a controller for an ERC725 Account.
|
|
78
|
-
* Permissions for controllers are stored in the ERC725Y storage of the ERC725 Account and can be updated using `setData(...)`.
|
|
79
|
-
*
|
|
80
|
-
* @custom:danger Because of its potential malicious impact on the linked contract, the current implementation of the Key Manager
|
|
81
|
-
* disallows the operation type **[DELEGATECALL](../universal-profile/lsp6-key-manager.md#permissions-value)** operation via the
|
|
82
|
-
* `execute(...)` function of the linked contract.
|
|
83
|
-
*/
|
|
84
|
-
abstract contract LSP6KeyManagerCore is
|
|
85
|
-
ERC165,
|
|
86
|
-
IERC1271,
|
|
87
|
-
ILSP6,
|
|
88
|
-
ILSP20,
|
|
89
|
-
ILSP25,
|
|
90
|
-
LSP6SetDataModule,
|
|
91
|
-
LSP6ExecuteModule,
|
|
92
|
-
LSP6ExecuteRelayCallModule,
|
|
93
|
-
LSP6OwnershipModule,
|
|
94
|
-
LSP25MultiChannelNonce
|
|
95
|
-
{
|
|
96
|
-
using LSP6Utils for *;
|
|
97
|
-
using ECDSA for *;
|
|
98
|
-
using BytesLib for bytes;
|
|
99
|
-
|
|
100
|
-
address internal _target;
|
|
101
|
-
|
|
102
|
-
mapping(address => bool) internal _reentrancyStatus;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @inheritdoc ILSP6
|
|
106
|
-
*/
|
|
107
|
-
function target() public view override returns (address) {
|
|
108
|
-
return _target;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @inheritdoc ERC165
|
|
113
|
-
*/
|
|
114
|
-
function supportsInterface(
|
|
115
|
-
bytes4 interfaceId
|
|
116
|
-
) public view virtual override returns (bool) {
|
|
117
|
-
return
|
|
118
|
-
interfaceId == _INTERFACEID_LSP6 ||
|
|
119
|
-
interfaceId == _INTERFACEID_ERC1271 ||
|
|
120
|
-
interfaceId == _INTERFACEID_LSP20_CALL_VERIFIER ||
|
|
121
|
-
interfaceId == _INTERFACEID_LSP25 ||
|
|
122
|
-
super.supportsInterface(interfaceId);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @inheritdoc ILSP25
|
|
127
|
-
*
|
|
128
|
-
* @custom:hint A signer can choose its channel number arbitrarily. The recommended practice is to:
|
|
129
|
-
* - use `channelId == 0` for transactions for which the ordering of execution matters.abi
|
|
130
|
-
*
|
|
131
|
-
* _Example: you have two transactions A and B, and transaction A must be executed first and complete successfully before
|
|
132
|
-
* transaction B should be executed)._
|
|
133
|
-
*
|
|
134
|
-
* - use any other `channelId` number for transactions that you want to be order independant (out-of-order execution, execution _"in parallel"_).
|
|
135
|
-
*
|
|
136
|
-
* _Example: you have two transactions A and B. You want transaction B to be executed a) without having to wait for transaction A to complete,
|
|
137
|
-
* or b) regardless if transaction A completed successfully or not.
|
|
138
|
-
*/
|
|
139
|
-
function getNonce(
|
|
140
|
-
address from,
|
|
141
|
-
uint128 channelId
|
|
142
|
-
) public view virtual override returns (uint256) {
|
|
143
|
-
return LSP25MultiChannelNonce._getNonce(from, channelId);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @inheritdoc IERC1271
|
|
148
|
-
*
|
|
149
|
-
* @dev Checks if a signature was signed by a controller that has the permission `SIGN`.
|
|
150
|
-
* If the signer is a controller with the permission `SIGN`, it will return the ERC1271 success value.
|
|
151
|
-
*
|
|
152
|
-
* @return returnedStatus `0x1626ba7e` on success, or `0xffffffff` on failure.
|
|
153
|
-
*
|
|
154
|
-
* @custom:warning This function does not enforce by default the inclusion of the address of this contract in the signature digest.
|
|
155
|
-
* It is recommended that protocols or applications using this contract include the targeted address (= this contract) in the data to sign.
|
|
156
|
-
* To ensure that a signature is valid for a specific LSP6KeyManager and prevent signatures from the same EOA to be replayed
|
|
157
|
-
* across different LSP6KeyManager.
|
|
158
|
-
*/
|
|
159
|
-
function isValidSignature(
|
|
160
|
-
bytes32 dataHash,
|
|
161
|
-
bytes memory signature
|
|
162
|
-
) public view virtual override returns (bytes4 returnedStatus) {
|
|
163
|
-
// if isValidSignature fail, the error is catched in returnedError
|
|
164
|
-
(address recoveredAddress, ECDSA.RecoverError returnedError) = ECDSA
|
|
165
|
-
.tryRecover(dataHash, signature);
|
|
166
|
-
|
|
167
|
-
// if recovering throws an error, return the fail value
|
|
168
|
-
if (returnedError != ECDSA.RecoverError.NoError)
|
|
169
|
-
return _ERC1271_FAILVALUE;
|
|
170
|
-
|
|
171
|
-
// if the address recovered has SIGN permission return the ERC1271 success value, otherwise the fail value
|
|
172
|
-
return (
|
|
173
|
-
ERC725Y(_target).getPermissionsFor(recoveredAddress).hasPermission(
|
|
174
|
-
_PERMISSION_SIGN
|
|
175
|
-
)
|
|
176
|
-
? _ERC1271_SUCCESSVALUE
|
|
177
|
-
: _ERC1271_FAILVALUE
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* @inheritdoc ILSP6
|
|
183
|
-
*
|
|
184
|
-
* @custom:events {PermissionsVerified} event when the permissions related to `payload` have been verified successfully.
|
|
185
|
-
*/
|
|
186
|
-
function execute(
|
|
187
|
-
bytes calldata payload
|
|
188
|
-
) public payable virtual override returns (bytes memory) {
|
|
189
|
-
return _execute(msg.value, payload);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @inheritdoc ILSP6
|
|
194
|
-
*
|
|
195
|
-
* @custom:events {PermissionsVerified} event for each permissions related to each `payload` that have been verified successfully.
|
|
196
|
-
*/
|
|
197
|
-
function executeBatch(
|
|
198
|
-
uint256[] calldata values,
|
|
199
|
-
bytes[] calldata payloads
|
|
200
|
-
) public payable virtual override returns (bytes[] memory) {
|
|
201
|
-
if (values.length != payloads.length) {
|
|
202
|
-
revert BatchExecuteParamsLengthMismatch();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
bytes[] memory results = new bytes[](payloads.length);
|
|
206
|
-
uint256 totalValues;
|
|
207
|
-
|
|
208
|
-
for (uint256 ii; ii < payloads.length; ) {
|
|
209
|
-
if ((totalValues += values[ii]) > msg.value) {
|
|
210
|
-
revert LSP6BatchInsufficientValueSent(totalValues, msg.value);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
results[ii] = _execute(values[ii], payloads[ii]);
|
|
214
|
-
|
|
215
|
-
unchecked {
|
|
216
|
-
++ii;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (totalValues < msg.value) {
|
|
221
|
-
revert LSP6BatchExcessiveValueSent(totalValues, msg.value);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return results;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* @inheritdoc ILSP25
|
|
229
|
-
*
|
|
230
|
-
* @dev Allows any address (executor) to execute a payload (= abi-encoded function call), given they have a valid signature from a signer address and a valid `nonce` for this signer.
|
|
231
|
-
* The signature MUST be generated according to the signature format defined by the LSP25 standard.
|
|
232
|
-
*
|
|
233
|
-
* The signer that generated the `signature` MUST be a controller with some permissions on the linked {target}.
|
|
234
|
-
* The `payload` will be executed on the {target} contract once the LSP25 signature and the permissions of the signer have been verified.
|
|
235
|
-
*
|
|
236
|
-
* @custom:events {PermissionsVerified} event when the permissions related to `payload` have been verified successfully.
|
|
237
|
-
*
|
|
238
|
-
* @custom:hint If you are looking to learn how to sign and execute relay transactions via the Key Manager,
|
|
239
|
-
* see our Javascript step by step guide [_"Execute Relay Transactions"_](../../../learn/expert-guides/key-manager/execute-relay-transactions.md).
|
|
240
|
-
* See the LSP6 Standard page for more details on how to
|
|
241
|
-
* [generate a valid signature for Execute Relay Call](../../../standards/universal-profile/lsp6-key-manager.md#how-to-sign-relay-transactions).
|
|
242
|
-
*/
|
|
243
|
-
function executeRelayCall(
|
|
244
|
-
bytes memory signature,
|
|
245
|
-
uint256 nonce,
|
|
246
|
-
uint256 validityTimestamps,
|
|
247
|
-
bytes calldata payload
|
|
248
|
-
) public payable virtual override returns (bytes memory) {
|
|
249
|
-
return
|
|
250
|
-
_executeRelayCall(
|
|
251
|
-
signature,
|
|
252
|
-
nonce,
|
|
253
|
-
validityTimestamps,
|
|
254
|
-
msg.value,
|
|
255
|
-
payload
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* @inheritdoc ILSP25
|
|
261
|
-
*
|
|
262
|
-
* @dev Same as {executeRelayCall} but execute a batch of signed calldata payloads (abi-encoded function calls) in a single transaction.
|
|
263
|
-
*
|
|
264
|
-
* The `signatures` can be from multiple controllers, not necessarely the same controller, as long as each of these controllers
|
|
265
|
-
* that signed have the right permissions related to the calldata `payload` they signed.
|
|
266
|
-
*
|
|
267
|
-
* @custom:requirements
|
|
268
|
-
* - the length of `signatures`, `nonces`, `validityTimestamps`, `values` and `payloads` MUST be the same.
|
|
269
|
-
* - the value sent to this function (`msg.value`) MUST be equal to the sum of all `values` in the batch.
|
|
270
|
-
* There should not be any excess value sent to this function.
|
|
271
|
-
*/
|
|
272
|
-
function executeRelayCallBatch(
|
|
273
|
-
bytes[] memory signatures,
|
|
274
|
-
uint256[] calldata nonces,
|
|
275
|
-
uint256[] calldata validityTimestamps,
|
|
276
|
-
uint256[] calldata values,
|
|
277
|
-
bytes[] calldata payloads
|
|
278
|
-
) public payable virtual override returns (bytes[] memory) {
|
|
279
|
-
if (
|
|
280
|
-
signatures.length != nonces.length ||
|
|
281
|
-
nonces.length != validityTimestamps.length ||
|
|
282
|
-
validityTimestamps.length != values.length ||
|
|
283
|
-
values.length != payloads.length
|
|
284
|
-
) {
|
|
285
|
-
revert BatchExecuteRelayCallParamsLengthMismatch();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
bytes[] memory results = new bytes[](payloads.length);
|
|
289
|
-
uint256 totalValues;
|
|
290
|
-
|
|
291
|
-
for (uint256 ii; ii < payloads.length; ) {
|
|
292
|
-
if ((totalValues += values[ii]) > msg.value) {
|
|
293
|
-
revert LSP6BatchInsufficientValueSent(totalValues, msg.value);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
results[ii] = _executeRelayCall(
|
|
297
|
-
signatures[ii],
|
|
298
|
-
nonces[ii],
|
|
299
|
-
validityTimestamps[ii],
|
|
300
|
-
values[ii],
|
|
301
|
-
payloads[ii]
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
unchecked {
|
|
305
|
-
++ii;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (totalValues < msg.value) {
|
|
310
|
-
revert LSP6BatchExcessiveValueSent(totalValues, msg.value);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return results;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* @inheritdoc ILSP20
|
|
318
|
-
*
|
|
319
|
-
* @custom:hint This function can call by any other address than the {`target`}.
|
|
320
|
-
* This allows to verify permissions in a _"read-only"_ manner.
|
|
321
|
-
*
|
|
322
|
-
* Anyone can call this function to verify if the `caller` has the right permissions to perform the abi-encoded function call `data`
|
|
323
|
-
* on the {`target`} contract (while sending `msgValue` alongside the call).
|
|
324
|
-
*
|
|
325
|
-
* If the permissions have been verified successfully and `caller` is authorized, one of the following two LSP20 success value will be returned:
|
|
326
|
-
* - `0x1a238000`: LSP20 success value **without** post verification (last byte is `0x00`).
|
|
327
|
-
* - `0x1a238001`: LSP20 success value **with** post-verification (last byte is `0x01`).
|
|
328
|
-
*/
|
|
329
|
-
function lsp20VerifyCall(
|
|
330
|
-
address /* requestor */,
|
|
331
|
-
address targetContract,
|
|
332
|
-
address caller,
|
|
333
|
-
uint256 msgValue,
|
|
334
|
-
bytes calldata callData
|
|
335
|
-
) external virtual override returns (bytes4) {
|
|
336
|
-
bool isSetData = bytes4(callData) == IERC725Y.setData.selector ||
|
|
337
|
-
bytes4(callData) == IERC725Y.setDataBatch.selector;
|
|
338
|
-
|
|
339
|
-
// If target is invoking the verification, emit the event and change the reentrancy guard
|
|
340
|
-
if (msg.sender == targetContract) {
|
|
341
|
-
bool reentrancyStatus = _nonReentrantBefore(
|
|
342
|
-
targetContract,
|
|
343
|
-
isSetData,
|
|
344
|
-
caller
|
|
345
|
-
);
|
|
346
|
-
|
|
347
|
-
_verifyPermissions(targetContract, caller, false, callData);
|
|
348
|
-
|
|
349
|
-
emit PermissionsVerified(caller, msgValue, bytes4(callData));
|
|
350
|
-
|
|
351
|
-
// if it's a setData call, do not invoke the `lsp20VerifyCallResult(..)` function
|
|
352
|
-
return
|
|
353
|
-
isSetData || reentrancyStatus
|
|
354
|
-
? _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITHOUT_POST_VERIFICATION
|
|
355
|
-
: _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITH_POST_VERIFICATION;
|
|
356
|
-
}
|
|
357
|
-
/// @dev If a different address is invoking the verification,
|
|
358
|
-
/// do not change the state or emit the event to allow read-only verification
|
|
359
|
-
else {
|
|
360
|
-
bool reentrancyStatus = _reentrancyStatus[targetContract];
|
|
361
|
-
|
|
362
|
-
if (reentrancyStatus) {
|
|
363
|
-
_requirePermissions(
|
|
364
|
-
caller,
|
|
365
|
-
ERC725Y(targetContract).getPermissionsFor(caller),
|
|
366
|
-
_PERMISSION_REENTRANCY
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
_verifyPermissions(targetContract, caller, false, callData);
|
|
371
|
-
|
|
372
|
-
// if it's a setData call, do not invoke the `lsp20VerifyCallResult(..)` function
|
|
373
|
-
return
|
|
374
|
-
isSetData || reentrancyStatus
|
|
375
|
-
? _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITHOUT_POST_VERIFICATION
|
|
376
|
-
: _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITH_POST_VERIFICATION;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* @inheritdoc ILSP20
|
|
382
|
-
*/
|
|
383
|
-
function lsp20VerifyCallResult(
|
|
384
|
-
bytes32 /* callHash */,
|
|
385
|
-
bytes memory /* callResult */
|
|
386
|
-
) external virtual override returns (bytes4) {
|
|
387
|
-
// If it's the target calling, set back the reentrancy guard
|
|
388
|
-
// to false, if not return the success value
|
|
389
|
-
if (msg.sender == _target) {
|
|
390
|
-
_nonReentrantAfter(msg.sender);
|
|
391
|
-
}
|
|
392
|
-
return _LSP20_VERIFY_CALL_RESULT_SUCCESS_VALUE;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
function _execute(
|
|
396
|
-
uint256 msgValue,
|
|
397
|
-
bytes calldata payload
|
|
398
|
-
) internal virtual returns (bytes memory) {
|
|
399
|
-
if (payload.length < 4) {
|
|
400
|
-
revert InvalidPayload(payload);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
bool isSetData = bytes4(payload) == IERC725Y.setData.selector ||
|
|
404
|
-
bytes4(payload) == IERC725Y.setDataBatch.selector;
|
|
405
|
-
|
|
406
|
-
address targetContract = _target;
|
|
407
|
-
|
|
408
|
-
bool reentrancyStatus = _nonReentrantBefore(
|
|
409
|
-
targetContract,
|
|
410
|
-
isSetData,
|
|
411
|
-
msg.sender
|
|
412
|
-
);
|
|
413
|
-
|
|
414
|
-
_verifyPermissions(targetContract, msg.sender, false, payload);
|
|
415
|
-
|
|
416
|
-
emit PermissionsVerified(msg.sender, msgValue, bytes4(payload));
|
|
417
|
-
|
|
418
|
-
bytes memory result = _executePayload(
|
|
419
|
-
targetContract,
|
|
420
|
-
msgValue,
|
|
421
|
-
payload
|
|
422
|
-
);
|
|
423
|
-
|
|
424
|
-
if (!reentrancyStatus && !isSetData) {
|
|
425
|
-
_nonReentrantAfter(targetContract);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
return result;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* @dev Validate that the `nonce` given for the `signature` signed and the `payload` to execute is valid
|
|
433
|
-
* and conform to the signature format according to the LSP25 standard.
|
|
434
|
-
*
|
|
435
|
-
* @param signature A valid signature for a signer, generated according to the signature format specified in the LSP25 standard.
|
|
436
|
-
* @param nonce The nonce that the signer used to generate the `signature`.
|
|
437
|
-
* @param validityTimestamps Two `uint128` concatenated together, where the left-most `uint128` represent the timestamp from which the transaction can be executed,
|
|
438
|
-
* and the right-most `uint128` represents the timestamp after which the transaction expire.
|
|
439
|
-
* @param payload The abi-encoded function call to execute.
|
|
440
|
-
*
|
|
441
|
-
* @custom:warning Be aware that this function can also throw an error if the `callData` was signed incorrectly (not conforming to the signature format defined in the LSP25 standard).
|
|
442
|
-
* This is because the contract cannot distinguish if the data is signed correctly or not. Instead, it will recover an incorrect signer address from the signature
|
|
443
|
-
* and throw an {InvalidRelayNonce} error with the incorrect signer address as the first parameter.
|
|
444
|
-
*/
|
|
445
|
-
function _executeRelayCall(
|
|
446
|
-
bytes memory signature,
|
|
447
|
-
uint256 nonce,
|
|
448
|
-
uint256 validityTimestamps,
|
|
449
|
-
uint256 msgValue,
|
|
450
|
-
bytes calldata payload
|
|
451
|
-
) internal virtual returns (bytes memory) {
|
|
452
|
-
if (payload.length < 4) {
|
|
453
|
-
revert InvalidPayload(payload);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
address targetContract = _target;
|
|
457
|
-
|
|
458
|
-
address signer = LSP25MultiChannelNonce
|
|
459
|
-
._recoverSignerFromLSP25Signature(
|
|
460
|
-
signature,
|
|
461
|
-
nonce,
|
|
462
|
-
validityTimestamps,
|
|
463
|
-
msgValue,
|
|
464
|
-
payload
|
|
465
|
-
);
|
|
466
|
-
|
|
467
|
-
if (!_isValidNonce(signer, nonce)) {
|
|
468
|
-
revert InvalidRelayNonce(signer, nonce, signature);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// increase nonce after successful verification
|
|
472
|
-
_nonceStore[signer][nonce >> 128]++;
|
|
473
|
-
|
|
474
|
-
LSP25MultiChannelNonce._verifyValidityTimestamps(validityTimestamps);
|
|
475
|
-
|
|
476
|
-
bool isSetData = bytes4(payload) == IERC725Y.setData.selector ||
|
|
477
|
-
bytes4(payload) == IERC725Y.setDataBatch.selector;
|
|
478
|
-
|
|
479
|
-
bool reentrancyStatus = _nonReentrantBefore(
|
|
480
|
-
targetContract,
|
|
481
|
-
isSetData,
|
|
482
|
-
signer
|
|
483
|
-
);
|
|
484
|
-
|
|
485
|
-
_verifyPermissions(targetContract, signer, true, payload);
|
|
486
|
-
|
|
487
|
-
emit PermissionsVerified(signer, msgValue, bytes4(payload));
|
|
488
|
-
|
|
489
|
-
bytes memory result = _executePayload(
|
|
490
|
-
targetContract,
|
|
491
|
-
msgValue,
|
|
492
|
-
payload
|
|
493
|
-
);
|
|
494
|
-
|
|
495
|
-
if (!reentrancyStatus && !isSetData) {
|
|
496
|
-
_nonReentrantAfter(targetContract);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
return result;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* @notice Execute the `payload` passed to `execute(...)` or `executeRelayCall(...)`
|
|
504
|
-
* @param payload The abi-encoded function call to execute on the {target} contract.
|
|
505
|
-
* @return bytes The data returned by the call made to the linked {target} contract.
|
|
506
|
-
*/
|
|
507
|
-
function _executePayload(
|
|
508
|
-
address targetContract,
|
|
509
|
-
uint256 msgValue,
|
|
510
|
-
bytes calldata payload
|
|
511
|
-
) internal virtual returns (bytes memory) {
|
|
512
|
-
(bool success, bytes memory returnData) = targetContract.call{
|
|
513
|
-
value: msgValue,
|
|
514
|
-
gas: gasleft()
|
|
515
|
-
}(payload);
|
|
516
|
-
|
|
517
|
-
bytes memory result = Address.verifyCallResult(
|
|
518
|
-
success,
|
|
519
|
-
returnData,
|
|
520
|
-
"LSP6: failed executing payload"
|
|
521
|
-
);
|
|
522
|
-
|
|
523
|
-
return result;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* @dev Verify if the `from` address is allowed to execute the `payload` on the {target} contract linked to this Key Manager.
|
|
528
|
-
* @param targetContract The contract that is owned by the Key Manager
|
|
529
|
-
* @param from Either the caller of {execute} or the signer of {executeRelayCall}.
|
|
530
|
-
* @param payload The abi-encoded function call to execute on the {target} contract.
|
|
531
|
-
*/
|
|
532
|
-
function _verifyPermissions(
|
|
533
|
-
address targetContract,
|
|
534
|
-
address from,
|
|
535
|
-
bool isRelayedCall,
|
|
536
|
-
bytes calldata payload
|
|
537
|
-
) internal view virtual {
|
|
538
|
-
bytes32 permissions = ERC725Y(targetContract).getPermissionsFor(from);
|
|
539
|
-
if (permissions == bytes32(0)) revert NoPermissionsSet(from);
|
|
540
|
-
|
|
541
|
-
if (isRelayedCall) {
|
|
542
|
-
LSP6ExecuteRelayCallModule._verifyExecuteRelayCallPermission(
|
|
543
|
-
from,
|
|
544
|
-
permissions
|
|
545
|
-
);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
bytes4 erc725Function = bytes4(payload);
|
|
549
|
-
|
|
550
|
-
// ERC725Y.setData(bytes32,bytes)
|
|
551
|
-
if (erc725Function == IERC725Y.setData.selector) {
|
|
552
|
-
(bytes32 inputKey, bytes memory inputValue) = abi.decode(
|
|
553
|
-
payload[4:],
|
|
554
|
-
(bytes32, bytes)
|
|
555
|
-
);
|
|
556
|
-
|
|
557
|
-
LSP6SetDataModule._verifyCanSetData(
|
|
558
|
-
targetContract,
|
|
559
|
-
from,
|
|
560
|
-
permissions,
|
|
561
|
-
inputKey,
|
|
562
|
-
inputValue
|
|
563
|
-
);
|
|
564
|
-
|
|
565
|
-
// ERC725Y.setDataBatch(bytes32[],bytes[])
|
|
566
|
-
} else if (erc725Function == IERC725Y.setDataBatch.selector) {
|
|
567
|
-
(bytes32[] memory inputKeys, bytes[] memory inputValues) = abi
|
|
568
|
-
.decode(payload[4:], (bytes32[], bytes[]));
|
|
569
|
-
|
|
570
|
-
LSP6SetDataModule._verifyCanSetData(
|
|
571
|
-
targetContract,
|
|
572
|
-
from,
|
|
573
|
-
permissions,
|
|
574
|
-
inputKeys,
|
|
575
|
-
inputValues
|
|
576
|
-
);
|
|
577
|
-
|
|
578
|
-
// ERC725X.execute(uint256,address,uint256,bytes)
|
|
579
|
-
} else if (erc725Function == IERC725X.execute.selector) {
|
|
580
|
-
(
|
|
581
|
-
uint256 operationType,
|
|
582
|
-
address to,
|
|
583
|
-
uint256 value,
|
|
584
|
-
bytes memory callData
|
|
585
|
-
) = abi.decode(payload[4:], (uint256, address, uint256, bytes));
|
|
586
|
-
|
|
587
|
-
LSP6ExecuteModule._verifyCanExecute(
|
|
588
|
-
targetContract,
|
|
589
|
-
from,
|
|
590
|
-
permissions,
|
|
591
|
-
operationType,
|
|
592
|
-
to,
|
|
593
|
-
value,
|
|
594
|
-
callData
|
|
595
|
-
);
|
|
596
|
-
} else if (erc725Function == IERC725X.executeBatch.selector) {
|
|
597
|
-
(
|
|
598
|
-
uint256[] memory operationTypes,
|
|
599
|
-
address[] memory targets,
|
|
600
|
-
uint256[] memory values,
|
|
601
|
-
bytes[] memory callDatas
|
|
602
|
-
) = abi.decode(
|
|
603
|
-
payload[4:],
|
|
604
|
-
(uint256[], address[], uint256[], bytes[])
|
|
605
|
-
);
|
|
606
|
-
|
|
607
|
-
if (
|
|
608
|
-
operationTypes.length != targets.length ||
|
|
609
|
-
targets.length != values.length ||
|
|
610
|
-
values.length != callDatas.length
|
|
611
|
-
) {
|
|
612
|
-
revert ERC725X_ExecuteParametersLengthMismatch();
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
if (operationTypes.length == 0) {
|
|
616
|
-
revert ERC725X_ExecuteParametersEmptyArray();
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
for (uint256 ii; ii < operationTypes.length; ii++) {
|
|
620
|
-
LSP6ExecuteModule._verifyCanExecute(
|
|
621
|
-
targetContract,
|
|
622
|
-
from,
|
|
623
|
-
permissions,
|
|
624
|
-
operationTypes[ii],
|
|
625
|
-
targets[ii],
|
|
626
|
-
values[ii],
|
|
627
|
-
callDatas[ii]
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
} else if (
|
|
631
|
-
erc725Function == ILSP14Ownable2Step.transferOwnership.selector ||
|
|
632
|
-
erc725Function == ILSP14Ownable2Step.acceptOwnership.selector ||
|
|
633
|
-
erc725Function == ILSP14Ownable2Step.renounceOwnership.selector
|
|
634
|
-
) {
|
|
635
|
-
LSP6OwnershipModule._verifyOwnershipPermissions(from, permissions);
|
|
636
|
-
} else {
|
|
637
|
-
revert InvalidERC725Function(erc725Function);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
* @dev Check if we are in the context of a reentrant call, by checking if the reentrancy status is `true`.
|
|
643
|
-
* - If the status is `true`, the caller (or signer for relay call) MUST have the `REENTRANCY` permission. Otherwise, the call is reverted.
|
|
644
|
-
* - If the status is `false`, it is set to `true` only if we are not dealing with a call to the functions `setData` or `setDataBatch`.
|
|
645
|
-
* Used at the beginning of the {`lsp20VerifyCall`}, {`_execute`} and {`_executeRelayCall`} functions, before the methods execution starts.
|
|
646
|
-
*
|
|
647
|
-
*/
|
|
648
|
-
function _nonReentrantBefore(
|
|
649
|
-
address targetContract,
|
|
650
|
-
bool isSetData,
|
|
651
|
-
address from
|
|
652
|
-
) internal virtual returns (bool reentrancyStatus) {
|
|
653
|
-
reentrancyStatus = _reentrancyStatus[targetContract];
|
|
654
|
-
|
|
655
|
-
if (reentrancyStatus) {
|
|
656
|
-
// CHECK the caller has REENTRANCY permission
|
|
657
|
-
_requirePermissions(
|
|
658
|
-
from,
|
|
659
|
-
ERC725Y(targetContract).getPermissionsFor(from),
|
|
660
|
-
_PERMISSION_REENTRANCY
|
|
661
|
-
);
|
|
662
|
-
} else {
|
|
663
|
-
if (!isSetData) {
|
|
664
|
-
_reentrancyStatus[targetContract] = true;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
/**
|
|
670
|
-
* @dev Resets the reentrancy status to `false`
|
|
671
|
-
* Used at the end of the {`lsp20VerifyCall`}, {`_execute`} and {`_executeRelayCall`} functions after the functions' execution is terminated.
|
|
672
|
-
*/
|
|
673
|
-
function _nonReentrantAfter(address targetContract) internal virtual {
|
|
674
|
-
// By storing the original value once again, a refund is triggered (see
|
|
675
|
-
// https://eips.ethereum.org/EIPS/eip-2200)
|
|
676
|
-
_reentrancyStatus[targetContract] = false;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
/**
|
|
680
|
-
* @dev Check if the `controller` has the `permissionRequired` among its permission listed in `controllerPermissions`
|
|
681
|
-
* If not, this function will revert with the error `NotAuthorised` and the name of the permission missing by the controller.
|
|
682
|
-
* @param controller the caller address
|
|
683
|
-
* @param addressPermissions the caller's permissions BitArray
|
|
684
|
-
* @param permissionRequired the required permission
|
|
685
|
-
*/
|
|
686
|
-
function _requirePermissions(
|
|
687
|
-
address controller,
|
|
688
|
-
bytes32 addressPermissions,
|
|
689
|
-
bytes32 permissionRequired
|
|
690
|
-
) internal pure override(LSP6ExecuteModule, LSP6SetDataModule) {
|
|
691
|
-
LSP6ExecuteModule._requirePermissions(
|
|
692
|
-
controller,
|
|
693
|
-
addressPermissions,
|
|
694
|
-
permissionRequired
|
|
695
|
-
);
|
|
696
|
-
}
|
|
697
|
-
}
|
|
4
|
+
import "@lukso/lsp6-contracts/contracts/LSP6KeyManagerCore.sol";
|