@mezo-org/passport 0.4.0-dev.8 → 0.4.0-dev.80
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 +7 -3
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/api/auth.js +3 -1
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +4 -1
- package/dist/src/api/client.d.ts.map +1 -1
- package/dist/src/api/client.js +9 -2
- package/dist/src/api/client.js.map +1 -1
- package/dist/src/api/portal.d.ts +3 -9
- package/dist/src/api/portal.d.ts.map +1 -1
- package/dist/src/api/portal.js +8 -5
- package/dist/src/api/portal.js.map +1 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +2 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.js +29 -20
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -1
- package/dist/src/components/Dropdown/Content.d.ts +19 -5
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Content.js +19 -61
- package/dist/src/components/Dropdown/Content.js.map +1 -1
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -1
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +2 -2
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.d.ts +13 -6
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.js +32 -9
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
- 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/{AccountBalance.d.ts → Root/AccountBalance.d.ts} +2 -1
- 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/{AccountAddress.js → Root/WalletAddress.js} +21 -15
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
- package/dist/src/components/Dropdown/{WelcomeBlock.d.ts → Root/WelcomeBlock.d.ts} +1 -1
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/{WelcomeBlock.js → Root/WelcomeBlock.js} +5 -5
- 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/config.d.ts +18 -5
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +45 -14
- package/dist/src/config.js.map +1 -1
- package/dist/src/constants.d.ts +11 -3
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +12 -4
- package/dist/src/constants.js.map +1 -1
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +4 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +23 -0
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
- package/dist/src/hooks/useAssetsConversionRates.js +90 -0
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +13 -13
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +8 -7
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/hooks/useBorrowData.d.ts +82 -0
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
- package/dist/src/hooks/useBorrowData.js +159 -0
- package/dist/src/hooks/useBorrowData.js.map +1 -0
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +22 -1
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useDropdownData.d.ts +37 -34
- package/dist/src/hooks/useDropdownData.d.ts.map +1 -1
- package/dist/src/hooks/useDropdownData.js +85 -61
- package/dist/src/hooks/useDropdownData.js.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts +19 -13
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +20 -1
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- 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/useSignInWithWallet.d.ts +13 -13
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +13 -13
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -1
- 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/useValidateMezoId.d.ts +8 -0
- package/dist/src/hooks/useValidateMezoId.d.ts.map +1 -0
- package/dist/src/hooks/useValidateMezoId.js +24 -0
- package/dist/src/hooks/useValidateMezoId.js.map +1 -0
- package/dist/src/hooks/useWalletAccount.d.ts +2 -1
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +19 -15
- package/dist/src/hooks/useWalletAccount.js.map +1 -1
- 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 +62 -0
- package/dist/src/lib/contracts/index.js.map +1 -0
- package/dist/src/lib/contracts/priceOracle.d.ts +43 -0
- package/dist/src/lib/contracts/priceOracle.d.ts.map +1 -0
- package/dist/src/lib/contracts/priceOracle.js +52 -0
- package/dist/src/lib/contracts/priceOracle.js.map +1 -0
- package/dist/src/provider.js +1 -1
- 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 +1 -1
- package/dist/src/utils/address.d.ts.map +1 -1
- package/dist/src/utils/address.js +2 -0
- package/dist/src/utils/address.js.map +1 -1
- package/dist/src/utils/address.test.js +8 -5
- package/dist/src/utils/address.test.js.map +1 -1
- package/dist/src/utils/cryptoAssets.d.ts +17 -1
- package/dist/src/utils/cryptoAssets.d.ts.map +1 -1
- package/dist/src/utils/cryptoAssets.js +87 -31
- package/dist/src/utils/cryptoAssets.js.map +1 -1
- package/dist/src/utils/cryptoAssets.test.js +51 -33
- package/dist/src/utils/cryptoAssets.test.js.map +1 -1
- package/dist/src/utils/currency.d.ts +8 -0
- package/dist/src/utils/currency.d.ts.map +1 -1
- package/dist/src/utils/currency.js +11 -0
- package/dist/src/utils/currency.js.map +1 -1
- package/dist/src/utils/currency.test.js +1 -0
- package/dist/src/utils/currency.test.js.map +1 -1
- package/dist/src/utils/mezoId.d.ts +7 -0
- package/dist/src/utils/mezoId.d.ts.map +1 -0
- package/dist/src/utils/mezoId.js +41 -0
- package/dist/src/utils/mezoId.js.map +1 -0
- package/dist/src/utils/numbers.d.ts +39 -17
- package/dist/src/utils/numbers.d.ts.map +1 -1
- package/dist/src/utils/numbers.js +91 -33
- package/dist/src/utils/numbers.js.map +1 -1
- package/dist/src/utils/numbers.test.js +144 -22
- package/dist/src/utils/numbers.test.js.map +1 -1
- package/dist/src/utils/siww.d.ts +1 -0
- package/dist/src/utils/siww.d.ts.map +1 -1
- package/dist/src/utils/siww.js +50 -12
- package/dist/src/utils/siww.js.map +1 -1
- package/dist/src/utils/wagmi.d.ts +3 -0
- package/dist/src/utils/wagmi.d.ts.map +1 -0
- package/dist/src/utils/wagmi.js +7 -0
- package/dist/src/utils/wagmi.js.map +1 -0
- package/dist/src/wallet/index.d.ts +1 -1
- package/dist/src/wallet/index.d.ts.map +1 -1
- package/dist/src/wallet/index.js +1 -1
- package/dist/src/wallet/index.js.map +1 -1
- package/package.json +10 -8
- package/src/api/auth.ts +8 -4
- package/src/api/client.ts +11 -2
- package/src/api/portal.ts +11 -14
- package/src/components/Dropdown/ConnectedTrigger.tsx +52 -32
- package/src/components/Dropdown/Content.tsx +67 -117
- package/src/components/Dropdown/DisconnectedTrigger.tsx +2 -1
- package/src/components/Dropdown/Dropdown.tsx +75 -15
- package/src/components/Dropdown/ListingItem.tsx +80 -0
- package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
- package/src/components/Dropdown/README.md +10 -18
- 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/{WelcomeBlock.tsx → Root/WelcomeBlock.tsx} +5 -6
- package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
- package/src/config.ts +73 -20
- package/src/constants.ts +12 -4
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useAssetsConversionRates.ts +97 -0
- package/src/hooks/useAuthenticateWithWallet.ts +33 -12
- package/src/hooks/useBorrowData.ts +187 -0
- package/src/hooks/useCreateAccount.ts +28 -2
- package/src/hooks/useDropdownData.ts +119 -97
- package/src/hooks/useLinkAccount.ts +36 -4
- package/src/hooks/useRefreshPassport.ts +56 -0
- package/src/hooks/useSignInWithWallet.ts +2 -2
- package/src/hooks/useSignUpWithWallet.ts +2 -2
- package/src/hooks/useTokensBalances.ts +187 -0
- package/src/hooks/useValidateMezoId.ts +31 -0
- package/src/hooks/useWalletAccount.ts +29 -19
- package/src/hooks/useWatchTransferEvents.ts +74 -0
- package/src/index.ts +12 -1
- package/src/lib/contracts/index.ts +92 -0
- package/src/lib/contracts/priceOracle.ts +53 -0
- package/src/provider.ts +1 -1
- package/src/stores/dropdownStore.ts +20 -0
- package/src/utils/address.test.ts +10 -6
- package/src/utils/address.ts +5 -3
- package/src/utils/cryptoAssets.test.ts +57 -37
- package/src/utils/cryptoAssets.ts +113 -35
- package/src/utils/currency.test.ts +2 -0
- package/src/utils/currency.ts +21 -0
- package/src/utils/mezoId.ts +51 -0
- package/src/utils/numbers.test.ts +181 -23
- package/src/utils/numbers.ts +121 -34
- package/src/utils/siww.ts +71 -16
- package/src/utils/wagmi.ts +12 -0
- package/src/wallet/index.ts +3 -2
- package/dist/src/components/Dropdown/AccountAddress.d.ts +0 -8
- package/dist/src/components/Dropdown/AccountAddress.d.ts.map +0 -1
- package/dist/src/components/Dropdown/AccountAddress.js.map +0 -1
- package/dist/src/components/Dropdown/AccountAssets.d.ts +0 -14
- package/dist/src/components/Dropdown/AccountAssets.d.ts.map +0 -1
- package/dist/src/components/Dropdown/AccountAssets.js +0 -44
- package/dist/src/components/Dropdown/AccountAssets.js.map +0 -1
- package/dist/src/components/Dropdown/AccountBalance.d.ts.map +0 -1
- package/dist/src/components/Dropdown/AccountBalance.js +0 -18
- package/dist/src/components/Dropdown/AccountBalance.js.map +0 -1
- package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +0 -1
- package/dist/src/components/Dropdown/WelcomeBlock.js.map +0 -1
- package/dist/src/hooks/useAssetsUSDConversion.d.ts +0 -8
- package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +0 -1
- package/dist/src/hooks/useAssetsUSDConversion.js +0 -21
- package/dist/src/hooks/useAssetsUSDConversion.js.map +0 -1
- package/src/components/Dropdown/AccountAddress.tsx +0 -111
- package/src/components/Dropdown/AccountAssets.tsx +0 -110
- package/src/components/Dropdown/AccountBalance.tsx +0 -38
- package/src/hooks/useAssetsUSDConversion.ts +0 -31
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { MutationOptions, DefaultError } from "@tanstack/react-query";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { LinkAccountResponse, SignatureData } from "../api";
|
|
3
|
+
type LinkAccountMutationFnParameters = ({
|
|
4
|
+
type: "wallet";
|
|
5
|
+
} & SignatureData) | {
|
|
6
|
+
type: "discord";
|
|
7
|
+
};
|
|
8
|
+
export declare function useLinkAccount(mutationOptions?: Omit<MutationOptions<LinkAccountResponse, DefaultError, LinkAccountMutationFnParameters>, "mutationFn" | "mutationKey">): {
|
|
4
9
|
data: undefined;
|
|
5
10
|
variables: undefined;
|
|
6
11
|
error: null;
|
|
@@ -15,11 +20,11 @@ export declare function useLinkAccount(mutationOptions?: Omit<MutationOptions<Li
|
|
|
15
20
|
failureReason: Error | null;
|
|
16
21
|
isPaused: boolean;
|
|
17
22
|
submittedAt: number;
|
|
18
|
-
linkAccount: import("@tanstack/react-query").UseMutateFunction<LinkAccountResponse, Error,
|
|
19
|
-
linkAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<LinkAccountResponse, Error,
|
|
23
|
+
linkAccount: import("@tanstack/react-query").UseMutateFunction<LinkAccountResponse, Error, LinkAccountMutationFnParameters, unknown>;
|
|
24
|
+
linkAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<LinkAccountResponse, Error, LinkAccountMutationFnParameters, unknown>;
|
|
20
25
|
} | {
|
|
21
26
|
data: undefined;
|
|
22
|
-
variables:
|
|
27
|
+
variables: LinkAccountMutationFnParameters;
|
|
23
28
|
error: null;
|
|
24
29
|
isError: false;
|
|
25
30
|
isIdle: false;
|
|
@@ -32,12 +37,12 @@ export declare function useLinkAccount(mutationOptions?: Omit<MutationOptions<Li
|
|
|
32
37
|
failureReason: Error | null;
|
|
33
38
|
isPaused: boolean;
|
|
34
39
|
submittedAt: number;
|
|
35
|
-
linkAccount: import("@tanstack/react-query").UseMutateFunction<LinkAccountResponse, Error,
|
|
36
|
-
linkAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<LinkAccountResponse, Error,
|
|
40
|
+
linkAccount: import("@tanstack/react-query").UseMutateFunction<LinkAccountResponse, Error, LinkAccountMutationFnParameters, unknown>;
|
|
41
|
+
linkAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<LinkAccountResponse, Error, LinkAccountMutationFnParameters, unknown>;
|
|
37
42
|
} | {
|
|
38
43
|
data: undefined;
|
|
39
44
|
error: Error;
|
|
40
|
-
variables:
|
|
45
|
+
variables: LinkAccountMutationFnParameters;
|
|
41
46
|
isError: true;
|
|
42
47
|
isIdle: false;
|
|
43
48
|
isPending: false;
|
|
@@ -49,12 +54,12 @@ export declare function useLinkAccount(mutationOptions?: Omit<MutationOptions<Li
|
|
|
49
54
|
failureReason: Error | null;
|
|
50
55
|
isPaused: boolean;
|
|
51
56
|
submittedAt: number;
|
|
52
|
-
linkAccount: import("@tanstack/react-query").UseMutateFunction<LinkAccountResponse, Error,
|
|
53
|
-
linkAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<LinkAccountResponse, Error,
|
|
57
|
+
linkAccount: import("@tanstack/react-query").UseMutateFunction<LinkAccountResponse, Error, LinkAccountMutationFnParameters, unknown>;
|
|
58
|
+
linkAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<LinkAccountResponse, Error, LinkAccountMutationFnParameters, unknown>;
|
|
54
59
|
} | {
|
|
55
60
|
data: LinkAccountResponse;
|
|
56
61
|
error: null;
|
|
57
|
-
variables:
|
|
62
|
+
variables: LinkAccountMutationFnParameters;
|
|
58
63
|
isError: false;
|
|
59
64
|
isIdle: false;
|
|
60
65
|
isPending: false;
|
|
@@ -66,7 +71,8 @@ export declare function useLinkAccount(mutationOptions?: Omit<MutationOptions<Li
|
|
|
66
71
|
failureReason: Error | null;
|
|
67
72
|
isPaused: boolean;
|
|
68
73
|
submittedAt: number;
|
|
69
|
-
linkAccount: import("@tanstack/react-query").UseMutateFunction<LinkAccountResponse, Error,
|
|
70
|
-
linkAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<LinkAccountResponse, Error,
|
|
74
|
+
linkAccount: import("@tanstack/react-query").UseMutateFunction<LinkAccountResponse, Error, LinkAccountMutationFnParameters, unknown>;
|
|
75
|
+
linkAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<LinkAccountResponse, Error, LinkAccountMutationFnParameters, unknown>;
|
|
71
76
|
};
|
|
77
|
+
export {};
|
|
72
78
|
//# sourceMappingURL=useLinkAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinkAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useLinkAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useLinkAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useLinkAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAKhE,KAAK,+BAA+B,GAChC,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,aAAa,CAAC,GACpC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAA;AAEvB,wBAAgB,cAAc,CAC5B,eAAe,GAAE,IAAI,CACnB,eAAe,CACb,mBAAmB,EACnB,YAAY,EACZ,+BAA+B,CAChC,EACD,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCP"}
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import { useQueryClient, useMutation, } from "@tanstack/react-query";
|
|
2
2
|
import { useAuthApiClient } from "./useAuthApiClient";
|
|
3
3
|
import { QUERY_KEYS } from "./constants";
|
|
4
|
+
import useWalletAccount from "./useWalletAccount";
|
|
5
|
+
import { getBitcoinPublicKeyFromConnector } from "../utils/wagmi";
|
|
4
6
|
export function useLinkAccount(mutationOptions = {}) {
|
|
5
7
|
const queryClient = useQueryClient();
|
|
6
8
|
const authApiClient = useAuthApiClient();
|
|
9
|
+
const { connector } = useWalletAccount();
|
|
7
10
|
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
8
11
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
9
|
-
mutationFn: (
|
|
12
|
+
mutationFn: async (linkAccountMutationFnParameters) => {
|
|
13
|
+
if (linkAccountMutationFnParameters.type === "wallet") {
|
|
14
|
+
if (!connector) {
|
|
15
|
+
throw new Error("Connector not defined.");
|
|
16
|
+
}
|
|
17
|
+
const bitcoinPublicKey = await getBitcoinPublicKeyFromConnector(connector);
|
|
18
|
+
// Linking bitcoin account
|
|
19
|
+
if (bitcoinPublicKey) {
|
|
20
|
+
return authApiClient.linkAccount({
|
|
21
|
+
...linkAccountMutationFnParameters,
|
|
22
|
+
bitcoinPublicKey,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Linking any other account like wallet evm address account or discord
|
|
27
|
+
return authApiClient.linkAccount(linkAccountMutationFnParameters);
|
|
28
|
+
},
|
|
10
29
|
onSuccess: (data, variables, context) => {
|
|
11
30
|
queryClient.resetQueries({ queryKey: [QUERY_KEYS.ACCOUNT] });
|
|
12
31
|
if (customOnSuccess)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinkAccount.js","sourceRoot":"","sources":["../../../src/hooks/useLinkAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"useLinkAccount.js","sourceRoot":"","sources":["../../../src/hooks/useLinkAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAA;AAMjE,MAAM,UAAU,cAAc,CAC5B,kBAOI,EAAE;IAEN,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,EAAE,SAAS,EAAE,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,KAAK,EACf,+BAAgE,EAChE,EAAE;YACF,IAAI,+BAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtD,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;gBAC3C,CAAC;gBAED,MAAM,gBAAgB,GACpB,MAAM,gCAAgC,CAAC,SAAS,CAAC,CAAA;gBAEnD,0BAA0B;gBAC1B,IAAI,gBAAgB,EAAE,CAAC;oBACrB,OAAO,aAAa,CAAC,WAAW,CAAC;wBAC/B,GAAG,+BAA+B;wBAClC,gBAAgB;qBACjB,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;YAED,uEAAuE;YACvE,OAAO,aAAa,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAA;QACnE,CAAC;QACD,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,IAAI,eAAe;gBAAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAA;IAEF,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AACxE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to refresh the passport using query invalidation mechanism.
|
|
3
|
+
* By calling the refresh function, the latest data will be refetched as soon as possible.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const { refreshCurrentAccount, refreshUsdConversion } = useRefreshPassport()
|
|
7
|
+
*
|
|
8
|
+
* // Call this function to refresh the current account
|
|
9
|
+
* const handlerefreshCurrentAccount = async () => {
|
|
10
|
+
* await refreshCurrentAccount()
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
export declare function useRefreshPassport(): {
|
|
14
|
+
refreshCurrentAccount: () => Promise<void>;
|
|
15
|
+
refreshUsdConversion: () => Promise<void>;
|
|
16
|
+
refreshBorrowData: () => Promise<void>;
|
|
17
|
+
refreshTokensBalances: () => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=useRefreshPassport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRefreshPassport.d.ts","sourceRoot":"","sources":["../../../src/hooks/useRefreshPassport.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB;;;;;EAoCjC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useAccount, useBalance } from "wagmi";
|
|
4
|
+
import { QUERY_KEYS } from "./constants";
|
|
5
|
+
import { useInvalidateBorrowData } from "./useBorrowData";
|
|
6
|
+
import { useInvalidateTokensBalances } from "./useTokensBalances";
|
|
7
|
+
/**
|
|
8
|
+
* Hook to refresh the passport using query invalidation mechanism.
|
|
9
|
+
* By calling the refresh function, the latest data will be refetched as soon as possible.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const { refreshCurrentAccount, refreshUsdConversion } = useRefreshPassport()
|
|
13
|
+
*
|
|
14
|
+
* // Call this function to refresh the current account
|
|
15
|
+
* const handlerefreshCurrentAccount = async () => {
|
|
16
|
+
* await refreshCurrentAccount()
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export function useRefreshPassport() {
|
|
20
|
+
const { address } = useAccount();
|
|
21
|
+
const queryClient = useQueryClient();
|
|
22
|
+
const { invalidateBorrowData } = useInvalidateBorrowData();
|
|
23
|
+
const { invalidateTokensBalances } = useInvalidateTokensBalances();
|
|
24
|
+
const { queryKey: nativeTokenQueryKey } = useBalance({ address });
|
|
25
|
+
const refreshCurrentAccount = useCallback(() => queryClient.invalidateQueries({
|
|
26
|
+
queryKey: [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT],
|
|
27
|
+
}), [queryClient]);
|
|
28
|
+
const refreshUsdConversion = useCallback(() => queryClient.invalidateQueries({
|
|
29
|
+
queryKey: [QUERY_KEYS.ASSETS_USD_CONVERSION],
|
|
30
|
+
}), [queryClient]);
|
|
31
|
+
const refreshTokensBalances = useCallback(async () => {
|
|
32
|
+
await queryClient.invalidateQueries({
|
|
33
|
+
queryKey: nativeTokenQueryKey,
|
|
34
|
+
});
|
|
35
|
+
await invalidateTokensBalances();
|
|
36
|
+
}, [queryClient, nativeTokenQueryKey, invalidateTokensBalances]);
|
|
37
|
+
return {
|
|
38
|
+
refreshCurrentAccount,
|
|
39
|
+
refreshUsdConversion,
|
|
40
|
+
refreshBorrowData: invalidateBorrowData,
|
|
41
|
+
refreshTokensBalances,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=useRefreshPassport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRefreshPassport.js","sourceRoot":"","sources":["../../../src/hooks/useRefreshPassport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AAEjE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAA;IAChC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,EAAE,oBAAoB,EAAE,GAAG,uBAAuB,EAAE,CAAA;IAC1D,MAAM,EAAE,wBAAwB,EAAE,GAAG,2BAA2B,EAAE,CAAA;IAClE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,GAAG,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;IAEjE,MAAM,qBAAqB,GAAG,WAAW,CACvC,GAAG,EAAE,CACH,WAAW,CAAC,iBAAiB,CAAC;QAC5B,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;KACnD,CAAC,EACJ,CAAC,WAAW,CAAC,CACd,CAAA;IAED,MAAM,oBAAoB,GAAG,WAAW,CACtC,GAAG,EAAE,CACH,WAAW,CAAC,iBAAiB,CAAC;QAC5B,QAAQ,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC;KAC7C,CAAC,EACJ,CAAC,WAAW,CAAC,CACd,CAAA;IAED,MAAM,qBAAqB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACnD,MAAM,WAAW,CAAC,iBAAiB,CAAC;YAClC,QAAQ,EAAE,mBAAmB;SAC9B,CAAC,CAAA;QACF,MAAM,wBAAwB,EAAE,CAAA;IAClC,CAAC,EAAE,CAAC,WAAW,EAAE,mBAAmB,EAAE,wBAAwB,CAAC,CAAC,CAAA;IAEhE,OAAO;QACL,qBAAqB;QACrB,oBAAoB;QACpB,iBAAiB,EAAE,oBAAoB;QACvC,qBAAqB;KACtB,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MutationOptions } from "@tanstack/react-query";
|
|
1
|
+
import { DefaultError, MutationOptions } from "@tanstack/react-query";
|
|
2
2
|
import type { Session } from "../api";
|
|
3
|
-
declare function useSignInWithWallet(mutationOptions?: Omit<MutationOptions<Session>, "mutationFn" | "mutationKey">): {
|
|
3
|
+
declare function useSignInWithWallet(mutationOptions?: Omit<MutationOptions<Session, DefaultError, number | void>, "mutationFn" | "mutationKey">): {
|
|
4
4
|
data: undefined;
|
|
5
5
|
variables: undefined;
|
|
6
6
|
error: null;
|
|
@@ -15,11 +15,11 @@ declare function useSignInWithWallet(mutationOptions?: Omit<MutationOptions<Sess
|
|
|
15
15
|
failureReason: Error | null;
|
|
16
16
|
isPaused: boolean;
|
|
17
17
|
submittedAt: number;
|
|
18
|
-
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
19
|
-
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
18
|
+
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, number | void | undefined, unknown>;
|
|
19
|
+
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, number | void | undefined, unknown>;
|
|
20
20
|
} | {
|
|
21
21
|
data: undefined;
|
|
22
|
-
variables: void;
|
|
22
|
+
variables: number | void | undefined;
|
|
23
23
|
error: null;
|
|
24
24
|
isError: false;
|
|
25
25
|
isIdle: false;
|
|
@@ -32,12 +32,12 @@ declare function useSignInWithWallet(mutationOptions?: Omit<MutationOptions<Sess
|
|
|
32
32
|
failureReason: Error | null;
|
|
33
33
|
isPaused: boolean;
|
|
34
34
|
submittedAt: number;
|
|
35
|
-
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
36
|
-
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
35
|
+
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, number | void | undefined, unknown>;
|
|
36
|
+
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, number | void | undefined, unknown>;
|
|
37
37
|
} | {
|
|
38
38
|
data: undefined;
|
|
39
39
|
error: Error;
|
|
40
|
-
variables: void;
|
|
40
|
+
variables: number | void | undefined;
|
|
41
41
|
isError: true;
|
|
42
42
|
isIdle: false;
|
|
43
43
|
isPending: false;
|
|
@@ -49,12 +49,12 @@ declare function useSignInWithWallet(mutationOptions?: Omit<MutationOptions<Sess
|
|
|
49
49
|
failureReason: Error | null;
|
|
50
50
|
isPaused: boolean;
|
|
51
51
|
submittedAt: number;
|
|
52
|
-
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
53
|
-
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
52
|
+
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, number | void | undefined, unknown>;
|
|
53
|
+
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, number | void | undefined, unknown>;
|
|
54
54
|
} | {
|
|
55
55
|
data: Session;
|
|
56
56
|
error: null;
|
|
57
|
-
variables: void;
|
|
57
|
+
variables: number | void | undefined;
|
|
58
58
|
isError: false;
|
|
59
59
|
isIdle: false;
|
|
60
60
|
isPending: false;
|
|
@@ -66,8 +66,8 @@ declare function useSignInWithWallet(mutationOptions?: Omit<MutationOptions<Sess
|
|
|
66
66
|
failureReason: Error | null;
|
|
67
67
|
isPaused: boolean;
|
|
68
68
|
submittedAt: number;
|
|
69
|
-
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
70
|
-
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
69
|
+
signInWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, number | void | undefined, unknown>;
|
|
70
|
+
signInWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, number | void | undefined, unknown>;
|
|
71
71
|
};
|
|
72
72
|
export { useSignInWithWallet };
|
|
73
73
|
//# sourceMappingURL=useSignInWithWallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignInWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"useSignInWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAErE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,iBAAS,mBAAmB,CAC1B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC,EACrD,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUP;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MutationOptions } from "@tanstack/react-query";
|
|
1
|
+
import { DefaultError, MutationOptions } from "@tanstack/react-query";
|
|
2
2
|
import type { Session } from "../api";
|
|
3
|
-
declare function useSignUpWithWallet(mutationOptions?: Omit<MutationOptions<Session>, "mutationFn" | "mutationKey">): {
|
|
3
|
+
declare function useSignUpWithWallet(mutationOptions?: Omit<MutationOptions<Session, DefaultError, number | void>, "mutationFn" | "mutationKey">): {
|
|
4
4
|
data: undefined;
|
|
5
5
|
variables: undefined;
|
|
6
6
|
error: null;
|
|
@@ -15,11 +15,11 @@ declare function useSignUpWithWallet(mutationOptions?: Omit<MutationOptions<Sess
|
|
|
15
15
|
failureReason: Error | null;
|
|
16
16
|
isPaused: boolean;
|
|
17
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>;
|
|
18
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, number | void | undefined, unknown>;
|
|
19
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, number | void | undefined, unknown>;
|
|
20
20
|
} | {
|
|
21
21
|
data: undefined;
|
|
22
|
-
variables: void;
|
|
22
|
+
variables: number | void | undefined;
|
|
23
23
|
error: null;
|
|
24
24
|
isError: false;
|
|
25
25
|
isIdle: false;
|
|
@@ -32,12 +32,12 @@ declare function useSignUpWithWallet(mutationOptions?: Omit<MutationOptions<Sess
|
|
|
32
32
|
failureReason: Error | null;
|
|
33
33
|
isPaused: boolean;
|
|
34
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>;
|
|
35
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, number | void | undefined, unknown>;
|
|
36
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, number | void | undefined, unknown>;
|
|
37
37
|
} | {
|
|
38
38
|
data: undefined;
|
|
39
39
|
error: Error;
|
|
40
|
-
variables: void;
|
|
40
|
+
variables: number | void | undefined;
|
|
41
41
|
isError: true;
|
|
42
42
|
isIdle: false;
|
|
43
43
|
isPending: false;
|
|
@@ -49,12 +49,12 @@ declare function useSignUpWithWallet(mutationOptions?: Omit<MutationOptions<Sess
|
|
|
49
49
|
failureReason: Error | null;
|
|
50
50
|
isPaused: boolean;
|
|
51
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>;
|
|
52
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, number | void | undefined, unknown>;
|
|
53
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, number | void | undefined, unknown>;
|
|
54
54
|
} | {
|
|
55
55
|
data: Session;
|
|
56
56
|
error: null;
|
|
57
|
-
variables: void;
|
|
57
|
+
variables: number | void | undefined;
|
|
58
58
|
isError: false;
|
|
59
59
|
isIdle: false;
|
|
60
60
|
isPending: false;
|
|
@@ -66,8 +66,8 @@ declare function useSignUpWithWallet(mutationOptions?: Omit<MutationOptions<Sess
|
|
|
66
66
|
failureReason: Error | null;
|
|
67
67
|
isPaused: boolean;
|
|
68
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>;
|
|
69
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, number | void | undefined, unknown>;
|
|
70
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, number | void | undefined, unknown>;
|
|
71
71
|
};
|
|
72
72
|
export { useSignUpWithWallet };
|
|
73
73
|
//# sourceMappingURL=useSignUpWithWallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignUpWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignUpWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"useSignUpWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignUpWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAErE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,iBAAS,mBAAmB,CAC1B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC,EACrD,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUP;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: number;
|
|
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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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import { MezoId } from "../utils/mezoId";
|
|
3
|
+
export declare function useValidateMezoId(mezoId: MezoId): UseQueryResult<{
|
|
4
|
+
isValid: boolean;
|
|
5
|
+
isAvailable: boolean;
|
|
6
|
+
errors: string[];
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=useValidateMezoId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useValidateMezoId.d.ts","sourceRoot":"","sources":["../../../src/hooks/useValidateMezoId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAkB,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGxD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAqBxC,cAAc,CAAC;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,OAAO,CAAA;IACpB,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAAC,CACH"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { validateMezoId } from "../utils/mezoId";
|
|
2
|
+
import { useGetAccountByMezoId } from "./useGetAccountByMezoId";
|
|
3
|
+
export function useValidateMezoId(mezoId) {
|
|
4
|
+
const validationErrors = validateMezoId(mezoId);
|
|
5
|
+
return useGetAccountByMezoId(mezoId, {
|
|
6
|
+
placeholderData: {
|
|
7
|
+
// @ts-expect-error TODO: Couldn't fix type for placeholderData which for
|
|
8
|
+
// some reason should return the same data as the data returned in
|
|
9
|
+
// queryFn.
|
|
10
|
+
isValid: validationErrors.length === 0,
|
|
11
|
+
isAvailable: validationErrors.length === 0,
|
|
12
|
+
errors: validationErrors,
|
|
13
|
+
},
|
|
14
|
+
enabled: validationErrors.length === 0,
|
|
15
|
+
// @ts-expect-error TODO: Couldn't fix type for select which for some reason
|
|
16
|
+
// should return the same data as the data returned in queryFn.
|
|
17
|
+
select: (data) => {
|
|
18
|
+
const isValid = validationErrors.length === 0;
|
|
19
|
+
const isAvailable = isValid ? !data : false;
|
|
20
|
+
return { isValid, isAvailable, errors: validationErrors };
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=useValidateMezoId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useValidateMezoId.js","sourceRoot":"","sources":["../../../src/hooks/useValidateMezoId.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAU,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,MAAM,gBAAgB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;IAE/C,OAAO,qBAAqB,CAAC,MAAM,EAAE;QACnC,eAAe,EAAE;YACf,yEAAyE;YACzE,kEAAkE;YAClE,WAAW;YACX,OAAO,EAAE,gBAAgB,CAAC,MAAM,KAAK,CAAC;YACtC,WAAW,EAAE,gBAAgB,CAAC,MAAM,KAAK,CAAC;YAC1C,MAAM,EAAE,gBAAgB;SACzB;QACD,OAAO,EAAE,gBAAgB,CAAC,MAAM,KAAK,CAAC;QACtC,4EAA4E;QAC5E,+DAA+D;QAC/D,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACf,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,KAAK,CAAC,CAAA;YAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;YAE3C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAA;QAC3D,CAAC;KACF,CAIC,CAAA;AACJ,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Address } from "viem";
|
|
2
2
|
import { Connector } from "wagmi";
|
|
3
3
|
type UseWalletAccountReturn = {
|
|
4
|
-
|
|
4
|
+
accountAddress?: Address;
|
|
5
|
+
walletAddress?: string;
|
|
5
6
|
isConnected: boolean;
|
|
6
7
|
networkFamily: "bitcoin" | "evm";
|
|
7
8
|
connector?: Connector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWalletAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useWalletAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWalletAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useWalletAccount.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAc,MAAM,OAAO,CAAA;AAE7C,KAAK,sBAAsB,GAAG;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,SAAS,GAAG,KAAK,CAAA;IAChC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,IAAI,sBAAsB,CAmCjE"}
|