diff --git a/hardhat.config.ts b/hardhat.config.ts index 1faa15b6..17a15383 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -52,7 +52,10 @@ const config: HardhatUserConfig = { }, }, solidity: { - version: "0.8.24", + version: "0.8.28", + settings: { + evmVersion: "cancun", + } }, }; diff --git a/src/helpers/Base64.sol b/src/helpers/Base64.sol index e258fc8b..b4f452fe 100644 --- a/src/helpers/Base64.sol +++ b/src/helpers/Base64.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Base64.sol) -pragma solidity 0.8.24; +pragma solidity ^0.8.24; /** * @dev Provides a set of functions to operate with Base64 strings. diff --git a/src/helpers/EIP712.sol b/src/helpers/EIP712.sol index 140777f8..00505f43 100644 --- a/src/helpers/EIP712.sol +++ b/src/helpers/EIP712.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) -pragma solidity 0.8.24; +pragma solidity ^0.8.24; // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) diff --git a/src/helpers/TokenCallbackHandler.sol b/src/helpers/TokenCallbackHandler.sol index 6703ef8a..4693f8d7 100644 --- a/src/helpers/TokenCallbackHandler.sol +++ b/src/helpers/TokenCallbackHandler.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity 0.8.24; +pragma solidity ^0.8.24; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; diff --git a/src/helpers/VerifierCaller.sol b/src/helpers/VerifierCaller.sol index c975f8f9..41ce61fc 100644 --- a/src/helpers/VerifierCaller.sol +++ b/src/helpers/VerifierCaller.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity 0.8.24; +pragma solidity ^0.8.24; abstract contract VerifierCaller { /** diff --git a/src/test/VerifierCaller.sol b/src/test/VerifierCaller.sol index 811e2eaa..63a43460 100644 --- a/src/test/VerifierCaller.sol +++ b/src/test/VerifierCaller.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity 0.8.24; +pragma solidity ^0.8.24; abstract contract VerifierCaller { /** diff --git a/src/validators/SessionKeyValidator.sol b/src/validators/SessionKeyValidator.sol index ccdb4f3b..dda287c3 100644 --- a/src/validators/SessionKeyValidator.sol +++ b/src/validators/SessionKeyValidator.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.23; +pragma solidity ^0.8.24; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; @@ -30,6 +30,15 @@ contract SessionKeyValidator is IValidationHook, IModuleValidator, IModule { // session hash => session state mapping(bytes32 => SessionLib.SessionStorage) private sessions; + modifier onlyWithValidationHook(uint256 slot) { + uint256 hookResult; + assembly { + hookResult := tload(slot) + } + require(hookResult == 1, "Can't call this function without calling validationHook"); + _; + } + function sessionState( address account, SessionLib.SessionSpec calldata spec @@ -114,9 +123,9 @@ contract SessionKeyValidator is IValidationHook, IModuleValidator, IModule { } /* - * If there are any spend limits configured + * Check if the validator is registered for the smart account * @param smartAccount The smart account to check - * @return true if spend limits are configured initialized, false otherwise + * @return true if validator is registered for the account, false otherwise */ function isInitialized(address smartAccount) external view returns (bool) { return _isInitialized(smartAccount); @@ -127,12 +136,12 @@ contract SessionKeyValidator is IValidationHook, IModuleValidator, IModule { // && IValidatorManager(smartAccount).isModuleValidator(address(this)); } - /* - * Currently doing 1271 validation, but might update the interface to match the zksync account validation - */ - function isValidSignature(bytes32 hash, bytes memory signature) public view returns (bytes4 magic) { + function isValidSignature( + bytes32 hash, + bytes memory signature + ) public view onlyWithValidationHook(uint256(hash)) returns (bytes4 magic) { + // Only succeeds if validationHook has previously succeeded. magic = EIP1271_SUCCESS_RETURN_VALUE; - // TODO: Does this method have to work standalone? If not, validationHook is sufficient for validation. } function validationHook(bytes32 signedHash, Transaction calldata transaction, bytes calldata hookData) external { @@ -146,6 +155,12 @@ contract SessionKeyValidator is IValidationHook, IModuleValidator, IModule { require(recoveredAddress == spec.signer, "Invalid signer"); bytes32 sessionHash = keccak256(abi.encode(spec)); sessions[sessionHash].validate(transaction, spec); + + // Set the validation result to 1 for this hash, so that isValidSignature succeeds + uint256 slot = uint256(signedHash); + assembly { + tstore(slot, 1) + } } /**