99 WEB3AUTH_NETWORK ,
1010 WEB3AUTH_NETWORK_TYPE ,
1111} from "@web3auth/auth" ;
12- import { type IBaseProvider , type IProvider } from "@web3auth/base" ;
12+ import { type IProvider } from "@web3auth/base" ;
1313import clonedeep from "lodash.clonedeep" ;
1414import merge from "lodash.merge" ;
1515import log from "loglevel" ;
@@ -50,7 +50,9 @@ class Web3Auth implements IWeb3Auth {
5050
5151 private addVersionInUrls = true ;
5252
53- private privateKeyProvider : IBaseProvider < string > ;
53+ private privateKeyProvider : SdkInitParams [ "privateKeyProvider" ] ;
54+
55+ private accountAbstractionProvider ?: SdkInitParams [ "accountAbstractionProvider" ] ;
5456
5557 constructor ( webBrowser : IWebBrowser , storage : SecureStore | EncryptedStorage , options : SdkInitParams ) {
5658 if ( ! options . clientId ) throw InitializationError . invalidParams ( "clientId is required" ) ;
@@ -117,6 +119,9 @@ class Web3Auth implements IWeb3Auth {
117119 this . webBrowser = webBrowser ;
118120 this . keyStore = new KeyStore ( storage ) ;
119121 this . privateKeyProvider = options . privateKeyProvider ;
122+ if ( options . accountAbstractionProvider ) {
123+ this . accountAbstractionProvider = options . accountAbstractionProvider ;
124+ }
120125 this . state = { } ;
121126 }
122127
@@ -126,7 +131,7 @@ class Web3Auth implements IWeb3Auth {
126131
127132 get provider ( ) : IProvider | null {
128133 if ( this . privateKeyProvider ) {
129- return this . privateKeyProvider ;
134+ return this . accountAbstractionProvider ?? this . privateKeyProvider ;
130135 }
131136 return null ;
132137 }
@@ -184,6 +189,10 @@ class Web3Auth implements IWeb3Auth {
184189 const finalPrivKey = this . getFinalPrivKey ( ) ;
185190 if ( ! finalPrivKey ) return ;
186191 await this . privateKeyProvider . setupProvider ( finalPrivKey ) ;
192+ // setup aa provider after private key provider is setup
193+ if ( this . accountAbstractionProvider ) {
194+ await this . accountAbstractionProvider . setupProvider ( this . privateKeyProvider ) ;
195+ }
187196 } else {
188197 await this . keyStore . remove ( "sessionId" ) ;
189198 this . updateState ( { } ) ;
@@ -253,6 +262,10 @@ class Web3Auth implements IWeb3Auth {
253262 const finalPrivKey = this . getFinalPrivKey ( ) ;
254263 if ( ! finalPrivKey ) throw LoginError . loginFailed ( "final private key not found" ) ;
255264 await this . privateKeyProvider . setupProvider ( finalPrivKey ) ;
265+ // setup aa provider after private key provider is setup
266+ if ( this . accountAbstractionProvider ) {
267+ await this . accountAbstractionProvider . setupProvider ( this . privateKeyProvider ) ;
268+ }
256269
257270 return this . provider ;
258271 }
0 commit comments