diff --git a/package-lock.json b/package-lock.json index 2ae94ab38..ef2c40711 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27453,6 +27453,7 @@ "devDependencies": { "@svgr/webpack": "^8.1.0", "@toruslabs/isomorphic-style-loader": "^5.3.3", + "@web3auth/account-abstraction-provider": "^9.2.1", "@web3auth/auth": "^9.4.1", "@web3auth/wallet-connect-v2-adapter": "^9.2.1", "css-loader": "^7.1.2", @@ -27485,6 +27486,7 @@ "deepmerge": "^4.3.1" }, "devDependencies": { + "@web3auth/account-abstraction-provider": "^9.2.1", "@web3auth/auth-adapter": "^9.2.1", "@web3auth/wallet-connect-v2-adapter": "^9.2.1" }, diff --git a/packages/base/src/provider/IProvider.ts b/packages/base/src/provider/IProvider.ts index d55d3e5a7..da2015082 100644 --- a/packages/base/src/provider/IProvider.ts +++ b/packages/base/src/provider/IProvider.ts @@ -11,3 +11,7 @@ export const PROVIDER_EVENTS = { INITIALIZED: "initialized", ERRORED: "errored", }; + +export interface IBaseSmartAccount { + name: string; +} diff --git a/packages/base/src/utils.ts b/packages/base/src/utils.ts index 9b50571ec..a13ce3d75 100644 --- a/packages/base/src/utils.ts +++ b/packages/base/src/utils.ts @@ -89,11 +89,16 @@ export const signerHost = (web3AuthNetwork?: WEB3AUTH_NETWORK_TYPE): string => { return SIGNER_MAP[web3AuthNetwork ?? WEB3AUTH_NETWORK.SAPPHIRE_MAINNET]; }; -export const fetchProjectConfig = async (clientId: string, web3AuthNetwork: WEB3AUTH_NETWORK_TYPE): Promise => { +export const fetchProjectConfig = async ( + clientId: string, + web3AuthNetwork: WEB3AUTH_NETWORK_TYPE, + aaProvider?: string +): Promise => { const url = new URL(`${signerHost(web3AuthNetwork)}/api/configuration`); url.searchParams.append("project_id", clientId); url.searchParams.append("network", web3AuthNetwork); url.searchParams.append("whitelist", "true"); + if (aaProvider) url.searchParams.append("aa_provider", aaProvider); const res = await get(url.href); return res; }; diff --git a/packages/modal/package.json b/packages/modal/package.json index f4c5603ff..67dde7278 100644 --- a/packages/modal/package.json +++ b/packages/modal/package.json @@ -14,6 +14,7 @@ "devDependencies": { "@svgr/webpack": "^8.1.0", "@toruslabs/isomorphic-style-loader": "^5.3.3", + "@web3auth/account-abstraction-provider": "^9.2.1", "@web3auth/auth": "^9.4.1", "@web3auth/wallet-connect-v2-adapter": "^9.2.1", "css-loader": "^7.1.2", diff --git a/packages/modal/src/modalManager.ts b/packages/modal/src/modalManager.ts index 82bcc35d2..d35dd9d04 100644 --- a/packages/modal/src/modalManager.ts +++ b/packages/modal/src/modalManager.ts @@ -1,3 +1,4 @@ +import type { AccountAbstractionProvider } from "@web3auth/account-abstraction-provider"; import { AuthAdapter, AuthOptions, getAuthDefaultOptions, LOGIN_PROVIDER, LoginConfig } from "@web3auth/auth-adapter"; import { ADAPTER_CATEGORY, @@ -75,7 +76,11 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { let projectConfig: PROJECT_CONFIG_RESPONSE; try { - projectConfig = await fetchProjectConfig(this.options.clientId, this.options.web3AuthNetwork); + projectConfig = await fetchProjectConfig( + this.options.clientId, + this.options.web3AuthNetwork, + (this.options.accountAbstractionProvider as AccountAbstractionProvider)?.config.smartAccountInit.name + ); } catch (e) { log.error("Failed to fetch project configurations", e); throw WalletInitializationError.notReady("failed to fetch project configurations", e); diff --git a/packages/no-modal/package.json b/packages/no-modal/package.json index c2ff9f448..58ff53598 100644 --- a/packages/no-modal/package.json +++ b/packages/no-modal/package.json @@ -43,6 +43,7 @@ "deepmerge": "^4.3.1" }, "devDependencies": { + "@web3auth/account-abstraction-provider": "^9.2.1", "@web3auth/auth-adapter": "^9.2.1", "@web3auth/wallet-connect-v2-adapter": "^9.2.1" }, diff --git a/packages/no-modal/src/noModal.ts b/packages/no-modal/src/noModal.ts index e82bbe9aa..2790e0cca 100644 --- a/packages/no-modal/src/noModal.ts +++ b/packages/no-modal/src/noModal.ts @@ -1,3 +1,4 @@ +import type { AccountAbstractionProvider } from "@web3auth/account-abstraction-provider"; import { SafeEventEmitter, type SafeEventEmitterProvider } from "@web3auth/auth"; import { type AuthAdapter, LOGIN_PROVIDER, type LoginConfig } from "@web3auth/auth-adapter"; import { @@ -97,7 +98,11 @@ export class Web3AuthNoModal extends SafeEventEmitter imp let projectConfig: PROJECT_CONFIG_RESPONSE; try { - projectConfig = await fetchProjectConfig(this.coreOptions.clientId, this.coreOptions.web3AuthNetwork); + projectConfig = await fetchProjectConfig( + this.coreOptions.clientId, + this.coreOptions.web3AuthNetwork, + (this.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config.smartAccountInit.name + ); } catch (e) { log.error("Failed to fetch project configurations", e); throw WalletInitializationError.notReady("failed to fetch project configurations", e); diff --git a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/BiconomySmartAccount.ts b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/BiconomySmartAccount.ts index 274c03aa3..7a944e799 100644 --- a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/BiconomySmartAccount.ts +++ b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/BiconomySmartAccount.ts @@ -3,11 +3,14 @@ import { toBiconomySmartAccount, ToBiconomySmartAccountParameters } from "permis import { Client, EIP1193Provider } from "viem"; import { entryPoint06Address, SmartAccount } from "viem/account-abstraction"; +import { SMART_ACCOUNT } from "./constants"; import { ISmartAccount } from "./types"; type BiconomySmartAccountConfig = Pick; export class BiconomySmartAccount implements ISmartAccount { + readonly name: string = SMART_ACCOUNT.BICONOMY; + private options: BiconomySmartAccountConfig; constructor(options?: BiconomySmartAccountConfig) { diff --git a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/KernelSmartAccount.ts b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/KernelSmartAccount.ts index 79a20b720..d91c82bd3 100644 --- a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/KernelSmartAccount.ts +++ b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/KernelSmartAccount.ts @@ -3,6 +3,7 @@ import { toEcdsaKernelSmartAccount } from "permissionless/accounts"; import { Client, EIP1193Provider } from "viem"; import { SmartAccount } from "viem/account-abstraction"; +import { SMART_ACCOUNT } from "./constants"; import { ISmartAccount } from "./types"; type KernelSmartAccountParameters = Parameters[0]; // use type of function so we don't need to pass in generic to parameter type @@ -10,6 +11,8 @@ type KernelSmartAccountParameters = Parameters type KernelSmartAccountConfig = Omit; export class KernelSmartAccount implements ISmartAccount { + readonly name: string = SMART_ACCOUNT.KERNEL; + private options: KernelSmartAccountConfig; constructor(options?: KernelSmartAccountConfig) { diff --git a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/LightSmartAccount.ts b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/LightSmartAccount.ts index 924f8a09e..87a1c6c2d 100644 --- a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/LightSmartAccount.ts +++ b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/LightSmartAccount.ts @@ -3,11 +3,14 @@ import { toLightSmartAccount, ToLightSmartAccountParameters } from "permissionle import { Client, EIP1193Provider } from "viem"; import { entryPoint07Address, SmartAccount } from "viem/account-abstraction"; +import { SMART_ACCOUNT } from "./constants"; import { ISmartAccount } from "./types"; type LightSmartAccountConfig = Omit; export class LightSmartAccount implements ISmartAccount { + readonly name: string = SMART_ACCOUNT.LIGHT; + private options: LightSmartAccountConfig; constructor(options?: LightSmartAccountConfig) { diff --git a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/SafeSmartAccount.ts b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/SafeSmartAccount.ts index 9befdd270..91891e21d 100644 --- a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/SafeSmartAccount.ts +++ b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/SafeSmartAccount.ts @@ -3,6 +3,7 @@ import { toSafeSmartAccount } from "permissionless/accounts"; import { Client, EIP1193Provider } from "viem"; import { entryPoint07Address, SmartAccount } from "viem/account-abstraction"; +import { SMART_ACCOUNT } from "./constants"; import { ISmartAccount } from "./types"; type SafeSmartAccountParameters = Parameters[0]; // use type of function so we don't need to pass in generic to parameter type @@ -13,6 +14,8 @@ type SafeSmartAccountConfig = Omit< >; export class SafeSmartAccount implements ISmartAccount { + readonly name: string = SMART_ACCOUNT.SAFE; + private options: SafeSmartAccountConfig; constructor(options?: SafeSmartAccountConfig) { diff --git a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/SimpleSmartAccount.ts b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/SimpleSmartAccount.ts index 135056d28..18ca1d7c6 100644 --- a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/SimpleSmartAccount.ts +++ b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/SimpleSmartAccount.ts @@ -3,6 +3,7 @@ import { toSimpleSmartAccount } from "permissionless/accounts"; import { Client, EIP1193Provider } from "viem"; import { entryPoint07Address, SmartAccount } from "viem/account-abstraction"; +import { SMART_ACCOUNT } from "./constants"; import { ISmartAccount } from "./types"; type SimpleSmartAccountParameters = Parameters[0]; // use type of function so we don't need to pass in generic to parameter type @@ -10,6 +11,8 @@ type SimpleSmartAccountParameters = Parameters[0]; type SimpleSmartAccountConfig = Omit; export class SimpleSmartAccount implements ISmartAccount { + readonly name: string = SMART_ACCOUNT.SIMPLE; + private options: SimpleSmartAccountConfig; constructor(options?: SimpleSmartAccountConfig) { diff --git a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/TrustSmartAccount.ts b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/TrustSmartAccount.ts index bd2064497..efe6548b9 100644 --- a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/TrustSmartAccount.ts +++ b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/TrustSmartAccount.ts @@ -3,6 +3,7 @@ import { toTrustSmartAccount } from "permissionless/accounts"; import { Client, EIP1193Provider } from "viem"; import { entryPoint06Address, SmartAccount } from "viem/account-abstraction"; +import { SMART_ACCOUNT } from "./constants"; import { ISmartAccount } from "./types"; type TrustSmartAccountParameters = Parameters[0]; // use type of function so we don't need to pass in generic to parameter type @@ -10,6 +11,8 @@ type TrustSmartAccountParameters = Parameters[0]; // type TrustSmartAccountConfig = Omit; export class TrustSmartAccount implements ISmartAccount { + readonly name: string = SMART_ACCOUNT.TRUST; + private options: TrustSmartAccountConfig; constructor(options?: TrustSmartAccountConfig) { diff --git a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/constants.ts b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/constants.ts new file mode 100644 index 000000000..fa9f1b767 --- /dev/null +++ b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/constants.ts @@ -0,0 +1,8 @@ +export const SMART_ACCOUNT = { + BICONOMY: "biconomy", + KERNEL: "kernel", + LIGHT: "light", + SAFE: "safe", + SIMPLE: "simple", + TRUST: "trust", +}; diff --git a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/types.ts b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/types.ts index 4c1d8632b..1346d6928 100644 --- a/packages/providers/account-abstraction-provider/src/providers/smartAccounts/types.ts +++ b/packages/providers/account-abstraction-provider/src/providers/smartAccounts/types.ts @@ -1,7 +1,7 @@ -import { IProvider } from "@web3auth/base"; +import { IBaseSmartAccount, IProvider } from "@web3auth/base"; import { Client } from "viem"; import { SmartAccount } from "viem/account-abstraction"; -export interface ISmartAccount { +export interface ISmartAccount extends IBaseSmartAccount { getSmartAccount(params: { owner: IProvider; client: Client }): Promise; }