Skip to content

Commit 528c22f

Browse files
committed
Merge branch 'feat/sdk-v10-aa' into feat/sdk-v10
2 parents 13f5e74 + 4930d04 commit 528c22f

File tree

28 files changed

+193
-509
lines changed

28 files changed

+193
-509
lines changed

demo/vite-react-app/src/services/web3auth.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AccountAbstractionProvider, CONNECTOR_EVENTS, IProvider, PLUGIN_EVENTS, SafeSmartAccount, WalletServicesPlugin, Web3Auth, WEB3AUTH_NETWORK_TYPE } from "@web3auth/modal";
1+
import { CONNECTOR_EVENTS, IProvider, PLUGIN_EVENTS, WalletServicesPlugin, Web3Auth, WEB3AUTH_NETWORK_TYPE, SMART_ACCOUNT } from "@web3auth/modal";
22
import { createContext, FunctionComponent, ReactNode, useContext, useEffect, useState } from "react";
33
import { CHAIN_CONFIG, CHAIN_CONFIG_TYPE } from "../config/chainConfig";
44
import * as ethHandler from "./ethHandler";
@@ -113,26 +113,22 @@ export const Web3AuthProvider: FunctionComponent<IWeb3AuthState> = ({ children,
113113
async function init() {
114114
try {
115115
const currentChainConfig = CHAIN_CONFIG[chain];
116-
const accountAbstractionProvider = new AccountAbstractionProvider({
117-
config: {
118-
chainConfig: currentChainConfig,
119-
bundlerConfig: {
120-
url: `https://api.pimlico.io/v2/11155111/rpc?apikey=${pimlicoAPIKey}`,
121-
},
122-
smartAccountInit: new SafeSmartAccount(),
123-
paymasterConfig: {
124-
url: `https://api.pimlico.io/v2/11155111/rpc?apikey=${pimlicoAPIKey}`,
125-
},
126-
},
127-
});
128116
setIsLoading(true);
129117
const clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ";
130118

131119
const web3AuthInstance = new Web3Auth({
132120
// get your client id from https://dashboard.web3auth.io
133121
clientId,
134122
web3AuthNetwork,
135-
accountAbstractionProvider,
123+
accountAbstractionConfig: {
124+
smartAccountType: SMART_ACCOUNT.SAFE,
125+
bundlerConfig: {
126+
url: `https://api.pimlico.io/v2/11155111/rpc?apikey=${pimlicoAPIKey}`,
127+
},
128+
paymasterConfig: {
129+
url: `https://api.pimlico.io/v2/11155111/rpc?apikey=${pimlicoAPIKey}`,
130+
},
131+
},
136132
chains: [currentChainConfig],
137133
uiConfig: {
138134
uxMode: "redirect",

demo/vue-app-new/package-lock.json

Lines changed: 10 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/vue-app-new/src/MainView.vue

Lines changed: 9 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<script setup lang="ts">
22
3-
import { AccountAbstractionProvider, ConnectorFn, CHAIN_NAMESPACES, ChainNamespaceType, coinbaseConnector, IBaseProvider, IProvider, ISmartAccount, KernelSmartAccount, NexusSmartAccount, NFTCheckoutPlugin, SafeSmartAccount, storageAvailable, TrustSmartAccount, WALLET_CONNECTORS, walletConnectV2Connector, WalletServicesPlugin, type Web3AuthOptions } from "@web3auth/modal";
3+
import { CHAIN_NAMESPACES, ChainNamespaceType, coinbaseConnector, ConnectorFn, NFTCheckoutPlugin, storageAvailable, WALLET_CONNECTORS, walletConnectV2Connector, WalletServicesPlugin, type Web3AuthOptions } from "@web3auth/modal";
44
import { Web3AuthContextConfig, Web3AuthProvider } from "@web3auth/modal/vue";
55
import { WalletServicesProvider } from "@web3auth/no-modal/vue";
66
import { computed, onBeforeMount, ref, watch } from "vue";
77
8-
import { SMART_ACCOUNT } from "@toruslabs/ethereum-controllers";
98
import AppDashboard from "./components/AppDashboard.vue";
109
import AppHeader from "./components/AppHeader.vue";
1110
import AppSettings from "./components/AppSettings.vue";
@@ -25,103 +24,34 @@ const chainOptions = computed(() =>
2524
2625
const showAAProviderSettings = computed(() => formData.chainNamespace === CHAIN_NAMESPACES.EIP155);
2726
28-
const accountAbstractionProvider = computed((): IBaseProvider<IProvider> | undefined => {
29-
const { useAccountAbstractionProvider } = formData;
30-
if (!showAAProviderSettings.value || !useAccountAbstractionProvider) return undefined;
31-
32-
// only need to setup AA provider for external wallets, for embedded wallet, we'll use WS which already supports AA
33-
if (!formData.useAAWithExternalWallet) return undefined;
34-
35-
const chainConfig = chainConfigs[formData.chainNamespace as ChainNamespaceType].find((x) => x.chainId === formData.chain)!;
36-
// setup aa provider
37-
let smartAccountInit: ISmartAccount;
38-
switch (formData.smartAccountType) {
39-
case "nexus":
40-
smartAccountInit = new NexusSmartAccount();
41-
break;
42-
case "kernel":
43-
smartAccountInit = new KernelSmartAccount();
44-
break;
45-
case "trust":
46-
smartAccountInit = new TrustSmartAccount();
47-
break;
48-
// case "light":
49-
// smartAccountInit = new LightSmartAccount();
50-
// break;
51-
// case "simple":
52-
// smartAccountInit = new SimpleSmartAccount();
53-
// break;
54-
case "safe":
55-
default:
56-
smartAccountInit = new SafeSmartAccount();
57-
break;
58-
}
59-
60-
return new AccountAbstractionProvider({
61-
config: {
62-
bundlerConfig: { url: formData.bundlerUrl ?? getDefaultBundlerUrl(chainConfig.chainId) },
63-
paymasterConfig: formData.paymasterUrl
64-
? {
65-
url: formData.paymasterUrl,
66-
}
67-
: undefined,
68-
smartAccountInit,
69-
},
70-
});
71-
});
72-
7327
// Options for reinitializing the web3Auth object
7428
const options = computed((): Web3AuthOptions => {
7529
const { config: whiteLabel, enable: enabledWhiteLabel } = formData.whiteLabel;
7630
const chainConfig = chainConfigs[formData.chainNamespace as ChainNamespaceType].find((x) => x.chainId === formData.chain)!;
7731
7832
// Account Abstraction
7933
const { useAccountAbstractionProvider } = formData;
80-
let accountAbstractionConfig = undefined;
34+
let accountAbstractionConfig: Web3AuthOptions["accountAbstractionConfig"];
8135
if (showAAProviderSettings.value && useAccountAbstractionProvider) {
82-
let smartAccountType = ""
83-
let smartAccountConfig = undefined;
84-
switch (formData.smartAccountType) {
85-
case "nexus":
86-
smartAccountType = SMART_ACCOUNT.NEXUS;
87-
break;
88-
case "kernel":
89-
smartAccountType = SMART_ACCOUNT.KERNEL;
90-
break;
91-
case "trust":
92-
smartAccountType = SMART_ACCOUNT.TRUST;
93-
break;
94-
// case "light":
95-
// smartAccountInit = new LightSmartAccount();
96-
// break;
97-
// case "simple":
98-
// smartAccountInit = new SimpleSmartAccount();
99-
// break;
100-
case "safe":
101-
default:
102-
smartAccountType = SMART_ACCOUNT.SAFE;
103-
break;
104-
}
10536
accountAbstractionConfig = {
106-
smartAccountType,
107-
paymasterConfig: formData.paymasterUrl ? { url: formData.paymasterUrl } : undefined,
37+
smartAccountType: formData.smartAccountType as string,
38+
smartAccountConfig: undefined,
10839
bundlerConfig: { url: formData.bundlerUrl ?? getDefaultBundlerUrl(chainConfig.chainId) },
109-
smartAccountConfig,
40+
paymasterConfig: formData.paymasterUrl ? { url: formData.paymasterUrl } : undefined,
11041
}
11142
}
11243
11344
// Wallet services settings
114-
let walletServicesSettings: Web3AuthOptions["walletServicesSettings"];
45+
let walletServicesConfig: Web3AuthOptions["walletServicesConfig"];
11546
const uiConfig = enabledWhiteLabel ? { ...whiteLabel } : undefined;
11647
if (formData.walletPlugin.enable) {
11748
const { confirmationStrategy } = formData.walletPlugin;
118-
walletServicesSettings = {
49+
walletServicesConfig = {
11950
whiteLabel: {
12051
...uiConfig,
12152
showWidgetButton: true,
12253
},
12354
confirmationStrategy,
124-
accountAbstractionConfig,
12555
};
12656
}
12757
@@ -130,7 +60,7 @@ const options = computed((): Web3AuthOptions => {
13060
clientId: clientIds[formData.network],
13161
web3AuthNetwork: formData.network,
13262
uiConfig,
133-
accountAbstractionProvider: accountAbstractionProvider.value,
63+
accountAbstractionConfig,
13464
useAAWithExternalWallet: formData.useAAWithExternalWallet,
13565
// TODO: Add more options
13666
// chainConfig?: CustomChainConfig;
@@ -143,7 +73,7 @@ const options = computed((): Web3AuthOptions => {
14373
enableLogging: true,
14474
connectors: externalConnectors.value,
14575
multiInjectedProviderDiscovery: formData.multiInjectedProviderDiscovery,
146-
walletServicesSettings,
76+
walletServicesConfig,
14777
};
14878
});
14979

demo/vue-app-new/src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ export const defaultLoginMethod: Record<LOGIN_PROVIDER_TYPE, FormConfigSettings>
162162
{} as Record<LOGIN_PROVIDER_TYPE, FormConfigSettings>
163163
);
164164

165-
export type SmartAccountType = "safe" | "kernel" | "nexus" | "trust";
165+
export type SmartAccountType = "biconomy" | "safe" | "nexus" | "kernel" | "trust";
166166

167167
export const SmartAccountOptions: { name: string; value: SmartAccountType }[] = [
168+
{ name: "Biconomy", value: "biconomy" },
168169
{ name: "Safe", value: "safe" },
169170
{ name: "Nexus", value: "nexus" },
170171
{ name: "Kernel", value: "kernel" },

demo/vue-app-new2/package-lock.json

Lines changed: 12 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/vue-app-new2/src/MainView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const ethWeb3AuthOptions: Web3AuthOptions = {
1111
clientId: clientIds["mainnet"],
1212
web3AuthNetwork: "mainnet",
1313
multiInjectedProviderDiscovery: true,
14-
connectors: [walletConnectV2Connector({ projectId: "d3c63f19f9582f8ba48e982057eb096b" }), coinbaseConnector()]
14+
connectors: [walletConnectV2Connector({ projectId: "d3c63f19f9582f8ba48e982057eb096b" }), coinbaseConnector()],
1515
};
1616
const web3auth = new Web3Auth(ethWeb3AuthOptions);
1717

package-lock.json

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)