@mezo-org/passport 0.4.0-dev.81 → 0.4.0-dev.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/auth.d.ts +1 -1
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Content.d.ts +0 -15
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Content.js +3 -3
- package/dist/src/components/Dropdown/Content.js.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.d.ts +0 -4
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.js +10 -33
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/src/components/Dropdown/ListingItem.d.ts +8 -7
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -1
- package/dist/src/components/Dropdown/ListingItem.js +36 -28
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -1
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +2 -1
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -1
- package/dist/src/components/Dropdown/NestedViewLayout.js +13 -15
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -1
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +1 -4
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Receive/Receive.js +36 -19
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +2 -5
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +28 -12
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +2 -4
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountBalance.js +24 -8
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js +27 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
- package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +2 -3
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +34 -39
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -1
- package/dist/src/components/Dropdown/Root/Root.d.ts +0 -15
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/Root.js +22 -34
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -1
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +2 -6
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/WalletAddress.js +43 -34
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -1
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +2 -4
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +60 -16
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -1
- package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
- package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
- package/dist/src/components/Dropdown/SlotNumber.js +67 -0
- package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
- package/dist/src/config.d.ts +1 -11
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +3 -40
- package/dist/src/config.js.map +1 -1
- package/dist/src/constants.d.ts +0 -2
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +0 -2
- package/dist/src/constants.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +8 -13
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.js +44 -67
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/hooks/useBorrowData.d.ts +31 -5
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -1
- package/dist/src/hooks/useBorrowData.js +53 -11
- package/dist/src/hooks/useBorrowData.js.map +1 -1
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +3 -3
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts +2 -2
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +4 -6
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +3 -3
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/useTokensBalances.d.ts +36 -35
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -1
- package/dist/src/hooks/useTokensBalances.js +93 -52
- package/dist/src/hooks/useTokensBalances.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +8 -10
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +22 -19
- package/dist/src/hooks/useWalletAccount.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/contracts/index.d.ts +1 -1
- package/dist/src/lib/contracts/index.d.ts.map +1 -1
- package/dist/src/lib/contracts/index.js +4 -0
- package/dist/src/lib/contracts/index.js.map +1 -1
- package/dist/src/provider.d.ts +7 -1
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +4 -1
- package/dist/src/provider.js.map +1 -1
- package/dist/src/utils/assets.d.ts +145 -0
- package/dist/src/utils/assets.d.ts.map +1 -0
- package/dist/src/utils/assets.js +100 -0
- package/dist/src/utils/assets.js.map +1 -0
- package/dist/src/utils/assets.test.d.ts +2 -0
- package/dist/src/utils/assets.test.d.ts.map +1 -0
- package/dist/src/utils/assets.test.js +46 -0
- package/dist/src/utils/assets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +6 -3
- package/dist/src/utils/currency.d.ts.map +1 -1
- package/dist/src/utils/currency.js +13 -10
- package/dist/src/utils/currency.js.map +1 -1
- package/dist/src/utils/currency.test.js +44 -2
- package/dist/src/utils/currency.test.js.map +1 -1
- package/dist/src/utils/numbers.d.ts +13 -53
- package/dist/src/utils/numbers.d.ts.map +1 -1
- package/dist/src/utils/numbers.js +16 -118
- package/dist/src/utils/numbers.js.map +1 -1
- package/dist/src/utils/numbers.test.js +24 -142
- package/dist/src/utils/numbers.test.js.map +1 -1
- package/package.json +2 -1
- package/src/api/auth.ts +1 -1
- package/src/components/Dropdown/Content.tsx +3 -48
- package/src/components/Dropdown/Dropdown.tsx +7 -55
- package/src/components/Dropdown/ListingItem.tsx +155 -59
- package/src/components/Dropdown/NestedViewLayout.tsx +32 -20
- package/src/components/Dropdown/Receive/Receive.tsx +69 -32
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +64 -35
- package/src/components/Dropdown/Root/AccountBalance.tsx +54 -16
- package/src/components/Dropdown/Root/AccountBtcListing.tsx +52 -0
- package/src/components/Dropdown/Root/AccountError.tsx +34 -0
- package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +63 -46
- package/src/components/Dropdown/Root/Root.tsx +28 -98
- package/src/components/Dropdown/Root/WalletAddress.tsx +95 -89
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +109 -29
- package/src/components/Dropdown/SlotNumber.tsx +131 -0
- package/src/config.ts +3 -59
- package/src/constants.ts +0 -6
- package/src/hooks/useAssetsConversionRates.ts +49 -67
- package/src/hooks/useAuthenticateWithWallet.ts +7 -5
- package/src/hooks/useBorrowData.ts +71 -12
- package/src/hooks/useCreateAccount.ts +5 -4
- package/src/hooks/useGetCurrentAccount.ts +5 -7
- package/src/hooks/useLinkAccount.ts +5 -4
- package/src/hooks/useTokensBalances.ts +152 -74
- package/src/hooks/useWalletAccount.ts +27 -36
- package/src/index.ts +0 -1
- package/src/lib/contracts/index.ts +8 -1
- package/src/provider.ts +11 -3
- package/src/utils/assets.test.ts +57 -0
- package/src/utils/assets.ts +103 -0
- package/src/utils/currency.test.ts +76 -2
- package/src/utils/currency.ts +20 -15
- package/src/utils/numbers.test.ts +29 -180
- package/src/utils/numbers.ts +22 -171
- 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/hooks/useDropdownData.d.ts +0 -47
- package/dist/src/hooks/useDropdownData.d.ts.map +0 -1
- package/dist/src/hooks/useDropdownData.js +0 -97
- package/dist/src/hooks/useDropdownData.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 -129
- 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/src/components/Dropdown/Root/AccountAssetItem.tsx +0 -26
- package/src/hooks/useDropdownData.ts +0 -152
- package/src/utils/cryptoAssets.test.ts +0 -79
- package/src/utils/cryptoAssets.ts +0 -171
|
@@ -41,7 +41,7 @@ export declare function useBorrowData(queryOptions?: {}): import("wagmi").UseRea
|
|
|
41
41
|
}];
|
|
42
42
|
readonly address: `0x${string}`;
|
|
43
43
|
readonly functionName: "getEntireDebtAndColl";
|
|
44
|
-
readonly args: [`0x${string}`];
|
|
44
|
+
readonly args: [`0x${string}`] | undefined;
|
|
45
45
|
readonly chainId: number;
|
|
46
46
|
}, {
|
|
47
47
|
readonly abi: readonly [{
|
|
@@ -57,12 +57,38 @@ export declare function useBorrowData(queryOptions?: {}): import("wagmi").UseRea
|
|
|
57
57
|
}];
|
|
58
58
|
readonly address: `0x${string}`;
|
|
59
59
|
readonly functionName: "MUSD_GAS_COMPENSATION";
|
|
60
|
-
readonly
|
|
60
|
+
readonly chainId: number;
|
|
61
|
+
}, {
|
|
62
|
+
readonly abi: readonly [{
|
|
63
|
+
readonly inputs: readonly [];
|
|
64
|
+
readonly name: "fetchPrice";
|
|
65
|
+
readonly outputs: readonly [{
|
|
66
|
+
readonly internalType: "uint256";
|
|
67
|
+
readonly name: "";
|
|
68
|
+
readonly type: "uint256";
|
|
69
|
+
}];
|
|
70
|
+
readonly stateMutability: "view";
|
|
71
|
+
readonly type: "function";
|
|
72
|
+
}];
|
|
73
|
+
readonly address: `0x${string}`;
|
|
74
|
+
readonly functionName: "fetchPrice";
|
|
61
75
|
readonly chainId: number;
|
|
62
76
|
}], true, {
|
|
63
|
-
collateral:
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
collateral: {
|
|
78
|
+
value: bigint;
|
|
79
|
+
decimals: number;
|
|
80
|
+
symbol: string;
|
|
81
|
+
formatted: string;
|
|
82
|
+
usd: {
|
|
83
|
+
value: bigint;
|
|
84
|
+
formatted: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
debtInUsd: {
|
|
88
|
+
value: bigint;
|
|
89
|
+
formatted: string;
|
|
90
|
+
};
|
|
91
|
+
}>;
|
|
66
92
|
/**
|
|
67
93
|
* Hook for for invalidating current user's borrow data. Can be used to
|
|
68
94
|
* invalidate borrow data manually, which forces the data to be re-fetched.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBorrowData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBorrowData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"AAuGA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,YAAY,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiG9C;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB;;EAatC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB;;EAajC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useReadContracts } from "wagmi";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
3
|
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { formatUnits } from "viem";
|
|
4
5
|
import { ONE_MINUTE_MS } from "../utils/time";
|
|
5
6
|
import { mainnetBorrowContracts, testnetBorrowContracts, } from "../lib/contracts";
|
|
6
7
|
import { usePassportContext } from "./usePassportContext";
|
|
7
8
|
import { CHAIN_ID } from "../constants";
|
|
8
|
-
import { bigIntMax } from "../utils/numbers";
|
|
9
|
+
import { bigIntMax, normalizePrecision } from "../utils/numbers";
|
|
10
|
+
import useWalletAccount from "./useWalletAccount";
|
|
11
|
+
import { getAsset } from "../utils/assets";
|
|
12
|
+
import { convertToUsd } from "../utils/currency";
|
|
13
|
+
const DEBT_AND_COLL_PRECISION = 18;
|
|
9
14
|
// Wagmi handles typesafety with ABI const assertions. TypeScript doesn't
|
|
10
15
|
// support importing JSON as const yet so types cannot be inferred from the
|
|
11
16
|
// imported contract. As a workaround there is minimal ABI definition that can
|
|
@@ -72,6 +77,21 @@ const BORROWER_OPERATIONS_ABI = [
|
|
|
72
77
|
type: "function",
|
|
73
78
|
},
|
|
74
79
|
];
|
|
80
|
+
const PRICE_FEED_ABI = [
|
|
81
|
+
{
|
|
82
|
+
inputs: [],
|
|
83
|
+
name: "fetchPrice",
|
|
84
|
+
outputs: [
|
|
85
|
+
{
|
|
86
|
+
internalType: "uint256",
|
|
87
|
+
name: "",
|
|
88
|
+
type: "uint256",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
stateMutability: "view",
|
|
92
|
+
type: "function",
|
|
93
|
+
},
|
|
94
|
+
];
|
|
75
95
|
/**
|
|
76
96
|
* Query hook for getting borrow data. Returns collateral and trove debt for the
|
|
77
97
|
* connected account, based on it's evm address.
|
|
@@ -79,17 +99,19 @@ const BORROWER_OPERATIONS_ABI = [
|
|
|
79
99
|
*/
|
|
80
100
|
export function useBorrowData(queryOptions = {}) {
|
|
81
101
|
const { environment = "mainnet" } = usePassportContext();
|
|
82
|
-
const {
|
|
102
|
+
const { data: walletAccountData } = useWalletAccount();
|
|
83
103
|
const contractAddress = useMemo(() => {
|
|
84
104
|
if (environment === "mainnet") {
|
|
85
105
|
return {
|
|
86
106
|
troveManager: mainnetBorrowContracts.TroveManager.address,
|
|
87
107
|
borrowerOperations: mainnetBorrowContracts.BorrowerOperations.address,
|
|
108
|
+
priceFeed: mainnetBorrowContracts.PriceFeed.address,
|
|
88
109
|
};
|
|
89
110
|
}
|
|
90
111
|
return {
|
|
91
112
|
troveManager: testnetBorrowContracts.TroveManager.address,
|
|
92
113
|
borrowerOperations: testnetBorrowContracts.BorrowerOperations.address,
|
|
114
|
+
priceFeed: testnetBorrowContracts.PriceFeed.address,
|
|
93
115
|
};
|
|
94
116
|
}, [environment]);
|
|
95
117
|
const chainId = CHAIN_ID[environment];
|
|
@@ -99,31 +121,51 @@ export function useBorrowData(queryOptions = {}) {
|
|
|
99
121
|
abi: TROVE_MANAGER_ABI,
|
|
100
122
|
address: contractAddress.troveManager,
|
|
101
123
|
functionName: "getEntireDebtAndColl",
|
|
102
|
-
args:
|
|
124
|
+
args: walletAccountData
|
|
125
|
+
? [walletAccountData.accountAddress]
|
|
126
|
+
: undefined,
|
|
103
127
|
chainId,
|
|
104
128
|
},
|
|
105
129
|
{
|
|
106
130
|
abi: BORROWER_OPERATIONS_ABI,
|
|
107
131
|
address: contractAddress.borrowerOperations,
|
|
108
132
|
functionName: "MUSD_GAS_COMPENSATION",
|
|
109
|
-
|
|
133
|
+
chainId,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
abi: PRICE_FEED_ABI,
|
|
137
|
+
address: contractAddress.priceFeed,
|
|
138
|
+
functionName: "fetchPrice",
|
|
110
139
|
chainId,
|
|
111
140
|
},
|
|
112
141
|
],
|
|
113
142
|
query: {
|
|
114
|
-
enabled: !!
|
|
143
|
+
enabled: !!walletAccountData,
|
|
115
144
|
staleTime: 5 * ONE_MINUTE_MS,
|
|
116
145
|
retry: 1,
|
|
117
146
|
select: (data) => {
|
|
118
147
|
if (!data || data.some((item) => !item.result))
|
|
119
|
-
|
|
120
|
-
const [
|
|
148
|
+
throw new Error("No borrow data available");
|
|
149
|
+
const [rawCollateral, principal, interest] = data[0].result;
|
|
121
150
|
const gasCompensation = data[1].result;
|
|
122
|
-
const
|
|
151
|
+
const collateralPrice = data[2].result;
|
|
152
|
+
const btcDetails = getAsset("BTC");
|
|
153
|
+
const collateral = {
|
|
154
|
+
value: rawCollateral,
|
|
155
|
+
decimals: btcDetails.decimals,
|
|
156
|
+
symbol: btcDetails.symbol,
|
|
157
|
+
formatted: formatUnits(rawCollateral, DEBT_AND_COLL_PRECISION),
|
|
158
|
+
usd: convertToUsd(rawCollateral, DEBT_AND_COLL_PRECISION, collateralPrice, DEBT_AND_COLL_PRECISION),
|
|
159
|
+
};
|
|
160
|
+
const debtInUsdValue = bigIntMax(normalizePrecision(principal + interest - gasCompensation, DEBT_AND_COLL_PRECISION), 0n);
|
|
161
|
+
const formattedDebtInUsd = formatUnits(debtInUsdValue, DEBT_AND_COLL_PRECISION);
|
|
162
|
+
const debtInUsd = {
|
|
163
|
+
value: debtInUsdValue,
|
|
164
|
+
formatted: formattedDebtInUsd,
|
|
165
|
+
};
|
|
123
166
|
return {
|
|
124
167
|
collateral,
|
|
125
|
-
|
|
126
|
-
troveDebt,
|
|
168
|
+
debtInUsd,
|
|
127
169
|
};
|
|
128
170
|
},
|
|
129
171
|
...queryOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBorrowData.js","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useBorrowData.js","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,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,CAAC,EAAE,QAAQ,EAAE,CAAC,EAC5C,CAAC,WAAW,EAAE,QAAQ,CAAC,CACxB,CAAA;IAED,OAAO;QACL,eAAe,EAAE,sBAAsB;KACxC,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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;AAIzE,wBAAgB,gBAAgB,CAC9B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,CAAC,EAC1E,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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;AAIzE,wBAAgB,gBAAgB,CAC9B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,CAAC,EAC1E,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8CP"}
|
|
@@ -6,15 +6,15 @@ import { getBitcoinPublicKeyFromConnector } from "../utils/wagmi";
|
|
|
6
6
|
export function useCreateAccount(mutationOptions = {}) {
|
|
7
7
|
const queryClient = useQueryClient();
|
|
8
8
|
const authApiClient = useAuthApiClient();
|
|
9
|
-
const
|
|
9
|
+
const walletAccount = useWalletAccount();
|
|
10
10
|
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
11
11
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
12
12
|
mutationFn: async (createAccountMutationFnParameters) => {
|
|
13
13
|
if (createAccountMutationFnParameters.type === "wallet") {
|
|
14
|
-
if (!connector) {
|
|
14
|
+
if (!walletAccount.data?.connector) {
|
|
15
15
|
throw new Error("Connector not defined.");
|
|
16
16
|
}
|
|
17
|
-
const bitcoinPublicKey = await getBitcoinPublicKeyFromConnector(connector);
|
|
17
|
+
const bitcoinPublicKey = await getBitcoinPublicKeyFromConnector(walletAccount.data.connector);
|
|
18
18
|
// Creating bitcoin mezo account
|
|
19
19
|
if (bitcoinPublicKey) {
|
|
20
20
|
return authApiClient.createAccount({
|
|
@@ -1 +1 @@
|
|
|
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;AAExC,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAA;AAEjE,MAAM,UAAU,gBAAgB,CAC9B,kBAGI,EAAE;IAEN,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,
|
|
1
|
+
{"version":3,"file":"useCreateAccount.js","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,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AAO,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"}
|
|
@@ -5,11 +5,11 @@ type GetCurrentAccountResponseWithMats = GetCurrentAccountResponse & {
|
|
|
5
5
|
totalMats: number;
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
|
-
export declare function useGetCurrentAccount(queryOptions?: Omit<UseBaseQueryOptions<GetCurrentAccountResponseWithMats>, "queryKey" | "queryFn">): import("@tanstack/react-query").UseQueryResult<
|
|
8
|
+
export declare function useGetCurrentAccount(queryOptions?: Omit<UseBaseQueryOptions<GetCurrentAccountResponseWithMats>, "queryKey" | "queryFn">): import("@tanstack/react-query").UseQueryResult<{
|
|
9
9
|
mezoId: string;
|
|
10
10
|
hasModifiedMezoId: boolean;
|
|
11
11
|
linkedAccounts: import("../api").LinkedAccount[];
|
|
12
|
-
}
|
|
12
|
+
} & {
|
|
13
13
|
mats: {
|
|
14
14
|
totalMats: number;
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetCurrentAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useGetCurrentAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,uBAAuB,CAAA;AAKrE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAA;AAEvD,KAAK,iCAAiC,GAAG,yBAAyB,GAAG;IACnE,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF,CAAA;AAED,wBAAgB,oBAAoB,CAClC,YAAY,GAAE,IAAI,CAChB,mBAAmB,CAAC,iCAAiC,CAAC,EACtD,UAAU,GAAG,SAAS,CAClB;;;;;UATA;QACJ,SAAS,EAAE,MAAM,CAAA;KAClB;
|
|
1
|
+
{"version":3,"file":"useGetCurrentAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useGetCurrentAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,uBAAuB,CAAA;AAKrE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAA;AAEvD,KAAK,iCAAiC,GAAG,yBAAyB,GAAG;IACnE,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF,CAAA;AAED,wBAAgB,oBAAoB,CAClC,YAAY,GAAE,IAAI,CAChB,mBAAmB,CAAC,iCAAiC,CAAC,EACtD,UAAU,GAAG,SAAS,CAClB;;;;;UATA;QACJ,SAAS,EAAE,MAAM,CAAA;KAClB;UAiDF"}
|
|
@@ -10,14 +10,12 @@ export function useGetCurrentAccount(queryOptions = {}) {
|
|
|
10
10
|
queryKey: [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT],
|
|
11
11
|
queryFn: async () => {
|
|
12
12
|
const currentAccount = await authApiClient.getCurrentAccount();
|
|
13
|
+
if (!currentAccount) {
|
|
14
|
+
throw new Error("No current account found");
|
|
15
|
+
}
|
|
13
16
|
const linkedWallets = currentAccount?.linkedAccounts?.filter((account) => account.type === "wallet");
|
|
14
17
|
if (!linkedWallets || linkedWallets.length === 0) {
|
|
15
|
-
|
|
16
|
-
...currentAccount,
|
|
17
|
-
mats: {
|
|
18
|
-
totalMats: 0,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
18
|
+
throw new Error("No linked wallets found for the current account");
|
|
21
19
|
}
|
|
22
20
|
const addresses = linkedWallets.map((account) => account.btcAddress || account.evmAddress);
|
|
23
21
|
const mats = await Promise.all(addresses.map((address) => portalApiClient.getPortalMats(address)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetCurrentAccount.js","sourceRoot":"","sources":["../../../src/hooks/useGetCurrentAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AASzD,MAAM,UAAU,oBAAoB,CAClC,eAGI,EAAE;IAEN,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAA;IAE5C,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;QAClD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,iBAAiB,EAAE,CAAA;YAC9D,MAAM,aAAa,GAAG,cAAc,EAAE,cAAc,EAAE,MAAM,CAC1D,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,CACvC,CAAA;YACD,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACjD,
|
|
1
|
+
{"version":3,"file":"useGetCurrentAccount.js","sourceRoot":"","sources":["../../../src/hooks/useGetCurrentAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAg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BACL,GAAG,cAAc;gBACjB,IAAI,EAAE;oBACJ,SAAS;iBACV;aACF,CAAA;QACH,CAAC;QACD,SAAS,EAAE,aAAa;QACxB,KAAK,EAAE,CAAC;QACR,GAAG,YAAY;KAChB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCP"}
|
|
@@ -6,15 +6,15 @@ import { getBitcoinPublicKeyFromConnector } from "../utils/wagmi";
|
|
|
6
6
|
export function useLinkAccount(mutationOptions = {}) {
|
|
7
7
|
const queryClient = useQueryClient();
|
|
8
8
|
const authApiClient = useAuthApiClient();
|
|
9
|
-
const
|
|
9
|
+
const walletAccount = useWalletAccount();
|
|
10
10
|
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
11
11
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
12
12
|
mutationFn: async (linkAccountMutationFnParameters) => {
|
|
13
13
|
if (linkAccountMutationFnParameters.type === "wallet") {
|
|
14
|
-
if (!connector) {
|
|
14
|
+
if (!walletAccount.data?.connector) {
|
|
15
15
|
throw new Error("Connector not defined.");
|
|
16
16
|
}
|
|
17
|
-
const bitcoinPublicKey = await getBitcoinPublicKeyFromConnector(connector);
|
|
17
|
+
const bitcoinPublicKey = await getBitcoinPublicKeyFromConnector(walletAccount.data.connector);
|
|
18
18
|
// Linking bitcoin account
|
|
19
19
|
if (bitcoinPublicKey) {
|
|
20
20
|
return authApiClient.linkAccount({
|
|
@@ -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;AACxC,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAA;AAMjE,MAAM,UAAU,cAAc,CAC5B,kBAOI,EAAE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gB;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"}
|
|
@@ -1,7 +1,33 @@
|
|
|
1
|
+
import { UseQueryOptions } from "@tanstack/react-query";
|
|
1
2
|
import { MezoChainToken } from "../lib/contracts";
|
|
2
|
-
|
|
3
|
+
export declare const BALANCE_OF_ABI: readonly [{
|
|
4
|
+
readonly inputs: readonly [{
|
|
5
|
+
readonly internalType: "address";
|
|
6
|
+
readonly name: "account";
|
|
7
|
+
readonly type: "address";
|
|
8
|
+
}];
|
|
9
|
+
readonly name: "balanceOf";
|
|
10
|
+
readonly outputs: readonly [{
|
|
11
|
+
readonly internalType: "uint256";
|
|
12
|
+
readonly name: "";
|
|
13
|
+
readonly type: "uint256";
|
|
14
|
+
}];
|
|
15
|
+
readonly stateMutability: "view";
|
|
16
|
+
readonly type: "function";
|
|
17
|
+
}];
|
|
18
|
+
type UseMezoChainTokensBalancesOptions<T extends MezoChainToken[]> = {
|
|
3
19
|
tokens?: T;
|
|
4
|
-
queryOptions?:
|
|
20
|
+
queryOptions?: Omit<UseQueryOptions<Record<T[number], TokenBalance>>, "queryKey" | "queryFn" | "select" | "enabled">;
|
|
21
|
+
};
|
|
22
|
+
export type TokenBalance = {
|
|
23
|
+
decimals: number;
|
|
24
|
+
formatted: string;
|
|
25
|
+
symbol: string;
|
|
26
|
+
value: bigint;
|
|
27
|
+
usd: {
|
|
28
|
+
value: bigint;
|
|
29
|
+
formatted: string;
|
|
30
|
+
};
|
|
5
31
|
};
|
|
6
32
|
/**
|
|
7
33
|
* Hook to get the balance of a list of tokens for the current account
|
|
@@ -12,62 +38,37 @@ type UseMezoChainTokensBalancesOptions<T> = {
|
|
|
12
38
|
* @returns Tanstack's `useQuery` returnings with balance of tokens for the
|
|
13
39
|
* current account in form of typesafe object with token names as keys
|
|
14
40
|
* 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
41
|
* @example
|
|
18
42
|
* const mezoTokensBalance = useTokensBalances({
|
|
19
43
|
* tokens: ["mT", "mxSolvBTC"],
|
|
20
44
|
* })
|
|
21
|
-
*
|
|
22
|
-
* console.log(
|
|
45
|
+
* // Assuming the status is "success"
|
|
46
|
+
* console.log(mezoTokensBalance.data.mT) // Eg. { value: 0n ... }
|
|
47
|
+
* console.log(Object.keys(mezoTokensBalance.data)) // ["mT", "mxSolvBTC"]
|
|
23
48
|
*/
|
|
24
|
-
export declare function useTokensBalances<T extends MezoChainToken[]>(options?: UseMezoChainTokensBalancesOptions<T>): import("
|
|
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>>;
|
|
49
|
+
export declare function useTokensBalances<T extends MezoChainToken[]>(options?: UseMezoChainTokensBalancesOptions<T>): import("@tanstack/react-query").UseQueryResult<Record<"BTC" | T[number], TokenBalance>, Error>;
|
|
45
50
|
/**
|
|
46
51
|
* Hook for invalidating current user's token balances. Can be used to
|
|
47
52
|
* 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
53
|
* @returns Function `invalidateTokenBalances` that invalidates token balances
|
|
51
54
|
* @example
|
|
52
|
-
* const { invalidateTokenBalances } = useInvalidateTokensBalances(
|
|
55
|
+
* const { invalidateTokenBalances } = useInvalidateTokensBalances()
|
|
53
56
|
* (...)
|
|
54
57
|
* await invalidateTokenBalances()
|
|
55
58
|
*/
|
|
56
|
-
export declare function useInvalidateTokensBalances(
|
|
59
|
+
export declare function useInvalidateTokensBalances(): {
|
|
57
60
|
invalidateTokensBalances: () => Promise<void>;
|
|
58
61
|
};
|
|
59
62
|
/**
|
|
60
63
|
* Hook for resetting current user's token balances. Can be used to reset the
|
|
61
64
|
* 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
65
|
* @returns Function `resetTokenBalances` that invalidates token balances
|
|
65
66
|
* @example
|
|
66
|
-
* const { resetTokenBalances } = useResetTokensBalances(
|
|
67
|
+
* const { resetTokenBalances } = useResetTokensBalances()
|
|
67
68
|
* (...)
|
|
68
69
|
* await resetTokenBalances()
|
|
69
70
|
*/
|
|
70
|
-
export declare function useResetTokensBalances(
|
|
71
|
+
export declare function useResetTokensBalances(): {
|
|
71
72
|
resetTokenBalances: () => Promise<void>;
|
|
72
73
|
};
|
|
73
74
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTokensBalances.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTokensBalances.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTokensBalances.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTokensBalances.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,eAAe,EAChB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAEL,cAAc,EAEf,MAAM,kBAAkB,CAAA;AAkBzB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;EAoBH,CAAA;AAgBxB,KAAK,iCAAiC,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI;IACnE,MAAM,CAAC,EAAE,CAAC,CAAA;IACV,YAAY,CAAC,EAAE,IAAI,CACjB,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,EAChD,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAC9C,CAAA;CACF,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE;QACH,KAAK,EAAE,MAAM,CAAA;QACb,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF,CAAA;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAAE,EAC1D,OAAO,GAAE,iCAAiC,CAAC,CAAC,CAAM,kGAuHnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B;;EAS1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB;;EASrC"}
|