Skip to content

Commit

Permalink
add userOp for validator api
Browse files Browse the repository at this point in the history
  • Loading branch information
ququzone committed Nov 24, 2023
1 parent afdb187 commit 889b5fe
Show file tree
Hide file tree
Showing 90 changed files with 1,502 additions and 507 deletions.
2 changes: 1 addition & 1 deletion contracts/SmartAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contract SmartAccount is
if (!isValidatorEnabled(validator)) {
return SIG_VALIDATION_FAILED;
}
return IValidator(validator).validateSignature(userOp.sender, userOpHash, signature);
return IValidator(validator).validateSignature(userOp, userOpHash, signature);
}

function recovery(address validator, bytes calldata data) external {
Expand Down
3 changes: 2 additions & 1 deletion contracts/interfaces/IValidator.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {UserOperation} from "@account-abstraction/contracts/interfaces/UserOperation.sol";
import "./Metadata.sol";

interface IValidator is Metadata {
function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)
function validateSignature(UserOperation calldata userOp, bytes32 userOpHash, bytes calldata signature)
external
payable
returns (uint256 validationData);
Expand Down
4 changes: 2 additions & 2 deletions contracts/validators/ECDSAValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ contract ECDSAValidator is BaseValidator {

mapping(address => address) public owner;

function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)
function validateSignature(UserOperation calldata userOp, bytes32 userOpHash, bytes calldata signature)
external
payable
override
returns (uint256 validationData)
{
address _owner = owner[account];
address _owner = owner[userOp.sender];
bytes32 hash = ECDSA.toEthSignedMessageHash(userOpHash);
if (_owner != ECDSA.recover(hash, signature)) {
return Contants.SIG_VALIDATION_FAILED;
Expand Down
24 changes: 24 additions & 0 deletions contracts/validators/OIDCSessionOnlyValidator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "../common/Contants.sol";
import "./BaseValidator.sol";

// OIDC ZK based validator that can only to add session validator
contract OIDCSessionOnlyValidator is BaseValidator {
string public constant override NAME = "OIDC Validator";
string public constant override VERSION = "0.0.1";

function validateSignature(UserOperation calldata userOp, bytes32 userOpHash, bytes calldata signature)
external
payable
override
returns (uint256 validationData)
{}

function validCaller(address caller, bytes calldata data) external view override returns (bool) {}

function enable(bytes calldata data) external payable override {}
}
4 changes: 2 additions & 2 deletions contracts/validators/p256/P256Validator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ contract P256Validator is BaseValidator {
impl = _impl;
}

function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)
function validateSignature(UserOperation calldata userOp, bytes32 userOpHash, bytes calldata signature)
external
payable
override
returns (uint256 validationData)
{
if (impl.validateSignature(sha256(abi.encode(userOpHash)), signature, pks[account])) {
if (impl.validateSignature(sha256(abi.encode(userOpHash)), signature, pks[userOp.sender])) {
return 0;
}
return Contants.SIG_VALIDATION_FAILED;
Expand Down
4 changes: 2 additions & 2 deletions contracts/validators/p256/WebauthnValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract WebauthnValidator is BaseValidator {
impl = _impl;
}

function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)
function validateSignature(UserOperation calldata userOp, bytes32 userOpHash, bytes calldata signature)
external
payable
override
Expand All @@ -42,7 +42,7 @@ contract WebauthnValidator is BaseValidator {
sig = realSig;
}

if (impl.validateSignature(messageHash, sig, pks[account])) {
if (impl.validateSignature(messageHash, sig, pks[userOp.sender])) {
return 0;
}
return Contants.SIG_VALIDATION_FAILED;
Expand Down
4 changes: 2 additions & 2 deletions contracts/validators/sessionkey/OwnerSessionKeyValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract OwnerSessionKeyValidator is BaseValidator {

mapping(address sessionKey => mapping(address account => SessionKeyStorage)) public sessionKeyStorage;

function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)
function validateSignature(UserOperation calldata userOp, bytes32 userOpHash, bytes calldata signature)
external
payable
override
Expand All @@ -30,7 +30,7 @@ contract OwnerSessionKeyValidator is BaseValidator {
bytes32 hash = ECDSA.toEthSignedMessageHash(userOpHash);
address recovered = ECDSA.recover(hash, signature);

SessionKeyStorage storage sessionKey = sessionKeyStorage[recovered][account];
SessionKeyStorage storage sessionKey = sessionKeyStorage[recovered][userOp.sender];
if (sessionKey.validUntil == 0) {
return Contants.SIG_VALIDATION_FAILED;
}
Expand Down
12 changes: 6 additions & 6 deletions src/types/@account-abstraction/contracts/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { BaseAccount } from "./BaseAccount";
export type { BasePaymaster } from "./BasePaymaster";
export type { EntryPoint } from "./EntryPoint";
export type { NonceManager } from "./NonceManager";
export type { SenderCreator } from "./SenderCreator";
export type { StakeManager } from "./StakeManager";
export type { BaseAccount } from './BaseAccount'
export type { BasePaymaster } from './BasePaymaster'
export type { EntryPoint } from './EntryPoint'
export type { NonceManager } from './NonceManager'
export type { SenderCreator } from './SenderCreator'
export type { StakeManager } from './StakeManager'
12 changes: 6 additions & 6 deletions src/types/@account-abstraction/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as core from "./core";
export type { core };
import type * as interfaces from "./interfaces";
export type { interfaces };
import type * as samples from "./samples";
export type { samples };
import type * as core from './core'
export type { core }
import type * as interfaces from './interfaces'
export type { interfaces }
import type * as samples from './samples'
export type { samples }
12 changes: 6 additions & 6 deletions src/types/@account-abstraction/contracts/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { IAccount } from "./IAccount";
export type { IAggregator } from "./IAggregator";
export type { IEntryPoint } from "./IEntryPoint";
export type { INonceManager } from "./INonceManager";
export type { IPaymaster } from "./IPaymaster";
export type { IStakeManager } from "./IStakeManager";
export type { IAccount } from './IAccount'
export type { IAggregator } from './IAggregator'
export type { IEntryPoint } from './IEntryPoint'
export type { INonceManager } from './INonceManager'
export type { IPaymaster } from './IPaymaster'
export type { IStakeManager } from './IStakeManager'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { TokenCallbackHandler } from "./TokenCallbackHandler";
export type { TokenCallbackHandler } from './TokenCallbackHandler'
4 changes: 2 additions & 2 deletions src/types/@account-abstraction/contracts/samples/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as callback from "./callback";
export type { callback };
import type * as callback from './callback'
export type { callback }
4 changes: 2 additions & 2 deletions src/types/@account-abstraction/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as contracts from "./contracts";
export type { contracts };
import type * as contracts from './contracts'
export type { contracts }
2 changes: 1 addition & 1 deletion src/types/@openzeppelin/contracts/access/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { Ownable } from "./Ownable";
export type { Ownable } from './Ownable'
20 changes: 10 additions & 10 deletions src/types/@openzeppelin/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as access from "./access";
export type { access };
import type * as interfaces from "./interfaces";
export type { interfaces };
import type * as proxy from "./proxy";
export type { proxy };
import type * as token from "./token";
export type { token };
import type * as utils from "./utils";
export type { utils };
import type * as access from './access'
export type { access }
import type * as interfaces from './interfaces'
export type { interfaces }
import type * as proxy from './proxy'
export type { proxy }
import type * as token from './token'
export type { token }
import type * as utils from './utils'
export type { utils }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { IERC1822Proxiable } from "./IERC1822Proxiable";
export type { IERC1822Proxiable } from './IERC1822Proxiable'
6 changes: 3 additions & 3 deletions src/types/@openzeppelin/contracts/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as draftIerc1822Sol from "./draft-IERC1822.sol";
export type { draftIerc1822Sol };
export type { IERC1967 } from "./IERC1967";
import type * as draftIerc1822Sol from './draft-IERC1822.sol'
export type { draftIerc1822Sol }
export type { IERC1967 } from './IERC1967'
4 changes: 2 additions & 2 deletions src/types/@openzeppelin/contracts/proxy/ERC1967/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { ERC1967Proxy } from "./ERC1967Proxy";
export type { ERC1967Upgrade } from "./ERC1967Upgrade";
export type { ERC1967Proxy } from './ERC1967Proxy'
export type { ERC1967Upgrade } from './ERC1967Upgrade'
2 changes: 1 addition & 1 deletion src/types/@openzeppelin/contracts/proxy/beacon/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { IBeacon } from "./IBeacon";
export type { IBeacon } from './IBeacon'
14 changes: 7 additions & 7 deletions src/types/@openzeppelin/contracts/proxy/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as erc1967 from "./ERC1967";
export type { erc1967 };
import type * as beacon from "./beacon";
export type { beacon };
import type * as utils from "./utils";
export type { utils };
export type { Proxy } from "./Proxy";
import type * as erc1967 from './ERC1967'
export type { erc1967 }
import type * as beacon from './beacon'
export type { beacon }
import type * as utils from './utils'
export type { utils }
export type { Proxy } from './Proxy'
2 changes: 1 addition & 1 deletion src/types/@openzeppelin/contracts/proxy/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { Initializable } from "./Initializable";
export type { Initializable } from './Initializable'
2 changes: 1 addition & 1 deletion src/types/@openzeppelin/contracts/token/ERC1155/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { IERC1155Receiver } from "./IERC1155Receiver";
export type { IERC1155Receiver } from './IERC1155Receiver'
2 changes: 1 addition & 1 deletion src/types/@openzeppelin/contracts/token/ERC721/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { IERC721Receiver } from "./IERC721Receiver";
export type { IERC721Receiver } from './IERC721Receiver'
2 changes: 1 addition & 1 deletion src/types/@openzeppelin/contracts/token/ERC777/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { IERC777Recipient } from "./IERC777Recipient";
export type { IERC777Recipient } from './IERC777Recipient'
12 changes: 6 additions & 6 deletions src/types/@openzeppelin/contracts/token/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as erc1155 from "./ERC1155";
export type { erc1155 };
import type * as erc721 from "./ERC721";
export type { erc721 };
import type * as erc777 from "./ERC777";
export type { erc777 };
import type * as erc1155 from './ERC1155'
export type { erc1155 }
import type * as erc721 from './ERC721'
export type { erc721 }
import type * as erc777 from './ERC777'
export type { erc777 }
4 changes: 2 additions & 2 deletions src/types/@openzeppelin/contracts/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as introspection from "./introspection";
export type { introspection };
import type * as introspection from './introspection'
export type { introspection }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { IERC165 } from "./IERC165";
export type { IERC165 } from './IERC165'
4 changes: 2 additions & 2 deletions src/types/@openzeppelin/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as contracts from "./contracts";
export type { contracts };
import type * as contracts from './contracts'
export type { contracts }
46 changes: 16 additions & 30 deletions src/types/common.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,30 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type { Listener } from "@ethersproject/providers";
import type { Event, EventFilter } from "ethers";

export interface TypedEvent<
TArgsArray extends Array<any> = any,
TArgsObject = any
> extends Event {
args: TArgsArray & TArgsObject;
import type { Listener } from '@ethersproject/providers'
import type { Event, EventFilter } from 'ethers'

export interface TypedEvent<TArgsArray extends Array<any> = any, TArgsObject = any> extends Event {
args: TArgsArray & TArgsObject
}

export interface TypedEventFilter<_TEvent extends TypedEvent>
extends EventFilter {}
export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {}

export interface TypedListener<TEvent extends TypedEvent> {
(...listenerArg: [...__TypechainArgsArray<TEvent>, TEvent]): void;
(...listenerArg: [...__TypechainArgsArray<TEvent>, TEvent]): void
}

type __TypechainArgsArray<T> = T extends TypedEvent<infer U> ? U : never;
type __TypechainArgsArray<T> = T extends TypedEvent<infer U> ? U : never

export interface OnEvent<TRes> {
<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>,
listener: TypedListener<TEvent>
): TRes;
(eventName: string, listener: Listener): TRes;
<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>, listener: TypedListener<TEvent>): TRes
(eventName: string, listener: Listener): TRes
}

export type MinEthersFactory<C, ARGS> = {
deploy(...a: ARGS[]): Promise<C>;
};

export type GetContractTypeFromFactory<F> = F extends MinEthersFactory<
infer C,
any
>
? C
: never;

export type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any>
? Parameters<F["deploy"]>
: never;
deploy(...a: ARGS[]): Promise<C>
}

export type GetContractTypeFromFactory<F> = F extends MinEthersFactory<infer C, any> ? C : never

export type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any> ? Parameters<F['deploy']> : never
4 changes: 2 additions & 2 deletions src/types/contracts/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { Authority } from "./Authority";
export type { EntryPointAuth } from "./EntryPointAuth";
export type { Authority } from './Authority'
export type { EntryPointAuth } from './EntryPointAuth'
Loading

0 comments on commit 889b5fe

Please sign in to comment.