diff --git a/.changeset/happy-cats-clean.md b/.changeset/happy-cats-clean.md new file mode 100644 index 00000000..ed0eac0b --- /dev/null +++ b/.changeset/happy-cats-clean.md @@ -0,0 +1,5 @@ +--- +"permissionless": patch +--- + +Fixed ethereum provider by changing type of EIP1193Provider to EthereumProvider diff --git a/packages/permissionless/accounts/biconomy/toBiconomySmartAccount.ts b/packages/permissionless/accounts/biconomy/toBiconomySmartAccount.ts index a3596072..dcc25d85 100644 --- a/packages/permissionless/accounts/biconomy/toBiconomySmartAccount.ts +++ b/packages/permissionless/accounts/biconomy/toBiconomySmartAccount.ts @@ -2,7 +2,6 @@ import type { Account, Assign, Chain, - EIP1193Provider, OneOf, Prettify, Transport, @@ -31,7 +30,7 @@ import { } from "viem/account-abstraction" import { signMessage } from "viem/actions" import { getAccountNonce } from "../../actions/public/getAccountNonce" -import { toOwner } from "../../utils/toOwner" +import { type EthereumProvider, toOwner } from "../../utils/toOwner" import { BiconomyAbi, FactoryAbi } from "./abi/BiconomySmartAccountAbi" const BICONOMY_PROXY_CREATION_CODE = @@ -95,7 +94,7 @@ export type ToBiconomySmartAccountParameters = Prettify<{ client: Client owners: [ OneOf< - | EIP1193Provider + | EthereumProvider | WalletClient | LocalAccount > diff --git a/packages/permissionless/accounts/kernel/toEcdsaKernelSmartAccount.ts b/packages/permissionless/accounts/kernel/toEcdsaKernelSmartAccount.ts index 62077413..af1591e6 100644 --- a/packages/permissionless/accounts/kernel/toEcdsaKernelSmartAccount.ts +++ b/packages/permissionless/accounts/kernel/toEcdsaKernelSmartAccount.ts @@ -2,7 +2,6 @@ import type { Account, Assign, Chain, - EIP1193Provider, OneOf, Transport, WalletClient @@ -32,7 +31,7 @@ import { signMessage as _signMessage, getChainId } from "viem/actions" import { getAction } from "viem/utils" import { getAccountNonce } from "../../actions/public/getAccountNonce" import { getSenderAddress } from "../../actions/public/getSenderAddress" -import { toOwner } from "../../utils/toOwner" +import { type EthereumProvider, toOwner } from "../../utils/toOwner" import { KernelInitAbi } from "./abi/KernelAccountAbi" import { KernelV3InitAbi, KernelV3_1AccountAbi } from "./abi/KernelV3AccountAbi" import { KernelV3MetaFactoryDeployWithFactoryAbi } from "./abi/KernelV3MetaFactoryAbi" @@ -305,7 +304,7 @@ export type ToEcdsaKernelSmartAccountParameters< client: Client owners: [ OneOf< - | EIP1193Provider + | EthereumProvider | WalletClient | LocalAccount > diff --git a/packages/permissionless/accounts/light/toLightSmartAccount.ts b/packages/permissionless/accounts/light/toLightSmartAccount.ts index 629e1ec8..335dd4f5 100644 --- a/packages/permissionless/accounts/light/toLightSmartAccount.ts +++ b/packages/permissionless/accounts/light/toLightSmartAccount.ts @@ -4,7 +4,6 @@ import { type Assign, type Chain, type Client, - type EIP1193Provider, type Hex, type LocalAccount, type OneOf, @@ -29,7 +28,7 @@ import { getChainId, signMessage } from "viem/actions" import { getAction } from "viem/utils" import { getAccountNonce } from "../../actions/public/getAccountNonce" import { getSenderAddress } from "../../actions/public/getSenderAddress" -import { toOwner } from "../../utils/toOwner" +import { type EthereumProvider, toOwner } from "../../utils/toOwner" const getAccountInitCode = async ( owner: Address, @@ -81,7 +80,7 @@ export type ToLightSmartAccountParameters< version: entryPointVersion } owner: OneOf< - | EIP1193Provider + | EthereumProvider | WalletClient | LocalAccount > diff --git a/packages/permissionless/accounts/nexus/toNexusSmartAccount.ts b/packages/permissionless/accounts/nexus/toNexusSmartAccount.ts index c5ae3b0a..271f05bd 100644 --- a/packages/permissionless/accounts/nexus/toNexusSmartAccount.ts +++ b/packages/permissionless/accounts/nexus/toNexusSmartAccount.ts @@ -2,7 +2,6 @@ import type { Account, Assign, Chain, - EIP1193Provider, OneOf, Prettify, Transport, @@ -40,7 +39,7 @@ import { getChainId, readContract } from "viem/actions" import { getAction } from "viem/utils" import { getAccountNonce } from "../../actions/public/getAccountNonce" import { encode7579Calls } from "../../utils" -import { toOwner } from "../../utils/toOwner" +import { type EthereumProvider, toOwner } from "../../utils/toOwner" const wrapMessageHash = ( messageHash: Hex, @@ -93,7 +92,7 @@ export type ToNexusSmartAccountParameters = Prettify<{ client: Client owners: [ OneOf< - | EIP1193Provider + | EthereumProvider | WalletClient | LocalAccount > diff --git a/packages/permissionless/accounts/safe/toSafeSmartAccount.ts b/packages/permissionless/accounts/safe/toSafeSmartAccount.ts index 03690096..570a9194 100644 --- a/packages/permissionless/accounts/safe/toSafeSmartAccount.ts +++ b/packages/permissionless/accounts/safe/toSafeSmartAccount.ts @@ -4,7 +4,6 @@ import { type Assign, type Chain, type Client, - type EIP1193Provider, type Hex, type LocalAccount, type OneOf, @@ -42,6 +41,7 @@ import { getAction } from "viem/utils" import { getAccountNonce } from "../../actions/public/getAccountNonce" import { isSmartAccountDeployed, toOwner } from "../../utils" import { encode7579Calls } from "../../utils/encode7579Calls" +import type { EthereumProvider } from "../../utils/toOwner" export type SafeVersion = "1.4.1" @@ -940,7 +940,7 @@ export type ToSafeSmartAccountParameters< client: Client owners: [ OneOf< - | EIP1193Provider + | EthereumProvider | WalletClient | LocalAccount > diff --git a/packages/permissionless/accounts/simple/toSimpleSmartAccount.ts b/packages/permissionless/accounts/simple/toSimpleSmartAccount.ts index 8c72a388..4d77abe3 100644 --- a/packages/permissionless/accounts/simple/toSimpleSmartAccount.ts +++ b/packages/permissionless/accounts/simple/toSimpleSmartAccount.ts @@ -4,7 +4,6 @@ import { type Assign, type Chain, type Client, - type EIP1193Provider, type Hex, type LocalAccount, type OneOf, @@ -26,7 +25,7 @@ import { getChainId, signMessage } from "viem/actions" import { getAction } from "viem/utils" import { getAccountNonce } from "../../actions/public/getAccountNonce" import { getSenderAddress } from "../../actions/public/getSenderAddress" -import { toOwner } from "../../utils/toOwner" +import { type EthereumProvider, toOwner } from "../../utils/toOwner" const getAccountInitCode = async ( owner: Address, @@ -71,7 +70,7 @@ export type ToSimpleSmartAccountParameters< > = { client: Client owner: OneOf< - | EIP1193Provider + | EthereumProvider | WalletClient | LocalAccount > diff --git a/packages/permissionless/accounts/thirdweb/toThirdwebSmartAccount.ts b/packages/permissionless/accounts/thirdweb/toThirdwebSmartAccount.ts index 8b27544c..ce28e990 100644 --- a/packages/permissionless/accounts/thirdweb/toThirdwebSmartAccount.ts +++ b/packages/permissionless/accounts/thirdweb/toThirdwebSmartAccount.ts @@ -4,7 +4,6 @@ import type { Assign, Chain, Client, - EIP1193Provider, LocalAccount, OneOf, Transport, @@ -25,7 +24,7 @@ import { toSmartAccount } from "viem/account-abstraction" import { getAction, toHex } from "viem/utils" -import { toOwner } from "../../utils/toOwner" +import { type EthereumProvider, toOwner } from "../../utils/toOwner" import { encodeCallData } from "./utils/encodeCallData" import { getAccountAddress } from "./utils/getAccountAddress" import { getFactoryData } from "./utils/getFactoryData" @@ -49,7 +48,7 @@ export type ToThirdwebSmartAccountParameters< > = { client: Client owner: OneOf< - | EIP1193Provider + | EthereumProvider | WalletClient | LocalAccount > diff --git a/packages/permissionless/accounts/trust/toTrustSmartAccount.ts b/packages/permissionless/accounts/trust/toTrustSmartAccount.ts index 65c3f7e8..d2990e02 100644 --- a/packages/permissionless/accounts/trust/toTrustSmartAccount.ts +++ b/packages/permissionless/accounts/trust/toTrustSmartAccount.ts @@ -4,7 +4,6 @@ import { type Assign, type Chain, type Client, - type EIP1193Provider, type Hex, type LocalAccount, type OneOf, @@ -27,7 +26,7 @@ import { } from "viem/account-abstraction" import { getAction } from "viem/utils" import { getSenderAddress } from "../../actions/public/getSenderAddress" -import { toOwner } from "../../utils/toOwner" +import { type EthereumProvider, toOwner } from "../../utils/toOwner" import { encodeCallData } from "./utils/encodeCallData" import { getFactoryData } from "./utils/getFactoryData" @@ -69,7 +68,7 @@ export const TRUST_ADDRESSES: { export type ToTrustSmartAccountParameters = { client: Client owner: OneOf< - | EIP1193Provider + | EthereumProvider | WalletClient | LocalAccount > diff --git a/packages/permissionless/utils/toOwner.ts b/packages/permissionless/utils/toOwner.ts index 7cab8742..d87efbc7 100644 --- a/packages/permissionless/utils/toOwner.ts +++ b/packages/permissionless/utils/toOwner.ts @@ -2,9 +2,6 @@ import { type Account, type Address, type Chain, - type EIP1193Provider, - type EIP1193RequestFn, - type EIP1474Methods, type LocalAccount, type OneOf, type Transport, @@ -17,12 +14,14 @@ import { toAccount } from "viem/accounts" import { signTypedData } from "viem/actions" import { getAction } from "viem/utils" -export async function toOwner({ +export type EthereumProvider = { request(...args: any): Promise } + +export async function toOwner({ owner, address }: { owner: OneOf< - | EIP1193Provider + | provider | WalletClient | LocalAccount > @@ -39,15 +38,11 @@ export async function toOwner({ if ("request" in owner) { if (!address) { try { - ;[address] = await ( - owner.request as EIP1193RequestFn - )({ + ;[address] = await (owner as EthereumProvider).request({ method: "eth_requestAccounts" }) } catch { - ;[address] = await ( - owner.request as EIP1193RequestFn - )({ + ;[address] = await (owner as EthereumProvider).request({ method: "eth_accounts" }) } @@ -58,7 +53,7 @@ export async function toOwner({ } walletClient = createWalletClient({ account: address, - transport: custom(owner as EIP1193Provider) + transport: custom(owner as EthereumProvider) }) }