@lukso/lsp-smart-contracts 0.11.1 → 0.12.0-rc.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/CONTRIBUTING.md +4 -0
- package/README.md +10 -2
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +52 -25
- package/artifacts/LSP0ERC725AccountInit.json +52 -25
- package/artifacts/LSP11BasicSocialRecovery.json +18 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +18 -2
- package/artifacts/LSP16UniversalFactory.json +3 -3
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +14 -46
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +14 -46
- package/artifacts/LSP23LinkedContractsFactory.json +3 -3
- package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
- package/artifacts/LSP6KeyManager.json +14 -9
- package/artifacts/LSP6KeyManagerInit.json +14 -9
- package/artifacts/LSP7CappedSupply.json +29 -4
- package/artifacts/LSP7CappedSupplyInitAbstract.json +29 -4
- package/artifacts/LSP7CompatibleERC20.json +48 -23
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +48 -23
- package/artifacts/LSP7CompatibleERC20Mintable.json +51 -26
- package/artifacts/LSP7CompatibleERC20MintableInit.json +51 -26
- package/artifacts/LSP7DigitalAsset.json +29 -4
- package/artifacts/LSP7DigitalAssetInitAbstract.json +29 -4
- package/artifacts/LSP7Mintable.json +32 -7
- package/artifacts/LSP7MintableInit.json +32 -7
- package/artifacts/LSP8CappedSupply.json +33 -3
- package/artifacts/LSP8CappedSupplyInitAbstract.json +33 -3
- package/artifacts/LSP8CompatibleERC721.json +55 -25
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +55 -25
- package/artifacts/LSP8CompatibleERC721Mintable.json +63 -28
- package/artifacts/LSP8CompatibleERC721MintableInit.json +63 -28
- package/artifacts/LSP8IdentifiableDigitalAsset.json +33 -3
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +33 -3
- package/artifacts/LSP8Mintable.json +41 -6
- package/artifacts/LSP8MintableInit.json +41 -6
- package/artifacts/LSP9Vault.json +38 -16
- package/artifacts/LSP9VaultInit.json +38 -16
- package/artifacts/UniversalProfile.json +52 -25
- package/artifacts/UniversalProfileInit.json +52 -25
- package/contracts/Factories/Create2Factory.sol +1 -1
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +0 -14
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +122 -94
- 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 +10 -7
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +4 -4
- 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 +20 -27
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +18 -21
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +2 -46
- package/contracts/LSP20CallVerification/ILSP20CallVerifier.sol +13 -9
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +39 -14
- package/contracts/LSP20CallVerification/LSP20Constants.sol +6 -6
- package/contracts/LSP20CallVerification/LSP20Errors.sol +9 -3
- 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 +134 -99
- 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 +31 -25
- package/contracts/LSP6KeyManager/LSP6Utils.sol +29 -2
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +10 -10
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +22 -8
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +180 -118
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +21 -7
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +12 -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 +120 -53
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +122 -53
- 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 +11 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +12 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +32 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +61 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +113 -74
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +63 -10
- 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 +162 -73
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +168 -84
- 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 -13
- package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
- package/contracts/LSP9Vault/LSP9Errors.sol +1 -1
- package/contracts/LSP9Vault/LSP9VaultCore.sol +58 -41
- package/devdocs/LSP0ERC725Account.json +73 -45
- package/devdocs/LSP0ERC725AccountInit.json +73 -45
- package/devdocs/LSP11BasicSocialRecovery.json +13 -0
- package/devdocs/LSP11BasicSocialRecoveryInit.json +13 -0
- package/devdocs/LSP16UniversalFactory.json +9 -9
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +1 -6
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +1 -6
- package/devdocs/LSP4DigitalAssetMetadata.json +32 -10
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +32 -10
- package/devdocs/LSP6KeyManager.json +12 -14
- package/devdocs/LSP6KeyManagerInit.json +12 -14
- package/devdocs/LSP7CappedSupply.json +47 -20
- package/devdocs/LSP7CappedSupplyInitAbstract.json +47 -20
- package/devdocs/LSP7CompatibleERC20.json +88 -24
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +88 -24
- package/devdocs/LSP7CompatibleERC20Mintable.json +88 -24
- package/devdocs/LSP7CompatibleERC20MintableInit.json +88 -24
- package/devdocs/LSP7DigitalAsset.json +47 -20
- package/devdocs/LSP7DigitalAssetInitAbstract.json +47 -20
- package/devdocs/LSP7Mintable.json +47 -20
- package/devdocs/LSP7MintableInit.json +47 -20
- package/devdocs/LSP8CappedSupply.json +57 -25
- package/devdocs/LSP8CappedSupplyInitAbstract.json +57 -25
- package/devdocs/LSP8CompatibleERC721.json +84 -31
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +84 -31
- package/devdocs/LSP8CompatibleERC721Mintable.json +86 -33
- package/devdocs/LSP8CompatibleERC721MintableInit.json +87 -34
- package/devdocs/LSP8IdentifiableDigitalAsset.json +61 -26
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -25
- package/devdocs/LSP8Mintable.json +59 -27
- package/devdocs/LSP8MintableInit.json +60 -28
- package/devdocs/LSP9Vault.json +57 -35
- package/devdocs/LSP9VaultInit.json +57 -35
- package/devdocs/UniversalProfile.json +73 -45
- package/devdocs/UniversalProfileInit.json +73 -45
- package/dist/constants.cjs.js +4323 -2361
- package/dist/constants.d.ts +2933 -1022
- package/dist/constants.es.js +4322 -2361
- package/package.json +8 -6
- package/userdocs/LSP0ERC725Account.json +17 -8
- package/userdocs/LSP0ERC725AccountInit.json +17 -8
- package/userdocs/LSP16UniversalFactory.json +26 -1
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +1 -11
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +1 -11
- package/userdocs/LSP4DigitalAssetMetadata.json +7 -4
- package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -4
- package/userdocs/LSP6KeyManager.json +0 -5
- package/userdocs/LSP6KeyManagerInit.json +0 -5
- package/userdocs/LSP7CappedSupply.json +14 -6
- package/userdocs/LSP7CappedSupplyInitAbstract.json +13 -5
- package/userdocs/LSP7CompatibleERC20.json +15 -5
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +15 -5
- package/userdocs/LSP7CompatibleERC20Mintable.json +15 -5
- package/userdocs/LSP7CompatibleERC20MintableInit.json +15 -5
- package/userdocs/LSP7DigitalAsset.json +15 -5
- package/userdocs/LSP7DigitalAssetInitAbstract.json +15 -5
- package/userdocs/LSP7Mintable.json +15 -5
- package/userdocs/LSP7MintableInit.json +15 -5
- package/userdocs/LSP8CappedSupply.json +13 -5
- package/userdocs/LSP8CappedSupplyInitAbstract.json +12 -4
- package/userdocs/LSP8CompatibleERC721.json +27 -17
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +27 -17
- package/userdocs/LSP8CompatibleERC721Mintable.json +28 -18
- package/userdocs/LSP8CompatibleERC721MintableInit.json +29 -19
- package/userdocs/LSP8IdentifiableDigitalAsset.json +15 -5
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +14 -4
- package/userdocs/LSP8Mintable.json +15 -5
- package/userdocs/LSP8MintableInit.json +16 -6
- package/userdocs/LSP9Vault.json +20 -11
- package/userdocs/LSP9VaultInit.json +20 -11
- package/userdocs/UniversalProfile.json +17 -8
- package/userdocs/UniversalProfileInit.json +17 -8
- 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
|
@@ -23,6 +23,9 @@ import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
|
23
23
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
24
24
|
import {LSP6SetDataModule} from "./LSP6Modules/LSP6SetDataModule.sol";
|
|
25
25
|
import {LSP6ExecuteModule} from "./LSP6Modules/LSP6ExecuteModule.sol";
|
|
26
|
+
import {
|
|
27
|
+
LSP6ExecuteRelayCallModule
|
|
28
|
+
} from "./LSP6Modules/LSP6ExecuteRelayCallModule.sol";
|
|
26
29
|
import {LSP6OwnershipModule} from "./LSP6Modules/LSP6OwnershipModule.sol";
|
|
27
30
|
import {
|
|
28
31
|
LSP25MultiChannelNonce
|
|
@@ -43,13 +46,12 @@ import {
|
|
|
43
46
|
InvalidPayload,
|
|
44
47
|
InvalidRelayNonce,
|
|
45
48
|
NoPermissionsSet,
|
|
46
|
-
InvalidERC725Function
|
|
47
|
-
CannotSendValueToSetData
|
|
49
|
+
InvalidERC725Function
|
|
48
50
|
} from "./LSP6Errors.sol";
|
|
49
51
|
|
|
50
52
|
import {
|
|
51
53
|
_INTERFACEID_ERC1271,
|
|
52
|
-
|
|
54
|
+
_ERC1271_SUCCESSVALUE,
|
|
53
55
|
_ERC1271_FAILVALUE
|
|
54
56
|
} from "../LSP0ERC725Account/LSP0Constants.sol";
|
|
55
57
|
import {
|
|
@@ -57,7 +59,12 @@ import {
|
|
|
57
59
|
_PERMISSION_SIGN,
|
|
58
60
|
_PERMISSION_REENTRANCY
|
|
59
61
|
} from "./LSP6Constants.sol";
|
|
60
|
-
import
|
|
62
|
+
import {
|
|
63
|
+
_INTERFACEID_LSP20_CALL_VERIFIER,
|
|
64
|
+
_LSP20_VERIFY_CALL_SUCCESS_VALUE_WITHOUT_POST_VERIFICATION,
|
|
65
|
+
_LSP20_VERIFY_CALL_SUCCESS_VALUE_WITH_POST_VERIFICATION,
|
|
66
|
+
_LSP20_VERIFY_CALL_RESULT_SUCCESS_VALUE
|
|
67
|
+
} from "../LSP20CallVerification/LSP20Constants.sol";
|
|
61
68
|
import {_INTERFACEID_LSP25} from "../LSP25ExecuteRelayCall/LSP25Constants.sol";
|
|
62
69
|
|
|
63
70
|
/**
|
|
@@ -72,11 +79,13 @@ import {_INTERFACEID_LSP25} from "../LSP25ExecuteRelayCall/LSP25Constants.sol";
|
|
|
72
79
|
*/
|
|
73
80
|
abstract contract LSP6KeyManagerCore is
|
|
74
81
|
ERC165,
|
|
82
|
+
IERC1271,
|
|
75
83
|
ILSP6,
|
|
76
84
|
ILSP20,
|
|
77
85
|
ILSP25,
|
|
78
86
|
LSP6SetDataModule,
|
|
79
87
|
LSP6ExecuteModule,
|
|
88
|
+
LSP6ExecuteRelayCallModule,
|
|
80
89
|
LSP6OwnershipModule,
|
|
81
90
|
LSP25MultiChannelNonce
|
|
82
91
|
{
|
|
@@ -86,14 +95,12 @@ abstract contract LSP6KeyManagerCore is
|
|
|
86
95
|
|
|
87
96
|
address internal _target;
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.8/contracts/security/ReentrancyGuard.sol
|
|
91
|
-
bool internal _reentrancyStatus;
|
|
98
|
+
mapping(address => bool) internal _reentrancyStatus;
|
|
92
99
|
|
|
93
100
|
/**
|
|
94
101
|
* @inheritdoc ILSP6
|
|
95
102
|
*/
|
|
96
|
-
function target() public view returns (address) {
|
|
103
|
+
function target() public view override returns (address) {
|
|
97
104
|
return _target;
|
|
98
105
|
}
|
|
99
106
|
|
|
@@ -128,7 +135,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
128
135
|
function getNonce(
|
|
129
136
|
address from,
|
|
130
137
|
uint128 channelId
|
|
131
|
-
) public view virtual returns (uint256) {
|
|
138
|
+
) public view virtual override returns (uint256) {
|
|
132
139
|
return LSP25MultiChannelNonce._getNonce(from, channelId);
|
|
133
140
|
}
|
|
134
141
|
|
|
@@ -136,14 +143,14 @@ abstract contract LSP6KeyManagerCore is
|
|
|
136
143
|
* @inheritdoc IERC1271
|
|
137
144
|
*
|
|
138
145
|
* @dev Checks if a signature was signed by a controller that has the permission `SIGN`.
|
|
139
|
-
* If the signer is a controller with the permission `SIGN`, it will return the ERC1271
|
|
146
|
+
* If the signer is a controller with the permission `SIGN`, it will return the ERC1271 success value.
|
|
140
147
|
*
|
|
141
|
-
* @return
|
|
148
|
+
* @return returnedStatus `0x1626ba7e` on success, or `0xffffffff` on failure.
|
|
142
149
|
*/
|
|
143
150
|
function isValidSignature(
|
|
144
151
|
bytes32 dataHash,
|
|
145
152
|
bytes memory signature
|
|
146
|
-
) public view virtual returns (bytes4
|
|
153
|
+
) public view virtual override returns (bytes4 returnedStatus) {
|
|
147
154
|
// if isValidSignature fail, the error is catched in returnedError
|
|
148
155
|
(address recoveredAddress, ECDSA.RecoverError returnedError) = ECDSA
|
|
149
156
|
.tryRecover(dataHash, signature);
|
|
@@ -152,12 +159,12 @@ abstract contract LSP6KeyManagerCore is
|
|
|
152
159
|
if (returnedError != ECDSA.RecoverError.NoError)
|
|
153
160
|
return _ERC1271_FAILVALUE;
|
|
154
161
|
|
|
155
|
-
// if the address recovered has SIGN permission return the ERC1271
|
|
162
|
+
// if the address recovered has SIGN permission return the ERC1271 success value, otherwise the fail value
|
|
156
163
|
return (
|
|
157
164
|
ERC725Y(_target).getPermissionsFor(recoveredAddress).hasPermission(
|
|
158
165
|
_PERMISSION_SIGN
|
|
159
166
|
)
|
|
160
|
-
?
|
|
167
|
+
? _ERC1271_SUCCESSVALUE
|
|
161
168
|
: _ERC1271_FAILVALUE
|
|
162
169
|
);
|
|
163
170
|
}
|
|
@@ -169,7 +176,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
169
176
|
*/
|
|
170
177
|
function execute(
|
|
171
178
|
bytes calldata payload
|
|
172
|
-
) public payable virtual returns (bytes memory) {
|
|
179
|
+
) public payable virtual override returns (bytes memory) {
|
|
173
180
|
return _execute(msg.value, payload);
|
|
174
181
|
}
|
|
175
182
|
|
|
@@ -181,7 +188,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
181
188
|
function executeBatch(
|
|
182
189
|
uint256[] calldata values,
|
|
183
190
|
bytes[] calldata payloads
|
|
184
|
-
) public payable virtual returns (bytes[] memory) {
|
|
191
|
+
) public payable virtual override returns (bytes[] memory) {
|
|
185
192
|
if (values.length != payloads.length) {
|
|
186
193
|
revert BatchExecuteParamsLengthMismatch();
|
|
187
194
|
}
|
|
@@ -189,7 +196,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
189
196
|
bytes[] memory results = new bytes[](payloads.length);
|
|
190
197
|
uint256 totalValues;
|
|
191
198
|
|
|
192
|
-
for (uint256 ii
|
|
199
|
+
for (uint256 ii; ii < payloads.length; ) {
|
|
193
200
|
if ((totalValues += values[ii]) > msg.value) {
|
|
194
201
|
revert LSP6BatchInsufficientValueSent(totalValues, msg.value);
|
|
195
202
|
}
|
|
@@ -229,7 +236,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
229
236
|
uint256 nonce,
|
|
230
237
|
uint256 validityTimestamps,
|
|
231
238
|
bytes calldata payload
|
|
232
|
-
) public payable virtual returns (bytes memory) {
|
|
239
|
+
) public payable virtual override returns (bytes memory) {
|
|
233
240
|
return
|
|
234
241
|
_executeRelayCall(
|
|
235
242
|
signature,
|
|
@@ -259,7 +266,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
259
266
|
uint256[] calldata validityTimestamps,
|
|
260
267
|
uint256[] calldata values,
|
|
261
268
|
bytes[] calldata payloads
|
|
262
|
-
) public payable virtual returns (bytes[] memory) {
|
|
269
|
+
) public payable virtual override returns (bytes[] memory) {
|
|
263
270
|
if (
|
|
264
271
|
signatures.length != nonces.length ||
|
|
265
272
|
nonces.length != validityTimestamps.length ||
|
|
@@ -272,7 +279,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
272
279
|
bytes[] memory results = new bytes[](payloads.length);
|
|
273
280
|
uint256 totalValues;
|
|
274
281
|
|
|
275
|
-
for (uint256 ii
|
|
282
|
+
for (uint256 ii; ii < payloads.length; ) {
|
|
276
283
|
if ((totalValues += values[ii]) > msg.value) {
|
|
277
284
|
revert LSP6BatchInsufficientValueSent(totalValues, msg.value);
|
|
278
285
|
}
|
|
@@ -299,53 +306,65 @@ abstract contract LSP6KeyManagerCore is
|
|
|
299
306
|
|
|
300
307
|
/**
|
|
301
308
|
* @inheritdoc ILSP20
|
|
309
|
+
*
|
|
310
|
+
* @custom:hint This function can call by any other address than the {`target`}.
|
|
311
|
+
* This allows to verify permissions in a _"read-only"_ manner.
|
|
312
|
+
*
|
|
313
|
+
* Anyone can call this function to verify if the `caller` has the right permissions to perform the abi-encoded function call `data`
|
|
314
|
+
* on the {`target`} contract (while sending `msgValue` alongside the call).
|
|
315
|
+
*
|
|
316
|
+
* If the permissions have been verified successfully and `caller` is authorized, one of the following two LSP20 success value will be returned:
|
|
317
|
+
* - `0x1a238000`: LSP20 success value **without** post verification (last byte is `0x00`).
|
|
318
|
+
* - `0x1a238001`: LSP20 success value **with** post-verification (last byte is `0x01`).
|
|
302
319
|
*/
|
|
303
320
|
function lsp20VerifyCall(
|
|
321
|
+
address /* requestor */,
|
|
322
|
+
address targetContract,
|
|
304
323
|
address caller,
|
|
305
324
|
uint256 msgValue,
|
|
306
|
-
bytes calldata
|
|
307
|
-
) external virtual returns (bytes4) {
|
|
308
|
-
bool isSetData =
|
|
309
|
-
|
|
310
|
-
bytes4(data) == IERC725Y.setData.selector ||
|
|
311
|
-
bytes4(data) == IERC725Y.setDataBatch.selector
|
|
312
|
-
) {
|
|
313
|
-
isSetData = true;
|
|
314
|
-
}
|
|
325
|
+
bytes calldata callData
|
|
326
|
+
) external virtual override returns (bytes4) {
|
|
327
|
+
bool isSetData = bytes4(callData) == IERC725Y.setData.selector ||
|
|
328
|
+
bytes4(callData) == IERC725Y.setDataBatch.selector;
|
|
315
329
|
|
|
316
330
|
// If target is invoking the verification, emit the event and change the reentrancy guard
|
|
317
|
-
if (msg.sender ==
|
|
318
|
-
bool
|
|
331
|
+
if (msg.sender == targetContract) {
|
|
332
|
+
bool reentrancyStatus = _nonReentrantBefore(
|
|
333
|
+
targetContract,
|
|
334
|
+
isSetData,
|
|
335
|
+
caller
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
_verifyPermissions(targetContract, caller, false, callData);
|
|
319
339
|
|
|
320
|
-
|
|
321
|
-
emit PermissionsVerified(caller, msgValue, bytes4(data));
|
|
340
|
+
emit PermissionsVerified(caller, msgValue, bytes4(callData));
|
|
322
341
|
|
|
323
342
|
// if it's a setData call, do not invoke the `lsp20VerifyCallResult(..)` function
|
|
324
343
|
return
|
|
325
|
-
isSetData ||
|
|
326
|
-
?
|
|
327
|
-
:
|
|
344
|
+
isSetData || reentrancyStatus
|
|
345
|
+
? _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITHOUT_POST_VERIFICATION
|
|
346
|
+
: _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITH_POST_VERIFICATION;
|
|
328
347
|
}
|
|
329
|
-
|
|
330
|
-
|
|
348
|
+
/// @dev If a different address is invoking the verification,
|
|
349
|
+
/// do not change the state or emit the event to allow read-only verification
|
|
331
350
|
else {
|
|
332
|
-
bool
|
|
351
|
+
bool reentrancyStatus = _reentrancyStatus[targetContract];
|
|
333
352
|
|
|
334
|
-
if (
|
|
353
|
+
if (reentrancyStatus) {
|
|
335
354
|
_requirePermissions(
|
|
336
355
|
caller,
|
|
337
|
-
ERC725Y(
|
|
356
|
+
ERC725Y(targetContract).getPermissionsFor(caller),
|
|
338
357
|
_PERMISSION_REENTRANCY
|
|
339
358
|
);
|
|
340
359
|
}
|
|
341
360
|
|
|
342
|
-
_verifyPermissions(caller,
|
|
361
|
+
_verifyPermissions(targetContract, caller, false, callData);
|
|
343
362
|
|
|
344
363
|
// if it's a setData call, do not invoke the `lsp20VerifyCallResult(..)` function
|
|
345
364
|
return
|
|
346
|
-
isSetData ||
|
|
347
|
-
?
|
|
348
|
-
:
|
|
365
|
+
isSetData || reentrancyStatus
|
|
366
|
+
? _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITHOUT_POST_VERIFICATION
|
|
367
|
+
: _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITH_POST_VERIFICATION;
|
|
349
368
|
}
|
|
350
369
|
}
|
|
351
370
|
|
|
@@ -353,15 +372,15 @@ abstract contract LSP6KeyManagerCore is
|
|
|
353
372
|
* @inheritdoc ILSP20
|
|
354
373
|
*/
|
|
355
374
|
function lsp20VerifyCallResult(
|
|
356
|
-
bytes32 /*callHash*/,
|
|
357
|
-
bytes memory /*
|
|
358
|
-
) external virtual returns (bytes4) {
|
|
375
|
+
bytes32 /* callHash */,
|
|
376
|
+
bytes memory /* callResult */
|
|
377
|
+
) external virtual override returns (bytes4) {
|
|
359
378
|
// If it's the target calling, set back the reentrancy guard
|
|
360
|
-
// to false, if not return the
|
|
379
|
+
// to false, if not return the success value
|
|
361
380
|
if (msg.sender == _target) {
|
|
362
|
-
_nonReentrantAfter();
|
|
381
|
+
_nonReentrantAfter(msg.sender);
|
|
363
382
|
}
|
|
364
|
-
return
|
|
383
|
+
return _LSP20_VERIFY_CALL_RESULT_SUCCESS_VALUE;
|
|
365
384
|
}
|
|
366
385
|
|
|
367
386
|
function _execute(
|
|
@@ -372,23 +391,29 @@ abstract contract LSP6KeyManagerCore is
|
|
|
372
391
|
revert InvalidPayload(payload);
|
|
373
392
|
}
|
|
374
393
|
|
|
375
|
-
bool isSetData =
|
|
376
|
-
|
|
377
|
-
bytes4(payload) == IERC725Y.setData.selector ||
|
|
378
|
-
bytes4(payload) == IERC725Y.setDataBatch.selector
|
|
379
|
-
) {
|
|
380
|
-
isSetData = true;
|
|
381
|
-
}
|
|
394
|
+
bool isSetData = bytes4(payload) == IERC725Y.setData.selector ||
|
|
395
|
+
bytes4(payload) == IERC725Y.setDataBatch.selector;
|
|
382
396
|
|
|
383
|
-
|
|
397
|
+
address targetContract = _target;
|
|
398
|
+
|
|
399
|
+
bool reentrancyStatus = _nonReentrantBefore(
|
|
400
|
+
targetContract,
|
|
401
|
+
isSetData,
|
|
402
|
+
msg.sender
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
_verifyPermissions(targetContract, msg.sender, false, payload);
|
|
384
406
|
|
|
385
|
-
_verifyPermissions(msg.sender, msgValue, payload);
|
|
386
407
|
emit PermissionsVerified(msg.sender, msgValue, bytes4(payload));
|
|
387
408
|
|
|
388
|
-
bytes memory result = _executePayload(
|
|
409
|
+
bytes memory result = _executePayload(
|
|
410
|
+
targetContract,
|
|
411
|
+
msgValue,
|
|
412
|
+
payload
|
|
413
|
+
);
|
|
389
414
|
|
|
390
|
-
if (!
|
|
391
|
-
_nonReentrantAfter();
|
|
415
|
+
if (!reentrancyStatus && !isSetData) {
|
|
416
|
+
_nonReentrantAfter(targetContract);
|
|
392
417
|
}
|
|
393
418
|
|
|
394
419
|
return result;
|
|
@@ -419,6 +444,8 @@ abstract contract LSP6KeyManagerCore is
|
|
|
419
444
|
revert InvalidPayload(payload);
|
|
420
445
|
}
|
|
421
446
|
|
|
447
|
+
address targetContract = _target;
|
|
448
|
+
|
|
422
449
|
address signer = LSP25MultiChannelNonce
|
|
423
450
|
._recoverSignerFromLSP25Signature(
|
|
424
451
|
signature,
|
|
@@ -437,23 +464,27 @@ abstract contract LSP6KeyManagerCore is
|
|
|
437
464
|
|
|
438
465
|
LSP25MultiChannelNonce._verifyValidityTimestamps(validityTimestamps);
|
|
439
466
|
|
|
440
|
-
bool isSetData =
|
|
441
|
-
|
|
442
|
-
bytes4(payload) == IERC725Y.setData.selector ||
|
|
443
|
-
bytes4(payload) == IERC725Y.setDataBatch.selector
|
|
444
|
-
) {
|
|
445
|
-
isSetData = true;
|
|
446
|
-
}
|
|
467
|
+
bool isSetData = bytes4(payload) == IERC725Y.setData.selector ||
|
|
468
|
+
bytes4(payload) == IERC725Y.setDataBatch.selector;
|
|
447
469
|
|
|
448
|
-
bool
|
|
470
|
+
bool reentrancyStatus = _nonReentrantBefore(
|
|
471
|
+
targetContract,
|
|
472
|
+
isSetData,
|
|
473
|
+
signer
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
_verifyPermissions(targetContract, signer, true, payload);
|
|
449
477
|
|
|
450
|
-
_verifyPermissions(signer, msgValue, payload);
|
|
451
478
|
emit PermissionsVerified(signer, msgValue, bytes4(payload));
|
|
452
479
|
|
|
453
|
-
bytes memory result = _executePayload(
|
|
480
|
+
bytes memory result = _executePayload(
|
|
481
|
+
targetContract,
|
|
482
|
+
msgValue,
|
|
483
|
+
payload
|
|
484
|
+
);
|
|
454
485
|
|
|
455
|
-
if (!
|
|
456
|
-
_nonReentrantAfter();
|
|
486
|
+
if (!reentrancyStatus && !isSetData) {
|
|
487
|
+
_nonReentrantAfter(targetContract);
|
|
457
488
|
}
|
|
458
489
|
|
|
459
490
|
return result;
|
|
@@ -465,10 +496,11 @@ abstract contract LSP6KeyManagerCore is
|
|
|
465
496
|
* @return bytes The data returned by the call made to the linked {target} contract.
|
|
466
497
|
*/
|
|
467
498
|
function _executePayload(
|
|
499
|
+
address targetContract,
|
|
468
500
|
uint256 msgValue,
|
|
469
501
|
bytes calldata payload
|
|
470
502
|
) internal virtual returns (bytes memory) {
|
|
471
|
-
(bool success, bytes memory returnData) =
|
|
503
|
+
(bool success, bytes memory returnData) = targetContract.call{
|
|
472
504
|
value: msgValue,
|
|
473
505
|
gas: gasleft()
|
|
474
506
|
}(payload);
|
|
@@ -483,29 +515,37 @@ abstract contract LSP6KeyManagerCore is
|
|
|
483
515
|
|
|
484
516
|
/**
|
|
485
517
|
* @dev Verify if the `from` address is allowed to execute the `payload` on the {target} contract linked to this Key Manager.
|
|
518
|
+
* @param targetContract The contract that is owned by the Key Manager
|
|
486
519
|
* @param from Either the caller of {execute} or the signer of {executeRelayCall}.
|
|
487
520
|
* @param payload The abi-encoded function call to execute on the {target} contract.
|
|
488
521
|
*/
|
|
489
522
|
function _verifyPermissions(
|
|
523
|
+
address targetContract,
|
|
490
524
|
address from,
|
|
491
|
-
|
|
525
|
+
bool isRelayedCall,
|
|
492
526
|
bytes calldata payload
|
|
493
527
|
) internal view virtual {
|
|
494
|
-
bytes32 permissions = ERC725Y(
|
|
528
|
+
bytes32 permissions = ERC725Y(targetContract).getPermissionsFor(from);
|
|
495
529
|
if (permissions == bytes32(0)) revert NoPermissionsSet(from);
|
|
496
530
|
|
|
531
|
+
if (isRelayedCall) {
|
|
532
|
+
LSP6ExecuteRelayCallModule._verifyExecuteRelayCallPermission(
|
|
533
|
+
from,
|
|
534
|
+
permissions
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
|
|
497
538
|
bytes4 erc725Function = bytes4(payload);
|
|
498
539
|
|
|
499
540
|
// ERC725Y.setData(bytes32,bytes)
|
|
500
541
|
if (erc725Function == IERC725Y.setData.selector) {
|
|
501
|
-
if (msgValue != 0) revert CannotSendValueToSetData();
|
|
502
542
|
(bytes32 inputKey, bytes memory inputValue) = abi.decode(
|
|
503
543
|
payload[4:],
|
|
504
544
|
(bytes32, bytes)
|
|
505
545
|
);
|
|
506
546
|
|
|
507
547
|
LSP6SetDataModule._verifyCanSetData(
|
|
508
|
-
|
|
548
|
+
targetContract,
|
|
509
549
|
from,
|
|
510
550
|
permissions,
|
|
511
551
|
inputKey,
|
|
@@ -514,12 +554,11 @@ abstract contract LSP6KeyManagerCore is
|
|
|
514
554
|
|
|
515
555
|
// ERC725Y.setDataBatch(bytes32[],bytes[])
|
|
516
556
|
} else if (erc725Function == IERC725Y.setDataBatch.selector) {
|
|
517
|
-
if (msgValue != 0) revert CannotSendValueToSetData();
|
|
518
557
|
(bytes32[] memory inputKeys, bytes[] memory inputValues) = abi
|
|
519
558
|
.decode(payload[4:], (bytes32[], bytes[]));
|
|
520
559
|
|
|
521
560
|
LSP6SetDataModule._verifyCanSetData(
|
|
522
|
-
|
|
561
|
+
targetContract,
|
|
523
562
|
from,
|
|
524
563
|
permissions,
|
|
525
564
|
inputKeys,
|
|
@@ -536,7 +575,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
536
575
|
) = abi.decode(payload[4:], (uint256, address, uint256, bytes));
|
|
537
576
|
|
|
538
577
|
LSP6ExecuteModule._verifyCanExecute(
|
|
539
|
-
|
|
578
|
+
targetContract,
|
|
540
579
|
from,
|
|
541
580
|
permissions,
|
|
542
581
|
operationType,
|
|
@@ -546,7 +585,8 @@ abstract contract LSP6KeyManagerCore is
|
|
|
546
585
|
);
|
|
547
586
|
} else if (
|
|
548
587
|
erc725Function == ILSP14Ownable2Step.transferOwnership.selector ||
|
|
549
|
-
erc725Function == ILSP14Ownable2Step.acceptOwnership.selector
|
|
588
|
+
erc725Function == ILSP14Ownable2Step.acceptOwnership.selector ||
|
|
589
|
+
erc725Function == ILSP14Ownable2Step.renounceOwnership.selector
|
|
550
590
|
) {
|
|
551
591
|
LSP6OwnershipModule._verifyOwnershipPermissions(from, permissions);
|
|
552
592
|
} else {
|
|
@@ -554,45 +594,40 @@ abstract contract LSP6KeyManagerCore is
|
|
|
554
594
|
}
|
|
555
595
|
}
|
|
556
596
|
|
|
557
|
-
/**
|
|
558
|
-
* @dev Initialise _reentrancyStatus to _NOT_ENTERED.
|
|
559
|
-
*/
|
|
560
|
-
function _setupLSP6ReentrancyGuard() internal virtual {
|
|
561
|
-
_reentrancyStatus = false;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
597
|
/**
|
|
565
598
|
* @dev Update the status from `_NON_ENTERED` to `_ENTERED` and checks if
|
|
566
599
|
* the status is `_ENTERED` in order to revert the call unless the caller has the REENTRANCY permission
|
|
567
600
|
* Used in the beginning of the `nonReentrant` modifier, before the method execution starts.
|
|
568
601
|
*/
|
|
569
602
|
function _nonReentrantBefore(
|
|
603
|
+
address targetContract,
|
|
570
604
|
bool isSetData,
|
|
571
605
|
address from
|
|
572
|
-
) internal virtual returns (bool
|
|
573
|
-
|
|
574
|
-
|
|
606
|
+
) internal virtual returns (bool reentrancyStatus) {
|
|
607
|
+
reentrancyStatus = _reentrancyStatus[targetContract];
|
|
608
|
+
|
|
609
|
+
if (reentrancyStatus) {
|
|
575
610
|
// CHECK the caller has REENTRANCY permission
|
|
576
611
|
_requirePermissions(
|
|
577
612
|
from,
|
|
578
|
-
ERC725Y(
|
|
613
|
+
ERC725Y(targetContract).getPermissionsFor(from),
|
|
579
614
|
_PERMISSION_REENTRANCY
|
|
580
615
|
);
|
|
581
616
|
} else {
|
|
582
617
|
if (!isSetData) {
|
|
583
|
-
_reentrancyStatus = true;
|
|
618
|
+
_reentrancyStatus[targetContract] = true;
|
|
584
619
|
}
|
|
585
620
|
}
|
|
586
621
|
}
|
|
587
622
|
|
|
588
623
|
/**
|
|
589
|
-
* @dev Resets the status to `
|
|
624
|
+
* @dev Resets the status to `false`
|
|
590
625
|
* Used in the end of the `nonReentrant` modifier after the method execution is terminated
|
|
591
626
|
*/
|
|
592
|
-
function _nonReentrantAfter() internal virtual {
|
|
627
|
+
function _nonReentrantAfter(address targetContract) internal virtual {
|
|
593
628
|
// By storing the original value once again, a refund is triggered (see
|
|
594
629
|
// https://eips.ethereum.org/EIPS/eip-2200)
|
|
595
|
-
_reentrancyStatus = false;
|
|
630
|
+
_reentrancyStatus[targetContract] = false;
|
|
596
631
|
}
|
|
597
632
|
|
|
598
633
|
/**
|
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
InvalidEncodedAllowedCalls,
|
|
42
42
|
InvalidWhitelistedCall,
|
|
43
43
|
NotAuthorised,
|
|
44
|
-
InvalidPayload,
|
|
45
44
|
CallingKeyManagerNotAllowed
|
|
46
45
|
} from "../LSP6Errors.sol";
|
|
47
46
|
|
|
@@ -262,7 +261,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
262
261
|
isEmptyCall
|
|
263
262
|
);
|
|
264
263
|
|
|
265
|
-
for (uint256 ii
|
|
264
|
+
for (uint256 ii; ii < allowedCalls.length; ii += 34) {
|
|
266
265
|
/// @dev structure of an AllowedCall
|
|
267
266
|
//
|
|
268
267
|
/// AllowedCall = 0x00200000000ncafecafecafecafecafecafecafecafecafecafe5a5a5a5af1f1f1f1
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.5;
|
|
3
|
+
|
|
4
|
+
// libraries
|
|
5
|
+
import {LSP6Utils} from "../LSP6Utils.sol";
|
|
6
|
+
|
|
7
|
+
// constants
|
|
8
|
+
import {_PERMISSION_EXECUTE_RELAY_CALL} from "../LSP6Constants.sol";
|
|
9
|
+
|
|
10
|
+
// errors
|
|
11
|
+
import {NotAuthorised} from "../LSP6Errors.sol";
|
|
12
|
+
|
|
13
|
+
abstract contract LSP6ExecuteRelayCallModule {
|
|
14
|
+
function _verifyExecuteRelayCallPermission(
|
|
15
|
+
address controllerAddress,
|
|
16
|
+
bytes32 controllerPermissions
|
|
17
|
+
) internal pure {
|
|
18
|
+
if (
|
|
19
|
+
!LSP6Utils.hasPermission(
|
|
20
|
+
controllerPermissions,
|
|
21
|
+
_PERMISSION_EXECUTE_RELAY_CALL
|
|
22
|
+
)
|
|
23
|
+
) {
|
|
24
|
+
revert NotAuthorised(controllerAddress, "EXECUTE_RELAY_CALL");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -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
|
}
|