@orderly.network/hooks 0.0.74 → 0.0.76

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
@@ -3006,6 +3006,7 @@ var useChains = (networkId, options = {}) => {
3006
3006
  {
3007
3007
  network_infos: {
3008
3008
  name: "Arbitrum Goerli",
3009
+ shortName: "Arbitrum Goerli",
3009
3010
  public_rpc_url: "https://goerli-rollup.arbitrum.io/rpc",
3010
3011
  chain_id: 421613,
3011
3012
  currency_symbol: "ETH",
@@ -3024,7 +3025,8 @@ var useChains = (networkId, options = {}) => {
3024
3025
  const item = mergeDeepRight(chain, {
3025
3026
  name: key,
3026
3027
  network_infos: {
3027
- bridgeless: orderlyChainIds.has(chain.network_infos.chain_id)
3028
+ bridgeless: orderlyChainIds.has(chain.network_infos.chain_id),
3029
+ shortName: key
3028
3030
  },
3029
3031
  token_infos: chain.token_infos.filter(
3030
3032
  (token) => !!token.swap_enable
@@ -3154,7 +3156,7 @@ var useDeposit = (options) => {
3154
3156
  address: USDC?.address,
3155
3157
  decimals: USDC?.decimals,
3156
3158
  chainId: chain.network_infos.chain_id,
3157
- network: chain.network_infos.name
3159
+ network: chain.network_infos.shortName
3158
3160
  // chainId: 42161,
3159
3161
  };
3160
3162
  }, []);
@@ -3340,6 +3342,26 @@ var useWalletSubscription = (options) => {
3340
3342
  return () => unsubscribe();
3341
3343
  });
3342
3344
  };
3345
+ var useSettleSubscription = (options) => {
3346
+ const ws = useWS();
3347
+ return useSWRSubscription("settle", (_, { next }) => {
3348
+ const unsubscribe = ws.privateSubscribe(
3349
+ {
3350
+ id: "settle",
3351
+ event: "subscribe",
3352
+ topic: "settle",
3353
+ ts: Date.now()
3354
+ },
3355
+ {
3356
+ onMessage: (data) => {
3357
+ options?.onMessage?.(data);
3358
+ next(data);
3359
+ }
3360
+ }
3361
+ );
3362
+ return () => unsubscribe();
3363
+ });
3364
+ };
3343
3365
  var useBalance = () => {
3344
3366
  const ws = useWS();
3345
3367
  const { data } = useSWRSubscription("balance", (_, { next }) => {
@@ -3558,7 +3580,7 @@ var useWooCrossSwapQuery = () => {
3558
3580
  start();
3559
3581
  const params = {
3560
3582
  // src_network: inputs.srcNetwork,
3561
- src_network: inputs.srcNetwork.toLowerCase(),
3583
+ src_network: inputs.srcNetwork,
3562
3584
  dst_network: "arbitrum",
3563
3585
  src_token: inputs.srcToken,
3564
3586
  dst_token: inputs.dstToken,
@@ -3639,20 +3661,29 @@ var useCrossSwap = () => {
3639
3661
  }, [txHashFromBridge.current]);
3640
3662
  const checkLayerStatus = useCallback((txHash) => {
3641
3663
  const check = async (txHash2) => {
3642
- const { messages } = await client.getMessagesBySrcTxHash(txHash2);
3643
- if (messages.length > 0) {
3644
- const { status: status2 } = messages[0];
3645
- if (status2 === "INFLIGHT" /* INFLIGHT */) {
3664
+ try {
3665
+ const { messages } = await client.getMessagesBySrcTxHash(txHash2);
3666
+ if (messages.length > 0) {
3667
+ const { status: status2 } = messages[0];
3668
+ if (status2 === "INFLIGHT" /* INFLIGHT */) {
3669
+ setTimeout(() => {
3670
+ check(txHash2);
3671
+ }, 1e3);
3672
+ }
3673
+ setLayerStatus(status2);
3674
+ if (status2 === "DELIVERED" /* DELIVERED */) {
3675
+ setBridgeMessage(messages[0]);
3676
+ txHashFromBridge.current = messages[0].dstTxHash;
3677
+ }
3678
+ if (status2 === "FAILED" /* FAILED */) {
3679
+ setBridgeMessage(messages[0]);
3680
+ }
3681
+ } else {
3646
3682
  setTimeout(() => {
3647
3683
  check(txHash2);
3648
3684
  }, 1e3);
3649
3685
  }
3650
- setLayerStatus(status2);
3651
- if (status2 === "DELIVERED" /* DELIVERED */) {
3652
- setBridgeMessage(messages[0]);
3653
- txHashFromBridge.current = messages[0].dstTxHash;
3654
- }
3655
- } else {
3686
+ } catch (e) {
3656
3687
  setTimeout(() => {
3657
3688
  check(txHash2);
3658
3689
  }, 1e3);
@@ -4071,6 +4102,6 @@ var useSwap = () => {
4071
4102
  };
4072
4103
  };
4073
4104
 
4074
- export { DataSourceProvider, OrderStatus, OrderlyContext, OrderlyProvider, apis_exports as apis, useAccount, useAccountInfo, useAccountInstance, useAppState, useBalance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useExecutionReport, useFetures, useFundingRate, useHoldingStream, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSwap, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
4105
+ export { DataSourceProvider, OrderStatus, OrderlyContext, OrderlyProvider, apis_exports as apis, useAccount, useAccountInfo, useAccountInstance, useAppState, useBalance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useExecutionReport, useFetures, useFundingRate, useHoldingStream, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
4075
4106
  //# sourceMappingURL=out.js.map
4076
4107
  //# sourceMappingURL=index.mjs.map