@mezo-org/passport 0.4.0-dev.44 → 0.4.0-dev.45
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/package.json +3 -3
- package/dist/src/api/auth.d.ts +0 -78
- package/dist/src/api/auth.d.ts.map +0 -1
- package/dist/src/api/auth.js +0 -77
- package/dist/src/api/auth.js.map +0 -1
- package/dist/src/api/client.d.ts +0 -24
- package/dist/src/api/client.d.ts.map +0 -1
- package/dist/src/api/client.js +0 -54
- package/dist/src/api/client.js.map +0 -1
- package/dist/src/api/fetch-error.d.ts +0 -5
- package/dist/src/api/fetch-error.d.ts.map +0 -1
- package/dist/src/api/fetch-error.js +0 -8
- package/dist/src/api/fetch-error.js.map +0 -1
- package/dist/src/api/index.d.ts +0 -3
- package/dist/src/api/index.d.ts.map +0 -1
- package/dist/src/api/index.js +0 -3
- package/dist/src/api/index.js.map +0 -1
- package/dist/src/api/portal.d.ts +0 -33
- package/dist/src/api/portal.d.ts.map +0 -1
- package/dist/src/api/portal.js +0 -23
- package/dist/src/api/portal.js.map +0 -1
- package/dist/src/assets/DefaultAvatar.d.ts +0 -5
- package/dist/src/assets/DefaultAvatar.d.ts.map +0 -1
- package/dist/src/assets/DefaultAvatar.js +0 -21
- package/dist/src/assets/DefaultAvatar.js.map +0 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +0 -8
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +0 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.js +0 -39
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +0 -1
- package/dist/src/components/Dropdown/Content.d.ts +0 -23
- package/dist/src/components/Dropdown/Content.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Content.js +0 -27
- package/dist/src/components/Dropdown/Content.js.map +0 -1
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +0 -7
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +0 -1
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +0 -13
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +0 -1
- package/dist/src/components/Dropdown/Dropdown.d.ts +0 -27
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Dropdown.js +0 -68
- package/dist/src/components/Dropdown/Dropdown.js.map +0 -1
- package/dist/src/components/Dropdown/ListingItem.d.ts +0 -13
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +0 -1
- package/dist/src/components/Dropdown/ListingItem.js +0 -34
- package/dist/src/components/Dropdown/ListingItem.js.map +0 -1
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +0 -7
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +0 -1
- package/dist/src/components/Dropdown/NestedViewLayout.js +0 -34
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +0 -1
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +0 -7
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Receive/Receive.js +0 -53
- package/dist/src/components/Dropdown/Receive/Receive.js.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +0 -7
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +0 -48
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +0 -11
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js +0 -9
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +0 -8
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountBalance.js +0 -15
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +0 -9
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +0 -48
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +0 -1
- package/dist/src/components/Dropdown/Root/Root.d.ts +0 -23
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Root/Root.js +0 -57
- package/dist/src/components/Dropdown/Root/Root.js.map +0 -1
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +0 -8
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Root/WalletAddress.js +0 -64
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +0 -1
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +0 -8
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +0 -1
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +0 -44
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +0 -1
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +0 -3
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +0 -1
- package/dist/src/components/Dropdown/TestnetTopBanner.js +0 -14
- package/dist/src/components/Dropdown/TestnetTopBanner.js.map +0 -1
- package/dist/src/components/Dropdown/index.d.ts +0 -3
- package/dist/src/components/Dropdown/index.d.ts.map +0 -1
- package/dist/src/components/Dropdown/index.js +0 -2
- package/dist/src/components/Dropdown/index.js.map +0 -1
- package/dist/src/components/index.d.ts +0 -2
- package/dist/src/components/index.d.ts.map +0 -1
- package/dist/src/components/index.js +0 -2
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/config.d.ts +0 -33
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js +0 -75
- package/dist/src/config.js.map +0 -1
- package/dist/src/constants.d.ts +0 -16
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js +0 -17
- package/dist/src/constants.js.map +0 -1
- package/dist/src/hooks/constants.d.ts +0 -7
- package/dist/src/hooks/constants.d.ts.map +0 -1
- package/dist/src/hooks/constants.js +0 -7
- package/dist/src/hooks/constants.js.map +0 -1
- package/dist/src/hooks/index.d.ts +0 -15
- package/dist/src/hooks/index.d.ts.map +0 -1
- package/dist/src/hooks/index.js +0 -15
- package/dist/src/hooks/index.js.map +0 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +0 -7
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +0 -1
- package/dist/src/hooks/useAssetsConversionRates.js +0 -24
- package/dist/src/hooks/useAssetsConversionRates.js.map +0 -1
- package/dist/src/hooks/useAuthApiClient.d.ts +0 -2
- package/dist/src/hooks/useAuthApiClient.d.ts.map +0 -1
- package/dist/src/hooks/useAuthApiClient.js +0 -6
- package/dist/src/hooks/useAuthApiClient.js.map +0 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +0 -73
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +0 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +0 -69
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +0 -1
- package/dist/src/hooks/useBorrowData.d.ts +0 -60
- package/dist/src/hooks/useBorrowData.d.ts.map +0 -1
- package/dist/src/hooks/useBorrowData.js +0 -122
- package/dist/src/hooks/useBorrowData.js.map +0 -1
- package/dist/src/hooks/useCreateAccount.d.ts +0 -108
- package/dist/src/hooks/useCreateAccount.d.ts.map +0 -1
- package/dist/src/hooks/useCreateAccount.js +0 -21
- package/dist/src/hooks/useCreateAccount.js.map +0 -1
- package/dist/src/hooks/useCreateSession.d.ts +0 -76
- package/dist/src/hooks/useCreateSession.d.ts.map +0 -1
- package/dist/src/hooks/useCreateSession.js +0 -29
- package/dist/src/hooks/useCreateSession.js.map +0 -1
- package/dist/src/hooks/useDropdownData.d.ts +0 -47
- package/dist/src/hooks/useDropdownData.d.ts.map +0 -1
- package/dist/src/hooks/useDropdownData.js +0 -95
- package/dist/src/hooks/useDropdownData.js.map +0 -1
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts +0 -5
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts.map +0 -1
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js +0 -34
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js.map +0 -1
- package/dist/src/hooks/useGetAccountByAddress.d.ts +0 -4
- package/dist/src/hooks/useGetAccountByAddress.d.ts.map +0 -1
- package/dist/src/hooks/useGetAccountByAddress.js +0 -17
- package/dist/src/hooks/useGetAccountByAddress.js.map +0 -1
- package/dist/src/hooks/useGetAccountByMezoId.d.ts +0 -4
- package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +0 -1
- package/dist/src/hooks/useGetAccountByMezoId.js +0 -17
- package/dist/src/hooks/useGetAccountByMezoId.js.map +0 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts +0 -18
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +0 -1
- package/dist/src/hooks/useGetCurrentAccount.js +0 -37
- package/dist/src/hooks/useGetCurrentAccount.js.map +0 -1
- package/dist/src/hooks/useGetSession.d.ts +0 -4
- package/dist/src/hooks/useGetSession.d.ts.map +0 -1
- package/dist/src/hooks/useGetSession.js +0 -15
- package/dist/src/hooks/useGetSession.js.map +0 -1
- package/dist/src/hooks/useLinkAccount.d.ts +0 -72
- package/dist/src/hooks/useLinkAccount.d.ts.map +0 -1
- package/dist/src/hooks/useLinkAccount.js +0 -19
- package/dist/src/hooks/useLinkAccount.js.map +0 -1
- package/dist/src/hooks/usePassportContext.d.ts +0 -3
- package/dist/src/hooks/usePassportContext.d.ts.map +0 -1
- package/dist/src/hooks/usePassportContext.js +0 -10
- package/dist/src/hooks/usePassportContext.js.map +0 -1
- package/dist/src/hooks/usePortalApiClient.d.ts +0 -2
- package/dist/src/hooks/usePortalApiClient.d.ts.map +0 -1
- package/dist/src/hooks/usePortalApiClient.js +0 -6
- package/dist/src/hooks/usePortalApiClient.js.map +0 -1
- package/dist/src/hooks/useRefreshPassport.d.ts +0 -19
- package/dist/src/hooks/useRefreshPassport.d.ts.map +0 -1
- package/dist/src/hooks/useRefreshPassport.js +0 -44
- package/dist/src/hooks/useRefreshPassport.js.map +0 -1
- package/dist/src/hooks/useSignInWithDiscord.d.ts +0 -73
- package/dist/src/hooks/useSignInWithDiscord.d.ts.map +0 -1
- package/dist/src/hooks/useSignInWithDiscord.js +0 -25
- package/dist/src/hooks/useSignInWithDiscord.js.map +0 -1
- package/dist/src/hooks/useSignInWithWallet.d.ts +0 -73
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +0 -1
- package/dist/src/hooks/useSignInWithWallet.js +0 -11
- package/dist/src/hooks/useSignInWithWallet.js.map +0 -1
- package/dist/src/hooks/useSignOut.d.ts +0 -72
- package/dist/src/hooks/useSignOut.d.ts.map +0 -1
- package/dist/src/hooks/useSignOut.js +0 -22
- package/dist/src/hooks/useSignOut.js.map +0 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +0 -73
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +0 -1
- package/dist/src/hooks/useSignUpWithWallet.js +0 -11
- package/dist/src/hooks/useSignUpWithWallet.js.map +0 -1
- package/dist/src/hooks/useTokensBalances.d.ts +0 -74
- package/dist/src/hooks/useTokensBalances.d.ts.map +0 -1
- package/dist/src/hooks/useTokensBalances.js +0 -140
- package/dist/src/hooks/useTokensBalances.js.map +0 -1
- package/dist/src/hooks/useUpdateMezoId.d.ts +0 -108
- package/dist/src/hooks/useUpdateMezoId.d.ts.map +0 -1
- package/dist/src/hooks/useUpdateMezoId.js +0 -19
- package/dist/src/hooks/useUpdateMezoId.js.map +0 -1
- package/dist/src/hooks/useWalletAccount.d.ts +0 -13
- package/dist/src/hooks/useWalletAccount.d.ts.map +0 -1
- package/dist/src/hooks/useWalletAccount.js +0 -29
- package/dist/src/hooks/useWalletAccount.js.map +0 -1
- package/dist/src/hooks/useWatchTransferEvents.d.ts +0 -5
- package/dist/src/hooks/useWatchTransferEvents.d.ts.map +0 -1
- package/dist/src/hooks/useWatchTransferEvents.js +0 -63
- package/dist/src/hooks/useWatchTransferEvents.js.map +0 -1
- package/dist/src/index.d.ts +0 -7
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -7
- package/dist/src/index.js.map +0 -1
- package/dist/src/lib/contracts/index.d.ts +0 -13
- package/dist/src/lib/contracts/index.d.ts.map +0 -1
- package/dist/src/lib/contracts/index.js +0 -57
- package/dist/src/lib/contracts/index.js.map +0 -1
- package/dist/src/lib/contracts/troveManager.d.ts +0 -1401
- package/dist/src/lib/contracts/troveManager.d.ts.map +0 -1
- package/dist/src/lib/contracts/troveManager.js +0 -1820
- package/dist/src/lib/contracts/troveManager.js.map +0 -1
- package/dist/src/provider.d.ts +0 -17
- package/dist/src/provider.d.ts.map +0 -1
- package/dist/src/provider.js +0 -16
- package/dist/src/provider.js.map +0 -1
- package/dist/src/stores/dropdownStore.d.ts +0 -12
- package/dist/src/stores/dropdownStore.d.ts.map +0 -1
- package/dist/src/stores/dropdownStore.js +0 -13
- package/dist/src/stores/dropdownStore.js.map +0 -1
- package/dist/src/utils/address.d.ts +0 -15
- package/dist/src/utils/address.d.ts.map +0 -1
- package/dist/src/utils/address.js +0 -37
- package/dist/src/utils/address.js.map +0 -1
- package/dist/src/utils/address.test.d.ts +0 -2
- package/dist/src/utils/address.test.d.ts.map +0 -1
- package/dist/src/utils/address.test.js +0 -40
- package/dist/src/utils/address.test.js.map +0 -1
- package/dist/src/utils/cryptoAssets.d.ts +0 -44
- package/dist/src/utils/cryptoAssets.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.js +0 -131
- package/dist/src/utils/cryptoAssets.js.map +0 -1
- package/dist/src/utils/cryptoAssets.test.d.ts +0 -2
- package/dist/src/utils/cryptoAssets.test.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.test.js +0 -67
- package/dist/src/utils/cryptoAssets.test.js.map +0 -1
- package/dist/src/utils/currency.d.ts +0 -14
- package/dist/src/utils/currency.d.ts.map +0 -1
- package/dist/src/utils/currency.js +0 -27
- package/dist/src/utils/currency.js.map +0 -1
- package/dist/src/utils/currency.test.d.ts +0 -2
- package/dist/src/utils/currency.test.d.ts.map +0 -1
- package/dist/src/utils/currency.test.js +0 -34
- package/dist/src/utils/currency.test.js.map +0 -1
- package/dist/src/utils/numbers.d.ts +0 -58
- package/dist/src/utils/numbers.d.ts.map +0 -1
- package/dist/src/utils/numbers.js +0 -132
- package/dist/src/utils/numbers.js.map +0 -1
- package/dist/src/utils/numbers.test.d.ts +0 -2
- package/dist/src/utils/numbers.test.d.ts.map +0 -1
- package/dist/src/utils/numbers.test.js +0 -170
- package/dist/src/utils/numbers.test.js.map +0 -1
- package/dist/src/utils/siww.d.ts +0 -4
- package/dist/src/utils/siww.d.ts.map +0 -1
- package/dist/src/utils/siww.js +0 -19
- package/dist/src/utils/siww.js.map +0 -1
- package/dist/src/utils/time.d.ts +0 -5
- package/dist/src/utils/time.d.ts.map +0 -1
- package/dist/src/utils/time.js +0 -5
- package/dist/src/utils/time.js.map +0 -1
- package/dist/src/wallet/index.d.ts +0 -2
- package/dist/src/wallet/index.d.ts.map +0 -1
- package/dist/src/wallet/index.js +0 -2
- package/dist/src/wallet/index.js.map +0 -1
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { useSignMessage } from "wagmi";
|
|
2
|
-
import { useMutation } from "@tanstack/react-query";
|
|
3
|
-
import { useCreateAccount } from "./useCreateAccount";
|
|
4
|
-
import { useCreateSession } from "./useCreateSession";
|
|
5
|
-
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
|
|
6
|
-
import { createSignInWithWalletMessage } from "../utils/siww";
|
|
7
|
-
import { useGetAccountByAddress } from "./useGetAccountByAddress";
|
|
8
|
-
import useWalletAccount from "./useWalletAccount";
|
|
9
|
-
function useAuthenticateWithWallet(shouldCreateAccount = false, mutationOptions = {}) {
|
|
10
|
-
const { walletAddress, chainId, connector, networkFamily } = useWalletAccount();
|
|
11
|
-
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
|
|
12
|
-
const { createSessionAsync } = useCreateSession();
|
|
13
|
-
const { createAccountAsync } = useCreateAccount();
|
|
14
|
-
const { signMessageAsync } = useSignMessage();
|
|
15
|
-
const { refetch: getAccountByAddress } = useGetAccountByAddress(walletAddress, {
|
|
16
|
-
enabled: false,
|
|
17
|
-
retry: false,
|
|
18
|
-
});
|
|
19
|
-
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
20
|
-
mutationFn: async () => {
|
|
21
|
-
if (!walletAddress) {
|
|
22
|
-
throw new Error("Sign in error: Wallet not connected!");
|
|
23
|
-
}
|
|
24
|
-
const nonce = await ensureNoSessionAndFetchNonce();
|
|
25
|
-
const messageResult = createSignInWithWalletMessage(walletAddress, nonce, networkFamily, chainId);
|
|
26
|
-
const signatureResult = await signMessageAsync({
|
|
27
|
-
message: messageResult,
|
|
28
|
-
connector,
|
|
29
|
-
});
|
|
30
|
-
if (shouldCreateAccount) {
|
|
31
|
-
const getAccountByAddressResult = await getAccountByAddress();
|
|
32
|
-
if (getAccountByAddressResult.data) {
|
|
33
|
-
throw new Error("Wallet authentication failed: Account creation failed. Account already exists.");
|
|
34
|
-
}
|
|
35
|
-
if (getAccountByAddressResult.error) {
|
|
36
|
-
throw new Error(`Wallet authentication failed: Account creation failed. Could not verify if account already exists: ${getAccountByAddressResult.error}`);
|
|
37
|
-
}
|
|
38
|
-
// Fetch was successful, but no account was found
|
|
39
|
-
try {
|
|
40
|
-
const createAccountResult = await createAccountAsync({
|
|
41
|
-
type: "wallet",
|
|
42
|
-
message: messageResult,
|
|
43
|
-
signature: signatureResult,
|
|
44
|
-
});
|
|
45
|
-
if (!createAccountResult) {
|
|
46
|
-
throw new Error("Failed to create new account");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
throw new Error(`Wallet authentication failed: Account creation failed: ${error}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return (await createSessionAsync({
|
|
54
|
-
type: "wallet",
|
|
55
|
-
message: messageResult,
|
|
56
|
-
signature: signatureResult,
|
|
57
|
-
}));
|
|
58
|
-
// ^ By passing type: "wallet" we know for sure the return type is Session
|
|
59
|
-
},
|
|
60
|
-
...mutationOptions,
|
|
61
|
-
});
|
|
62
|
-
return {
|
|
63
|
-
authenticateWithWallet: mutate,
|
|
64
|
-
authenticateWithWalletAsync: mutateAsync,
|
|
65
|
-
...signInMutationRestParameters,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export { useAuthenticateWithWallet };
|
|
69
|
-
//# sourceMappingURL=useAuthenticateWithWallet.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthenticateWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAmB,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAA;AACnF,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AAEjD,SAAS,yBAAyB,CAChC,mBAAmB,GAAG,KAAK,EAC3B,kBAGI,EAAE;IAEN,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,GACxD,gBAAgB,EAAE,C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AkB,CAAC;wBACnD,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,aAAa;wBACtB,SAAS,EAAE,eAAe;qBAC3B,CAAC,CAAA;oBAEF,IAAI,CAAC,mBAAmB,EAAE,CAAC;wBACzB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;oBACjD,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,IAAI,KAAK,CACb,0DAA0D,KAAK,EAAE,CAClE,CAAA;gBACH,CAAC;YACH,CAAC;YAED,OAAO,CAAC,MAAM,kBAAkB,CAAC;gBAC/B,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,aAAa;gBACtB,SAAS,EAAE,eAAe;aAC3B,CAAC,CAAY,CAAA;YACd,0EAA0E;QAC5E,CAAC;QACD,GAAG,eAAe;KACnB,CAAC,CAAA;IAEF,OAAO;QACL,sBAAsB,EAAE,MAAM;QAC9B,2BAA2B,EAAE,WAAW;QACxC,GAAG,4BAA4B;KAChC,CAAA;AACH,CAAC;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Query hook for getting borrow data. Returns collateral and trove debt for the
|
|
3
|
-
* connected account, based on it's evm address.
|
|
4
|
-
* @param queryOptions Query options passed to the underlying `useQuery` hook.
|
|
5
|
-
*/
|
|
6
|
-
export declare function useBorrowData(queryOptions?: {}): import("wagmi").UseReadContractReturnType<readonly [{
|
|
7
|
-
readonly inputs: readonly [{
|
|
8
|
-
readonly internalType: "address";
|
|
9
|
-
readonly name: "_borrower";
|
|
10
|
-
readonly type: "address";
|
|
11
|
-
}];
|
|
12
|
-
readonly name: "getEntireDebtAndColl";
|
|
13
|
-
readonly outputs: readonly [{
|
|
14
|
-
readonly internalType: "uint256";
|
|
15
|
-
readonly name: "coll";
|
|
16
|
-
readonly type: "uint256";
|
|
17
|
-
}, {
|
|
18
|
-
readonly internalType: "uint256";
|
|
19
|
-
readonly name: "principal";
|
|
20
|
-
readonly type: "uint256";
|
|
21
|
-
}, {
|
|
22
|
-
readonly internalType: "uint256";
|
|
23
|
-
readonly name: "interest";
|
|
24
|
-
readonly type: "uint256";
|
|
25
|
-
}, {
|
|
26
|
-
readonly internalType: "uint256";
|
|
27
|
-
readonly name: "pendingCollateral";
|
|
28
|
-
readonly type: "uint256";
|
|
29
|
-
}, {
|
|
30
|
-
readonly internalType: "uint256";
|
|
31
|
-
readonly name: "pendingPrincipal";
|
|
32
|
-
readonly type: "uint256";
|
|
33
|
-
}, {
|
|
34
|
-
readonly internalType: "uint256";
|
|
35
|
-
readonly name: "pendingInterest";
|
|
36
|
-
readonly type: "uint256";
|
|
37
|
-
}];
|
|
38
|
-
readonly stateMutability: "view";
|
|
39
|
-
readonly type: "function";
|
|
40
|
-
}], "getEntireDebtAndColl", [`0x${string}`], {
|
|
41
|
-
collateral: bigint;
|
|
42
|
-
troveDebt: bigint;
|
|
43
|
-
} | undefined>;
|
|
44
|
-
/**
|
|
45
|
-
* Hook for for invalidating current user's borrow data. Can be used to
|
|
46
|
-
* invalidate borrow data manually, which forces the data to be re-fetched.
|
|
47
|
-
* @returns Function `invalidateBorrowData` for invalidating the borrow data
|
|
48
|
-
*/
|
|
49
|
-
export declare function useInvalidateBorrowData(): {
|
|
50
|
-
invalidateBorrowData: () => Promise<void>;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Hook for for resetting current user's borrow data. Can be used to reset
|
|
54
|
-
* borrow data manually, which forces the data to be re-fetched.
|
|
55
|
-
* @returns Function `resetBorrowData` for resetting the borrow data
|
|
56
|
-
*/
|
|
57
|
-
export declare function useResetBorrowData(): {
|
|
58
|
-
resetBorrowData: () => Promise<void>;
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=useBorrowData.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBorrowData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"AAgEA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,YAAY,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAiC9C;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB;;EAatC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB;;EAajC"}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { useAccount, useReadContract } from "wagmi";
|
|
2
|
-
import { useCallback, useMemo } from "react";
|
|
3
|
-
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
import { ONE_MINUTE_MS } from "../utils/time";
|
|
5
|
-
import { mainnetBorrowContracts, testnetBorrowContracts, } from "../lib/contracts";
|
|
6
|
-
import { usePassportContext } from "./usePassportContext";
|
|
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 TROVE_MANAGER_ABI = [
|
|
14
|
-
{
|
|
15
|
-
inputs: [
|
|
16
|
-
{
|
|
17
|
-
internalType: "address",
|
|
18
|
-
name: "_borrower",
|
|
19
|
-
type: "address",
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
name: "getEntireDebtAndColl",
|
|
23
|
-
outputs: [
|
|
24
|
-
{
|
|
25
|
-
internalType: "uint256",
|
|
26
|
-
name: "coll",
|
|
27
|
-
type: "uint256",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
internalType: "uint256",
|
|
31
|
-
name: "principal",
|
|
32
|
-
type: "uint256",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
internalType: "uint256",
|
|
36
|
-
name: "interest",
|
|
37
|
-
type: "uint256",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
internalType: "uint256",
|
|
41
|
-
name: "pendingCollateral",
|
|
42
|
-
type: "uint256",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
internalType: "uint256",
|
|
46
|
-
name: "pendingPrincipal",
|
|
47
|
-
type: "uint256",
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
internalType: "uint256",
|
|
51
|
-
name: "pendingInterest",
|
|
52
|
-
type: "uint256",
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
stateMutability: "view",
|
|
56
|
-
type: "function",
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
/**
|
|
60
|
-
* Query hook for getting borrow data. Returns collateral and trove debt for the
|
|
61
|
-
* connected account, based on it's evm address.
|
|
62
|
-
* @param queryOptions Query options passed to the underlying `useQuery` hook.
|
|
63
|
-
*/
|
|
64
|
-
export function useBorrowData(queryOptions = {}) {
|
|
65
|
-
const { environment = "mainnet" } = usePassportContext();
|
|
66
|
-
const { address } = useAccount();
|
|
67
|
-
const contractAddress = useMemo(() => {
|
|
68
|
-
if (environment === "mainnet") {
|
|
69
|
-
return mainnetBorrowContracts.TroveManager.address;
|
|
70
|
-
}
|
|
71
|
-
return testnetBorrowContracts.TroveManager.address;
|
|
72
|
-
}, [environment]);
|
|
73
|
-
return useReadContract({
|
|
74
|
-
abi: TROVE_MANAGER_ABI,
|
|
75
|
-
address: contractAddress,
|
|
76
|
-
functionName: "getEntireDebtAndColl",
|
|
77
|
-
args: [address || "0x"],
|
|
78
|
-
query: {
|
|
79
|
-
enabled: !!address,
|
|
80
|
-
staleTime: 5 * ONE_MINUTE_MS,
|
|
81
|
-
retry: 1,
|
|
82
|
-
select: (data) => {
|
|
83
|
-
if (!data)
|
|
84
|
-
return undefined;
|
|
85
|
-
const [collateral, principal, interest] = data;
|
|
86
|
-
return {
|
|
87
|
-
collateral,
|
|
88
|
-
troveDebt: principal + interest,
|
|
89
|
-
};
|
|
90
|
-
},
|
|
91
|
-
...queryOptions,
|
|
92
|
-
},
|
|
93
|
-
chainId: CHAIN_ID[environment],
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Hook for for invalidating current user's borrow data. Can be used to
|
|
98
|
-
* invalidate borrow data manually, which forces the data to be re-fetched.
|
|
99
|
-
* @returns Function `invalidateBorrowData` for invalidating the borrow data
|
|
100
|
-
*/
|
|
101
|
-
export function useInvalidateBorrowData() {
|
|
102
|
-
const queryClient = useQueryClient();
|
|
103
|
-
const { queryKey } = useBorrowData();
|
|
104
|
-
const invalidateBorrowDataHandler = useCallback(() => queryClient.invalidateQueries({ queryKey }), [queryClient, queryKey]);
|
|
105
|
-
return {
|
|
106
|
-
invalidateBorrowData: invalidateBorrowDataHandler,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Hook for for resetting current user's borrow data. Can be used to reset
|
|
111
|
-
* borrow data manually, which forces the data to be re-fetched.
|
|
112
|
-
* @returns Function `resetBorrowData` for resetting the borrow data
|
|
113
|
-
*/
|
|
114
|
-
export function useResetBorrowData() {
|
|
115
|
-
const queryClient = useQueryClient();
|
|
116
|
-
const { queryKey } = useBorrowData();
|
|
117
|
-
const resetBorrowDataHandler = useCallback(() => queryClient.resetQueries({ queryKey }), [queryClient, queryKey]);
|
|
118
|
-
return {
|
|
119
|
-
resetBorrowData: resetBorrowDataHandler,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=useBorrowData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBorrowData.js","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAA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2B;KAClD,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAA;IAEpC,MAAM,sBAAsB,GAAG,WAAW,CACxC,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,EAC5C,CAAC,WAAW,EAAE,QAAQ,CAAC,CACxB,CAAA;IAED,OAAO;QACL,eAAe,EAAE,sBAAsB;KACxC,CAAA;AACH,CAAC"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { MutationOptions, DefaultError } from "@tanstack/react-query";
|
|
2
|
-
import type { CreateAccountRequest, CreateAccountResponse } from "../api";
|
|
3
|
-
export declare function useCreateAccount(mutationOptions?: Omit<MutationOptions<CreateAccountResponse, DefaultError, CreateAccountRequest>, "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
|
-
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
19
|
-
mezoId: string;
|
|
20
|
-
hasModifiedMezoId: boolean;
|
|
21
|
-
linkedAccounts: import("../api").LinkedAccount[];
|
|
22
|
-
}, Error, CreateAccountRequest, unknown>;
|
|
23
|
-
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
24
|
-
mezoId: string;
|
|
25
|
-
hasModifiedMezoId: boolean;
|
|
26
|
-
linkedAccounts: import("../api").LinkedAccount[];
|
|
27
|
-
}, Error, CreateAccountRequest, unknown>;
|
|
28
|
-
} | {
|
|
29
|
-
data: undefined;
|
|
30
|
-
variables: CreateAccountRequest;
|
|
31
|
-
error: null;
|
|
32
|
-
isError: false;
|
|
33
|
-
isIdle: false;
|
|
34
|
-
isPending: true;
|
|
35
|
-
isSuccess: false;
|
|
36
|
-
status: "pending";
|
|
37
|
-
reset: () => void;
|
|
38
|
-
context: unknown;
|
|
39
|
-
failureCount: number;
|
|
40
|
-
failureReason: Error | null;
|
|
41
|
-
isPaused: boolean;
|
|
42
|
-
submittedAt: number;
|
|
43
|
-
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
44
|
-
mezoId: string;
|
|
45
|
-
hasModifiedMezoId: boolean;
|
|
46
|
-
linkedAccounts: import("../api").LinkedAccount[];
|
|
47
|
-
}, Error, CreateAccountRequest, unknown>;
|
|
48
|
-
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
49
|
-
mezoId: string;
|
|
50
|
-
hasModifiedMezoId: boolean;
|
|
51
|
-
linkedAccounts: import("../api").LinkedAccount[];
|
|
52
|
-
}, Error, CreateAccountRequest, unknown>;
|
|
53
|
-
} | {
|
|
54
|
-
data: undefined;
|
|
55
|
-
error: Error;
|
|
56
|
-
variables: CreateAccountRequest;
|
|
57
|
-
isError: true;
|
|
58
|
-
isIdle: false;
|
|
59
|
-
isPending: false;
|
|
60
|
-
isSuccess: false;
|
|
61
|
-
status: "error";
|
|
62
|
-
reset: () => void;
|
|
63
|
-
context: unknown;
|
|
64
|
-
failureCount: number;
|
|
65
|
-
failureReason: Error | null;
|
|
66
|
-
isPaused: boolean;
|
|
67
|
-
submittedAt: number;
|
|
68
|
-
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
69
|
-
mezoId: string;
|
|
70
|
-
hasModifiedMezoId: boolean;
|
|
71
|
-
linkedAccounts: import("../api").LinkedAccount[];
|
|
72
|
-
}, Error, CreateAccountRequest, unknown>;
|
|
73
|
-
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
74
|
-
mezoId: string;
|
|
75
|
-
hasModifiedMezoId: boolean;
|
|
76
|
-
linkedAccounts: import("../api").LinkedAccount[];
|
|
77
|
-
}, Error, CreateAccountRequest, unknown>;
|
|
78
|
-
} | {
|
|
79
|
-
data: {
|
|
80
|
-
mezoId: string;
|
|
81
|
-
hasModifiedMezoId: boolean;
|
|
82
|
-
linkedAccounts: import("../api").LinkedAccount[];
|
|
83
|
-
};
|
|
84
|
-
error: null;
|
|
85
|
-
variables: CreateAccountRequest;
|
|
86
|
-
isError: false;
|
|
87
|
-
isIdle: false;
|
|
88
|
-
isPending: false;
|
|
89
|
-
isSuccess: true;
|
|
90
|
-
status: "success";
|
|
91
|
-
reset: () => void;
|
|
92
|
-
context: unknown;
|
|
93
|
-
failureCount: number;
|
|
94
|
-
failureReason: Error | null;
|
|
95
|
-
isPaused: boolean;
|
|
96
|
-
submittedAt: number;
|
|
97
|
-
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
98
|
-
mezoId: string;
|
|
99
|
-
hasModifiedMezoId: boolean;
|
|
100
|
-
linkedAccounts: import("../api").LinkedAccount[];
|
|
101
|
-
}, Error, CreateAccountRequest, unknown>;
|
|
102
|
-
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
103
|
-
mezoId: string;
|
|
104
|
-
hasModifiedMezoId: boolean;
|
|
105
|
-
linkedAccounts: import("../api").LinkedAccount[];
|
|
106
|
-
}, Error, CreateAccountRequest, unknown>;
|
|
107
|
-
};
|
|
108
|
-
//# sourceMappingURL=useCreateAccount.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAEzE,wBAAgB,gBAAgB,CAC9B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,CAAC,EAC1E,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBP"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useQueryClient, useMutation, } from "@tanstack/react-query";
|
|
2
|
-
import { useAuthApiClient } from "./useAuthApiClient";
|
|
3
|
-
import { QUERY_KEYS } from "./constants";
|
|
4
|
-
export function useCreateAccount(mutationOptions = {}) {
|
|
5
|
-
const queryClient = useQueryClient();
|
|
6
|
-
const authApiClient = useAuthApiClient();
|
|
7
|
-
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
8
|
-
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
9
|
-
mutationFn: (createAccountRequest) => authApiClient.createAccount(createAccountRequest),
|
|
10
|
-
onSuccess: (data, variables, context) => {
|
|
11
|
-
queryClient.resetQueries({
|
|
12
|
-
queryKey: [QUERY_KEYS.ACCOUNT],
|
|
13
|
-
});
|
|
14
|
-
if (customOnSuccess)
|
|
15
|
-
customOnSuccess(data, variables, context);
|
|
16
|
-
},
|
|
17
|
-
...restMutationOptions,
|
|
18
|
-
});
|
|
19
|
-
return { createAccount: mutate, createAccountAsync: mutateAsync, ...rest };
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=useCreateAccount.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateAccount.js","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,UAAU,gBAAgB,CAC9B,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,CAAC,oBAA0C,EAAE,EAAE,CACzD,aAAa,CAAC,aAAa,CAAC,oBAAoB,CAAC;QACnD,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACtC,WAAW,CAAC,YAAY,CAAC;gBACvB,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;aAC/B,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,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAC5E,CAAC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { MutationOptions, DefaultError } from "@tanstack/react-query";
|
|
2
|
-
import type { CreateSessionRequest, CreateSessionResponse } from "../api";
|
|
3
|
-
/**
|
|
4
|
-
* This hook is not exposed for external consumers. For creating session they
|
|
5
|
-
* should use `useSignIn` hook related to the authentication method.
|
|
6
|
-
*/
|
|
7
|
-
export declare function useCreateSession(mutationOptions?: Omit<MutationOptions<CreateSessionResponse, DefaultError, CreateSessionRequest>, "mutationFn" | "mutationKey">): {
|
|
8
|
-
data: undefined;
|
|
9
|
-
variables: undefined;
|
|
10
|
-
error: null;
|
|
11
|
-
isError: false;
|
|
12
|
-
isIdle: true;
|
|
13
|
-
isPending: false;
|
|
14
|
-
isSuccess: false;
|
|
15
|
-
status: "idle";
|
|
16
|
-
reset: () => void;
|
|
17
|
-
context: unknown;
|
|
18
|
-
failureCount: number;
|
|
19
|
-
failureReason: Error | null;
|
|
20
|
-
isPaused: boolean;
|
|
21
|
-
submittedAt: number;
|
|
22
|
-
createSession: import("@tanstack/react-query").UseMutateFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
23
|
-
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
24
|
-
} | {
|
|
25
|
-
data: undefined;
|
|
26
|
-
variables: CreateSessionRequest;
|
|
27
|
-
error: null;
|
|
28
|
-
isError: false;
|
|
29
|
-
isIdle: false;
|
|
30
|
-
isPending: true;
|
|
31
|
-
isSuccess: false;
|
|
32
|
-
status: "pending";
|
|
33
|
-
reset: () => void;
|
|
34
|
-
context: unknown;
|
|
35
|
-
failureCount: number;
|
|
36
|
-
failureReason: Error | null;
|
|
37
|
-
isPaused: boolean;
|
|
38
|
-
submittedAt: number;
|
|
39
|
-
createSession: import("@tanstack/react-query").UseMutateFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
40
|
-
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
41
|
-
} | {
|
|
42
|
-
data: undefined;
|
|
43
|
-
error: Error;
|
|
44
|
-
variables: CreateSessionRequest;
|
|
45
|
-
isError: true;
|
|
46
|
-
isIdle: false;
|
|
47
|
-
isPending: false;
|
|
48
|
-
isSuccess: false;
|
|
49
|
-
status: "error";
|
|
50
|
-
reset: () => void;
|
|
51
|
-
context: unknown;
|
|
52
|
-
failureCount: number;
|
|
53
|
-
failureReason: Error | null;
|
|
54
|
-
isPaused: boolean;
|
|
55
|
-
submittedAt: number;
|
|
56
|
-
createSession: import("@tanstack/react-query").UseMutateFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
57
|
-
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
58
|
-
} | {
|
|
59
|
-
data: CreateSessionResponse;
|
|
60
|
-
error: null;
|
|
61
|
-
variables: CreateSessionRequest;
|
|
62
|
-
isError: false;
|
|
63
|
-
isIdle: false;
|
|
64
|
-
isPending: false;
|
|
65
|
-
isSuccess: true;
|
|
66
|
-
status: "success";
|
|
67
|
-
reset: () => void;
|
|
68
|
-
context: unknown;
|
|
69
|
-
failureCount: number;
|
|
70
|
-
failureReason: Error | null;
|
|
71
|
-
isPaused: boolean;
|
|
72
|
-
submittedAt: number;
|
|
73
|
-
createSession: import("@tanstack/react-query").UseMutateFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
74
|
-
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=useCreateSession.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateSession.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAGzE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,CAAC,EAC1E,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBP"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useQueryClient, useMutation, } from "@tanstack/react-query";
|
|
2
|
-
import { useAuthApiClient } from "./useAuthApiClient";
|
|
3
|
-
import { QUERY_KEYS } from "./constants";
|
|
4
|
-
/**
|
|
5
|
-
* This hook is not exposed for external consumers. For creating session they
|
|
6
|
-
* should use `useSignIn` hook related to the authentication method.
|
|
7
|
-
*/
|
|
8
|
-
export function useCreateSession(mutationOptions = {}) {
|
|
9
|
-
const queryClient = useQueryClient();
|
|
10
|
-
const authApiClient = useAuthApiClient();
|
|
11
|
-
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
12
|
-
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
13
|
-
mutationFn: (createSessionRequest) => authApiClient.createSession(createSessionRequest),
|
|
14
|
-
onSuccess: (data, variables, context) => {
|
|
15
|
-
// Since `getSession` query also has code in its query keys we can't set
|
|
16
|
-
// query data for a specific query, because we don't know if the code was
|
|
17
|
-
// used or not. Because of that we just reset all getSession queries
|
|
18
|
-
queryClient.resetQueries({ queryKey: [QUERY_KEYS.SESSION] });
|
|
19
|
-
queryClient.resetQueries({
|
|
20
|
-
queryKey: [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT],
|
|
21
|
-
});
|
|
22
|
-
if (customOnSuccess)
|
|
23
|
-
customOnSuccess(data, variables, context);
|
|
24
|
-
},
|
|
25
|
-
...restMutationOptions,
|
|
26
|
-
});
|
|
27
|
-
return { createSession: mutate, createSessionAsync: mutateAsync, ...rest };
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=useCreateSession.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateSession.js","sourceRoot":"","sources":["../../../src/hooks/useCreateSession.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;AAExC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,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,CAAC,oBAA0C,EAAE,EAAE,CACzD,aAAa,CAAC,aAAa,CAAC,oBAAoB,CAAC;QACnD,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACtC,wEAAwE;YACxE,yEAAyE;YACzE,oEAAoE;YACpE,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,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAC5E,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { CryptoAssetKey } from "../utils/cryptoAssets";
|
|
2
|
-
export type DropdownCryptoAsset<T = CryptoAssetKey> = {
|
|
3
|
-
type: T;
|
|
4
|
-
balance: bigint;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Aggregates dropdown data for Dropdown component.
|
|
8
|
-
* @param {accountDataRefetchInterval: number, nativeBalanceRefetchInterval: number }
|
|
9
|
-
* Object containing refetch intervals time (in milliseconds) for account data
|
|
10
|
-
* (like mats or mezo id) and for native balance. After that time the specific
|
|
11
|
-
* value should be marked as stale and re-fetched. Default value for both is
|
|
12
|
-
* 90000 (90 secs).
|
|
13
|
-
* @returns Dropdown data.
|
|
14
|
-
* @dev This hook is for internal use only.
|
|
15
|
-
*/
|
|
16
|
-
export default function useDropdownData({ accountDataRefetchInterval, nativeBalanceRefetchInterval, }: {
|
|
17
|
-
accountDataRefetchInterval?: number | undefined;
|
|
18
|
-
nativeBalanceRefetchInterval?: number | undefined;
|
|
19
|
-
}): {
|
|
20
|
-
mezoId: string | undefined;
|
|
21
|
-
matsBalance: number;
|
|
22
|
-
accountAddress: `0x${string}` | undefined;
|
|
23
|
-
walletAddress: string | undefined;
|
|
24
|
-
walletType: "bitcoin" | "evm";
|
|
25
|
-
usdTotalBalance: number;
|
|
26
|
-
usdTroveDebt: number;
|
|
27
|
-
usdCollateral: number;
|
|
28
|
-
assets: {
|
|
29
|
-
btc: {
|
|
30
|
-
type: CryptoAssetKey;
|
|
31
|
-
rawBalance: bigint;
|
|
32
|
-
formattedBalance: string;
|
|
33
|
-
usdBalance: number;
|
|
34
|
-
formattedUsdBalance: string;
|
|
35
|
-
};
|
|
36
|
-
musd: {
|
|
37
|
-
type: CryptoAssetKey;
|
|
38
|
-
rawBalance: bigint;
|
|
39
|
-
formattedBalance: string;
|
|
40
|
-
usdBalance: number;
|
|
41
|
-
formattedUsdBalance: string;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
otherAssetsCount: number;
|
|
45
|
-
otherAssetsUsdTotal: number;
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=useDropdownData.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDropdownData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDropdownData.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EAGf,MAAM,uBAAuB,CAAA;AAU9B,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,cAAc,IAAI;IACpD,IAAI,EAAE,CAAC,CAAA;IACP,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AASD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,0BAAkC,EAClC,4BAAoC,GACrC;;;CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiGA"}
|