@lukso/lsp-smart-contracts 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -7
- package/artifacts/LSP0ERC725Account.json +62 -68
- package/artifacts/LSP0ERC725AccountInit.json +62 -68
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
- package/artifacts/LSP4Compatibility.json +32 -38
- package/artifacts/LSP4DigitalAssetMetadata.json +32 -38
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +32 -38
- package/artifacts/LSP6KeyManager.json +29 -15
- package/artifacts/LSP6KeyManagerInit.json +29 -15
- package/artifacts/LSP7CappedSupply.json +71 -36
- package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -36
- package/artifacts/LSP7CompatibleERC20.json +71 -36
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -36
- package/artifacts/LSP7CompatibleERC20Mintable.json +73 -38
- package/artifacts/LSP7CompatibleERC20MintableInit.json +73 -38
- package/artifacts/LSP7DigitalAsset.json +71 -36
- package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -36
- package/artifacts/LSP7Mintable.json +73 -38
- package/artifacts/LSP7MintableInit.json +73 -38
- package/artifacts/LSP8CappedSupply.json +32 -38
- package/artifacts/LSP8CappedSupplyInitAbstract.json +32 -38
- package/artifacts/LSP8CompatibleERC721.json +35 -41
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +35 -41
- package/artifacts/LSP8CompatibleERC721Mintable.json +37 -43
- package/artifacts/LSP8CompatibleERC721MintableInit.json +37 -43
- package/artifacts/LSP8IdentifiableDigitalAsset.json +32 -38
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +32 -38
- package/artifacts/LSP8Mintable.json +34 -40
- package/artifacts/LSP8MintableInit.json +34 -40
- package/artifacts/LSP9Vault.json +61 -67
- package/artifacts/LSP9VaultInit.json +61 -67
- package/artifacts/UniversalProfile.json +62 -68
- package/artifacts/UniversalProfileInit.json +62 -68
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +45 -10
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +36 -6
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +361 -124
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +30 -4
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +37 -3
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +0 -1
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +30 -15
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +0 -1
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +0 -1
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +5 -7
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +10 -5
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +0 -4
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +91 -34
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +27 -8
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +18 -9
- package/contracts/LSP20CallVerification/LSP20Constants.sol +17 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +26 -12
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +0 -1
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +32 -16
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +11 -2
- package/contracts/LSP6KeyManager/LSP6Constants.sol +5 -5
- package/contracts/LSP6KeyManager/LSP6Errors.sol +10 -6
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +140 -68
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +30 -38
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +153 -60
- package/contracts/LSP6KeyManager/LSP6Utils.sol +1 -5
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +67 -13
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +5 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +2 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +24 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +1 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +1 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +3 -5
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +3 -5
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +15 -12
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +1 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +1 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +5 -5
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +6 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +2 -2
- package/contracts/LSP9Vault/ILSP9Vault.sol +9 -1
- package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +0 -6
- package/contracts/LSP9Vault/LSP9VaultCore.sol +17 -15
- package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +8 -5
- package/contracts/UniversalProfileInitAbstract.sol +5 -0
- package/devdocs/Create2Factory.json +16 -0
- package/devdocs/LSP0ERC725Account.json +200 -0
- package/devdocs/LSP0ERC725AccountInit.json +203 -0
- package/devdocs/LSP11BasicSocialRecovery.json +146 -0
- package/devdocs/LSP11BasicSocialRecoveryInit.json +146 -0
- package/devdocs/LSP16UniversalFactory.json +51 -0
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +80 -0
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +62 -0
- package/devdocs/LSP4Compatibility.json +79 -0
- package/devdocs/LSP4DigitalAssetMetadata.json +84 -0
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +77 -0
- package/devdocs/LSP6KeyManager.json +257 -0
- package/devdocs/LSP6KeyManagerInit.json +260 -0
- package/devdocs/LSP7CappedSupply.json +211 -0
- package/devdocs/LSP7CappedSupplyInitAbstract.json +206 -0
- package/devdocs/LSP7CompatibleERC20.json +225 -0
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +218 -0
- package/devdocs/LSP7CompatibleERC20Mintable.json +217 -0
- package/devdocs/LSP7CompatibleERC20MintableInit.json +227 -0
- package/devdocs/LSP7DigitalAsset.json +210 -0
- package/devdocs/LSP7DigitalAssetInitAbstract.json +202 -0
- package/devdocs/LSP7Mintable.json +219 -0
- package/devdocs/LSP7MintableInit.json +220 -0
- package/devdocs/LSP8CappedSupply.json +232 -0
- package/devdocs/LSP8CappedSupplyInitAbstract.json +227 -0
- package/devdocs/LSP8CompatibleERC721.json +298 -0
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +291 -0
- package/devdocs/LSP8CompatibleERC721Mintable.json +290 -0
- package/devdocs/LSP8CompatibleERC721MintableInit.json +300 -0
- package/devdocs/LSP8IdentifiableDigitalAsset.json +230 -0
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +223 -0
- package/devdocs/LSP8Mintable.json +242 -0
- package/devdocs/LSP8MintableInit.json +245 -0
- package/devdocs/LSP9Vault.json +171 -0
- package/devdocs/LSP9VaultInit.json +175 -0
- package/devdocs/UniversalProfile.json +199 -0
- package/devdocs/UniversalProfileInit.json +202 -0
- package/devdocs/UniversalReceiverAddressStore.json +9 -0
- package/dist/constants.cjs.js +31569 -0
- package/dist/constants.d.ts +31681 -0
- package/dist/constants.es.js +31550 -0
- package/package.json +69 -52
- package/userdocs/Create2Factory.json +5 -0
- package/userdocs/LSP0ERC725Account.json +47 -0
- package/userdocs/LSP0ERC725AccountInit.json +47 -0
- package/userdocs/LSP11BasicSocialRecovery.json +29 -0
- package/userdocs/LSP11BasicSocialRecoveryInit.json +29 -0
- package/userdocs/LSP16UniversalFactory.json +5 -0
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +10 -0
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +10 -0
- package/userdocs/LSP4Compatibility.json +20 -0
- package/userdocs/LSP4DigitalAssetMetadata.json +23 -0
- package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +20 -0
- package/userdocs/LSP6KeyManager.json +18 -0
- package/userdocs/LSP6KeyManagerInit.json +18 -0
- package/userdocs/LSP7CappedSupply.json +29 -0
- package/userdocs/LSP7CappedSupplyInitAbstract.json +26 -0
- package/userdocs/LSP7CompatibleERC20.json +35 -0
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +32 -0
- package/userdocs/LSP7CompatibleERC20Mintable.json +32 -0
- package/userdocs/LSP7CompatibleERC20MintableInit.json +35 -0
- package/userdocs/LSP7DigitalAsset.json +29 -0
- package/userdocs/LSP7DigitalAssetInitAbstract.json +26 -0
- package/userdocs/LSP7Mintable.json +29 -0
- package/userdocs/LSP7MintableInit.json +29 -0
- package/userdocs/LSP8CappedSupply.json +23 -0
- package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -0
- package/userdocs/LSP8CompatibleERC721.json +29 -0
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +26 -0
- package/userdocs/LSP8CompatibleERC721Mintable.json +26 -0
- package/userdocs/LSP8CompatibleERC721MintableInit.json +29 -0
- package/userdocs/LSP8IdentifiableDigitalAsset.json +23 -0
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +20 -0
- package/userdocs/LSP8Mintable.json +23 -0
- package/userdocs/LSP8MintableInit.json +23 -0
- package/userdocs/LSP9Vault.json +38 -0
- package/userdocs/LSP9VaultInit.json +38 -0
- package/userdocs/UniversalProfile.json +50 -0
- package/userdocs/UniversalProfileInit.json +50 -0
- package/userdocs/UniversalReceiverAddressStore.json +5 -0
- package/CONTRIBUTING.md +0 -57
- package/common/constants.d.ts +0 -461
- package/common/constants.js +0 -789
- package/contracts/Utils/GasLib.sol +0 -17
- package/module/constants.d.ts +0 -461
- package/module/constants.js +0 -786
|
@@ -17,7 +17,6 @@ import {LSP6ExecuteModule} from "./LSP6Modules/LSP6ExecuteModule.sol";
|
|
|
17
17
|
import {LSP6OwnershipModule} from "./LSP6Modules/LSP6OwnershipModule.sol";
|
|
18
18
|
|
|
19
19
|
// libraries
|
|
20
|
-
import {GasLib} from "../Utils/GasLib.sol";
|
|
21
20
|
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
22
21
|
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
23
22
|
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
@@ -34,15 +33,15 @@ import {
|
|
|
34
33
|
InvalidRelayNonce,
|
|
35
34
|
NoPermissionsSet,
|
|
36
35
|
InvalidERC725Function,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
CannotSendValueToSetData,
|
|
37
|
+
RelayCallBeforeStartTime,
|
|
38
|
+
RelayCallExpired
|
|
40
39
|
} from "./LSP6Errors.sol";
|
|
41
40
|
|
|
42
41
|
// constants
|
|
43
42
|
import {
|
|
44
43
|
SETDATA_SELECTOR,
|
|
45
|
-
|
|
44
|
+
SETDATA_BATCH_SELECTOR,
|
|
46
45
|
EXECUTE_SELECTOR
|
|
47
46
|
} from "@erc725/smart-contracts/contracts/constants.sol";
|
|
48
47
|
import {
|
|
@@ -56,6 +55,7 @@ import {
|
|
|
56
55
|
_PERMISSION_SIGN,
|
|
57
56
|
_PERMISSION_REENTRANCY
|
|
58
57
|
} from "./LSP6Constants.sol";
|
|
58
|
+
import "../LSP20CallVerification/LSP20Constants.sol";
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* @title Core implementation of the LSP6 Key Manager standard.
|
|
@@ -88,45 +88,6 @@ abstract contract LSP6KeyManagerCore is
|
|
|
88
88
|
return _target;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
/**
|
|
92
|
-
* @inheritdoc ILSP20
|
|
93
|
-
*/
|
|
94
|
-
function lsp20VerifyCall(
|
|
95
|
-
address caller,
|
|
96
|
-
uint256 msgValue,
|
|
97
|
-
bytes calldata data
|
|
98
|
-
) external returns (bytes4) {
|
|
99
|
-
if (msg.sender != _target) revert CallerIsNotTheTarget(msg.sender);
|
|
100
|
-
|
|
101
|
-
bool isSetData = false;
|
|
102
|
-
if (bytes4(data) == SETDATA_SELECTOR || bytes4(data) == SETDATA_ARRAY_SELECTOR) {
|
|
103
|
-
isSetData = true;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
_nonReentrantBefore(isSetData, caller);
|
|
107
|
-
|
|
108
|
-
_verifyPermissions(caller, msgValue, data);
|
|
109
|
-
emit VerifiedCall(msg.sender, msgValue, bytes4(data));
|
|
110
|
-
|
|
111
|
-
// if it's a setData call, do not invoke the `lsp20VerifyCallResult(..)` function
|
|
112
|
-
return
|
|
113
|
-
isSetData
|
|
114
|
-
? bytes4(bytes.concat(bytes3(ILSP20.lsp20VerifyCall.selector), hex"00"))
|
|
115
|
-
: bytes4(bytes.concat(bytes3(ILSP20.lsp20VerifyCall.selector), hex"01"));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @inheritdoc ILSP20
|
|
120
|
-
*/
|
|
121
|
-
function lsp20VerifyCallResult(
|
|
122
|
-
bytes32, /*callHash*/
|
|
123
|
-
bytes memory /*result*/
|
|
124
|
-
) external returns (bytes4) {
|
|
125
|
-
if (msg.sender != _target) revert CallerIsNotTheTarget(msg.sender);
|
|
126
|
-
_nonReentrantAfter();
|
|
127
|
-
return ILSP20.lsp20VerifyCallResult.selector;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
91
|
/**
|
|
131
92
|
* @dev See {IERC165-supportsInterface}.
|
|
132
93
|
*/
|
|
@@ -134,6 +95,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
134
95
|
return
|
|
135
96
|
interfaceId == _INTERFACEID_LSP6 ||
|
|
136
97
|
interfaceId == _INTERFACEID_ERC1271 ||
|
|
98
|
+
interfaceId == _INTERFACEID_LSP20_CALL_VERIFIER ||
|
|
137
99
|
super.supportsInterface(interfaceId);
|
|
138
100
|
}
|
|
139
101
|
|
|
@@ -153,8 +115,16 @@ abstract contract LSP6KeyManagerCore is
|
|
|
153
115
|
view
|
|
154
116
|
returns (bytes4 magicValue)
|
|
155
117
|
{
|
|
156
|
-
|
|
118
|
+
// if isValidSignature fail, the error is catched in returnedError
|
|
119
|
+
(address recoveredAddress, ECDSA.RecoverError returnedError) = ECDSA.tryRecover(
|
|
120
|
+
dataHash,
|
|
121
|
+
signature
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// if recovering throws an error, return the fail value
|
|
125
|
+
if (returnedError != ECDSA.RecoverError.NoError) return _ERC1271_FAILVALUE;
|
|
157
126
|
|
|
127
|
+
// if the address recovered has SIGN permission return the ERC1271 magic value, otherwise the fail value
|
|
158
128
|
return (
|
|
159
129
|
ERC725Y(_target).getPermissionsFor(recoveredAddress).hasPermission(_PERMISSION_SIGN)
|
|
160
130
|
? _ERC1271_MAGICVALUE
|
|
@@ -172,7 +142,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
172
142
|
/**
|
|
173
143
|
* @inheritdoc ILSP6KeyManager
|
|
174
144
|
*/
|
|
175
|
-
function
|
|
145
|
+
function executeBatch(uint256[] calldata values, bytes[] calldata payloads)
|
|
176
146
|
public
|
|
177
147
|
payable
|
|
178
148
|
virtual
|
|
@@ -185,12 +155,16 @@ abstract contract LSP6KeyManagerCore is
|
|
|
185
155
|
bytes[] memory results = new bytes[](payloads.length);
|
|
186
156
|
uint256 totalValues;
|
|
187
157
|
|
|
188
|
-
for (uint256 ii; ii < payloads.length;
|
|
158
|
+
for (uint256 ii; ii < payloads.length; ) {
|
|
189
159
|
if ((totalValues += values[ii]) > msg.value) {
|
|
190
160
|
revert LSP6BatchInsufficientValueSent(totalValues, msg.value);
|
|
191
161
|
}
|
|
192
162
|
|
|
193
163
|
results[ii] = _execute(values[ii], payloads[ii]);
|
|
164
|
+
|
|
165
|
+
unchecked {
|
|
166
|
+
++ii;
|
|
167
|
+
}
|
|
194
168
|
}
|
|
195
169
|
|
|
196
170
|
if (totalValues < msg.value) {
|
|
@@ -206,23 +180,26 @@ abstract contract LSP6KeyManagerCore is
|
|
|
206
180
|
function executeRelayCall(
|
|
207
181
|
bytes memory signature,
|
|
208
182
|
uint256 nonce,
|
|
183
|
+
uint256 validityTimestamps,
|
|
209
184
|
bytes calldata payload
|
|
210
185
|
) public payable virtual returns (bytes memory) {
|
|
211
|
-
return _executeRelayCall(signature, nonce, msg.value, payload);
|
|
186
|
+
return _executeRelayCall(signature, nonce, validityTimestamps, msg.value, payload);
|
|
212
187
|
}
|
|
213
188
|
|
|
214
189
|
/**
|
|
215
190
|
* @inheritdoc ILSP6KeyManager
|
|
216
191
|
*/
|
|
217
|
-
function
|
|
192
|
+
function executeRelayCallBatch(
|
|
218
193
|
bytes[] memory signatures,
|
|
219
194
|
uint256[] calldata nonces,
|
|
195
|
+
uint256[] calldata validityTimestamps,
|
|
220
196
|
uint256[] calldata values,
|
|
221
197
|
bytes[] calldata payloads
|
|
222
198
|
) public payable virtual returns (bytes[] memory) {
|
|
223
199
|
if (
|
|
224
200
|
signatures.length != nonces.length ||
|
|
225
|
-
nonces.length !=
|
|
201
|
+
nonces.length != validityTimestamps.length ||
|
|
202
|
+
validityTimestamps.length != values.length ||
|
|
226
203
|
values.length != payloads.length
|
|
227
204
|
) {
|
|
228
205
|
revert BatchExecuteRelayCallParamsLengthMismatch();
|
|
@@ -231,12 +208,22 @@ abstract contract LSP6KeyManagerCore is
|
|
|
231
208
|
bytes[] memory results = new bytes[](payloads.length);
|
|
232
209
|
uint256 totalValues;
|
|
233
210
|
|
|
234
|
-
for (uint256 ii; ii < payloads.length;
|
|
211
|
+
for (uint256 ii; ii < payloads.length; ) {
|
|
235
212
|
if ((totalValues += values[ii]) > msg.value) {
|
|
236
213
|
revert LSP6BatchInsufficientValueSent(totalValues, msg.value);
|
|
237
214
|
}
|
|
238
215
|
|
|
239
|
-
results[ii] = _executeRelayCall(
|
|
216
|
+
results[ii] = _executeRelayCall(
|
|
217
|
+
signatures[ii],
|
|
218
|
+
nonces[ii],
|
|
219
|
+
validityTimestamps[ii],
|
|
220
|
+
values[ii],
|
|
221
|
+
payloads[ii]
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
unchecked {
|
|
225
|
+
++ii;
|
|
226
|
+
}
|
|
240
227
|
}
|
|
241
228
|
|
|
242
229
|
if (totalValues < msg.value) {
|
|
@@ -246,6 +233,70 @@ abstract contract LSP6KeyManagerCore is
|
|
|
246
233
|
return results;
|
|
247
234
|
}
|
|
248
235
|
|
|
236
|
+
/**
|
|
237
|
+
* @inheritdoc ILSP20
|
|
238
|
+
*/
|
|
239
|
+
function lsp20VerifyCall(
|
|
240
|
+
address caller,
|
|
241
|
+
uint256 msgValue,
|
|
242
|
+
bytes calldata data
|
|
243
|
+
) external returns (bytes4) {
|
|
244
|
+
bool isSetData = false;
|
|
245
|
+
if (bytes4(data) == SETDATA_SELECTOR || bytes4(data) == SETDATA_BATCH_SELECTOR) {
|
|
246
|
+
isSetData = true;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// If target is invoking the verification, emit the event and change the reentrancy guard
|
|
250
|
+
if (msg.sender == _target) {
|
|
251
|
+
bool isReentrantCall = _nonReentrantBefore(isSetData, caller);
|
|
252
|
+
|
|
253
|
+
_verifyPermissions(caller, msgValue, data);
|
|
254
|
+
emit VerifiedCall(caller, msgValue, bytes4(data));
|
|
255
|
+
|
|
256
|
+
// if it's a setData call, do not invoke the `lsp20VerifyCallResult(..)` function
|
|
257
|
+
return
|
|
258
|
+
isSetData || isReentrantCall
|
|
259
|
+
? _LSP20_VERIFY_CALL_MAGIC_VALUE_WITHOUT_POST_VERIFICATION
|
|
260
|
+
: _LSP20_VERIFY_CALL_MAGIC_VALUE_WITH_POST_VERIFICATION;
|
|
261
|
+
}
|
|
262
|
+
// If a different address is invoking the verification, do not change the state
|
|
263
|
+
// and do read-only verification
|
|
264
|
+
else {
|
|
265
|
+
bool isReentrantCall = _reentrancyStatus;
|
|
266
|
+
|
|
267
|
+
if (isReentrantCall) {
|
|
268
|
+
_requirePermissions(
|
|
269
|
+
caller,
|
|
270
|
+
ERC725Y(_target).getPermissionsFor(caller),
|
|
271
|
+
_PERMISSION_REENTRANCY
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
_verifyPermissions(caller, msgValue, data);
|
|
276
|
+
|
|
277
|
+
// if it's a setData call, do not invoke the `lsp20VerifyCallResult(..)` function
|
|
278
|
+
return
|
|
279
|
+
isSetData || isReentrantCall
|
|
280
|
+
? _LSP20_VERIFY_CALL_MAGIC_VALUE_WITHOUT_POST_VERIFICATION
|
|
281
|
+
: _LSP20_VERIFY_CALL_MAGIC_VALUE_WITH_POST_VERIFICATION;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @inheritdoc ILSP20
|
|
287
|
+
*/
|
|
288
|
+
function lsp20VerifyCallResult(
|
|
289
|
+
bytes32, /*callHash*/
|
|
290
|
+
bytes memory /*result*/
|
|
291
|
+
) external returns (bytes4) {
|
|
292
|
+
// If it's the target calling, set back the reentrancy guard
|
|
293
|
+
// to false, if not return the magic value
|
|
294
|
+
if (msg.sender == _target) {
|
|
295
|
+
_nonReentrantAfter();
|
|
296
|
+
}
|
|
297
|
+
return _LSP20_VERIFY_CALL_RESULT_MAGIC_VALUE;
|
|
298
|
+
}
|
|
299
|
+
|
|
249
300
|
function _execute(uint256 msgValue, bytes calldata payload)
|
|
250
301
|
internal
|
|
251
302
|
virtual
|
|
@@ -255,19 +306,19 @@ abstract contract LSP6KeyManagerCore is
|
|
|
255
306
|
revert InvalidPayload(payload);
|
|
256
307
|
}
|
|
257
308
|
|
|
258
|
-
bool isSetData;
|
|
259
|
-
if (bytes4(payload) == SETDATA_SELECTOR || bytes4(payload) ==
|
|
309
|
+
bool isSetData = false;
|
|
310
|
+
if (bytes4(payload) == SETDATA_SELECTOR || bytes4(payload) == SETDATA_BATCH_SELECTOR) {
|
|
260
311
|
isSetData = true;
|
|
261
312
|
}
|
|
262
313
|
|
|
263
|
-
_nonReentrantBefore(isSetData, msg.sender);
|
|
314
|
+
bool isReentrantCall = _nonReentrantBefore(isSetData, msg.sender);
|
|
264
315
|
|
|
265
316
|
_verifyPermissions(msg.sender, msgValue, payload);
|
|
266
317
|
emit VerifiedCall(msg.sender, msgValue, bytes4(payload));
|
|
267
318
|
|
|
268
319
|
bytes memory result = _executePayload(msgValue, payload);
|
|
269
320
|
|
|
270
|
-
if (!isSetData) {
|
|
321
|
+
if (!isReentrantCall && !isSetData) {
|
|
271
322
|
_nonReentrantAfter();
|
|
272
323
|
}
|
|
273
324
|
|
|
@@ -277,6 +328,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
277
328
|
function _executeRelayCall(
|
|
278
329
|
bytes memory signature,
|
|
279
330
|
uint256 nonce,
|
|
331
|
+
uint256 validityTimestamps,
|
|
280
332
|
uint256 msgValue,
|
|
281
333
|
bytes calldata payload
|
|
282
334
|
) internal virtual returns (bytes memory) {
|
|
@@ -288,6 +340,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
288
340
|
LSP6_VERSION,
|
|
289
341
|
block.chainid,
|
|
290
342
|
nonce,
|
|
343
|
+
validityTimestamps,
|
|
291
344
|
msgValue,
|
|
292
345
|
payload
|
|
293
346
|
);
|
|
@@ -296,12 +349,12 @@ abstract contract LSP6KeyManagerCore is
|
|
|
296
349
|
signature
|
|
297
350
|
);
|
|
298
351
|
|
|
299
|
-
bool isSetData;
|
|
300
|
-
if (bytes4(payload) == SETDATA_SELECTOR || bytes4(payload) ==
|
|
352
|
+
bool isSetData = false;
|
|
353
|
+
if (bytes4(payload) == SETDATA_SELECTOR || bytes4(payload) == SETDATA_BATCH_SELECTOR) {
|
|
301
354
|
isSetData = true;
|
|
302
355
|
}
|
|
303
356
|
|
|
304
|
-
_nonReentrantBefore(isSetData, signer);
|
|
357
|
+
bool isReentrantCall = _nonReentrantBefore(isSetData, signer);
|
|
305
358
|
|
|
306
359
|
if (!_isValidNonce(signer, nonce)) {
|
|
307
360
|
revert InvalidRelayNonce(signer, nonce, signature);
|
|
@@ -310,12 +363,25 @@ abstract contract LSP6KeyManagerCore is
|
|
|
310
363
|
// increase nonce after successful verification
|
|
311
364
|
_nonceStore[signer][nonce >> 128]++;
|
|
312
365
|
|
|
366
|
+
if (validityTimestamps != 0) {
|
|
367
|
+
uint128 startingTimestamp = uint128(validityTimestamps >> 128);
|
|
368
|
+
uint128 endingTimestamp = uint128(validityTimestamps);
|
|
369
|
+
|
|
370
|
+
// solhint-disable not-rely-on-time
|
|
371
|
+
if (block.timestamp < startingTimestamp) {
|
|
372
|
+
revert RelayCallBeforeStartTime();
|
|
373
|
+
}
|
|
374
|
+
if (block.timestamp > endingTimestamp) {
|
|
375
|
+
revert RelayCallExpired();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
313
379
|
_verifyPermissions(signer, msgValue, payload);
|
|
314
380
|
emit VerifiedCall(signer, msgValue, bytes4(payload));
|
|
315
381
|
|
|
316
382
|
bytes memory result = _executePayload(msgValue, payload);
|
|
317
383
|
|
|
318
|
-
if (!isSetData) {
|
|
384
|
+
if (!isReentrantCall && !isSetData) {
|
|
319
385
|
_nonReentrantAfter();
|
|
320
386
|
}
|
|
321
387
|
|
|
@@ -353,10 +419,11 @@ abstract contract LSP6KeyManagerCore is
|
|
|
353
419
|
* @param idx (channel id + nonce within the channel)
|
|
354
420
|
*/
|
|
355
421
|
function _isValidNonce(address from, uint256 idx) internal view virtual returns (bool) {
|
|
356
|
-
|
|
357
|
-
//
|
|
358
|
-
//
|
|
359
|
-
|
|
422
|
+
uint256 mask = ~uint128(0);
|
|
423
|
+
// Alternatively:
|
|
424
|
+
// uint256 mask = (1<<128)-1;
|
|
425
|
+
// uint256 mask = 0xffffffffffffffffffffffffffffffff;
|
|
426
|
+
return (idx & mask) == (_nonceStore[from][idx >> 128]);
|
|
360
427
|
}
|
|
361
428
|
|
|
362
429
|
/**
|
|
@@ -381,8 +448,8 @@ abstract contract LSP6KeyManagerCore is
|
|
|
381
448
|
|
|
382
449
|
LSP6SetDataModule._verifyCanSetData(_target, from, permissions, inputKey, inputValue);
|
|
383
450
|
|
|
384
|
-
// ERC725Y.
|
|
385
|
-
} else if (erc725Function ==
|
|
451
|
+
// ERC725Y.setDataBatch(bytes32[],bytes[])
|
|
452
|
+
} else if (erc725Function == SETDATA_BATCH_SELECTOR) {
|
|
386
453
|
if (msgValue != 0) revert CannotSendValueToSetData();
|
|
387
454
|
(bytes32[] memory inputKeys, bytes[] memory inputValues) = abi.decode(
|
|
388
455
|
payload[4:],
|
|
@@ -416,8 +483,13 @@ abstract contract LSP6KeyManagerCore is
|
|
|
416
483
|
* the status is `_ENTERED` in order to revert the call unless the caller has the REENTRANCY permission
|
|
417
484
|
* Used in the beginning of the `nonReentrant` modifier, before the method execution starts.
|
|
418
485
|
*/
|
|
419
|
-
function _nonReentrantBefore(bool isSetData, address from)
|
|
420
|
-
|
|
486
|
+
function _nonReentrantBefore(bool isSetData, address from)
|
|
487
|
+
internal
|
|
488
|
+
virtual
|
|
489
|
+
returns (bool isReentrantCall)
|
|
490
|
+
{
|
|
491
|
+
isReentrantCall = _reentrancyStatus;
|
|
492
|
+
if (isReentrantCall) {
|
|
421
493
|
// CHECK the caller has REENTRANCY permission
|
|
422
494
|
_requirePermissions(
|
|
423
495
|
from,
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
6
5
|
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
7
6
|
import {LSP6KeyManagerCore} from "./LSP6KeyManagerCore.sol";
|
|
8
7
|
import {InvalidLSP6Target} from "./LSP6Errors.sol";
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
|
-
// interfaces
|
|
5
|
-
import {
|
|
6
|
-
ILSP20CallVerification as ILSP20
|
|
7
|
-
} from "../../LSP20CallVerification/ILSP20CallVerification.sol";
|
|
8
|
-
|
|
9
4
|
// modules
|
|
10
5
|
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
11
6
|
|
|
@@ -23,12 +18,10 @@ import {
|
|
|
23
18
|
_PERMISSION_SUPER_CALL,
|
|
24
19
|
_PERMISSION_STATICCALL,
|
|
25
20
|
_PERMISSION_SUPER_STATICCALL,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
_ALLOWEDCALLS_READ,
|
|
31
|
-
_ALLOWEDCALLS_EXECUTE
|
|
21
|
+
_ALLOWEDCALLS_TRANSFERVALUE,
|
|
22
|
+
_ALLOWEDCALLS_CALL,
|
|
23
|
+
_ALLOWEDCALLS_STATICCALL,
|
|
24
|
+
_ALLOWEDCALLS_DELEGATECALL
|
|
32
25
|
} from "../LSP6Constants.sol";
|
|
33
26
|
import {
|
|
34
27
|
OPERATION_0_CALL,
|
|
@@ -218,7 +211,8 @@ abstract contract LSP6ExecuteModule {
|
|
|
218
211
|
uint256 operationType,
|
|
219
212
|
address to,
|
|
220
213
|
uint256 value,
|
|
221
|
-
bytes4 selector
|
|
214
|
+
bytes4 selector,
|
|
215
|
+
bool isEmptyCall
|
|
222
216
|
) = _extractExecuteParameters(payload);
|
|
223
217
|
|
|
224
218
|
// CHECK for ALLOWED CALLS
|
|
@@ -230,7 +224,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
230
224
|
revert NoCallsAllowed(controllerAddress);
|
|
231
225
|
}
|
|
232
226
|
|
|
233
|
-
bytes4 requiredCallTypes = _extractCallType(operationType,
|
|
227
|
+
bytes4 requiredCallTypes = _extractCallType(operationType, value, isEmptyCall);
|
|
234
228
|
|
|
235
229
|
for (uint256 ii; ii < allowedCalls.length; ii += 34) {
|
|
236
230
|
/// @dev structure of an AllowedCall
|
|
@@ -272,37 +266,28 @@ abstract contract LSP6ExecuteModule {
|
|
|
272
266
|
/**
|
|
273
267
|
* @dev extract the bytes4 representation of a single bit for the type of call according to the `operationType`
|
|
274
268
|
* @param operationType 0 = CALL, 3 = STATICCALL or 3 = DELEGATECALL
|
|
275
|
-
* @return a bytes4 value containing a single 1 bit for the callType
|
|
269
|
+
* @return requiredCallTypes a bytes4 value containing a single 1 bit for the callType
|
|
276
270
|
*/
|
|
277
271
|
function _extractCallType(
|
|
278
272
|
uint256 operationType,
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
) internal pure returns (bytes4) {
|
|
282
|
-
bytes4 requiredCallTypes;
|
|
283
|
-
|
|
284
|
-
if (operationType == OPERATION_0_CALL) {
|
|
285
|
-
if (
|
|
286
|
-
// CHECK if we are doing an empty call
|
|
287
|
-
(selector == bytes4(0) && value == 0) ||
|
|
288
|
-
// we do not require callType CALL
|
|
289
|
-
// if we are just transferring value without `data`
|
|
290
|
-
selector != bytes4(0)
|
|
291
|
-
) {
|
|
292
|
-
requiredCallTypes = _ALLOWEDCALLS_WRITE;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (operationType == OPERATION_3_STATICCALL) requiredCallTypes = _ALLOWEDCALLS_READ;
|
|
297
|
-
if (operationType == OPERATION_4_DELEGATECALL) requiredCallTypes = _ALLOWEDCALLS_EXECUTE;
|
|
298
|
-
|
|
273
|
+
uint256 value,
|
|
274
|
+
bool isEmptyCall
|
|
275
|
+
) internal pure returns (bytes4 requiredCallTypes) {
|
|
299
276
|
// if there is value being transferred, add the extra bit
|
|
300
277
|
// for the first bit for Value Transfer in the `requiredCallTypes`
|
|
301
278
|
if (value != 0) {
|
|
302
|
-
requiredCallTypes |=
|
|
279
|
+
requiredCallTypes |= _ALLOWEDCALLS_TRANSFERVALUE;
|
|
303
280
|
}
|
|
304
281
|
|
|
305
|
-
|
|
282
|
+
if (!isEmptyCall) {
|
|
283
|
+
if (operationType == OPERATION_0_CALL) {
|
|
284
|
+
requiredCallTypes |= _ALLOWEDCALLS_CALL;
|
|
285
|
+
} else if (operationType == OPERATION_3_STATICCALL) {
|
|
286
|
+
requiredCallTypes |= _ALLOWEDCALLS_STATICCALL;
|
|
287
|
+
} else if (operationType == OPERATION_4_DELEGATECALL) {
|
|
288
|
+
requiredCallTypes |= _ALLOWEDCALLS_DELEGATECALL;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
306
291
|
}
|
|
307
292
|
|
|
308
293
|
function _extractExecuteParameters(bytes calldata executeCalldata)
|
|
@@ -312,11 +297,18 @@ abstract contract LSP6ExecuteModule {
|
|
|
312
297
|
uint256,
|
|
313
298
|
address,
|
|
314
299
|
uint256,
|
|
315
|
-
bytes4
|
|
300
|
+
bytes4,
|
|
301
|
+
bool
|
|
316
302
|
)
|
|
317
303
|
{
|
|
318
304
|
uint256 operationType = uint256(bytes32(executeCalldata[4:36]));
|
|
305
|
+
|
|
306
|
+
// CHECK that it is a valid address left-padded with `00` on the 12 upper bytes
|
|
307
|
+
if (bytes12(executeCalldata[36:48]) != bytes12(0)) {
|
|
308
|
+
revert InvalidPayload(executeCalldata);
|
|
309
|
+
}
|
|
319
310
|
address to = address(bytes20(executeCalldata[48:68]));
|
|
311
|
+
|
|
320
312
|
uint256 value = uint256(bytes32(executeCalldata[68:100]));
|
|
321
313
|
|
|
322
314
|
// CHECK if there is at least a 4 bytes function selector
|
|
@@ -324,7 +316,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
324
316
|
? bytes4(executeCalldata[164:168])
|
|
325
317
|
: bytes4(0);
|
|
326
318
|
|
|
327
|
-
return (operationType, to, value, selector);
|
|
319
|
+
return (operationType, to, value, selector, executeCalldata.length == 164);
|
|
328
320
|
}
|
|
329
321
|
|
|
330
322
|
function _isAllowedAddress(bytes memory allowedCall, address to) internal pure returns (bool) {
|