@orderly.network/hooks 1.0.6 → 1.0.8
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 +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,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
10
|
import useSWRInfinite from 'swr/infinite';
|
|
11
|
+
import { jsx } from 'react/jsx-runtime';
|
|
11
12
|
import { Decimal, zero, getPrecisionByNumber, timeConvertString } from '@orderly.network/utils';
|
|
12
13
|
import useSWRSubscription from 'swr/subscription';
|
|
13
14
|
import { pathOr, propOr, compose, head, prop, mergeDeepRight, pick, min } from 'ramda';
|
|
@@ -21,6 +22,9 @@ var OrderlyContext = createContext({
|
|
|
21
22
|
// configStore: new MemoryConfigStore(),
|
|
22
23
|
});
|
|
23
24
|
var OrderlyProvider = OrderlyContext.Provider;
|
|
25
|
+
var useOrderlyContext = () => {
|
|
26
|
+
return useContext(OrderlyContext);
|
|
27
|
+
};
|
|
24
28
|
|
|
25
29
|
// src/useConfig.ts
|
|
26
30
|
var useConfig = (key, defaultValue) => {
|
|
@@ -463,7 +467,7 @@ var OrderlyConfigProvider = (props) => {
|
|
|
463
467
|
if (!account5) {
|
|
464
468
|
return null;
|
|
465
469
|
}
|
|
466
|
-
return /* @__PURE__ */
|
|
470
|
+
return /* @__PURE__ */ jsx(
|
|
467
471
|
OrderlyProvider,
|
|
468
472
|
{
|
|
469
473
|
value: {
|
|
@@ -471,10 +475,9 @@ var OrderlyConfigProvider = (props) => {
|
|
|
471
475
|
keyStore: innerKeyStore,
|
|
472
476
|
getWalletAdapter: innerGetWalletAdapter,
|
|
473
477
|
networkId
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
props.children
|
|
478
|
+
},
|
|
479
|
+
children: props.children
|
|
480
|
+
}
|
|
478
481
|
);
|
|
479
482
|
};
|
|
480
483
|
var WalletConnectorContext = createContext({});
|
|
@@ -1266,7 +1269,7 @@ var useHoldingStream = () => {
|
|
|
1266
1269
|
const usdc2 = data?.find((item) => item.token === "USDC");
|
|
1267
1270
|
return usdc2;
|
|
1268
1271
|
}, [data]);
|
|
1269
|
-
useSWRSubscription("holding", (_, { next }) => {
|
|
1272
|
+
const { data: balance } = useSWRSubscription("holding", (_, { next }) => {
|
|
1270
1273
|
const unsubscribe = ws.privateSubscribe(
|
|
1271
1274
|
{
|
|
1272
1275
|
id: "balance",
|
|
@@ -1298,6 +1301,7 @@ var useHoldingStream = () => {
|
|
|
1298
1301
|
return {
|
|
1299
1302
|
data,
|
|
1300
1303
|
usdc,
|
|
1304
|
+
balance,
|
|
1301
1305
|
isLoading
|
|
1302
1306
|
};
|
|
1303
1307
|
};
|
|
@@ -3497,6 +3501,17 @@ var usePrivateDataObserver = () => {
|
|
|
3497
3501
|
const ws = useWS();
|
|
3498
3502
|
const { mutate: mutate2 } = useSWRConfig();
|
|
3499
3503
|
const { state } = useAccount();
|
|
3504
|
+
useEffect(() => {
|
|
3505
|
+
console.log("----!!!usePrivateDataObserver!!!----");
|
|
3506
|
+
}, []);
|
|
3507
|
+
useEffect(() => {
|
|
3508
|
+
const unsubscribe = ws.privateSubscribe("executionreport", {
|
|
3509
|
+
onMessage: (data) => {
|
|
3510
|
+
console.log(data);
|
|
3511
|
+
}
|
|
3512
|
+
});
|
|
3513
|
+
return () => unsubscribe?.();
|
|
3514
|
+
}, [state.accountId]);
|
|
3500
3515
|
useEffect(() => {
|
|
3501
3516
|
if (!state.accountId)
|
|
3502
3517
|
return;
|
|
@@ -3504,6 +3519,7 @@ var usePrivateDataObserver = () => {
|
|
|
3504
3519
|
const unsubscribe = ws.privateSubscribe("position", {
|
|
3505
3520
|
onMessage: (data) => {
|
|
3506
3521
|
const { positions: nextPostions } = data;
|
|
3522
|
+
console.log("ws-----data-----", data);
|
|
3507
3523
|
mutate2(key, (prevPositions) => {
|
|
3508
3524
|
if (!!prevPositions) {
|
|
3509
3525
|
return {
|
|
@@ -4148,6 +4164,6 @@ var useSwap = () => {
|
|
|
4148
4164
|
};
|
|
4149
4165
|
};
|
|
4150
4166
|
|
|
4151
|
-
export { OrderlyConfigProvider, OrderlyContext, OrderlyProvider, WalletConnectorContext, 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, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
|
4167
|
+
export { OrderlyConfigProvider, OrderlyContext, OrderlyProvider, WalletConnectorContext, 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, useOrderlyContext, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
|
4152
4168
|
//# sourceMappingURL=out.js.map
|
|
4153
4169
|
//# sourceMappingURL=index.mjs.map
|