@getpara/react-sdk-lite 2.0.0-alpha.52 → 2.0.0-alpha.54
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/cli/cli.mjs +0 -0
- package/dist/modal/ParaModal.js +5 -5
- package/dist/modal/components/Account/Account.js +4 -3
- package/dist/modal/components/Account/AccountHeader.js +10 -16
- package/dist/modal/components/Account/AccountProfile.js +33 -4
- package/dist/modal/components/Account/AccountProfileLink.js +3 -3
- package/dist/modal/components/AddFunds/AddFundsAsset.js +5 -2
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +5 -5
- package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.d.ts +1 -0
- package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.js +20 -0
- package/dist/modal/components/Body/Body.js +88 -37
- package/dist/modal/components/Header/hooks/useStepTitle.js +2 -1
- package/dist/modal/components/OAuth/FarcasterLink.d.ts +2 -0
- package/dist/modal/components/OAuth/FarcasterLink.js +30 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -3
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +47 -26
- package/dist/modal/components/OAuth/OAuth.js +2 -2
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +35 -19
- package/dist/modal/components/common.d.ts +3 -3
- package/dist/modal/constants/constants.d.ts +8 -8
- package/dist/modal/constants/constants.js +25 -25
- package/dist/modal/hooks/useFarcasterLogin.d.ts +9 -0
- package/dist/modal/hooks/useFarcasterLogin.js +70 -0
- package/dist/modal/hooks/useTelegramLogin.d.ts +4 -3
- package/dist/modal/hooks/useTelegramLogin.js +11 -3
- package/dist/modal/stores/modal/actions.js +1 -0
- package/dist/modal/stores/modal/useModalStore.d.ts +2 -0
- package/dist/modal/stores/modal/useModalStore.js +1 -0
- package/dist/modal/types/modalProps.d.ts +5 -1
- package/dist/modal/utils/renderTextWithLinks.d.ts +2 -0
- package/dist/modal/utils/renderTextWithLinks.js +34 -0
- package/dist/modal/utils/steps.d.ts +6 -3
- package/dist/modal/utils/steps.js +14 -8
- package/dist/modal/utils/stringFormatters.d.ts +2 -3
- package/dist/modal/utils/stringFormatters.js +0 -5
- package/dist/provider/ParaProviderMin.js +6 -2
- package/dist/provider/actions/index.d.ts +9 -9
- package/dist/provider/components/ExternalWalletWrapper.js +5 -0
- package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +3 -3
- package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +3 -3
- package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +6 -3
- package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +3 -3
- package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +3 -3
- package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +9 -6
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +2 -0
- package/dist/provider/hooks/queries/useLinkedAccounts.js +4 -2
- package/dist/provider/hooks/queries/useProfileBalance.d.ts +25 -0
- package/dist/provider/hooks/queries/useProfileBalance.js +60 -0
- package/dist/provider/hooks/utils/useAssetInfo.d.ts +3 -0
- package/dist/provider/hooks/utils/useAssetInfo.js +21 -0
- package/dist/provider/hooks/utils/useEventListeners.js +11 -1
- package/dist/provider/hooks/utils/useModal.js +3 -3
- package/dist/provider/providers/AssetsProvider.d.ts +14 -0
- package/dist/provider/providers/AssetsProvider.js +68 -0
- package/dist/provider/providers/AuthProvider.d.ts +6 -4
- package/dist/provider/providers/AuthProvider.js +120 -52
- package/dist/provider/stores/slices/modal.js +4 -1
- package/dist/provider/stores/types.d.ts +4 -1
- package/package.json +8 -8
- package/dist/modal/components/AwaitingIFrameStep/AwaitingIFrameStep.d.ts +0 -1
- package/dist/modal/components/AwaitingIFrameStep/AwaitingIFrameStep.js +0 -12
|
@@ -40,7 +40,8 @@ var ModalStep = /* @__PURE__ */ ((ModalStep2) => {
|
|
|
40
40
|
ModalStep2["ACCOUNT_PROFILE_ADD"] = "ACCOUNT_PROFILE_ADD";
|
|
41
41
|
ModalStep2["ACCOUNT_PROFILE_LIST"] = "ACCOUNT_PROFILE_LIST";
|
|
42
42
|
ModalStep2["ACCOUNT_PROFILE_REMOVE"] = "ACCOUNT_PROFILE_REMOVE";
|
|
43
|
-
ModalStep2["
|
|
43
|
+
ModalStep2["AWAITING_ACCOUNT"] = "AWAITING_ACCOUNT";
|
|
44
|
+
ModalStep2["OTP"] = "OTP";
|
|
44
45
|
return ModalStep2;
|
|
45
46
|
})(ModalStep || {});
|
|
46
47
|
var AccountStep = /* @__PURE__ */ ((AccountStep2) => {
|
|
@@ -72,7 +73,7 @@ const RESET_TO_AUTH_STEPS = [
|
|
|
72
73
|
"AWAITING_BIOMETRIC_CREATION" /* AWAITING_BIOMETRIC_CREATION */,
|
|
73
74
|
"PASSWORD_CREATION" /* PASSWORD_CREATION */,
|
|
74
75
|
"AWAITING_PASSWORD_CREATION" /* AWAITING_PASSWORD_CREATION */,
|
|
75
|
-
"
|
|
76
|
+
"AWAITING_ACCOUNT" /* AWAITING_ACCOUNT */,
|
|
76
77
|
"BIOMETRIC_LOGIN" /* BIOMETRIC_LOGIN */,
|
|
77
78
|
"EMBEDDED_PASSWORD_LOGIN" /* EMBEDDED_PASSWORD_LOGIN */,
|
|
78
79
|
"AWAITING_BIOMETRIC_LOGIN" /* AWAITING_BIOMETRIC_LOGIN */,
|
|
@@ -83,7 +84,8 @@ const RESET_TO_AUTH_STEPS = [
|
|
|
83
84
|
"SETUP_2FA" /* SETUP_2FA */,
|
|
84
85
|
"VERIFY_2FA" /* VERIFY_2FA */,
|
|
85
86
|
"TWO_FACTOR_DONE" /* TWO_FACTOR_DONE */,
|
|
86
|
-
"LOGIN_DONE" /* LOGIN_DONE
|
|
87
|
+
"LOGIN_DONE" /* LOGIN_DONE */,
|
|
88
|
+
"OTP" /* OTP */
|
|
87
89
|
];
|
|
88
90
|
const RESET_TO_ACCOUNT_STEPS = [
|
|
89
91
|
"AUTH_GUEST_SIGNUP" /* AUTH_GUEST_SIGNUP */,
|
|
@@ -141,7 +143,8 @@ var SignUpModalStep = /* @__PURE__ */ ((SignUpModalStep2) => {
|
|
|
141
143
|
SignUpModalStep2["ADD_FUNDS_AWAITING"] = "ADD_FUNDS_AWAITING";
|
|
142
144
|
SignUpModalStep2["ADD_FUNDS_SUCCESS"] = "ADD_FUNDS_SUCCESS";
|
|
143
145
|
SignUpModalStep2["ADD_FUNDS_FAILURE"] = "ADD_FUNDS_FAILURE";
|
|
144
|
-
SignUpModalStep2["
|
|
146
|
+
SignUpModalStep2["AWAITING_ACCOUNT"] = "AWAITING_ACCOUNT";
|
|
147
|
+
SignUpModalStep2["OTP"] = "OTP";
|
|
145
148
|
return SignUpModalStep2;
|
|
146
149
|
})(SignUpModalStep || {});
|
|
147
150
|
const SignUpPreviousStep = {
|
|
@@ -171,7 +174,8 @@ const SignUpPreviousStep = {
|
|
|
171
174
|
["ADD_FUNDS_AWAITING" /* ADD_FUNDS_AWAITING */]: "ADD_FUNDS_BUY" /* ADD_FUNDS_BUY */,
|
|
172
175
|
["ADD_FUNDS_SUCCESS" /* ADD_FUNDS_SUCCESS */]: void 0,
|
|
173
176
|
["ADD_FUNDS_FAILURE" /* ADD_FUNDS_FAILURE */]: void 0,
|
|
174
|
-
["
|
|
177
|
+
["AWAITING_ACCOUNT" /* AWAITING_ACCOUNT */]: "AUTH_MAIN" /* AUTH_MAIN */,
|
|
178
|
+
["OTP" /* OTP */]: "AUTH_MAIN" /* AUTH_MAIN */
|
|
175
179
|
};
|
|
176
180
|
const GuestPreviousStep = Object.fromEntries([
|
|
177
181
|
...Object.entries(SignUpPreviousStep).map(([key, value]) => {
|
|
@@ -208,7 +212,8 @@ var LoginModalStep = /* @__PURE__ */ ((LoginModalStep2) => {
|
|
|
208
212
|
LoginModalStep2["ADD_FUNDS_AWAITING"] = "ADD_FUNDS_AWAITING";
|
|
209
213
|
LoginModalStep2["ADD_FUNDS_SUCCESS"] = "ADD_FUNDS_SUCCESS";
|
|
210
214
|
LoginModalStep2["ADD_FUNDS_FAILURE"] = "ADD_FUNDS_FAILURE";
|
|
211
|
-
LoginModalStep2["
|
|
215
|
+
LoginModalStep2["AWAITING_ACCOUNT"] = "AWAITING_ACCOUNT";
|
|
216
|
+
LoginModalStep2["OTP"] = "OTP";
|
|
212
217
|
return LoginModalStep2;
|
|
213
218
|
})(LoginModalStep || {});
|
|
214
219
|
const LoginPreviousStep = {
|
|
@@ -237,7 +242,8 @@ const LoginPreviousStep = {
|
|
|
237
242
|
["ADD_FUNDS_AWAITING" /* ADD_FUNDS_AWAITING */]: "ADD_FUNDS_BUY" /* ADD_FUNDS_BUY */,
|
|
238
243
|
["ADD_FUNDS_SUCCESS" /* ADD_FUNDS_SUCCESS */]: void 0,
|
|
239
244
|
["ADD_FUNDS_FAILURE" /* ADD_FUNDS_FAILURE */]: void 0,
|
|
240
|
-
["
|
|
245
|
+
["AWAITING_ACCOUNT" /* AWAITING_ACCOUNT */]: "AUTH_MAIN" /* AUTH_MAIN */,
|
|
246
|
+
["OTP" /* OTP */]: "AUTH_MAIN" /* AUTH_MAIN */
|
|
241
247
|
};
|
|
242
248
|
const getStepHasFooter = (step) => {
|
|
243
249
|
switch (step) {
|
|
@@ -264,7 +270,7 @@ function getAddFundsStep(currentTab) {
|
|
|
264
270
|
return "ADD_FUNDS_WITHDRAW" /* ADD_FUNDS_WITHDRAW */;
|
|
265
271
|
}
|
|
266
272
|
}
|
|
267
|
-
const IFrameSteps = ["PASSWORD_CREATION" /* PASSWORD_CREATION */, "EMBEDDED_PASSWORD_LOGIN" /* EMBEDDED_PASSWORD_LOGIN */];
|
|
273
|
+
const IFrameSteps = ["PASSWORD_CREATION" /* PASSWORD_CREATION */, "EMBEDDED_PASSWORD_LOGIN" /* EMBEDDED_PASSWORD_LOGIN */, "OTP" /* OTP */];
|
|
268
274
|
export {
|
|
269
275
|
AccountPreviousStep,
|
|
270
276
|
GuestPreviousStep,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const formatNetworkList: (networks:
|
|
1
|
+
import { TNetwork } from '@getpara/web-sdk';
|
|
2
|
+
export declare const formatNetworkList: (networks: TNetwork[]) => string;
|
|
3
3
|
export declare const formatWalletCreatedDate: (date: string) => string;
|
|
4
4
|
export declare const camelToSnakeCase: (str: string) => string;
|
|
5
|
-
export declare const formatBalanceString: (str: string) => string;
|
|
@@ -7,13 +7,8 @@ const formatNetworkList = (networks) => {
|
|
|
7
7
|
};
|
|
8
8
|
const formatWalletCreatedDate = (date) => `${format(new Date(date), "M/d/y")}`;
|
|
9
9
|
const camelToSnakeCase = (str) => str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
10
|
-
const formatBalanceString = (str) => {
|
|
11
|
-
const numericBalance = parseFloat(str);
|
|
12
|
-
return `$${numericBalance.toLocaleString(void 0, { maximumFractionDigits: 2 })}`;
|
|
13
|
-
};
|
|
14
10
|
export {
|
|
15
11
|
camelToSnakeCase,
|
|
16
|
-
formatBalanceString,
|
|
17
12
|
formatNetworkList,
|
|
18
13
|
formatWalletCreatedDate
|
|
19
14
|
};
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { forwardRef, useEffect, useState } from "react";
|
|
8
8
|
import { useStore } from "./stores/useStore.js";
|
|
9
|
+
import { useModalStore } from "../modal/stores/index.js";
|
|
9
10
|
import { useAutoSessionKeepAlive } from "./hooks/utils/useAutoSessionKeepAlive.js";
|
|
10
11
|
import { useEventListeners } from "./hooks/utils/useEventListeners.js";
|
|
11
12
|
import { ExternalWalletWrapper } from "./components/ExternalWalletWrapper.js";
|
|
@@ -15,6 +16,7 @@ import ParaWeb from "@getpara/web-sdk";
|
|
|
15
16
|
import { EXTERNAL_WALLET_TYPES } from "@getpara/web-sdk";
|
|
16
17
|
import { AuthProvider } from "./providers/AuthProvider.js";
|
|
17
18
|
import { AccountLinkProvider } from "./providers/AccountLinkProvider.js";
|
|
19
|
+
import { AssetsProvider } from "./providers/AssetsProvider.js";
|
|
18
20
|
const ParaProviderMin = forwardRef(({ children, paraClientConfig, callbacks, config, externalWalletConfig, paraModalConfig }, ref) => {
|
|
19
21
|
useEventListeners(callbacks);
|
|
20
22
|
useAutoSessionKeepAlive({ disabled: config.disableAutoSessionKeepAlive });
|
|
@@ -37,6 +39,7 @@ const ParaProviderMin = forwardRef(({ children, paraClientConfig, callbacks, con
|
|
|
37
39
|
const rpcUrl = useStore((state) => state.rpcUrl);
|
|
38
40
|
const setRpcUrl = useStore((state) => state.setRpcUrl);
|
|
39
41
|
const setProviderProps = useStore((state) => state.setProviderProps);
|
|
42
|
+
const setModalError = useModalStore((state) => state.setModalError);
|
|
40
43
|
const [isClientReady, setIsClientReady] = useState(client == null ? void 0 : client.isReady);
|
|
41
44
|
useEffect(() => {
|
|
42
45
|
setProviderProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, config), externalWalletConfig), paraModalConfig), {
|
|
@@ -97,6 +100,7 @@ const ParaProviderMin = forwardRef(({ children, paraClientConfig, callbacks, con
|
|
|
97
100
|
throw new Error("Invalid Para config");
|
|
98
101
|
}
|
|
99
102
|
const newClient = isParaWeb(paraClientConfig) ? paraClientConfig : new ParaWeb(paraClientConfig.env, paraClientConfig.apiKey, paraClientConfig.opts);
|
|
103
|
+
newClient.setModalError = setModalError;
|
|
100
104
|
if (newClient.isReady) {
|
|
101
105
|
setIsClientReady(true);
|
|
102
106
|
} else {
|
|
@@ -126,10 +130,10 @@ const ParaProviderMin = forwardRef(({ children, paraClientConfig, callbacks, con
|
|
|
126
130
|
login: paraModalConfig == null ? void 0 : paraModalConfig.loginTransitionOverride,
|
|
127
131
|
createWallets: paraModalConfig == null ? void 0 : paraModalConfig.createWalletOverride
|
|
128
132
|
},
|
|
129
|
-
children: /* @__PURE__ */ jsx(ExternalWalletWrapper, { config: externalWalletConfig, children: /* @__PURE__ */ jsxs(AccountLinkProvider, { children: [
|
|
133
|
+
children: /* @__PURE__ */ jsx(AssetsProvider, { children: /* @__PURE__ */ jsx(ExternalWalletWrapper, { config: externalWalletConfig, children: /* @__PURE__ */ jsxs(AccountLinkProvider, { children: [
|
|
130
134
|
children,
|
|
131
135
|
!config.disableEmbeddedModal && client.isReady && /* @__PURE__ */ jsx(ParaModal, { ref })
|
|
132
|
-
] }) })
|
|
136
|
+
] }) }) })
|
|
133
137
|
}
|
|
134
138
|
);
|
|
135
139
|
});
|
|
@@ -29,19 +29,19 @@ export declare const issueJwt: import("./utils.js").CoreAction<"issueJwt">;
|
|
|
29
29
|
export declare const getLinkedAccounts: import("./utils.js").CoreAction<"getLinkedAccounts">;
|
|
30
30
|
export declare const accountLinkInProgress: import("./utils.js").CoreAction<"accountLinkInProgress">;
|
|
31
31
|
export declare const linkAccount: (_?: import("@getpara/core-sdk").default, __?: {
|
|
32
|
-
auth: import("@getpara/
|
|
32
|
+
auth: import("@getpara/shared").VerifiedAuth;
|
|
33
33
|
} | {
|
|
34
|
-
externalWallet: import("@getpara/
|
|
34
|
+
externalWallet: import("@getpara/shared").ExternalWalletInfo;
|
|
35
35
|
} | {
|
|
36
|
-
type: import("@getpara/
|
|
36
|
+
type: import("@getpara/shared").TLinkedAccountType | "X";
|
|
37
37
|
} | undefined) => Promise<import("@getpara/core-sdk").AccountLinkInProgress>;
|
|
38
38
|
export declare const unlinkAccount: (_?: import("@getpara/core-sdk").default, __?: {
|
|
39
39
|
linkedAccountId: string;
|
|
40
|
-
} | undefined) => Promise<import("@getpara/
|
|
40
|
+
} | undefined) => Promise<import("@getpara/shared").LinkedAccounts>;
|
|
41
41
|
export declare const verifyEmailOrPhoneLink: (_?: import("@getpara/core-sdk").default, __?: {
|
|
42
42
|
verificationCode?: string;
|
|
43
|
-
} | undefined) => Promise<import("@getpara/
|
|
44
|
-
export declare const verifyFarcasterLink: (_?: import("@getpara/core-sdk").default, __?: import("@getpara/core-sdk/dist/types/types/methods.js").FarcasterParams | undefined) => Promise<import("@getpara/
|
|
45
|
-
export declare const verifyTelegramLink: (_?: import("@getpara/core-sdk").default, __?: import("@getpara/core-sdk/dist/types/types/methods.js").TelegramParams | undefined) => Promise<import("@getpara/
|
|
46
|
-
export declare const verifyOAuthLink: (_?: import("@getpara/core-sdk").default, __?: import("@getpara/core-sdk/dist/types/types/methods.js").OAuthParams | undefined) => Promise<import("@getpara/
|
|
47
|
-
export declare const verifyExternalWalletLink: (_?: import("@getpara/core-sdk").default, __?: Omit<import("@getpara/
|
|
43
|
+
} | undefined) => Promise<import("@getpara/shared").LinkedAccounts>;
|
|
44
|
+
export declare const verifyFarcasterLink: (_?: import("@getpara/core-sdk").default, __?: import("@getpara/core-sdk/dist/types/types/methods.js").FarcasterParams | undefined) => Promise<import("@getpara/shared").LinkedAccounts>;
|
|
45
|
+
export declare const verifyTelegramLink: (_?: import("@getpara/core-sdk").default, __?: import("@getpara/core-sdk/dist/types/types/methods.js").TelegramParams | undefined) => Promise<import("@getpara/shared").LinkedAccounts>;
|
|
46
|
+
export declare const verifyOAuthLink: (_?: import("@getpara/core-sdk").default, __?: import("@getpara/core-sdk/dist/types/types/methods.js").OAuthParams | undefined) => Promise<import("@getpara/shared").LinkedAccounts>;
|
|
47
|
+
export declare const verifyExternalWalletLink: (_?: import("@getpara/core-sdk").default, __?: Omit<import("@getpara/shared").VerifyExternalWalletParams, "externalWallet"> | undefined) => Promise<import("@getpara/shared").LinkedAccounts>;
|
|
@@ -11,6 +11,7 @@ import { EvmWalletWrapper } from "./EvmWalletWrapper.js";
|
|
|
11
11
|
import { CosmosWalletWrapper } from "./CosmosWalletWrapper.js";
|
|
12
12
|
import { SolanaWalletWrapper } from "./SolanaWalletWrapper.js";
|
|
13
13
|
import { useStore } from "../stores/useStore.js";
|
|
14
|
+
import { useInternalClient } from "../hooks/utils/useInternalClient.js";
|
|
14
15
|
const ExternalWalletWrapper = ({
|
|
15
16
|
children,
|
|
16
17
|
config
|
|
@@ -20,8 +21,12 @@ const ExternalWalletWrapper = ({
|
|
|
20
21
|
const appName = useStore((state) => state.appName);
|
|
21
22
|
const resetModalState = useModalStore((state) => state.resetState);
|
|
22
23
|
const wallets = useStore((state) => state.externalWallets);
|
|
24
|
+
const para = useInternalClient();
|
|
23
25
|
useEffect(() => {
|
|
24
26
|
if (!!wallets.length && !(walletConnect == null ? void 0 : walletConnect.projectId)) {
|
|
27
|
+
para.setModalError(
|
|
28
|
+
"It is recommended to provide a WalletConnect project id to ensure wallet connection works as expected. Refer to our docs at [https://docs.getpara.com/v2/react/guides/external-wallets/evm#configure-the-providers](https://docs.getpara.com/v2/react/guides/external-wallets/evm#configure-the-providers) for configuration details and sign up for your free key at [https://cloud.walletconnect.com/sign-in](https://cloud.walletconnect.com/sign-in)"
|
|
29
|
+
);
|
|
25
30
|
console.warn(
|
|
26
31
|
"It is recommended to provide a WalletConnect project id to ensure wallet connection works as expected. Sign up for your free key at https://cloud.walletconnect.com/sign-in"
|
|
27
32
|
);
|
|
@@ -24,7 +24,7 @@ export declare const useCreatePregenWallet: () => {
|
|
|
24
24
|
addressSecondary?: string | undefined;
|
|
25
25
|
publicKey?: string | undefined;
|
|
26
26
|
scheme?: import("@getpara/web-sdk").TWalletScheme | undefined;
|
|
27
|
-
type?:
|
|
27
|
+
type?: import("@getpara/web-sdk").TWalletType | undefined;
|
|
28
28
|
isPregen?: boolean | undefined;
|
|
29
29
|
pregenIdentifier?: string | undefined;
|
|
30
30
|
pregenIdentifierType?: import("@getpara/web-sdk").TPregenIdentifierType | undefined;
|
|
@@ -66,7 +66,7 @@ export declare const useCreatePregenWallet: () => {
|
|
|
66
66
|
addressSecondary?: string | undefined;
|
|
67
67
|
publicKey?: string | undefined;
|
|
68
68
|
scheme?: import("@getpara/web-sdk").TWalletScheme | undefined;
|
|
69
|
-
type?:
|
|
69
|
+
type?: import("@getpara/web-sdk").TWalletType | undefined;
|
|
70
70
|
isPregen?: boolean | undefined;
|
|
71
71
|
pregenIdentifier?: string | undefined;
|
|
72
72
|
pregenIdentifierType?: import("@getpara/web-sdk").TPregenIdentifierType | undefined;
|
|
@@ -96,7 +96,7 @@ export declare const useCreatePregenWallet: () => {
|
|
|
96
96
|
addressSecondary?: string | undefined;
|
|
97
97
|
publicKey?: string | undefined;
|
|
98
98
|
scheme?: import("@getpara/web-sdk").TWalletScheme | undefined;
|
|
99
|
-
type?:
|
|
99
|
+
type?: import("@getpara/web-sdk").TWalletType | undefined;
|
|
100
100
|
isPregen?: boolean | undefined;
|
|
101
101
|
pregenIdentifier?: string | undefined;
|
|
102
102
|
pregenIdentifierType?: import("@getpara/web-sdk").TPregenIdentifierType | undefined;
|
|
@@ -16,7 +16,7 @@ export declare const SIGN_UP_LOG_IN_KEY = "SIGN_UP_LOG_IN";
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const useSignUpOrLogIn: () => {
|
|
18
18
|
status: "error" | "idle" | "pending" | "success";
|
|
19
|
-
data: Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/
|
|
19
|
+
data: Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/web-sdk").AuthStateVerify> | undefined;
|
|
20
20
|
isSuccess: boolean;
|
|
21
21
|
variables: {
|
|
22
22
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
@@ -33,12 +33,12 @@ export declare const useSignUpOrLogIn: () => {
|
|
|
33
33
|
failureReason: Error | null;
|
|
34
34
|
isPaused: boolean;
|
|
35
35
|
submittedAt: number;
|
|
36
|
-
signUpOrLogIn: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/
|
|
36
|
+
signUpOrLogIn: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/web-sdk").AuthStateVerify>, Error, {
|
|
37
37
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
38
38
|
useShortUrls?: boolean | undefined;
|
|
39
39
|
auth: import("@getpara/web-sdk").VerifiedAuth;
|
|
40
40
|
}, unknown>;
|
|
41
|
-
signUpOrLogInAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/
|
|
41
|
+
signUpOrLogInAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/web-sdk").AuthStateVerify>, Error, {
|
|
42
42
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
43
43
|
useShortUrls?: boolean | undefined;
|
|
44
44
|
auth: import("@getpara/web-sdk").VerifiedAuth;
|
|
@@ -16,7 +16,7 @@ export declare const VERIFY_FARCASTER_KEY = "VERIFY_FARCASTER";
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const useVerifyFarcaster: () => {
|
|
18
18
|
status: "error" | "idle" | "pending" | "success";
|
|
19
|
-
data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").
|
|
19
|
+
data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
|
|
20
20
|
isSuccess: boolean;
|
|
21
21
|
variables: void | {
|
|
22
22
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
@@ -25,6 +25,7 @@ export declare const useVerifyFarcaster: () => {
|
|
|
25
25
|
onCancel?: (() => void) | undefined;
|
|
26
26
|
isCanceled?: (() => boolean) | undefined;
|
|
27
27
|
onConnectUri?: ((uri: string) => void) | undefined;
|
|
28
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
28
29
|
} | undefined;
|
|
29
30
|
error: Error | null;
|
|
30
31
|
isError: boolean;
|
|
@@ -36,20 +37,22 @@ export declare const useVerifyFarcaster: () => {
|
|
|
36
37
|
failureReason: Error | null;
|
|
37
38
|
isPaused: boolean;
|
|
38
39
|
submittedAt: number;
|
|
39
|
-
verifyFarcaster: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").
|
|
40
|
+
verifyFarcaster: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, void | {
|
|
40
41
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
41
42
|
useShortUrls?: boolean | undefined;
|
|
42
43
|
onPoll?: (() => void) | undefined;
|
|
43
44
|
onCancel?: (() => void) | undefined;
|
|
44
45
|
isCanceled?: (() => boolean) | undefined;
|
|
45
46
|
onConnectUri?: ((uri: string) => void) | undefined;
|
|
47
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
46
48
|
}, unknown>;
|
|
47
|
-
verifyFarcasterAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").
|
|
49
|
+
verifyFarcasterAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, void | {
|
|
48
50
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
49
51
|
useShortUrls?: boolean | undefined;
|
|
50
52
|
onPoll?: (() => void) | undefined;
|
|
51
53
|
onCancel?: (() => void) | undefined;
|
|
52
54
|
isCanceled?: (() => boolean) | undefined;
|
|
53
55
|
onConnectUri?: ((uri: string) => void) | undefined;
|
|
56
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
54
57
|
}, unknown>;
|
|
55
58
|
};
|
|
@@ -20,7 +20,7 @@ export declare const useVerifyNewAccount: () => {
|
|
|
20
20
|
displayName?: string | undefined;
|
|
21
21
|
pfpUrl?: string | undefined;
|
|
22
22
|
externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
|
|
23
|
-
auth: import("@getpara/
|
|
23
|
+
auth: import("@getpara/shared").PrimaryAuth;
|
|
24
24
|
userId: string;
|
|
25
25
|
stage: "signup";
|
|
26
26
|
isPasskeySupported: boolean;
|
|
@@ -52,7 +52,7 @@ export declare const useVerifyNewAccount: () => {
|
|
|
52
52
|
displayName?: string | undefined;
|
|
53
53
|
pfpUrl?: string | undefined;
|
|
54
54
|
externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
|
|
55
|
-
auth: import("@getpara/
|
|
55
|
+
auth: import("@getpara/shared").PrimaryAuth;
|
|
56
56
|
userId: string;
|
|
57
57
|
stage: "signup";
|
|
58
58
|
isPasskeySupported: boolean;
|
|
@@ -72,7 +72,7 @@ export declare const useVerifyNewAccount: () => {
|
|
|
72
72
|
displayName?: string | undefined;
|
|
73
73
|
pfpUrl?: string | undefined;
|
|
74
74
|
externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
|
|
75
|
-
auth: import("@getpara/
|
|
75
|
+
auth: import("@getpara/shared").PrimaryAuth;
|
|
76
76
|
userId: string;
|
|
77
77
|
stage: "signup";
|
|
78
78
|
isPasskeySupported: boolean;
|
|
@@ -16,7 +16,7 @@ export declare const VERIFY_OAUTH_KEY = "VERIFY_OAUTH";
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const useVerifyOAuth: () => {
|
|
18
18
|
status: "error" | "idle" | "pending" | "success";
|
|
19
|
-
data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").
|
|
19
|
+
data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
|
|
20
20
|
isSuccess: boolean;
|
|
21
21
|
variables: {
|
|
22
22
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
@@ -39,7 +39,7 @@ export declare const useVerifyOAuth: () => {
|
|
|
39
39
|
failureReason: Error | null;
|
|
40
40
|
isPaused: boolean;
|
|
41
41
|
submittedAt: number;
|
|
42
|
-
verifyOAuth: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").
|
|
42
|
+
verifyOAuth: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
|
|
43
43
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
44
44
|
useShortUrls?: boolean | undefined;
|
|
45
45
|
method: Exclude<import("@getpara/web-sdk").TOAuthMethod, "TELEGRAM" | "FARCASTER">;
|
|
@@ -50,7 +50,7 @@ export declare const useVerifyOAuth: () => {
|
|
|
50
50
|
onOAuthUrl?: ((url: string) => void) | undefined;
|
|
51
51
|
onOAuthPopup?: ((popup: Window) => void) | undefined;
|
|
52
52
|
}, unknown>;
|
|
53
|
-
verifyOAuthAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").
|
|
53
|
+
verifyOAuthAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
|
|
54
54
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
55
55
|
useShortUrls?: boolean | undefined;
|
|
56
56
|
method: Exclude<import("@getpara/web-sdk").TOAuthMethod, "TELEGRAM" | "FARCASTER">;
|
|
@@ -16,12 +16,13 @@ export declare const VERIFY_TELEGRAM_KEY = "VERIFY_TELEGRAM";
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const useVerifyTelegram: () => {
|
|
18
18
|
status: "error" | "idle" | "pending" | "success";
|
|
19
|
-
data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").
|
|
19
|
+
data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
|
|
20
20
|
isSuccess: boolean;
|
|
21
21
|
variables: {
|
|
22
22
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
23
23
|
useShortUrls?: boolean | undefined;
|
|
24
|
-
telegramAuthResponse
|
|
24
|
+
telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
|
|
25
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
25
26
|
} | undefined;
|
|
26
27
|
error: Error | null;
|
|
27
28
|
isError: boolean;
|
|
@@ -33,14 +34,16 @@ export declare const useVerifyTelegram: () => {
|
|
|
33
34
|
failureReason: Error | null;
|
|
34
35
|
isPaused: boolean;
|
|
35
36
|
submittedAt: number;
|
|
36
|
-
verifyTelegram: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").
|
|
37
|
+
verifyTelegram: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
|
|
37
38
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
38
39
|
useShortUrls?: boolean | undefined;
|
|
39
|
-
telegramAuthResponse
|
|
40
|
+
telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
|
|
41
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
40
42
|
}, unknown>;
|
|
41
|
-
verifyTelegramAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").
|
|
43
|
+
verifyTelegramAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
|
|
42
44
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
43
45
|
useShortUrls?: boolean | undefined;
|
|
44
|
-
telegramAuthResponse
|
|
46
|
+
telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
|
|
47
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
45
48
|
}, unknown>;
|
|
46
49
|
};
|
|
@@ -4,3 +4,4 @@ export { useWallet } from './useWallet.js';
|
|
|
4
4
|
export { useWalletBalance } from './useWalletBalance.js';
|
|
5
5
|
export { useLinkedAccounts } from './useLinkedAccounts.js';
|
|
6
6
|
export { useAccountLinkInProgress } from './useAccountLinkInProgress.js';
|
|
7
|
+
export { useProfileBalance } from './useProfileBalance.js';
|
|
@@ -6,11 +6,13 @@ import { useWallet } from "./useWallet.js";
|
|
|
6
6
|
import { useWalletBalance } from "./useWalletBalance.js";
|
|
7
7
|
import { useLinkedAccounts } from "./useLinkedAccounts.js";
|
|
8
8
|
import { useAccountLinkInProgress } from "./useAccountLinkInProgress.js";
|
|
9
|
+
import { useProfileBalance } from "./useProfileBalance.js";
|
|
9
10
|
export {
|
|
10
11
|
useAccount,
|
|
11
12
|
useAccountLinkInProgress,
|
|
12
13
|
useLinkedAccounts,
|
|
13
14
|
useParaStatus,
|
|
15
|
+
useProfileBalance,
|
|
14
16
|
useWallet,
|
|
15
17
|
useWalletBalance
|
|
16
18
|
};
|
|
@@ -5,13 +5,15 @@ import {
|
|
|
5
5
|
import { useQuery } from "@tanstack/react-query";
|
|
6
6
|
import { useInternalClient } from "../utils/useInternalClient.js";
|
|
7
7
|
import { getLinkedAccounts } from "../../actions/index.js";
|
|
8
|
+
import { useAccount } from "./useAccount.js";
|
|
8
9
|
const LINKED_ACCOUNTS_BASE_KEY = "PARA_LINKED_ACCOUNTS";
|
|
9
10
|
const useLinkedAccounts = (params = { withMetadata: false }) => {
|
|
10
11
|
var _a;
|
|
11
12
|
const client = useInternalClient();
|
|
13
|
+
const { connectionType } = useAccount();
|
|
12
14
|
return useQuery({
|
|
13
|
-
enabled: !!(client == null ? void 0 : client.isReady),
|
|
14
|
-
queryKey: [LINKED_ACCOUNTS_BASE_KEY, (_a = client == null ? void 0 : client.userId) != null ? _a : null, params],
|
|
15
|
+
enabled: !!(client == null ? void 0 : client.isReady) && ["both", "embedded"].includes(connectionType),
|
|
16
|
+
queryKey: [LINKED_ACCOUNTS_BASE_KEY, (_a = client == null ? void 0 : client.userId) != null ? _a : null, connectionType, params],
|
|
15
17
|
queryFn: () => __async(void 0, null, function* () {
|
|
16
18
|
var _a2;
|
|
17
19
|
return (_a2 = yield getLinkedAccounts(client, params)) != null ? _a2 : [];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { ProfileBalance } from '@getpara/web-sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Options for the useProfileBalance hook.
|
|
5
|
+
*/
|
|
6
|
+
type UseProfileBalanceOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* A value that, when changed, will recalculate the current profile's balances.
|
|
9
|
+
*
|
|
10
|
+
* Use a counter (increment when you want to refetch) or timestamp for one-time refetches.
|
|
11
|
+
*
|
|
12
|
+
* When not provided, internal SDK events (like asset transfers) will still trigger refetches via React Query invalidation.
|
|
13
|
+
*/
|
|
14
|
+
refetchTrigger?: number | string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* React Query hook for retrieving the asset balance for your currently connected wallets.
|
|
18
|
+
*
|
|
19
|
+
* @returns {ProfileBalance}
|
|
20
|
+
* The profile balance object, containing the aggregated balance for all wallets and entries for each wallet, further divided by various assets and networks.
|
|
21
|
+
*
|
|
22
|
+
* The profile balance will be denoted in USD or in a custom asset you specify, depending on your ParaProvider configuration.
|
|
23
|
+
*/
|
|
24
|
+
export declare const useProfileBalance: (options?: UseProfileBalanceOptions) => UseQueryResult<ProfileBalance>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { useRef, useEffect } from "react";
|
|
7
|
+
import { useStore } from "../../stores/useStore.js";
|
|
8
|
+
import { useInternalClient } from "../utils/useInternalClient.js";
|
|
9
|
+
import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
|
|
10
|
+
const useProfileBalance = (options) => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const client = useInternalClient();
|
|
13
|
+
const { data: isFullyLoggedIn, isSuccess } = useIsFullyLoggedIn();
|
|
14
|
+
const config = useStore((state) => {
|
|
15
|
+
var _a2;
|
|
16
|
+
return (_a2 = state.modalConfig) == null ? void 0 : _a2.balances;
|
|
17
|
+
});
|
|
18
|
+
const refs = useStore((state) => state.refs);
|
|
19
|
+
const previousTriggerRef = useRef(options == null ? void 0 : options.refetchTrigger);
|
|
20
|
+
const shouldRefetchRef = useRef(false);
|
|
21
|
+
const lastQueryTimeRef = useRef(0);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if ((options == null ? void 0 : options.refetchTrigger) !== previousTriggerRef.current) {
|
|
24
|
+
shouldRefetchRef.current = true;
|
|
25
|
+
previousTriggerRef.current = options == null ? void 0 : options.refetchTrigger;
|
|
26
|
+
}
|
|
27
|
+
}, [options == null ? void 0 : options.refetchTrigger]);
|
|
28
|
+
return useQuery({
|
|
29
|
+
enabled: isSuccess && !!client,
|
|
30
|
+
queryKey: [
|
|
31
|
+
"useProfileBalance",
|
|
32
|
+
isFullyLoggedIn != null ? isFullyLoggedIn : null,
|
|
33
|
+
(_a = client == null ? void 0 : client.userId) != null ? _a : null,
|
|
34
|
+
(_b = client == null ? void 0 : client.availableWallets.map(({ address }) => address)) != null ? _b : null,
|
|
35
|
+
config != null ? config : null
|
|
36
|
+
// Note: refetchTrigger is NOT in query key to allow cache sharing
|
|
37
|
+
],
|
|
38
|
+
staleTime: 3e4,
|
|
39
|
+
retry: 3,
|
|
40
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
41
|
+
var _a2;
|
|
42
|
+
if (!client || !isFullyLoggedIn) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const isInvalidationRefetch = ((_a2 = refs.balancesInvalidationTime.current) != null ? _a2 : 0) > lastQueryTimeRef.current;
|
|
46
|
+
const profileBalance = yield client == null ? void 0 : client.getProfileBalance({
|
|
47
|
+
config,
|
|
48
|
+
refetch: shouldRefetchRef.current || isInvalidationRefetch
|
|
49
|
+
});
|
|
50
|
+
lastQueryTimeRef.current = Date.now();
|
|
51
|
+
shouldRefetchRef.current = false;
|
|
52
|
+
return profileBalance;
|
|
53
|
+
}),
|
|
54
|
+
// We handle refetch manually
|
|
55
|
+
refetchOnWindowFocus: false
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
useProfileBalance
|
|
60
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useInternalClient } from "../utils/useInternalClient.js";
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
|
+
const useAssetInfo = () => {
|
|
8
|
+
const client = useInternalClient();
|
|
9
|
+
return useQuery({
|
|
10
|
+
enabled: !!client,
|
|
11
|
+
queryKey: ["useAssetInfo"],
|
|
12
|
+
staleTime: 15e3,
|
|
13
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
14
|
+
const { assets } = yield client == null ? void 0 : client.ctx.client.getAssetInfo();
|
|
15
|
+
return assets;
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
useAssetInfo
|
|
21
|
+
};
|
|
@@ -3,11 +3,11 @@ import "../../../chunk-MMUBH76A.js";
|
|
|
3
3
|
import { useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { useCallback, useEffect } from "react";
|
|
5
5
|
import { useWalletState } from "../index.js";
|
|
6
|
+
import { useStore } from "../../stores/useStore.js";
|
|
6
7
|
import {
|
|
7
8
|
ParaEvent
|
|
8
9
|
} from "@getpara/web-sdk";
|
|
9
10
|
import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
|
|
10
|
-
import { useStore } from "../../stores/useStore.js";
|
|
11
11
|
import { WALLET_BASE_KEY } from "../queries/useWallet.js";
|
|
12
12
|
import { WALLET_BALANCE_BASE_KEY } from "../queries/useWalletBalance.js";
|
|
13
13
|
import { IS_FULLY_LOGGED_IN_BASE_KEY } from "../queries/useIsFullyLoggedIn.js";
|
|
@@ -25,6 +25,7 @@ const useEventListeners = ({
|
|
|
25
25
|
onGuestWalletsCreated
|
|
26
26
|
} = {}) => {
|
|
27
27
|
const queryClient = useQueryClient();
|
|
28
|
+
const refs = useStore((state) => state.refs);
|
|
28
29
|
const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
|
|
29
30
|
const { updateSelectedWallet } = useWalletState();
|
|
30
31
|
const loginOrSetupListener = useCallback(() => {
|
|
@@ -113,6 +114,13 @@ const useEventListeners = ({
|
|
|
113
114
|
},
|
|
114
115
|
[queryClient, updateSelectedWallet, onGuestWalletsCreated]
|
|
115
116
|
);
|
|
117
|
+
const assetTransferListener = useCallback(() => {
|
|
118
|
+
refs.balancesInvalidationTime.current = Date.now();
|
|
119
|
+
queryClient.invalidateQueries({
|
|
120
|
+
queryKey: ["useProfileBalance"],
|
|
121
|
+
refetchType: "active"
|
|
122
|
+
});
|
|
123
|
+
}, [queryClient, refs.balancesInvalidationTime]);
|
|
116
124
|
useEffect(() => {
|
|
117
125
|
window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
118
126
|
window.addEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
@@ -125,6 +133,7 @@ const useEventListeners = ({
|
|
|
125
133
|
window.addEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
126
134
|
window.addEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
127
135
|
window.addEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
|
|
136
|
+
window.addEventListener(ParaEvent.ASSET_TRANSFERRED, assetTransferListener);
|
|
128
137
|
return () => {
|
|
129
138
|
window.removeEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
130
139
|
window.removeEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
@@ -137,6 +146,7 @@ const useEventListeners = ({
|
|
|
137
146
|
window.removeEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
138
147
|
window.removeEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
139
148
|
window.removeEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
|
|
149
|
+
window.removeEventListener(ParaEvent.ASSET_TRANSFERRED, assetTransferListener);
|
|
140
150
|
};
|
|
141
151
|
}, [
|
|
142
152
|
loginListener,
|
|
@@ -5,11 +5,11 @@ import { useStore } from "../../stores/useStore.js";
|
|
|
5
5
|
const useModal = () => {
|
|
6
6
|
const isOpen = useStore((state) => state.isOpen);
|
|
7
7
|
const setIsOpen = useStore((state) => state.setIsOpen);
|
|
8
|
-
const
|
|
8
|
+
const refs = useStore((state) => state.refs);
|
|
9
9
|
const setStep = useModalStore((state) => state.setStep);
|
|
10
10
|
const openModal = ({ step } = {}) => {
|
|
11
11
|
if (step) {
|
|
12
|
-
openedToStep.current = step;
|
|
12
|
+
refs.openedToStep.current = step;
|
|
13
13
|
setStep(step);
|
|
14
14
|
}
|
|
15
15
|
if (!isOpen) {
|
|
@@ -17,7 +17,7 @@ const useModal = () => {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
const closeModal = () => {
|
|
20
|
-
openedToStep.current = null;
|
|
20
|
+
refs.openedToStep.current = null;
|
|
21
21
|
setIsOpen(false);
|
|
22
22
|
};
|
|
23
23
|
return { isOpen, openModal, closeModal };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { AssetMetadataIndexed, ProfileBalance } from '@getpara/web-sdk';
|
|
3
|
+
type Value = {
|
|
4
|
+
displayCurrency: 'USD';
|
|
5
|
+
profileBalance: ProfileBalance | null;
|
|
6
|
+
profileBalanceIsPending: boolean;
|
|
7
|
+
assetMetadata: AssetMetadataIndexed | null;
|
|
8
|
+
assetMetadataIsPending: boolean;
|
|
9
|
+
totalBalance: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const AssetsContext: import("react").Context<Value>;
|
|
12
|
+
export declare function AssetsProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const useAssets: () => Value;
|
|
14
|
+
export {};
|