@orderly.network/hooks 1.0.13 → 1.0.14

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
@@ -277,9 +277,12 @@ var useBoolean = (initialValue = false) => {
277
277
  };
278
278
  var usePreLoadData = () => {
279
279
  useContext(OrderlyContext);
280
- const { error: tokenError, data: tokenData } = useQuery("/v1/public/token", {
281
- revalidateOnFocus: false
282
- });
280
+ const { error: tokenError, data: tokenData } = useQuery(
281
+ "https://api-evm.orderly.org/v1/public/token",
282
+ {
283
+ revalidateOnFocus: false
284
+ }
285
+ );
283
286
  const isDone = useMemo(() => {
284
287
  return !!tokenData;
285
288
  }, [tokenData]);
@@ -428,7 +431,14 @@ var useWS = () => {
428
431
  };
429
432
  var OrderlyConfigProvider = (props) => {
430
433
  const [account5, setAccount] = React.useState(null);
431
- const { configStore, keyStore, getWalletAdapter, brokerId, networkId, enableSwapDeposit } = props;
434
+ const {
435
+ configStore,
436
+ keyStore,
437
+ getWalletAdapter,
438
+ brokerId,
439
+ networkId,
440
+ enableSwapDeposit
441
+ } = props;
432
442
  if (!brokerId && typeof configStore === "undefined") {
433
443
  console.error("[OrderlyConfigProvider]: brokerId is required");
434
444
  }
@@ -1965,7 +1975,6 @@ var useLeverage = () => {
1965
1975
  const { data: config } = useQuery("/v1/public/config");
1966
1976
  const updateLeverage = useCallback((data2) => {
1967
1977
  return update(data2).then((res) => {
1968
- console.log(res);
1969
1978
  if (res.success) {
1970
1979
  return mutate2();
1971
1980
  } else {
@@ -3147,7 +3156,7 @@ var useChains = (networkId, options = {}) => {
3147
3156
  }
3148
3157
  );
3149
3158
  const { data: orderlyChains, error: tokenError } = useQuery(
3150
- // wooSwapEnabled ? "/v1/public/token" :
3159
+ // wooSwapEnabled ? "/v1/public/token" :
3151
3160
  "https://api-evm.orderly.org/v1/public/token",
3152
3161
  {
3153
3162
  revalidateIfStale: false,
@@ -3158,11 +3167,9 @@ var useChains = (networkId, options = {}) => {
3158
3167
  }
3159
3168
  );
3160
3169
  const chains = useMemo(() => {
3161
- if (!orderlyChains)
3162
- return void 0;
3163
3170
  let orderlyChainsArr = [];
3164
3171
  const orderlyChainIds = /* @__PURE__ */ new Set();
3165
- orderlyChains.forEach((item) => {
3172
+ orderlyChains?.forEach((item) => {
3166
3173
  item.chain_details.forEach((chain) => {
3167
3174
  const chainId = Number(chain.chain_id);
3168
3175
  orderlyChainIds.add(chainId);
@@ -3188,7 +3195,9 @@ var useChains = (networkId, options = {}) => {
3188
3195
  return;
3189
3196
  }
3190
3197
  if (_chain.chain_id === 421613) {
3191
- const index = testnetArr.findIndex((item2) => item2.network_infos.chain_id === 421613);
3198
+ const index = testnetArr.findIndex(
3199
+ (item2) => item2.network_infos.chain_id === 421613
3200
+ );
3192
3201
  if (index > -1) {
3193
3202
  testnetArr[index] = _chain;
3194
3203
  }
@@ -3255,16 +3264,19 @@ var useChains = (networkId, options = {}) => {
3255
3264
  }
3256
3265
  });
3257
3266
  } else {
3258
- if (!chainInfos)
3259
- return void 0;
3260
3267
  orderlyChainsArr.forEach((chain) => {
3261
3268
  let _chain = chain;
3262
- const networkInfo = chainInfos.find((item) => {
3263
- console.log(item.chain_id, chain.network_infos.chain_id);
3269
+ const networkInfo = chainInfos?.find((item) => {
3264
3270
  return item.chain_id == chain.network_infos.chain_id;
3265
3271
  });
3266
3272
  if (networkInfo) {
3267
- const { name, public_rpc_url, chain_id, currency_symbol, explorer_base_url } = networkInfo;
3273
+ const {
3274
+ name,
3275
+ public_rpc_url,
3276
+ chain_id,
3277
+ currency_symbol,
3278
+ explorer_base_url
3279
+ } = networkInfo;
3268
3280
  _chain.network_infos = {
3269
3281
  ..._chain.network_infos,
3270
3282
  name,
@@ -3281,7 +3293,9 @@ var useChains = (networkId, options = {}) => {
3281
3293
  }
3282
3294
  map.current.set(_chain.network_infos.chain_id, _chain);
3283
3295
  if (_chain.network_infos.chain_id === 421613) {
3284
- const index = testnetArr.findIndex((item) => item.network_infos.chain_id === 421613);
3296
+ const index = testnetArr.findIndex(
3297
+ (item) => item.network_infos.chain_id === 421613
3298
+ );
3285
3299
  if (index > -1) {
3286
3300
  testnetArr[index] = _chain;
3287
3301
  }
@@ -3313,7 +3327,15 @@ var useChains = (networkId, options = {}) => {
3313
3327
  testnet: testnetArr,
3314
3328
  mainnet: mainnetArr
3315
3329
  };
3316
- }, [data, networkId, field, options, orderlyChains, wooSwapEnabled]);
3330
+ }, [
3331
+ data,
3332
+ networkId,
3333
+ field,
3334
+ options,
3335
+ orderlyChains,
3336
+ wooSwapEnabled,
3337
+ chainInfos
3338
+ ]);
3317
3339
  const findByChainId = useCallback(
3318
3340
  (chainId, field2) => {
3319
3341
  const chain = map.current.get(chainId);
@@ -3409,7 +3431,7 @@ var useDeposit = (options) => {
3409
3431
  network: chain.network_infos.shortName
3410
3432
  // chainId: 42161,
3411
3433
  };
3412
- }, [networkId]);
3434
+ }, [networkId, findByChainId]);
3413
3435
  const isNativeToken = useMemo(
3414
3436
  () => isNativeTokenChecker(options?.address || ""),
3415
3437
  [options?.address]