@getpara/react-sdk-lite 2.0.0-dev.6 → 2.0.0
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 +26 -1
- package/dist/modal/ParaModal.js +16 -11
- package/dist/modal/components/Account/Account.js +42 -4
- package/dist/modal/components/Account/AccountHeader.js +10 -16
- package/dist/modal/components/Account/AccountProfile.d.ts +1 -1
- package/dist/modal/components/Account/AccountProfile.js +82 -210
- package/dist/modal/components/Account/AccountProfileEntry.d.ts +12 -0
- package/dist/modal/components/Account/AccountProfileEntry.js +220 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.js +15 -4
- package/dist/modal/components/Account/AccountSend/AccountSendAsset.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendAsset.js +94 -0
- package/dist/modal/components/Account/AccountSend/AccountSendForm.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendForm.js +343 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNetwork.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNetwork.js +53 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.d.ts +1 -0
- package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.js +56 -0
- package/dist/modal/components/Account/AccountSend/AssetNetwork.d.ts +5 -0
- package/dist/modal/components/Account/AccountSend/AssetNetwork.js +36 -0
- package/dist/modal/components/Account/AccountSend/context.d.ts +38 -0
- package/dist/modal/components/Account/AccountSend/context.js +418 -0
- package/dist/modal/components/Account/AccountSend/index.d.ts +4 -0
- package/dist/modal/components/Account/AccountSend/index.js +67 -0
- package/dist/modal/components/Account/AccountWallet.d.ts +1 -0
- package/dist/modal/components/Account/AccountWallet.js +133 -0
- package/dist/modal/components/{WalletSelect/WalletSelect.d.ts → Account/AccountWalletSelect.d.ts} +1 -1
- package/dist/modal/components/{WalletSelect/WalletSelect.js → Account/AccountWalletSelect.js} +20 -6
- package/dist/modal/components/AddFunds/AddFunds.js +3 -2
- package/dist/modal/components/AddFunds/AddFundsAsset.js +7 -6
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +5 -5
- package/dist/modal/components/AddFunds/AddFundsProvider.js +1 -2
- package/dist/modal/components/AddFunds/AddFundsSettings.js +13 -54
- package/dist/modal/components/AddFunds/common.d.ts +0 -14
- package/dist/modal/components/AddFunds/common.js +1 -8
- package/dist/modal/components/AuthInput/AuthInput.js +2 -2
- package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.js +10 -1
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +8 -33
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +5 -2
- package/dist/modal/components/Body/Body.js +81 -48
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +8 -5
- package/dist/modal/components/Controls/ChainSelect.js +1 -2
- package/dist/modal/components/Controls/Controls.js +1 -0
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.d.ts +5 -1
- package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +48 -19
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +5 -2
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +63 -33
- package/dist/modal/components/ExternalWallets/ExternalWallets.d.ts +3 -1
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +22 -12
- package/dist/modal/components/Footer/Footer.js +4 -5
- package/dist/modal/components/Header/Header.js +1 -2
- package/dist/modal/components/Header/hooks/useStepTitle.js +53 -37
- package/dist/modal/components/Hero/Hero.js +5 -3
- package/dist/modal/components/IFrameStep/IFrameStep.js +13 -12
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +4 -1
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -5
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +34 -18
- package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +1 -2
- package/dist/modal/components/QuantityInput.d.ts +9 -0
- package/dist/modal/components/QuantityInput.js +91 -0
- package/dist/modal/components/SearchableButtonList.d.ts +34 -0
- package/dist/modal/components/SearchableButtonList.js +223 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +4 -1
- package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.d.ts +1 -0
- package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.js +10 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +13 -2
- package/dist/modal/components/Waiting/Waiting.d.ts +1 -1
- package/dist/modal/components/Waiting/Waiting.js +7 -2
- package/dist/modal/components/WalletCard/WalletCard.js +2 -3
- package/dist/modal/components/WalletSelectOld/WalletSelectOld.d.ts +7 -1
- package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +33 -12
- package/dist/modal/components/common.d.ts +8 -10
- package/dist/modal/components/common.js +16 -36
- package/dist/modal/hooks/index.d.ts +4 -0
- package/dist/modal/hooks/index.js +5 -0
- package/dist/modal/hooks/useDebounce.d.ts +4 -0
- package/dist/modal/hooks/useDebounce.js +16 -0
- package/dist/modal/hooks/useFarcasterLogin.js +8 -1
- package/dist/modal/hooks/useTelegramLogin.js +4 -0
- package/dist/modal/index.d.ts +1 -1
- package/dist/modal/index.js +1 -1
- package/dist/modal/stores/modal/actions.js +9 -2
- package/dist/modal/stores/modal/useModalStore.d.ts +9 -1
- package/dist/modal/stores/modal/useModalStore.js +6 -2
- package/dist/modal/types/modalProps.d.ts +5 -1
- package/dist/modal/utils/authInputHelpers.js +1 -1
- package/dist/modal/utils/countryCodes.js +50 -1
- package/dist/modal/utils/getWalletDisplayName.js +1 -1
- package/dist/modal/utils/openPopup.d.ts +1 -1
- package/dist/modal/utils/openPopup.js +6 -2
- package/dist/modal/utils/renderTextWithLinks.d.ts +2 -0
- package/dist/modal/utils/renderTextWithLinks.js +34 -0
- package/dist/modal/utils/steps.d.ts +24 -3
- package/dist/modal/utils/steps.js +51 -5
- package/dist/modal/utils/stringFormatters.d.ts +2 -3
- package/dist/modal/utils/stringFormatters.js +11 -7
- package/dist/modal/utils/validatePortalOrigin.d.ts +2 -0
- package/dist/modal/utils/validatePortalOrigin.js +14 -0
- package/dist/provider/ParaProviderMin.js +13 -5
- package/dist/provider/actions/getEmbeddedAccount.d.ts +3 -2
- package/dist/provider/actions/getEmbeddedAccount.js +13 -4
- package/dist/provider/actions/index.d.ts +11 -9
- package/dist/provider/actions/index.js +4 -0
- package/dist/provider/components/CosmosWalletWrapper.js +3 -3
- package/dist/provider/components/EvmWalletWrapper.js +3 -3
- package/dist/provider/components/ExternalWalletWrapper.js +7 -1
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +3 -1
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +3 -1
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +3 -1
- package/dist/provider/hooks/mutations/index.d.ts +2 -0
- package/dist/provider/hooks/mutations/index.js +4 -0
- package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +42 -0
- package/dist/provider/hooks/mutations/useAddAuthMethod.js +59 -0
- package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +5 -5
- package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreateWallet.d.ts +2 -2
- package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +2 -2
- package/dist/provider/hooks/mutations/useEnable2fa.d.ts +2 -2
- package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +15 -0
- package/dist/provider/hooks/mutations/useExportPrivateKey.js +32 -0
- package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +2 -2
- package/dist/provider/hooks/mutations/useIssueJwt.d.ts +2 -2
- package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +2 -2
- package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +8 -2
- package/dist/provider/hooks/mutations/useLogout.d.ts +2 -2
- package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSetup2fa.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSignMessage.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSignTransaction.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +2 -2
- package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +57 -0
- package/dist/provider/hooks/mutations/useSwitchWallets.js +30 -0
- package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +2 -2
- package/dist/provider/hooks/mutations/useVerify2fa.d.ts +2 -2
- package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +18 -27
- package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +5 -5
- package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +14 -11
- package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +2 -2
- package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +5 -5
- package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +2 -2
- package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +2 -2
- package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +2 -2
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +2 -0
- package/dist/provider/hooks/queries/useAccount.js +58 -24
- package/dist/provider/hooks/queries/useLinkedAccounts.js +4 -2
- package/dist/provider/hooks/queries/useProfileBalance.d.ts +29 -0
- package/dist/provider/hooks/queries/useProfileBalance.js +65 -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/useAutoSessionKeepAlive.js +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +22 -5
- package/dist/provider/hooks/utils/useModal.js +3 -3
- package/dist/provider/hooks/utils/useWalletState.d.ts +2 -1
- package/dist/provider/hooks/utils/useWalletState.js +2 -1
- package/dist/provider/providers/AccountLinkProvider.js +18 -11
- 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 -1
- package/dist/provider/providers/AuthProvider.js +204 -44
- package/dist/provider/providers/ExternalWalletProvider.d.ts +19 -5
- package/dist/provider/providers/ExternalWalletProvider.js +363 -44
- package/dist/provider/stores/getters.d.ts +2 -2
- package/dist/provider/stores/slices/modal.js +4 -1
- package/dist/provider/stores/types.d.ts +6 -3
- package/package.json +8 -8
- package/dist/modal/constants/constants.d.ts +0 -35
- package/dist/modal/constants/constants.js +0 -148
- package/dist/modal/utils/routeMobileExternalWallet.d.ts +0 -1
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
|
@@ -15,7 +15,8 @@ export declare const VERIFY_FARCASTER_KEY = "VERIFY_FARCASTER";
|
|
|
15
15
|
* await verifyFarcasterAsync({ ...params });
|
|
16
16
|
*/
|
|
17
17
|
export declare const useVerifyFarcaster: () => {
|
|
18
|
-
status: "
|
|
18
|
+
status: "idle" | "pending" | "error" | "success";
|
|
19
|
+
error: Error | null;
|
|
19
20
|
data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
|
|
20
21
|
isSuccess: boolean;
|
|
21
22
|
variables: void | {
|
|
@@ -25,9 +26,8 @@ export declare const useVerifyFarcaster: () => {
|
|
|
25
26
|
onCancel?: (() => void) | undefined;
|
|
26
27
|
isCanceled?: (() => boolean) | undefined;
|
|
27
28
|
onConnectUri?: ((uri: string) => void) | undefined;
|
|
28
|
-
serverAuthState?: import("@getpara/
|
|
29
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
29
30
|
} | undefined;
|
|
30
|
-
error: Error | null;
|
|
31
31
|
isError: boolean;
|
|
32
32
|
isIdle: boolean;
|
|
33
33
|
isPending: boolean;
|
|
@@ -44,7 +44,7 @@ export declare const useVerifyFarcaster: () => {
|
|
|
44
44
|
onCancel?: (() => void) | undefined;
|
|
45
45
|
isCanceled?: (() => boolean) | undefined;
|
|
46
46
|
onConnectUri?: ((uri: string) => void) | undefined;
|
|
47
|
-
serverAuthState?: import("@getpara/
|
|
47
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
48
48
|
}, unknown>;
|
|
49
49
|
verifyFarcasterAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, void | {
|
|
50
50
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
@@ -53,6 +53,6 @@ export declare const useVerifyFarcaster: () => {
|
|
|
53
53
|
onCancel?: (() => void) | undefined;
|
|
54
54
|
isCanceled?: (() => boolean) | undefined;
|
|
55
55
|
onConnectUri?: ((uri: string) => void) | undefined;
|
|
56
|
-
serverAuthState?: import("@getpara/
|
|
56
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
57
57
|
}, unknown>;
|
|
58
58
|
};
|
|
@@ -14,14 +14,15 @@ export declare const VERIFY_NEW_ACCOUNT_KEY = "VERIFY_NEW_ACCOUNT";
|
|
|
14
14
|
* await verifyNewAccountAsync({ ...params });
|
|
15
15
|
*/
|
|
16
16
|
export declare const useVerifyNewAccount: () => {
|
|
17
|
-
status: "
|
|
17
|
+
status: "idle" | "pending" | "error" | "success";
|
|
18
|
+
error: Error | null;
|
|
18
19
|
data: {
|
|
20
|
+
userId: string;
|
|
21
|
+
externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
|
|
19
22
|
username?: string | undefined;
|
|
20
23
|
displayName?: string | undefined;
|
|
21
24
|
pfpUrl?: string | undefined;
|
|
22
|
-
|
|
23
|
-
auth: import("@getpara/user-management-client").PrimaryAuth;
|
|
24
|
-
userId: string;
|
|
25
|
+
auth: import("@getpara/shared").PrimaryAuth;
|
|
25
26
|
stage: "signup";
|
|
26
27
|
isPasskeySupported: boolean;
|
|
27
28
|
passkeyUrl?: string | undefined;
|
|
@@ -30,6 +31,7 @@ export declare const useVerifyNewAccount: () => {
|
|
|
30
31
|
passkeyId?: string | undefined;
|
|
31
32
|
passwordId?: string | undefined;
|
|
32
33
|
pinId?: string | undefined;
|
|
34
|
+
signupAuthMethods?: import("@getpara/web-sdk").TAuthMethod[] | undefined;
|
|
33
35
|
} | undefined;
|
|
34
36
|
isSuccess: boolean;
|
|
35
37
|
variables: {
|
|
@@ -37,7 +39,6 @@ export declare const useVerifyNewAccount: () => {
|
|
|
37
39
|
useShortUrls?: boolean | undefined;
|
|
38
40
|
verificationCode: string;
|
|
39
41
|
} | undefined;
|
|
40
|
-
error: Error | null;
|
|
41
42
|
isError: boolean;
|
|
42
43
|
isIdle: boolean;
|
|
43
44
|
isPending: boolean;
|
|
@@ -48,12 +49,12 @@ export declare const useVerifyNewAccount: () => {
|
|
|
48
49
|
isPaused: boolean;
|
|
49
50
|
submittedAt: number;
|
|
50
51
|
verifyNewAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
52
|
+
userId: string;
|
|
53
|
+
externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
|
|
51
54
|
username?: string | undefined;
|
|
52
55
|
displayName?: string | undefined;
|
|
53
56
|
pfpUrl?: string | undefined;
|
|
54
|
-
|
|
55
|
-
auth: import("@getpara/user-management-client").PrimaryAuth;
|
|
56
|
-
userId: string;
|
|
57
|
+
auth: import("@getpara/shared").PrimaryAuth;
|
|
57
58
|
stage: "signup";
|
|
58
59
|
isPasskeySupported: boolean;
|
|
59
60
|
passkeyUrl?: string | undefined;
|
|
@@ -62,18 +63,19 @@ export declare const useVerifyNewAccount: () => {
|
|
|
62
63
|
passkeyId?: string | undefined;
|
|
63
64
|
passwordId?: string | undefined;
|
|
64
65
|
pinId?: string | undefined;
|
|
66
|
+
signupAuthMethods?: import("@getpara/web-sdk").TAuthMethod[] | undefined;
|
|
65
67
|
}, Error, {
|
|
66
68
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
67
69
|
useShortUrls?: boolean | undefined;
|
|
68
70
|
verificationCode: string;
|
|
69
71
|
}, unknown>;
|
|
70
72
|
verifyNewAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
73
|
+
userId: string;
|
|
74
|
+
externalWallet?: import("@getpara/web-sdk").ExternalWalletInfo | undefined;
|
|
71
75
|
username?: string | undefined;
|
|
72
76
|
displayName?: string | undefined;
|
|
73
77
|
pfpUrl?: string | undefined;
|
|
74
|
-
|
|
75
|
-
auth: import("@getpara/user-management-client").PrimaryAuth;
|
|
76
|
-
userId: string;
|
|
78
|
+
auth: import("@getpara/shared").PrimaryAuth;
|
|
77
79
|
stage: "signup";
|
|
78
80
|
isPasskeySupported: boolean;
|
|
79
81
|
passkeyUrl?: string | undefined;
|
|
@@ -82,6 +84,7 @@ export declare const useVerifyNewAccount: () => {
|
|
|
82
84
|
passkeyId?: string | undefined;
|
|
83
85
|
passwordId?: string | undefined;
|
|
84
86
|
pinId?: string | undefined;
|
|
87
|
+
signupAuthMethods?: import("@getpara/web-sdk").TAuthMethod[] | undefined;
|
|
85
88
|
}, Error, {
|
|
86
89
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
87
90
|
useShortUrls?: boolean | undefined;
|
|
@@ -15,7 +15,8 @@ export declare const VERIFY_OAUTH_KEY = "VERIFY_OAUTH";
|
|
|
15
15
|
* await verifyOAuthAsync({ ...params });
|
|
16
16
|
*/
|
|
17
17
|
export declare const useVerifyOAuth: () => {
|
|
18
|
-
status: "
|
|
18
|
+
status: "idle" | "pending" | "error" | "success";
|
|
19
|
+
error: Error | null;
|
|
19
20
|
data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
|
|
20
21
|
isSuccess: boolean;
|
|
21
22
|
variables: {
|
|
@@ -29,7 +30,6 @@ export declare const useVerifyOAuth: () => {
|
|
|
29
30
|
onOAuthUrl?: ((url: string) => void) | undefined;
|
|
30
31
|
onOAuthPopup?: ((popup: Window) => void) | undefined;
|
|
31
32
|
} | undefined;
|
|
32
|
-
error: Error | null;
|
|
33
33
|
isError: boolean;
|
|
34
34
|
isIdle: boolean;
|
|
35
35
|
isPending: boolean;
|
|
@@ -15,16 +15,16 @@ export declare const VERIFY_TELEGRAM_KEY = "VERIFY_TELEGRAM";
|
|
|
15
15
|
* await verifyTelegramAsync({ ...params });
|
|
16
16
|
*/
|
|
17
17
|
export declare const useVerifyTelegram: () => {
|
|
18
|
-
status: "
|
|
18
|
+
status: "idle" | "pending" | "error" | "success";
|
|
19
|
+
error: Error | null;
|
|
19
20
|
data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
|
|
20
21
|
isSuccess: boolean;
|
|
21
22
|
variables: {
|
|
22
23
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
23
24
|
useShortUrls?: boolean | undefined;
|
|
24
25
|
telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
|
|
25
|
-
serverAuthState?: import("@getpara/
|
|
26
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
26
27
|
} | undefined;
|
|
27
|
-
error: Error | null;
|
|
28
28
|
isError: boolean;
|
|
29
29
|
isIdle: boolean;
|
|
30
30
|
isPending: boolean;
|
|
@@ -38,12 +38,12 @@ export declare const useVerifyTelegram: () => {
|
|
|
38
38
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
39
39
|
useShortUrls?: boolean | undefined;
|
|
40
40
|
telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
|
|
41
|
-
serverAuthState?: import("@getpara/
|
|
41
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
42
42
|
}, unknown>;
|
|
43
43
|
verifyTelegramAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
|
|
44
44
|
portalTheme?: import("@getpara/web-sdk").Theme | undefined;
|
|
45
45
|
useShortUrls?: boolean | undefined;
|
|
46
46
|
telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
|
|
47
|
-
serverAuthState?: import("@getpara/
|
|
47
|
+
serverAuthState?: import("@getpara/shared").VerifyThirdPartyAuth | undefined;
|
|
48
48
|
}, unknown>;
|
|
49
49
|
};
|
|
@@ -14,7 +14,8 @@ export declare const WAIT_FOR_LOG_IN_KEY = "WAIT_FOR_LOG_IN";
|
|
|
14
14
|
* await waitForLoginAsync({ ...params });
|
|
15
15
|
*/
|
|
16
16
|
export declare const useWaitForLogin: () => {
|
|
17
|
-
status: "
|
|
17
|
+
status: "idle" | "pending" | "error" | "success";
|
|
18
|
+
error: Error | null;
|
|
18
19
|
data: {
|
|
19
20
|
needsWallet?: boolean | undefined;
|
|
20
21
|
partnerId?: string | undefined;
|
|
@@ -26,7 +27,6 @@ export declare const useWaitForLogin: () => {
|
|
|
26
27
|
skipSessionRefresh?: boolean | undefined;
|
|
27
28
|
isCanceled?: (() => boolean) | undefined;
|
|
28
29
|
} | undefined;
|
|
29
|
-
error: Error | null;
|
|
30
30
|
isError: boolean;
|
|
31
31
|
isIdle: boolean;
|
|
32
32
|
isPending: boolean;
|
|
@@ -14,7 +14,8 @@ export declare const WAIT_FOR_SIGN_UP_KEY = "WAIT_FOR_SIGN_UP";
|
|
|
14
14
|
* await waitForSignupAsync({ ...params });
|
|
15
15
|
*/
|
|
16
16
|
export declare const useWaitForSignup: () => {
|
|
17
|
-
status: "
|
|
17
|
+
status: "idle" | "pending" | "error" | "success";
|
|
18
|
+
error: Error | null;
|
|
18
19
|
data: true | undefined;
|
|
19
20
|
isSuccess: boolean;
|
|
20
21
|
variables: void | {
|
|
@@ -22,7 +23,6 @@ export declare const useWaitForSignup: () => {
|
|
|
22
23
|
onCancel?: (() => void) | undefined;
|
|
23
24
|
isCanceled?: (() => boolean) | undefined;
|
|
24
25
|
} | undefined;
|
|
25
|
-
error: Error | null;
|
|
26
26
|
isError: boolean;
|
|
27
27
|
isIdle: boolean;
|
|
28
28
|
isPending: boolean;
|
|
@@ -14,7 +14,8 @@ export declare const WAIT_FOR_WALLET_CREATION_KEY = "WAIT_FOR_WALLET_CREATION";
|
|
|
14
14
|
* await waitForWalletCreationAsync({ ...params });
|
|
15
15
|
*/
|
|
16
16
|
export declare const useWaitForWalletCreation: () => {
|
|
17
|
-
status: "
|
|
17
|
+
status: "idle" | "pending" | "error" | "success";
|
|
18
|
+
error: Error | null;
|
|
18
19
|
data: {
|
|
19
20
|
walletIds: import("@getpara/web-sdk").CurrentWalletIds;
|
|
20
21
|
recoverySecret?: string | undefined;
|
|
@@ -25,7 +26,6 @@ export declare const useWaitForWalletCreation: () => {
|
|
|
25
26
|
onCancel?: (() => void) | undefined;
|
|
26
27
|
isCanceled?: (() => boolean) | undefined;
|
|
27
28
|
} | undefined;
|
|
28
|
-
error: Error | null;
|
|
29
29
|
isError: boolean;
|
|
30
30
|
isIdle: boolean;
|
|
31
31
|
isPending: boolean;
|
|
@@ -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
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
__async,
|
|
3
4
|
__objRest,
|
|
4
5
|
__spreadProps,
|
|
5
6
|
__spreadValues
|
|
6
7
|
} from "../../../chunk-MMUBH76A.js";
|
|
7
|
-
import { useQuery } from "@tanstack/react-query";
|
|
8
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
8
9
|
import { useInternalClient } from "../utils/useInternalClient.js";
|
|
9
10
|
import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
|
|
10
11
|
import { useStore } from "../../stores/useStore.js";
|
|
11
|
-
import { useContext } from "react";
|
|
12
|
+
import { useContext, useEffect, useMemo } from "react";
|
|
12
13
|
import { getEmbeddedAccount } from "../../actions/getEmbeddedAccount.js";
|
|
13
14
|
const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
|
|
14
15
|
function pickSolanaAdapter(adapter) {
|
|
@@ -30,40 +31,71 @@ function pickCosmosAccount(account) {
|
|
|
30
31
|
const _a = account, { reconnect: _ } = _a, rest = __objRest(_a, ["reconnect"]);
|
|
31
32
|
return rest;
|
|
32
33
|
}
|
|
34
|
+
let lastConnectionState = "";
|
|
35
|
+
let invalidationTimeoutId = null;
|
|
36
|
+
const useInvalidation = (connectionStates, queryKey) => {
|
|
37
|
+
const queryClient = useQueryClient();
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const connectionStateKey = `${connectionStates.evm}-${connectionStates.cosmos}-${connectionStates.solana}`;
|
|
40
|
+
if (connectionStateKey === lastConnectionState) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
lastConnectionState = connectionStateKey;
|
|
44
|
+
if (invalidationTimeoutId) {
|
|
45
|
+
clearTimeout(invalidationTimeoutId);
|
|
46
|
+
}
|
|
47
|
+
invalidationTimeoutId = setTimeout(() => {
|
|
48
|
+
queryClient.invalidateQueries({ queryKey });
|
|
49
|
+
invalidationTimeoutId = null;
|
|
50
|
+
}, 0);
|
|
51
|
+
return () => {
|
|
52
|
+
if (invalidationTimeoutId) {
|
|
53
|
+
clearTimeout(invalidationTimeoutId);
|
|
54
|
+
invalidationTimeoutId = null;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, [connectionStates, queryClient]);
|
|
58
|
+
};
|
|
33
59
|
const useAccount = ({ cosmos } = {}) => {
|
|
34
|
-
var _a, _b, _c, _d, _e, _f
|
|
60
|
+
var _a, _b, _c, _d, _e, _f;
|
|
35
61
|
const client = useInternalClient();
|
|
36
62
|
const { data: isFullyLoggedIn, isSuccess, isLoading: isFullyLoggedInLoading } = useIsFullyLoggedIn();
|
|
37
63
|
const evmContext = useStore((state) => state.evmContext);
|
|
38
64
|
const { useAccount: useEvmAccount } = useContext(evmContext);
|
|
39
65
|
const evmAccount = useEvmAccount();
|
|
40
|
-
const evmQueryKeys = [evmAccount == null ? void 0 : evmAccount.
|
|
66
|
+
const evmQueryKeys = [evmAccount == null ? void 0 : evmAccount.addresses, evmAccount == null ? void 0 : evmAccount.chainId];
|
|
41
67
|
const cosmosContext = useStore((state) => state.cosmosContext);
|
|
42
68
|
const { useAccount: useCosmosAccount } = useContext(cosmosContext);
|
|
43
69
|
const cosmosAccount = useCosmosAccount(cosmos);
|
|
44
|
-
const cosmosQueryKeys = [cosmosAccount == null ? void 0 : cosmosAccount.
|
|
70
|
+
const cosmosQueryKeys = [cosmosAccount == null ? void 0 : cosmosAccount.data];
|
|
45
71
|
const solanaContext = useStore((state) => state.solanaContext);
|
|
46
72
|
const { useWallet: useSolanaWallet } = useContext(solanaContext);
|
|
47
73
|
const solanaWallet = useSolanaWallet();
|
|
48
|
-
const solanaQueryKeys = [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
74
|
+
const solanaQueryKeys = [(_b = (_a = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _a.adapter) == null ? void 0 : _b.publicKey];
|
|
75
|
+
const solanaAdapter = (_c = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _c.adapter;
|
|
76
|
+
const queryKey = [
|
|
77
|
+
ACCOUNT_BASE_KEY,
|
|
78
|
+
isFullyLoggedIn != null ? isFullyLoggedIn : null,
|
|
79
|
+
isFullyLoggedInLoading,
|
|
80
|
+
(_d = client == null ? void 0 : client.userId) != null ? _d : null,
|
|
81
|
+
evmQueryKeys,
|
|
82
|
+
cosmosQueryKeys,
|
|
83
|
+
solanaQueryKeys
|
|
52
84
|
];
|
|
53
|
-
const
|
|
85
|
+
const connectionStates = useMemo(() => {
|
|
86
|
+
var _a2, _b2;
|
|
87
|
+
return {
|
|
88
|
+
evm: !!(evmAccount == null ? void 0 : evmAccount.isConnected),
|
|
89
|
+
cosmos: !!(cosmosAccount == null ? void 0 : cosmosAccount.isConnected),
|
|
90
|
+
solana: !!((_b2 = (_a2 = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _a2.adapter) == null ? void 0 : _b2.connected)
|
|
91
|
+
};
|
|
92
|
+
}, [!!(evmAccount == null ? void 0 : evmAccount.isConnected), !!(cosmosAccount == null ? void 0 : cosmosAccount.isConnected), !!((_f = (_e = solanaWallet == null ? void 0 : solanaWallet.wallet) == null ? void 0 : _e.adapter) == null ? void 0 : _f.connected)]);
|
|
93
|
+
useInvalidation(connectionStates, queryKey);
|
|
54
94
|
const { data, isLoading } = useQuery({
|
|
55
95
|
enabled: isSuccess && !!client,
|
|
56
|
-
queryKey
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
isFullyLoggedInLoading,
|
|
60
|
-
(_h = client == null ? void 0 : client.userId) != null ? _h : null,
|
|
61
|
-
evmQueryKeys,
|
|
62
|
-
cosmosQueryKeys,
|
|
63
|
-
solanaQueryKeys
|
|
64
|
-
],
|
|
65
|
-
queryFn: () => {
|
|
66
|
-
const paraAccount = getEmbeddedAccount(client, isFullyLoggedIn);
|
|
96
|
+
queryKey,
|
|
97
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
98
|
+
const paraAccount = yield getEmbeddedAccount(client, isFullyLoggedIn);
|
|
67
99
|
let connectionType = "none";
|
|
68
100
|
if (paraAccount.isConnected) {
|
|
69
101
|
connectionType = "embedded";
|
|
@@ -74,7 +106,7 @@ const useAccount = ({ cosmos } = {}) => {
|
|
|
74
106
|
connectionType = "external";
|
|
75
107
|
}
|
|
76
108
|
}
|
|
77
|
-
const isEmbeddedConnected =
|
|
109
|
+
const isEmbeddedConnected = connectionType === "embedded" || connectionType === "both";
|
|
78
110
|
const connectedNetworks = [];
|
|
79
111
|
if (evmAccount == null ? void 0 : evmAccount.isConnected) {
|
|
80
112
|
connectedNetworks.push("evm");
|
|
@@ -107,7 +139,7 @@ const useAccount = ({ cosmos } = {}) => {
|
|
|
107
139
|
solana: pickSolanaAdapter(solanaAdapter)
|
|
108
140
|
}
|
|
109
141
|
};
|
|
110
|
-
}
|
|
142
|
+
})
|
|
111
143
|
});
|
|
112
144
|
const defaultResp = {
|
|
113
145
|
isConnected: false,
|
|
@@ -134,7 +166,9 @@ const useAccount = ({ cosmos } = {}) => {
|
|
|
134
166
|
solana: { isConnected: false }
|
|
135
167
|
}
|
|
136
168
|
};
|
|
137
|
-
return __spreadProps(__spreadValues({}, data != null ? data : defaultResp), {
|
|
169
|
+
return __spreadProps(__spreadValues({}, data != null ? data : defaultResp), {
|
|
170
|
+
isLoading: isFullyLoggedInLoading || isLoading
|
|
171
|
+
});
|
|
138
172
|
};
|
|
139
173
|
export {
|
|
140
174
|
ACCOUNT_BASE_KEY,
|
|
@@ -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,29 @@
|
|
|
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
|
+
* Whether to return the comprehensive balance set. If `false` or `undefined`, the results will be filtered and modified based on your `ParaProvider`'s balances configuration.
|
|
17
|
+
*/
|
|
18
|
+
isComprehensive?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* React Query hook for retrieving the asset balance for your currently connected wallets.
|
|
22
|
+
*
|
|
23
|
+
* @returns {ProfileBalance}
|
|
24
|
+
* The profile balance object, containing the aggregated balance for all wallets and entries for each wallet, further divided by various assets and networks.
|
|
25
|
+
*
|
|
26
|
+
* The profile balance will be denoted in USD or in a custom asset you specify, depending on your ParaProvider configuration.
|
|
27
|
+
*/
|
|
28
|
+
export declare const useProfileBalance: (options?: UseProfileBalanceOptions) => UseQueryResult<ProfileBalance>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
import { filterProfileBalance } from "@getpara/shared";
|
|
11
|
+
const useProfileBalance = (options) => {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const client = useInternalClient();
|
|
14
|
+
const { data: isFullyLoggedIn, isSuccess } = useIsFullyLoggedIn();
|
|
15
|
+
const config = useStore((state) => {
|
|
16
|
+
var _a2;
|
|
17
|
+
return (_a2 = state.modalConfig) == null ? void 0 : _a2.balances;
|
|
18
|
+
});
|
|
19
|
+
const refs = useStore((state) => state.refs);
|
|
20
|
+
const isComprehensive = (_a = options == null ? void 0 : options.isComprehensive) != null ? _a : false;
|
|
21
|
+
const previousTriggerRef = useRef(options == null ? void 0 : options.refetchTrigger);
|
|
22
|
+
const shouldRefetchRef = useRef(false);
|
|
23
|
+
const lastQueryTimeRef = useRef(0);
|
|
24
|
+
const isInitialLoadRef = useRef(true);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if ((options == null ? void 0 : options.refetchTrigger) !== previousTriggerRef.current) {
|
|
27
|
+
shouldRefetchRef.current = true;
|
|
28
|
+
previousTriggerRef.current = options == null ? void 0 : options.refetchTrigger;
|
|
29
|
+
}
|
|
30
|
+
}, [options == null ? void 0 : options.refetchTrigger]);
|
|
31
|
+
return useQuery({
|
|
32
|
+
enabled: isSuccess && !!client,
|
|
33
|
+
queryKey: [
|
|
34
|
+
"useProfileBalance",
|
|
35
|
+
isFullyLoggedIn != null ? isFullyLoggedIn : null,
|
|
36
|
+
(_b = client == null ? void 0 : client.userId) != null ? _b : null,
|
|
37
|
+
(_c = client == null ? void 0 : client.availableWallets.map(({ address }) => address)) != null ? _c : null,
|
|
38
|
+
config != null ? config : null
|
|
39
|
+
// Note: refetchTrigger is NOT in query key to allow cache sharing
|
|
40
|
+
],
|
|
41
|
+
staleTime: 3e4,
|
|
42
|
+
retry: 3,
|
|
43
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
44
|
+
var _a2;
|
|
45
|
+
if (!client || !isFullyLoggedIn) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const isInvalidationRefetch = ((_a2 = refs.balancesInvalidationTime.current) != null ? _a2 : 0) > lastQueryTimeRef.current;
|
|
49
|
+
const isInitialLoad = isInitialLoadRef.current;
|
|
50
|
+
const profileBalance = yield client == null ? void 0 : client.getProfileBalance({
|
|
51
|
+
config,
|
|
52
|
+
refetch: shouldRefetchRef.current || isInvalidationRefetch || isInitialLoad
|
|
53
|
+
});
|
|
54
|
+
lastQueryTimeRef.current = Date.now();
|
|
55
|
+
shouldRefetchRef.current = false;
|
|
56
|
+
isInitialLoadRef.current = false;
|
|
57
|
+
return isComprehensive ? profileBalance : filterProfileBalance(profileBalance, config || { displayType: "AGGREGATED" });
|
|
58
|
+
}),
|
|
59
|
+
// We handle refetch manually
|
|
60
|
+
refetchOnWindowFocus: false
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
useProfileBalance
|
|
65
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -31,7 +31,7 @@ const useAutoSessionKeepAlive = ({ disabled }) => {
|
|
|
31
31
|
if (!sessionCookie) return null;
|
|
32
32
|
const expiresMatch = sessionCookie.match(/Expires=([^;]+)/);
|
|
33
33
|
return expiresMatch ? new Date(expiresMatch[1]) : null;
|
|
34
|
-
} catch (
|
|
34
|
+
} catch (e) {
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -3,14 +3,15 @@ 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";
|
|
14
|
+
import { useModalStore } from "../../../modal/stores/index.js";
|
|
14
15
|
const useEventListeners = ({
|
|
15
16
|
onLogin,
|
|
16
17
|
onLogout,
|
|
@@ -25,8 +26,10 @@ const useEventListeners = ({
|
|
|
25
26
|
onGuestWalletsCreated
|
|
26
27
|
} = {}) => {
|
|
27
28
|
const queryClient = useQueryClient();
|
|
29
|
+
const refs = useStore((state) => state.refs);
|
|
28
30
|
const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
|
|
29
31
|
const { updateSelectedWallet } = useWalletState();
|
|
32
|
+
const setSendTx = useModalStore((state) => state.setSendTx);
|
|
30
33
|
const loginOrSetupListener = useCallback(() => {
|
|
31
34
|
queryClient.refetchQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
|
|
32
35
|
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
@@ -49,18 +52,21 @@ const useEventListeners = ({
|
|
|
49
52
|
);
|
|
50
53
|
const accountCreationListener = useCallback(
|
|
51
54
|
(event) => {
|
|
55
|
+
loginOrSetupListener();
|
|
52
56
|
onAccountCreation == null ? void 0 : onAccountCreation(event);
|
|
53
57
|
},
|
|
54
|
-
[onAccountCreation]
|
|
58
|
+
[loginOrSetupListener, onAccountCreation]
|
|
55
59
|
);
|
|
56
60
|
const logoutListener = useCallback(
|
|
57
61
|
(event) => {
|
|
58
|
-
queryClient.
|
|
59
|
-
queryClient.
|
|
62
|
+
queryClient.setQueriesData({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] }, false);
|
|
63
|
+
queryClient.invalidateQueries({ queryKey: [IS_FULLY_LOGGED_IN_BASE_KEY] });
|
|
64
|
+
queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
60
65
|
clearSelectedWallet();
|
|
66
|
+
setSendTx(void 0);
|
|
61
67
|
onLogout == null ? void 0 : onLogout(event);
|
|
62
68
|
},
|
|
63
|
-
[queryClient, clearSelectedWallet, onLogout]
|
|
69
|
+
[queryClient, clearSelectedWallet, setSendTx, onLogout]
|
|
64
70
|
);
|
|
65
71
|
const signMessageListener = useCallback(
|
|
66
72
|
(event) => {
|
|
@@ -113,7 +119,15 @@ const useEventListeners = ({
|
|
|
113
119
|
},
|
|
114
120
|
[queryClient, updateSelectedWallet, onGuestWalletsCreated]
|
|
115
121
|
);
|
|
122
|
+
const assetTransferListener = useCallback(() => {
|
|
123
|
+
refs.balancesInvalidationTime.current = Date.now();
|
|
124
|
+
queryClient.invalidateQueries({
|
|
125
|
+
queryKey: ["useProfileBalance"],
|
|
126
|
+
refetchType: "active"
|
|
127
|
+
});
|
|
128
|
+
}, [queryClient, refs.balancesInvalidationTime]);
|
|
116
129
|
useEffect(() => {
|
|
130
|
+
if (typeof window === "undefined") return;
|
|
117
131
|
window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
118
132
|
window.addEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
119
133
|
window.addEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
|
|
@@ -125,7 +139,9 @@ const useEventListeners = ({
|
|
|
125
139
|
window.addEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
126
140
|
window.addEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
127
141
|
window.addEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
|
|
142
|
+
window.addEventListener(ParaEvent.ASSET_TRANSFERRED, assetTransferListener);
|
|
128
143
|
return () => {
|
|
144
|
+
if (typeof window === "undefined") return;
|
|
129
145
|
window.removeEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
130
146
|
window.removeEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
131
147
|
window.removeEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
|
|
@@ -137,6 +153,7 @@ const useEventListeners = ({
|
|
|
137
153
|
window.removeEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
138
154
|
window.removeEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
139
155
|
window.removeEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
|
|
156
|
+
window.removeEventListener(ParaEvent.ASSET_TRANSFERRED, assetTransferListener);
|
|
140
157
|
};
|
|
141
158
|
}, [
|
|
142
159
|
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 };
|