This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
forked from getclave/clave-contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add session key module validator (#16)
* feat: add module validator and session keys module * chore: timestamp asserter testnet deploy * fix: validation handler should check for module validators * fix tests * t * additional checks * fix cast * t * t * move self target check to SessionLib.validate * rework batch caller to be part of account implementation; fee calc after validation in session key validator * fix session key * revert hh config * lock zksolc version
- Loading branch information
1 parent
4499660
commit a34c603
Showing
33 changed files
with
783 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import {ITimestampAsserter} from "../interfaces/ITimestampAsserter.sol"; | ||
|
||
error TimestampOutOfRange(uint256 currentTimestamp, uint256 start, uint256 end); | ||
|
||
/// @title TimestampAsserter | ||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
/// @dev A contract that verifies if the current block timestamp falls within a specified range. | ||
/// This is useful for custom account abstraction where time-bound checks are needed but accessing block.timestamp | ||
/// directly is not possible. | ||
contract TimestampAsserter is ITimestampAsserter { | ||
function assertTimestampInRange(uint256 _start, uint256 _end) external view { | ||
if (block.timestamp < _start || block.timestamp > _end) { | ||
revert TimestampOutOfRange(block.timestamp, _start, _end); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import "../interfaces/ITimestampAsserter.sol"; | ||
|
||
library TimestampAsserterLocator { | ||
function locate() internal view returns (ITimestampAsserter) { | ||
if (block.chainid == 260) { | ||
return ITimestampAsserter(address(0x00000000000000000000000000000000808012)); | ||
} | ||
if (block.chainid == 11124) { | ||
return ITimestampAsserter(address(0x27570660a298db7373EaA50c1a728DA93b5BC969)); | ||
} | ||
if (block.chainid == 300) { | ||
revert("Timestamp asserter is not deployed on ZKsync Sepolia testnet yet"); | ||
} | ||
if (block.chainid == 324) { | ||
revert("Timestamp asserter is not deployed on ZKsync mainnet yet"); | ||
} | ||
revert("Timestamp asserter is not deployed on this network"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.24; | ||
|
||
/** | ||
* @title Modular validator interface for native AA | ||
* @dev Add signature to module or validate existing signatures for acccount | ||
*/ | ||
interface IModuleValidator { | ||
function handleValidation(bytes32 signedHash, bytes memory signature) external view returns (bool); | ||
|
||
function addValidationKey(bytes memory key) external returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
interface ITimestampAsserter { | ||
function assertTimestampInRange(uint256 start, uint256 end) external view; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.