@getpara/react-sdk-lite 2.0.0-alpha.66 → 2.0.0-alpha.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/modal/components/Account/AccountProfile.js +12 -172
  2. package/dist/modal/components/Account/AccountProfileEntry.d.ts +12 -0
  3. package/dist/modal/components/Account/AccountProfileEntry.js +220 -0
  4. package/dist/modal/components/Account/AccountWallet.d.ts +1 -0
  5. package/dist/modal/components/Account/AccountWallet.js +133 -0
  6. package/dist/modal/components/Account/AccountWalletSelect.js +15 -2
  7. package/dist/modal/components/Body/Body.js +4 -0
  8. package/dist/modal/components/ChainSwitch/ChainSwitch.js +8 -3
  9. package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +2 -2
  10. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +2 -1
  11. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +36 -29
  12. package/dist/modal/components/ExternalWallets/ExternalWallets.js +2 -2
  13. package/dist/modal/components/Header/hooks/useStepTitle.js +50 -45
  14. package/dist/modal/components/IFrameStep/IFrameStep.js +8 -6
  15. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -5
  16. package/dist/modal/components/OAuth/TelegramOAuthStep.js +6 -5
  17. package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +17 -4
  18. package/dist/modal/hooks/useFarcasterLogin.js +8 -1
  19. package/dist/modal/hooks/useTelegramLogin.js +4 -0
  20. package/dist/modal/stores/modal/actions.js +2 -1
  21. package/dist/modal/stores/modal/useModalStore.d.ts +4 -0
  22. package/dist/modal/stores/modal/useModalStore.js +4 -2
  23. package/dist/modal/utils/openPopup.d.ts +1 -1
  24. package/dist/modal/utils/openPopup.js +3 -1
  25. package/dist/modal/utils/steps.d.ts +3 -1
  26. package/dist/modal/utils/steps.js +4 -0
  27. package/dist/modal/utils/stringFormatters.js +10 -1
  28. package/dist/modal/utils/validatePortalOrigin.d.ts +2 -0
  29. package/dist/modal/utils/validatePortalOrigin.js +14 -0
  30. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +3 -1
  31. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +3 -1
  32. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +3 -1
  33. package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +5 -5
  34. package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +2 -2
  35. package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +2 -2
  36. package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +2 -2
  37. package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +2 -2
  38. package/dist/provider/hooks/mutations/useCreateWallet.d.ts +2 -2
  39. package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +2 -2
  40. package/dist/provider/hooks/mutations/useEnable2fa.d.ts +2 -2
  41. package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +2 -2
  42. package/dist/provider/hooks/mutations/useIssueJwt.d.ts +2 -2
  43. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +2 -2
  44. package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +8 -2
  45. package/dist/provider/hooks/mutations/useLogout.d.ts +2 -2
  46. package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +2 -2
  47. package/dist/provider/hooks/mutations/useSetup2fa.d.ts +2 -2
  48. package/dist/provider/hooks/mutations/useSignMessage.d.ts +2 -2
  49. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +2 -2
  50. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +2 -2
  51. package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +2 -2
  52. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +2 -2
  53. package/dist/provider/hooks/mutations/useVerify2fa.d.ts +2 -2
  54. package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +18 -30
  55. package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +2 -2
  56. package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +8 -8
  57. package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +2 -2
  58. package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +2 -2
  59. package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +2 -2
  60. package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +2 -2
  61. package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +2 -2
  62. package/dist/provider/hooks/utils/useEventListeners.js +2 -0
  63. package/dist/provider/hooks/utils/useWalletState.d.ts +1 -1
  64. package/dist/provider/providers/AccountLinkProvider.js +3 -2
  65. package/dist/provider/providers/AuthProvider.js +73 -34
  66. package/dist/provider/providers/ExternalWalletProvider.d.ts +17 -5
  67. package/dist/provider/providers/ExternalWalletProvider.js +275 -38
  68. package/dist/provider/stores/getters.d.ts +1 -1
  69. package/package.json +8 -8
  70. package/dist/modal/utils/routeMobileExternalWallet.d.ts +0 -1
  71. package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
@@ -5,17 +5,22 @@ import {
5
5
  __spreadValues
6
6
  } from "../../chunk-MMUBH76A.js";
7
7
  import { jsx } from "react/jsx-runtime";
8
- import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
8
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
9
9
  import { isMobile, truncateAddress } from "@getpara/web-sdk";
10
10
  import { useInternalClient } from "../hooks/utils/useInternalClient.js";
11
11
  import { useStore } from "../stores/useStore.js";
12
- import { ModalStep } from "../../modal/index.js";
12
+ import { ModalStep, openPopup } from "../../modal/index.js";
13
13
  import { useModalStore } from "../../modal/stores/index.js";
14
14
  import { useAccount, useModal, useParaStatus, useVerifyExternalWallet, useWalletState } from "../hooks/index.js";
15
+ import {
16
+ openMobileUrl
17
+ } from "@getpara/react-common";
15
18
  import { ParaEvent, dispatchEvent } from "@getpara/web-sdk";
16
19
  import { useAuthActions } from "./AuthProvider.js";
17
20
  import { IS_FULLY_LOGGED_IN_BASE_KEY } from "../hooks/queries/useIsFullyLoggedIn.js";
18
21
  import { useQueryClient } from "@tanstack/react-query";
22
+ import { useGoBack } from "../../modal/hooks/useGoBack.js";
23
+ import { validatePortalOrigin } from "../../modal/utils/validatePortalOrigin.js";
19
24
  const useWalletDisplayHelpers = (wallet) => {
20
25
  const isUsingMobileConnector = useModalStore((state) => state.isUsingMobileConnector);
21
26
  return {
@@ -49,9 +54,12 @@ const defaultExternalWallet = {
49
54
  isSigningMessage: false,
50
55
  getWalletBalance: () => Promise.resolve(void 0),
51
56
  requestInfo: (_) => Promise.resolve({}),
52
- disconnectBase: (_, __) => Promise.resolve(),
57
+ disconnectBase: (_, __, ___) => Promise.resolve(),
53
58
  connectFarcasterMiniApp: () => Promise.resolve(),
54
- verificationStage: void 0
59
+ verificationStage: void 0,
60
+ evmDisconnectStatus: "idle",
61
+ solanaDisconnectStatus: "idle",
62
+ cosmosDisconnectStatus: "idle"
55
63
  };
56
64
  const ExternalWalletContext = createContext(defaultExternalWallet);
57
65
  function ExternalWalletProvider({ children }) {
@@ -81,7 +89,8 @@ function ExternalWalletProvider({ children }) {
81
89
  requestInfo: evmRequestInfo,
82
90
  disconnectBase: evmDisconnectBase,
83
91
  farcasterStatus: evmFarcasterStatus,
84
- verificationStage: evmVerificationStage
92
+ verificationStage: evmVerificationStage,
93
+ disconnectStatus: evmDisconnectStatus
85
94
  } = useContext(evmContext);
86
95
  const {
87
96
  wallets: solanaWallets,
@@ -90,7 +99,8 @@ function ExternalWalletProvider({ children }) {
90
99
  signVerificationMessage: solanaSignVerificationMessage,
91
100
  requestInfo: solanaRequestInfo,
92
101
  disconnectBase: solanaDisconnectBase,
93
- farcasterStatus: solanaFarcasterStatus
102
+ farcasterStatus: solanaFarcasterStatus,
103
+ disconnectStatus: solanaDisconnectStatus
94
104
  } = useContext(solanaContext);
95
105
  const {
96
106
  wallets: cosmosWallets,
@@ -102,7 +112,8 @@ function ExternalWalletProvider({ children }) {
102
112
  signMessage: cosmosSignMessage,
103
113
  signVerificationMessage: cosmosSignVerificationMessage,
104
114
  requestInfo: cosmosRequestInfo,
105
- disconnectBase: cosmosDisconnectBase
115
+ disconnectBase: cosmosDisconnectBase,
116
+ disconnectStatus: cosmosDisconnectStatus
106
117
  } = useContext(cosmosContext);
107
118
  const onLoginRef = useStore((state) => state.onLoginRef);
108
119
  const setStep = useModalStore((state) => state.setStep);
@@ -119,9 +130,11 @@ function ExternalWalletProvider({ children }) {
119
130
  const { onNewAuthState } = useAuthActions();
120
131
  const { verifyExternalWalletAsync } = useVerifyExternalWallet();
121
132
  const queryClient = useQueryClient();
133
+ const goBack = useGoBack();
122
134
  const [qrUri, setQrUri] = useState();
123
135
  const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
124
136
  const [isSigningMessage, setIsSigningMessage] = useState(false);
137
+ const popupCloseIntervalRef = useRef(null);
125
138
  const allWallets = [...evmWallets, ...solanaWallets, ...cosmosWallets];
126
139
  let wallets = allWallets.filter(
127
140
  (w) => (w.internalId !== "FARCASTER" || (para == null ? void 0 : para.isFarcasterMiniApp)) && externalWallets.includes(w.internalId)
@@ -136,20 +149,25 @@ function ExternalWalletProvider({ children }) {
136
149
  () => wallets.find((w) => w.id === (selectedExternalWallet == null ? void 0 : selectedExternalWallet.id) && w.type === (selectedExternalWallet == null ? void 0 : selectedExternalWallet.type)),
137
150
  [wallets, selectedExternalWallet]
138
151
  );
139
- const updateQrUri = () => __async(this, null, function* () {
140
- var _a;
141
- const uri = yield (_a = wallet == null ? void 0 : wallet.getQrUri) == null ? void 0 : _a.call(wallet);
142
- setQrUri(uri);
143
- });
144
- useEffect(() => {
145
- if (wallet) {
146
- if (!qrUri) {
147
- updateQrUri();
148
- }
149
- } else if (qrUri) {
150
- setQrUri(void 0);
152
+ const [walletConnectCleanup, setWalletConnectCleanup] = useState(null);
153
+ const listenForWalletConnectUri = () => {
154
+ setQrUri(void 0);
155
+ if (walletConnectCleanup) {
156
+ walletConnectCleanup();
151
157
  }
152
- }, [wallet]);
158
+ const callback = (event) => {
159
+ openMobileUrl(event.detail);
160
+ setQrUri(event.detail);
161
+ cleanup();
162
+ setWalletConnectCleanup(null);
163
+ };
164
+ const cleanup = () => {
165
+ window.removeEventListener("PARA_WALLETCONNECT_URI_READY", callback);
166
+ };
167
+ window.addEventListener("PARA_WALLETCONNECT_URI_READY", callback);
168
+ setWalletConnectCleanup(() => cleanup);
169
+ return cleanup;
170
+ };
153
171
  const isWithFullAuth = (wallet2) => {
154
172
  if (connectionOnly) {
155
173
  return false;
@@ -345,7 +363,10 @@ function ExternalWalletProvider({ children }) {
345
363
  return verifyExternalWalletParams;
346
364
  }), [cosmosSignVerificationMessage, evmSignVerificationMessage, solanaSignVerificationMessage, wallet]);
347
365
  const signMessage = useCallback(
348
- (_0) => __async(this, [_0], function* ({ message, externalWallet: _externalWallet }) {
366
+ (_0) => __async(this, [_0], function* ({
367
+ message,
368
+ externalWallet: _externalWallet
369
+ }) {
349
370
  var _a;
350
371
  setExternalWalletError();
351
372
  setIsSigningMessage(true);
@@ -356,14 +377,16 @@ function ExternalWalletProvider({ children }) {
356
377
  switch (walletType) {
357
378
  case "COSMOS":
358
379
  {
359
- const { address, signature, error, cosmosPublicKeyHex, cosmosSigner } = yield cosmosSignMessage({
360
- message,
361
- externalWallet
362
- });
380
+ const { address, signature, error, cosmosPublicKeyHex, cosmosSigner, addressBech32 } = yield cosmosSignMessage(
381
+ {
382
+ message,
383
+ externalWallet
384
+ }
385
+ );
363
386
  if (error) {
364
387
  throw new Error(error);
365
388
  } else if (signature && address) {
366
- response = { address, signature, cosmosPublicKeyHex, cosmosSigner };
389
+ response = { address, signature, cosmosPublicKeyHex, cosmosSigner, addressBech32 };
367
390
  }
368
391
  }
369
392
  break;
@@ -401,6 +424,7 @@ function ExternalWalletProvider({ children }) {
401
424
  );
402
425
  const addAdditionalExternalWallet = useCallback(
403
426
  (wallet2) => __async(this, null, function* () {
427
+ setExternalWalletError();
404
428
  try {
405
429
  const walletInfo = yield requestInfo(wallet2.id, wallet2.type);
406
430
  const walletAddress = wallet2.type === "COSMOS" && walletInfo.addressBech32 ? walletInfo.addressBech32 : walletInfo.address;
@@ -464,8 +488,198 @@ function ExternalWalletProvider({ children }) {
464
488
  }),
465
489
  [para, connectionOnly, includeWalletVerification, setStep, setExternalWalletError]
466
490
  );
491
+ const setupExternalWalletVerificationStatusListener = (wallet2) => {
492
+ typeof window !== "undefined" && window.addEventListener("message", function handleMessage(event) {
493
+ return __async(this, null, function* () {
494
+ var _a, _b, _c, _d;
495
+ if (!validatePortalOrigin(event, para.ctx)) {
496
+ return;
497
+ }
498
+ if (((_a = event.data) == null ? void 0 : _a.type) === "EW_VERIFY_SUCCESS") {
499
+ clearPopupWindowCloseListener();
500
+ const serverAuthState = (_b = event.data) == null ? void 0 : _b.serverAuthState;
501
+ if (serverAuthState && ((_c = serverAuthState.externalWallet) == null ? void 0 : _c.withFullParaAuth)) {
502
+ const authState = yield para.verifyExternalWallet({ serverAuthState });
503
+ yield onNewAuthState(authState);
504
+ } else {
505
+ setStep(ModalStep.LOGIN_DONE);
506
+ }
507
+ window.removeEventListener("message", handleMessage);
508
+ }
509
+ if (((_d = event.data) == null ? void 0 : _d.type) === "EW_VERIFY_RETRY") {
510
+ yield handleTriggerSignMessage(wallet2, event.data.message);
511
+ window.removeEventListener("message", handleMessage);
512
+ }
513
+ });
514
+ });
515
+ };
516
+ const handlePostMessage = (message) => {
517
+ var _a;
518
+ if (refs.popupWindow.current) {
519
+ refs.popupWindow.current.postMessage(message, "*");
520
+ } else if (refs.iFrame.current) {
521
+ (_a = refs.iFrame.current.contentWindow) == null ? void 0 : _a.postMessage(message, "*");
522
+ }
523
+ };
524
+ const handleTriggerSignMessage = (wallet2, message) => __async(this, null, function* () {
525
+ setupExternalWalletVerificationStatusListener(wallet2);
526
+ try {
527
+ const { address, signature, cosmosPublicKeyHex, cosmosSigner, addressBech32 } = yield signMessage({
528
+ message,
529
+ externalWallet: wallet2
530
+ });
531
+ const paraWallet = Object.values(para.externalWallets)[0];
532
+ const walletType = paraWallet == null ? void 0 : paraWallet.type;
533
+ let verifyExternalWalletParams;
534
+ const withVerification = includeWalletVerification;
535
+ const isConnectionOnly = connectionOnly;
536
+ const withFullParaAuth = (paraWallet == null ? void 0 : paraWallet.name) ? isWithFullAuth(paraWallet) : false;
537
+ const defaultWalletInfo = {
538
+ withVerification,
539
+ isConnectionOnly,
540
+ withFullParaAuth,
541
+ provider: paraWallet.name,
542
+ providerId: paraWallet.externalProviderId,
543
+ isExternal: true
544
+ };
545
+ switch (walletType) {
546
+ case "COSMOS":
547
+ {
548
+ verifyExternalWalletParams = {
549
+ externalWallet: __spreadValues({
550
+ partnerId: para.partnerId,
551
+ type: "COSMOS",
552
+ address,
553
+ addressBech32
554
+ }, defaultWalletInfo),
555
+ signedMessage: signature,
556
+ cosmosPublicKeyHex,
557
+ cosmosSigner
558
+ };
559
+ }
560
+ break;
561
+ case "EVM":
562
+ {
563
+ verifyExternalWalletParams = {
564
+ externalWallet: __spreadValues({
565
+ partnerId: para.partnerId,
566
+ type: "EVM",
567
+ address
568
+ }, defaultWalletInfo),
569
+ signedMessage: signature
570
+ };
571
+ }
572
+ break;
573
+ case "SOLANA":
574
+ {
575
+ verifyExternalWalletParams = {
576
+ externalWallet: __spreadValues({
577
+ partnerId: para.partnerId,
578
+ type: "SOLANA",
579
+ address
580
+ }, defaultWalletInfo),
581
+ signedMessage: signature
582
+ };
583
+ }
584
+ break;
585
+ default:
586
+ break;
587
+ }
588
+ if (!(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.externalWallet) || !(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.signedMessage)) {
589
+ console.error("No signature or address found on the verifyWalletSignature response.");
590
+ handlePostMessage({ type: "EW_SIGN_MESSAGE_ERROR", error: "Signature verification failed." });
591
+ return;
592
+ }
593
+ handlePostMessage({ type: "EW_SIGN_MESSAGE_SUCCESS", verifyExternalWalletParams });
594
+ } catch (error) {
595
+ handlePostMessage({ type: "EW_SIGN_MESSAGE_ERROR", error: error.message || "Error signing message" });
596
+ }
597
+ });
598
+ const setupExternalWalletVerificationTriggerListener = (wallet2) => {
599
+ if (!wallet2) {
600
+ return;
601
+ }
602
+ typeof window !== "undefined" && window.addEventListener("message", function handleMessage(event) {
603
+ return __async(this, null, function* () {
604
+ var _a;
605
+ if (!validatePortalOrigin(event, para.ctx)) {
606
+ return;
607
+ }
608
+ if (((_a = event.data) == null ? void 0 : _a.type) === "EW_TRIGGER_SIGN_MESSAGE") {
609
+ yield handleTriggerSignMessage(wallet2, event.data.message);
610
+ window.removeEventListener("message", handleMessage);
611
+ }
612
+ });
613
+ });
614
+ };
615
+ const setupPopupWindowCloseListener = () => {
616
+ const popup = refs.popupWindow.current;
617
+ if (!popup) return;
618
+ if (popupCloseIntervalRef.current) {
619
+ clearInterval(popupCloseIntervalRef.current);
620
+ }
621
+ popupCloseIntervalRef.current = setInterval(() => {
622
+ if (popup.closed) {
623
+ if (popupCloseIntervalRef.current) {
624
+ clearInterval(popupCloseIntervalRef.current);
625
+ popupCloseIntervalRef.current = null;
626
+ }
627
+ goBack();
628
+ disconnectExternalWallet();
629
+ }
630
+ }, 500);
631
+ };
632
+ const clearPopupWindowCloseListener = () => {
633
+ if (popupCloseIntervalRef.current) {
634
+ clearInterval(popupCloseIntervalRef.current);
635
+ popupCloseIntervalRef.current = null;
636
+ }
637
+ };
638
+ const handlePostConnectRetry = () => {
639
+ handlePostMessage({ type: "EW_CONNECT_RETRY" });
640
+ };
641
+ const handlePostConnectError = (error) => {
642
+ handlePostMessage({ type: "EW_CONNECT_ERROR", error });
643
+ };
644
+ const handleConnectRetryMessage = (wallet2) => (event) => __async(this, null, function* () {
645
+ var _a;
646
+ if (!validatePortalOrigin(event, para.ctx)) {
647
+ return;
648
+ }
649
+ if (((_a = event.data) == null ? void 0 : _a.type) === "EW_CONNECT_RETRY") {
650
+ clearExternalWalletConnectionRetryListener(wallet2);
651
+ yield connectExternalWallet({ wallet: wallet2, isMobileConnect: wallet2.isMobile, isRetryConnection: true });
652
+ }
653
+ });
654
+ const setupExternalWalletConnectionRetryListener = (wallet2) => {
655
+ typeof window !== "undefined" && window.addEventListener("message", handleConnectRetryMessage(wallet2));
656
+ };
657
+ const clearExternalWalletConnectionRetryListener = (wallet2) => {
658
+ window.removeEventListener("message", handleConnectRetryMessage(wallet2));
659
+ };
467
660
  const connectExternalWallet = useCallback(
468
- (wallet2, isMobileConnect, isManualWalletConnect, isResetAfterManualWalletConnect) => __async(this, null, function* () {
661
+ (_0) => __async(this, [_0], function* ({
662
+ wallet: wallet2,
663
+ isManualWalletConnect,
664
+ isMobileConnect,
665
+ isResetAfterManualWalletConnect,
666
+ isRetryConnection
667
+ }) {
668
+ if (isRetryConnection) {
669
+ clearExternalWalletConnectionRetryListener(wallet2);
670
+ handlePostConnectRetry();
671
+ }
672
+ if (!isMobile() && isWithFullAuth(wallet2)) {
673
+ const popupUrl = yield para.constructPortalUrl("connectExternalWallet");
674
+ if (typeof window !== void 0) {
675
+ refs.popupWindow.current = openPopup({
676
+ url: popupUrl,
677
+ type: "LOGIN_EXTERNAL_WALLET",
678
+ target: "ParaExternalWallet"
679
+ });
680
+ }
681
+ setupPopupWindowCloseListener();
682
+ }
469
683
  if (isExternalWalletConnecting && isManualWalletConnect) {
470
684
  yield evmDisconnect();
471
685
  yield solanaDisconnect();
@@ -473,23 +687,27 @@ function ExternalWalletProvider({ children }) {
473
687
  setQrUri(void 0);
474
688
  setIsExternalWalletConnecting(false);
475
689
  }
476
- if (isResetAfterManualWalletConnect || isManualWalletConnect || !isExternalWalletConnecting) {
690
+ if (isResetAfterManualWalletConnect || isManualWalletConnect || isMobileConnect || !isExternalWalletConnecting) {
477
691
  setExternalWalletError();
478
692
  setIsExternalWalletConnecting(true);
479
693
  setIsUsingMobileConnector(isMobileConnect);
694
+ listenForWalletConnectUri();
480
695
  const { address, error, authState } = yield isMobileConnect ? wallet2.connectMobile(isManualWalletConnect, connectionOnly) : wallet2.connect(connectionOnly);
481
696
  if (error) {
482
697
  setExternalWalletError([error]);
483
698
  setIsUsingMobileConnector();
699
+ handlePostConnectError(error);
484
700
  if (isManualWalletConnect && error === "Connection request rejected") {
485
701
  setExternalWalletError();
486
- yield connectExternalWallet(wallet2, false, false, true);
487
- yield updateQrUri();
702
+ yield connectExternalWallet({ wallet: wallet2, isResetAfterManualWalletConnect: true });
488
703
  return;
489
704
  }
705
+ setupExternalWalletConnectionRetryListener(wallet2);
490
706
  } else if (address) {
491
707
  if (!!authState && (isWithFullAuth(wallet2) || includeWalletVerification)) {
708
+ clearExternalWalletConnectionRetryListener(wallet2);
492
709
  onNewAuthState(authState);
710
+ setupExternalWalletVerificationTriggerListener(authState.externalWallet);
493
711
  } else {
494
712
  setStep(ModalStep.LOGIN_DONE);
495
713
  }
@@ -515,7 +733,7 @@ function ExternalWalletProvider({ children }) {
515
733
  isConnectionOnly: true
516
734
  });
517
735
  } else {
518
- yield connectExternalWallet(evmWallet, false, true);
736
+ yield connectExternalWallet({ wallet: evmWallet, isManualWalletConnect: true });
519
737
  }
520
738
  }
521
739
  if (solanaWallet && (solanaFarcasterStatus == null ? void 0 : solanaFarcasterStatus.isPresent)) {
@@ -529,7 +747,7 @@ function ExternalWalletProvider({ children }) {
529
747
  isConnectionOnly: true
530
748
  });
531
749
  } else {
532
- yield connectExternalWallet(solanaWallet, false, true);
750
+ yield connectExternalWallet({ wallet: solanaWallet, isManualWalletConnect: true });
533
751
  }
534
752
  }
535
753
  if (loginWallets.length > 0) {
@@ -541,6 +759,7 @@ function ExternalWalletProvider({ children }) {
541
759
  }
542
760
  });
543
761
  const requestInfo = (providerId, type) => __async(this, null, function* () {
762
+ listenForWalletConnectUri();
544
763
  switch (type) {
545
764
  case "EVM": {
546
765
  const externalWallet = yield evmRequestInfo(providerId);
@@ -559,19 +778,31 @@ function ExternalWalletProvider({ children }) {
559
778
  }
560
779
  }
561
780
  });
562
- const disconnectBase = (providerId, type) => __async(this, null, function* () {
781
+ const disconnectBase = (providerId, type, opts) => __async(this, null, function* () {
563
782
  switch (type) {
564
783
  case "EVM":
565
- yield evmDisconnectBase(providerId);
784
+ yield evmDisconnectBase(providerId, opts);
566
785
  break;
567
786
  case "SOLANA":
568
- yield solanaDisconnectBase(providerId);
787
+ yield solanaDisconnectBase(providerId, opts);
569
788
  break;
570
789
  default: {
571
- yield cosmosDisconnectBase();
790
+ yield cosmosDisconnectBase(void 0, opts);
572
791
  break;
573
792
  }
574
793
  }
794
+ if ((opts == null ? void 0 : opts.disconnectType) === "ACCOUNT_WIDGET") {
795
+ yield para.setExternalWallets(
796
+ (prev) => Object.entries(prev).reduce((acc, [address, externalWallet]) => {
797
+ if (externalWallet.type === type && externalWallet.externalProviderId === providerId) {
798
+ return acc;
799
+ }
800
+ return __spreadProps(__spreadValues({}, acc), {
801
+ [address]: externalWallet
802
+ });
803
+ }, {})
804
+ );
805
+ }
575
806
  });
576
807
  const disconnectExternalWallet = () => __async(this, null, function* () {
577
808
  if (para.isExternalWalletAuth) yield para.logout();
@@ -683,7 +914,10 @@ function ExternalWalletProvider({ children }) {
683
914
  requestInfo,
684
915
  disconnectBase,
685
916
  connectFarcasterMiniApp,
686
- verificationStage
917
+ verificationStage,
918
+ evmDisconnectStatus,
919
+ solanaDisconnectStatus,
920
+ cosmosDisconnectStatus
687
921
  }),
688
922
  [
689
923
  wallets,
@@ -708,7 +942,10 @@ function ExternalWalletProvider({ children }) {
708
942
  requestInfo,
709
943
  disconnectBase,
710
944
  connectFarcasterMiniApp,
711
- verificationStage
945
+ verificationStage,
946
+ evmDisconnectStatus,
947
+ solanaDisconnectStatus,
948
+ cosmosDisconnectStatus
712
949
  ]
713
950
  ),
714
951
  children
@@ -1,4 +1,4 @@
1
1
  export declare const getClient: () => import("graz").ParaWeb | undefined;
2
2
  export declare const getIsOpen: () => boolean;
3
3
  export declare const getSelectedWalletId: () => string | undefined;
4
- export declare const getSelectedWalletType: () => "EVM" | "SOLANA" | "COSMOS" | undefined;
4
+ export declare const getSelectedWalletType: () => "SOLANA" | "COSMOS" | "EVM" | undefined;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk-lite",
3
- "version": "2.0.0-alpha.66",
3
+ "version": "2.0.0-alpha.68",
4
4
  "bin": {
5
5
  "setup-para": "dist/cli/cli.mjs"
6
6
  },
7
7
  "dependencies": {
8
- "@getpara/react-common": "2.0.0-alpha.66",
9
- "@getpara/react-components": "2.0.0-alpha.66",
10
- "@getpara/web-sdk": "2.0.0-alpha.66",
8
+ "@getpara/react-common": "2.0.0-alpha.68",
9
+ "@getpara/react-components": "2.0.0-alpha.68",
10
+ "@getpara/web-sdk": "2.0.0-alpha.68",
11
11
  "date-fns": "^3.6.0",
12
12
  "framer-motion": "^11.3.31",
13
13
  "libphonenumber-js": "^1.11.7",
@@ -16,9 +16,9 @@
16
16
  "zustand-sync-tabs": "^0.2.2"
17
17
  },
18
18
  "devDependencies": {
19
- "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.66",
20
- "@getpara/evm-wallet-connectors": "2.0.0-alpha.66",
21
- "@getpara/solana-wallet-connectors": "2.0.0-alpha.66",
19
+ "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.68",
20
+ "@getpara/evm-wallet-connectors": "2.0.0-alpha.68",
21
+ "@getpara/solana-wallet-connectors": "2.0.0-alpha.68",
22
22
  "@tanstack/react-query": "^5.74.0",
23
23
  "@testing-library/dom": "^10.4.0",
24
24
  "@testing-library/react": "^16.3.0",
@@ -38,7 +38,7 @@
38
38
  "package.json",
39
39
  "styles.css"
40
40
  ],
41
- "gitHead": "07c8b7b68aa36dec6071e3b3b3a66de2870312c8",
41
+ "gitHead": "98955203281606201609bb4674f5984acb63d3bf",
42
42
  "main": "dist/index.js",
43
43
  "peerDependencies": {
44
44
  "@tanstack/react-query": ">=5.0.0",
@@ -1 +0,0 @@
1
- export declare const routeMobileExternalWallet: (qrUri?: string) => void;
@@ -1,31 +0,0 @@
1
- "use client";
2
- import "../../chunk-MMUBH76A.js";
3
- import { isAndroid, isMobile, isTelegram } from "@getpara/web-sdk";
4
- const routeMobileExternalWallet = (qrUri) => {
5
- if (typeof window === "undefined") {
6
- return;
7
- }
8
- if (isMobile()) {
9
- if (!qrUri) return;
10
- if (!isTelegram() && qrUri.startsWith("http")) {
11
- const link = document.createElement("a");
12
- link.href = qrUri;
13
- link.target = "_blank";
14
- link.rel = "noreferrer noopener";
15
- link.click();
16
- } else {
17
- if (isTelegram()) {
18
- let href = qrUri;
19
- if (isAndroid()) {
20
- href = encodeURI(qrUri);
21
- }
22
- window.open(href, "_blank", "noreferrer noopener");
23
- } else {
24
- window.location.href = qrUri;
25
- }
26
- }
27
- }
28
- };
29
- export {
30
- routeMobileExternalWallet
31
- };