From 74e4fe2d746557198275f8297136b07f55bf802a Mon Sep 17 00:00:00 2001 From: Garvit Khatri Date: Mon, 12 Aug 2024 12:54:45 +0100 Subject: [PATCH 1/3] simplify account requirements --- .../privateKeyToBiconomySmartAccount.ts | 21 +--- .../biconomy/signerToBiconomySmartAccount.ts | 13 +-- .../kernel/signerToEcdsaKernelSmartAccount.ts | 18 ++-- .../light/privateKeyToLightSmartAccount.ts | 20 +--- .../light/signerToLightSmartAccount.ts | 17 ++- .../safe/privateKeyToSafeSmartAccount.ts | 20 +--- .../accounts/safe/signerToSafeSmartAccount.ts | 17 ++- .../simple/privateKeyToSimpleSmartAccount.ts | 22 +--- .../simple/signerToSimpleSmartAccount.ts | 17 ++- .../permissionless/accounts/toSmartAccount.ts | 23 ++-- .../trust/privateKeyToTrustSmartAccount.ts | 20 +--- .../trust/signerToTrustSmartAccount.ts | 12 +-- .../accounts/trust/utils/getAccountAddress.ts | 6 +- .../accounts/trust/utils/signMessage.ts | 7 +- .../accounts/trust/utils/signUserOperation.ts | 5 +- packages/permissionless/accounts/types.ts | 18 ++-- packages/permissionless/actions/erc7579.ts | 72 +++---------- .../actions/erc7579/accountId.ts | 27 +++-- .../actions/erc7579/installModule.ts | 32 ++---- .../actions/erc7579/installModules.ts | 32 ++---- .../actions/erc7579/isModuleInstalled.ts | 44 ++++---- .../actions/erc7579/supportsExecutionMode.ts | 47 ++++---- .../actions/erc7579/supportsModule.ts | 41 ++++--- .../actions/erc7579/uninstallModule.ts | 39 ++----- .../actions/erc7579/uninstallModules.ts | 32 ++---- .../actions/smartAccount/deployContract.ts | 36 +++---- .../prepareUserOperationRequest.ts | 102 +++++++----------- .../actions/smartAccount/sendTransaction.ts | 21 +--- .../actions/smartAccount/sendTransactions.ts | 30 ++---- .../actions/smartAccount/sendUserOperation.ts | 29 ++--- .../actions/smartAccount/signMessage.ts | 8 +- .../actions/smartAccount/signTypedData.ts | 8 +- .../actions/smartAccount/writeContract.ts | 13 +-- .../clients/createBundlerClient.ts | 5 +- .../clients/decorators/smartAccount.ts | 87 +++++++-------- .../eip7677/actions/getPaymasterData.ts | 4 +- .../eip7677/actions/getPaymasterStubData.ts | 4 +- .../decorators/paymasterActionsEip7677.ts | 9 +- packages/permissionless/types/index.ts | 14 +-- 39 files changed, 344 insertions(+), 648 deletions(-) diff --git a/packages/permissionless/accounts/biconomy/privateKeyToBiconomySmartAccount.ts b/packages/permissionless/accounts/biconomy/privateKeyToBiconomySmartAccount.ts index 39f36efb..a7b4665c 100644 --- a/packages/permissionless/accounts/biconomy/privateKeyToBiconomySmartAccount.ts +++ b/packages/permissionless/accounts/biconomy/privateKeyToBiconomySmartAccount.ts @@ -1,11 +1,4 @@ -import type { - Chain, - Client, - Hex, - PublicActions, - PublicRpcSchema, - Transport -} from "viem" +import type { Account, Chain, Client, Hex, Transport } from "viem" import { privateKeyToAccount } from "viem/accounts" import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types" import { @@ -30,15 +23,10 @@ export type PrivateKeyToBiconomySmartAccountParameters< export async function privateKeyToBiconomySmartAccount< entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { privateKey, ...rest @@ -49,6 +37,7 @@ export async function privateKeyToBiconomySmartAccount< entryPoint, TTransport, TChain, + TClientAccount, "privateKey" >(client, { signer: privateKeyAccount, diff --git a/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts b/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts index edc52b4e..fe53e130 100644 --- a/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts +++ b/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts @@ -1,4 +1,4 @@ -import type { PublicActions, PublicRpcSchema, TypedData } from "viem" +import type { Account, TypedData } from "viem" import { type Address, type Chain, @@ -212,16 +212,11 @@ export async function signerToBiconomySmartAccount< entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined, TSource extends string = string, TAddress extends Address = Address >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { signer, address, @@ -311,7 +306,7 @@ export async function signerToBiconomySmartAccount< TTypedData, TPrimaryType, TChain, - undefined + TClientAccount >(client, { account: viemSigner, ...typedData diff --git a/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts b/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts index 3eb63024..ac0e5d1b 100644 --- a/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +++ b/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts @@ -1,4 +1,4 @@ -import type { PublicActions, PublicRpcSchema, TypedData } from "viem" +import type { Account, TypedData } from "viem" import { type Address, type Chain, @@ -316,14 +316,15 @@ const getAccountInitCode = async ({ const getAccountAddress = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >({ client, entryPoint: entryPointAddress, factory, factoryData }: { - client: Client + client: Client entryPoint: entryPoint factory: Address factoryData: Hex @@ -373,16 +374,11 @@ export async function signerToEcdsaKernelSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined, TSource extends string = string, TAddress extends Address = Address >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { signer, address, @@ -487,7 +483,7 @@ export async function signerToEcdsaKernelSmartAccount< TTypedData, TPrimaryType, TChain, - undefined + TClientAccount >(client, { account: viemSigner, ...typedData, diff --git a/packages/permissionless/accounts/light/privateKeyToLightSmartAccount.ts b/packages/permissionless/accounts/light/privateKeyToLightSmartAccount.ts index 7d7d7651..b5a5556d 100644 --- a/packages/permissionless/accounts/light/privateKeyToLightSmartAccount.ts +++ b/packages/permissionless/accounts/light/privateKeyToLightSmartAccount.ts @@ -1,11 +1,4 @@ -import type { - Chain, - Client, - Hex, - PublicActions, - PublicRpcSchema, - Transport -} from "viem" +import type { Account, Chain, Client, Hex, Transport } from "viem" import { privateKeyToAccount } from "viem/accounts" import type { Prettify } from "../../types" import type { EntryPoint } from "../../types" @@ -31,15 +24,10 @@ export type PrivateKeyToLightSmartAccountParameters< export async function privateKeyToLightSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { privateKey, ...rest }: PrivateKeyToLightSmartAccountParameters ): Promise> { const privateKeyAccount = privateKeyToAccount(privateKey) diff --git a/packages/permissionless/accounts/light/signerToLightSmartAccount.ts b/packages/permissionless/accounts/light/signerToLightSmartAccount.ts index 8f043ad5..7f369f77 100644 --- a/packages/permissionless/accounts/light/signerToLightSmartAccount.ts +++ b/packages/permissionless/accounts/light/signerToLightSmartAccount.ts @@ -1,11 +1,10 @@ import { + type Account, type Address, type Chain, type Client, type Hex, type LocalAccount, - type PublicActions, - type PublicRpcSchema, type Transport, type TypedData, type TypedDataDefinition, @@ -80,7 +79,8 @@ const getAccountInitCode = async ( const getAccountAddress = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >({ client, factoryAddress, @@ -88,7 +88,7 @@ const getAccountAddress = async < owner, index = BigInt(0) }: { - client: Client + client: Client factoryAddress: Address owner: Address entryPoint: entryPoint @@ -191,16 +191,11 @@ export async function signerToLightSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined, TSource extends string = string, TAddress extends Address = Address >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { signer, address, diff --git a/packages/permissionless/accounts/safe/privateKeyToSafeSmartAccount.ts b/packages/permissionless/accounts/safe/privateKeyToSafeSmartAccount.ts index 8404f27e..e96946d6 100644 --- a/packages/permissionless/accounts/safe/privateKeyToSafeSmartAccount.ts +++ b/packages/permissionless/accounts/safe/privateKeyToSafeSmartAccount.ts @@ -1,11 +1,4 @@ -import type { - Chain, - Client, - Hex, - PublicActions, - PublicRpcSchema, - Transport -} from "viem" +import type { Account, Chain, Client, Hex, Transport } from "viem" import { privateKeyToAccount } from "viem/accounts" import type { EntryPoint, Prettify } from "../../types" import { @@ -30,15 +23,10 @@ export type PrivateKeyToSafeSmartAccountParameters< export async function privateKeyToSafeSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { privateKey, ...rest }: PrivateKeyToSafeSmartAccountParameters ): Promise> { const privateKeyAccount = privateKeyToAccount(privateKey) diff --git a/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts b/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts index 00311de5..a404e350 100644 --- a/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts +++ b/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts @@ -1,11 +1,10 @@ import { + type Account, type Address, type Chain, type Client, type Hex, type LocalAccount, - type PublicActions, - type PublicRpcSchema, type SignableMessage, type Transport, type TypedData, @@ -864,7 +863,8 @@ const getAccountInitCode = async ({ const getAccountAddress = async < TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >({ client, owner, @@ -884,7 +884,7 @@ const getAccountAddress = async < attesters = [], attestersThreshold = 0 }: { - client: Client + client: Client owner: Address safeModuleSetupAddress: Address safe4337ModuleAddress: Address @@ -1087,17 +1087,12 @@ export async function signerToSafeSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined, TSource extends string = string, TAddress extends Address = Address, TErc7579 extends Address | undefined = undefined >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, args: SignerToSafeSmartAccountParameters< entryPoint, TSource, diff --git a/packages/permissionless/accounts/simple/privateKeyToSimpleSmartAccount.ts b/packages/permissionless/accounts/simple/privateKeyToSimpleSmartAccount.ts index 927d47bc..135f827d 100644 --- a/packages/permissionless/accounts/simple/privateKeyToSimpleSmartAccount.ts +++ b/packages/permissionless/accounts/simple/privateKeyToSimpleSmartAccount.ts @@ -1,12 +1,4 @@ -import type { - Address, - Chain, - Client, - Hex, - PublicActions, - PublicRpcSchema, - Transport -} from "viem" +import type { Account, Address, Chain, Client, Hex, Transport } from "viem" import { privateKeyToAccount } from "viem/accounts" import type { EntryPoint, Prettify } from "../../types" import { @@ -31,15 +23,10 @@ export type PrivateKeyToSimpleSmartAccountParameters< export async function privateKeyToSimpleSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { privateKey, ...rest @@ -51,6 +38,7 @@ export async function privateKeyToSimpleSmartAccount< entryPoint, TTransport, TChain, + TClientAccount, "privateKey", Address >(client, { diff --git a/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts b/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts index 7c987bf9..16dd0ea2 100644 --- a/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts +++ b/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts @@ -1,11 +1,10 @@ import { + type Account, type Address, type Chain, type Client, type Hex, type LocalAccount, - type PublicActions, - type PublicRpcSchema, type Transport, concatHex, encodeFunctionData @@ -76,7 +75,8 @@ const getAccountInitCode = async ( const getAccountAddress = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >({ client, factoryAddress, @@ -84,7 +84,7 @@ const getAccountAddress = async < owner, index = BigInt(0) }: { - client: Client + client: Client factoryAddress: Address owner: Address entryPoint: entryPoint @@ -142,16 +142,11 @@ export async function signerToSimpleSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined, TSource extends string = string, TAddress extends Address = Address >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { signer, factoryAddress: _factoryAddress, diff --git a/packages/permissionless/accounts/toSmartAccount.ts b/packages/permissionless/accounts/toSmartAccount.ts index c4637dd5..9d199174 100644 --- a/packages/permissionless/accounts/toSmartAccount.ts +++ b/packages/permissionless/accounts/toSmartAccount.ts @@ -1,13 +1,12 @@ import { type Abi, + type Account, type Address, type Chain, type Client, type CustomSource, type EncodeDeployDataParameters, type Hex, - type PublicActions, - type PublicRpcSchema, type SignableMessage, type Transport, type TypedDataDefinition, @@ -32,6 +31,7 @@ export function toSmartAccount< TSource extends string = string, transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, + clientAccount extends Account | undefined = Account | undefined, TAbi extends Abi | readonly unknown[] = Abi >({ address, @@ -50,13 +50,7 @@ export function toSmartAccount< signTypedData }: TAccountSource & { source: TSource - client: Client< - transport, - chain, - undefined, - PublicRpcSchema, - PublicActions - > + client: Client entryPoint: TEntryPoint getNonce: (key?: bigint) => Promise getInitCode: () => Promise @@ -86,7 +80,7 @@ export function toSmartAccount< signUserOperation: ( userOperation: UserOperation> ) => Promise -}): SmartAccount { +}): SmartAccount { const account = toAccount({ address: address, signMessage: async ({ message }: { message: SignableMessage }) => { @@ -171,5 +165,12 @@ export function toSmartAccount< getDummySignature, encodeDeployCallData, signUserOperation - } + } as SmartAccount< + TEntryPoint, + TSource, + transport, + chain, + clientAccount, + TAbi + > } diff --git a/packages/permissionless/accounts/trust/privateKeyToTrustSmartAccount.ts b/packages/permissionless/accounts/trust/privateKeyToTrustSmartAccount.ts index 1613b028..45f33611 100644 --- a/packages/permissionless/accounts/trust/privateKeyToTrustSmartAccount.ts +++ b/packages/permissionless/accounts/trust/privateKeyToTrustSmartAccount.ts @@ -1,11 +1,4 @@ -import type { - Chain, - Client, - Hex, - PublicActions, - PublicRpcSchema, - Transport -} from "viem" +import type { Account, Chain, Client, Hex, Transport } from "viem" import { privateKeyToAccount } from "viem/accounts" import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types" import { @@ -30,15 +23,10 @@ export type PrivateKeyToTrustSmartAccountParameters< export async function privateKeyToTrustSmartAccount< entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { privateKey, ...rest }: PrivateKeyToTrustSmartAccountParameters ): Promise> { const privateKeyAccount = privateKeyToAccount(privateKey) diff --git a/packages/permissionless/accounts/trust/signerToTrustSmartAccount.ts b/packages/permissionless/accounts/trust/signerToTrustSmartAccount.ts index 6cc97f84..5384ac25 100644 --- a/packages/permissionless/accounts/trust/signerToTrustSmartAccount.ts +++ b/packages/permissionless/accounts/trust/signerToTrustSmartAccount.ts @@ -1,11 +1,10 @@ import { + type Account, type Address, type Chain, type Client, type Hex, type LocalAccount, - type PublicActions, - type PublicRpcSchema, type Transport, type TypedData, type TypedDataDefinition, @@ -100,16 +99,11 @@ export async function signerToTrustSmartAccount< entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined, TSource extends string = string, TAddress extends Address = Address >( - client: Client< - TTransport, - TChain, - undefined, - PublicRpcSchema, - PublicActions - >, + client: Client, { signer, factoryAddress = TRUST_ADDRESSES.factoryAddress, diff --git a/packages/permissionless/accounts/trust/utils/getAccountAddress.ts b/packages/permissionless/accounts/trust/utils/getAccountAddress.ts index f52d45cf..ffb65dff 100644 --- a/packages/permissionless/accounts/trust/utils/getAccountAddress.ts +++ b/packages/permissionless/accounts/trust/utils/getAccountAddress.ts @@ -1,4 +1,5 @@ import { + type Account, type Address, type Chain, type Client, @@ -12,9 +13,10 @@ import { getFactoryData } from "./getFactoryData" export const getAccountAddress = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >( - client: Client, + client: Client, { factoryAddress, entryPoint: entryPointAddress, diff --git a/packages/permissionless/accounts/trust/utils/signMessage.ts b/packages/permissionless/accounts/trust/utils/signMessage.ts index 76558165..75099d24 100644 --- a/packages/permissionless/accounts/trust/utils/signMessage.ts +++ b/packages/permissionless/accounts/trust/utils/signMessage.ts @@ -1,12 +1,13 @@ -import type { Chain, Client, Transport } from "viem" +import type { Account, Chain, Client, Transport } from "viem" import type { SignMessageParameters } from "viem" import { signMessage as viem_signMessage } from "viem/actions" export const signMessage = < TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >( - client: Client, + client: Client, { account, message }: SignMessageParameters ) => { return viem_signMessage(client, { account, message }) diff --git a/packages/permissionless/accounts/trust/utils/signUserOperation.ts b/packages/permissionless/accounts/trust/utils/signUserOperation.ts index 0ff0393a..b5e01d89 100644 --- a/packages/permissionless/accounts/trust/utils/signUserOperation.ts +++ b/packages/permissionless/accounts/trust/utils/signUserOperation.ts @@ -10,9 +10,10 @@ import { signMessage } from "./signMessage" export const signUserOperation = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >( - client: Client, + client: Client, { account, userOperation, diff --git a/packages/permissionless/accounts/types.ts b/packages/permissionless/accounts/types.ts index a11d787f..8f1541e9 100644 --- a/packages/permissionless/accounts/types.ts +++ b/packages/permissionless/accounts/types.ts @@ -7,10 +7,9 @@ import { type LocalAccount } from "viem" import type { + Account, Chain, EncodeDeployDataParameters, - PublicActions, - PublicRpcSchema, Transport } from "viem" import type { UserOperation } from "../types" @@ -34,18 +33,13 @@ export class SignTransactionNotSupportedBySmartAccount extends BaseError { export type SmartAccount< entryPoint extends EntryPoint, - TSource extends string, - transport extends Transport, - chain extends Chain | undefined, + TSource extends string = string, + transport extends Transport = Transport, + chain extends Chain | undefined = Chain | undefined, + clientAccount extends Account | undefined = Account | undefined, TAbi extends Abi | readonly unknown[] = Abi > = LocalAccount & { - client: Client< - transport, - chain, - undefined, - PublicRpcSchema, - PublicActions - > + client: Client entryPoint: entryPoint getNonce: (key?: bigint) => Promise getInitCode: () => Promise diff --git a/packages/permissionless/actions/erc7579.ts b/packages/permissionless/actions/erc7579.ts index f131ede2..d2f62948 100644 --- a/packages/permissionless/actions/erc7579.ts +++ b/packages/permissionless/actions/erc7579.ts @@ -36,77 +36,33 @@ import { export type Erc7579Actions< TEntryPoint extends EntryPoint, - TTransport extends Transport, - TChain extends Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined + TSmartAccount extends SmartAccount | undefined > = { accountId: ( args?: TSmartAccount extends undefined - ? GetAccountParameter< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > + ? GetAccountParameter : undefined ) => Promise installModule: ( - args: InstallModuleParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > + args: InstallModuleParameters ) => Promise installModules: ( - args: InstallModulesParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > + args: InstallModulesParameters ) => Promise isModuleInstalled: ( - args: IsModuleInstalledParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > + args: IsModuleInstalledParameters ) => Promise supportsExecutionMode: ( - args: SupportsExecutionModeParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > + args: SupportsExecutionModeParameters ) => Promise supportsModule: ( - args: SupportsModuleParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > + args: SupportsModuleParameters ) => Promise uninstallModule: ( - args: UninstallModuleParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > + args: UninstallModuleParameters ) => Promise uninstallModules: ( - args: UninstallModulesParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > + args: UninstallModulesParameters ) => Promise } @@ -136,14 +92,14 @@ export function erc7579Actions(_args: { entryPoint: TEntryPoint }) { return < - TTransport extends Transport, - TChain extends Chain | undefined, - TSmartAccount extends - | SmartAccount + TTransport extends Transport = Transport, + TChain extends Chain | undefined = Chain | undefined, + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client - ): Erc7579Actions => ({ + ): Erc7579Actions => ({ accountId: (args) => accountId(client, args), installModule: (args) => installModule( diff --git a/packages/permissionless/actions/erc7579/accountId.ts b/packages/permissionless/actions/erc7579/accountId.ts index d7e370bd..ea681270 100644 --- a/packages/permissionless/actions/erc7579/accountId.ts +++ b/packages/permissionless/actions/erc7579/accountId.ts @@ -7,6 +7,8 @@ import { decodeFunctionResult, encodeFunctionData } from "viem" +import { call, readContract } from "viem/actions" +import { getAction } from "viem/utils" import type { SmartAccount } from "../../accounts/types" import type { GetAccountParameter } from "../../types" import type { EntryPoint } from "../../types/entrypoint" @@ -17,12 +19,12 @@ export async function accountId< TEntryPoint extends EntryPoint, TTransport extends Transport, TChain extends Chain | undefined, - TSmartAccount extends - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - args?: GetAccountParameter + args?: GetAccountParameter ): Promise { let account_ = client.account @@ -36,12 +38,7 @@ export async function accountId< }) } - const account = parseAccount(account_) as SmartAccount< - TEntryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const publicClient = account.client @@ -61,7 +58,11 @@ export async function accountId< ] as const try { - return await publicClient.readContract({ + return await getAction( + publicClient, + readContract, + "readContract" + )({ abi, functionName: "accountId", address: account.address @@ -71,7 +72,11 @@ export async function accountId< const factory = await account.getFactory() const factoryData = await account.getFactoryData() - const result = await publicClient.call({ + const result = await getAction( + publicClient, + call, + "call" + )({ factory: factory, factoryData: factoryData, to: account.address, diff --git a/packages/permissionless/actions/erc7579/installModule.ts b/packages/permissionless/actions/erc7579/installModule.ts index 2e5a1341..f61f47de 100644 --- a/packages/permissionless/actions/erc7579/installModule.ts +++ b/packages/permissionless/actions/erc7579/installModule.ts @@ -22,12 +22,8 @@ import { type ModuleType, parseModuleTypeId } from "./supportsModule" export type InstallModuleParameters< TEntryPoint extends EntryPoint, - TTransport extends Transport, - TChain extends Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined -> = GetAccountParameter & { + TSmartAccount extends SmartAccount | undefined +> = GetAccountParameter & { type: ModuleType address: Address context: Hex @@ -40,16 +36,12 @@ export async function installModule< TEntryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - parameters: Prettify< - InstallModuleParameters - > + parameters: Prettify> ): Promise { const { account: account_ = client.account, @@ -67,12 +59,7 @@ export async function installModule< }) } - const account = parseAccount(account_) as SmartAccount< - TEntryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const installModuleCallData = await account.encodeCallData({ to: account.address, @@ -123,10 +110,5 @@ export async function installModule< }, account: account, middleware - } as SendUserOperationParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - >) + } as SendUserOperationParameters) } diff --git a/packages/permissionless/actions/erc7579/installModules.ts b/packages/permissionless/actions/erc7579/installModules.ts index 0f943c4c..c9a81468 100644 --- a/packages/permissionless/actions/erc7579/installModules.ts +++ b/packages/permissionless/actions/erc7579/installModules.ts @@ -22,12 +22,8 @@ import { type ModuleType, parseModuleTypeId } from "./supportsModule" export type InstallModulesParameters< TEntryPoint extends EntryPoint, - TTransport extends Transport, - TChain extends Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined -> = GetAccountParameter & + TSmartAccount extends SmartAccount | undefined +> = GetAccountParameter & Middleware & { modules: { type: ModuleType @@ -43,17 +39,13 @@ export async function installModules< TEntryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined | undefined >( client: Client, - parameters: Prettify< - InstallModulesParameters - > + parameters: Prettify> ): Promise { const { account: account_ = client.account, @@ -70,12 +62,7 @@ export async function installModules< }) } - const account = parseAccount(account_) as SmartAccount< - TEntryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const installModulesCallData = await account.encodeCallData( await Promise.all( @@ -130,10 +117,5 @@ export async function installModules< }, account: account, middleware - } as SendUserOperationParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - >) + } as SendUserOperationParameters) } diff --git a/packages/permissionless/actions/erc7579/isModuleInstalled.ts b/packages/permissionless/actions/erc7579/isModuleInstalled.ts index 6ab614b1..851ae77a 100644 --- a/packages/permissionless/actions/erc7579/isModuleInstalled.ts +++ b/packages/permissionless/actions/erc7579/isModuleInstalled.ts @@ -10,6 +10,8 @@ import { encodeFunctionData, getAddress } from "viem" +import { call, readContract } from "viem/actions" +import { getAction } from "viem/utils" import type { SmartAccount } from "../../accounts/types" import type { GetAccountParameter } from "../../types/" import type { EntryPoint } from "../../types/entrypoint" @@ -19,14 +21,8 @@ import { type ModuleType, parseModuleTypeId } from "./supportsModule" export type IsModuleInstalledParameters< TEntryPoint extends EntryPoint, - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount - | undefined -> = GetAccountParameter & { + TSmartAccount extends SmartAccount | undefined +> = GetAccountParameter & { type: ModuleType address: Address context: Hex @@ -36,19 +32,12 @@ export async function isModuleInstalled< TEntryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - parameters: IsModuleInstalledParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > + parameters: IsModuleInstalledParameters ): Promise { const { account: account_ = client.account, address, context } = parameters @@ -58,12 +47,7 @@ export async function isModuleInstalled< }) } - const account = parseAccount(account_) as SmartAccount< - TEntryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const publicClient = account.client @@ -95,7 +79,11 @@ export async function isModuleInstalled< ] as const try { - return await publicClient.readContract({ + return await getAction( + publicClient, + readContract, + "readContract" + )({ abi, functionName: "isModuleInstalled", args: [ @@ -110,7 +98,11 @@ export async function isModuleInstalled< const factory = await account.getFactory() const factoryData = await account.getFactoryData() - const result = await publicClient.call({ + const result = await getAction( + publicClient, + call, + "call" + )({ factory: factory, factoryData: factoryData, to: account.address, diff --git a/packages/permissionless/actions/erc7579/supportsExecutionMode.ts b/packages/permissionless/actions/erc7579/supportsExecutionMode.ts index da0d27a3..39820b41 100644 --- a/packages/permissionless/actions/erc7579/supportsExecutionMode.ts +++ b/packages/permissionless/actions/erc7579/supportsExecutionMode.ts @@ -11,6 +11,8 @@ import { toBytes, toHex } from "viem" +import { call, readContract } from "viem/actions" +import { getAction } from "viem/utils" import type { SmartAccount } from "../../accounts/types" import type { GetAccountParameter, Prettify } from "../../types/" import type { EntryPoint } from "../../types/entrypoint" @@ -28,16 +30,11 @@ export type ExecutionMode = { export type SupportsExecutionModeParameters< TEntryPoint extends EntryPoint, - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined, callType extends CallType = CallType -> = GetAccountParameter & - ExecutionMode +> = GetAccountParameter & ExecutionMode function parseCallType(callType: CallType) { switch (callType) { @@ -72,21 +69,12 @@ export async function supportsExecutionMode< TEntryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - args: Prettify< - SupportsExecutionModeParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > - > + args: Prettify> ): Promise { const { account: account_ = client.account, @@ -102,12 +90,7 @@ export async function supportsExecutionMode< }) } - const account = parseAccount(account_) as SmartAccount< - TEntryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const publicClient = account.client @@ -138,7 +121,11 @@ export async function supportsExecutionMode< ] as const try { - return await publicClient.readContract({ + return await getAction( + publicClient, + readContract, + "readContract" + )({ abi, functionName: "supportsExecutionMode", args: [encodedMode], @@ -149,7 +136,11 @@ export async function supportsExecutionMode< const factory = await account.getFactory() const factoryData = await account.getFactoryData() - const result = await publicClient.call({ + const result = await getAction( + publicClient, + call, + "call" + )({ factory: factory, factoryData: factoryData, to: account.address, diff --git a/packages/permissionless/actions/erc7579/supportsModule.ts b/packages/permissionless/actions/erc7579/supportsModule.ts index 3396d5f5..17f36799 100644 --- a/packages/permissionless/actions/erc7579/supportsModule.ts +++ b/packages/permissionless/actions/erc7579/supportsModule.ts @@ -7,6 +7,8 @@ import { decodeFunctionResult, encodeFunctionData } from "viem" +import { call, readContract } from "viem/actions" +import { getAction } from "viem/utils" import type { SmartAccount } from "../../accounts/types" import type { GetAccountParameter, Prettify } from "../../types/" import type { EntryPoint } from "../../types/entrypoint" @@ -17,14 +19,10 @@ export type ModuleType = "validator" | "executor" | "fallback" | "hook" export type SupportsModuleParameters< TEntryPoint extends EntryPoint, - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined -> = GetAccountParameter & { +> = GetAccountParameter & { type: ModuleType } @@ -47,16 +45,12 @@ export async function supportsModule< TEntryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - args: Prettify< - SupportsModuleParameters - > + args: Prettify> ): Promise { const { account: account_ = client.account } = args @@ -66,12 +60,7 @@ export async function supportsModule< }) } - const account = parseAccount(account_) as SmartAccount< - TEntryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const publicClient = account.client @@ -95,7 +84,11 @@ export async function supportsModule< ] as const try { - return await publicClient.readContract({ + return await getAction( + publicClient, + readContract, + "readContract" + )({ abi, functionName: "supportsModule", args: [parseModuleTypeId(args.type)], @@ -106,7 +99,11 @@ export async function supportsModule< const factory = await account.getFactory() const factoryData = await account.getFactoryData() - const result = await publicClient.call({ + const result = await getAction( + publicClient, + call, + "call" + )({ factory: factory, factoryData: factoryData, to: account.address, diff --git a/packages/permissionless/actions/erc7579/uninstallModule.ts b/packages/permissionless/actions/erc7579/uninstallModule.ts index 617eb7dd..495f044f 100644 --- a/packages/permissionless/actions/erc7579/uninstallModule.ts +++ b/packages/permissionless/actions/erc7579/uninstallModule.ts @@ -22,14 +22,10 @@ import { type ModuleType, parseModuleTypeId } from "./supportsModule" export type UninstallModuleParameters< TEntryPoint extends EntryPoint, - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined -> = GetAccountParameter & { +> = GetAccountParameter & { type: ModuleType address: Address context: Hex @@ -42,21 +38,12 @@ export async function uninstallModule< TEntryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - parameters: Prettify< - UninstallModuleParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > - > + parameters: Prettify> ): Promise { const { account: account_ = client.account, @@ -74,12 +61,7 @@ export async function uninstallModule< }) } - const account = parseAccount(account_) as SmartAccount< - TEntryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const uninstallModuleCallData = await account.encodeCallData({ to: account.address, @@ -130,10 +112,5 @@ export async function uninstallModule< }, account: account, middleware - } as SendUserOperationParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - >) + } as SendUserOperationParameters) } diff --git a/packages/permissionless/actions/erc7579/uninstallModules.ts b/packages/permissionless/actions/erc7579/uninstallModules.ts index e9a12853..43b47dc5 100644 --- a/packages/permissionless/actions/erc7579/uninstallModules.ts +++ b/packages/permissionless/actions/erc7579/uninstallModules.ts @@ -22,14 +22,10 @@ import { type ModuleType, parseModuleTypeId } from "./supportsModule" export type UninstallModulesParameters< TEntryPoint extends EntryPoint, - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined -> = GetAccountParameter & { +> = GetAccountParameter & { modules: [ { type: ModuleType @@ -46,21 +42,12 @@ export async function uninstallModules< TEntryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - parameters: Prettify< - UninstallModulesParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - > - > + parameters: Prettify> ): Promise { const { account: account_ = client.account, @@ -137,10 +124,5 @@ export async function uninstallModules< }, account: account, middleware - } as SendUserOperationParameters< - TEntryPoint, - TTransport, - TChain, - TSmartAccount - >) + } as SendUserOperationParameters) } diff --git a/packages/permissionless/actions/smartAccount/deployContract.ts b/packages/permissionless/actions/smartAccount/deployContract.ts index bbb1ee2a..50bfd3b8 100644 --- a/packages/permissionless/actions/smartAccount/deployContract.ts +++ b/packages/permissionless/actions/smartAccount/deployContract.ts @@ -1,5 +1,6 @@ import type { Abi, + Account, Chain, Client, DeployContractParameters, @@ -9,7 +10,6 @@ import type { } from "viem" import { getAction } from "viem/utils" import type { SmartAccount } from "../../accounts/types" -import type { Prettify } from "../../types/" import type { EntryPoint } from "../../types/entrypoint" import { parseAccount } from "../../utils/" import { AccountOrClientNotFoundError } from "../../utils/signUserOperationHashWithECDSA" @@ -23,13 +23,8 @@ import { export type DeployContractParametersWithPaymaster< entryPoint extends EntryPoint, TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[], - TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount - | undefined, + TAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined > = DeployContractParameters & Middleware @@ -66,14 +61,18 @@ export async function deployContract< entryPoint extends EntryPoint, TTransport extends Transport, TChain extends Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount - | undefined + TAbi extends Abi | readonly unknown[], + TAccount extends SmartAccount | undefined, + TChainOverride extends Chain | undefined >( - client: Client, - args: Prettify> + client: Client, + args: DeployContractParametersWithPaymaster< + entryPoint, + TAbi, + TChain, + TAccount, + TChainOverride + > ): Promise { const { abi, @@ -91,12 +90,7 @@ export async function deployContract< }) } - const account = parseAccount(account_) as SmartAccount< - entryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const userOpHash = await getAction( client, @@ -115,7 +109,7 @@ export async function deployContract< }, account: account, middleware - } as SendUserOperationParameters) + } as SendUserOperationParameters) const userOperationReceipt = await getAction( client, diff --git a/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts b/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts index 444a4150..f719bf8a 100644 --- a/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts +++ b/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts @@ -72,12 +72,8 @@ export type Middleware = { export type PrepareUserOperationRequestParameters< entryPoint extends EntryPoint, - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined > = { userOperation: entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE @@ -111,7 +107,7 @@ export type PrepareUserOperationRequestParameters< | "paymasterData" | "signature" > -} & GetAccountParameter & +} & GetAccountParameter & Middleware export type PrepareUserOperationRequestReturnType< @@ -122,21 +118,12 @@ async function prepareUserOperationRequestForEntryPointV06< entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - args: Prettify< - PrepareUserOperationRequestParameters< - entryPoint, - TTransport, - TChain, - TAccount - > - >, + args: PrepareUserOperationRequestParameters, stateOverrides?: StateOverrides ): Promise>> { const { @@ -146,12 +133,9 @@ async function prepareUserOperationRequestForEntryPointV06< } = args if (!account_) throw new AccountOrClientNotFoundError() - const account = parseAccount(account_) as SmartAccount< - ENTRYPOINT_ADDRESS_V06_TYPE, - string, - Transport, - TChain - > + const account = parseAccount( + account_ + ) as SmartAccount const [sender, nonce, initCode, callData] = await Promise.all([ partialUserOperation.sender || account.address, @@ -271,21 +255,12 @@ async function prepareUserOperationRequestEntryPointV07< entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V07_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - args: Prettify< - PrepareUserOperationRequestParameters< - entryPoint, - TTransport, - TChain, - TAccount - > - >, + args: Prettify>, stateOverrides?: StateOverrides ): Promise>> { const { @@ -295,12 +270,9 @@ async function prepareUserOperationRequestEntryPointV07< } = args if (!account_) throw new AccountOrClientNotFoundError() - const account = parseAccount(account_) as SmartAccount< - ENTRYPOINT_ADDRESS_V07_TYPE, - string, - Transport, - TChain - > + const account = parseAccount( + account_ + ) as SmartAccount const [sender, nonce, factory, factoryData, callData] = await Promise.all([ partialUserOperation.sender || account.address, @@ -427,46 +399,46 @@ export async function prepareUserOperationRequest< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - args: Prettify< - PrepareUserOperationRequestParameters< - entryPoint, - TTransport, - TChain, - TAccount - > - >, + args: PrepareUserOperationRequestParameters, stateOverrides?: StateOverrides ): Promise>> { const { account: account_ = client.account } = args if (!account_) throw new AccountOrClientNotFoundError() - const account = parseAccount(account_) as SmartAccount< - entryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const entryPointVersion = getEntryPointVersion(account.entryPoint) if (entryPointVersion === "v0.6") { return prepareUserOperationRequestForEntryPointV06( - client, - args, + client as unknown as Client< + Transport, + Chain | undefined, + SmartAccount + >, + args as unknown as PrepareUserOperationRequestParameters< + ENTRYPOINT_ADDRESS_V06_TYPE, + SmartAccount + >, stateOverrides ) as Promise> } return prepareUserOperationRequestEntryPointV07( - client, - args, + client as unknown as Client< + Transport, + Chain | undefined, + SmartAccount + >, + args as unknown as PrepareUserOperationRequestParameters< + ENTRYPOINT_ADDRESS_V07_TYPE, + SmartAccount + >, stateOverrides ) as Promise> } diff --git a/packages/permissionless/actions/smartAccount/sendTransaction.ts b/packages/permissionless/actions/smartAccount/sendTransaction.ts index 3f64cb4c..72d4208f 100644 --- a/packages/permissionless/actions/smartAccount/sendTransaction.ts +++ b/packages/permissionless/actions/smartAccount/sendTransaction.ts @@ -16,12 +16,9 @@ import { sendUserOperation } from "./sendUserOperation" export type SendTransactionWithPaymasterParameters< entryPoint extends EntryPoint, - TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined, TChainOverride extends Chain | undefined = Chain | undefined > = SendTransactionParameters & @@ -76,9 +73,7 @@ export type SendTransactionWithPaymasterParameters< export async function sendTransaction< TTransport extends Transport, TChain extends Chain | undefined, - TAccount extends - | SmartAccount - | undefined, + TAccount extends SmartAccount | undefined, entryPoint extends EntryPoint, TChainOverride extends Chain | undefined = Chain | undefined >( @@ -86,7 +81,6 @@ export async function sendTransaction< args: Prettify< SendTransactionWithPaymasterParameters< entryPoint, - TTransport, TChain, TAccount, TChainOverride @@ -110,12 +104,7 @@ export async function sendTransaction< }) } - const account = parseAccount(account_) as SmartAccount< - entryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount if (!to) throw new Error("Missing to address") @@ -135,7 +124,7 @@ export async function sendTransaction< entryPoint, TTransport, TChain, - SmartAccount + SmartAccount >, "sendUserOperation" )({ diff --git a/packages/permissionless/actions/smartAccount/sendTransactions.ts b/packages/permissionless/actions/smartAccount/sendTransactions.ts index ef03a44d..863fb24b 100644 --- a/packages/permissionless/actions/smartAccount/sendTransactions.ts +++ b/packages/permissionless/actions/smartAccount/sendTransactions.ts @@ -18,17 +18,13 @@ import { sendUserOperation } from "./sendUserOperation" export type SendTransactionsWithPaymasterParameters< entryPoint extends EntryPoint, - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined | undefined > = { transactions: { to: Address; value: bigint; data: Hex }[] -} & GetAccountParameter & +} & GetAccountParameter & Middleware & { maxFeePerGas?: bigint maxPriorityFeePerGas?: bigint @@ -84,19 +80,12 @@ export type SendTransactionsWithPaymasterParameters< export async function sendTransactions< TTransport extends Transport, TChain extends Chain | undefined, - TAccount extends - | SmartAccount - | undefined, + TAccount extends SmartAccount | undefined, entryPoint extends EntryPoint >( client: Client, args: Prettify< - SendTransactionsWithPaymasterParameters< - entryPoint, - TTransport, - TChain, - TAccount - > + SendTransactionsWithPaymasterParameters > ): Promise { const { @@ -114,12 +103,7 @@ export async function sendTransactions< }) } - const account = parseAccount(account_) as SmartAccount< - entryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount if (account.type !== "local") { throw new Error("RPC account type not supported") @@ -142,7 +126,7 @@ export async function sendTransactions< entryPoint, TTransport, TChain, - SmartAccount + SmartAccount >, "sendUserOperation" )({ diff --git a/packages/permissionless/actions/smartAccount/sendUserOperation.ts b/packages/permissionless/actions/smartAccount/sendUserOperation.ts index b78d19ac..b5a2dbeb 100644 --- a/packages/permissionless/actions/smartAccount/sendUserOperation.ts +++ b/packages/permissionless/actions/smartAccount/sendUserOperation.ts @@ -22,12 +22,8 @@ import { export type SendUserOperationParameters< entryPoint extends EntryPoint, - TTransport extends Transport = Transport, - TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined > = { userOperation: entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE @@ -61,33 +57,24 @@ export type SendUserOperationParameters< | "paymasterData" | "signature" > -} & GetAccountParameter & +} & GetAccountParameter & Middleware export async function sendUserOperation< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client, - args: Prettify< - SendUserOperationParameters - > + args: Prettify> ): Promise { const { account: account_ = client.account } = args if (!account_) throw new AccountOrClientNotFoundError() - const account = parseAccount(account_) as SmartAccount< - entryPoint, - string, - TTransport, - TChain - > + const account = parseAccount(account_) as SmartAccount const userOperation = await getAction( client, @@ -95,8 +82,6 @@ export async function sendUserOperation< "prepareUserOperationRequest" )({ ...args, account } as PrepareUserOperationRequestParameters< entryPoint, - TTransport, - TChain, TAccount >) diff --git a/packages/permissionless/actions/smartAccount/signMessage.ts b/packages/permissionless/actions/smartAccount/signMessage.ts index 8c0deebc..4a08426a 100644 --- a/packages/permissionless/actions/smartAccount/signMessage.ts +++ b/packages/permissionless/actions/smartAccount/signMessage.ts @@ -59,13 +59,11 @@ export async function signMessage< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( - client: Client, + client: Client, { account: account_ = client.account, message diff --git a/packages/permissionless/actions/smartAccount/signTypedData.ts b/packages/permissionless/actions/smartAccount/signTypedData.ts index 438f3b39..bae146d1 100644 --- a/packages/permissionless/actions/smartAccount/signTypedData.ts +++ b/packages/permissionless/actions/smartAccount/signTypedData.ts @@ -118,13 +118,11 @@ export async function signTypedData< TPrimaryType extends string, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( - client: Client, + client: Client, { account: account_ = client.account, domain, diff --git a/packages/permissionless/actions/smartAccount/writeContract.ts b/packages/permissionless/actions/smartAccount/writeContract.ts index 67a231aa..0ac942b0 100644 --- a/packages/permissionless/actions/smartAccount/writeContract.ts +++ b/packages/permissionless/actions/smartAccount/writeContract.ts @@ -72,12 +72,9 @@ import { */ export type WriteContractWithPaymasterParameters< entryPoint extends EntryPoint, - TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TAccount extends - | SmartAccount - | undefined = - | SmartAccount + TAccount extends SmartAccount | undefined = + | SmartAccount | undefined, TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[], TFunctionName extends ContractFunctionName< @@ -104,9 +101,7 @@ export async function writeContract< entryPoint extends EntryPoint, TTransport extends Transport, TChain extends Chain | undefined, - TAccount extends - | SmartAccount - | undefined, + TAccount extends SmartAccount | undefined, const TAbi extends Abi | readonly unknown[], TFunctionName extends ContractFunctionName< TAbi, @@ -129,7 +124,6 @@ export async function writeContract< ...request }: WriteContractWithPaymasterParameters< entryPoint, - TTransport, TChain, TAccount, TAbi, @@ -159,7 +153,6 @@ export async function writeContract< ...request } as unknown as SendTransactionWithPaymasterParameters< entryPoint, - TTransport, TChain, TAccount, TChainOverride diff --git a/packages/permissionless/clients/createBundlerClient.ts b/packages/permissionless/clients/createBundlerClient.ts index 4ea177dd..7e295133 100644 --- a/packages/permissionless/clients/createBundlerClient.ts +++ b/packages/permissionless/clients/createBundlerClient.ts @@ -12,11 +12,12 @@ import { type BundlerActions, bundlerActions } from "./decorators/bundler" export type BundlerClient< entryPoint extends EntryPoint, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined > = Client< Transport, TChain, - Account | undefined, + TClientAccount, BundlerRpcSchema, BundlerActions > diff --git a/packages/permissionless/clients/decorators/smartAccount.ts b/packages/permissionless/clients/decorators/smartAccount.ts index 39c472c2..0a20aac7 100644 --- a/packages/permissionless/clients/decorators/smartAccount.ts +++ b/packages/permissionless/clients/decorators/smartAccount.ts @@ -47,10 +47,8 @@ export type SmartAccountActions< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined > = { /** @@ -299,13 +297,11 @@ export type SmartAccountActions< const TAbi extends Abi | readonly unknown[], TChainOverride extends Chain | undefined = undefined >( - args: Prettify< - DeployContractParameters< - TAbi, - TChain, - TSmartAccount, - TChainOverride - > + args: DeployContractParameters< + TAbi, + TChain, + TSmartAccount, + TChainOverride > ) => Promise /** @@ -390,16 +386,14 @@ export type SmartAccountActions< > > prepareUserOperationRequest: ( - args: Prettify< - Parameters< - typeof prepareUserOperationRequest< - entryPoint, - TTransport, - TChain, - TSmartAccount - > - >[1] - >, + args: Parameters< + typeof prepareUserOperationRequest< + entryPoint, + TTransport, + TChain, + TSmartAccount + > + >[1], stateOverrides?: StateOverrides ) => Promise>> sendUserOperation: ( @@ -465,12 +459,7 @@ export type SmartAccountActions< */ sendTransactions: ( args: Prettify< - SendTransactionsWithPaymasterParameters< - entryPoint, - TTransport, - TChain, - TSmartAccount - > + SendTransactionsWithPaymasterParameters > ) => ReturnType< typeof sendTransactions @@ -483,10 +472,8 @@ export function smartAccountActions({ return < TTransport extends Transport, TChain extends Chain | undefined = Chain | undefined, - TSmartAccount extends - | SmartAccount - | undefined = - | SmartAccount + TSmartAccount extends SmartAccount | undefined = + | SmartAccount | undefined >( client: Client @@ -500,11 +487,34 @@ export function smartAccountActions({ }, stateOverrides ), - deployContract: (args) => - deployContract(client, { + deployContract: < + const TAbi extends Abi | readonly unknown[], + TChainOverride extends Chain | undefined = undefined + >( + args: DeployContractParameters< + TAbi, + TChain, + TSmartAccount, + TChainOverride + > + ) => + deployContract< + entryPoint, + TTransport, + TChain, + TAbi, + TSmartAccount, + TChainOverride + >(client, { ...args, middleware - } as DeployContractParametersWithPaymaster), + } as unknown as DeployContractParametersWithPaymaster< + entryPoint, + TAbi, + TChain, + TSmartAccount, + TChainOverride + >), sendTransaction: (args) => sendTransaction( client, @@ -513,7 +523,6 @@ export function smartAccountActions({ middleware } as SendTransactionWithPaymasterParameters< entryPoint, - TTransport, TChain, TSmartAccount > @@ -532,12 +541,7 @@ export function smartAccountActions({ { ...args, middleware - } as SendUserOperationParameters< - entryPoint, - TTransport, - TChain, - TSmartAccount - > + } as SendUserOperationParameters ), signMessage: (args) => signMessage( @@ -598,7 +602,6 @@ export function smartAccountActions({ middleware } as WriteContractWithPaymasterParameters< entryPoint, - TTransport, TChain, TSmartAccount, TAbi diff --git a/packages/permissionless/experimental/eip7677/actions/getPaymasterData.ts b/packages/permissionless/experimental/eip7677/actions/getPaymasterData.ts index c656a105..9482f8e2 100644 --- a/packages/permissionless/experimental/eip7677/actions/getPaymasterData.ts +++ b/packages/permissionless/experimental/eip7677/actions/getPaymasterData.ts @@ -1,4 +1,5 @@ import { + type Account, type Address, type Chain, ChainNotFoundError, @@ -81,13 +82,14 @@ export type GetPaymasterDataReturnType = export async function getPaymasterData< TEntryPoint extends EntryPoint, TChain extends Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined, TTransport extends Transport = Transport, TChainOverride extends Chain | undefined = Chain | undefined >( client: Client< TTransport, TChain, - undefined, + TClientAccount, Eip7677RpcSchema >, { diff --git a/packages/permissionless/experimental/eip7677/actions/getPaymasterStubData.ts b/packages/permissionless/experimental/eip7677/actions/getPaymasterStubData.ts index 0d0ba502..da062abc 100644 --- a/packages/permissionless/experimental/eip7677/actions/getPaymasterStubData.ts +++ b/packages/permissionless/experimental/eip7677/actions/getPaymasterStubData.ts @@ -1,4 +1,5 @@ import { + type Account, type Address, type Chain, ChainNotFoundError, @@ -88,12 +89,13 @@ export async function getPaymasterStubData< TEntryPoint extends EntryPoint, TChain extends Chain | undefined, TTransport extends Transport = Transport, + TClientAccount extends Account | undefined = Account | undefined, TChainOverride extends Chain | undefined = Chain | undefined >( client: Client< TTransport, TChain, - undefined, + TClientAccount, Eip7677RpcSchema >, { diff --git a/packages/permissionless/experimental/eip7677/clients/decorators/paymasterActionsEip7677.ts b/packages/permissionless/experimental/eip7677/clients/decorators/paymasterActionsEip7677.ts index 452d0658..9ee6b955 100644 --- a/packages/permissionless/experimental/eip7677/clients/decorators/paymasterActionsEip7677.ts +++ b/packages/permissionless/experimental/eip7677/clients/decorators/paymasterActionsEip7677.ts @@ -1,4 +1,4 @@ -import type { Chain, Client, Transport } from "viem" +import type { Account, Chain, Client, Transport } from "viem" import type { EntryPoint } from "../../../../types/entrypoint" import { type GetPaymasterDataParameters, @@ -38,7 +38,8 @@ const paymasterActionsEip7677 = (entryPoint: TEntryPoint) => < TTransport extends Transport, - TChain extends Chain | undefined = Chain | undefined + TChain extends Chain | undefined = Chain | undefined, + TClientAccount extends Account | undefined = Account | undefined >( client: Client ): PaymasterActionsEip7677 => ({ @@ -47,7 +48,7 @@ const paymasterActionsEip7677 = client as Client< TTransport, TChain, - undefined, + TClientAccount, Eip7677RpcSchema >, { @@ -62,7 +63,7 @@ const paymasterActionsEip7677 = client as Client< TTransport, TChain, - undefined, + TClientAccount, Eip7677RpcSchema >, { diff --git a/packages/permissionless/types/index.ts b/packages/permissionless/types/index.ts index 05462f29..6ce78630 100644 --- a/packages/permissionless/types/index.ts +++ b/packages/permissionless/types/index.ts @@ -25,14 +25,14 @@ export type GetAccountParameterWithClient< export type GetAccountParameter< entryPoint extends EntryPoint, - TTransport extends Transport, - TChain extends Chain | undefined, - TAccount extends - | SmartAccount - | undefined + TAccount extends SmartAccount | undefined > = IsUndefined extends true - ? { account: SmartAccount } - : { account?: SmartAccount } + ? { + account: SmartAccount + } + : { + account?: SmartAccount + } export type Prettify = { [K in keyof T]: T[K] From e137fbee1d16c07a17eb8907b011f4bc904e310e Mon Sep 17 00:00:00 2001 From: Garvit Khatri Date: Mon, 12 Aug 2024 13:12:38 +0100 Subject: [PATCH 2/3] Default public account to undefined --- .../accounts/biconomy/privateKeyToBiconomySmartAccount.ts | 2 +- .../accounts/biconomy/signerToBiconomySmartAccount.ts | 2 +- .../accounts/kernel/signerToEcdsaKernelSmartAccount.ts | 4 ++-- .../accounts/light/privateKeyToLightSmartAccount.ts | 2 +- .../accounts/light/signerToLightSmartAccount.ts | 4 ++-- .../accounts/safe/privateKeyToSafeSmartAccount.ts | 2 +- .../permissionless/accounts/safe/signerToSafeSmartAccount.ts | 4 ++-- .../accounts/simple/privateKeyToSimpleSmartAccount.ts | 2 +- .../accounts/simple/signerToSimpleSmartAccount.ts | 4 ++-- .../accounts/trust/privateKeyToTrustSmartAccount.ts | 2 +- .../accounts/trust/signerToTrustSmartAccount.ts | 2 +- .../permissionless/accounts/trust/utils/getAccountAddress.ts | 2 +- packages/permissionless/accounts/trust/utils/signMessage.ts | 2 +- .../permissionless/accounts/trust/utils/signUserOperation.ts | 2 +- packages/permissionless/clients/createBundlerClient.ts | 2 +- .../experimental/eip7677/actions/getPaymasterData.ts | 2 +- .../experimental/eip7677/actions/getPaymasterStubData.ts | 2 +- .../eip7677/clients/decorators/paymasterActionsEip7677.ts | 2 +- 18 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/permissionless/accounts/biconomy/privateKeyToBiconomySmartAccount.ts b/packages/permissionless/accounts/biconomy/privateKeyToBiconomySmartAccount.ts index a7b4665c..3aec0f37 100644 --- a/packages/permissionless/accounts/biconomy/privateKeyToBiconomySmartAccount.ts +++ b/packages/permissionless/accounts/biconomy/privateKeyToBiconomySmartAccount.ts @@ -24,7 +24,7 @@ export async function privateKeyToBiconomySmartAccount< entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >( client: Client, { diff --git a/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts b/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts index fe53e130..329d5e3b 100644 --- a/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts +++ b/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts @@ -212,7 +212,7 @@ export async function signerToBiconomySmartAccount< entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined, + TClientAccount extends Account | undefined = undefined, TSource extends string = string, TAddress extends Address = Address >( diff --git a/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts b/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts index ac0e5d1b..a16c1203 100644 --- a/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +++ b/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts @@ -317,7 +317,7 @@ const getAccountAddress = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >({ client, entryPoint: entryPointAddress, @@ -374,7 +374,7 @@ export async function signerToEcdsaKernelSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined, + TClientAccount extends Account | undefined = undefined, TSource extends string = string, TAddress extends Address = Address >( diff --git a/packages/permissionless/accounts/light/privateKeyToLightSmartAccount.ts b/packages/permissionless/accounts/light/privateKeyToLightSmartAccount.ts index b5a5556d..c243054e 100644 --- a/packages/permissionless/accounts/light/privateKeyToLightSmartAccount.ts +++ b/packages/permissionless/accounts/light/privateKeyToLightSmartAccount.ts @@ -25,7 +25,7 @@ export async function privateKeyToLightSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >( client: Client, { privateKey, ...rest }: PrivateKeyToLightSmartAccountParameters diff --git a/packages/permissionless/accounts/light/signerToLightSmartAccount.ts b/packages/permissionless/accounts/light/signerToLightSmartAccount.ts index 7f369f77..d3a43aea 100644 --- a/packages/permissionless/accounts/light/signerToLightSmartAccount.ts +++ b/packages/permissionless/accounts/light/signerToLightSmartAccount.ts @@ -80,7 +80,7 @@ const getAccountAddress = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >({ client, factoryAddress, @@ -191,7 +191,7 @@ export async function signerToLightSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined, + TClientAccount extends Account | undefined = undefined, TSource extends string = string, TAddress extends Address = Address >( diff --git a/packages/permissionless/accounts/safe/privateKeyToSafeSmartAccount.ts b/packages/permissionless/accounts/safe/privateKeyToSafeSmartAccount.ts index e96946d6..a16bdfa6 100644 --- a/packages/permissionless/accounts/safe/privateKeyToSafeSmartAccount.ts +++ b/packages/permissionless/accounts/safe/privateKeyToSafeSmartAccount.ts @@ -24,7 +24,7 @@ export async function privateKeyToSafeSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >( client: Client, { privateKey, ...rest }: PrivateKeyToSafeSmartAccountParameters diff --git a/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts b/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts index a404e350..f21062ad 100644 --- a/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts +++ b/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts @@ -864,7 +864,7 @@ const getAccountInitCode = async ({ const getAccountAddress = async < TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >({ client, owner, @@ -1087,7 +1087,7 @@ export async function signerToSafeSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined, + TClientAccount extends Account | undefined = undefined, TSource extends string = string, TAddress extends Address = Address, TErc7579 extends Address | undefined = undefined diff --git a/packages/permissionless/accounts/simple/privateKeyToSimpleSmartAccount.ts b/packages/permissionless/accounts/simple/privateKeyToSimpleSmartAccount.ts index 135f827d..43e9ec1f 100644 --- a/packages/permissionless/accounts/simple/privateKeyToSimpleSmartAccount.ts +++ b/packages/permissionless/accounts/simple/privateKeyToSimpleSmartAccount.ts @@ -24,7 +24,7 @@ export async function privateKeyToSimpleSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >( client: Client, { diff --git a/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts b/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts index 16dd0ea2..8e448b2c 100644 --- a/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts +++ b/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts @@ -76,7 +76,7 @@ const getAccountAddress = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >({ client, factoryAddress, @@ -142,7 +142,7 @@ export async function signerToSimpleSmartAccount< entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined, + TClientAccount extends Account | undefined = undefined, TSource extends string = string, TAddress extends Address = Address >( diff --git a/packages/permissionless/accounts/trust/privateKeyToTrustSmartAccount.ts b/packages/permissionless/accounts/trust/privateKeyToTrustSmartAccount.ts index 45f33611..13ddc59c 100644 --- a/packages/permissionless/accounts/trust/privateKeyToTrustSmartAccount.ts +++ b/packages/permissionless/accounts/trust/privateKeyToTrustSmartAccount.ts @@ -24,7 +24,7 @@ export async function privateKeyToTrustSmartAccount< entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >( client: Client, { privateKey, ...rest }: PrivateKeyToTrustSmartAccountParameters diff --git a/packages/permissionless/accounts/trust/signerToTrustSmartAccount.ts b/packages/permissionless/accounts/trust/signerToTrustSmartAccount.ts index 5384ac25..4869b6a3 100644 --- a/packages/permissionless/accounts/trust/signerToTrustSmartAccount.ts +++ b/packages/permissionless/accounts/trust/signerToTrustSmartAccount.ts @@ -99,7 +99,7 @@ export async function signerToTrustSmartAccount< entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined, + TClientAccount extends Account | undefined = undefined, TSource extends string = string, TAddress extends Address = Address >( diff --git a/packages/permissionless/accounts/trust/utils/getAccountAddress.ts b/packages/permissionless/accounts/trust/utils/getAccountAddress.ts index ffb65dff..dcf054ae 100644 --- a/packages/permissionless/accounts/trust/utils/getAccountAddress.ts +++ b/packages/permissionless/accounts/trust/utils/getAccountAddress.ts @@ -14,7 +14,7 @@ export const getAccountAddress = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >( client: Client, { diff --git a/packages/permissionless/accounts/trust/utils/signMessage.ts b/packages/permissionless/accounts/trust/utils/signMessage.ts index 75099d24..57596437 100644 --- a/packages/permissionless/accounts/trust/utils/signMessage.ts +++ b/packages/permissionless/accounts/trust/utils/signMessage.ts @@ -5,7 +5,7 @@ import { signMessage as viem_signMessage } from "viem/actions" export const signMessage = < TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >( client: Client, { account, message }: SignMessageParameters diff --git a/packages/permissionless/accounts/trust/utils/signUserOperation.ts b/packages/permissionless/accounts/trust/utils/signUserOperation.ts index b5e01d89..22b5f32b 100644 --- a/packages/permissionless/accounts/trust/utils/signUserOperation.ts +++ b/packages/permissionless/accounts/trust/utils/signUserOperation.ts @@ -11,7 +11,7 @@ export const signUserOperation = async < entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >( client: Client, { diff --git a/packages/permissionless/clients/createBundlerClient.ts b/packages/permissionless/clients/createBundlerClient.ts index 7e295133..28fe4d48 100644 --- a/packages/permissionless/clients/createBundlerClient.ts +++ b/packages/permissionless/clients/createBundlerClient.ts @@ -13,7 +13,7 @@ import { type BundlerActions, bundlerActions } from "./decorators/bundler" export type BundlerClient< entryPoint extends EntryPoint, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined > = Client< Transport, TChain, diff --git a/packages/permissionless/experimental/eip7677/actions/getPaymasterData.ts b/packages/permissionless/experimental/eip7677/actions/getPaymasterData.ts index 9482f8e2..a1fadf4e 100644 --- a/packages/permissionless/experimental/eip7677/actions/getPaymasterData.ts +++ b/packages/permissionless/experimental/eip7677/actions/getPaymasterData.ts @@ -82,7 +82,7 @@ export type GetPaymasterDataReturnType = export async function getPaymasterData< TEntryPoint extends EntryPoint, TChain extends Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined, + TClientAccount extends Account | undefined = undefined, TTransport extends Transport = Transport, TChainOverride extends Chain | undefined = Chain | undefined >( diff --git a/packages/permissionless/experimental/eip7677/actions/getPaymasterStubData.ts b/packages/permissionless/experimental/eip7677/actions/getPaymasterStubData.ts index da062abc..19108e2b 100644 --- a/packages/permissionless/experimental/eip7677/actions/getPaymasterStubData.ts +++ b/packages/permissionless/experimental/eip7677/actions/getPaymasterStubData.ts @@ -89,7 +89,7 @@ export async function getPaymasterStubData< TEntryPoint extends EntryPoint, TChain extends Chain | undefined, TTransport extends Transport = Transport, - TClientAccount extends Account | undefined = Account | undefined, + TClientAccount extends Account | undefined = undefined, TChainOverride extends Chain | undefined = Chain | undefined >( client: Client< diff --git a/packages/permissionless/experimental/eip7677/clients/decorators/paymasterActionsEip7677.ts b/packages/permissionless/experimental/eip7677/clients/decorators/paymasterActionsEip7677.ts index 9ee6b955..bffdb614 100644 --- a/packages/permissionless/experimental/eip7677/clients/decorators/paymasterActionsEip7677.ts +++ b/packages/permissionless/experimental/eip7677/clients/decorators/paymasterActionsEip7677.ts @@ -39,7 +39,7 @@ const paymasterActionsEip7677 = < TTransport extends Transport, TChain extends Chain | undefined = Chain | undefined, - TClientAccount extends Account | undefined = Account | undefined + TClientAccount extends Account | undefined = undefined >( client: Client ): PaymasterActionsEip7677 => ({ From b5f998abd9ab2c0e9bf80876252a4cc5eaad7e3e Mon Sep 17 00:00:00 2001 From: Garvit Khatri Date: Mon, 12 Aug 2024 13:15:52 +0100 Subject: [PATCH 3/3] Fix build --- .../accounts/kernel/signerToEcdsaKernelSmartAccount.ts | 2 +- .../permissionless/accounts/light/signerToLightSmartAccount.ts | 2 +- .../permissionless/accounts/safe/signerToSafeSmartAccount.ts | 2 +- .../accounts/simple/signerToSimpleSmartAccount.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts b/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts index a16c1203..d1714f6c 100644 --- a/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +++ b/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts @@ -431,7 +431,7 @@ export async function signerToEcdsaKernelSmartAccount< // Fetch account address and chain id const [accountAddress, chainId] = await Promise.all([ address ?? - getAccountAddress({ + getAccountAddress({ client, factory: entryPointVersion === "v0.6" diff --git a/packages/permissionless/accounts/light/signerToLightSmartAccount.ts b/packages/permissionless/accounts/light/signerToLightSmartAccount.ts index d3a43aea..65a65f08 100644 --- a/packages/permissionless/accounts/light/signerToLightSmartAccount.ts +++ b/packages/permissionless/accounts/light/signerToLightSmartAccount.ts @@ -225,7 +225,7 @@ export async function signerToLightSmartAccount< const [accountAddress, chainId] = await Promise.all([ address ?? - getAccountAddress({ + getAccountAddress({ client, factoryAddress, entryPoint: entryPointAddress, diff --git a/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts b/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts index f21062ad..419b022e 100644 --- a/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts +++ b/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts @@ -1175,7 +1175,7 @@ export async function signerToSafeSmartAccount< const accountAddress = address ?? - (await getAccountAddress({ + (await getAccountAddress({ client, owner: viemSigner.address, safeModuleSetupAddress, diff --git a/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts b/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts index 8e448b2c..0a9a8333 100644 --- a/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts +++ b/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts @@ -167,7 +167,7 @@ export async function signerToSimpleSmartAccount< const [accountAddress, chainId] = await Promise.all([ address ?? - getAccountAddress({ + getAccountAddress({ client, factoryAddress, entryPoint: entryPointAddress,