@orderly.network/hooks 1.0.1 → 1.0.3
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.d.mts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import useSWR, { useSWRConfig } from 'swr';
|
|
2
2
|
export { SWRConfig, default as useSWR } from 'swr';
|
|
3
|
-
import {
|
|
3
|
+
import { get, WS, mutate } from '@orderly.network/net';
|
|
4
4
|
import React, { createContext, useContext, useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
5
5
|
import useSWRMutation from 'swr/mutation';
|
|
6
6
|
import useConstant4 from 'use-constant';
|
|
7
7
|
export { default as useConstant } from 'use-constant';
|
|
8
8
|
import { SimpleDI, Account, EventEmitter, MemoryConfigStore, 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
|
+
import useSWRInfinite from 'swr/infinite';
|
|
10
11
|
import { Decimal, zero, getPrecisionByNumber, timeConvertString } from '@orderly.network/utils';
|
|
11
12
|
import useSWRSubscription from 'swr/subscription';
|
|
12
13
|
import { pathOr, propOr, compose, head, prop, mergeDeepRight, pick, min } from 'ramda';
|
|
13
14
|
import { positions, account, order } from '@orderly.network/perp';
|
|
14
|
-
import useSWRInfinite from 'swr/infinite';
|
|
15
15
|
export * from 'use-debounce';
|
|
16
16
|
import { createClient } from '@layerzerolabs/scan-client';
|
|
17
17
|
|
|
@@ -254,6 +254,20 @@ var usePrivateQuery = (query, options) => {
|
|
|
254
254
|
}
|
|
255
255
|
);
|
|
256
256
|
};
|
|
257
|
+
var usePrivateInfiniteQuery = (getKey, options) => {
|
|
258
|
+
const { formatter, ...restOptions } = options || {};
|
|
259
|
+
const account5 = useAccount();
|
|
260
|
+
const middleware = Array.isArray(restOptions?.use) ? restOptions?.use ?? [] : [];
|
|
261
|
+
const result = useSWRInfinite(
|
|
262
|
+
(pageIndex, previousPageData) => account5.state.status >= AccountStatusEnum.EnableTrading ? getKey(pageIndex, previousPageData) : null,
|
|
263
|
+
(url, init) => get(url, init, formatter),
|
|
264
|
+
{
|
|
265
|
+
...restOptions,
|
|
266
|
+
use: [signatureMiddleware, ...middleware]
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
return result;
|
|
270
|
+
};
|
|
257
271
|
var useBoolean = (initialValue = false) => {
|
|
258
272
|
const [value, setValue] = useState(initialValue);
|
|
259
273
|
const setTrue = useCallback(() => setValue(true), []);
|
|
@@ -1283,20 +1297,6 @@ var useHoldingStream = () => {
|
|
|
1283
1297
|
isLoading
|
|
1284
1298
|
};
|
|
1285
1299
|
};
|
|
1286
|
-
var usePrivateInfiniteQuery = (getKey, options) => {
|
|
1287
|
-
const { formatter, ...restOptions } = options || {};
|
|
1288
|
-
const account5 = useAccount();
|
|
1289
|
-
const middleware = Array.isArray(restOptions?.use) ? restOptions?.use ?? [] : [];
|
|
1290
|
-
const result = useSWRInfinite(
|
|
1291
|
-
(pageIndex, previousPageData) => account5.state.status >= AccountStatusEnum.EnableTrading ? getKey(pageIndex, previousPageData) : null,
|
|
1292
|
-
(url, init) => get(url, init, formatter),
|
|
1293
|
-
{
|
|
1294
|
-
...restOptions,
|
|
1295
|
-
use: [signatureMiddleware, ...middleware]
|
|
1296
|
-
}
|
|
1297
|
-
);
|
|
1298
|
-
return result;
|
|
1299
|
-
};
|
|
1300
1300
|
var useOrderStream = (params) => {
|
|
1301
1301
|
const { status, symbol, side, size = 100 } = params;
|
|
1302
1302
|
const ws = useWS();
|
|
@@ -1305,7 +1305,7 @@ var useOrderStream = (params) => {
|
|
|
1305
1305
|
const [doUpdateOrder] = useMutation("/v1/order", "PUT");
|
|
1306
1306
|
const ordersResponse = usePrivateInfiniteQuery(
|
|
1307
1307
|
(pageIndex, previousPageData) => {
|
|
1308
|
-
if (previousPageData && !previousPageData.length)
|
|
1308
|
+
if (previousPageData && !previousPageData.rows?.length)
|
|
1309
1309
|
return null;
|
|
1310
1310
|
const search = new URLSearchParams([
|
|
1311
1311
|
["size", size.toString()],
|
|
@@ -1324,6 +1324,7 @@ var useOrderStream = (params) => {
|
|
|
1324
1324
|
},
|
|
1325
1325
|
{
|
|
1326
1326
|
initialSize: 1,
|
|
1327
|
+
// revalidateFirstPage: false,
|
|
1327
1328
|
onError: (err) => {
|
|
1328
1329
|
console.error("fetch failed::::", err);
|
|
1329
1330
|
},
|
|
@@ -4143,6 +4144,6 @@ var useSwap = () => {
|
|
|
4143
4144
|
};
|
|
4144
4145
|
};
|
|
4145
4146
|
|
|
4146
|
-
export { OrderlyConfigProvider, OrderlyContext, OrderlyProvider, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
|
4147
|
+
export { OrderlyConfigProvider, OrderlyContext, OrderlyProvider, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
|
4147
4148
|
//# sourceMappingURL=out.js.map
|
|
4148
4149
|
//# sourceMappingURL=index.mjs.map
|