@lukso/lsp-smart-contracts 0.10.1 → 0.10.2
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 +0 -1
- package/artifacts/Create2Factory.json +2 -2
- 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/LSP16UniversalFactory.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
- package/artifacts/LSP6KeyManager.json +2 -2
- package/artifacts/LSP6KeyManagerInit.json +2 -2
- package/artifacts/LSP7CompatibleERC20Mintable.json +2 -2
- package/artifacts/LSP7CompatibleERC20MintableInit.json +2 -2
- package/artifacts/LSP7Mintable.json +2 -2
- package/artifacts/LSP7MintableInit.json +2 -2
- package/artifacts/LSP8CompatibleERC721Mintable.json +2 -2
- package/artifacts/LSP8CompatibleERC721MintableInit.json +2 -2
- package/artifacts/LSP8Mintable.json +2 -2
- package/artifacts/LSP8MintableInit.json +2 -2
- package/artifacts/LSP9Vault.json +2 -2
- package/artifacts/LSP9VaultInit.json +2 -2
- package/artifacts/UniversalProfile.json +3 -3
- package/artifacts/UniversalProfileInit.json +3 -3
- package/artifacts/UniversalReceiverAddressStore.json +2 -2
- package/contracts/Factories/Create2Factory.sol +11 -3
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +13 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +5 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +256 -186
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +6 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +13 -4
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +3 -5
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +25 -10
- package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +4 -2
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +3 -1
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +65 -23
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +7 -2
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +14 -4
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +4 -1
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +17 -16
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +4 -1
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +22 -11
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +85 -27
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +38 -16
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +20 -8
- package/contracts/LSP17ContractExtension/LSP17Utils.sol +4 -5
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +38 -14
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +31 -11
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +34 -9
- package/contracts/LSP20CallVerification/{ILSP20CallVerification.sol → ILSP20CallVerifier.sol} +7 -2
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +24 -9
- package/contracts/LSP20CallVerification/LSP20Errors.sol +1 -1
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +62 -36
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +3 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +15 -4
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +18 -5
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +32 -12
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +17 -8
- package/contracts/LSP6KeyManager/LSP6Constants.sol +3 -9
- package/contracts/LSP6KeyManager/LSP6Errors.sol +4 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +114 -72
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +7 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +96 -46
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +10 -5
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +98 -32
- package/contracts/LSP6KeyManager/LSP6Utils.sol +42 -34
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +8 -6
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +13 -10
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +96 -26
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +11 -9
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +8 -2
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +9 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +1 -5
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -6
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +6 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +32 -12
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +28 -7
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +8 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +6 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +6 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +13 -3
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +14 -5
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +12 -10
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +95 -28
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +14 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +23 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +72 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +77 -27
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +8 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +5 -1
- package/contracts/LSP9Vault/ILSP9Vault.sol +13 -5
- package/contracts/LSP9Vault/LSP9Vault.sol +7 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +108 -51
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +10 -3
- package/contracts/Legacy/Registries/AddressRegistry.sol +13 -4
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +6 -2
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +17 -6
- package/contracts/UniversalProfile.sol +4 -1
- package/contracts/UniversalProfileInit.sol +3 -1
- package/contracts/UniversalProfileInitAbstract.sol +13 -4
- package/devdocs/LSP0ERC725Account.json +33 -19
- package/devdocs/LSP0ERC725AccountInit.json +30 -17
- package/devdocs/LSP9Vault.json +3 -3
- package/devdocs/LSP9VaultInit.json +3 -3
- package/devdocs/UniversalProfile.json +30 -17
- package/devdocs/UniversalProfileInit.json +30 -17
- package/dist/constants.cjs.js +142 -102
- package/dist/constants.d.ts +62 -10
- package/dist/constants.es.js +142 -102
- package/package.json +17 -16
- package/userdocs/LSP0ERC725Account.json +2 -2
- package/userdocs/LSP0ERC725AccountInit.json +2 -2
- package/userdocs/UniversalProfile.json +2 -2
- package/userdocs/UniversalProfileInit.json +2 -2
- package/contracts/Custom/EIP191Signer.sol +0 -12
|
@@ -4,12 +4,16 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
|
|
6
6
|
import {ILSP0ERC725Account} from "./ILSP0ERC725Account.sol";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ILSP1UniversalReceiver
|
|
9
|
+
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
|
|
8
10
|
|
|
9
11
|
// libraries
|
|
10
12
|
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
11
13
|
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
12
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
ERC165Checker
|
|
16
|
+
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
13
17
|
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
14
18
|
import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
|
|
15
19
|
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
@@ -17,10 +21,14 @@ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
|
17
21
|
// modules
|
|
18
22
|
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
19
23
|
import {ERC725XCore} from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
|
|
20
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
OwnableUnset
|
|
26
|
+
} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
21
27
|
import {LSP14Ownable2Step} from "../LSP14Ownable2Step/LSP14Ownable2Step.sol";
|
|
22
28
|
import {LSP17Extendable} from "../LSP17ContractExtension/LSP17Extendable.sol";
|
|
23
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
LSP20CallVerification
|
|
31
|
+
} from "../LSP20CallVerification/LSP20CallVerification.sol";
|
|
24
32
|
|
|
25
33
|
// constants
|
|
26
34
|
import "@erc725/smart-contracts/contracts/constants.sol";
|
|
@@ -40,12 +48,20 @@ import {
|
|
|
40
48
|
} from "../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
41
49
|
import {_INTERFACEID_LSP14} from "../LSP14Ownable2Step/LSP14Constants.sol";
|
|
42
50
|
|
|
43
|
-
import {
|
|
44
|
-
|
|
51
|
+
import {
|
|
52
|
+
_LSP17_EXTENSION_PREFIX
|
|
53
|
+
} from "../LSP17ContractExtension/LSP17Constants.sol";
|
|
54
|
+
import {
|
|
55
|
+
_INTERFACEID_LSP20_CALL_VERIFICATION
|
|
56
|
+
} from "../LSP20CallVerification/LSP20Constants.sol";
|
|
45
57
|
|
|
46
58
|
// errors
|
|
47
|
-
import {
|
|
48
|
-
|
|
59
|
+
import {
|
|
60
|
+
ERC725Y_DataKeysValuesLengthMismatch
|
|
61
|
+
} from "@erc725/smart-contracts/contracts/errors.sol";
|
|
62
|
+
import {
|
|
63
|
+
NoExtensionFoundForFunctionSelector
|
|
64
|
+
} from "../LSP17ContractExtension/LSP17Errors.sol";
|
|
49
65
|
|
|
50
66
|
/**
|
|
51
67
|
* @title The Core Implementation of LSP0-ERC725Account Standard
|
|
@@ -53,7 +69,6 @@ import {NoExtensionFoundForFunctionSelector} from "../LSP17ContractExtension/LSP
|
|
|
53
69
|
*
|
|
54
70
|
* @author Fabian Vogelsteller <fabian@lukso.network>, Jean Cavallera (CJ42)
|
|
55
71
|
* @dev A smart contract account including basic functionalities such as:
|
|
56
|
-
*
|
|
57
72
|
* - Detecting supported standards using ERC165
|
|
58
73
|
* https://eips.ethereum.org/EIPS/eip-165
|
|
59
74
|
*
|
|
@@ -93,11 +108,11 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
93
108
|
using Address for address;
|
|
94
109
|
|
|
95
110
|
/**
|
|
96
|
-
* @dev
|
|
111
|
+
* @dev Executed:
|
|
112
|
+
* - when receiving some native tokens without any additional data.
|
|
113
|
+
* - on empty calls to the contract.
|
|
97
114
|
*
|
|
98
|
-
*
|
|
99
|
-
* - when receiving some native tokens without any additional data.
|
|
100
|
-
* - on empty calls to the contract.
|
|
115
|
+
* @custom:events {ValueReceived} event when receiving native tokens.
|
|
101
116
|
*/
|
|
102
117
|
receive() external payable virtual {
|
|
103
118
|
if (msg.value != 0) {
|
|
@@ -108,31 +123,30 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
108
123
|
// solhint-disable no-complex-fallback
|
|
109
124
|
|
|
110
125
|
/**
|
|
111
|
-
* @notice Achieves the goal of
|
|
126
|
+
* @notice Achieves the goal of [LSP17-ContractExtension] standard by extending the contract to
|
|
112
127
|
* handle calls of functions that do not exist natively, forwarding the function call to the
|
|
113
128
|
* extension address mapped to the function being called.
|
|
114
129
|
*
|
|
115
|
-
* @dev This function:
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
130
|
+
* @dev This function is executed when:
|
|
131
|
+
* - sending data of length less than 4 bytes to the contract.
|
|
132
|
+
* - the first 4 bytes of the calldata do not match any publicly callable functions from the contract ABI.
|
|
133
|
+
* - receiving native tokens with some calldata.
|
|
119
134
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
135
|
+
* 1. If the data is equal or longer than 4 bytes, the ERC725Y storage is queried with the following data key:
|
|
136
|
+
* `[_LSP17_EXTENSION_PREFIX] + <bytes4 (msg.sig)>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key)
|
|
122
137
|
*
|
|
123
138
|
* - If there is no address stored under the following data key, revert with {NoExtensionFoundForFunctionSelector(bytes4)}
|
|
124
|
-
* The data key relative to bytes4(0) is an exception, where no reverts occurs if there is no extension address stored under
|
|
139
|
+
* The data key relative to `bytes4(0)` is an exception, where no reverts occurs if there is no extension address stored under
|
|
125
140
|
*
|
|
126
141
|
* This exception is made to allow users to send random data (graffiti) to the account and to be able to react on it.
|
|
127
142
|
*
|
|
128
|
-
* - If there is an address, forward the
|
|
129
|
-
* appending 52 bytes (20 bytes of
|
|
143
|
+
* - If there is an address, forward the `msg.data` to the extension using the CALL opcode,
|
|
144
|
+
* appending 52 bytes (20 bytes of `msg.sender` and 32 bytes of `msg.value`).
|
|
130
145
|
* Return what the calls returns, or revert if the call failed
|
|
131
146
|
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* - receiving native tokens with some calldata.
|
|
147
|
+
* @custom:return if the data sent to this function is of length less than 4 bytes (not a function selector)
|
|
148
|
+
*
|
|
149
|
+
* @custom:events {ValueReceived} event when receiving native tokens.
|
|
136
150
|
*/
|
|
137
151
|
fallback() external payable virtual {
|
|
138
152
|
if (msg.value != 0) {
|
|
@@ -154,10 +168,14 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
154
168
|
* @param data An array of ABI encoded function calls to be called on the contract.
|
|
155
169
|
* @return results An array of values returned by the executed functions.
|
|
156
170
|
*/
|
|
157
|
-
function batchCalls(
|
|
171
|
+
function batchCalls(
|
|
172
|
+
bytes[] calldata data
|
|
173
|
+
) public returns (bytes[] memory results) {
|
|
158
174
|
results = new bytes[](data.length);
|
|
159
175
|
for (uint256 i; i < data.length; ) {
|
|
160
|
-
(bool success, bytes memory result) = address(this).delegatecall(
|
|
176
|
+
(bool success, bytes memory result) = address(this).delegatecall(
|
|
177
|
+
data[i]
|
|
178
|
+
);
|
|
161
179
|
|
|
162
180
|
if (!success) {
|
|
163
181
|
// Look for revert reason and bubble it up if present
|
|
@@ -185,22 +203,21 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
185
203
|
/**
|
|
186
204
|
* @dev Executes any call on other addresses.
|
|
187
205
|
*
|
|
188
|
-
* @param operationType The operation to execute: CALL = 0 CREATE = 1 CREATE2 = 2 STATICCALL = 3 DELEGATECALL = 4
|
|
189
|
-
* @param target The address (smart contract/EOA) to interact with, `target` will be unused if a contract is created (
|
|
206
|
+
* @param operationType The operation to execute: `CALL = 0`, `CREATE = 1` `CREATE2 = 2`, `STATICCALL = 3`, `DELEGATECALL = 4`.
|
|
207
|
+
* @param target The address (smart contract/EOA) to interact with, `target` will be unused if a contract is created (`CREATE` & `CREATE2`).
|
|
190
208
|
* @param value The amount of native tokens to transfer (in Wei).
|
|
191
|
-
* @param data The call data to execute on `target`, or the bytecode of the contract to deploy
|
|
192
|
-
*
|
|
193
|
-
* Requirements:
|
|
209
|
+
* @param data The call data to execute on `target`, or the bytecode of the contract to deploy.
|
|
194
210
|
*
|
|
211
|
+
* @custom:requirements
|
|
195
212
|
* - if a `value` is provided, the contract MUST have at least this amount in its balance to execute successfully.
|
|
196
|
-
* - if the operation type is
|
|
197
|
-
* - `target` SHOULD be address(0) when deploying a contract.
|
|
198
|
-
* - MUST pass when called by the owner or by an authorised address that pass the verification check performed
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
213
|
+
* - if the operation type is `STATICCALL` or `DELEGATECALL`, `value` SHOULD be 0.
|
|
214
|
+
* - `target` SHOULD be `address(0)` when deploying a contract.
|
|
215
|
+
* - MUST pass when called by the owner or by an authorised address that pass the verification check performed on the owner accordinng to [LSP20-CallVerification] specification
|
|
216
|
+
*
|
|
217
|
+
* @custom:events
|
|
218
|
+
* - {Executed} event, when a call is executed under `operationType` 0, 3 and 4
|
|
219
|
+
* - {ContractCreated} event, when a contract is created under `operationType` 1 and 2
|
|
220
|
+
* - {ValueReceived} event when receiving native tokens.
|
|
204
221
|
*/
|
|
205
222
|
function execute(
|
|
206
223
|
uint256 operationType,
|
|
@@ -224,7 +241,12 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
224
241
|
bool verifyAfter = LSP20CallVerification._verifyCall(_owner);
|
|
225
242
|
|
|
226
243
|
// Perform the execution
|
|
227
|
-
bytes memory result = ERC725XCore._execute(
|
|
244
|
+
bytes memory result = ERC725XCore._execute(
|
|
245
|
+
operationType,
|
|
246
|
+
target,
|
|
247
|
+
value,
|
|
248
|
+
data
|
|
249
|
+
);
|
|
228
250
|
|
|
229
251
|
// if verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
|
|
230
252
|
if (verifyAfter) {
|
|
@@ -237,23 +259,23 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
237
259
|
/**
|
|
238
260
|
* @dev Generic batch executor function that executes any call on other addresses
|
|
239
261
|
*
|
|
240
|
-
* @param operationsType The list of operations type used: CALL = 0
|
|
241
|
-
* @param targets The list of addresses to call. `targets` will be unused if a contract is created (
|
|
242
|
-
* @param values The list of native token amounts to transfer (in Wei)
|
|
243
|
-
* @param datas The list of call data to execute on `targets`, or the creation bytecode of the contracts to deploy
|
|
244
|
-
*
|
|
245
|
-
* Requirements:
|
|
262
|
+
* @param operationsType The list of operations type used: `CALL = 0`, `CREATE = 1`, `CREATE2 = 2`, `STATICCALL = 3`, `DELEGATECALL = 4`.
|
|
263
|
+
* @param targets The list of addresses to call. `targets` will be unused if a contract is created (`CREATE` & `CREATE2`).
|
|
264
|
+
* @param values The list of native token amounts to transfer (in Wei).
|
|
265
|
+
* @param datas The list of call data to execute on `targets`, or the creation bytecode of the contracts to deploy.
|
|
246
266
|
*
|
|
267
|
+
* @custom:requirements
|
|
247
268
|
* - The length of the parameters provided MUST be equal
|
|
248
269
|
* - if a `value` is provided, the contract MUST have at least this amount in its balance to execute successfully.
|
|
249
|
-
* - if the operation type is
|
|
250
|
-
* - `target` SHOULD be address(0) when deploying a contract.
|
|
270
|
+
* - if the operation type is `STATICCALL` or `DELEGATECALL`, `value` SHOULD be 0.
|
|
271
|
+
* - `target` SHOULD be `address(0)` when deploying a contract.
|
|
251
272
|
* - MUST pass when called by the owner or by an authorised address that pass the verification check performed
|
|
252
|
-
* on the owner accordinng to LSP20
|
|
273
|
+
* on the owner accordinng to [LSP20-CallVerification] specification
|
|
253
274
|
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
275
|
+
* @custom:events
|
|
276
|
+
* - {Executed} event, when a call is executed under `operationType` 0, 3 and 4 (each iteration)
|
|
277
|
+
* - {ContractCreated} event, when a contract is created under `operationType` 1 and 2 (each iteration)
|
|
278
|
+
* - {ValueReceived} event when receiving native tokens.
|
|
257
279
|
*/
|
|
258
280
|
function executeBatch(
|
|
259
281
|
uint256[] memory operationsType,
|
|
@@ -269,7 +291,13 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
269
291
|
|
|
270
292
|
// If the caller is the owner perform execute directly
|
|
271
293
|
if (msg.sender == _owner) {
|
|
272
|
-
return
|
|
294
|
+
return
|
|
295
|
+
ERC725XCore._executeBatch(
|
|
296
|
+
operationsType,
|
|
297
|
+
targets,
|
|
298
|
+
values,
|
|
299
|
+
datas
|
|
300
|
+
);
|
|
273
301
|
}
|
|
274
302
|
|
|
275
303
|
// If the caller is not the owner, call {lsp20VerifyCall} on the owner
|
|
@@ -277,11 +305,19 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
277
305
|
bool verifyAfter = LSP20CallVerification._verifyCall(_owner);
|
|
278
306
|
|
|
279
307
|
// Perform the execution
|
|
280
|
-
bytes[] memory results = ERC725XCore._executeBatch(
|
|
308
|
+
bytes[] memory results = ERC725XCore._executeBatch(
|
|
309
|
+
operationsType,
|
|
310
|
+
targets,
|
|
311
|
+
values,
|
|
312
|
+
datas
|
|
313
|
+
);
|
|
281
314
|
|
|
282
315
|
// if verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
|
|
283
316
|
if (verifyAfter) {
|
|
284
|
-
LSP20CallVerification._verifyCallResult(
|
|
317
|
+
LSP20CallVerification._verifyCallResult(
|
|
318
|
+
_owner,
|
|
319
|
+
abi.encode(results)
|
|
320
|
+
);
|
|
285
321
|
}
|
|
286
322
|
|
|
287
323
|
return results;
|
|
@@ -293,15 +329,17 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
293
329
|
* @param dataKey The key to retrieve stored value
|
|
294
330
|
* @param dataValue The value to set
|
|
295
331
|
*
|
|
296
|
-
*
|
|
332
|
+
* @custom:requirements
|
|
333
|
+
* - MUST pass when called by the owner or by an authorised address that pass the verification check performed on the owner accordinng to [LSP20-CallVerification] specification
|
|
297
334
|
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
* Emits a {ValueReceived} event when receiving native tokens.
|
|
302
|
-
* Emits a {DataChanged} event.
|
|
335
|
+
* @custom:events
|
|
336
|
+
* - {ValueReceived} event when receiving native tokens.
|
|
337
|
+
* - {DataChanged} event.
|
|
303
338
|
*/
|
|
304
|
-
function setData(
|
|
339
|
+
function setData(
|
|
340
|
+
bytes32 dataKey,
|
|
341
|
+
bytes memory dataValue
|
|
342
|
+
) public payable virtual override {
|
|
305
343
|
if (msg.value != 0) {
|
|
306
344
|
emit ValueReceived(msg.sender, msg.value);
|
|
307
345
|
}
|
|
@@ -332,20 +370,17 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
332
370
|
* @param dataKeys The array of data keys for values to set
|
|
333
371
|
* @param dataValues The array of values to set
|
|
334
372
|
*
|
|
335
|
-
*
|
|
373
|
+
* @custom:requirements
|
|
374
|
+
* - MUST pass when called by the owner or by an authorised address that pass the verification check performed on the owner accordinng to [LSP20-CallVerification] specification
|
|
336
375
|
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
* Emits a {ValueReceived} event when receiving native tokens.
|
|
341
|
-
* Emits a {DataChanged} event. (on each iteration of setting data)
|
|
376
|
+
* @custom:events
|
|
377
|
+
* - {ValueReceived} event when receiving native tokens.
|
|
378
|
+
* - {DataChanged} event. (on each iteration of setting data)
|
|
342
379
|
*/
|
|
343
|
-
function setDataBatch(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
override
|
|
348
|
-
{
|
|
380
|
+
function setDataBatch(
|
|
381
|
+
bytes32[] memory dataKeys,
|
|
382
|
+
bytes[] memory dataValues
|
|
383
|
+
) public payable virtual override {
|
|
349
384
|
if (msg.value != 0) {
|
|
350
385
|
emit ValueReceived(msg.sender, msg.value);
|
|
351
386
|
}
|
|
@@ -389,7 +424,7 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
389
424
|
}
|
|
390
425
|
|
|
391
426
|
/**
|
|
392
|
-
* @notice Achieves the goal of LSP1-UniversalReceiver by allowing the account to be notified about incoming/outgoing
|
|
427
|
+
* @notice Achieves the goal of [LSP1-UniversalReceiver] by allowing the account to be notified about incoming/outgoing
|
|
393
428
|
* transactions and enabling reactions to these actions.
|
|
394
429
|
*
|
|
395
430
|
* The reaction is achieved by having two external contracts (UniversalReceiverDelegates) that react on the whole transaction
|
|
@@ -400,50 +435,53 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
400
435
|
*
|
|
401
436
|
* @dev The function performs the following steps:
|
|
402
437
|
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
* - Query the ERC725Y storage with the data key {_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY}.
|
|
438
|
+
* 1. Query the ERC725Y storage with the data key `[_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY]`.
|
|
406
439
|
* - If there is an address stored under the data key, check if this address supports the LSP1 interfaceId.
|
|
407
440
|
*
|
|
408
|
-
* - If yes, call this address with the typeId and data (params), along with additional calldata consisting
|
|
409
|
-
* of 20 bytes of {msg.sender} and 32 bytes of {msg.value}. If not, continue the execution of the function.
|
|
441
|
+
* - If yes, call this address with the typeId and data (params), along with additional calldata consisting of 20 bytes of `msg.sender` and 32 bytes of `msg.value`. If not, continue the execution of the function.
|
|
410
442
|
*
|
|
411
443
|
*
|
|
412
|
-
*
|
|
413
|
-
* (Check
|
|
444
|
+
* 2. Query the ERC725Y storage with the data key `[_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY] + <bytes32 typeId>`.
|
|
445
|
+
* (Check [LSP2-ERC725YJSONSchema] for encoding the data key)
|
|
414
446
|
*
|
|
415
447
|
* - If there is an address stored under the data key, check if this address supports the LSP1 interfaceId.
|
|
416
448
|
*
|
|
417
|
-
* - If yes, call this address with the typeId and data (params), along with additional calldata consisting
|
|
418
|
-
* of 20 bytes of {msg.sender} and 32 bytes of {msg.value}. If not, continue the execution of the function.
|
|
419
|
-
*
|
|
420
|
-
* - Emits a {UniversalReceiver} event.
|
|
449
|
+
* - If yes, call this address with the typeId and data (params), along with additional calldata consisting of 20 bytes of `msg.sender` and 32 bytes of `msg.value`. If not, continue the execution of the function.
|
|
421
450
|
*
|
|
422
451
|
* @param typeId The type of call received.
|
|
423
452
|
* @param receivedData The data received.
|
|
424
453
|
*
|
|
425
|
-
* @return returnedValues The ABI encoded return value of the LSP1UniversalReceiverDelegate call
|
|
426
|
-
*
|
|
454
|
+
* @return returnedValues The ABI encoded return value of the LSP1UniversalReceiverDelegate call and the LSP1TypeIdDelegate call.
|
|
455
|
+
*
|
|
456
|
+
* @custom:events
|
|
457
|
+
* - {ValueReceived} when receiving native tokens.
|
|
458
|
+
* - {UniversalReceiver} event.
|
|
427
459
|
*/
|
|
428
|
-
function universalReceiver(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
returns (bytes memory returnedValues)
|
|
433
|
-
{
|
|
460
|
+
function universalReceiver(
|
|
461
|
+
bytes32 typeId,
|
|
462
|
+
bytes calldata receivedData
|
|
463
|
+
) public payable virtual returns (bytes memory returnedValues) {
|
|
434
464
|
if (msg.value != 0) {
|
|
435
465
|
emit ValueReceived(msg.sender, msg.value);
|
|
436
466
|
}
|
|
437
467
|
|
|
438
468
|
// Query the ERC725Y storage with the data key {_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY}
|
|
439
|
-
bytes memory lsp1DelegateValue = _getData(
|
|
469
|
+
bytes memory lsp1DelegateValue = _getData(
|
|
470
|
+
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
|
|
471
|
+
);
|
|
440
472
|
bytes memory resultDefaultDelegate;
|
|
441
473
|
|
|
442
474
|
if (lsp1DelegateValue.length >= 20) {
|
|
443
|
-
address universalReceiverDelegate = address(
|
|
475
|
+
address universalReceiverDelegate = address(
|
|
476
|
+
bytes20(lsp1DelegateValue)
|
|
477
|
+
);
|
|
444
478
|
|
|
445
479
|
// Checking LSP1 InterfaceId support
|
|
446
|
-
if (
|
|
480
|
+
if (
|
|
481
|
+
universalReceiverDelegate.supportsERC165InterfaceUnchecked(
|
|
482
|
+
_INTERFACEID_LSP1
|
|
483
|
+
)
|
|
484
|
+
) {
|
|
447
485
|
// calling {universalReceiver} function on URD appending the caller and the value sent
|
|
448
486
|
resultDefaultDelegate = universalReceiverDelegate
|
|
449
487
|
.callUniversalReceiverWithCallerInfos(
|
|
@@ -466,10 +504,16 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
466
504
|
bytes memory resultTypeIdDelegate;
|
|
467
505
|
|
|
468
506
|
if (lsp1TypeIdDelegateValue.length >= 20) {
|
|
469
|
-
address universalReceiverDelegate = address(
|
|
507
|
+
address universalReceiverDelegate = address(
|
|
508
|
+
bytes20(lsp1TypeIdDelegateValue)
|
|
509
|
+
);
|
|
470
510
|
|
|
471
511
|
// Checking LSP1 InterfaceId support
|
|
472
|
-
if (
|
|
512
|
+
if (
|
|
513
|
+
universalReceiverDelegate.supportsERC165InterfaceUnchecked(
|
|
514
|
+
_INTERFACEID_LSP1
|
|
515
|
+
)
|
|
516
|
+
) {
|
|
473
517
|
// calling {universalReceiver} function on URD appending the caller and the value sent
|
|
474
518
|
resultTypeIdDelegate = universalReceiverDelegate
|
|
475
519
|
.callUniversalReceiverWithCallerInfos(
|
|
@@ -481,45 +525,51 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
481
525
|
}
|
|
482
526
|
}
|
|
483
527
|
|
|
484
|
-
returnedValues = abi.encode(
|
|
485
|
-
|
|
528
|
+
returnedValues = abi.encode(
|
|
529
|
+
resultDefaultDelegate,
|
|
530
|
+
resultTypeIdDelegate
|
|
531
|
+
);
|
|
532
|
+
emit UniversalReceiver(
|
|
533
|
+
msg.sender,
|
|
534
|
+
msg.value,
|
|
535
|
+
typeId,
|
|
536
|
+
receivedData,
|
|
537
|
+
returnedValues
|
|
538
|
+
);
|
|
486
539
|
}
|
|
487
540
|
|
|
488
541
|
/**
|
|
489
542
|
* @notice Achieves the goal of LSP14Ownable2Step by implementing a 2-step ownership transfer process.
|
|
490
543
|
*
|
|
491
|
-
* @dev Sets the
|
|
492
|
-
* the ownership transfer of the account.
|
|
544
|
+
* @dev Sets the address of the `pendingNewOwner` as a pending owner that should call {`acceptOwnership()`} in order to complete
|
|
545
|
+
* the ownership transfer to become the new {`owner()`} of the account.
|
|
493
546
|
*
|
|
494
|
-
* Notifies the pending owner via LSP1Standard by calling {universalReceiver} on the pending owner if it's
|
|
547
|
+
* Notifies the pending owner via LSP1Standard by calling {universalReceiver()} on the pending owner if it's
|
|
495
548
|
* an address that supports LSP1.
|
|
496
549
|
*
|
|
497
|
-
* @param
|
|
498
|
-
*
|
|
499
|
-
* Requirements:
|
|
500
|
-
*
|
|
501
|
-
* - MUST pass when called by the owner or by an authorized address that passes the verification check performed
|
|
502
|
-
* on the owner according to LSP20 - CallVerification specification.
|
|
550
|
+
* @param pendingNewOwner The address of the new pending owner.
|
|
503
551
|
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
* -
|
|
552
|
+
* @custom:requirements
|
|
553
|
+
* - MUST pass when called by the owner or by an authorized address that passes the verification check performed on the owner according to [LSP20-CallVerification] specification.
|
|
554
|
+
* - When notifying the new owner via LSP1, the `typeId` used MUST be `keccak256('LSP0OwnershipTransferStarted')`.
|
|
555
|
+
* - Pending owner cannot accept ownership in the same tx via the LSP1 hook.
|
|
507
556
|
*/
|
|
508
|
-
function transferOwnership(
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
override(LSP14Ownable2Step, OwnableUnset)
|
|
512
|
-
{
|
|
557
|
+
function transferOwnership(
|
|
558
|
+
address pendingNewOwner
|
|
559
|
+
) public virtual override(LSP14Ownable2Step, OwnableUnset) {
|
|
513
560
|
address currentOwner = owner();
|
|
514
561
|
|
|
515
562
|
// If the caller is the owner perform transferOwnership directly
|
|
516
563
|
if (msg.sender == currentOwner) {
|
|
517
564
|
// set the pending owner
|
|
518
|
-
LSP14Ownable2Step._transferOwnership(
|
|
519
|
-
emit OwnershipTransferStarted(currentOwner,
|
|
565
|
+
LSP14Ownable2Step._transferOwnership(pendingNewOwner);
|
|
566
|
+
emit OwnershipTransferStarted(currentOwner, pendingNewOwner);
|
|
520
567
|
|
|
521
568
|
// notify the pending owner through LSP1
|
|
522
|
-
|
|
569
|
+
pendingNewOwner.tryNotifyUniversalReceiver(
|
|
570
|
+
_TYPEID_LSP0_OwnershipTransferStarted,
|
|
571
|
+
""
|
|
572
|
+
);
|
|
523
573
|
|
|
524
574
|
// Require that the owner didn't change after the LSP1 Call
|
|
525
575
|
// (Pending owner didn't automate the acceptOwnership call through LSP1)
|
|
@@ -533,11 +583,14 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
533
583
|
bool verifyAfter = _verifyCall(currentOwner);
|
|
534
584
|
|
|
535
585
|
// Set the pending owner if the call is allowed
|
|
536
|
-
LSP14Ownable2Step._transferOwnership(
|
|
537
|
-
emit OwnershipTransferStarted(currentOwner,
|
|
586
|
+
LSP14Ownable2Step._transferOwnership(pendingNewOwner);
|
|
587
|
+
emit OwnershipTransferStarted(currentOwner, pendingNewOwner);
|
|
538
588
|
|
|
539
589
|
// notify the pending owner through LSP1
|
|
540
|
-
|
|
590
|
+
pendingNewOwner.tryNotifyUniversalReceiver(
|
|
591
|
+
_TYPEID_LSP0_OwnershipTransferStarted,
|
|
592
|
+
""
|
|
593
|
+
);
|
|
541
594
|
|
|
542
595
|
// Require that the owner didn't change after the LSP1 Call
|
|
543
596
|
// (Pending owner didn't automate the acceptOwnership call through LSP1)
|
|
@@ -557,16 +610,16 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
557
610
|
/**
|
|
558
611
|
* @notice Achieves the goal of LSP14Ownable2Step by implementing a 2-step ownership transfer process.
|
|
559
612
|
*
|
|
560
|
-
* @dev Transfer ownership of the contract from the current `owner()` to the `pendingOwner()
|
|
613
|
+
* @dev Transfer ownership of the contract from the current {`owner()`} to the {`pendingOwner()`}.
|
|
561
614
|
*
|
|
562
615
|
* Once this function is called:
|
|
563
|
-
* - the current `owner()` will loose access to the functions restricted to the `owner()` only.
|
|
564
|
-
* - the `pendingOwner()` will gain access to the functions restricted to the `owner()` only.
|
|
616
|
+
* - the current {`owner()`} will loose access to the functions restricted to the {`owner()`} only.
|
|
617
|
+
* - the {`pendingOwner()`} will gain access to the functions restricted to the {`owner()`} only.
|
|
565
618
|
*
|
|
566
|
-
*
|
|
619
|
+
* @custom:requirements
|
|
567
620
|
* - MUST be called by the pendingOwner.
|
|
568
|
-
* - When notifying the previous owner via LSP1, the typeId used MUST be keccak256('LSP0OwnershipTransferred_SenderNotification')
|
|
569
|
-
* - When notifying the new owner via LSP1, the typeId used MUST be keccak256('LSP0OwnershipTransferred_RecipientNotification')
|
|
621
|
+
* - When notifying the previous owner via LSP1, the typeId used MUST be `keccak256('LSP0OwnershipTransferred_SenderNotification')`.
|
|
622
|
+
* - When notifying the new owner via LSP1, the typeId used MUST be `keccak256('LSP0OwnershipTransferred_RecipientNotification')`.
|
|
570
623
|
*/
|
|
571
624
|
function acceptOwnership() public virtual override {
|
|
572
625
|
address previousOwner = owner();
|
|
@@ -594,14 +647,16 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
594
647
|
* 1. the first call will initiate the process of renouncing ownership.
|
|
595
648
|
* 2. the second is used as a confirmation and will leave the contract without an owner.
|
|
596
649
|
*
|
|
597
|
-
* MUST pass when called by the owner or by an authorised address that pass the verification check performed
|
|
598
|
-
*
|
|
650
|
+
* MUST pass when called by the owner or by an authorised address that pass the verification check performed on the owner accordinng to [LSP20-CallVerification] specification
|
|
651
|
+
*
|
|
652
|
+
* @custom:danger Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner will be permanently inaccessible, making these functions not callable anymore and unusable.
|
|
599
653
|
*
|
|
600
|
-
* WARNING: once ownership of the contract has been renounced, any functions
|
|
601
|
-
* that are restricted to be called by the owner will be permanently inaccessible,
|
|
602
|
-
* making these functions not callable anymore and unusable.
|
|
603
654
|
*/
|
|
604
|
-
function renounceOwnership()
|
|
655
|
+
function renounceOwnership()
|
|
656
|
+
public
|
|
657
|
+
virtual
|
|
658
|
+
override(LSP14Ownable2Step, OwnableUnset)
|
|
659
|
+
{
|
|
605
660
|
address _owner = owner();
|
|
606
661
|
|
|
607
662
|
// If the caller is the owner perform renounceOwnership directly
|
|
@@ -634,7 +689,9 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
634
689
|
* `supportsInterface` extension according to LSP17, and checks if the extension
|
|
635
690
|
* implements the interface defined by `interfaceId`.
|
|
636
691
|
*/
|
|
637
|
-
function supportsInterface(
|
|
692
|
+
function supportsInterface(
|
|
693
|
+
bytes4 interfaceId
|
|
694
|
+
)
|
|
638
695
|
public
|
|
639
696
|
view
|
|
640
697
|
virtual
|
|
@@ -652,43 +709,42 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
652
709
|
}
|
|
653
710
|
|
|
654
711
|
/**
|
|
655
|
-
* @notice Achieves the goal of EIP-1271 by validating signatures of smart contracts
|
|
712
|
+
* @notice Achieves the goal of [EIP-1271] by validating signatures of smart contracts
|
|
656
713
|
* according to their own logic.
|
|
657
714
|
*
|
|
658
|
-
* @param dataHash The hash of the data to be validated.
|
|
659
|
-
* @param signature A signature that can validate the previous parameter (Hash).
|
|
660
|
-
*
|
|
661
715
|
* @dev Handles two cases:
|
|
662
716
|
*
|
|
663
|
-
*
|
|
717
|
+
* 1. If the owner is an EOA, recovers an address from the hash and the signature provided:
|
|
664
718
|
*
|
|
665
|
-
* - Returns the magicValue if the address recovered is the same as the owner, indicating
|
|
666
|
-
* that it was a valid signature.
|
|
719
|
+
* - Returns the magicValue if the address recovered is the same as the owner, indicating that it was a valid signature.
|
|
667
720
|
*
|
|
668
721
|
* - If the address is different, it returns the fail value indicating that the signature is not valid.
|
|
669
722
|
*
|
|
670
|
-
*
|
|
723
|
+
* 2. If the owner is a smart contract, it forwards the call of {isValidSignature()} to the owner contract:
|
|
671
724
|
*
|
|
672
|
-
* - If the contract fails or returns the fail value, the {isValidSignature} on the account returns the
|
|
673
|
-
* fail value, indicating that the signature is not valid.
|
|
725
|
+
* - If the contract fails or returns the fail value, the {isValidSignature()} on the account returns the fail value, indicating that the signature is not valid.
|
|
674
726
|
*
|
|
675
|
-
* - If the {isValidSignature} on the owner returned the magicValue, the {isValidSignature} on the account
|
|
676
|
-
*
|
|
727
|
+
* - If the {isValidSignature()} on the owner returned the magicValue, the {isValidSignature()} on the account returns the magicValue, indicating that it's a valid signature.
|
|
728
|
+
*
|
|
729
|
+
* @param dataHash The hash of the data to be validated.
|
|
730
|
+
* @param signature A signature that can validate the previous parameter (Hash).
|
|
677
731
|
*
|
|
678
732
|
* @return magicValue A bytes4 value that indicates if the signature is valid or not.
|
|
679
733
|
*/
|
|
680
|
-
function isValidSignature(
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
returns (bytes4 magicValue)
|
|
685
|
-
{
|
|
734
|
+
function isValidSignature(
|
|
735
|
+
bytes32 dataHash,
|
|
736
|
+
bytes memory signature
|
|
737
|
+
) public view virtual returns (bytes4 magicValue) {
|
|
686
738
|
address _owner = owner();
|
|
687
739
|
|
|
688
740
|
// If owner is a contract
|
|
689
741
|
if (_owner.code.length > 0) {
|
|
690
742
|
(bool success, bytes memory result) = _owner.staticcall(
|
|
691
|
-
abi.encodeWithSelector(
|
|
743
|
+
abi.encodeWithSelector(
|
|
744
|
+
IERC1271.isValidSignature.selector,
|
|
745
|
+
dataHash,
|
|
746
|
+
signature
|
|
747
|
+
)
|
|
692
748
|
);
|
|
693
749
|
|
|
694
750
|
bool isValid = (success &&
|
|
@@ -700,18 +756,20 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
700
756
|
// If owner is an EOA
|
|
701
757
|
else {
|
|
702
758
|
// if isValidSignature fail, the error is catched in returnedError
|
|
703
|
-
(address recoveredAddress, ECDSA.RecoverError returnedError) = ECDSA
|
|
704
|
-
dataHash,
|
|
705
|
-
signature
|
|
706
|
-
);
|
|
759
|
+
(address recoveredAddress, ECDSA.RecoverError returnedError) = ECDSA
|
|
760
|
+
.tryRecover(dataHash, signature);
|
|
707
761
|
|
|
708
762
|
// if recovering throws an error, return the fail value
|
|
709
|
-
if (returnedError != ECDSA.RecoverError.NoError)
|
|
763
|
+
if (returnedError != ECDSA.RecoverError.NoError)
|
|
764
|
+
return _ERC1271_FAILVALUE;
|
|
710
765
|
|
|
711
766
|
// if recovering is successful and the recovered address matches the owner's address,
|
|
712
767
|
// return the ERC1271 magic value. Otherwise, return the ERC1271 fail value
|
|
713
768
|
// matches the address of the owner, otherwise return fail value
|
|
714
|
-
return
|
|
769
|
+
return
|
|
770
|
+
recoveredAddress == _owner
|
|
771
|
+
? _ERC1271_MAGICVALUE
|
|
772
|
+
: _ERC1271_FAILVALUE;
|
|
715
773
|
}
|
|
716
774
|
}
|
|
717
775
|
|
|
@@ -721,19 +779,19 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
721
779
|
* @dev Forwards the call to an extension mapped to a function selector.
|
|
722
780
|
*
|
|
723
781
|
* Calls {_getExtension} to get the address of the extension mapped to the function selector being
|
|
724
|
-
* called on the account. If there is no extension, the address(0) will be returned.
|
|
782
|
+
* called on the account. If there is no extension, the `address(0)` will be returned.
|
|
725
783
|
*
|
|
726
784
|
* Reverts if there is no extension for the function being called, except for the bytes4(0) function
|
|
727
785
|
* selector, which passes even if there is no extension for it.
|
|
728
786
|
*
|
|
729
787
|
* If there is an extension for the function selector being called, it calls the extension with the
|
|
730
|
-
* CALL opcode, passing the
|
|
731
|
-
* 32 bytes of the
|
|
788
|
+
* CALL opcode, passing the `msg.data` appended with the 20 bytes of the `msg.sender` and
|
|
789
|
+
* 32 bytes of the `msg.value`
|
|
732
790
|
*
|
|
733
|
-
* Because the function uses assembly
|
|
734
|
-
* called before other codes in fallback().
|
|
791
|
+
* Because the function uses assembly `return()`/`revert()` to terminate the call, it cannot be
|
|
792
|
+
* called before other codes in {fallback()}.
|
|
735
793
|
*
|
|
736
|
-
* Otherwise, the codes after _fallbackLSP17Extendable() may never be reached.
|
|
794
|
+
* Otherwise, the codes after {_fallbackLSP17Extendable()} may never be reached.
|
|
737
795
|
*/
|
|
738
796
|
function _fallbackLSP17Extendable() internal virtual override {
|
|
739
797
|
// If there is a function selector
|
|
@@ -743,7 +801,8 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
743
801
|
if (msg.sig == bytes4(0) && extension == address(0)) return;
|
|
744
802
|
|
|
745
803
|
// if no extension was found for other function selectors, revert
|
|
746
|
-
if (extension == address(0))
|
|
804
|
+
if (extension == address(0))
|
|
805
|
+
revert NoExtensionFoundForFunctionSelector(msg.sig);
|
|
747
806
|
|
|
748
807
|
// solhint-disable no-inline-assembly
|
|
749
808
|
// if the extension was found, call the extension with the msg.data
|
|
@@ -759,7 +818,15 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
759
818
|
mstore(add(calldatasize(), 20), callvalue())
|
|
760
819
|
|
|
761
820
|
// Add 52 bytes for the msg.sender and msg.value appended at the end of the calldata
|
|
762
|
-
let success := call(
|
|
821
|
+
let success := call(
|
|
822
|
+
gas(),
|
|
823
|
+
extension,
|
|
824
|
+
0,
|
|
825
|
+
0,
|
|
826
|
+
add(calldatasize(), 52),
|
|
827
|
+
0,
|
|
828
|
+
0
|
|
829
|
+
)
|
|
763
830
|
|
|
764
831
|
// Copy the returned data
|
|
765
832
|
returndatacopy(0, 0, returndatasize())
|
|
@@ -777,17 +844,13 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
777
844
|
|
|
778
845
|
/**
|
|
779
846
|
* @dev Returns the extension address stored under the following data key:
|
|
780
|
-
* {_LSP17_EXTENSION_PREFIX + <bytes4>} (Check
|
|
847
|
+
* {_LSP17_EXTENSION_PREFIX + <bytes4>} (Check [LSP2-ERC725YJSONSchema] for encoding the data key)
|
|
781
848
|
*
|
|
782
849
|
* If no extension is stored, returns the address(0)
|
|
783
850
|
*/
|
|
784
|
-
function _getExtension(
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
virtual
|
|
788
|
-
override
|
|
789
|
-
returns (address)
|
|
790
|
-
{
|
|
851
|
+
function _getExtension(
|
|
852
|
+
bytes4 functionSelector
|
|
853
|
+
) internal view virtual override returns (address) {
|
|
791
854
|
// Generate the data key relevant for the functionSelector being called
|
|
792
855
|
bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
|
|
793
856
|
_LSP17_EXTENSION_PREFIX,
|
|
@@ -795,23 +858,30 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
795
858
|
);
|
|
796
859
|
|
|
797
860
|
// Check if there is an extension stored under the generated data key
|
|
798
|
-
address extension = address(
|
|
861
|
+
address extension = address(
|
|
862
|
+
bytes20(ERC725YCore._getData(mappedExtensionDataKey))
|
|
863
|
+
);
|
|
799
864
|
|
|
800
865
|
return extension;
|
|
801
866
|
}
|
|
802
867
|
|
|
803
868
|
/**
|
|
804
|
-
* @
|
|
805
|
-
* emitting the {DataChanged} event with only the first 256 bytes of {dataValue}.
|
|
869
|
+
* @custom:events {DataChanged} event with only the first 256 bytes of {dataValue}.
|
|
806
870
|
*
|
|
871
|
+
* @dev This function overrides the {ERC725YCore} internal {_setData} function to optimize gas usage by
|
|
807
872
|
* @param dataKey The key to store the data value under.
|
|
808
873
|
* @param dataValue The data value to be stored.
|
|
809
874
|
*/
|
|
810
|
-
function _setData(
|
|
875
|
+
function _setData(
|
|
876
|
+
bytes32 dataKey,
|
|
877
|
+
bytes memory dataValue
|
|
878
|
+
) internal virtual override {
|
|
811
879
|
ERC725YCore._store[dataKey] = dataValue;
|
|
812
880
|
emit DataChanged(
|
|
813
881
|
dataKey,
|
|
814
|
-
dataValue.length <= 256
|
|
882
|
+
dataValue.length <= 256
|
|
883
|
+
? dataValue
|
|
884
|
+
: BytesLib.slice(dataValue, 0, 256)
|
|
815
885
|
);
|
|
816
886
|
}
|
|
817
887
|
}
|