@@ -347076,72 +347076,72 @@ Code: ${s}`;
347076347076 this.walletMap.set(s.id, o));
347077347077 }
347078347078 }
347079- async connect(e = "injected", t, n, a, i = "localWallet", s) {
347079+ async connect(e = "injected", t, n, a, i = "localWallet", s, o ) {
347080347080 if (!this.activeSDK) throw new Error("SDK not initialized");
347081- let o = this.walletMap.get(e),
347082- c = Number(t);
347083- if (o ) {
347081+ let c = this.walletMap.get(e),
347082+ u = Number(t);
347083+ if (c ) {
347084347084 if (
347085- (o .walletId === sb.walletIds.localWallet &&
347086- (await this.initializeLocalWallet(n), o .connect({ chainId: c })),
347087- o .walletId === sb.walletIds.embeddedWallet)
347085+ (c .walletId === sb.walletIds.localWallet &&
347086+ (await this.initializeLocalWallet(n), c .connect({ chainId: u })),
347087+ c .walletId === sb.walletIds.embeddedWallet)
347088347088 ) {
347089- let u = o ,
347090- l = JSON.parse(s || "{}");
347091- if (l .authProvider === 0) {
347089+ let l = c ,
347090+ f = JSON.parse(s || "{}");
347091+ if (f .authProvider === 0) {
347092347092 if (!a) throw new Error("Email is required for EmbeddedWallet");
347093- let f = await u .authenticate({
347093+ let h = await l .authenticate({
347094347094 strategy: "iframe_email_verification",
347095347095 email: a,
347096347096 });
347097- await u .connect({ chainId: c , authResult: f });
347098- } else if (l .authProvider < 4) {
347099- let f ;
347100- switch (l .authProvider) {
347097+ await l .connect({ chainId: u , authResult: h });
347098+ } else if (f .authProvider < 4) {
347099+ let h ;
347100+ switch (f .authProvider) {
347101347101 case 1:
347102- f = "google";
347102+ h = "google";
347103347103 break;
347104347104 case 2:
347105- f = "apple";
347105+ h = "apple";
347106347106 break;
347107347107 case 3:
347108- f = "facebook";
347108+ h = "facebook";
347109347109 break;
347110347110 default:
347111- throw new Error("Invalid auth provider: " + l .authProvider);
347111+ throw new Error("Invalid auth provider: " + f .authProvider);
347112347112 }
347113- let h = this.openPopupWindow();
347114- if (!h ) throw new Error("Failed to open login window");
347115- let y = await u .authenticate({
347116- strategy: f ,
347117- openedWindow: h ,
347118- closeOpenedWindow: (w ) => {
347119- w .close();
347113+ let y = this.openPopupWindow();
347114+ if (!y ) throw new Error("Failed to open login window");
347115+ let w = await l .authenticate({
347116+ strategy: h ,
347117+ openedWindow: y ,
347118+ closeOpenedWindow: (S ) => {
347119+ S .close();
347120347120 },
347121347121 });
347122- await u .connect({ chainId: c , authResult: y });
347123- } else if (l .authProvider === 4) {
347124- let f = await u .authenticate({
347122+ await l .connect({ chainId: u , authResult: w });
347123+ } else if (f .authProvider === 4) {
347124+ let h = await l .authenticate({
347125347125 strategy: "jwt",
347126- jwt: l .authToken,
347126+ jwt: f .authToken,
347127347127 });
347128- await u .connect({ chainId: c , authResult: f });
347129- } else throw new Error("Invalid auth provider: " + l .authProvider);
347130- } else if (o .walletId === sb.walletIds.smartWallet) {
347131- let u = o ,
347132- l = this.walletMap.get(i);
347128+ await l .connect({ chainId: u , authResult: h });
347129+ } else throw new Error("Invalid auth provider: " + f .authProvider);
347130+ } else if (c .walletId === sb.walletIds.smartWallet) {
347131+ let l = c ,
347132+ f = this.walletMap.get(i);
347133347133 if (
347134- (await this.connect(l ?.walletId, t, n, a, i), this.activeWallet)
347134+ (await this.connect(f ?.walletId, t, n, a, i), this.activeWallet)
347135347135 )
347136- await this.initializeSmartWallet(u , this.activeWallet);
347136+ await this.initializeSmartWallet(l , this.activeWallet, o );
347137347137 else
347138347138 throw new Error(
347139347139 "Unable to connect EOA wallet to initialize smart wallet!"
347140347140 );
347141- } else await o .connect({ chainId: c });
347141+ } else await c .connect({ chainId: u });
347142347142 return (
347143- (this.activeWallet = o ),
347144- this.updateSDKSigner(await o .getSigner()),
347143+ (this.activeWallet = c ),
347144+ this.updateSDKSigner(await c .getSigner()),
347145347145 await this.activeSDK.wallet.getAddress()
347146347146 );
347147347147 } else throw new Error("Invalid Wallet");
@@ -347310,10 +347310,15 @@ Code: ${s}`;
347310347310 .get(sb.walletIds.localWallet)
347311347311 .export({ strategy: "encryptedJson", password: e });
347312347312 }
347313- async initializeSmartWallet(e, t) {
347314- let n = await t.getAddress();
347315- console.debug("Personal wallet address:", n),
347316- await e.connect({ personalWallet: t }),
347313+ async initializeSmartWallet(e, t, n) {
347314+ n &&
347315+ console.debug(
347316+ "Initializing smart wallet with account address override:",
347317+ n
347318+ );
347319+ let a = await t.getAddress();
347320+ console.debug("Personal wallet address:", a),
347321+ await e.connect({ personalWallet: t, accountAddress: n }),
347317347322 e.listenerCount("disconnect") === 1 &&
347318347323 e.on("disconnect", () => {
347319347324 t.disconnect();
0 commit comments