@mezo-org/passport 0.4.0-dev.4 → 0.4.0-dev.41
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/README.md +18 -22
- package/dist/src/api/auth.d.ts +36 -59
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/api/auth.js +21 -49
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +24 -0
- package/dist/src/api/client.d.ts.map +1 -0
- package/dist/src/api/client.js +54 -0
- package/dist/src/api/client.js.map +1 -0
- package/dist/src/api/fetch-error.d.ts +5 -0
- package/dist/src/api/fetch-error.d.ts.map +1 -0
- package/dist/src/api/fetch-error.js +8 -0
- package/dist/src/api/fetch-error.js.map +1 -0
- package/dist/src/api/index.d.ts +3 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +3 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/api/portal.d.ts +33 -0
- package/dist/src/api/portal.d.ts.map +1 -0
- package/dist/src/api/portal.js +23 -0
- package/dist/src/api/portal.js.map +1 -0
- package/dist/src/assets/DefaultAvatar.d.ts +5 -0
- package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
- package/dist/src/assets/DefaultAvatar.js +21 -0
- package/dist/src/assets/DefaultAvatar.js.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +8 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js +39 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Content.d.ts +23 -0
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Content.js +27 -0
- package/dist/src/components/Dropdown/Content.js.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts +27 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.js +68 -0
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.js +34 -0
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +48 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.js +57 -0
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js +64 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +44 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
- package/dist/src/components/Dropdown/index.d.ts +3 -0
- package/dist/src/components/Dropdown/index.d.ts.map +1 -0
- package/dist/src/components/Dropdown/index.js +2 -0
- package/dist/src/components/Dropdown/index.js.map +1 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/config.d.ts +41 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +20 -5
- package/dist/src/config.js.map +1 -1
- package/dist/src/constants.d.ts +6 -2
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +8 -4
- package/dist/src/constants.js.map +1 -1
- package/dist/src/hooks/constants.d.ts +1 -0
- package/dist/src/hooks/constants.d.ts.map +1 -1
- package/dist/src/hooks/constants.js +1 -0
- package/dist/src/hooks/constants.js.map +1 -1
- package/dist/src/hooks/index.d.ts +4 -1
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +4 -1
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +7 -0
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
- package/dist/src/hooks/useAssetsConversionRates.js +24 -0
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
- package/dist/src/hooks/useAuthApiClient.d.ts +1 -1
- package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +73 -0
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -0
- package/dist/src/hooks/useAuthenticateWithWallet.js +69 -0
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -0
- package/dist/src/hooks/useBorrowData.d.ts +60 -0
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
- package/dist/src/hooks/useBorrowData.js +122 -0
- package/dist/src/hooks/useBorrowData.js.map +1 -0
- package/dist/src/hooks/useCreateAccount.d.ts +23 -173
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +7 -4
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useCreateSession.d.ts +12 -101
- package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
- package/dist/src/hooks/useCreateSession.js +10 -8
- package/dist/src/hooks/useCreateSession.js.map +1 -1
- package/dist/src/hooks/useDropdownData.d.ts +47 -0
- package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
- package/dist/src/hooks/useDropdownData.js +95 -0
- package/dist/src/hooks/useDropdownData.js.map +1 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts.map +1 -1
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js +1 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js.map +1 -1
- package/dist/src/hooks/useGetAccountByAddress.d.ts +2 -2
- package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
- package/dist/src/hooks/useGetAccountByMezoId.d.ts +2 -2
- package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts +16 -2
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +25 -3
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useGetSession.d.ts +1 -1
- package/dist/src/hooks/useGetSession.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts +15 -175
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +7 -4
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
- package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
- package/dist/src/hooks/usePortalApiClient.js +6 -0
- package/dist/src/hooks/usePortalApiClient.js.map +1 -0
- package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
- package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
- package/dist/src/hooks/useRefreshPassport.js +44 -0
- package/dist/src/hooks/useRefreshPassport.js.map +1 -0
- package/dist/src/hooks/useSignInWithDiscord.d.ts +12 -100
- package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithDiscord.js +6 -3
- package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.d.ts +12 -100
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.js +6 -34
- package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
- package/dist/src/hooks/useSignOut.d.ts +12 -28
- package/dist/src/hooks/useSignOut.d.ts.map +1 -1
- package/dist/src/hooks/useSignOut.js +7 -4
- package/dist/src/hooks/useSignOut.js.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +73 -0
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -0
- package/dist/src/hooks/useSignUpWithWallet.js +11 -0
- package/dist/src/hooks/useSignUpWithWallet.js.map +1 -0
- package/dist/src/hooks/useTokensBalances.d.ts +74 -0
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
- package/dist/src/hooks/useTokensBalances.js +140 -0
- package/dist/src/hooks/useTokensBalances.js.map +1 -0
- package/dist/src/hooks/useUpdateMezoId.d.ts +30 -136
- package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useUpdateMezoId.js +7 -4
- package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +13 -0
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
- package/dist/src/hooks/useWalletAccount.js +29 -0
- package/dist/src/hooks/useWalletAccount.js.map +1 -0
- package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
- package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
- package/dist/src/hooks/useWatchTransferEvents.js +63 -0
- package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/contracts/index.d.ts +13 -0
- package/dist/src/lib/contracts/index.d.ts.map +1 -0
- package/dist/src/lib/contracts/index.js +57 -0
- package/dist/src/lib/contracts/index.js.map +1 -0
- package/dist/src/provider.d.ts +10 -13
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +11 -20
- package/dist/src/provider.js.map +1 -1
- package/dist/src/stores/dropdownStore.d.ts +12 -0
- package/dist/src/stores/dropdownStore.d.ts.map +1 -0
- package/dist/src/stores/dropdownStore.js +13 -0
- package/dist/src/stores/dropdownStore.js.map +1 -0
- package/dist/src/utils/address.d.ts +15 -0
- package/dist/src/utils/address.d.ts.map +1 -0
- package/dist/src/utils/address.js +37 -0
- package/dist/src/utils/address.js.map +1 -0
- package/dist/src/utils/address.test.d.ts +2 -0
- package/dist/src/utils/address.test.d.ts.map +1 -0
- package/dist/src/utils/address.test.js +40 -0
- package/dist/src/utils/address.test.js.map +1 -0
- package/dist/src/utils/cryptoAssets.d.ts +44 -0
- package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.js +131 -0
- package/dist/src/utils/cryptoAssets.js.map +1 -0
- package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
- package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.test.js +67 -0
- package/dist/src/utils/cryptoAssets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +14 -0
- package/dist/src/utils/currency.d.ts.map +1 -0
- package/dist/src/utils/currency.js +27 -0
- package/dist/src/utils/currency.js.map +1 -0
- package/dist/src/utils/currency.test.d.ts +2 -0
- package/dist/src/utils/currency.test.d.ts.map +1 -0
- package/dist/src/utils/currency.test.js +34 -0
- package/dist/src/utils/currency.test.js.map +1 -0
- package/dist/src/utils/numbers.d.ts +58 -0
- package/dist/src/utils/numbers.d.ts.map +1 -0
- package/dist/src/utils/numbers.js +132 -0
- package/dist/src/utils/numbers.js.map +1 -0
- package/dist/src/utils/numbers.test.d.ts +2 -0
- package/dist/src/utils/numbers.test.d.ts.map +1 -0
- package/dist/src/utils/numbers.test.js +170 -0
- package/dist/src/utils/numbers.test.js.map +1 -0
- package/package.json +13 -5
- package/src/api/auth.ts +72 -129
- package/src/api/client.ts +78 -0
- package/src/api/fetch-error.ts +8 -0
- package/src/api/index.ts +2 -0
- package/src/api/portal.ts +57 -0
- package/src/assets/DefaultAvatar.tsx +74 -0
- package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
- package/src/components/Dropdown/Content.tsx +98 -0
- package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
- package/src/components/Dropdown/Dropdown.tsx +148 -0
- package/src/components/Dropdown/ListingItem.tsx +80 -0
- package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
- package/src/components/Dropdown/README.md +41 -0
- package/src/components/Dropdown/Receive/Receive.tsx +119 -0
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
- package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
- package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +68 -0
- package/src/components/Dropdown/Root/Root.tsx +147 -0
- package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +91 -0
- package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
- package/src/components/Dropdown/index.ts +2 -0
- package/src/components/index.ts +1 -0
- package/src/config.ts +27 -6
- package/src/constants.ts +8 -4
- package/src/hooks/constants.ts +1 -0
- package/src/hooks/index.ts +7 -1
- package/src/hooks/useAssetsConversionRates.ts +32 -0
- package/src/hooks/useAuthenticateWithWallet.ts +102 -0
- package/src/hooks/useBorrowData.ts +143 -0
- package/src/hooks/useCreateAccount.ts +19 -5
- package/src/hooks/useCreateSession.ts +22 -9
- package/src/hooks/useDropdownData.ts +139 -0
- package/src/hooks/useEnsureNoSessionAndFetchNonce.ts +1 -0
- package/src/hooks/useGetAccountByAddress.ts +2 -2
- package/src/hooks/useGetAccountByMezoId.ts +2 -2
- package/src/hooks/useGetCurrentAccount.ts +46 -6
- package/src/hooks/useGetSession.ts +1 -1
- package/src/hooks/useLinkAccount.ts +18 -5
- package/src/hooks/usePortalApiClient.ts +6 -0
- package/src/hooks/useRefreshPassport.ts +56 -0
- package/src/hooks/useSignInWithDiscord.ts +14 -5
- package/src/hooks/useSignInWithWallet.ts +14 -42
- package/src/hooks/useSignOut.ts +18 -4
- package/src/hooks/useSignUpWithWallet.ts +21 -0
- package/src/hooks/useTokensBalances.ts +187 -0
- package/src/hooks/useUpdateMezoId.ts +19 -4
- package/src/hooks/useWalletAccount.ts +55 -0
- package/src/hooks/useWatchTransferEvents.ts +74 -0
- package/src/index.ts +9 -1
- package/src/lib/contracts/index.ts +88 -0
- package/src/provider.ts +30 -37
- package/src/stores/dropdownStore.ts +20 -0
- package/src/utils/address.test.ts +48 -0
- package/src/utils/address.ts +45 -0
- package/src/utils/cryptoAssets.test.ts +79 -0
- package/src/utils/cryptoAssets.ts +173 -0
- package/src/utils/currency.test.ts +38 -0
- package/src/utils/currency.ts +32 -0
- package/src/utils/numbers.test.ts +220 -0
- package/src/utils/numbers.ts +188 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { MutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import type { Session } from "../api";
|
|
3
|
+
declare function useSignInWithWallet(mutationOptions?: Omit<MutationOptions<Session>, "mutationFn" | "mutationKey">): {
|
|
2
4
|
data: undefined;
|
|
3
5
|
variables: undefined;
|
|
4
6
|
error: null;
|
|
@@ -13,28 +15,8 @@ declare function useSignInWithWallet(): {
|
|
|
13
15
|
failureReason: Error | null;
|
|
14
16
|
isPaused: boolean;
|
|
15
17
|
submittedAt: number;
|
|
16
|
-
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<
|
|
17
|
-
|
|
18
|
-
expiresAt: number;
|
|
19
|
-
sessionLinks: {
|
|
20
|
-
_links: {
|
|
21
|
-
account: "/session/account";
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
} | {
|
|
25
|
-
redirectTo: string;
|
|
26
|
-
}, Error, void, unknown>;
|
|
27
|
-
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
28
|
-
expiresIn: number;
|
|
29
|
-
expiresAt: number;
|
|
30
|
-
sessionLinks: {
|
|
31
|
-
_links: {
|
|
32
|
-
account: "/session/account";
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
} | {
|
|
36
|
-
redirectTo: string;
|
|
37
|
-
}, Error, void, unknown>;
|
|
18
|
+
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
19
|
+
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
38
20
|
} | {
|
|
39
21
|
data: undefined;
|
|
40
22
|
variables: void;
|
|
@@ -50,28 +32,8 @@ declare function useSignInWithWallet(): {
|
|
|
50
32
|
failureReason: Error | null;
|
|
51
33
|
isPaused: boolean;
|
|
52
34
|
submittedAt: number;
|
|
53
|
-
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<
|
|
54
|
-
|
|
55
|
-
expiresAt: number;
|
|
56
|
-
sessionLinks: {
|
|
57
|
-
_links: {
|
|
58
|
-
account: "/session/account";
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
} | {
|
|
62
|
-
redirectTo: string;
|
|
63
|
-
}, Error, void, unknown>;
|
|
64
|
-
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
65
|
-
expiresIn: number;
|
|
66
|
-
expiresAt: number;
|
|
67
|
-
sessionLinks: {
|
|
68
|
-
_links: {
|
|
69
|
-
account: "/session/account";
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
} | {
|
|
73
|
-
redirectTo: string;
|
|
74
|
-
}, Error, void, unknown>;
|
|
35
|
+
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
36
|
+
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
75
37
|
} | {
|
|
76
38
|
data: undefined;
|
|
77
39
|
error: Error;
|
|
@@ -87,40 +49,10 @@ declare function useSignInWithWallet(): {
|
|
|
87
49
|
failureReason: Error | null;
|
|
88
50
|
isPaused: boolean;
|
|
89
51
|
submittedAt: number;
|
|
90
|
-
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<
|
|
91
|
-
|
|
92
|
-
expiresAt: number;
|
|
93
|
-
sessionLinks: {
|
|
94
|
-
_links: {
|
|
95
|
-
account: "/session/account";
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
} | {
|
|
99
|
-
redirectTo: string;
|
|
100
|
-
}, Error, void, unknown>;
|
|
101
|
-
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
102
|
-
expiresIn: number;
|
|
103
|
-
expiresAt: number;
|
|
104
|
-
sessionLinks: {
|
|
105
|
-
_links: {
|
|
106
|
-
account: "/session/account";
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
} | {
|
|
110
|
-
redirectTo: string;
|
|
111
|
-
}, Error, void, unknown>;
|
|
52
|
+
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
53
|
+
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
112
54
|
} | {
|
|
113
|
-
data:
|
|
114
|
-
expiresIn: number;
|
|
115
|
-
expiresAt: number;
|
|
116
|
-
sessionLinks: {
|
|
117
|
-
_links: {
|
|
118
|
-
account: "/session/account";
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
} | {
|
|
122
|
-
redirectTo: string;
|
|
123
|
-
};
|
|
55
|
+
data: Session;
|
|
124
56
|
error: null;
|
|
125
57
|
variables: void;
|
|
126
58
|
isError: false;
|
|
@@ -134,28 +66,8 @@ declare function useSignInWithWallet(): {
|
|
|
134
66
|
failureReason: Error | null;
|
|
135
67
|
isPaused: boolean;
|
|
136
68
|
submittedAt: number;
|
|
137
|
-
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<
|
|
138
|
-
|
|
139
|
-
expiresAt: number;
|
|
140
|
-
sessionLinks: {
|
|
141
|
-
_links: {
|
|
142
|
-
account: "/session/account";
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
} | {
|
|
146
|
-
redirectTo: string;
|
|
147
|
-
}, Error, void, unknown>;
|
|
148
|
-
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
149
|
-
expiresIn: number;
|
|
150
|
-
expiresAt: number;
|
|
151
|
-
sessionLinks: {
|
|
152
|
-
_links: {
|
|
153
|
-
account: "/session/account";
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
} | {
|
|
157
|
-
redirectTo: string;
|
|
158
|
-
}, Error, void, unknown>;
|
|
69
|
+
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
70
|
+
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
159
71
|
};
|
|
160
72
|
export { useSignInWithWallet };
|
|
161
73
|
//# sourceMappingURL=useSignInWithWallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignInWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSignInWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,iBAAS,mBAAmB,CAC1B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,OAAO,CAAC,EACxB,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUP;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -1,38 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { useCreateSession } from "./useCreateSession";
|
|
5
|
-
import { createSignInWithWalletMessage } from "../utils/siww";
|
|
6
|
-
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
|
|
7
|
-
function useSignInWithWallet() {
|
|
8
|
-
const { chainId, address, connector } = useAccount();
|
|
9
|
-
const { btcAddress } = useBitcoinAccount();
|
|
10
|
-
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
|
|
11
|
-
const { createSessionAsync } = useCreateSession();
|
|
12
|
-
const { signMessageAsync } = useSignMessage();
|
|
13
|
-
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
14
|
-
mutationFn: async () => {
|
|
15
|
-
if (!address) {
|
|
16
|
-
throw new Error("Sign in error: Wallet not connected!");
|
|
17
|
-
}
|
|
18
|
-
const nonce = await ensureNoSessionAndFetchNonce();
|
|
19
|
-
const networkFamily = btcAddress ? "bitcoin" : "evm";
|
|
20
|
-
const messageResult = createSignInWithWalletMessage(btcAddress ? btcAddress : address, nonce, networkFamily, chainId);
|
|
21
|
-
const signatureResult = await signMessageAsync({
|
|
22
|
-
message: messageResult,
|
|
23
|
-
connector,
|
|
24
|
-
});
|
|
25
|
-
return createSessionAsync({
|
|
26
|
-
type: "wallet",
|
|
27
|
-
message: messageResult,
|
|
28
|
-
signature: signatureResult,
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
});
|
|
1
|
+
import { useAuthenticateWithWallet } from "./useAuthenticateWithWallet";
|
|
2
|
+
function useSignInWithWallet(mutationOptions = {}) {
|
|
3
|
+
const { authenticateWithWallet, authenticateWithWalletAsync, ...rest } = useAuthenticateWithWallet(false, mutationOptions);
|
|
32
4
|
return {
|
|
33
|
-
signInWithWallet:
|
|
34
|
-
signInWithWalletAsync:
|
|
35
|
-
...
|
|
5
|
+
signInWithWallet: authenticateWithWallet,
|
|
6
|
+
signInWithWalletAsync: authenticateWithWalletAsync,
|
|
7
|
+
...rest,
|
|
36
8
|
};
|
|
37
9
|
}
|
|
38
10
|
export { useSignInWithWallet };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignInWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSignInWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAGvE,SAAS,mBAAmB,CAC1B,kBAGI,EAAE;IAEN,MAAM,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,GAAG,IAAI,EAAE,GACpE,yBAAyB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAA;IAEnD,OAAO;QACL,gBAAgB,EAAE,sBAAsB;QACxC,qBAAqB,EAAE,2BAA2B;QAClD,GAAG,IAAI;KACR,CAAA;AACH,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { MutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import type { DeleteSessionResponse } from "../api";
|
|
3
|
+
export declare function useSignOut(mutationOptions?: Omit<MutationOptions<DeleteSessionResponse>, "mutationFn" | "mutationKey">): {
|
|
2
4
|
data: undefined;
|
|
3
5
|
variables: undefined;
|
|
4
6
|
error: null;
|
|
@@ -13,12 +15,8 @@ export declare function useSignOut(useMutationOptions?: {}): {
|
|
|
13
15
|
failureReason: Error | null;
|
|
14
16
|
isPaused: boolean;
|
|
15
17
|
submittedAt: number;
|
|
16
|
-
signOut: import("@tanstack/react-query").UseMutateFunction<
|
|
17
|
-
|
|
18
|
-
}, Error, void, unknown>;
|
|
19
|
-
signOutAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
20
|
-
message: string;
|
|
21
|
-
}, Error, void, unknown>;
|
|
18
|
+
signOut: import("@tanstack/react-query").UseMutateFunction<DeleteSessionResponse, Error, void, unknown>;
|
|
19
|
+
signOutAsync: import("@tanstack/react-query").UseMutateAsyncFunction<DeleteSessionResponse, Error, void, unknown>;
|
|
22
20
|
} | {
|
|
23
21
|
data: undefined;
|
|
24
22
|
variables: void;
|
|
@@ -34,12 +32,8 @@ export declare function useSignOut(useMutationOptions?: {}): {
|
|
|
34
32
|
failureReason: Error | null;
|
|
35
33
|
isPaused: boolean;
|
|
36
34
|
submittedAt: number;
|
|
37
|
-
signOut: import("@tanstack/react-query").UseMutateFunction<
|
|
38
|
-
|
|
39
|
-
}, Error, void, unknown>;
|
|
40
|
-
signOutAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
41
|
-
message: string;
|
|
42
|
-
}, Error, void, unknown>;
|
|
35
|
+
signOut: import("@tanstack/react-query").UseMutateFunction<DeleteSessionResponse, Error, void, unknown>;
|
|
36
|
+
signOutAsync: import("@tanstack/react-query").UseMutateAsyncFunction<DeleteSessionResponse, Error, void, unknown>;
|
|
43
37
|
} | {
|
|
44
38
|
data: undefined;
|
|
45
39
|
error: Error;
|
|
@@ -55,16 +49,10 @@ export declare function useSignOut(useMutationOptions?: {}): {
|
|
|
55
49
|
failureReason: Error | null;
|
|
56
50
|
isPaused: boolean;
|
|
57
51
|
submittedAt: number;
|
|
58
|
-
signOut: import("@tanstack/react-query").UseMutateFunction<
|
|
59
|
-
|
|
60
|
-
}, Error, void, unknown>;
|
|
61
|
-
signOutAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
62
|
-
message: string;
|
|
63
|
-
}, Error, void, unknown>;
|
|
52
|
+
signOut: import("@tanstack/react-query").UseMutateFunction<DeleteSessionResponse, Error, void, unknown>;
|
|
53
|
+
signOutAsync: import("@tanstack/react-query").UseMutateAsyncFunction<DeleteSessionResponse, Error, void, unknown>;
|
|
64
54
|
} | {
|
|
65
|
-
data:
|
|
66
|
-
message: string;
|
|
67
|
-
};
|
|
55
|
+
data: DeleteSessionResponse;
|
|
68
56
|
error: null;
|
|
69
57
|
variables: void;
|
|
70
58
|
isError: false;
|
|
@@ -78,11 +66,7 @@ export declare function useSignOut(useMutationOptions?: {}): {
|
|
|
78
66
|
failureReason: Error | null;
|
|
79
67
|
isPaused: boolean;
|
|
80
68
|
submittedAt: number;
|
|
81
|
-
signOut: import("@tanstack/react-query").UseMutateFunction<
|
|
82
|
-
|
|
83
|
-
}, Error, void, unknown>;
|
|
84
|
-
signOutAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
85
|
-
message: string;
|
|
86
|
-
}, Error, void, unknown>;
|
|
69
|
+
signOut: import("@tanstack/react-query").UseMutateFunction<DeleteSessionResponse, Error, void, unknown>;
|
|
70
|
+
signOutAsync: import("@tanstack/react-query").UseMutateAsyncFunction<DeleteSessionResponse, Error, void, unknown>;
|
|
87
71
|
};
|
|
88
72
|
//# sourceMappingURL=useSignOut.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignOut.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignOut.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSignOut.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignOut.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGhB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAEnD,wBAAgB,UAAU,CACxB,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,CAAC,EACtC,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBP"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
1
|
+
import { useMutation, useQueryClient, } from "@tanstack/react-query";
|
|
2
2
|
import { useAuthApiClient } from "./useAuthApiClient";
|
|
3
3
|
import { QUERY_KEYS } from "./constants";
|
|
4
|
-
export function useSignOut(
|
|
4
|
+
export function useSignOut(mutationOptions = {}) {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
6
|
const authApiClient = useAuthApiClient();
|
|
7
|
+
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
7
8
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
8
9
|
mutationFn: () => authApiClient.deleteSession(),
|
|
9
|
-
onSuccess: () => {
|
|
10
|
+
onSuccess: (data, variables, context) => {
|
|
10
11
|
queryClient.resetQueries({ queryKey: [QUERY_KEYS.SESSION] });
|
|
11
12
|
queryClient.resetQueries({
|
|
12
13
|
queryKey: [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT],
|
|
13
14
|
});
|
|
15
|
+
if (customOnSuccess)
|
|
16
|
+
customOnSuccess(data, variables, context);
|
|
14
17
|
},
|
|
15
|
-
...
|
|
18
|
+
...restMutationOptions,
|
|
16
19
|
});
|
|
17
20
|
return { signOut: mutate, signOutAsync: mutateAsync, ...rest };
|
|
18
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignOut.js","sourceRoot":"","sources":["../../../src/hooks/useSignOut.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useSignOut.js","sourceRoot":"","sources":["../../../src/hooks/useSignOut.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,UAAU,UAAU,CACxB,kBAGI,EAAE;IAEN,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IAExC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,mBAAmB,EAAE,GAAG,eAAe,CAAA;IAE9E,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,CAAC;QACnD,UAAU,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE;QAC/C,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACtC,WAAW,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAC5D,WAAW,CAAC,YAAY,CAAC;gBACvB,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;aACnD,CAAC,CAAA;YAEF,IAAI,eAAe;gBAAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAA;IAEF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAChE,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { MutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import type { Session } from "../api";
|
|
3
|
+
declare function useSignUpWithWallet(mutationOptions?: Omit<MutationOptions<Session>, "mutationFn" | "mutationKey">): {
|
|
4
|
+
data: undefined;
|
|
5
|
+
variables: undefined;
|
|
6
|
+
error: null;
|
|
7
|
+
isError: false;
|
|
8
|
+
isIdle: true;
|
|
9
|
+
isPending: false;
|
|
10
|
+
isSuccess: false;
|
|
11
|
+
status: "idle";
|
|
12
|
+
reset: () => void;
|
|
13
|
+
context: unknown;
|
|
14
|
+
failureCount: number;
|
|
15
|
+
failureReason: Error | null;
|
|
16
|
+
isPaused: boolean;
|
|
17
|
+
submittedAt: number;
|
|
18
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
19
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
20
|
+
} | {
|
|
21
|
+
data: undefined;
|
|
22
|
+
variables: void;
|
|
23
|
+
error: null;
|
|
24
|
+
isError: false;
|
|
25
|
+
isIdle: false;
|
|
26
|
+
isPending: true;
|
|
27
|
+
isSuccess: false;
|
|
28
|
+
status: "pending";
|
|
29
|
+
reset: () => void;
|
|
30
|
+
context: unknown;
|
|
31
|
+
failureCount: number;
|
|
32
|
+
failureReason: Error | null;
|
|
33
|
+
isPaused: boolean;
|
|
34
|
+
submittedAt: number;
|
|
35
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
36
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
37
|
+
} | {
|
|
38
|
+
data: undefined;
|
|
39
|
+
error: Error;
|
|
40
|
+
variables: void;
|
|
41
|
+
isError: true;
|
|
42
|
+
isIdle: false;
|
|
43
|
+
isPending: false;
|
|
44
|
+
isSuccess: false;
|
|
45
|
+
status: "error";
|
|
46
|
+
reset: () => void;
|
|
47
|
+
context: unknown;
|
|
48
|
+
failureCount: number;
|
|
49
|
+
failureReason: Error | null;
|
|
50
|
+
isPaused: boolean;
|
|
51
|
+
submittedAt: number;
|
|
52
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
53
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
54
|
+
} | {
|
|
55
|
+
data: Session;
|
|
56
|
+
error: null;
|
|
57
|
+
variables: void;
|
|
58
|
+
isError: false;
|
|
59
|
+
isIdle: false;
|
|
60
|
+
isPending: false;
|
|
61
|
+
isSuccess: true;
|
|
62
|
+
status: "success";
|
|
63
|
+
reset: () => void;
|
|
64
|
+
context: unknown;
|
|
65
|
+
failureCount: number;
|
|
66
|
+
failureReason: Error | null;
|
|
67
|
+
isPaused: boolean;
|
|
68
|
+
submittedAt: number;
|
|
69
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
70
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
71
|
+
};
|
|
72
|
+
export { useSignUpWithWallet };
|
|
73
|
+
//# sourceMappingURL=useSignUpWithWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignUpWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignUpWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,iBAAS,mBAAmB,CAC1B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,OAAO,CAAC,EACxB,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUP;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useAuthenticateWithWallet } from "./useAuthenticateWithWallet";
|
|
2
|
+
function useSignUpWithWallet(mutationOptions = {}) {
|
|
3
|
+
const { authenticateWithWallet, authenticateWithWalletAsync, ...rest } = useAuthenticateWithWallet(true, mutationOptions);
|
|
4
|
+
return {
|
|
5
|
+
signUpWithWallet: authenticateWithWallet,
|
|
6
|
+
signUpWithWalletAsync: authenticateWithWalletAsync,
|
|
7
|
+
...rest,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export { useSignUpWithWallet };
|
|
11
|
+
//# sourceMappingURL=useSignUpWithWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignUpWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useSignUpWithWallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAGvE,SAAS,mBAAmB,CAC1B,kBAGI,EAAE;IAEN,MAAM,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,GAAG,IAAI,EAAE,GACpE,yBAAyB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAA;IAElD,OAAO;QACL,gBAAgB,EAAE,sBAAsB;QACxC,qBAAqB,EAAE,2BAA2B;QAClD,GAAG,IAAI;KACR,CAAA;AACH,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { MezoChainToken } from "../lib/contracts";
|
|
2
|
+
type UseMezoChainTokensBalancesOptions<T> = {
|
|
3
|
+
tokens?: T;
|
|
4
|
+
queryOptions?: object;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Hook to get the balance of a list of tokens for the current account
|
|
8
|
+
* @param options.tokens The list of tokens to get the balance for. It will
|
|
9
|
+
* fallback to all tokens if not provided.
|
|
10
|
+
* @param options.queryOptions The query options to pass to the
|
|
11
|
+
* `useReadContracts`
|
|
12
|
+
* @returns Tanstack's `useQuery` returnings with balance of tokens for the
|
|
13
|
+
* current account in form of typesafe object with token names as keys
|
|
14
|
+
* and balances as values.
|
|
15
|
+
* @dev In case of error data fallbacks to `0n`. To determine if an error
|
|
16
|
+
* occurred, check the `isError` property.
|
|
17
|
+
* @example
|
|
18
|
+
* const mezoTokensBalance = useTokensBalances({
|
|
19
|
+
* tokens: ["mT", "mxSolvBTC"],
|
|
20
|
+
* })
|
|
21
|
+
* console.log(mezoTokensBalance?.data.mT) // Eg. 0n
|
|
22
|
+
* console.log(Object.keys(mezoTokensBalance?.data)) // ["mT", "mxSolvBTC"]
|
|
23
|
+
*/
|
|
24
|
+
export declare function useTokensBalances<T extends MezoChainToken[]>(options?: UseMezoChainTokensBalancesOptions<T>): import("wagmi").UseReadContractsReturnType<{
|
|
25
|
+
address: `0x${string}`;
|
|
26
|
+
abi: readonly [{
|
|
27
|
+
readonly inputs: readonly [{
|
|
28
|
+
readonly internalType: "address";
|
|
29
|
+
readonly name: "account";
|
|
30
|
+
readonly type: "address";
|
|
31
|
+
}];
|
|
32
|
+
readonly name: "balanceOf";
|
|
33
|
+
readonly outputs: readonly [{
|
|
34
|
+
readonly internalType: "uint256";
|
|
35
|
+
readonly name: "";
|
|
36
|
+
readonly type: "uint256";
|
|
37
|
+
}];
|
|
38
|
+
readonly stateMutability: "view";
|
|
39
|
+
readonly type: "function";
|
|
40
|
+
}];
|
|
41
|
+
functionName: string;
|
|
42
|
+
args: `0x${string}`[];
|
|
43
|
+
chainId: 31611 | undefined;
|
|
44
|
+
}[], true, Record<T[number], bigint>>;
|
|
45
|
+
/**
|
|
46
|
+
* Hook for invalidating current user's token balances. Can be used to
|
|
47
|
+
* invalidate the balances manually, which forces the data to be re-fetched.
|
|
48
|
+
* @param tokens The list of tokens (as string arrays) for which we want to
|
|
49
|
+
* invalidate query for.
|
|
50
|
+
* @returns Function `invalidateTokenBalances` that invalidates token balances
|
|
51
|
+
* @example
|
|
52
|
+
* const { invalidateTokenBalances } = useInvalidateTokensBalances(["mT", "mUSD"])
|
|
53
|
+
* (...)
|
|
54
|
+
* await invalidateTokenBalances()
|
|
55
|
+
*/
|
|
56
|
+
export declare function useInvalidateTokensBalances(tokens?: MezoChainToken[]): {
|
|
57
|
+
invalidateTokensBalances: () => Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Hook for resetting current user's token balances. Can be used to reset the
|
|
61
|
+
* balances manually, which forces the data to be re-fetched.
|
|
62
|
+
* @param tokens The list of tokens (as string arrays) for which we want to
|
|
63
|
+
* reset query for.
|
|
64
|
+
* @returns Function `resetTokenBalances` that invalidates token balances
|
|
65
|
+
* @example
|
|
66
|
+
* const { resetTokenBalances } = useResetTokensBalances(["mT", "mUSD"])
|
|
67
|
+
* (...)
|
|
68
|
+
* await resetTokenBalances()
|
|
69
|
+
*/
|
|
70
|
+
export declare function useResetTokensBalances(tokens?: MezoChainToken[]): {
|
|
71
|
+
resetTokenBalances: () => Promise<void>;
|
|
72
|
+
};
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=useTokensBalances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTokensBalances.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTokensBalances.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,cAAc,EACf,MAAM,kBAAkB,CAAA;AA8CzB,KAAK,iCAAiC,CAAC,CAAC,IAAI;IAC1C,MAAM,CAAC,EAAE,CAAC,CAAA;IACV,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAAE,EAC1D,OAAO,GAAE,iCAAiC,CAAC,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;sCAuDnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE;;EAapE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE;;EAa/D"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useReadContracts } from "wagmi";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { usePassportContext } from "./usePassportContext";
|
|
5
|
+
import { mainnetTokenContracts, testnetTokenContracts, } from "../lib/contracts";
|
|
6
|
+
import useWalletAccount from "./useWalletAccount";
|
|
7
|
+
import { CHAIN_ID } from "../constants";
|
|
8
|
+
// Wagmi handles typesafety with ABI const assertions. TypeScript doesn't
|
|
9
|
+
// support importing JSON as const yet so types cannot be inferred from the
|
|
10
|
+
// imported contract. As a workaround there is minimal ABI definition that can
|
|
11
|
+
// be asserted types from.
|
|
12
|
+
// Ref: https://wagmi.sh/core/typescript#const-assert-abis-typed-data
|
|
13
|
+
const BALANCE_OF_ABI = [
|
|
14
|
+
{
|
|
15
|
+
inputs: [
|
|
16
|
+
{
|
|
17
|
+
internalType: "address",
|
|
18
|
+
name: "account",
|
|
19
|
+
type: "address",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
name: "balanceOf",
|
|
23
|
+
outputs: [
|
|
24
|
+
{
|
|
25
|
+
internalType: "uint256",
|
|
26
|
+
name: "",
|
|
27
|
+
type: "uint256",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
stateMutability: "view",
|
|
31
|
+
type: "function",
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
const BALANCE_TOKENS = [
|
|
35
|
+
"mcbBTC",
|
|
36
|
+
"mDAI",
|
|
37
|
+
"mFBTC",
|
|
38
|
+
"mSolvBTC",
|
|
39
|
+
"mswBTC",
|
|
40
|
+
"mT",
|
|
41
|
+
"mUSDC",
|
|
42
|
+
"mUSDe",
|
|
43
|
+
"mUSDT",
|
|
44
|
+
"mxSolvBTC",
|
|
45
|
+
"MUSD",
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Hook to get the balance of a list of tokens for the current account
|
|
49
|
+
* @param options.tokens The list of tokens to get the balance for. It will
|
|
50
|
+
* fallback to all tokens if not provided.
|
|
51
|
+
* @param options.queryOptions The query options to pass to the
|
|
52
|
+
* `useReadContracts`
|
|
53
|
+
* @returns Tanstack's `useQuery` returnings with balance of tokens for the
|
|
54
|
+
* current account in form of typesafe object with token names as keys
|
|
55
|
+
* and balances as values.
|
|
56
|
+
* @dev In case of error data fallbacks to `0n`. To determine if an error
|
|
57
|
+
* occurred, check the `isError` property.
|
|
58
|
+
* @example
|
|
59
|
+
* const mezoTokensBalance = useTokensBalances({
|
|
60
|
+
* tokens: ["mT", "mxSolvBTC"],
|
|
61
|
+
* })
|
|
62
|
+
* console.log(mezoTokensBalance?.data.mT) // Eg. 0n
|
|
63
|
+
* console.log(Object.keys(mezoTokensBalance?.data)) // ["mT", "mxSolvBTC"]
|
|
64
|
+
*/
|
|
65
|
+
export function useTokensBalances(options = {}) {
|
|
66
|
+
const { environment = "mainnet" } = usePassportContext();
|
|
67
|
+
const { accountAddress } = useWalletAccount();
|
|
68
|
+
const contractsMap = useMemo(() => {
|
|
69
|
+
const contracts = environment === "mainnet" ? mainnetTokenContracts : testnetTokenContracts;
|
|
70
|
+
const tokenContracts = Object.fromEntries(Object.entries(contracts).filter(([key]) => BALANCE_TOKENS.includes(key)));
|
|
71
|
+
return tokenContracts;
|
|
72
|
+
}, [environment]);
|
|
73
|
+
const { tokens = Object.keys(contractsMap), queryOptions = {} } = options;
|
|
74
|
+
const contracts = useMemo(() => {
|
|
75
|
+
if (!accountAddress)
|
|
76
|
+
return [];
|
|
77
|
+
return tokens.map((token) => {
|
|
78
|
+
const { address } = contractsMap[token];
|
|
79
|
+
return {
|
|
80
|
+
address,
|
|
81
|
+
abi: BALANCE_OF_ABI,
|
|
82
|
+
functionName: "balanceOf",
|
|
83
|
+
args: [accountAddress],
|
|
84
|
+
chainId: CHAIN_ID[environment],
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
}, [accountAddress, tokens, contractsMap, environment]);
|
|
88
|
+
return useReadContracts({
|
|
89
|
+
contracts,
|
|
90
|
+
query: {
|
|
91
|
+
select: (data) => data.reduce((acc, item) => {
|
|
92
|
+
const token = tokens[data.indexOf(item)];
|
|
93
|
+
return {
|
|
94
|
+
...acc,
|
|
95
|
+
[token]: item.result ?? 0n,
|
|
96
|
+
};
|
|
97
|
+
}, {}),
|
|
98
|
+
...queryOptions,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Hook for invalidating current user's token balances. Can be used to
|
|
104
|
+
* invalidate the balances manually, which forces the data to be re-fetched.
|
|
105
|
+
* @param tokens The list of tokens (as string arrays) for which we want to
|
|
106
|
+
* invalidate query for.
|
|
107
|
+
* @returns Function `invalidateTokenBalances` that invalidates token balances
|
|
108
|
+
* @example
|
|
109
|
+
* const { invalidateTokenBalances } = useInvalidateTokensBalances(["mT", "mUSD"])
|
|
110
|
+
* (...)
|
|
111
|
+
* await invalidateTokenBalances()
|
|
112
|
+
*/
|
|
113
|
+
export function useInvalidateTokensBalances(tokens) {
|
|
114
|
+
const queryClient = useQueryClient();
|
|
115
|
+
const { queryKey } = useTokensBalances({ tokens });
|
|
116
|
+
const invalidateTokensBalancesHandler = useCallback(() => queryClient.invalidateQueries({ queryKey }), [queryClient, queryKey]);
|
|
117
|
+
return {
|
|
118
|
+
invalidateTokensBalances: invalidateTokensBalancesHandler,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Hook for resetting current user's token balances. Can be used to reset the
|
|
123
|
+
* balances manually, which forces the data to be re-fetched.
|
|
124
|
+
* @param tokens The list of tokens (as string arrays) for which we want to
|
|
125
|
+
* reset query for.
|
|
126
|
+
* @returns Function `resetTokenBalances` that invalidates token balances
|
|
127
|
+
* @example
|
|
128
|
+
* const { resetTokenBalances } = useResetTokensBalances(["mT", "mUSD"])
|
|
129
|
+
* (...)
|
|
130
|
+
* await resetTokenBalances()
|
|
131
|
+
*/
|
|
132
|
+
export function useResetTokensBalances(tokens) {
|
|
133
|
+
const queryClient = useQueryClient();
|
|
134
|
+
const { queryKey } = useTokensBalances({ tokens });
|
|
135
|
+
const resetTokenBalancesHandler = useCallback(() => queryClient.resetQueries({ queryKey }), [queryClient, queryKey]);
|
|
136
|
+
return {
|
|
137
|
+
resetTokenBalances: resetTokenBalancesHandler,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=useTokensBalances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTokensBalances.js","sourceRoot":"","sources":["../../../src/hooks/useTokensBalances.ts"],"names":[],"mappings":"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"}
|