diff --git a/CHANGELOG.md b/CHANGELOG.md index ec1f2cc..0c6b4a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## [1.1.2] - 2024-07-10 +### New +- Added `SessionKeyValidator` module for ERC20 SessionKeyValidator. +- Added `enableSessionKey`, `rotateSessionKey`, `disableSessionKey`, and `getAssociatedSessionKeys` functions to `SessionKeyValidator`. ## [1.1.1] - 2024-07-08 ### Feature Enhancement diff --git a/examples/13-enable-sessionkey-module.ts b/examples/13-enable-sessionkey-module.ts new file mode 100644 index 0000000..5259d58 --- /dev/null +++ b/examples/13-enable-sessionkey-module.ts @@ -0,0 +1,65 @@ +import { EtherspotBundler, ModularSdk, SessionKeyValidator } from '../src'; +import * as dotenv from 'dotenv'; +import { sleep } from '../src/sdk/common'; +import { KeyStore } from '../src/sdk/SessionKeyValidator'; + +dotenv.config(); + +async function main() { + const bundlerApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjMxMDZiOGY2NTRhZTRhZTM4MGVjYjJiN2Q2NDMzMjM4IiwiaCI6Im11cm11cjEyOCJ9'; + + // initializating sdk... + const modularSdk = new ModularSdk({ privateKey: process.env.WALLET_PRIVATE_KEY }, + { + chainId: Number(process.env.CHAIN_ID), + bundlerProvider: new EtherspotBundler(Number(process.env.CHAIN_ID), bundlerApiKey) + }) + + console.log('address: ', modularSdk.state.EOAAddress); + + // get address of EtherspotWallet + const address: string = await modularSdk.getCounterFactualAddress(); + + console.log('\x1b[33m%s\x1b[0m', `EtherspotWallet address: ${address}`); + + const token = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'; + const functionSelector = '0xa9059cbb'; + const spendingLimit = '100000'; + const validAfter = new Date().getTime(); + const validUntil = new Date().getTime() + 24 * 60 * 60 * 1000; + + // get instance of SessionKeyValidator + const sessionKeyModule = new SessionKeyValidator( + modularSdk, + new EtherspotBundler(Number(process.env.CHAIN_ID), bundlerApiKey) + ) + + const response = await sessionKeyModule.enableSessionKey( + token, + functionSelector, + spendingLimit, + validAfter, + validUntil, + KeyStore.AWS + ); + + console.log('\x1b[33m%s\x1b[0m', `UserOpHash: `, response.userOpHash); + console.log('\x1b[33m%s\x1b[0m', `SessionKey: `, response.sessionKey); + + // get transaction hash... + console.log('Waiting for transaction...'); + let userOpsReceipt = null; + const timeout = Date.now() + 60000; // 1 minute timeout + while ((userOpsReceipt == null) && (Date.now() < timeout)) { + await sleep(2); + userOpsReceipt = await modularSdk.getUserOpReceipt(response.userOpHash); + } + console.log('\x1b[33m%s\x1b[0m', `Transaction Receipt: `, userOpsReceipt); + + const sessionKeys = await sessionKeyModule.getAssociatedSessionKeys(); + console.log('\x1b[33m%s\x1b[0m', `AssociatedSessionKeys: `, sessionKeys); +} + +main() + .catch(console.error) + .finally(() => process.exit()); diff --git a/examples/14-rotate-sessionkey-module.ts b/examples/14-rotate-sessionkey-module.ts new file mode 100644 index 0000000..8f32d89 --- /dev/null +++ b/examples/14-rotate-sessionkey-module.ts @@ -0,0 +1,65 @@ +import { EtherspotBundler, ModularSdk, SessionKeyValidator } from '../src'; +import * as dotenv from 'dotenv'; +import { sleep } from '../src/sdk/common'; +import { KeyStore } from '../src/sdk/SessionKeyValidator'; + +dotenv.config(); + +async function main() { + const bundlerApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjMxMDZiOGY2NTRhZTRhZTM4MGVjYjJiN2Q2NDMzMjM4IiwiaCI6Im11cm11cjEyOCJ9'; + + // initializating sdk... + const modularSdk = new ModularSdk({ privateKey: process.env.WALLET_PRIVATE_KEY }, + { + chainId: Number(process.env.CHAIN_ID), + bundlerProvider: new EtherspotBundler(Number(process.env.CHAIN_ID), bundlerApiKey) + }) + + console.log('address: ', modularSdk.state.EOAAddress); + + // get address of EtherspotWallet + const address: string = await modularSdk.getCounterFactualAddress(); + + console.log('\x1b[33m%s\x1b[0m', `EtherspotWallet address: ${address}`); + + const token = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'; + const functionSelector = '0xa9059cbb'; + const spendingLimit = '100000'; + const validAfter = new Date().getTime(); + const validUntil = new Date().getTime() + 24 * 60 * 60 * 1000; + + // get instance of SessionKeyValidator + const sessionKeyModule = new SessionKeyValidator( + modularSdk, + new EtherspotBundler(Number(process.env.CHAIN_ID), bundlerApiKey) + ) + + const response = await sessionKeyModule.rotateSessionKey( + token, + functionSelector, + spendingLimit, + validAfter, + validUntil, + KeyStore.AWS + ); + + console.log('\x1b[33m%s\x1b[0m', `UserOpHash: `, response.userOpHash); + console.log('\x1b[33m%s\x1b[0m', `SessionKey: `, response.sessionKey); + + // get transaction hash... + console.log('Waiting for transaction...'); + let userOpsReceipt = null; + const timeout = Date.now() + 60000; // 1 minute timeout + while ((userOpsReceipt == null) && (Date.now() < timeout)) { + await sleep(2); + userOpsReceipt = await modularSdk.getUserOpReceipt(response.userOpHash); + } + console.log('\x1b[33m%s\x1b[0m', `Transaction Receipt: `, userOpsReceipt); + + const sessionKeys = await sessionKeyModule.getAssociatedSessionKeys(); + console.log('\x1b[33m%s\x1b[0m', `AssociatedSessionKeys: `, sessionKeys); +} + +main() + .catch(console.error) + .finally(() => process.exit()); diff --git a/examples/15-disable-sessionkey-module.ts b/examples/15-disable-sessionkey-module.ts new file mode 100644 index 0000000..ddf51f5 --- /dev/null +++ b/examples/15-disable-sessionkey-module.ts @@ -0,0 +1,51 @@ +import { EtherspotBundler, ModularSdk, SessionKeyValidator } from '../src'; +import * as dotenv from 'dotenv'; +import { sleep } from '../src/sdk/common'; + +dotenv.config(); + +async function main() { + const bundlerApiKey = 'eyJvcmciOiI2NTIzZjY5MzUwOTBmNzAwMDFiYjJkZWIiLCJpZCI6IjMxMDZiOGY2NTRhZTRhZTM4MGVjYjJiN2Q2NDMzMjM4IiwiaCI6Im11cm11cjEyOCJ9'; + + // initializating sdk... + const modularSdk = new ModularSdk({ privateKey: process.env.WALLET_PRIVATE_KEY }, + { + chainId: Number(process.env.CHAIN_ID), + bundlerProvider: new EtherspotBundler(Number(process.env.CHAIN_ID), bundlerApiKey) + }) + + console.log('address: ', modularSdk.state.EOAAddress); + + // get address of EtherspotWallet + const address: string = await modularSdk.getCounterFactualAddress(); + + console.log('\x1b[33m%s\x1b[0m', `EtherspotWallet address: ${address}`); + + // get instance of SessionKeyValidator + const sessionKeyModule = new SessionKeyValidator( + modularSdk, + new EtherspotBundler(Number(process.env.CHAIN_ID), bundlerApiKey) + ) + + const response = await sessionKeyModule.disableSessionKey(); + + console.log('\x1b[33m%s\x1b[0m', `UserOpHash: `, response.userOpHash); + console.log('\x1b[33m%s\x1b[0m', `SessionKey: `, response.sessionKey); + + // get transaction hash... + console.log('Waiting for transaction...'); + let userOpsReceipt = null; + const timeout = Date.now() + 60000; // 1 minute timeout + while ((userOpsReceipt == null) && (Date.now() < timeout)) { + await sleep(2); + userOpsReceipt = await modularSdk.getUserOpReceipt(response.userOpHash); + } + console.log('\x1b[33m%s\x1b[0m', `Transaction Receipt: `, userOpsReceipt); + + const sessionKeys = await sessionKeyModule.getAssociatedSessionKeys(); + console.log('\x1b[33m%s\x1b[0m', `AssociatedSessionKeys: `, sessionKeys); +} + +main() + .catch(console.error) + .finally(() => process.exit()); diff --git a/package-lock.json b/package-lock.json index d3b567f..1a74b37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@etherspot/modular-sdk", - "version": "1.1.1", + "version": "1.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@etherspot/modular-sdk", - "version": "1.1.1", + "version": "1.1.2", "license": "MIT", "dependencies": { "@lifi/sdk": "2.5.0", diff --git a/package.json b/package.json index 1273d3e..41ab4d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@etherspot/modular-sdk", - "version": "1.1.1", + "version": "1.1.2", "description": "Etherspot Modular SDK - build with ERC-7579 smart accounts modules", "keywords": [ "ether", @@ -31,13 +31,14 @@ "04-transfer-nft": "./node_modules/.bin/ts-node ./examples/04-transfer-nft", "05-add-guardians": "./node_modules/.bin/ts-node ./examples/05-add-guardians", "06-paymaster": "./node_modules/.bin/ts-node ./examples/06-paymaster", - "07-paymaster-arka": "./node_modules/.bin/ts-node ./examples/07-paymaster-arka", - "08-paymaster-validUntil-validAfter": "./node_modules/.bin/ts-node ./examples/08-paymaster-validUntil-validAfter", - "09-callGasLimit": "./node_modules/.bin/ts-node ./examples/09-callGasLimit", - "10-get-multiple-accounts": "./node_modules/.bin/ts-node ./examples/10-get-multiple-accounts", - "11-concurrent-userops": "./node_modules/.bin/ts-node ./examples/11-concurrent-userops", - "14-install-module": "./node_modules/.bin/ts-node ./examples/14-install-module", - "15-uninstall-module": "./node_modules/.bin/ts-node ./examples/15-uninstall-module", + "07-callGasLimit": "./node_modules/.bin/ts-node ./examples/07-callGasLimit", + "08-get-multiple-accounts": "./node_modules/.bin/ts-node ./examples/08-get-multiple-accounts", + "09-concurrent-userops": "./node_modules/.bin/ts-node ./examples/09-concurrent-userops", + "11-install-module": "./node_modules/.bin/ts-node ./examples/11-install-module", + "12-uninstall-module": "./node_modules/.bin/ts-node ./examples/12-uninstall-module", + "13-enable-sessionkey-module": "./node_modules/.bin/ts-node ./examples/13-enable-sessionkey-module", + "14-rotate-sessionkey-module": "./node_modules/.bin/ts-node ./examples/14-rotate-sessionkey-module", + "15-disable-sessionkey-module": "./node_modules/.bin/ts-node ./examples/15-disable-sessionkey-module", "format": "prettier --write \"{src,test,examples}/**/*.ts\"", "lint": "eslint \"{src,test,examples}/**/*.ts\"", "lint-fix": "npm run lint -- --fix", diff --git a/src/sdk/SessionKeyValidator/SessionKeyValidator.ts b/src/sdk/SessionKeyValidator/SessionKeyValidator.ts new file mode 100644 index 0000000..0a3ef43 --- /dev/null +++ b/src/sdk/SessionKeyValidator/SessionKeyValidator.ts @@ -0,0 +1,367 @@ +import { ERC20SessionKeyValidator__factory } from "../contracts/factories/src/ERC7579/modules/validator"; +import { BigNumber, providers } from "ethers"; +import { ModularSdk } from "../sdk"; +import { KeyStore, PERMISSIONS_URL } from "./constants"; +import { SessionKeyResponse, GenerateSessionKeyResponse, GetNonceResponse, GetSessionKeyResponse, DeleteSessionKeyResponse } from "./interfaces"; +import { BundlerProvider } from "../bundler"; +import { DEFAULT_ERC20_SESSION_KEY_VALIDATOR_ADDRESS, Networks } from "../network/constants"; + +export class SessionKeyValidator { + private modularSdk: ModularSdk; + private provider: providers.JsonRpcProvider; + private erc20SessionKeyValidator?: string; + private chainId?: number; + + constructor(modularSdk: ModularSdk, provider: BundlerProvider) { + this.modularSdk = modularSdk; + this.provider = new providers.JsonRpcProvider(provider.url); + } + + async enableSessionKey( + token: string, + functionSelector: string, + spendingLimit: string, + validAfter: number, + validUntil: number, + keyStore?: KeyStore, + ): Promise { + try { + const account = await this.modularSdk.getCounterFactualAddress(); + const chainId = await this.getChainId(); + const erc20SessionKeyValidator = await this.getERC20SessionKeyValidator(); + const apiKeyMatch = this.provider.connection.url.match(/api-key=([^&]+)/); + const apiKey = apiKeyMatch ? apiKeyMatch[1] : null; + + const data = await this.generateSessionKeyData( + account, + chainId, + token, + functionSelector, + spendingLimit, + validAfter, + validUntil, + apiKey, + false, + keyStore ? keyStore : null, + ) + + const erc20SessionKeyValidatorContract = ERC20SessionKeyValidator__factory.connect( + erc20SessionKeyValidator, + this.provider + ); + + const enableSessionKeyData = erc20SessionKeyValidatorContract.interface.encodeFunctionData('enableSessionKey', [data.enableSessionKeyData]); + + this.modularSdk.clearUserOpsFromBatch(); + + await this.modularSdk.addUserOpsToBatch({ to: erc20SessionKeyValidator, data: enableSessionKeyData }); + + const op = await this.modularSdk.estimate({ + key: BigNumber.from(erc20SessionKeyValidator) + }); + + const uoHash = await this.modularSdk.send(op) + + return { + userOpHash: uoHash, + sessionKey: data.sessionKey, + } + } catch (error) { + throw error; + } + } + + async rotateSessionKey( + token: string, + functionSelector: string, + spendingLimit: string, + validAfter: number, + validUntil: number, + keyStore?: KeyStore, + ): Promise { + try { + const account = await this.modularSdk.getCounterFactualAddress(); + const chainId = await this.getChainId(); + const erc20SessionKeyValidator = await this.getERC20SessionKeyValidator(); + const apiKeyMatch = this.provider.connection.url.match(/api-key=([^&]+)/); + const apiKey = apiKeyMatch ? apiKeyMatch[1] : null; + + const data = await this.generateSessionKeyData( + account, + chainId, + token, + functionSelector, + spendingLimit, + validAfter, + validUntil, + apiKey, + true, + keyStore ? keyStore : null, + ) + + const erc20SessionKeyValidatorContract = ERC20SessionKeyValidator__factory.connect( + erc20SessionKeyValidator, + this.provider + ); + + const rotateSessionKeyData = erc20SessionKeyValidatorContract.interface.encodeFunctionData('rotateSessionKey', + [data.oldSessionKey, data.enableSessionKeyData] + ); + + this.modularSdk.clearUserOpsFromBatch(); + + await this.modularSdk.addUserOpsToBatch({ to: erc20SessionKeyValidator, data: rotateSessionKeyData }); + + const op = await this.modularSdk.estimate({ + key: BigNumber.from(erc20SessionKeyValidator) + }); + + const uoHash = await this.modularSdk.send(op); + + return { + userOpHash: uoHash, + sessionKey: data.sessionKey, + } + } catch (error) { + throw error; + } + } + + async disableSessionKey(): Promise { + try { + const account = await this.modularSdk.getCounterFactualAddress(); + const erc20SessionKeyValidator = await this.getERC20SessionKeyValidator(); + const chainId = await this.getChainId(); + const apiKeyMatch = this.provider.connection.url.match(/api-key=([^&]+)/); + const apiKey = apiKeyMatch ? apiKeyMatch[1] : null; + + const getSessionKeyData = await this.getSessionKey( + account, + chainId, + apiKey, + ) + + const erc20SessionKeyValidatorContract = ERC20SessionKeyValidator__factory.connect( + erc20SessionKeyValidator, + this.provider + ); + + const disableSessionKeyData = erc20SessionKeyValidatorContract.interface.encodeFunctionData('disableSessionKey', + [getSessionKeyData.sessionKey] + ); + + this.modularSdk.clearUserOpsFromBatch(); + + await this.modularSdk.addUserOpsToBatch({ to: erc20SessionKeyValidator, data: disableSessionKeyData }); + + const op = await this.modularSdk.estimate({ + key: BigNumber.from(erc20SessionKeyValidator) + }); + + const uoHash = await this.modularSdk.send(op); + + if (uoHash) { + await this.deleteSessionKey(account, chainId, apiKey); + } + + return { + userOpHash: uoHash, + sessionKey: getSessionKeyData.sessionKey, + } + } catch (error) { + throw error; + } + } + + async getNonce(): Promise { + try { + const account = await this.modularSdk.getCounterFactualAddress(); + const chainId = await this.getChainId(); + const apiKeyMatch = this.provider.connection.url.match(/api-key=([^&]+)/); + const apiKey = apiKeyMatch ? apiKeyMatch[1] : null; + + const data = await this.getNonceData( + account, + chainId, + apiKey, + ) + + return data; + } catch (error) { + throw error; + } + } + + async getAssociatedSessionKeys(): Promise { + const account = await this.modularSdk.getCounterFactualAddress(); + + const erc20SessionKeyValidator = await this.getERC20SessionKeyValidator(); + + const erc20SessionKeyValidatorContract = ERC20SessionKeyValidator__factory.connect( + erc20SessionKeyValidator, + this.provider + ); + + return await erc20SessionKeyValidatorContract.callStatic.getAssociatedSessionKeys({ from: account }); + } + + private async getERC20SessionKeyValidator(): Promise { + if (this.erc20SessionKeyValidator) { + return this.erc20SessionKeyValidator; + } + + const chainId = await this.getChainId(); + this.erc20SessionKeyValidator = Networks[chainId]?.contracts?.erc20SessionKeyValidator || DEFAULT_ERC20_SESSION_KEY_VALIDATOR_ADDRESS; + + return this.erc20SessionKeyValidator; + } + + private async getChainId(): Promise { + if (!this.chainId) { + this.chainId = (await this.provider.getNetwork()).chainId; + } + return this.chainId; + } + + private async generateSessionKeyData( + account: string, + chainId: number, + token: string, + functionSelector: string, + spendingLimit: string, + validAfter: number, + validUntil: number, + apiKey: string, + rotateKey: boolean, + keyStore: KeyStore, + ): Promise { + let response = null; + try { + let url = `${PERMISSIONS_URL}/account/generateSessionKeyData`; + if (apiKey) url += `?apiKey=${apiKey}`; + + const requestBody = { + account, + chainId, + rotateKey, + keyStore, + token, + functionSelector, + spendingLimit, + validAfter, + validUntil, + }; + + response = await fetch(url, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify(requestBody), + }); + + if (response.status === 200) { + const responseJson: GenerateSessionKeyResponse = await response.json(); + return responseJson + } else { + const responseJson = await response.json(); + throw new Error(responseJson.message) + } + } catch (err) { + throw new Error(err.message) + } + } + + private async getSessionKey( + account: string, + chainId: number, + apiKey: string, + ): Promise { + let response = null; + + try { + let url = `${PERMISSIONS_URL}/account/getSessionKey?account=${account}&chainId=${chainId}`; + if (apiKey) url += `&apiKey=${apiKey}`; + + response = await fetch(url, { + method: 'GET', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + }); + + if (response.status === 200) { + const responseJson: GetSessionKeyResponse = await response.json(); + return responseJson + } else { + const responseJson = await response.json(); + throw new Error(responseJson.message) + } + } catch (err) { + throw new Error(err.message) + } + } + + private async deleteSessionKey( + account: string, + chainId: number, + apiKey: string, + ): Promise { + let response = null; + try { + let url = `${PERMISSIONS_URL}/account/deleteSessionKey?account=${account}&chainId=${chainId}`; + if (apiKey) url += `&apiKey=${apiKey}`; + + response = await fetch(url, { + method: 'DELETE', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + }); + + if (response.status === 200) { + const responseJson: DeleteSessionKeyResponse = await response.json(); + return responseJson + } else { + const responseJson = await response.json(); + throw new Error(responseJson.message) + } + } catch (err) { + throw new Error(err.message) + } + } + + private async getNonceData( + account: string, + chainId: number, + apiKey: string, + ): Promise { + let response = null; + + try { + let url = `${PERMISSIONS_URL}/account/getNonce?account=${account}&chainId=${chainId}`; + if (apiKey) url += `&apiKey=${apiKey}`; + + response = await fetch(url, { + method: 'GET', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + }); + + if (response.status === 200) { + const responseJson: GetNonceResponse = await response.json(); + return responseJson + } else { + const responseJson = await response.json(); + throw new Error(responseJson.message) + } + } catch (err) { + throw new Error(err.message) + } + } +} diff --git a/src/sdk/SessionKeyValidator/constants.ts b/src/sdk/SessionKeyValidator/constants.ts new file mode 100644 index 0000000..a5e3f8a --- /dev/null +++ b/src/sdk/SessionKeyValidator/constants.ts @@ -0,0 +1,6 @@ +export const PERMISSIONS_URL = 'https://rpc.etherspot.io/permissions'; + +export enum KeyStore { + AWS = 'AWS', + TEE = 'TEE', +} \ No newline at end of file diff --git a/src/sdk/SessionKeyValidator/index.ts b/src/sdk/SessionKeyValidator/index.ts new file mode 100644 index 0000000..e945eb7 --- /dev/null +++ b/src/sdk/SessionKeyValidator/index.ts @@ -0,0 +1,3 @@ +export * from './SessionKeyValidator'; +export * from './interfaces'; +export * from './constants'; \ No newline at end of file diff --git a/src/sdk/SessionKeyValidator/interfaces.ts b/src/sdk/SessionKeyValidator/interfaces.ts new file mode 100644 index 0000000..c5b7f9d --- /dev/null +++ b/src/sdk/SessionKeyValidator/interfaces.ts @@ -0,0 +1,24 @@ +export interface GenerateSessionKeyResponse { + sessionKey: string; + enableSessionKeyData: string; + oldSessionKey?: string; +} + +export interface GetSessionKeyResponse { + sessionKey: string; +} + +export interface DeleteSessionKeyResponse { + account: string; + chainId: number; + message: string; +} + +export interface SessionKeyResponse { + userOpHash: string; + sessionKey: string; +} + +export interface GetNonceResponse { + nonce: number; +} \ No newline at end of file diff --git a/src/sdk/contracts/factories/src/ERC7579/modules/validator/ERC20SessionKeyValidator__factory.ts b/src/sdk/contracts/factories/src/ERC7579/modules/validator/ERC20SessionKeyValidator__factory.ts new file mode 100644 index 0000000..856b42f --- /dev/null +++ b/src/sdk/contracts/factories/src/ERC7579/modules/validator/ERC20SessionKeyValidator__factory.ts @@ -0,0 +1,702 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers"; +import type { Provider, TransactionRequest } from "@ethersproject/providers"; +import type { PromiseOrValue } from "../../../../../common"; +import { + ERC20SessionKeyValidator, + ERC20SessionKeyValidatorInterface +} from "../../../../../src/ERC7579/modules/ERC20SessionKeyValidator" + +const _abi = [ + { + inputs: [ + { + internalType: "address", + name: "smartAccount", + type: "address", + }, + ], + name: "AlreadyInitialized", + type: "error", + }, + { + inputs: [ + { + internalType: "uint256", + name: "total", + type: "uint256", + }, + { + internalType: "uint256", + name: "spendCap", + type: "uint256", + }, + ], + name: "ERC20SKV_ExceedsExecutorSpendCap", + type: "error", + }, + { + inputs: [], + name: "ERC20SKV_InsufficientApprovalAmount", + type: "error", + }, + { + inputs: [], + name: "ERC20SKV_InvalidSessionKey", + type: "error", + }, + { + inputs: [], + name: "ERC20SKV_SessionKeySpendLimitExceeded", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "sessionKey", + type: "address", + }, + ], + name: "ERC20SKV_SessionPaused", + type: "error", + }, + { + inputs: [], + name: "ERC20SKV_UnsuportedToken", + type: "error", + }, + { + inputs: [], + name: "ERC20SKV_UnsupportedInterface", + type: "error", + }, + { + inputs: [ + { + internalType: "bytes4", + name: "selectorUsed", + type: "bytes4", + }, + ], + name: "ERC20SKV_UnsupportedSelector", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address", + }, + ], + name: "InvalidTargetAddress", + type: "error", + }, + { + inputs: [], + name: "NotImplemented", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "smartAccount", + type: "address", + }, + ], + name: "NotInitialized", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "newCap", + type: "uint256", + }, + ], + name: "ERC20SKV_ExecutorSpendCapReduced", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "sessionKey", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "wallet", + type: "address", + }, + ], + name: "ERC20SKV_SessionKeyDisabled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "sessionKey", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "wallet", + type: "address", + }, + ], + name: "ERC20SKV_SessionKeyEnabled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "newLimit", + type: "uint256", + }, + ], + name: "ERC20SKV_SessionKeySpentLimitReduced", + type: "event", + }, + { + inputs: [ + { + internalType: "address", + name: "_sessionKey", + type: "address", + }, + ], + name: "checkSessionKeyPaused", + outputs: [ + { + internalType: "bool", + name: "paused", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_session", + type: "address", + }, + ], + name: "disableSessionKey", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes", + name: "_sessionData", + type: "bytes", + }, + ], + name: "enableSessionKey", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "getAssociatedSessionKeys", + outputs: [ + { + internalType: "address[]", + name: "keys", + type: "address[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_sessionKey", + type: "address", + }, + ], + name: "getSessionKeyData", + outputs: [ + { + components: [ + { + internalType: "address", + name: "token", + type: "address", + }, + { + internalType: "bytes4", + name: "interfaceId", + type: "bytes4", + }, + { + internalType: "bytes4", + name: "funcSelector", + type: "bytes4", + }, + { + internalType: "uint256", + name: "spendingLimit", + type: "uint256", + }, + { + internalType: "uint48", + name: "validAfter", + type: "uint48", + }, + { + internalType: "uint48", + name: "validUntil", + type: "uint48", + }, + { + internalType: "bool", + name: "paused", + type: "bool", + }, + ], + internalType: "struct ERC20SessionKeyValidator.SessionData", + name: "data", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "smartAccount", + type: "address", + }, + ], + name: "isInitialized", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "moduleTypeId", + type: "uint256", + }, + ], + name: "isModuleType", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "pure", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bytes32", + name: "hash", + type: "bytes32", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + name: "isValidSignatureWithSender", + outputs: [ + { + internalType: "bytes4", + name: "", + type: "bytes4", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + name: "onInstall", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + name: "onUninstall", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_oldSessionKey", + type: "address", + }, + { + internalType: "bytes", + name: "_newSessionData", + type: "bytes", + }, + ], + name: "rotateSessionKey", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "sessionKey", + type: "address", + }, + { + internalType: "address", + name: "wallet", + type: "address", + }, + ], + name: "sessionData", + outputs: [ + { + internalType: "address", + name: "token", + type: "address", + }, + { + internalType: "bytes4", + name: "interfaceId", + type: "bytes4", + }, + { + internalType: "bytes4", + name: "funcSelector", + type: "bytes4", + }, + { + internalType: "uint256", + name: "spendingLimit", + type: "uint256", + }, + { + internalType: "uint48", + name: "validAfter", + type: "uint48", + }, + { + internalType: "uint48", + name: "validUntil", + type: "uint48", + }, + { + internalType: "bool", + name: "paused", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_sessionKey", + type: "address", + }, + ], + name: "toggleSessionKeyPause", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_sessionKey", + type: "address", + }, + { + components: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "nonce", + type: "uint256", + }, + { + internalType: "bytes", + name: "initCode", + type: "bytes", + }, + { + internalType: "bytes", + name: "callData", + type: "bytes", + }, + { + internalType: "bytes32", + name: "accountGasLimits", + type: "bytes32", + }, + { + internalType: "uint256", + name: "preVerificationGas", + type: "uint256", + }, + { + internalType: "bytes32", + name: "gasFees", + type: "bytes32", + }, + { + internalType: "bytes", + name: "paymasterAndData", + type: "bytes", + }, + { + internalType: "bytes", + name: "signature", + type: "bytes", + }, + ], + internalType: "struct PackedUserOperation", + name: "userOp", + type: "tuple", + }, + ], + name: "validateSessionKeyParams", + outputs: [ + { + internalType: "bool", + name: "valid", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "nonce", + type: "uint256", + }, + { + internalType: "bytes", + name: "initCode", + type: "bytes", + }, + { + internalType: "bytes", + name: "callData", + type: "bytes", + }, + { + internalType: "bytes32", + name: "accountGasLimits", + type: "bytes32", + }, + { + internalType: "uint256", + name: "preVerificationGas", + type: "uint256", + }, + { + internalType: "bytes32", + name: "gasFees", + type: "bytes32", + }, + { + internalType: "bytes", + name: "paymasterAndData", + type: "bytes", + }, + { + internalType: "bytes", + name: "signature", + type: "bytes", + }, + ], + internalType: "struct PackedUserOperation", + name: "userOp", + type: "tuple", + }, + { + internalType: "bytes32", + name: "userOpHash", + type: "bytes32", + }, + ], + name: "validateUserOp", + outputs: [ + { + internalType: "uint256", + name: "validationData", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "wallet", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + name: "walletSessionKeys", + outputs: [ + { + internalType: "address", + name: "assocSessionKeys", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +const _bytecode = + "0x608060405234801561001057600080fd5b506004361061010b5760003560e01c8063c037ee19116100a2578063d60b347f11610071578063d60b347f14610453578063d8d38e421461047f578063e08dd00814610492578063ecd05961146104a7578063f551e2ee146104bb57600080fd5b8063c037ee19146103e7578063c602e59c1461040a578063cbca47db1461041d578063cc8cbd281461044057600080fd5b80636d61fe70116100de5780636d61fe70146103755780638a91b0e3146103885780638aaa6a401461039b57806397003203146103c657600080fd5b8063110891c11461011057806320cbdcc61461027a578063495079a01461028f57806352721fdd146102a2575b600080fd5b6101fa61011e36600461178e565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810191909152506001600160a01b039081166000908152600260208181526040808420338552825292839020835160e08082018652825496871682526001600160e01b0319600160a01b8804821b811694830194909452600160c01b90960490951b9091169284019290925260018201546060840152015465ffffffffffff8082166080840152600160301b82041660a083015260ff600160601b90910416151560c082015290565b6040805182516001600160a01b031681526020808401516001600160e01b0319908116918301919091528383015116918101919091526060808301519082015260808083015165ffffffffffff9081169183019190915260a0808401519091169082015260c09182015115159181019190915260e0015b60405180910390f35b61028d61028836600461178e565b6104e7565b005b61028d61029d3660046117f2565b610667565b61031b6102b0366004611834565b600260208181526000938452604080852090915291835291208054600182015491909201546001600160a01b03831692600160a01b810460e090811b93600160c01b909204901b9165ffffffffffff80821691600160301b810490911690600160601b900460ff1687565b604080516001600160a01b039890981688526001600160e01b031996871660208901529490951693860193909352606085019190915265ffffffffffff90811660808501521660a0830152151560c082015260e001610271565b61028d6103833660046117f2565b610b20565b61028d6103963660046117f2565b610b9e565b6103ae6103a9366004611867565b610cce565b6040516001600160a01b039091168152602001610271565b6103d96103d43660046118aa565b610d06565b604051908152602001610271565b6103fa6103f53660046118ef565b610e5c565b6040519015158152602001610271565b61028d61041836600461193d565b6111c1565b6103fa61042b36600461178e565b60006020819052908152604090205460ff1681565b6103fa61044e36600461178e565b6111d9565b6103fa61046136600461178e565b6001600160a01b031660009081526020819052604090205460ff1690565b61028d61048d36600461178e565b61120b565b61049a611331565b6040516102719190611990565b6103fa6104b53660046119dd565b60011490565b6104ce6104c93660046119f6565b61139c565b6040516001600160e01b03199091168152602001610271565b6001600160a01b038082166000908152600260208181526040808420338552825292839020835160e08082018652825496871682526001600160e01b0319600160a01b8804821b811694830194909452600160c01b90960490951b9091169284019290925260018201546060840152015465ffffffffffff8082166080840152600160301b82041660a083015260ff600160601b9091041615801560c08301526105fa576001600160a01b03821660008181526002602081815260408084203380865290835293819020909201805460ff60601b1916905581519384528301919091527fdafe9b16860cb2a92db27f042fbea578512b3290e6025be770cafb9f82d253ae91015b60405180910390a15050565b6001600160a01b03821660008181526002602081815260408084203380865290835293819020909201805460ff60601b1916600160601b17905581519384528301919091527ff5eec43346204709e3490be81892a0abceba36de8afb2c87c9c8b62565cf0a7b91016105ee565b60006106766014828486611a50565b61067f91611a7a565b60601c9050806106a257604051636ed16c7960e01b815260040160405180910390fd5b6001600160a01b03811660009081526002602081815260408084203385529091529091200154600160301b900465ffffffffffff16158015906106f157506106f16106eb611331565b826113b7565b1561071f576040516353a146e760e11b81526001600160a01b03821660048201526024015b60405180910390fd5b600061072f602860148587611a50565b61073891611a7a565b60601c90508061075b57604051630c99762360e11b815260040160405180910390fd5b600061076b602c60288688611a50565b61077491611aaf565b90506001600160e01b0319811661079e57604051639c7bab4360e01b815260040160405180910390fd5b60006107ae6030602c8789611a50565b6107b791611aaf565b90506001600160e01b031981166107e15760405163b17e3ec360e01b815260040160405180910390fd5b60006107f160506030888a611a50565b6107fa91611add565b9050600081900361081e5760405163171c5d6160e01b815260040160405180910390fd5b600061082e60566050898b611a50565b61083791611afb565b60d01c9050600061084c605c60568a8c611a50565b61085591611afb565b60d01c905065ffffffffffff821681111580610877575065ffffffffffff8116155b80610888575065ffffffffffff8216155b156108b857604051630a6c748560e11b815265ffffffffffff808416600483015282166024820152604401610716565b6040518060e00160405280876001600160a01b03168152602001866001600160e01b0319168152602001856001600160e01b03191681526020018481526020018365ffffffffffff1681526020018265ffffffffffff1681526020016000151581525060026000896001600160a01b03166001600160a01b031681526020019081526020016000206000336001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548163ffffffff021916908360e01c021790555060408201518160000160186101000a81548163ffffffff021916908360e01c02179055506060820151816001015560808201518160020160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060a08201518160020160066101000a81548165ffffffffffff021916908365ffffffffffff16021790555060c082015181600201600c6101000a81548160ff02191690831515021790555090505060016000336001600160a01b03166001600160a01b03168152602001908152602001600020879080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b031602179055507f3c8d6097a1246293dc66a3eeb0db267cb28a5b6c3367e2de5f331659222eb1ff8733604051610b0d9291906001600160a01b0392831681529116602082015260400190565b60405180910390a1505050505050505050565b3360009081526020819052604090205460ff161515600103610b5557604051639fb25a0560e01b815260040160405180910390fd5b3360008181526020818152604091829020805460ff1916600117905590519182527fa6d916f9c8039923d6c8929c933b9417bdeeceb2dfbb39525b8a2269094d5e3c91016105ee565b3360009081526020819052604081205460ff1615159003610bd2576040516317bd7c1760e31b815260040160405180910390fd5b6000610bdc611331565b805190915060005b81811015610c665760026000848381518110610c0257610c02611b29565b6020908102919091018101516001600160a01b031682528181019290925260409081016000908120338252909252812080546001600160e01b031916815560018082019290925560020180546cffffffffffffffffffffffffff1916905501610be4565b50336000908152600160205260408120610c7f916116d7565b3360008181526020818152604091829020805460ff1916905590519182527fd168e595dbfa90dd76eed9c2c9b6c3a9892ae9e79dd68661b0e26f30c582cd4d910160405180910390a150505050565b60016020528160005260406000208181548110610cea57600080fd5b6000918252602090912001546001600160a01b03169150829050565b600080610d38836020527b19457468657265756d205369676e6564204d6573736167653a0a3332600052603c60042090565b90506000610d8882610d4e610100880188611b3f565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506113cd92505050565b9050610d948186610e5c565b610da357600192505050610e56565b6001600160a01b0381811660009081526002602081815260408084203385528252808420815160e0808201845282549788168252600160a01b8804811b6001600160e01b031990811695830195909552600160c01b90970490961b9092169085015260018101546060850152015465ffffffffffff80821660808501819052600160301b830490911660a08501819052600160601b90920460ff16151560c0850152610e5092919061145e565b93505050505b92915050565b60003681610e6d6060850185611b3f565b915091506000806000806000610e838787611496565b945094509450945094506000600260008c6001600160a01b03166001600160a01b031681526020019081526020016000206000336001600160a01b03166001600160a01b031681526020019081526020016000206040518060e00160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b031681526020016000820160149054906101000a900460e01b6001600160e01b0319166001600160e01b03191681526020016000820160189054906101000a900460e01b6001600160e01b0319166001600160e01b0319168152602001600182015481526020016002820160009054906101000a900465ffffffffffff1665ffffffffffff1665ffffffffffff1681526020016002820160069054906101000a900465ffffffffffff1665ffffffffffff1665ffffffffffff16815260200160028201600c9054906101000a900460ff16151515158152505090508060a0015165ffffffffffff166000148061100c5750428160a0015165ffffffffffff16105b806110215750608081015165ffffffffffff16155b80611037575042816080015165ffffffffffff16115b1561105557604051636ed16c7960e01b815260040160405180910390fd5b80516001600160a01b038681169116146110825760405163218d2fb360e11b815260040160405180910390fd5b60208101516040516301ffc9a760e01b81526001600160e01b031990911660048201526001600160a01b038616906301ffc9a790602401602060405180830381865afa1580156110d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110fa9190611b86565b151560000361111c57604051630863587160e11b815260040160405180910390fd5b60408101516001600160e01b03198781169116146111595760405163a47eb18d60e01b81526001600160e01b031987166004820152602401610716565b806060015182111561117e57604051638d6d48cb60e01b815260040160405180910390fd5b6111878b6111d9565b156111b0576040516374d12a8360e01b81526001600160a01b038c166004820152602401610716565b5060019a9950505050505050505050565b6111ca8361120b565b6111d48282610667565b505050565b6001600160a01b031660009081526002602081815260408084203385529091529091200154600160601b900460ff1690565b6001600160a01b038116600090815260026020818152604080842033855290915282200154600160301b900465ffffffffffff169003611269576040516315aab36760e31b81526001600160a01b0382166004820152602401610716565b6001600160a01b0381166000908152600260208181526040808420338552909152822080546001600160e01b031916815560018101929092550180546cffffffffffffffffffffffffff191690556112c86112c2611331565b82611575565b33600090815260016020908152604090912082516112ec93919291909101906116f8565b50604080516001600160a01b03831681523360208201527f3552ecdbdb725cc8b621be8a316008bbcb5bc1e72e9a6b08da9b20bd7f78266d910160405180910390a150565b3360009081526001602090815260409182902080548351818402810184019094528084526060939283018282801561139257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611374575b5050505050905090565b600060405163d623472560e01b815260040160405180910390fd5b6000806113c4848461166e565b95945050505050565b604051600190836000526020830151604052604083510361140957604083015160ff81901c601b016020526001600160ff1b031660605261142f565b604183510361142a57606083015160001a602052604083015160605261142f565b600091505b6020600160806000855afa5191503d61145057638baa579f6000526004601cfd5b600060605260405292915050565b600060d08265ffffffffffff16901b60a08465ffffffffffff16901b85611486576000611489565b60015b60ff161717949350505050565b6000600483013581808086356001600160e01b0319811663095ea7b360e01b14806114d157506001600160e01b0319811663a9059cbb60e01b145b806114ec57506001600160e01b0319811663010a5c0b60e41b145b1561150e5794505050506004840135905060248401356000604486013561156b565b63dc478d2360e01b6001600160e01b03198216016115465794505050506004840135905060448401356024850135606486013561156b565b60405163a47eb18d60e01b81526001600160e01b031982166004820152602401610716565b9295509295909350565b60606000600184516115879190611bbe565b67ffffffffffffffff81111561159f5761159f611bd1565b6040519080825280602002602001820160405280156115c8578160200160208202803683370190505b5090506000805b855181101561166457846001600160a01b03168682815181106115f4576115f4611b29565b60200260200101516001600160a01b03161461165c5785818151811061161c5761161c611b29565b602002602001015183838151811061163657611636611b29565b6001600160a01b03909216602092830291909101909101528161165881611be7565b9250505b6001016115cf565b5090949350505050565b81516000908190815b818110156116c657846001600160a01b031686828151811061169b5761169b611b29565b60200260200101516001600160a01b0316036116be579250600191506116d09050565b600101611677565b5060008092509250505b9250929050565b50805460008255906000526020600020908101906116f5919061175d565b50565b82805482825590600052602060002090810192821561174d579160200282015b8281111561174d57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190611718565b5061175992915061175d565b5090565b5b80821115611759576000815560010161175e565b80356001600160a01b038116811461178957600080fd5b919050565b6000602082840312156117a057600080fd5b6117a982611772565b9392505050565b60008083601f8401126117c257600080fd5b50813567ffffffffffffffff8111156117da57600080fd5b6020830191508360208285010111156116d057600080fd5b6000806020838503121561180557600080fd5b823567ffffffffffffffff81111561181c57600080fd5b611828858286016117b0565b90969095509350505050565b6000806040838503121561184757600080fd5b61185083611772565b915061185e60208401611772565b90509250929050565b6000806040838503121561187a57600080fd5b61188383611772565b946020939093013593505050565b600061012082840312156118a457600080fd5b50919050565b600080604083850312156118bd57600080fd5b823567ffffffffffffffff8111156118d457600080fd5b6118e085828601611891565b95602094909401359450505050565b6000806040838503121561190257600080fd5b61190b83611772565b9150602083013567ffffffffffffffff81111561192757600080fd5b61193385828601611891565b9150509250929050565b60008060006040848603121561195257600080fd5b61195b84611772565b9250602084013567ffffffffffffffff81111561197757600080fd5b611983868287016117b0565b9497909650939450505050565b6020808252825182820181905260009190848201906040850190845b818110156119d15783516001600160a01b0316835292840192918401916001016119ac565b50909695505050505050565b6000602082840312156119ef57600080fd5b5035919050565b60008060008060608587031215611a0c57600080fd5b611a1585611772565b935060208501359250604085013567ffffffffffffffff811115611a3857600080fd5b611a44878288016117b0565b95989497509550505050565b60008085851115611a6057600080fd5b83861115611a6d57600080fd5b5050820193919092039150565b6bffffffffffffffffffffffff198135818116916014851015611aa75780818660140360031b1b83161692505b505092915050565b6001600160e01b03198135818116916004851015611aa75760049490940360031b84901b1690921692915050565b80356020831015610e5657600019602084900360031b1b1692915050565b6001600160d01b03198135818116916006851015611aa75760069490940360031b84901b1690921692915050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611b5657600080fd5b83018035915067ffffffffffffffff821115611b7157600080fd5b6020019150368190038213156116d057600080fd5b600060208284031215611b9857600080fd5b815180151581146117a957600080fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610e5657610e56611ba8565b634e487b7160e01b600052604160045260246000fd5b600060018201611bf957611bf9611ba8565b506001019056fea2646970667358221220100b100d2bc7239d8d7fb65be54c5198e4522b2e1c109335a63d69f820ea2ff764736f6c63430008170033"; + +type ERC20SessionKeyValidatorConstructorParams = + | [signer?: Signer] + | ConstructorParameters; + +const isSuperArgs = ( + xs: ERC20SessionKeyValidatorConstructorParams +): xs is ConstructorParameters => xs.length > 1; + +export class ERC20SessionKeyValidator__factory extends ContractFactory { + constructor(...args: ERC20SessionKeyValidatorConstructorParams) { + if (isSuperArgs(args)) { + super(...args); + } else { + super(_abi, _bytecode, args[0]); + } + } + + override deploy( + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise { + return super.deploy(overrides || {}) as Promise; + } + override getDeployTransaction( + overrides?: Overrides & { from?: PromiseOrValue } + ): TransactionRequest { + return super.getDeployTransaction(overrides || {}); + } + override attach(address: string): ERC20SessionKeyValidator { + return super.attach(address) as ERC20SessionKeyValidator; + } + override connect(signer: Signer): ERC20SessionKeyValidator__factory { + return super.connect(signer) as ERC20SessionKeyValidator__factory; + } + + static readonly bytecode = _bytecode; + static readonly abi = _abi; + static createInterface(): ERC20SessionKeyValidatorInterface { + return new utils.Interface(_abi) as ERC20SessionKeyValidatorInterface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider + ): ERC20SessionKeyValidator { + return new Contract( + address, + _abi, + signerOrProvider + ) as ERC20SessionKeyValidator; + } +} \ No newline at end of file diff --git a/src/sdk/contracts/factories/src/ERC7579/modules/validator/index.ts b/src/sdk/contracts/factories/src/ERC7579/modules/validator/index.ts new file mode 100644 index 0000000..c27e10b --- /dev/null +++ b/src/sdk/contracts/factories/src/ERC7579/modules/validator/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { ERC20SessionKeyValidator__factory } from "./ERC20SessionKeyValidator__factory"; \ No newline at end of file diff --git a/src/sdk/contracts/src/ERC7579/modules/ERC20SessionKeyValidator.ts b/src/sdk/contracts/src/ERC7579/modules/ERC20SessionKeyValidator.ts new file mode 100644 index 0000000..348ba37 --- /dev/null +++ b/src/sdk/contracts/src/ERC7579/modules/ERC20SessionKeyValidator.ts @@ -0,0 +1,928 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from "ethers"; +import type { + FunctionFragment, + Result, + EventFragment, +} from "@ethersproject/abi"; +import type { Listener, Provider } from "@ethersproject/providers"; +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, + PromiseOrValue, +} from "../../../common"; + +export type PackedUserOperationStruct = { + sender: PromiseOrValue; + nonce: PromiseOrValue; + initCode: PromiseOrValue; + callData: PromiseOrValue; + accountGasLimits: PromiseOrValue; + preVerificationGas: PromiseOrValue; + gasFees: PromiseOrValue; + paymasterAndData: PromiseOrValue; + signature: PromiseOrValue; +}; + +export type PackedUserOperationStructOutput = [ + string, + BigNumber, + string, + string, + string, + BigNumber, + string, + string, + string +] & { + sender: string; + nonce: BigNumber; + initCode: string; + callData: string; + accountGasLimits: string; + preVerificationGas: BigNumber; + gasFees: string; + paymasterAndData: string; + signature: string; +}; + +export declare namespace IERC20SessionKeyValidator { + export type SessionDataStruct = { + token: PromiseOrValue; + interfaceId: PromiseOrValue; + funcSelector: PromiseOrValue; + spendingLimit: PromiseOrValue; + validAfter: PromiseOrValue; + validUntil: PromiseOrValue; + paused: PromiseOrValue; + }; + + export type SessionDataStructOutput = [ + string, + string, + string, + BigNumber, + number, + number, + boolean + ] & { + token: string; + interfaceId: string; + funcSelector: string; + spendingLimit: BigNumber; + validAfter: number; + validUntil: number; + paused: boolean; + }; +} + +export interface ERC20SessionKeyValidatorInterface extends utils.Interface { + functions: { + "checkSessionKeyPaused(address)": FunctionFragment; + "disableSessionKey(address)": FunctionFragment; + "enableSessionKey(bytes)": FunctionFragment; + "getAssociatedSessionKeys()": FunctionFragment; + "getSessionKeyData(address)": FunctionFragment; + "initialized(address)": FunctionFragment; + "isInitialized(address)": FunctionFragment; + "isModuleType(uint256)": FunctionFragment; + "isValidSignatureWithSender(address,bytes32,bytes)": FunctionFragment; + "onInstall(bytes)": FunctionFragment; + "onUninstall(bytes)": FunctionFragment; + "rotateSessionKey(address,bytes)": FunctionFragment; + "sessionData(address,address)": FunctionFragment; + "toggleSessionKeyPause(address)": FunctionFragment; + "validateSessionKeyParams(address,(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes))": FunctionFragment; + "validateUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32)": FunctionFragment; + "walletSessionKeys(address,uint256)": FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | "checkSessionKeyPaused" + | "disableSessionKey" + | "enableSessionKey" + | "getAssociatedSessionKeys" + | "getSessionKeyData" + | "initialized" + | "isInitialized" + | "isModuleType" + | "isValidSignatureWithSender" + | "onInstall" + | "onUninstall" + | "rotateSessionKey" + | "sessionData" + | "toggleSessionKeyPause" + | "validateSessionKeyParams" + | "validateUserOp" + | "walletSessionKeys" + ): FunctionFragment; + + encodeFunctionData( + functionFragment: "checkSessionKeyPaused", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "disableSessionKey", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "enableSessionKey", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "getAssociatedSessionKeys", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getSessionKeyData", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "initialized", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "isInitialized", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "isModuleType", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "isValidSignatureWithSender", + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue + ] + ): string; + encodeFunctionData( + functionFragment: "onInstall", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "onUninstall", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "rotateSessionKey", + values: [PromiseOrValue, PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "sessionData", + values: [PromiseOrValue, PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "toggleSessionKeyPause", + values: [PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "validateSessionKeyParams", + values: [PromiseOrValue, PackedUserOperationStruct] + ): string; + encodeFunctionData( + functionFragment: "validateUserOp", + values: [PackedUserOperationStruct, PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "walletSessionKeys", + values: [PromiseOrValue, PromiseOrValue] + ): string; + + decodeFunctionResult( + functionFragment: "checkSessionKeyPaused", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "disableSessionKey", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "enableSessionKey", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getAssociatedSessionKeys", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getSessionKeyData", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "initialized", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isInitialized", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isModuleType", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isValidSignatureWithSender", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "onInstall", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "onUninstall", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "rotateSessionKey", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "sessionData", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "toggleSessionKeyPause", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "validateSessionKeyParams", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "validateUserOp", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "walletSessionKeys", + data: BytesLike + ): Result; + + events: { + "ERC20SKV_ModuleInstalled(address)": EventFragment; + "ERC20SKV_ModuleUninstalled(address)": EventFragment; + "ERC20SKV_SessionKeyDisabled(address,address)": EventFragment; + "ERC20SKV_SessionKeyEnabled(address,address)": EventFragment; + "ERC20SKV_SessionKeyPaused(address,address)": EventFragment; + "ERC20SKV_SessionKeyUnpaused(address,address)": EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: "ERC20SKV_ModuleInstalled"): EventFragment; + getEvent(nameOrSignatureOrTopic: "ERC20SKV_ModuleUninstalled"): EventFragment; + getEvent( + nameOrSignatureOrTopic: "ERC20SKV_SessionKeyDisabled" + ): EventFragment; + getEvent(nameOrSignatureOrTopic: "ERC20SKV_SessionKeyEnabled"): EventFragment; + getEvent(nameOrSignatureOrTopic: "ERC20SKV_SessionKeyPaused"): EventFragment; + getEvent( + nameOrSignatureOrTopic: "ERC20SKV_SessionKeyUnpaused" + ): EventFragment; +} + +export interface ERC20SKV_ModuleInstalledEventObject { + wallet: string; +} +export type ERC20SKV_ModuleInstalledEvent = TypedEvent< + [string], + ERC20SKV_ModuleInstalledEventObject +>; + +export type ERC20SKV_ModuleInstalledEventFilter = + TypedEventFilter; + +export interface ERC20SKV_ModuleUninstalledEventObject { + wallet: string; +} +export type ERC20SKV_ModuleUninstalledEvent = TypedEvent< + [string], + ERC20SKV_ModuleUninstalledEventObject +>; + +export type ERC20SKV_ModuleUninstalledEventFilter = + TypedEventFilter; + +export interface ERC20SKV_SessionKeyDisabledEventObject { + sessionKey: string; + wallet: string; +} +export type ERC20SKV_SessionKeyDisabledEvent = TypedEvent< + [string, string], + ERC20SKV_SessionKeyDisabledEventObject +>; + +export type ERC20SKV_SessionKeyDisabledEventFilter = + TypedEventFilter; + +export interface ERC20SKV_SessionKeyEnabledEventObject { + sessionKey: string; + wallet: string; +} +export type ERC20SKV_SessionKeyEnabledEvent = TypedEvent< + [string, string], + ERC20SKV_SessionKeyEnabledEventObject +>; + +export type ERC20SKV_SessionKeyEnabledEventFilter = + TypedEventFilter; + +export interface ERC20SKV_SessionKeyPausedEventObject { + sessionKey: string; + wallet: string; +} +export type ERC20SKV_SessionKeyPausedEvent = TypedEvent< + [string, string], + ERC20SKV_SessionKeyPausedEventObject +>; + +export type ERC20SKV_SessionKeyPausedEventFilter = + TypedEventFilter; + +export interface ERC20SKV_SessionKeyUnpausedEventObject { + sessionKey: string; + wallet: string; +} +export type ERC20SKV_SessionKeyUnpausedEvent = TypedEvent< + [string, string], + ERC20SKV_SessionKeyUnpausedEventObject +>; + +export type ERC20SKV_SessionKeyUnpausedEventFilter = + TypedEventFilter; + +export interface ERC20SessionKeyValidator extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: ERC20SessionKeyValidatorInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners( + eventFilter?: TypedEventFilter + ): Array>; + listeners(eventName?: string): Array; + removeAllListeners( + eventFilter: TypedEventFilter + ): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + checkSessionKeyPaused( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[boolean]>; + + disableSessionKey( + _session: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + enableSessionKey( + _sessionData: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + getAssociatedSessionKeys(overrides?: CallOverrides): Promise<[string[]]>; + + getSessionKeyData( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[IERC20SessionKeyValidator.SessionDataStructOutput]>; + + initialized( + arg0: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[boolean]>; + + isInitialized( + smartAccount: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[boolean]>; + + isModuleType( + moduleTypeId: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[boolean]>; + + isValidSignatureWithSender( + sender: PromiseOrValue, + hash: PromiseOrValue, + data: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[string]>; + + onInstall( + data: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + onUninstall( + data: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + rotateSessionKey( + _oldSessionKey: PromiseOrValue, + _newSessionData: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + sessionData( + sessionKey: PromiseOrValue, + wallet: PromiseOrValue, + overrides?: CallOverrides + ): Promise< + [string, string, string, BigNumber, number, number, boolean] & { + token: string; + interfaceId: string; + funcSelector: string; + spendingLimit: BigNumber; + validAfter: number; + validUntil: number; + paused: boolean; + } + >; + + toggleSessionKeyPause( + _sessionKey: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + validateSessionKeyParams( + _sessionKey: PromiseOrValue, + userOp: PackedUserOperationStruct, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + validateUserOp( + userOp: PackedUserOperationStruct, + userOpHash: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + walletSessionKeys( + wallet: PromiseOrValue, + arg1: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[string] & { assocSessionKeys: string }>; + }; + + checkSessionKeyPaused( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + disableSessionKey( + _session: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + enableSessionKey( + _sessionData: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + getAssociatedSessionKeys(overrides?: CallOverrides): Promise; + + getSessionKeyData( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + initialized( + arg0: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isInitialized( + smartAccount: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isModuleType( + moduleTypeId: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isValidSignatureWithSender( + sender: PromiseOrValue, + hash: PromiseOrValue, + data: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + onInstall( + data: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + onUninstall( + data: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + rotateSessionKey( + _oldSessionKey: PromiseOrValue, + _newSessionData: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + sessionData( + sessionKey: PromiseOrValue, + wallet: PromiseOrValue, + overrides?: CallOverrides + ): Promise< + [string, string, string, BigNumber, number, number, boolean] & { + token: string; + interfaceId: string; + funcSelector: string; + spendingLimit: BigNumber; + validAfter: number; + validUntil: number; + paused: boolean; + } + >; + + toggleSessionKeyPause( + _sessionKey: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + validateSessionKeyParams( + _sessionKey: PromiseOrValue, + userOp: PackedUserOperationStruct, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + validateUserOp( + userOp: PackedUserOperationStruct, + userOpHash: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + walletSessionKeys( + wallet: PromiseOrValue, + arg1: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + callStatic: { + checkSessionKeyPaused( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + disableSessionKey( + _session: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + enableSessionKey( + _sessionData: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + getAssociatedSessionKeys(overrides?: CallOverrides): Promise; + + getSessionKeyData( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + initialized( + arg0: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isInitialized( + smartAccount: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isModuleType( + moduleTypeId: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isValidSignatureWithSender( + sender: PromiseOrValue, + hash: PromiseOrValue, + data: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + onInstall( + data: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + onUninstall( + data: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + rotateSessionKey( + _oldSessionKey: PromiseOrValue, + _newSessionData: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + sessionData( + sessionKey: PromiseOrValue, + wallet: PromiseOrValue, + overrides?: CallOverrides + ): Promise< + [string, string, string, BigNumber, number, number, boolean] & { + token: string; + interfaceId: string; + funcSelector: string; + spendingLimit: BigNumber; + validAfter: number; + validUntil: number; + paused: boolean; + } + >; + + toggleSessionKeyPause( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + validateSessionKeyParams( + _sessionKey: PromiseOrValue, + userOp: PackedUserOperationStruct, + overrides?: CallOverrides + ): Promise; + + validateUserOp( + userOp: PackedUserOperationStruct, + userOpHash: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + walletSessionKeys( + wallet: PromiseOrValue, + arg1: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + }; + + filters: { + "ERC20SKV_ModuleInstalled(address)"( + wallet?: null + ): ERC20SKV_ModuleInstalledEventFilter; + ERC20SKV_ModuleInstalled( + wallet?: null + ): ERC20SKV_ModuleInstalledEventFilter; + + "ERC20SKV_ModuleUninstalled(address)"( + wallet?: null + ): ERC20SKV_ModuleUninstalledEventFilter; + ERC20SKV_ModuleUninstalled( + wallet?: null + ): ERC20SKV_ModuleUninstalledEventFilter; + + "ERC20SKV_SessionKeyDisabled(address,address)"( + sessionKey?: null, + wallet?: null + ): ERC20SKV_SessionKeyDisabledEventFilter; + ERC20SKV_SessionKeyDisabled( + sessionKey?: null, + wallet?: null + ): ERC20SKV_SessionKeyDisabledEventFilter; + + "ERC20SKV_SessionKeyEnabled(address,address)"( + sessionKey?: null, + wallet?: null + ): ERC20SKV_SessionKeyEnabledEventFilter; + ERC20SKV_SessionKeyEnabled( + sessionKey?: null, + wallet?: null + ): ERC20SKV_SessionKeyEnabledEventFilter; + + "ERC20SKV_SessionKeyPaused(address,address)"( + sessionKey?: null, + wallet?: null + ): ERC20SKV_SessionKeyPausedEventFilter; + ERC20SKV_SessionKeyPaused( + sessionKey?: null, + wallet?: null + ): ERC20SKV_SessionKeyPausedEventFilter; + + "ERC20SKV_SessionKeyUnpaused(address,address)"( + sessionKey?: null, + wallet?: null + ): ERC20SKV_SessionKeyUnpausedEventFilter; + ERC20SKV_SessionKeyUnpaused( + sessionKey?: null, + wallet?: null + ): ERC20SKV_SessionKeyUnpausedEventFilter; + }; + + estimateGas: { + checkSessionKeyPaused( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + disableSessionKey( + _session: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + enableSessionKey( + _sessionData: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + getAssociatedSessionKeys(overrides?: CallOverrides): Promise; + + getSessionKeyData( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + initialized( + arg0: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isInitialized( + smartAccount: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isModuleType( + moduleTypeId: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isValidSignatureWithSender( + sender: PromiseOrValue, + hash: PromiseOrValue, + data: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + onInstall( + data: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + onUninstall( + data: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + rotateSessionKey( + _oldSessionKey: PromiseOrValue, + _newSessionData: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + sessionData( + sessionKey: PromiseOrValue, + wallet: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + toggleSessionKeyPause( + _sessionKey: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + validateSessionKeyParams( + _sessionKey: PromiseOrValue, + userOp: PackedUserOperationStruct, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + validateUserOp( + userOp: PackedUserOperationStruct, + userOpHash: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + walletSessionKeys( + wallet: PromiseOrValue, + arg1: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + }; + + populateTransaction: { + checkSessionKeyPaused( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + disableSessionKey( + _session: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + enableSessionKey( + _sessionData: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + getAssociatedSessionKeys( + overrides?: CallOverrides + ): Promise; + + getSessionKeyData( + _sessionKey: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + initialized( + arg0: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isInitialized( + smartAccount: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isModuleType( + moduleTypeId: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + isValidSignatureWithSender( + sender: PromiseOrValue, + hash: PromiseOrValue, + data: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + onInstall( + data: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + onUninstall( + data: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + rotateSessionKey( + _oldSessionKey: PromiseOrValue, + _newSessionData: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + sessionData( + sessionKey: PromiseOrValue, + wallet: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + toggleSessionKeyPause( + _sessionKey: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + validateSessionKeyParams( + _sessionKey: PromiseOrValue, + userOp: PackedUserOperationStruct, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + validateUserOp( + userOp: PackedUserOperationStruct, + userOpHash: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + walletSessionKeys( + wallet: PromiseOrValue, + arg1: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + }; +} \ No newline at end of file diff --git a/src/sdk/contracts/src/ERC7579/modules/index.ts b/src/sdk/contracts/src/ERC7579/modules/index.ts index 40783ab..6d3f51a 100644 --- a/src/sdk/contracts/src/ERC7579/modules/index.ts +++ b/src/sdk/contracts/src/ERC7579/modules/index.ts @@ -2,3 +2,4 @@ /* tslint:disable */ /* eslint-disable */ export type { MultipleOwnerECDSAValidator } from "./MultipleOwnerECDSAValidator"; +export type { ERC20SessionKeyValidator } from "./ERC20SessionKeyValidator"; diff --git a/src/sdk/index.ts b/src/sdk/index.ts index 31be71c..8682f97 100644 --- a/src/sdk/index.ts +++ b/src/sdk/index.ts @@ -1,3 +1,4 @@ +import { SessionKeyValidator } from './SessionKeyValidator'; import { ModularSdk } from './sdk'; export * from './dto'; @@ -7,5 +8,5 @@ export * from './state'; export * from './wallet'; export * from './bundler'; -export { ModularSdk }; +export { ModularSdk, SessionKeyValidator }; export default ModularSdk; \ No newline at end of file diff --git a/src/sdk/network/constants.ts b/src/sdk/network/constants.ts index 346f1c9..61e5d88 100644 --- a/src/sdk/network/constants.ts +++ b/src/sdk/network/constants.ts @@ -88,6 +88,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [11155111]: { @@ -98,6 +99,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '0x90A5d7496C8D83f6389E60C0c26ea3928d9bb891', }, }, [10]: { @@ -108,6 +110,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [137]: { @@ -118,6 +121,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [42161]: { @@ -128,6 +132,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [1]: { @@ -138,6 +143,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [10200]: { @@ -148,6 +154,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [122]: { @@ -158,6 +165,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [123]: { @@ -168,6 +176,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [100]: { @@ -178,6 +187,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [2357]: { @@ -188,6 +198,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [30]: { @@ -198,6 +209,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [31]: { @@ -208,6 +220,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [5000]: { @@ -218,6 +231,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [5003]: { @@ -228,6 +242,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [43114]: { @@ -238,6 +253,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [8453]: { @@ -248,6 +264,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [56]: { @@ -258,6 +275,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [97]: { @@ -268,6 +286,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [43113]: { @@ -278,6 +297,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [59144]: { @@ -288,6 +308,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [59140]: { @@ -298,6 +319,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [114]: { @@ -308,6 +330,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [14]: { @@ -318,6 +341,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [534351]: { @@ -328,6 +352,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [534352]: { @@ -338,6 +363,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [11155420]: { @@ -348,6 +374,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [28122024]: { @@ -358,6 +385,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [888888888]: { @@ -368,6 +396,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [80002]: { @@ -378,6 +407,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [421614]: { @@ -388,6 +418,7 @@ export const Networks: { walletFactory: '0xf80D543Ca10B48AF07c65Ff508605c1737EFAF3F', bootstrap: '0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066', multipleOwnerECDSAValidator: '0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143', + erc20SessionKeyValidator: '', }, }, [51]: { @@ -398,10 +429,12 @@ export const Networks: { walletFactory: '0x5952653F151e844346825050d7157A9a6b46A23A', bootstrap: '0x805650ce74561C85baA44a8Bd13E19633Fd0F79d', multipleOwnerECDSAValidator: '0x68BA597bf6B9097b1D89b8E0D34646D30997f773', + erc20SessionKeyValidator: '', }, } }; +export const DEFAULT_ERC20_SESSION_KEY_VALIDATOR_ADDRESS = "0x90A5d7496C8D83f6389E60C0c26ea3928d9bb891"; export const DEFAULT_BOOTSTRAP_ADDRESS = "0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066"; export const DEFAULT_MULTIPLE_OWNER_ECDSA_VALIDATOR_ADDRESS = "0x609d3ED5F7D1707806327D198Cb480B93dD6E6b9"; export const DEFAULT_QUERY_PAGE_SIZE = 50; diff --git a/src/sdk/network/interfaces.ts b/src/sdk/network/interfaces.ts index 8902b6f..1c00161 100644 --- a/src/sdk/network/interfaces.ts +++ b/src/sdk/network/interfaces.ts @@ -13,5 +13,6 @@ export interface NetworkConfig { walletFactory: string; bootstrap: string; multipleOwnerECDSAValidator: string; + erc20SessionKeyValidator: string; }; };