|
1 | 1 | import { isAddress, vnlDecimals } from "@vanilladefi/core-sdk"; |
2 | 2 | import { |
3 | 3 | getBasicWalletDetails, |
4 | | - getJuiceStakingContract, |
| 4 | + getJuiceStakingContract |
5 | 5 | } from "@vanilladefi/stake-sdk"; |
6 | 6 | import { BigNumber, providers } from "ethers"; |
7 | | -import { snapshot } from "valtio"; |
| 7 | +import { parseUnits } from "ethers/lib/utils"; |
8 | 8 | import { toast } from "react-toastify"; |
| 9 | +import { retryAsync } from 'ts-retry'; |
| 10 | +import { snapshot } from "valtio"; |
9 | 11 | import { ref, state, subscribeKey, VanillaEvents } from ".."; |
10 | | -import { correctNetwork, getHexaDecimalChainId } from "../../lib/config"; |
| 12 | +import { |
| 13 | + correctNetwork, |
| 14 | + getHexaDecimalChainId |
| 15 | +} from "../../lib/config"; |
11 | 16 | import { emitEvent, formatJuice, parseJuice } from "../../utils/helpers"; |
12 | 17 | import { showDialog } from "./dialog"; |
13 | | -import { parseUnits } from "ethers/lib/utils"; |
14 | 18 |
|
15 | 19 | let lockedWalletToast: any; |
16 | 20 |
|
@@ -220,12 +224,13 @@ export const updateBalances = async () => { |
220 | 224 | const contractAddress = isAddress( |
221 | 225 | process.env.NEXT_PUBLIC_VANILLA_ROUTER_ADDRESS || "" |
222 | 226 | ); |
223 | | - let { vnlBalance, ethBalance, maticBalance, juiceBalance } = |
224 | | - await getBasicWalletDetails(walletAddress, { |
| 227 | + let { vnlBalance, ethBalance, maticBalance, juiceBalance } = await retryAsync( |
| 228 | + async () => await getBasicWalletDetails(walletAddress, { |
225 | 229 | polygonProvider: polygonProvider || undefined, |
226 | 230 | ethereumProvider: ethereumProvider || undefined, |
227 | 231 | optionalAddress: contractAddress || undefined, |
228 | | - }); |
| 232 | + }) |
| 233 | + ); |
229 | 234 |
|
230 | 235 | state.balances.vnl = Number(vnlBalance).toLocaleString(); |
231 | 236 | state.balances.eth = Number(ethBalance).toLocaleString(); |
|
0 commit comments