@@ -99,14 +99,14 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin {
9999 if ( ! connectedChainConfig . ticker ) throw WalletServicesPluginError . invalidParams ( "ticker is required in chainConfig" ) ;
100100 if ( ! connectedChainConfig . tickerName ) throw WalletServicesPluginError . invalidParams ( "tickerName is required in chainConfig" ) ;
101101
102- const enableAccountAbstraction =
102+ const hasAaProvider =
103103 web3auth . coreOptions . accountAbstractionProvider &&
104104 ( web3auth . connectedAdapterName === WALLET_ADAPTERS . AUTH ||
105105 ( web3auth . connectedAdapterName !== WALLET_ADAPTERS . AUTH && web3auth . coreOptions . useAAWithExternalWallet ) ) ;
106106
107107 let accountAbstractionConfig : AccountAbstractionConfig ;
108108
109- if ( enableAccountAbstraction ) {
109+ if ( hasAaProvider ) {
110110 const smartAccountAddress = ( web3auth . coreOptions . accountAbstractionProvider as AccountAbstractionProvider ) ?. smartAccount . address ;
111111 const smartAccountType = ( web3auth . coreOptions . accountAbstractionProvider as AccountAbstractionProvider ) ?. config . smartAccountInit . name ;
112112 const paymasterConfig = ( web3auth . coreOptions . accountAbstractionProvider as AccountAbstractionProvider ) ?. config ?. paymasterConfig ;
@@ -121,6 +121,9 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin {
121121 bundlerConfig : bundlerConfig || undefined ,
122122 smartAccountConfig : smartAccountConfig || undefined ,
123123 } as AccountAbstractionConfig ;
124+ } else if ( this . walletInitOptions ?. accountAbstractionConfig && Object . keys ( this . walletInitOptions . accountAbstractionConfig ) . length > 0 ) {
125+ // if wallet services plugin is initialized with accountAbstractionConfig we enable wallet service AA without AA provider
126+ accountAbstractionConfig = this . walletInitOptions . accountAbstractionConfig ;
124127 }
125128
126129 const finalInitOptions = {
@@ -168,7 +171,6 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin {
168171 sessionId,
169172 sessionNamespace,
170173 } ) ;
171- if ( this . walletInitOptions ?. whiteLabel ?. showWidgetButton ) this . wsEmbedInstance . showTorusButton ( ) ;
172174 this . subscribeToProviderEvents ( this . provider ) ;
173175 this . subscribeToWalletEvents ( ) ;
174176 this . emit ( PLUGIN_EVENTS . CONNECTED ) ;
@@ -218,7 +220,6 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin {
218220 private subscribeToWalletEvents ( ) {
219221 this . wsEmbedInstance ?. provider . on ( "accountsChanged" , ( accounts : unknown [ ] = [ ] ) => {
220222 if ( ( accounts as string [ ] ) . length === 0 ) {
221- this . wsEmbedInstance . hideTorusButton ( ) ;
222223 if ( this . web3auth ?. status === ADAPTER_STATUS . CONNECTED ) this . web3auth ?. logout ( ) ;
223224 }
224225 } ) ;
@@ -232,12 +233,6 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin {
232233 provider . on ( "chainChanged" , ( chainId : string ) => {
233234 this . setChainID ( parseInt ( chainId , 16 ) ) ;
234235 } ) ;
235- provider . on ( "disconnect" , ( ) => {
236- this . wsEmbedInstance . hideTorusButton ( ) ;
237- } ) ;
238- provider . on ( "connect" , ( ) => {
239- if ( this . walletInitOptions ?. whiteLabel ?. showWidgetButton ) this . wsEmbedInstance . showTorusButton ( ) ;
240- } ) ;
241236 }
242237
243238 private subscribeToWeb3AuthEvents ( web3Auth : IWeb3AuthCore ) {
@@ -252,7 +247,6 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin {
252247 if ( this . wsEmbedInstance . isLoggedIn ) {
253248 await this . wsEmbedInstance . logout ( ) ;
254249 }
255- this . wsEmbedInstance . hideTorusButton ( ) ;
256250 } ) ;
257251 }
258252
0 commit comments