@getpara/react-sdk 2.0.0-alpha.19 → 2.0.0-alpha.21

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 (88) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -5
  3. package/dist/modal/ParaModal.js +15 -5
  4. package/dist/modal/components/Account/Account.js +14 -8
  5. package/dist/modal/components/Account/AccountProfile.d.ts +1 -0
  6. package/dist/modal/components/Account/AccountProfile.js +170 -0
  7. package/dist/modal/components/Account/AccountProfileLink.d.ts +1 -0
  8. package/dist/modal/components/Account/AccountProfileLink.js +205 -0
  9. package/dist/modal/components/Account/AccountProfileLinkOptions.d.ts +1 -0
  10. package/dist/modal/components/Account/AccountProfileLinkOptions.js +98 -0
  11. package/dist/modal/components/Account/AccountProfileUnlink.d.ts +1 -0
  12. package/dist/modal/components/Account/AccountProfileUnlink.js +47 -0
  13. package/dist/modal/components/AuthInput/AuthInput.d.ts +17 -3
  14. package/dist/modal/components/AuthInput/AuthInput.js +116 -101
  15. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +2 -2
  16. package/dist/modal/components/AuthOptions/AuthOptions.js +26 -1
  17. package/dist/modal/components/Body/Body.js +21 -2
  18. package/dist/modal/components/Controls/Selects.js +3 -19
  19. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +7 -0
  20. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +75 -44
  21. package/dist/modal/components/Header/hooks/useStepTitle.js +7 -1
  22. package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -0
  23. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -2
  24. package/dist/modal/components/OAuth/OAuth.js +2 -2
  25. package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +7 -0
  26. package/dist/modal/components/OAuth/TelegramOAuthStep.js +36 -52
  27. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +12 -1
  28. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +40 -23
  29. package/dist/modal/components/common.d.ts +18 -1
  30. package/dist/modal/components/common.js +86 -0
  31. package/dist/modal/constants/constants.d.ts +1 -1
  32. package/dist/modal/constants/constants.js +1 -1
  33. package/dist/modal/constants/oAuthLogos.d.ts +15 -6
  34. package/dist/modal/constants/oAuthLogos.js +148 -19
  35. package/dist/modal/hooks/useTelegramLogin.d.ts +12 -0
  36. package/dist/modal/hooks/useTelegramLogin.js +65 -0
  37. package/dist/modal/stores/modal/actions.js +6 -1
  38. package/dist/modal/stores/modal/useModalStore.d.ts +4 -3
  39. package/dist/modal/stores/modal/useModalStore.js +7 -2
  40. package/dist/modal/types/modalProps.d.ts +6 -1
  41. package/dist/modal/utils/authInputHelpers.d.ts +3 -5
  42. package/dist/modal/utils/authInputHelpers.js +23 -20
  43. package/dist/modal/utils/getWalletDisplayName.d.ts +5 -0
  44. package/dist/modal/utils/getWalletDisplayName.js +22 -0
  45. package/dist/modal/utils/steps.d.ts +10 -2
  46. package/dist/modal/utils/steps.js +18 -2
  47. package/dist/provider/ParaProvider.js +6 -5
  48. package/dist/provider/actions/index.d.ts +19 -0
  49. package/dist/provider/actions/index.js +47 -29
  50. package/dist/provider/actions/utils.d.ts +3 -2
  51. package/dist/provider/actions/utils.js +25 -6
  52. package/dist/provider/components/CosmosWalletWrapper.js +2 -2
  53. package/dist/provider/components/EvmWalletWrapper.js +2 -2
  54. package/dist/provider/components/ExternalWalletWrapper.js +2 -1
  55. package/dist/provider/components/SolanaWalletWrapper.js +2 -2
  56. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +0 -10
  57. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +2 -12
  58. package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +0 -1
  59. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +2 -15
  60. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +0 -6
  61. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +2 -8
  62. package/dist/provider/hooks/mutations/core.d.ts +27 -0
  63. package/dist/provider/hooks/mutations/core.js +66 -0
  64. package/dist/provider/hooks/mutations/index.d.ts +3 -28
  65. package/dist/provider/hooks/mutations/index.js +4 -60
  66. package/dist/provider/hooks/mutations/useLinkAccount.d.ts +9 -0
  67. package/dist/provider/hooks/mutations/useLinkAccount.js +18 -0
  68. package/dist/provider/hooks/mutations/utils.d.ts +11 -4
  69. package/dist/provider/hooks/mutations/utils.js +35 -4
  70. package/dist/provider/hooks/queries/core.d.ts +2 -0
  71. package/dist/provider/hooks/queries/core.js +13 -0
  72. package/dist/provider/hooks/queries/index.d.ts +1 -0
  73. package/dist/provider/hooks/queries/index.js +1 -0
  74. package/dist/provider/hooks/queries/utils.d.ts +4 -0
  75. package/dist/provider/hooks/queries/utils.js +24 -0
  76. package/dist/provider/hooks/utils/useModal.d.ts +4 -1
  77. package/dist/provider/hooks/utils/useModal.js +12 -2
  78. package/dist/provider/providers/AccountLinkProvider.d.ts +42 -0
  79. package/dist/provider/providers/AccountLinkProvider.js +443 -0
  80. package/dist/provider/providers/AuthProvider.d.ts +3 -1
  81. package/dist/provider/providers/AuthProvider.js +8 -5
  82. package/dist/provider/providers/ExternalWalletProvider.d.ts +18 -35
  83. package/dist/provider/providers/ExternalWalletProvider.js +169 -39
  84. package/dist/provider/stores/slices/modal.js +3 -1
  85. package/dist/provider/stores/types.d.ts +2 -1
  86. package/dist/provider/types/utils.d.ts +25 -6
  87. package/dist/provider/utils/renameMutations.d.ts +2 -2
  88. package/package.json +8 -8
@@ -40,7 +40,7 @@ const AuthContext = createContext({
40
40
  isSignUpOrLogInPending: false,
41
41
  verifyNewAccount: () => {
42
42
  },
43
- isVerifyNewAccountPending: false,
43
+ verifyNewAccountStatus: "idle",
44
44
  verifyNewAccountError: null,
45
45
  verifyOAuth: () => {
46
46
  },
@@ -48,6 +48,7 @@ const AuthContext = createContext({
48
48
  },
49
49
  verifyTelegram: () => {
50
50
  },
51
+ verifyTelegramStatus: "idle",
51
52
  onNewAuthState: () => {
52
53
  },
53
54
  isSetup2faPending: false,
@@ -94,12 +95,12 @@ function AuthProvider({
94
95
  const { mutate: mutateSignUpOrLogIn, isPending: isSignUpOrLogInPending } = useSignUpOrLogIn();
95
96
  const {
96
97
  mutate: mutateVerifyNewAccount,
97
- isPending: isVerifyNewAccountPending,
98
+ status: verifyNewAccountStatus,
98
99
  error: verifyNewAccountError
99
100
  } = useVerifyNewAccount();
100
101
  const { mutate: mutateVerifyOAuth } = useVerifyOAuth();
101
102
  const { mutate: mutateVerifyFarcaster } = useVerifyFarcaster();
102
- const { mutate: mutateVerifyTelegram } = useVerifyTelegram();
103
+ const { mutate: mutateVerifyTelegram, status: verifyTelegramStatus } = useVerifyTelegram();
103
104
  const { mutate: mutateWaitForLogin } = useWaitForLogin();
104
105
  const { mutate: mutateWaitForSignup } = useWaitForSignup();
105
106
  const { mutateAsync: mutateAsyncWaitForWalletCreation } = useWaitForWalletCreation();
@@ -454,11 +455,12 @@ function AuthProvider({
454
455
  signUpOrLogIn,
455
456
  isSignUpOrLogInPending,
456
457
  verifyNewAccount,
457
- isVerifyNewAccountPending: isVerifyNewAccountPending || isPasswordIFrameLoading,
458
+ verifyNewAccountStatus: isPasswordIFrameLoading ? "pending" : verifyNewAccountStatus,
458
459
  verifyNewAccountError,
459
460
  verifyOAuth,
460
461
  verifyFarcaster,
461
462
  verifyTelegram,
463
+ verifyTelegramStatus,
462
464
  onNewAuthState,
463
465
  isSetup2faPending,
464
466
  createGuestWallets,
@@ -472,12 +474,13 @@ function AuthProvider({
472
474
  signUpOrLogIn,
473
475
  isSignUpOrLogInPending,
474
476
  verifyNewAccount,
475
- isVerifyNewAccountPending,
477
+ verifyNewAccountStatus,
476
478
  isPasswordIFrameLoading,
477
479
  verifyNewAccountError,
478
480
  verifyOAuth,
479
481
  verifyFarcaster,
480
482
  verifyTelegram,
483
+ verifyTelegramStatus,
481
484
  onNewAuthState,
482
485
  isSetup2faPending,
483
486
  createGuestWallets,
@@ -1,6 +1,12 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { CommonChain, CommonWallet } from '@getpara/react-common';
3
- import { VerifyExternalWalletParams } from '@getpara/user-management-client';
2
+ import { BalanceManagement, ChainManagement, CommonWallet, ExternalWalletContextType, TExternalWallet } from '@getpara/react-common';
3
+ import { ExternalWalletInfo, VerifyExternalWalletParams } from '@getpara/web-sdk';
4
+ import { CosmosSignResult } from '@getpara/cosmos-wallet-connectors';
5
+ export declare const useWalletDisplayHelpers: (wallet: CommonWallet | undefined) => {
6
+ showExtension: boolean;
7
+ showMobile: boolean;
8
+ isCosmosMobileWallet: boolean;
9
+ };
4
10
  export declare const defaultExternalWallet: {
5
11
  wallets: never[];
6
12
  chains: never[];
@@ -11,7 +17,6 @@ export declare const defaultExternalWallet: {
11
17
  walletDisplayHelpers: {
12
18
  showExtension: boolean;
13
19
  showMobile: boolean;
14
- isSolanaMobileIOS: boolean;
15
20
  isCosmosMobileWallet: boolean;
16
21
  };
17
22
  username: undefined;
@@ -22,55 +27,33 @@ export declare const defaultExternalWallet: {
22
27
  setChainIdSwitchingTo: () => void;
23
28
  connectEmbeddedToExternalConnectors: () => Promise<void>;
24
29
  verifyWalletSignature: () => Promise<any>;
30
+ signMessage: () => Promise<any>;
31
+ isSigningMessage: boolean;
25
32
  getWalletBalance: () => Promise<undefined>;
26
33
  isExternalWalletVerifying: boolean;
34
+ requestInfo: (_: TExternalWallet) => Promise<ExternalWalletInfo>;
35
+ disconnectBase: (_: TExternalWallet) => Promise<void>;
27
36
  };
28
- export declare const ExternalWalletContext: import("react").Context<{
29
- wallets: CommonWallet[];
30
- chains: CommonChain[];
31
- chainId?: string;
37
+ type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 'signVerificationMessage'> & ChainManagement<string, void> & BalanceManagement & {
32
38
  wallet?: CommonWallet;
33
39
  qrUri?: string;
34
40
  chainIdSwitchingTo?: string;
35
41
  walletDisplayHelpers: {
36
42
  showExtension: boolean;
37
43
  showMobile: boolean;
38
- isSolanaMobileIOS: boolean;
39
44
  isCosmosMobileWallet: boolean;
40
45
  };
41
46
  username?: string;
42
47
  avatar?: string;
43
48
  connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => Promise<void>;
44
49
  disconnectExternalWallet: () => Promise<void>;
45
- switchChain: (chainId: string) => Promise<void>;
46
50
  setChainIdSwitchingTo: (chainId?: string) => void;
47
51
  connectEmbeddedToExternalConnectors: () => Promise<void>;
52
+ isSigningMessage: boolean;
48
53
  verifyWalletSignature: () => Promise<VerifyExternalWalletParams | undefined>;
49
- getWalletBalance: () => Promise<string | undefined>;
50
- isExternalWalletVerifying?: boolean;
51
- }>;
52
- export declare function ExternalWalletProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
53
- export declare const useExternalWallets: () => {
54
- wallets: CommonWallet[];
55
- chains: CommonChain[];
56
- chainId?: string;
57
- wallet?: CommonWallet;
58
- qrUri?: string;
59
- chainIdSwitchingTo?: string;
60
- walletDisplayHelpers: {
61
- showExtension: boolean;
62
- showMobile: boolean;
63
- isSolanaMobileIOS: boolean;
64
- isCosmosMobileWallet: boolean;
65
- };
66
- username?: string;
67
- avatar?: string;
68
- connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => Promise<void>;
69
- disconnectExternalWallet: () => Promise<void>;
70
- switchChain: (chainId: string) => Promise<void>;
71
- setChainIdSwitchingTo: (chainId?: string) => void;
72
- connectEmbeddedToExternalConnectors: () => Promise<void>;
73
- verifyWalletSignature: () => Promise<VerifyExternalWalletParams | undefined>;
74
- getWalletBalance: () => Promise<string | undefined>;
75
54
  isExternalWalletVerifying?: boolean;
76
55
  };
56
+ export declare const ExternalWalletContext: import("react").Context<Value>;
57
+ export declare function ExternalWalletProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
58
+ export declare const useExternalWallets: () => Value;
59
+ export {};
@@ -5,13 +5,29 @@ import {
5
5
  } from "../../chunk-MMUBH76A.js";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
8
- import { isIOS, isIOSWebview, isMobile, truncateAddress } from "@getpara/web-sdk";
8
+ import { isMobile, truncateAddress } from "@getpara/web-sdk";
9
9
  import { useInternalClient } from "../hooks/utils/useInternalClient.js";
10
10
  import { useStore } from "../stores/useStore.js";
11
11
  import { ModalStep } from "../../modal/index.js";
12
12
  import { useModalStore } from "../../modal/stores/index.js";
13
13
  import { useVerifyExternalWallet, useWalletState } from "../hooks/index.js";
14
+ import {
15
+ COSMOS_WALLETS,
16
+ EVM_WALLETS,
17
+ SOLANA_WALLETS
18
+ } from "@getpara/web-sdk";
14
19
  import { useAuthActions } from "./AuthProvider.js";
20
+ const useWalletDisplayHelpers = (wallet) => {
21
+ const isUsingMobileConnector = useModalStore((state) => state.isUsingMobileConnector);
22
+ return {
23
+ // Show the extension screen if on web and the wallet is an extension and installed or the wallet isn't a mobile wallet
24
+ // Also show the extension connection if on desktop for a solana wallet (no walletConnect)
25
+ showExtension: !isMobile() && ((wallet == null ? void 0 : wallet.isExtension) && (wallet == null ? void 0 : wallet.installed) || !(wallet == null ? void 0 : wallet.isMobile) || (wallet == null ? void 0 : wallet.type) === "SOLANA"),
26
+ // Show the mobile screen if on mobile and the wallet is a mobile wallet or if on desktop and the wallet isn't installed
27
+ showMobile: isMobile() && (wallet == null ? void 0 : wallet.isMobile) || !isMobile() && !(wallet == null ? void 0 : wallet.installed),
28
+ isCosmosMobileWallet: (wallet == null ? void 0 : wallet.type) === "COSMOS" && !!isUsingMobileConnector
29
+ };
30
+ };
15
31
  const defaultExternalWallet = {
16
32
  wallets: [],
17
33
  chains: [],
@@ -19,7 +35,7 @@ const defaultExternalWallet = {
19
35
  wallet: void 0,
20
36
  qrUri: void 0,
21
37
  chainIdSwitchingTo: void 0,
22
- walletDisplayHelpers: { showExtension: false, showMobile: false, isSolanaMobileIOS: false, isCosmosMobileWallet: false },
38
+ walletDisplayHelpers: { showExtension: false, showMobile: false, isCosmosMobileWallet: false },
23
39
  username: void 0,
24
40
  avatar: void 0,
25
41
  connectExternalWallet: () => Promise.resolve(),
@@ -29,8 +45,12 @@ const defaultExternalWallet = {
29
45
  },
30
46
  connectEmbeddedToExternalConnectors: () => Promise.resolve(),
31
47
  verifyWalletSignature: () => Promise.resolve({}),
48
+ signMessage: () => Promise.resolve({}),
49
+ isSigningMessage: false,
32
50
  getWalletBalance: () => Promise.resolve(void 0),
33
- isExternalWalletVerifying: false
51
+ isExternalWalletVerifying: false,
52
+ requestInfo: (_) => Promise.resolve({}),
53
+ disconnectBase: (_) => Promise.resolve()
34
54
  };
35
55
  const ExternalWalletContext = createContext(defaultExternalWallet);
36
56
  function ExternalWalletProvider({ children }) {
@@ -50,13 +70,19 @@ function ExternalWalletProvider({ children }) {
50
70
  username: evmUsername,
51
71
  avatar: evmAvatar,
52
72
  connectParaEmbedded: evmConnectParaEmbedded,
73
+ signMessage: evmSignMessage,
53
74
  signVerificationMessage: evmSignVerificationMessage,
54
- getWalletBalance: evmGetWalletBalance
75
+ getWalletBalance: evmGetWalletBalance,
76
+ requestInfo: evmRequestInfo,
77
+ disconnectBase: evmDisconnectBase
55
78
  } = useContext(evmContext);
56
79
  const {
57
80
  wallets: solanaWallets,
58
81
  disconnect: solanaDisconnect,
59
- signVerificationMessage: solanaSignVerificationMessage
82
+ signMessage: solanaSignMessage,
83
+ signVerificationMessage: solanaSignVerificationMessage,
84
+ requestInfo: solanaRequestInfo,
85
+ disconnectBase: solanaDisconnectBase
60
86
  } = useContext(solanaContext);
61
87
  const {
62
88
  wallets: cosmosWallets,
@@ -65,7 +91,10 @@ function ExternalWalletProvider({ children }) {
65
91
  chainId: cosmosChainId,
66
92
  switchChain: cosmosSwitchChain,
67
93
  connectParaEmbedded: cosmosConnectParaEmbedded,
68
- signVerificationMessage: cosmosSignVerificationMessage
94
+ signMessage: cosmosSignMessage,
95
+ signVerificationMessage: cosmosSignVerificationMessage,
96
+ requestInfo: cosmosRequestInfo,
97
+ disconnectBase: cosmosDisconnectBase
69
98
  } = useContext(cosmosContext);
70
99
  const onLoginRef = useStore((state) => state.onLoginRef);
71
100
  const setStep = useModalStore((state) => state.setStep);
@@ -76,7 +105,6 @@ function ExternalWalletProvider({ children }) {
76
105
  const selectedExternalWalletId = useModalStore((state) => state.selectedExternalWalletId);
77
106
  const setExternalWalletError = useModalStore((state) => state.setExternalWalletError);
78
107
  const setIsUsingMobileConnector = useModalStore((state) => state.setIsUsingMobileConnector);
79
- const isUsingMobileConnector = useModalStore((state) => state.isUsingMobileConnector);
80
108
  const para = useInternalClient();
81
109
  const { setSelectedWallet } = useWalletState();
82
110
  const { onNewAuthState } = useAuthActions();
@@ -84,6 +112,7 @@ function ExternalWalletProvider({ children }) {
84
112
  const [qrUri, setQrUri] = useState();
85
113
  const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
86
114
  const [isExternalWalletVerifying, setIsExternalWalletVerifying] = useState(false);
115
+ const [isSigningMessage, setIsSigningMessage] = useState(false);
87
116
  const wallets = [...evmWallets, ...solanaWallets, ...cosmosWallets].filter((w) => externalWallets.includes(w.id.toUpperCase())).sort(
88
117
  (a, b) => externalWallets.indexOf(a.id.toUpperCase()) - externalWallets.indexOf(b.id.toUpperCase())
89
118
  ).sort((a, b) => a.installed === b.installed ? 0 : a.installed ? -1 : 1);
@@ -193,6 +222,7 @@ function ExternalWalletProvider({ children }) {
193
222
  isConnectionOnly,
194
223
  withFullParaAuth,
195
224
  provider: wallet2.name,
225
+ providerId: wallet2.externalProviderId,
196
226
  isExternal: true
197
227
  };
198
228
  switch (walletType) {
@@ -277,6 +307,61 @@ function ExternalWalletProvider({ children }) {
277
307
  setIsExternalWalletVerifying(false);
278
308
  return void 0;
279
309
  }), [cosmosSignVerificationMessage, evmSignVerificationMessage, solanaSignVerificationMessage, wallet]);
310
+ const signMessage = useCallback(
311
+ (_0) => __async(this, [_0], function* ({ message, externalWallet: _externalWallet }) {
312
+ var _a;
313
+ setExternalWalletError();
314
+ setIsSigningMessage(true);
315
+ let externalWallet = _externalWallet;
316
+ const walletType = (externalWallet == null ? void 0 : externalWallet.type) || ((_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type);
317
+ let response;
318
+ try {
319
+ switch (walletType) {
320
+ case "COSMOS":
321
+ {
322
+ const { address, signature, error, cosmosPublicKeyHex, cosmosSigner } = yield cosmosSignMessage({
323
+ message,
324
+ externalWallet
325
+ });
326
+ if (error) {
327
+ throw new Error(error);
328
+ } else if (signature && address) {
329
+ response = { address, signature, cosmosPublicKeyHex, cosmosSigner };
330
+ }
331
+ }
332
+ break;
333
+ case "EVM":
334
+ {
335
+ const { address, signature, error } = yield evmSignMessage({ message, externalWallet });
336
+ if (error) {
337
+ throw new Error(error);
338
+ } else if (signature && address) {
339
+ response = { address, signature };
340
+ }
341
+ }
342
+ break;
343
+ case "SOLANA":
344
+ {
345
+ const { signature, error, address } = yield solanaSignMessage({ message });
346
+ if (error) {
347
+ throw new Error(error);
348
+ } else if (signature && address) {
349
+ response = { address, signature };
350
+ }
351
+ }
352
+ break;
353
+ default:
354
+ break;
355
+ }
356
+ setIsSigningMessage(false);
357
+ return response;
358
+ } catch (error) {
359
+ setIsSigningMessage(false);
360
+ throw error;
361
+ }
362
+ }),
363
+ [cosmosSignMessage, evmSignMessage, solanaSignMessage]
364
+ );
280
365
  const connectExternalWallet = useCallback(
281
366
  (wallet2, isMobileConnect, isManualWalletConnect, isResetAfterManualWalletConnect) => __async(this, null, function* () {
282
367
  if (isExternalWalletConnecting && isManualWalletConnect) {
@@ -312,6 +397,46 @@ function ExternalWalletProvider({ children }) {
312
397
  }),
313
398
  [isExternalWalletConnecting, externalWalletsWithFullAuth, connectionOnly, includeWalletVerification]
314
399
  );
400
+ const requestInfo = (providerId) => __async(this, null, function* () {
401
+ const [isEvm, isSolana, _isCosmos] = [
402
+ EVM_WALLETS.includes(providerId),
403
+ SOLANA_WALLETS.includes(providerId),
404
+ COSMOS_WALLETS.includes(providerId)
405
+ ];
406
+ switch (true) {
407
+ case isEvm: {
408
+ const externalWallet = yield evmRequestInfo(providerId);
409
+ return externalWallet;
410
+ }
411
+ case isSolana: {
412
+ const externalWallet = yield solanaRequestInfo(providerId);
413
+ return externalWallet;
414
+ }
415
+ default: {
416
+ const externalWallet = yield cosmosRequestInfo(providerId);
417
+ return externalWallet;
418
+ }
419
+ }
420
+ });
421
+ const disconnectBase = (providerId) => __async(this, null, function* () {
422
+ const [isEvm, isSolana, _isCosmos] = [
423
+ EVM_WALLETS.includes(providerId),
424
+ SOLANA_WALLETS.includes(providerId),
425
+ COSMOS_WALLETS.includes(providerId)
426
+ ];
427
+ switch (true) {
428
+ case isEvm:
429
+ yield evmDisconnectBase(providerId);
430
+ break;
431
+ case isSolana:
432
+ yield solanaDisconnectBase(providerId);
433
+ break;
434
+ default: {
435
+ yield cosmosDisconnectBase();
436
+ break;
437
+ }
438
+ }
439
+ });
315
440
  const disconnectExternalWallet = () => __async(this, null, function* () {
316
441
  yield para.logout();
317
442
  yield evmDisconnect();
@@ -319,15 +444,7 @@ function ExternalWalletProvider({ children }) {
319
444
  setSelectedExternalWalletId();
320
445
  yield solanaDisconnect();
321
446
  });
322
- const walletDisplayHelpers = {
323
- // Show the extension screen if on web and the wallet is an extension and installed or the wallet isn't a mobile wallet
324
- // Also show the extension connection if on desktop for a solana wallet (no walletConnect)
325
- showExtension: !isMobile() && ((wallet == null ? void 0 : wallet.isExtension) && (wallet == null ? void 0 : wallet.installed) || !(wallet == null ? void 0 : wallet.isMobile) || (wallet == null ? void 0 : wallet.type) === "SOLANA"),
326
- // Show the mobile screen if on mobile and the wallet is a mobile wallet or if on desktop and the wallet isn't installed
327
- showMobile: isMobile() && (wallet == null ? void 0 : wallet.isMobile) || !isMobile() && !(wallet == null ? void 0 : wallet.installed),
328
- isSolanaMobileIOS: isIOS() && isMobile() && !isIOSWebview() && (wallet == null ? void 0 : wallet.type) === "SOLANA",
329
- isCosmosMobileWallet: (wallet == null ? void 0 : wallet.type) === "COSMOS" && !!isUsingMobileConnector
330
- };
447
+ const walletDisplayHelpers = useWalletDisplayHelpers(wallet);
331
448
  const username = useMemo(() => {
332
449
  let username2;
333
450
  const storedExternalWallet = Object.values(para.externalWallets || {})[0];
@@ -361,31 +478,35 @@ function ExternalWalletProvider({ children }) {
361
478
  }
362
479
  }, [evmAvatar, wallet]);
363
480
  const connectEmbeddedToExternalConnectors = useCallback(() => __async(this, null, function* () {
364
- try {
365
- const { error } = yield evmConnectParaEmbedded();
366
- if (error) {
367
- console.warn("Failed to connect Para EVM wallet to Wagmi:", error);
368
- } else {
369
- const wallet2 = para.findWallet(void 0, void 0, { type: ["EVM"] });
370
- if (wallet2) {
371
- setSelectedWallet({ id: wallet2.id, type: "EVM" });
481
+ const evmWallet = para.findWallet(void 0, void 0, { type: ["EVM"] });
482
+ const cosmosWallet = para.findWallet(void 0, void 0, { type: ["COSMOS"] });
483
+ if (evmWallet) {
484
+ try {
485
+ const { error } = yield evmConnectParaEmbedded();
486
+ if (error) {
487
+ console.warn("Failed to connect Para EVM wallet to Wagmi:", error);
488
+ } else {
489
+ if (evmWallet) {
490
+ setSelectedWallet({ id: evmWallet.id, type: "EVM" });
491
+ }
372
492
  }
493
+ } catch (err) {
494
+ console.warn("Error calling connectParaEvmWallet:", err);
373
495
  }
374
- } catch (err) {
375
- console.warn("Error calling connectParaEvmWallet:", err);
376
496
  }
377
- try {
378
- const { error } = yield cosmosConnectParaEmbedded();
379
- if (error) {
380
- console.warn("Failed to connect Para Cosmos wallet to Graz:", error);
381
- } else {
382
- const wallet2 = para.findWallet(void 0, void 0, { type: ["COSMOS"] });
383
- if (wallet2) {
384
- setSelectedWallet({ id: wallet2.id, type: "COSMOS" });
497
+ if (cosmosWallet) {
498
+ try {
499
+ const { error } = yield cosmosConnectParaEmbedded();
500
+ if (error) {
501
+ console.warn("Failed to connect Para Cosmos wallet to Graz:", error);
502
+ } else {
503
+ if (cosmosWallet) {
504
+ setSelectedWallet({ id: cosmosWallet.id, type: "COSMOS" });
505
+ }
385
506
  }
507
+ } catch (err) {
508
+ console.warn("Error calling connectParaCosmosWallet:", err);
386
509
  }
387
- } catch (err) {
388
- console.warn("Error calling connectParaCosmosWallet:", err);
389
510
  }
390
511
  }), [evmConnectParaEmbedded, cosmosConnectParaEmbedded]);
391
512
  useEffect(() => {
@@ -412,9 +533,13 @@ function ExternalWalletProvider({ children }) {
412
533
  switchChain,
413
534
  setChainIdSwitchingTo,
414
535
  connectEmbeddedToExternalConnectors,
536
+ signMessage,
537
+ isSigningMessage,
415
538
  verifyWalletSignature,
416
539
  isExternalWalletVerifying,
417
- getWalletBalance
540
+ getWalletBalance,
541
+ requestInfo,
542
+ disconnectBase
418
543
  }),
419
544
  [
420
545
  wallets,
@@ -431,9 +556,13 @@ function ExternalWalletProvider({ children }) {
431
556
  switchChain,
432
557
  setChainIdSwitchingTo,
433
558
  connectEmbeddedToExternalConnectors,
559
+ signMessage,
560
+ isSigningMessage,
434
561
  verifyWalletSignature,
435
562
  isExternalWalletVerifying,
436
- getWalletBalance
563
+ getWalletBalance,
564
+ requestInfo,
565
+ disconnectBase
437
566
  ]
438
567
  ),
439
568
  children
@@ -445,5 +574,6 @@ export {
445
574
  ExternalWalletContext,
446
575
  ExternalWalletProvider,
447
576
  defaultExternalWallet,
448
- useExternalWallets
577
+ useExternalWallets,
578
+ useWalletDisplayHelpers
449
579
  };
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import "../../../chunk-MMUBH76A.js";
3
+ import { createRef } from "react";
3
4
  const createModalSlice = (set, get) => {
4
5
  var _a, _b, _c, _d, _e, _f, _g;
5
6
  return {
@@ -8,7 +9,8 @@ const createModalSlice = (set, get) => {
8
9
  isDarkTheme: ((_c = (_b = (_a = get()) == null ? void 0 : _a.modalConfig) == null ? void 0 : _b.theme) == null ? void 0 : _c.mode) === "dark",
9
10
  oAuthLogoVariant: (_g = (_f = (_e = (_d = get()) == null ? void 0 : _d.modalConfig) == null ? void 0 : _e.theme) == null ? void 0 : _f.oAuthLogoVariant) != null ? _g : "default",
10
11
  isOpen: false,
11
- setIsOpen: (isOpen) => set({ isOpen })
12
+ setIsOpen: (isOpen) => set({ isOpen }),
13
+ openedToStep: createRef()
12
14
  };
13
15
  };
14
16
  export {
@@ -3,7 +3,7 @@ import ParaWeb, { TWalletType } from '@getpara/web-sdk';
3
3
  import { EvmExternalWalletContextType, ParaEvmProvider, WalletList as EvmWalletList } from '@getpara/evm-wallet-connectors';
4
4
  import { CosmosExternalWalletContextType, ParaCosmosProvider, WalletList as CosmosWalletList } from '@getpara/cosmos-wallet-connectors';
5
5
  import { ParaSolanaProvider, SolanaExternalWalletContextType, WalletList as SolanaWalletList } from '@getpara/solana-wallet-connectors';
6
- import { ParaModalProps } from '../../modal/index.js';
6
+ import { ModalStep, ParaModalProps } from '../../modal/index.js';
7
7
  import { OAuthLogoVariantType } from '../../modal/types/modalProps.js';
8
8
  import { type TExternalWallet } from '@getpara/react-common';
9
9
  export interface ClientSlice {
@@ -25,6 +25,7 @@ export interface ModalSlice {
25
25
  oAuthLogoVariant: OAuthLogoVariantType;
26
26
  isOpen: boolean;
27
27
  setIsOpen: (_: boolean) => void;
28
+ openedToStep: MutableRefObject<ModalStep | null>;
28
29
  }
29
30
  export interface WalletSlice {
30
31
  rpcUrl?: string;
@@ -1,6 +1,6 @@
1
- import { CoreMethodName, CoreMethodParams, CoreMethodResponse, CoreMethods } from '@getpara/web-sdk';
1
+ import ParaWeb, { CoreMethodName, CoreMethodParams, CoreMethodResponse, CoreMethods, InternalMethodName, InternalMethodParams, InternalMethodResponse, InternalMethods } from '@getpara/web-sdk';
2
2
  import { UseMutationReturnType } from './query.js';
3
- import { UseMutateFunction, UseMutateAsyncFunction, MutationState, Mutation } from '@tanstack/react-query';
3
+ import { UseMutateFunction, UseMutateAsyncFunction, MutationState, Mutation, UseQueryResult, Query } from '@tanstack/react-query';
4
4
  export type Compute<type> = {
5
5
  [key in keyof type]: type[key];
6
6
  } & unknown;
@@ -8,19 +8,38 @@ export type Compute<type> = {
8
8
  export type StrictOmit<type, keys extends keyof type> = Pick<type, Exclude<keyof type, keys>>;
9
9
  export type UnionStrictOmit<type, keys extends keyof type> = type extends any ? StrictOmit<type, keys> : never;
10
10
  export type ChangeFields<T, R> = Omit<T, keyof R> & R;
11
- type SyncHook<method extends CoreMethodName & keyof CoreMethods> = {
11
+ type CoreSyncMutationHook<method extends CoreMethodName & keyof CoreMethods> = {
12
12
  mutate: UseMutateFunction<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
13
13
  } & {
14
14
  [K in method]: UseMutateFunction<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
15
15
  };
16
- type AsyncHook<method extends CoreMethodName & keyof CoreMethods> = {
16
+ type CoreAsyncMutationHook<method extends CoreMethodName & keyof CoreMethods> = {
17
17
  mutateAsync: UseMutateAsyncFunction<CoreMethodResponse<method>, Error, CoreMethodParams<method> | void, unknown>;
18
18
  } & {
19
19
  [K in `${method}Async`]: UseMutateAsyncFunction<CoreMethodResponse<method>, Error, CoreMethodParams<method> | void, unknown>;
20
20
  };
21
21
  export type CoreMethodUseMutationReturnType<method extends CoreMethodName & keyof CoreMethods> = UseMutationReturnType<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
22
22
  export type CoreMethodMutation<method extends CoreMethodName & keyof CoreMethods> = Mutation<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
23
+ export type CoreMethodQuery<method extends CoreMethodName & keyof CoreMethods> = Query<Awaited<CoreMethodResponse<method>>, Error>;
24
+ export type CoreGetterQuery<name extends keyof typeof ParaWeb> = Query<(typeof ParaWeb)[name] | null, Error>;
23
25
  export type CoreMethodMutationState<method extends CoreMethodName & keyof CoreMethods> = MutationState<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
24
- export type CoreMethodHook<method extends CoreMethodName & keyof CoreMethods> = Compute<CoreMethodUseMutationReturnType<method> & SyncHook<method> & AsyncHook<method>>;
25
- export type CoreMethodStateHook<method extends CoreMethodName & keyof CoreMethods> = () => Omit<CoreMethodUseMutationReturnType<method>, 'reset'>;
26
+ export type CoreMethodMutationHook<method extends CoreMethodName & keyof CoreMethods> = Compute<CoreMethodUseMutationReturnType<method> & CoreSyncMutationHook<method> & CoreAsyncMutationHook<method>>;
27
+ export type CoreMethodQueryHook<method extends CoreMethodName & keyof CoreMethods> = UseQueryResult<Awaited<CoreMethodResponse<method>>, Error>;
28
+ export type CoreGetterQueryHook<name extends keyof typeof ParaWeb> = UseQueryResult<(typeof ParaWeb)[name] | null, Error>;
29
+ export type CoreMethodMutationStateHook<method extends CoreMethodName & keyof CoreMethods> = () => Omit<CoreMethodUseMutationReturnType<method>, 'reset'>;
30
+ type InternalSyncMutationHook<method extends InternalMethodName & keyof InternalMethods> = {
31
+ mutate: UseMutateFunction<Awaited<InternalMethodResponse<method>>, Error, InternalMethodParams<method> | void, unknown>;
32
+ };
33
+ type InternalAsyncMutationHook<method extends InternalMethodName & keyof InternalMethods> = {
34
+ mutateAsync: UseMutateAsyncFunction<InternalMethodResponse<method>, Error, InternalMethodParams<method> | void, unknown>;
35
+ };
36
+ export type InternalMethodUseMutationReturnType<method extends InternalMethodName & keyof InternalMethods> = UseMutationReturnType<Awaited<InternalMethodResponse<method>>, Error, InternalMethodParams<method> | void, unknown>;
37
+ export type InternalMethodMutation<method extends InternalMethodName & keyof InternalMethods> = Mutation<Awaited<InternalMethodResponse<method>>, Error, InternalMethodParams<method> | void, unknown>;
38
+ export type InternalMethodQuery<method extends InternalMethodName & keyof InternalMethods> = Query<Awaited<InternalMethodResponse<method>>, Error>;
39
+ export type InternalGetterQuery<name extends keyof typeof ParaWeb> = Query<(typeof ParaWeb)[name] | null, Error>;
40
+ export type InternalMethodMutationState<method extends InternalMethodName & keyof InternalMethods> = MutationState<Awaited<InternalMethodResponse<method>>, Error, InternalMethodParams<method> | void, unknown>;
41
+ export type InternalMethodMutationHook<method extends InternalMethodName & keyof InternalMethods> = Compute<InternalMethodUseMutationReturnType<method> & InternalSyncMutationHook<method> & InternalAsyncMutationHook<method>>;
42
+ export type InternalMethodQueryHook<method extends InternalMethodName & keyof InternalMethods> = UseQueryResult<Awaited<InternalMethodResponse<method>>, Error>;
43
+ export type InternalGetterQueryHook<name extends keyof typeof ParaWeb> = UseQueryResult<(typeof ParaWeb)[name] | null, Error>;
44
+ export type InternalMethodMutationStateHook<method extends InternalMethodName & keyof InternalMethods> = () => Omit<InternalMethodUseMutationReturnType<method>, 'reset'>;
26
45
  export {};
@@ -1,5 +1,5 @@
1
1
  import { CoreMethodName, CoreMethodParams, CoreMethodResponse, CoreMethods } from '@getpara/web-sdk';
2
2
  import { DefaultError, UseMutationResult } from '@tanstack/react-query';
3
- import { CoreMethodHook } from '../types/utils.js';
3
+ import { CoreMethodMutationHook } from '../types/utils.js';
4
4
  export declare function renameMutations<TResp = unknown, TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(mutationObj: UseMutationResult<TData, TError, TVariables, TContext>, name: string): TResp;
5
- export declare function renameCoreMutations<method extends CoreMethodName & keyof CoreMethods>(mutationObj: UseMutationResult<CoreMethodResponse<method>, Error, CoreMethodParams<method> | undefined, unknown>, name: method): CoreMethodHook<method>;
5
+ export declare function renameCoreMutations<method extends CoreMethodName & keyof CoreMethods>(mutationObj: UseMutationResult<CoreMethodResponse<method>, Error, CoreMethodParams<method> | undefined, unknown>, name: method): CoreMethodMutationHook<method>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk",
3
- "version": "2.0.0-alpha.19",
3
+ "version": "2.0.0-alpha.21",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,9 +15,9 @@
15
15
  "*.css"
16
16
  ],
17
17
  "dependencies": {
18
- "@getpara/react-common": "2.0.0-alpha.19",
19
- "@getpara/react-components": "2.0.0-alpha.19",
20
- "@getpara/web-sdk": "2.0.0-alpha.19",
18
+ "@getpara/react-common": "2.0.0-alpha.21",
19
+ "@getpara/react-components": "2.0.0-alpha.21",
20
+ "@getpara/web-sdk": "2.0.0-alpha.21",
21
21
  "date-fns": "^3.6.0",
22
22
  "framer-motion": "11.3.28",
23
23
  "libphonenumber-js": "^1.11.1",
@@ -33,9 +33,9 @@
33
33
  "cli": "node ./dist/cli/cli.mjs"
34
34
  },
35
35
  "devDependencies": {
36
- "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.19",
37
- "@getpara/evm-wallet-connectors": "2.0.0-alpha.19",
38
- "@getpara/solana-wallet-connectors": "2.0.0-alpha.19",
36
+ "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.21",
37
+ "@getpara/evm-wallet-connectors": "2.0.0-alpha.21",
38
+ "@getpara/solana-wallet-connectors": "2.0.0-alpha.21",
39
39
  "@testing-library/dom": "^10.4.0",
40
40
  "@testing-library/react": "^16.3.0",
41
41
  "@testing-library/react-hooks": "^8.0.1",
@@ -63,5 +63,5 @@
63
63
  "resolutions": {
64
64
  "styled-components": "^6"
65
65
  },
66
- "gitHead": "80d2c5d7e1203fb12378aa29bfd4d7003c7d7075"
66
+ "gitHead": "03daa3537312bc52e0640225c8abdbf8047c15da"
67
67
  }