@orderly.network/hooks 1.0.16 → 1.0.18

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/index.js CHANGED
@@ -3370,7 +3370,7 @@ var useWithdraw = () => {
3370
3370
  return { withdraw, isLoading, maxAmount, availableBalance, unsettledPnL };
3371
3371
  };
3372
3372
  var useDeposit = (options) => {
3373
- const { onlyTestnet, enableSwapDeposit } = React.useContext(OrderlyContext);
3373
+ const { enableSwapDeposit } = React.useContext(OrderlyContext);
3374
3374
  const networkId = useConfig("networkId");
3375
3375
  const [balanceRevalidating, setBalanceRevalidating] = React.useState(false);
3376
3376
  const [allowanceRevalidating, setAllowanceRevalidating] = React.useState(false);
@@ -3422,19 +3422,14 @@ var useDeposit = (options) => {
3422
3422
  if (!address)
3423
3423
  return;
3424
3424
  try {
3425
- if (balanceRevalidating)
3426
- return;
3427
- setBalanceRevalidating(true);
3428
3425
  const balance2 = await fetchBalanceHandler(address, decimals);
3429
3426
  setBalance(() => balance2);
3430
- setBalanceRevalidating(false);
3431
3427
  } catch (e) {
3432
3428
  console.warn("----- refresh balance error -----", e);
3433
- setBalanceRevalidating(false);
3434
3429
  setBalance(() => "0");
3435
3430
  }
3436
3431
  },
3437
- [state, balanceRevalidating]
3432
+ [state]
3438
3433
  );
3439
3434
  const fetchBalances = React.useCallback(async (tokens) => {
3440
3435
  const tasks = [];
@@ -3483,7 +3478,10 @@ var useDeposit = (options) => {
3483
3478
  React.useEffect(() => {
3484
3479
  if (state.status < types.AccountStatusEnum.Connected)
3485
3480
  return;
3486
- fetchBalance(options?.address, options?.decimals);
3481
+ setBalanceRevalidating(true);
3482
+ fetchBalance(options?.address, options?.decimals).finally(() => {
3483
+ setBalanceRevalidating(false);
3484
+ });
3487
3485
  if (dst.chainId !== options?.srcChainId) {
3488
3486
  getAllowance(options?.address, options?.crossChainRouteAddress);
3489
3487
  } else {
@@ -3501,7 +3499,8 @@ var useDeposit = (options) => {
3501
3499
  options?.srcChainId,
3502
3500
  options?.srcToken,
3503
3501
  account5.address,
3504
- dst
3502
+ dst.chainId,
3503
+ dst.symbol
3505
3504
  ]);
3506
3505
  const approve = React.useCallback(
3507
3506
  (amount) => {