@orderly.network/hooks 1.0.10 → 1.0.12

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.mjs CHANGED
@@ -5,7 +5,7 @@ import React, { createContext, useContext, useState, useEffect, useCallback, use
5
5
  import useSWRMutation from 'swr/mutation';
6
6
  import useConstant4 from 'use-constant';
7
7
  export { default as useConstant } from 'use-constant';
8
- import { SimpleDI, Account, EventEmitter, MemoryConfigStore, LocalStorageStore, EtherAdapter, utils } from '@orderly.network/core';
8
+ import { SimpleDI, Account, EventEmitter, DefaultConfigStore, LocalStorageStore, EtherAdapter, utils } from '@orderly.network/core';
9
9
  import { AccountStatusEnum, OrderStatus, OrderSide, chainsInfoMap, ARBITRUM_TESTNET_CHAINID, ARBITRUM_MAINNET_CHAINID, WS_WalletStatusEnum, OrderType } from '@orderly.network/types';
10
10
  import useSWRInfinite from 'swr/infinite';
11
11
  import { Decimal, zero, getPrecisionByNumber, timeConvertString } from '@orderly.network/utils';
@@ -433,7 +433,7 @@ var OrderlyConfigProvider = (props) => {
433
433
  console.error("[OrderlyConfigProvider]: brokerId is required");
434
434
  }
435
435
  const innerConfigStore = useConstant4(() => {
436
- return configStore || new MemoryConfigStore({ brokerId });
436
+ return configStore || new DefaultConfigStore({ brokerId, networkId });
437
437
  });
438
438
  const innerKeyStore = useConstant4(() => {
439
439
  return keyStore || new LocalStorageStore(networkId);
@@ -3147,7 +3147,8 @@ var useChains = (networkId, options = {}) => {
3147
3147
  }
3148
3148
  );
3149
3149
  const { data: orderlyChains, error: tokenError } = useQuery(
3150
- "/v1/public/token",
3150
+ // wooSwapEnabled ? "/v1/public/token" :
3151
+ "https://api-evm.orderly.org/v1/public/token",
3151
3152
  {
3152
3153
  revalidateIfStale: false,
3153
3154
  revalidateOnFocus: false,
@@ -3381,6 +3382,7 @@ var useWithdraw = () => {
3381
3382
  };
3382
3383
  var useDeposit = (options) => {
3383
3384
  const { onlyTestnet, enableSwapDeposit } = useContext(OrderlyContext);
3385
+ const networkId = useConfig("networkId");
3384
3386
  const [balanceRevalidating, setBalanceRevalidating] = useState(false);
3385
3387
  const [allowanceRevalidating, setAllowanceRevalidating] = useState(false);
3386
3388
  const [_, { findByChainId }] = useChains(void 0, {
@@ -3392,8 +3394,10 @@ var useDeposit = (options) => {
3392
3394
  const prevAddress = useRef();
3393
3395
  const getBalanceListener = useRef();
3394
3396
  const dst = useMemo(() => {
3395
- const chain = onlyTestnet || 421613 == options?.srcChainId ? findByChainId(ARBITRUM_TESTNET_CHAINID) : findByChainId(ARBITRUM_MAINNET_CHAINID);
3396
- const USDC = chain?.token_infos.find((token) => token.symbol === "USDC");
3397
+ const chain = networkId === "testnet" ? findByChainId(ARBITRUM_TESTNET_CHAINID) : findByChainId(ARBITRUM_MAINNET_CHAINID);
3398
+ const USDC = chain?.token_infos.find(
3399
+ (token) => token.symbol === "USDC"
3400
+ );
3397
3401
  if (!chain) {
3398
3402
  throw new Error("dst chain not found");
3399
3403
  }
@@ -3405,7 +3409,7 @@ var useDeposit = (options) => {
3405
3409
  network: chain.network_infos.shortName
3406
3410
  // chainId: 42161,
3407
3411
  };
3408
- }, []);
3412
+ }, [networkId]);
3409
3413
  const isNativeToken = useMemo(
3410
3414
  () => isNativeTokenChecker(options?.address || ""),
3411
3415
  [options?.address]