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" ;
44import { Web3AuthContextConfig , Web3AuthProvider } from " @web3auth/modal/vue" ;
55import { WalletServicesProvider } from " @web3auth/no-modal/vue" ;
66import { computed , onBeforeMount , ref , watch } from " vue" ;
77
8- import { SMART_ACCOUNT } from " @toruslabs/ethereum-controllers" ;
98import AppDashboard from " ./components/AppDashboard.vue" ;
109import AppHeader from " ./components/AppHeader.vue" ;
1110import AppSettings from " ./components/AppSettings.vue" ;
@@ -25,103 +24,34 @@ const chainOptions = computed(() =>
2524
2625const 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
7428const 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
0 commit comments