@getpara/react-sdk 2.0.0-alpha.20 → 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.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -5
- package/dist/modal/ParaModal.js +15 -5
- package/dist/modal/components/Account/Account.js +14 -8
- package/dist/modal/components/Account/AccountProfile.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfile.js +170 -0
- package/dist/modal/components/Account/AccountProfileLink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLink.js +205 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.js +98 -0
- package/dist/modal/components/Account/AccountProfileUnlink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileUnlink.js +47 -0
- package/dist/modal/components/AuthInput/AuthInput.d.ts +17 -3
- package/dist/modal/components/AuthInput/AuthInput.js +116 -101
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +2 -2
- package/dist/modal/components/AuthOptions/AuthOptions.js +26 -1
- package/dist/modal/components/Body/Body.js +21 -2
- package/dist/modal/components/Controls/Selects.js +3 -19
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +7 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +70 -39
- package/dist/modal/components/Header/hooks/useStepTitle.js +7 -1
- package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -2
- package/dist/modal/components/OAuth/OAuth.js +2 -2
- package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +7 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +36 -52
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +12 -1
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +40 -23
- package/dist/modal/components/common.d.ts +18 -1
- package/dist/modal/components/common.js +86 -0
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/constants.js +1 -1
- package/dist/modal/constants/oAuthLogos.d.ts +15 -6
- package/dist/modal/constants/oAuthLogos.js +148 -19
- package/dist/modal/hooks/useTelegramLogin.d.ts +12 -0
- package/dist/modal/hooks/useTelegramLogin.js +65 -0
- package/dist/modal/stores/modal/actions.js +6 -1
- package/dist/modal/stores/modal/useModalStore.d.ts +4 -3
- package/dist/modal/stores/modal/useModalStore.js +7 -2
- package/dist/modal/types/modalProps.d.ts +6 -1
- package/dist/modal/utils/authInputHelpers.d.ts +3 -5
- package/dist/modal/utils/authInputHelpers.js +23 -20
- package/dist/modal/utils/getWalletDisplayName.d.ts +5 -0
- package/dist/modal/utils/getWalletDisplayName.js +22 -0
- package/dist/modal/utils/steps.d.ts +10 -2
- package/dist/modal/utils/steps.js +18 -2
- package/dist/provider/ParaProvider.js +6 -5
- package/dist/provider/actions/index.d.ts +19 -0
- package/dist/provider/actions/index.js +47 -29
- package/dist/provider/actions/utils.d.ts +3 -2
- package/dist/provider/actions/utils.js +25 -6
- package/dist/provider/components/CosmosWalletWrapper.js +2 -2
- package/dist/provider/components/EvmWalletWrapper.js +2 -2
- package/dist/provider/components/ExternalWalletWrapper.js +2 -1
- package/dist/provider/components/SolanaWalletWrapper.js +2 -2
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +0 -10
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +2 -12
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +0 -1
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +2 -15
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +0 -6
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +2 -8
- package/dist/provider/hooks/mutations/core.d.ts +27 -0
- package/dist/provider/hooks/mutations/core.js +66 -0
- package/dist/provider/hooks/mutations/index.d.ts +3 -28
- package/dist/provider/hooks/mutations/index.js +4 -60
- package/dist/provider/hooks/mutations/useLinkAccount.d.ts +9 -0
- package/dist/provider/hooks/mutations/useLinkAccount.js +18 -0
- package/dist/provider/hooks/mutations/utils.d.ts +11 -4
- package/dist/provider/hooks/mutations/utils.js +35 -4
- package/dist/provider/hooks/queries/core.d.ts +2 -0
- package/dist/provider/hooks/queries/core.js +13 -0
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +1 -0
- package/dist/provider/hooks/queries/utils.d.ts +4 -0
- package/dist/provider/hooks/queries/utils.js +24 -0
- package/dist/provider/hooks/utils/useModal.d.ts +4 -1
- package/dist/provider/hooks/utils/useModal.js +12 -2
- package/dist/provider/providers/AccountLinkProvider.d.ts +42 -0
- package/dist/provider/providers/AccountLinkProvider.js +443 -0
- package/dist/provider/providers/AuthProvider.d.ts +3 -1
- package/dist/provider/providers/AuthProvider.js +8 -5
- package/dist/provider/providers/ExternalWalletProvider.d.ts +18 -32
- package/dist/provider/providers/ExternalWalletProvider.js +167 -36
- package/dist/provider/stores/slices/modal.js +3 -1
- package/dist/provider/stores/types.d.ts +2 -1
- package/dist/provider/types/utils.d.ts +25 -6
- package/dist/provider/utils/renameMutations.d.ts +2 -2
- package/package.json +8 -8
|
@@ -40,7 +40,7 @@ const AuthContext = createContext({
|
|
|
40
40
|
isSignUpOrLogInPending: false,
|
|
41
41
|
verifyNewAccount: () => {
|
|
42
42
|
},
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
3
|
-
import { VerifyExternalWalletParams } from '@getpara/
|
|
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[];
|
|
@@ -21,13 +27,14 @@ export declare const defaultExternalWallet: {
|
|
|
21
27
|
setChainIdSwitchingTo: () => void;
|
|
22
28
|
connectEmbeddedToExternalConnectors: () => Promise<void>;
|
|
23
29
|
verifyWalletSignature: () => Promise<any>;
|
|
30
|
+
signMessage: () => Promise<any>;
|
|
31
|
+
isSigningMessage: boolean;
|
|
24
32
|
getWalletBalance: () => Promise<undefined>;
|
|
25
33
|
isExternalWalletVerifying: boolean;
|
|
34
|
+
requestInfo: (_: TExternalWallet) => Promise<ExternalWalletInfo>;
|
|
35
|
+
disconnectBase: (_: TExternalWallet) => Promise<void>;
|
|
26
36
|
};
|
|
27
|
-
|
|
28
|
-
wallets: CommonWallet[];
|
|
29
|
-
chains: CommonChain[];
|
|
30
|
-
chainId?: string;
|
|
37
|
+
type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 'signVerificationMessage'> & ChainManagement<string, void> & BalanceManagement & {
|
|
31
38
|
wallet?: CommonWallet;
|
|
32
39
|
qrUri?: string;
|
|
33
40
|
chainIdSwitchingTo?: string;
|
|
@@ -40,34 +47,13 @@ export declare const ExternalWalletContext: import("react").Context<{
|
|
|
40
47
|
avatar?: string;
|
|
41
48
|
connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => Promise<void>;
|
|
42
49
|
disconnectExternalWallet: () => Promise<void>;
|
|
43
|
-
switchChain: (chainId: string) => Promise<void>;
|
|
44
50
|
setChainIdSwitchingTo: (chainId?: string) => void;
|
|
45
51
|
connectEmbeddedToExternalConnectors: () => Promise<void>;
|
|
52
|
+
isSigningMessage: boolean;
|
|
46
53
|
verifyWalletSignature: () => Promise<VerifyExternalWalletParams | undefined>;
|
|
47
|
-
getWalletBalance: () => Promise<string | undefined>;
|
|
48
|
-
isExternalWalletVerifying?: boolean;
|
|
49
|
-
}>;
|
|
50
|
-
export declare function ExternalWalletProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
51
|
-
export declare const useExternalWallets: () => {
|
|
52
|
-
wallets: CommonWallet[];
|
|
53
|
-
chains: CommonChain[];
|
|
54
|
-
chainId?: string;
|
|
55
|
-
wallet?: CommonWallet;
|
|
56
|
-
qrUri?: string;
|
|
57
|
-
chainIdSwitchingTo?: string;
|
|
58
|
-
walletDisplayHelpers: {
|
|
59
|
-
showExtension: boolean;
|
|
60
|
-
showMobile: boolean;
|
|
61
|
-
isCosmosMobileWallet: boolean;
|
|
62
|
-
};
|
|
63
|
-
username?: string;
|
|
64
|
-
avatar?: string;
|
|
65
|
-
connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => Promise<void>;
|
|
66
|
-
disconnectExternalWallet: () => Promise<void>;
|
|
67
|
-
switchChain: (chainId: string) => Promise<void>;
|
|
68
|
-
setChainIdSwitchingTo: (chainId?: string) => void;
|
|
69
|
-
connectEmbeddedToExternalConnectors: () => Promise<void>;
|
|
70
|
-
verifyWalletSignature: () => Promise<VerifyExternalWalletParams | undefined>;
|
|
71
|
-
getWalletBalance: () => Promise<string | undefined>;
|
|
72
54
|
isExternalWalletVerifying?: boolean;
|
|
73
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 {};
|
|
@@ -11,7 +11,23 @@ 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: [],
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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,14 +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
|
-
isCosmosMobileWallet: (wallet == null ? void 0 : wallet.type) === "COSMOS" && !!isUsingMobileConnector
|
|
329
|
-
};
|
|
447
|
+
const walletDisplayHelpers = useWalletDisplayHelpers(wallet);
|
|
330
448
|
const username = useMemo(() => {
|
|
331
449
|
let username2;
|
|
332
450
|
const storedExternalWallet = Object.values(para.externalWallets || {})[0];
|
|
@@ -360,31 +478,35 @@ function ExternalWalletProvider({ children }) {
|
|
|
360
478
|
}
|
|
361
479
|
}, [evmAvatar, wallet]);
|
|
362
480
|
const connectEmbeddedToExternalConnectors = useCallback(() => __async(this, null, function* () {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
+
}
|
|
371
492
|
}
|
|
493
|
+
} catch (err) {
|
|
494
|
+
console.warn("Error calling connectParaEvmWallet:", err);
|
|
372
495
|
}
|
|
373
|
-
} catch (err) {
|
|
374
|
-
console.warn("Error calling connectParaEvmWallet:", err);
|
|
375
496
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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
|
+
}
|
|
384
506
|
}
|
|
507
|
+
} catch (err) {
|
|
508
|
+
console.warn("Error calling connectParaCosmosWallet:", err);
|
|
385
509
|
}
|
|
386
|
-
} catch (err) {
|
|
387
|
-
console.warn("Error calling connectParaCosmosWallet:", err);
|
|
388
510
|
}
|
|
389
511
|
}), [evmConnectParaEmbedded, cosmosConnectParaEmbedded]);
|
|
390
512
|
useEffect(() => {
|
|
@@ -411,9 +533,13 @@ function ExternalWalletProvider({ children }) {
|
|
|
411
533
|
switchChain,
|
|
412
534
|
setChainIdSwitchingTo,
|
|
413
535
|
connectEmbeddedToExternalConnectors,
|
|
536
|
+
signMessage,
|
|
537
|
+
isSigningMessage,
|
|
414
538
|
verifyWalletSignature,
|
|
415
539
|
isExternalWalletVerifying,
|
|
416
|
-
getWalletBalance
|
|
540
|
+
getWalletBalance,
|
|
541
|
+
requestInfo,
|
|
542
|
+
disconnectBase
|
|
417
543
|
}),
|
|
418
544
|
[
|
|
419
545
|
wallets,
|
|
@@ -430,9 +556,13 @@ function ExternalWalletProvider({ children }) {
|
|
|
430
556
|
switchChain,
|
|
431
557
|
setChainIdSwitchingTo,
|
|
432
558
|
connectEmbeddedToExternalConnectors,
|
|
559
|
+
signMessage,
|
|
560
|
+
isSigningMessage,
|
|
433
561
|
verifyWalletSignature,
|
|
434
562
|
isExternalWalletVerifying,
|
|
435
|
-
getWalletBalance
|
|
563
|
+
getWalletBalance,
|
|
564
|
+
requestInfo,
|
|
565
|
+
disconnectBase
|
|
436
566
|
]
|
|
437
567
|
),
|
|
438
568
|
children
|
|
@@ -444,5 +574,6 @@ export {
|
|
|
444
574
|
ExternalWalletContext,
|
|
445
575
|
ExternalWalletProvider,
|
|
446
576
|
defaultExternalWallet,
|
|
447
|
-
useExternalWallets
|
|
577
|
+
useExternalWallets,
|
|
578
|
+
useWalletDisplayHelpers
|
|
448
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
|
|
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
|
|
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
|
|
25
|
-
export type
|
|
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 {
|
|
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):
|
|
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.
|
|
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
|
-
"@getpara/react-components": "2.0.0-alpha.
|
|
20
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
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.
|
|
37
|
-
"@getpara/evm-wallet-connectors": "2.0.0-alpha.
|
|
38
|
-
"@getpara/solana-wallet-connectors": "2.0.0-alpha.
|
|
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": "
|
|
66
|
+
"gitHead": "03daa3537312bc52e0640225c8abdbf8047c15da"
|
|
67
67
|
}
|