@mezo-org/passport 0.4.0-dev.2 → 0.4.0-dev.21
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 +57 -52
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/api/auth.js +22 -53
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +24 -0
- package/dist/src/api/client.d.ts.map +1 -0
- package/dist/src/api/client.js +54 -0
- package/dist/src/api/client.js.map +1 -0
- package/dist/src/api/fetch-error.d.ts +5 -0
- package/dist/src/api/fetch-error.d.ts.map +1 -0
- package/dist/src/api/fetch-error.js +8 -0
- package/dist/src/api/fetch-error.js.map +1 -0
- package/dist/src/api/index.d.ts +3 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +3 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/api/portal.d.ts +33 -0
- package/dist/src/api/portal.d.ts.map +1 -0
- package/dist/src/api/portal.js +23 -0
- package/dist/src/api/portal.js.map +1 -0
- package/dist/src/assets/DefaultAvatar.d.ts +5 -0
- package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
- package/dist/src/assets/DefaultAvatar.js +21 -0
- package/dist/src/assets/DefaultAvatar.js.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +8 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js +39 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Content.d.ts +23 -0
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Content.js +27 -0
- package/dist/src/components/Dropdown/Content.js.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts +23 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.js +65 -0
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.js +34 -0
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +47 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.js +57 -0
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js +64 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +44 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
- package/dist/src/components/Dropdown/index.d.ts +3 -0
- package/dist/src/components/Dropdown/index.d.ts.map +1 -0
- package/dist/src/components/Dropdown/index.js +2 -0
- package/dist/src/components/Dropdown/index.js.map +1 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/config.js +2 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/constants.d.ts +2 -1
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +5 -4
- package/dist/src/constants.js.map +1 -1
- package/dist/src/hooks/constants.d.ts +3 -3
- package/dist/src/hooks/constants.js +4 -4
- package/dist/src/hooks/constants.js.map +1 -1
- package/dist/src/hooks/index.d.ts +4 -4
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +4 -4
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +7 -0
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
- package/dist/src/hooks/useAssetsConversionRates.js +24 -0
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
- package/dist/src/hooks/useAuthApiClient.d.ts +1 -1
- package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +73 -0
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -0
- package/dist/src/hooks/useAuthenticateWithWallet.js +69 -0
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -0
- package/dist/src/hooks/useBorrowData.d.ts +1418 -0
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
- package/dist/src/hooks/useBorrowData.js +65 -0
- package/dist/src/hooks/useBorrowData.js.map +1 -0
- package/dist/src/hooks/useCreateAccount.d.ts +41 -137
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +8 -10
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useCreateSession.d.ts +12 -182
- package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
- package/dist/src/hooks/useCreateSession.js +12 -18
- package/dist/src/hooks/useCreateSession.js.map +1 -1
- package/dist/src/hooks/useDropdownData.d.ts +39 -0
- package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
- package/dist/src/hooks/useDropdownData.js +63 -0
- package/dist/src/hooks/useDropdownData.js.map +1 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts +5 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts.map +1 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js +34 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js.map +1 -0
- package/dist/src/hooks/useGetAccountByAddress.d.ts +3 -5
- package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
- package/dist/src/hooks/useGetAccountByAddress.js +3 -4
- package/dist/src/hooks/useGetAccountByAddress.js.map +1 -1
- package/dist/src/hooks/useGetAccountByMezoId.d.ts +3 -5
- package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useGetAccountByMezoId.js +3 -4
- package/dist/src/hooks/useGetAccountByMezoId.js.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts +14 -8
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +28 -6
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useGetSession.d.ts +3 -20
- package/dist/src/hooks/useGetSession.d.ts.map +1 -1
- package/dist/src/hooks/useGetSession.js +2 -2
- package/dist/src/hooks/useGetSession.js.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts +15 -121
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +8 -21
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
- package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
- package/dist/src/hooks/usePortalApiClient.js +6 -0
- package/dist/src/hooks/usePortalApiClient.js.map +1 -0
- package/dist/src/hooks/useRefreshPassport.d.ts +17 -0
- package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
- package/dist/src/hooks/useRefreshPassport.js +29 -0
- package/dist/src/hooks/useRefreshPassport.js.map +1 -0
- package/dist/src/hooks/useSignInWithDiscord.d.ts +12 -181
- package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithDiscord.js +11 -22
- package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.d.ts +12 -181
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.js +6 -44
- package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
- package/dist/src/hooks/useSignOut.d.ts +12 -28
- package/dist/src/hooks/useSignOut.d.ts.map +1 -1
- package/dist/src/hooks/useSignOut.js +11 -6
- package/dist/src/hooks/useSignOut.js.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +73 -0
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -0
- package/dist/src/hooks/useSignUpWithWallet.js +11 -0
- package/dist/src/hooks/useSignUpWithWallet.js.map +1 -0
- package/dist/src/hooks/useTokensBalances.d.ts +74 -0
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
- package/dist/src/hooks/useTokensBalances.js +140 -0
- package/dist/src/hooks/useTokensBalances.js.map +1 -0
- package/dist/src/hooks/useUpdateMezoId.d.ts +30 -82
- package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useUpdateMezoId.js +8 -12
- package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +13 -0
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
- package/dist/src/hooks/useWalletAccount.js +29 -0
- package/dist/src/hooks/useWalletAccount.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/contracts/index.d.ts +10 -0
- package/dist/src/lib/contracts/index.d.ts.map +1 -0
- package/dist/src/lib/contracts/index.js +49 -0
- package/dist/src/lib/contracts/index.js.map +1 -0
- package/dist/src/lib/contracts/musd.d.ts +107 -0
- package/dist/src/lib/contracts/musd.d.ts.map +1 -0
- package/dist/src/lib/contracts/musd.js +1070 -0
- package/dist/src/lib/contracts/musd.js.map +1 -0
- package/dist/src/lib/contracts/troveManager.d.ts +1401 -0
- package/dist/src/lib/contracts/troveManager.d.ts.map +1 -0
- package/dist/src/lib/contracts/troveManager.js +1820 -0
- package/dist/src/lib/contracts/troveManager.js.map +1 -0
- package/dist/src/provider.d.ts +10 -13
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +11 -20
- package/dist/src/provider.js.map +1 -1
- package/dist/src/stores/dropdownStore.d.ts +12 -0
- package/dist/src/stores/dropdownStore.d.ts.map +1 -0
- package/dist/src/stores/dropdownStore.js +13 -0
- package/dist/src/stores/dropdownStore.js.map +1 -0
- package/dist/src/utils/address.d.ts +15 -0
- package/dist/src/utils/address.d.ts.map +1 -0
- package/dist/src/utils/address.js +37 -0
- package/dist/src/utils/address.js.map +1 -0
- package/dist/src/utils/address.test.d.ts +2 -0
- package/dist/src/utils/address.test.d.ts.map +1 -0
- package/dist/src/utils/address.test.js +40 -0
- package/dist/src/utils/address.test.js.map +1 -0
- package/dist/src/utils/cryptoAssets.d.ts +44 -0
- package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.js +131 -0
- package/dist/src/utils/cryptoAssets.js.map +1 -0
- package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
- package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.test.js +67 -0
- package/dist/src/utils/cryptoAssets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +14 -0
- package/dist/src/utils/currency.d.ts.map +1 -0
- package/dist/src/utils/currency.js +27 -0
- package/dist/src/utils/currency.js.map +1 -0
- package/dist/src/utils/currency.test.d.ts +2 -0
- package/dist/src/utils/currency.test.d.ts.map +1 -0
- package/dist/src/utils/currency.test.js +34 -0
- package/dist/src/utils/currency.test.js.map +1 -0
- package/dist/src/utils/numbers.d.ts +58 -0
- package/dist/src/utils/numbers.d.ts.map +1 -0
- package/dist/src/utils/numbers.js +132 -0
- package/dist/src/utils/numbers.js.map +1 -0
- package/dist/src/utils/numbers.test.d.ts +2 -0
- package/dist/src/utils/numbers.test.d.ts.map +1 -0
- package/dist/src/utils/numbers.test.js +170 -0
- package/dist/src/utils/numbers.test.js.map +1 -0
- package/package.json +12 -5
- package/src/api/auth.ts +104 -129
- package/src/api/client.ts +78 -0
- package/src/api/fetch-error.ts +8 -0
- package/src/api/index.ts +2 -0
- package/src/api/portal.ts +57 -0
- package/src/assets/DefaultAvatar.tsx +74 -0
- package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
- package/src/components/Dropdown/Content.tsx +98 -0
- package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
- package/src/components/Dropdown/Dropdown.tsx +139 -0
- package/src/components/Dropdown/ListingItem.tsx +80 -0
- package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
- package/src/components/Dropdown/README.md +41 -0
- package/src/components/Dropdown/Receive/Receive.tsx +119 -0
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
- package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
- package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +63 -0
- package/src/components/Dropdown/Root/Root.tsx +147 -0
- package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +91 -0
- package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
- package/src/components/Dropdown/index.ts +2 -0
- package/src/components/index.ts +1 -0
- package/src/config.ts +2 -2
- package/src/constants.ts +5 -4
- package/src/hooks/constants.ts +4 -4
- package/src/hooks/index.ts +7 -4
- package/src/hooks/useAssetsConversionRates.ts +32 -0
- package/src/hooks/useAuthenticateWithWallet.ts +102 -0
- package/src/hooks/useBorrowData.ts +79 -0
- package/src/hooks/useCreateAccount.ts +20 -11
- package/src/hooks/useCreateSession.ts +24 -18
- package/src/hooks/useDropdownData.ts +101 -0
- package/src/hooks/useEnsureNoSessionAndFetchNonce.ts +46 -0
- package/src/hooks/useGetAccountByAddress.ts +11 -5
- package/src/hooks/useGetAccountByMezoId.ts +11 -5
- package/src/hooks/useGetCurrentAccount.ts +53 -7
- package/src/hooks/useGetSession.ts +10 -3
- package/src/hooks/useLinkAccount.ts +19 -31
- package/src/hooks/usePortalApiClient.ts +6 -0
- package/src/hooks/useRefreshPassport.ts +40 -0
- package/src/hooks/useSignInWithDiscord.ts +19 -28
- package/src/hooks/useSignInWithWallet.ts +14 -55
- package/src/hooks/useSignOut.ts +22 -6
- package/src/hooks/useSignUpWithWallet.ts +21 -0
- package/src/hooks/useTokensBalances.ts +187 -0
- package/src/hooks/useUpdateMezoId.ts +20 -12
- package/src/hooks/useWalletAccount.ts +55 -0
- package/src/index.ts +1 -0
- package/src/lib/contracts/index.ts +75 -0
- package/src/lib/contracts/musd.ts +1071 -0
- package/src/lib/contracts/troveManager.ts +1819 -0
- package/src/provider.ts +30 -37
- package/src/stores/dropdownStore.ts +20 -0
- package/src/utils/address.test.ts +48 -0
- package/src/utils/address.ts +45 -0
- package/src/utils/cryptoAssets.test.ts +79 -0
- package/src/utils/cryptoAssets.ts +173 -0
- package/src/utils/currency.test.ts +38 -0
- package/src/utils/currency.ts +32 -0
- package/src/utils/numbers.test.ts +220 -0
- package/src/utils/numbers.ts +188 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useQueryClient } from "@tanstack/react-query"
|
|
2
|
+
import { useCallback } from "react"
|
|
3
|
+
import { QUERY_KEYS } from "./constants"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hook to refresh the passport using query invalidation mechanism.
|
|
7
|
+
* By calling the refresh function, the latest data will be refetched as soon as possible.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const { refreshCurrentAccount, refreshUsdConversion } = useRefreshPassport()
|
|
11
|
+
*
|
|
12
|
+
* // Call this function to refresh the current account
|
|
13
|
+
* const handlerefreshCurrentAccount = async () => {
|
|
14
|
+
* await refreshCurrentAccount()
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export function useRefreshPassport() {
|
|
18
|
+
const queryClient = useQueryClient()
|
|
19
|
+
|
|
20
|
+
const refreshCurrentAccount = useCallback(
|
|
21
|
+
() =>
|
|
22
|
+
queryClient.invalidateQueries({
|
|
23
|
+
queryKey: [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT],
|
|
24
|
+
}),
|
|
25
|
+
[queryClient],
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const refreshUsdConversion = useCallback(
|
|
29
|
+
() =>
|
|
30
|
+
queryClient.invalidateQueries({
|
|
31
|
+
queryKey: [QUERY_KEYS.ASSETS_USD_CONVERSION],
|
|
32
|
+
}),
|
|
33
|
+
[queryClient],
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
refreshCurrentAccount,
|
|
38
|
+
refreshUsdConversion,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,42 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMutation } from "@tanstack/react-query"
|
|
3
|
-
import { useGetSession } from "./useGetSession"
|
|
1
|
+
import { MutationOptions, useMutation } from "@tanstack/react-query"
|
|
4
2
|
import { useCreateSession } from "./useCreateSession"
|
|
3
|
+
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce"
|
|
4
|
+
import type { AuthenticationProviderRedirectResponse } from "../api"
|
|
5
5
|
|
|
6
|
-
function useSignInWithDiscord(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
6
|
+
function useSignInWithDiscord(
|
|
7
|
+
mutationOptions: Omit<
|
|
8
|
+
MutationOptions<AuthenticationProviderRedirectResponse>,
|
|
9
|
+
"mutationFn" | "mutationKey"
|
|
10
|
+
> = {},
|
|
11
|
+
) {
|
|
12
|
+
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce()
|
|
11
13
|
const { createSessionAsync } = useCreateSession()
|
|
12
14
|
|
|
13
15
|
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
14
|
-
mutationFn: async () => {
|
|
15
|
-
|
|
16
|
-
throw new Error("Sign in error: User not connected!")
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const getSessionResult = await getSession()
|
|
20
|
-
|
|
21
|
-
// TODO: We should create a separate endpoint that will always return nonce
|
|
22
|
-
if (!getSessionResult.data || !("nonce" in getSessionResult.data)) {
|
|
23
|
-
if (getSessionResult.error) {
|
|
24
|
-
throw new Error(`Sign in error: ${getSessionResult.error}`)
|
|
25
|
-
}
|
|
26
|
-
throw new Error(
|
|
27
|
-
"Sign in error: Nonce not available! Remove the session first.",
|
|
28
|
-
)
|
|
29
|
-
}
|
|
16
|
+
mutationFn: async (): Promise<AuthenticationProviderRedirectResponse> => {
|
|
17
|
+
await ensureNoSessionAndFetchNonce()
|
|
30
18
|
|
|
31
|
-
return createSessionAsync({
|
|
19
|
+
return (await createSessionAsync({
|
|
32
20
|
type: "discord",
|
|
33
|
-
})
|
|
21
|
+
})) as AuthenticationProviderRedirectResponse
|
|
22
|
+
// ^ By passing type: "discord" we know for sure the return type is
|
|
23
|
+
// AuthenticationProviderRedirectResponse
|
|
34
24
|
},
|
|
25
|
+
...mutationOptions,
|
|
35
26
|
})
|
|
36
27
|
|
|
37
28
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
signInWithDiscord: mutate,
|
|
30
|
+
signInWithDiscordAsync: mutateAsync,
|
|
40
31
|
...signInMutationRestParameters,
|
|
41
32
|
}
|
|
42
33
|
}
|
|
@@ -1,61 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useGetSession } from "./useGetSession"
|
|
5
|
-
import { useCreateSession } from "./useCreateSession"
|
|
6
|
-
import { createSignInWithWalletMessage } from "../utils/siww"
|
|
1
|
+
import { MutationOptions } from "@tanstack/react-query"
|
|
2
|
+
import { useAuthenticateWithWallet } from "./useAuthenticateWithWallet"
|
|
3
|
+
import type { Session } from "../api"
|
|
7
4
|
|
|
8
|
-
function useSignInWithWallet(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const { signMessageAsync } = useSignMessage()
|
|
17
|
-
|
|
18
|
-
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
19
|
-
mutationFn: async () => {
|
|
20
|
-
if (!address) {
|
|
21
|
-
throw new Error("Sign in error: User not connected!")
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const getSessionResult = await getSession()
|
|
25
|
-
|
|
26
|
-
// TODO: We should create a separate endpoint that will always return nonce
|
|
27
|
-
if (!getSessionResult.data || !("nonce" in getSessionResult.data)) {
|
|
28
|
-
if (getSessionResult.error) {
|
|
29
|
-
throw new Error(`Sign in error: ${getSessionResult.error}`)
|
|
30
|
-
}
|
|
31
|
-
throw new Error(
|
|
32
|
-
"Sign in error: Nonce not available! Remove the session first.",
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const networkFamily = btcAddress ? "bitcoin" : "evm"
|
|
37
|
-
const messageResult = createSignInWithWalletMessage(
|
|
38
|
-
btcAddress ? btcAddress! : address!,
|
|
39
|
-
getSessionResult.data.nonce,
|
|
40
|
-
networkFamily,
|
|
41
|
-
chainId,
|
|
42
|
-
)
|
|
43
|
-
const signatureResult = await signMessageAsync({
|
|
44
|
-
message: messageResult,
|
|
45
|
-
connector,
|
|
46
|
-
})
|
|
47
|
-
return createSessionAsync({
|
|
48
|
-
type: "wallet",
|
|
49
|
-
message: messageResult,
|
|
50
|
-
signature: signatureResult,
|
|
51
|
-
})
|
|
52
|
-
},
|
|
53
|
-
})
|
|
5
|
+
function useSignInWithWallet(
|
|
6
|
+
mutationOptions: Omit<
|
|
7
|
+
MutationOptions<Session>,
|
|
8
|
+
"mutationFn" | "mutationKey"
|
|
9
|
+
> = {},
|
|
10
|
+
) {
|
|
11
|
+
const { authenticateWithWallet, authenticateWithWalletAsync, ...rest } =
|
|
12
|
+
useAuthenticateWithWallet(false, mutationOptions)
|
|
54
13
|
|
|
55
14
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...
|
|
15
|
+
signInWithWallet: authenticateWithWallet,
|
|
16
|
+
signInWithWalletAsync: authenticateWithWalletAsync,
|
|
17
|
+
...rest,
|
|
59
18
|
}
|
|
60
19
|
}
|
|
61
20
|
|
package/src/hooks/useSignOut.ts
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
MutationOptions,
|
|
3
|
+
useMutation,
|
|
4
|
+
useQueryClient,
|
|
5
|
+
} from "@tanstack/react-query"
|
|
2
6
|
import { useAuthApiClient } from "./useAuthApiClient"
|
|
3
7
|
import { QUERY_KEYS } from "./constants"
|
|
8
|
+
import type { DeleteSessionResponse } from "../api"
|
|
4
9
|
|
|
5
|
-
export function useSignOut(
|
|
10
|
+
export function useSignOut(
|
|
11
|
+
mutationOptions: Omit<
|
|
12
|
+
MutationOptions<DeleteSessionResponse>,
|
|
13
|
+
"mutationFn" | "mutationKey"
|
|
14
|
+
> = {},
|
|
15
|
+
) {
|
|
6
16
|
const queryClient = useQueryClient()
|
|
7
17
|
const authApiClient = useAuthApiClient()
|
|
8
18
|
|
|
19
|
+
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions
|
|
20
|
+
|
|
9
21
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
10
22
|
mutationFn: () => authApiClient.deleteSession(),
|
|
11
|
-
onSuccess: () => {
|
|
12
|
-
queryClient.resetQueries({ queryKey: [QUERY_KEYS.SESSION]
|
|
13
|
-
queryClient.resetQueries({
|
|
23
|
+
onSuccess: (data, variables, context) => {
|
|
24
|
+
queryClient.resetQueries({ queryKey: [QUERY_KEYS.SESSION] })
|
|
25
|
+
queryClient.resetQueries({
|
|
26
|
+
queryKey: [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT],
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
if (customOnSuccess) customOnSuccess(data, variables, context)
|
|
14
30
|
},
|
|
15
|
-
...
|
|
31
|
+
...restMutationOptions,
|
|
16
32
|
})
|
|
17
33
|
|
|
18
34
|
return { signOut: mutate, signOutAsync: mutateAsync, ...rest }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MutationOptions } from "@tanstack/react-query"
|
|
2
|
+
import { useAuthenticateWithWallet } from "./useAuthenticateWithWallet"
|
|
3
|
+
import type { Session } from "../api"
|
|
4
|
+
|
|
5
|
+
function useSignUpWithWallet(
|
|
6
|
+
mutationOptions: Omit<
|
|
7
|
+
MutationOptions<Session>,
|
|
8
|
+
"mutationFn" | "mutationKey"
|
|
9
|
+
> = {},
|
|
10
|
+
) {
|
|
11
|
+
const { authenticateWithWallet, authenticateWithWalletAsync, ...rest } =
|
|
12
|
+
useAuthenticateWithWallet(true, mutationOptions)
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
signUpWithWallet: authenticateWithWallet,
|
|
16
|
+
signUpWithWalletAsync: authenticateWithWalletAsync,
|
|
17
|
+
...rest,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { useSignUpWithWallet }
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { useReadContracts } from "wagmi"
|
|
2
|
+
import { useCallback, useMemo } from "react"
|
|
3
|
+
import { Abi } from "viem"
|
|
4
|
+
import { useQueryClient } from "@tanstack/react-query"
|
|
5
|
+
import { usePassportContext } from "./usePassportContext"
|
|
6
|
+
import {
|
|
7
|
+
mainnetContracts,
|
|
8
|
+
testnetContracts,
|
|
9
|
+
MezoChainToken,
|
|
10
|
+
} from "../lib/contracts"
|
|
11
|
+
import useWalletAccount from "./useWalletAccount"
|
|
12
|
+
import { CHAIN_ID } from "../constants"
|
|
13
|
+
|
|
14
|
+
// Wagmi handles typesafety with ABI const assertions. TypeScript doesn't
|
|
15
|
+
// support importing JSON as const yet so types cannot be inferred from the
|
|
16
|
+
// imported contract. As a workaround there is minimal ABI definition that can
|
|
17
|
+
// be asserted types from.
|
|
18
|
+
// Ref: https://wagmi.sh/core/typescript#const-assert-abis-typed-data
|
|
19
|
+
|
|
20
|
+
const BALANCE_OF_ABI = [
|
|
21
|
+
{
|
|
22
|
+
inputs: [
|
|
23
|
+
{
|
|
24
|
+
internalType: "address",
|
|
25
|
+
name: "account",
|
|
26
|
+
type: "address",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
name: "balanceOf",
|
|
30
|
+
outputs: [
|
|
31
|
+
{
|
|
32
|
+
internalType: "uint256",
|
|
33
|
+
name: "",
|
|
34
|
+
type: "uint256",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
stateMutability: "view",
|
|
38
|
+
type: "function",
|
|
39
|
+
},
|
|
40
|
+
] as const satisfies Abi
|
|
41
|
+
|
|
42
|
+
const BALANCE_TOKENS: MezoChainToken[] = [
|
|
43
|
+
"mcbBTC",
|
|
44
|
+
"mDAI",
|
|
45
|
+
"mFBTC",
|
|
46
|
+
"mSolvBTC",
|
|
47
|
+
"mswBTC",
|
|
48
|
+
"mT",
|
|
49
|
+
"mUSDC",
|
|
50
|
+
"mUSDe",
|
|
51
|
+
"mUSDT",
|
|
52
|
+
"mxSolvBTC",
|
|
53
|
+
"MUSD",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
type UseMezoChainTokensBalancesOptions<T> = {
|
|
57
|
+
tokens?: T
|
|
58
|
+
queryOptions?: object
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Hook to get the balance of a list of tokens for the current account
|
|
63
|
+
* @param options.tokens The list of tokens to get the balance for. It will
|
|
64
|
+
* fallback to all tokens if not provided.
|
|
65
|
+
* @param options.queryOptions The query options to pass to the
|
|
66
|
+
* `useReadContracts`
|
|
67
|
+
* @returns Tanstack's `useQuery` returnings with balance of tokens for the
|
|
68
|
+
* current account in form of typesafe object with token names as keys
|
|
69
|
+
* and balances as values.
|
|
70
|
+
* @dev In case of error data fallbacks to `0n`. To determine if an error
|
|
71
|
+
* occurred, check the `isError` property.
|
|
72
|
+
* @example
|
|
73
|
+
* const mezoTokensBalance = useTokensBalances({
|
|
74
|
+
* tokens: ["mT", "mxSolvBTC"],
|
|
75
|
+
* })
|
|
76
|
+
* console.log(mezoTokensBalance?.data.mT) // Eg. 0n
|
|
77
|
+
* console.log(Object.keys(mezoTokensBalance?.data)) // ["mT", "mxSolvBTC"]
|
|
78
|
+
*/
|
|
79
|
+
export function useTokensBalances<T extends MezoChainToken[]>(
|
|
80
|
+
options: UseMezoChainTokensBalancesOptions<T> = {},
|
|
81
|
+
) {
|
|
82
|
+
const { environment = "mainnet" } = usePassportContext()
|
|
83
|
+
|
|
84
|
+
const { accountAddress } = useWalletAccount()
|
|
85
|
+
|
|
86
|
+
const contractsMap = useMemo(() => {
|
|
87
|
+
const contracts =
|
|
88
|
+
environment === "mainnet" ? mainnetContracts : testnetContracts
|
|
89
|
+
|
|
90
|
+
const tokenContracts = Object.fromEntries(
|
|
91
|
+
Object.entries(contracts).filter(([key]) =>
|
|
92
|
+
BALANCE_TOKENS.includes(key as MezoChainToken),
|
|
93
|
+
),
|
|
94
|
+
) as typeof contracts
|
|
95
|
+
|
|
96
|
+
return tokenContracts
|
|
97
|
+
}, [environment])
|
|
98
|
+
|
|
99
|
+
const { tokens = Object.keys(contractsMap) as T, queryOptions = {} } = options
|
|
100
|
+
|
|
101
|
+
const contracts = useMemo(() => {
|
|
102
|
+
if (!accountAddress) return []
|
|
103
|
+
|
|
104
|
+
return tokens.map((token) => {
|
|
105
|
+
const { address } = contractsMap[token]
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
address,
|
|
109
|
+
abi: BALANCE_OF_ABI,
|
|
110
|
+
functionName: "balanceOf",
|
|
111
|
+
args: [accountAddress],
|
|
112
|
+
chainId: CHAIN_ID[environment],
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}, [accountAddress, tokens, contractsMap, environment])
|
|
116
|
+
|
|
117
|
+
return useReadContracts({
|
|
118
|
+
contracts,
|
|
119
|
+
query: {
|
|
120
|
+
select: (data) =>
|
|
121
|
+
data.reduce(
|
|
122
|
+
(acc, item) => {
|
|
123
|
+
const token = tokens[data.indexOf(item)]
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
...acc,
|
|
127
|
+
[token]: item.result ?? 0n,
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{} as Record<T[number], bigint>,
|
|
131
|
+
),
|
|
132
|
+
...queryOptions,
|
|
133
|
+
},
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Hook for invalidating current user's token balances. Can be used to
|
|
139
|
+
* invalidate the balances manually, which forces the data to be re-fetched.
|
|
140
|
+
* @param tokens The list of tokens (as string arrays) for which we want to
|
|
141
|
+
* invalidate query for.
|
|
142
|
+
* @returns Function `invalidateTokenBalances` that invalidates token balances
|
|
143
|
+
* @example
|
|
144
|
+
* const { invalidateTokenBalances } = useInvalidateTokensBalances(["mT", "mUSD"])
|
|
145
|
+
* (...)
|
|
146
|
+
* await invalidateTokenBalances()
|
|
147
|
+
*/
|
|
148
|
+
export function useInvalidateTokensBalances(tokens?: MezoChainToken[]) {
|
|
149
|
+
const queryClient = useQueryClient()
|
|
150
|
+
|
|
151
|
+
const { queryKey } = useTokensBalances({ tokens })
|
|
152
|
+
|
|
153
|
+
const invalidateTokenBalancesHandler = useCallback(
|
|
154
|
+
() => queryClient.invalidateQueries({ queryKey }),
|
|
155
|
+
[queryClient, queryKey],
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
invalidateTokenBalances: invalidateTokenBalancesHandler,
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Hook for resetting current user's token balances. Can be used to reset the
|
|
165
|
+
* balances manually, which forces the data to be re-fetched.
|
|
166
|
+
* @param tokens The list of tokens (as string arrays) for which we want to
|
|
167
|
+
* reset query for.
|
|
168
|
+
* @returns Function `resetTokenBalances` that invalidates token balances
|
|
169
|
+
* @example
|
|
170
|
+
* const { resetTokenBalances } = useResetTokensBalances(["mT", "mUSD"])
|
|
171
|
+
* (...)
|
|
172
|
+
* await resetTokenBalances()
|
|
173
|
+
*/
|
|
174
|
+
export function useResetTokensBalances(tokens?: MezoChainToken[]) {
|
|
175
|
+
const queryClient = useQueryClient()
|
|
176
|
+
|
|
177
|
+
const { queryKey } = useTokensBalances({ tokens })
|
|
178
|
+
|
|
179
|
+
const resetTokenBalancesHandler = useCallback(
|
|
180
|
+
() => queryClient.resetQueries({ queryKey }),
|
|
181
|
+
[queryClient, queryKey],
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
resetTokenBalances: resetTokenBalancesHandler,
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useQueryClient,
|
|
3
|
+
useMutation,
|
|
4
|
+
MutationOptions,
|
|
5
|
+
DefaultError,
|
|
6
|
+
} from "@tanstack/react-query"
|
|
2
7
|
import { useAuthApiClient } from "./useAuthApiClient"
|
|
3
8
|
import { QUERY_KEYS } from "./constants"
|
|
9
|
+
import type { UpdateMezoIdResponse } from "../api"
|
|
4
10
|
|
|
5
|
-
export function useUpdateMezoId(
|
|
11
|
+
export function useUpdateMezoId(
|
|
12
|
+
mutationOptions: Omit<
|
|
13
|
+
MutationOptions<UpdateMezoIdResponse, DefaultError, string>,
|
|
14
|
+
"mutationFn" | "mutationKey"
|
|
15
|
+
> = {},
|
|
16
|
+
) {
|
|
6
17
|
const queryClient = useQueryClient()
|
|
7
18
|
const authApiClient = useAuthApiClient()
|
|
8
19
|
|
|
20
|
+
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions
|
|
21
|
+
|
|
9
22
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
10
23
|
mutationFn: (newMezoId: string) => authApiClient.updateMezoId(newMezoId),
|
|
11
|
-
onSuccess: () => {
|
|
12
|
-
queryClient.resetQueries({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
queryClient.resetQueries({
|
|
17
|
-
queryKey: [QUERY_KEYS.ACCOUNT_BY_MEZO_ID],
|
|
18
|
-
exact: false,
|
|
19
|
-
})
|
|
24
|
+
onSuccess: (data, variables, context) => {
|
|
25
|
+
queryClient.resetQueries({ queryKey: [QUERY_KEYS.ACCOUNT] })
|
|
26
|
+
|
|
27
|
+
if (customOnSuccess) customOnSuccess(data, variables, context)
|
|
20
28
|
},
|
|
21
|
-
...
|
|
29
|
+
...restMutationOptions,
|
|
22
30
|
})
|
|
23
31
|
|
|
24
32
|
return { updateMezoId: mutate, updateMezoIdAsync: mutateAsync, ...rest }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { OrangeKitBitcoinProvider } from "@mezo-org/orangekit"
|
|
2
|
+
import { useQuery } from "@tanstack/react-query"
|
|
3
|
+
import { useMemo } from "react"
|
|
4
|
+
import { Address } from "viem"
|
|
5
|
+
import { Connector, useAccount } from "wagmi"
|
|
6
|
+
|
|
7
|
+
type UseWalletAccountReturn = {
|
|
8
|
+
accountAddress?: string | Address
|
|
9
|
+
walletAddress?: string | Address
|
|
10
|
+
isConnected: boolean
|
|
11
|
+
networkFamily: "bitcoin" | "evm"
|
|
12
|
+
connector?: Connector
|
|
13
|
+
chainId?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type OrangeKitConnector = {
|
|
17
|
+
getBitcoinProvider: () => OrangeKitBitcoinProvider
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function useWalletAccount(): UseWalletAccountReturn {
|
|
21
|
+
const { address: evmAddress, connector, chainId } = useAccount()
|
|
22
|
+
|
|
23
|
+
const networkFamily = useMemo(
|
|
24
|
+
() => (connector?.type !== "orangekit" ? "evm" : "bitcoin"),
|
|
25
|
+
[connector],
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const { data: btcData } = useQuery({
|
|
29
|
+
queryKey: [connector?.id],
|
|
30
|
+
queryFn: async () => {
|
|
31
|
+
const bitcoinProvider = (
|
|
32
|
+
connector as unknown as OrangeKitConnector
|
|
33
|
+
).getBitcoinProvider()
|
|
34
|
+
|
|
35
|
+
const address = await bitcoinProvider.getAddress()
|
|
36
|
+
const balance = await bitcoinProvider.getBalance()
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
address,
|
|
40
|
+
balance,
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const { address: btcAddress } = btcData || {}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
accountAddress: evmAddress,
|
|
49
|
+
walletAddress: btcAddress ?? evmAddress,
|
|
50
|
+
isConnected: networkFamily === "bitcoin" ? !!btcAddress : !!evmAddress,
|
|
51
|
+
networkFamily,
|
|
52
|
+
connector,
|
|
53
|
+
chainId,
|
|
54
|
+
} as const
|
|
55
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import cbbtcMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mcbBTC.json"
|
|
2
|
+
import daiMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mDAI.json"
|
|
3
|
+
import fbtcMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mFBTC.json"
|
|
4
|
+
import solvbtcMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mSolvBTC.json"
|
|
5
|
+
import swbtcMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mswBTC.json"
|
|
6
|
+
import tMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mT.json"
|
|
7
|
+
import usdcMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mUSDC.json"
|
|
8
|
+
import usdeMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mUSDe.json"
|
|
9
|
+
import usdtMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mUSDT.json"
|
|
10
|
+
import xsolvbtcMainnet from "@mezo-org/mezod-contracts/deployments/mainnet/mxSolvBTC.json"
|
|
11
|
+
|
|
12
|
+
import cbbtcTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mcbBTC.json"
|
|
13
|
+
import daiTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mDAI.json"
|
|
14
|
+
import fbtcTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mFBTC.json"
|
|
15
|
+
import solvbtcTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mSolvBTC.json"
|
|
16
|
+
import swbtcTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mswBTC.json"
|
|
17
|
+
import tTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mT.json"
|
|
18
|
+
import usdcTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mUSDC.json"
|
|
19
|
+
import usdeTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mUSDe.json"
|
|
20
|
+
import usdtTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mUSDT.json"
|
|
21
|
+
import xsolvbtcTestnet from "@mezo-org/mezod-contracts/deployments/testnet/mxSolvBTC.json"
|
|
22
|
+
|
|
23
|
+
import { Abi, Address } from "viem"
|
|
24
|
+
import { musdTestnet, musdMainnet } from "./musd"
|
|
25
|
+
|
|
26
|
+
export { default as troveManagerContract } from "./troveManager"
|
|
27
|
+
|
|
28
|
+
export type MezoChainToken =
|
|
29
|
+
| "mcbBTC"
|
|
30
|
+
| "mDAI"
|
|
31
|
+
| "mFBTC"
|
|
32
|
+
| "mSolvBTC"
|
|
33
|
+
| "mswBTC"
|
|
34
|
+
| "mT"
|
|
35
|
+
| "mUSDC"
|
|
36
|
+
| "mUSDe"
|
|
37
|
+
| "mUSDT"
|
|
38
|
+
| "mxSolvBTC"
|
|
39
|
+
| "MUSD"
|
|
40
|
+
|
|
41
|
+
type ContractsMap = Record<
|
|
42
|
+
MezoChainToken,
|
|
43
|
+
{
|
|
44
|
+
address: Address
|
|
45
|
+
abi: Abi
|
|
46
|
+
}
|
|
47
|
+
>
|
|
48
|
+
|
|
49
|
+
export const testnetContracts = {
|
|
50
|
+
mcbBTC: cbbtcTestnet,
|
|
51
|
+
mDAI: daiTestnet,
|
|
52
|
+
mFBTC: fbtcTestnet,
|
|
53
|
+
mSolvBTC: solvbtcTestnet,
|
|
54
|
+
mswBTC: swbtcTestnet,
|
|
55
|
+
mT: tTestnet,
|
|
56
|
+
mUSDC: usdcTestnet,
|
|
57
|
+
mUSDe: usdeTestnet,
|
|
58
|
+
mUSDT: usdtTestnet,
|
|
59
|
+
mxSolvBTC: xsolvbtcTestnet,
|
|
60
|
+
MUSD: musdTestnet,
|
|
61
|
+
} as unknown as ContractsMap
|
|
62
|
+
|
|
63
|
+
export const mainnetContracts = {
|
|
64
|
+
mcbBTC: cbbtcMainnet,
|
|
65
|
+
mDAI: daiMainnet,
|
|
66
|
+
mFBTC: fbtcMainnet,
|
|
67
|
+
mSolvBTC: solvbtcMainnet,
|
|
68
|
+
mswBTC: swbtcMainnet,
|
|
69
|
+
mT: tMainnet,
|
|
70
|
+
mUSDC: usdcMainnet,
|
|
71
|
+
mUSDe: usdeMainnet,
|
|
72
|
+
mUSDT: usdtMainnet,
|
|
73
|
+
mxSolvBTC: xsolvbtcMainnet,
|
|
74
|
+
MUSD: musdMainnet,
|
|
75
|
+
} as unknown as ContractsMap
|