Skip to content

Commit 76d3837

Browse files
Merge pull request #2053 from Web3Auth/feat/pass-smart-account-config
Feat/pass smart account config
2 parents 25b7451 + 443b812 commit 76d3837

File tree

10 files changed

+62
-43
lines changed

10 files changed

+62
-43
lines changed

packages/plugins/wallet-services-plugin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
"dist"
3232
],
3333
"devDependencies": {
34-
"@toruslabs/ethereum-controllers": "^7.0.1"
34+
"@toruslabs/ethereum-controllers": "^7.1.3"
3535
},
3636
"dependencies": {
3737
"@web3auth/account-abstraction-provider": "^9.5.2",
3838
"@web3auth/auth": "^9.6.2",
3939
"@web3auth/base": "^9.5.2",
4040
"@web3auth/no-modal": "^9.5.2",
41-
"@web3auth/ws-embed": "^3.4.0",
41+
"@web3auth/ws-embed": "^3.4.4",
4242
"loglevel": "^1.9.2"
4343
},
4444
"peerDependencies": {

packages/plugins/wallet-services-plugin/src/plugin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type BaseEmbedControllerState } from "@toruslabs/base-controllers";
2-
import type { EthereumProviderConfig } from "@toruslabs/ethereum-controllers";
2+
import type { AccountAbstractionConfig, EthereumProviderConfig } from "@toruslabs/ethereum-controllers";
33
import { AccountAbstractionProvider } from "@web3auth/account-abstraction-provider";
44
import { SafeEventEmitter, type WhiteLabelData } from "@web3auth/auth";
55
import {
@@ -21,7 +21,7 @@ import {
2121
WALLET_ADAPTERS,
2222
WalletServicesPluginError,
2323
} from "@web3auth/base";
24-
import WsEmbed, { AccountAbstractionConfig, CtorArgs, WsEmbedParams } from "@web3auth/ws-embed";
24+
import WsEmbed, { CtorArgs, WsEmbedParams } from "@web3auth/ws-embed";
2525

2626
type WsPluginEmbedParams = Omit<WsEmbedParams, "buildEnv" | "enableLogging" | "chainConfig" | "confirmationStrategy"> & {
2727
/**
@@ -111,13 +111,15 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin {
111111
const smartAccountType = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config.smartAccountInit.name;
112112
const paymasterConfig = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config?.paymasterConfig;
113113
const bundlerConfig = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config?.bundlerConfig;
114+
const smartAccountConfig = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config.smartAccountInit.options;
114115

115116
// TODO: fix this type casting when we start using accountAbstractionController
116117
accountAbstractionConfig = {
117118
smartAccountAddress: smartAccountAddress || undefined,
118119
smartAccountType: smartAccountType || undefined,
119120
paymasterConfig: paymasterConfig || undefined,
120121
bundlerConfig: bundlerConfig || undefined,
122+
smartAccountConfig: smartAccountConfig || undefined,
121123
} as AccountAbstractionConfig;
122124
} else if (this.walletInitOptions?.accountAbstractionConfig && Object.keys(this.walletInitOptions.accountAbstractionConfig).length > 0) {
123125
// if wallet services plugin is initialized with accountAbstractionConfig we enable wallet service AA without AA provider

packages/providers/account-abstraction-provider/src/providers/smartAccounts/BiconomySmartAccount.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ import { Client, EIP1193Provider } from "viem";
44
import { entryPoint06Address, SmartAccount } from "viem/account-abstraction";
55

66
import { SMART_ACCOUNT } from "./constants";
7-
import { ISmartAccount } from "./types";
8-
9-
type BiconomySmartAccountConfig = Pick<ToBiconomySmartAccountParameters, "entryPoint" | "ecdsaModuleAddress" | "factoryAddress">;
7+
import { BiconomySmartAccountConfig, ISmartAccount } from "./types";
108

119
export class BiconomySmartAccount implements ISmartAccount {
1210
readonly name: string = SMART_ACCOUNT.BICONOMY;
1311

14-
private options: BiconomySmartAccountConfig;
12+
public options: BiconomySmartAccountConfig;
1513

1614
constructor(options?: BiconomySmartAccountConfig) {
1715
this.options = options;

packages/providers/account-abstraction-provider/src/providers/smartAccounts/KernelSmartAccount.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import { Client, EIP1193Provider } from "viem";
44
import { SmartAccount } from "viem/account-abstraction";
55

66
import { SMART_ACCOUNT } from "./constants";
7-
import { ISmartAccount } from "./types";
8-
9-
type KernelSmartAccountParameters = Parameters<typeof toEcdsaKernelSmartAccount>[0]; // use type of function so we don't need to pass in generic to parameter type
10-
11-
type KernelSmartAccountConfig = Omit<KernelSmartAccountParameters, "owners" | "client" | "address" | "nonceKey" | "index">;
7+
import { ISmartAccount, KernelSmartAccountConfig, KernelSmartAccountParameters } from "./types";
128

139
export class KernelSmartAccount implements ISmartAccount {
1410
readonly name: string = SMART_ACCOUNT.KERNEL;
1511

16-
private options: KernelSmartAccountConfig;
12+
public options: KernelSmartAccountConfig;
1713

1814
constructor(options?: KernelSmartAccountConfig) {
1915
this.options = options;

packages/providers/account-abstraction-provider/src/providers/smartAccounts/LightSmartAccount.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ import { Client, EIP1193Provider } from "viem";
44
import { entryPoint07Address, SmartAccount } from "viem/account-abstraction";
55

66
import { SMART_ACCOUNT } from "./constants";
7-
import { ISmartAccount } from "./types";
8-
9-
type LightSmartAccountConfig = Omit<ToLightSmartAccountParameters, "owner" | "client" | "index" | "address" | "nonceKey">;
7+
import { ISmartAccount, LightSmartAccountConfig } from "./types";
108

119
export class LightSmartAccount implements ISmartAccount {
1210
readonly name: string = SMART_ACCOUNT.LIGHT;
1311

14-
private options: LightSmartAccountConfig;
12+
public options: LightSmartAccountConfig;
1513

1614
constructor(options?: LightSmartAccountConfig) {
1715
this.options = options;

packages/providers/account-abstraction-provider/src/providers/smartAccounts/NexusSmartAccount.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ import { Client, EIP1193Provider } from "viem";
44
import { entryPoint07Address, SmartAccount } from "viem/account-abstraction";
55

66
import { SMART_ACCOUNT } from "./constants";
7-
import { ISmartAccount } from "./types";
8-
9-
type NexusSmartAccountConfig = Omit<ToNexusSmartAccountParameters, "owners" | "client" | "index" | "address">;
7+
import { ISmartAccount, NexusSmartAccountConfig } from "./types";
108

119
export class NexusSmartAccount implements ISmartAccount {
1210
readonly name: string = SMART_ACCOUNT.NEXUS;
1311

14-
private options: NexusSmartAccountConfig;
12+
public options: NexusSmartAccountConfig;
1513

1614
constructor(options?: NexusSmartAccountConfig) {
1715
this.options = options;

packages/providers/account-abstraction-provider/src/providers/smartAccounts/SafeSmartAccount.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@ import { Client, EIP1193Provider } from "viem";
44
import { entryPoint07Address, SmartAccount } from "viem/account-abstraction";
55

66
import { SMART_ACCOUNT } from "./constants";
7-
import { ISmartAccount } from "./types";
8-
9-
type SafeSmartAccountParameters = Parameters<typeof toSafeSmartAccount>[0]; // use type of function so we don't need to pass in generic to parameter type
10-
11-
type SafeSmartAccountConfig = Omit<
12-
SafeSmartAccountParameters,
13-
"owners" | "client" | "address" | "nonceKey" | "saltNonce" | "validUntil" | "validAfter"
14-
>;
7+
import { ISmartAccount, SafeSmartAccountConfig, SafeSmartAccountParameters } from "./types";
158

169
export class SafeSmartAccount implements ISmartAccount {
1710
readonly name: string = SMART_ACCOUNT.SAFE;
1811

19-
private options: SafeSmartAccountConfig;
12+
public options: SafeSmartAccountConfig;
2013

2114
constructor(options?: SafeSmartAccountConfig) {
2215
this.options = options;

packages/providers/account-abstraction-provider/src/providers/smartAccounts/SimpleSmartAccount.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import { Client, EIP1193Provider } from "viem";
44
import { entryPoint07Address, SmartAccount } from "viem/account-abstraction";
55

66
import { SMART_ACCOUNT } from "./constants";
7-
import { ISmartAccount } from "./types";
8-
9-
type SimpleSmartAccountParameters = Parameters<typeof toSimpleSmartAccount>[0]; // use type of function so we don't need to pass in generic to parameter type
10-
11-
type SimpleSmartAccountConfig = Omit<SimpleSmartAccountParameters, "owner" | "client">;
7+
import { ISmartAccount, SimpleSmartAccountConfig } from "./types";
128

139
export class SimpleSmartAccount implements ISmartAccount {
1410
readonly name: string = SMART_ACCOUNT.SIMPLE;
1511

16-
private options: SimpleSmartAccountConfig;
12+
public options: SimpleSmartAccountConfig;
1713

1814
constructor(options?: SimpleSmartAccountConfig) {
1915
this.options = options;

packages/providers/account-abstraction-provider/src/providers/smartAccounts/TrustSmartAccount.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import { Client, EIP1193Provider } from "viem";
44
import { entryPoint06Address, SmartAccount } from "viem/account-abstraction";
55

66
import { SMART_ACCOUNT } from "./constants";
7-
import { ISmartAccount } from "./types";
8-
9-
type TrustSmartAccountParameters = Parameters<typeof toTrustSmartAccount>[0]; // use type of function so we don't need to pass in generic to parameter type
10-
11-
type TrustSmartAccountConfig = Omit<TrustSmartAccountParameters, "owner" | "client" | "address" | "nonceKey" | "index">;
7+
import { ISmartAccount, TrustSmartAccountConfig, TrustSmartAccountParameters } from "./types";
128

139
export class TrustSmartAccount implements ISmartAccount {
1410
readonly name: string = SMART_ACCOUNT.TRUST;
1511

16-
private options: TrustSmartAccountConfig;
12+
public options: TrustSmartAccountConfig;
1713

1814
constructor(options?: TrustSmartAccountConfig) {
1915
this.options = options;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,49 @@
11
import { IBaseSmartAccount, IProvider } from "@web3auth/base";
2+
import {
3+
ToBiconomySmartAccountParameters,
4+
toEcdsaKernelSmartAccount,
5+
ToLightSmartAccountParameters,
6+
ToNexusSmartAccountParameters,
7+
toSafeSmartAccount,
8+
toSimpleSmartAccount,
9+
toTrustSmartAccount,
10+
} from "permissionless/accounts";
211
import { Client } from "viem";
312
import { SmartAccount } from "viem/account-abstraction";
413

14+
export type BiconomySmartAccountConfig = Pick<ToBiconomySmartAccountParameters, "entryPoint" | "ecdsaModuleAddress" | "factoryAddress">;
15+
16+
export type KernelSmartAccountParameters = Parameters<typeof toEcdsaKernelSmartAccount>[0]; // use type of function so we don't need to pass in generic to parameter type
17+
18+
export type KernelSmartAccountConfig = Omit<KernelSmartAccountParameters, "owners" | "client" | "address" | "nonceKey" | "index">;
19+
20+
export type LightSmartAccountConfig = Omit<ToLightSmartAccountParameters, "owner" | "client" | "index" | "address" | "nonceKey">;
21+
22+
export type NexusSmartAccountConfig = Omit<ToNexusSmartAccountParameters, "owners" | "client" | "index" | "address">;
23+
24+
export type SafeSmartAccountParameters = Parameters<typeof toSafeSmartAccount>[0]; // use type of function so we don't need to pass in generic to parameter type
25+
26+
export type SafeSmartAccountConfig = Omit<
27+
SafeSmartAccountParameters,
28+
"owners" | "client" | "address" | "nonceKey" | "saltNonce" | "validUntil" | "validAfter"
29+
>;
30+
31+
export type SimpleSmartAccountParameters = Parameters<typeof toSimpleSmartAccount>[0]; // use type of function so we don't need to pass in generic to parameter type
32+
33+
export type SimpleSmartAccountConfig = Omit<SimpleSmartAccountParameters, "owner" | "client">;
34+
35+
export type TrustSmartAccountParameters = Parameters<typeof toTrustSmartAccount>[0]; // use type of function so we don't need to pass in generic to parameter type
36+
37+
export type TrustSmartAccountConfig = Omit<TrustSmartAccountParameters, "owner" | "client" | "address" | "nonceKey" | "index">;
38+
539
export interface ISmartAccount extends IBaseSmartAccount {
40+
options:
41+
| BiconomySmartAccountConfig
42+
| KernelSmartAccountConfig
43+
| NexusSmartAccountConfig
44+
| SafeSmartAccountConfig
45+
| TrustSmartAccountConfig
46+
| LightSmartAccountConfig
47+
| SimpleSmartAccountConfig;
648
getSmartAccount(params: { owner: IProvider; client: Client }): Promise<SmartAccount>;
749
}

0 commit comments

Comments
 (0)