@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.d.mts
CHANGED
|
@@ -9,8 +9,9 @@ import { AccountState, Account, EventEmitter, ConfigKey, ConfigStore, OrderlyKey
|
|
|
9
9
|
export { default as useConstant } from 'use-constant';
|
|
10
10
|
import { WS } from '@orderly.network/net';
|
|
11
11
|
import * as react from 'react';
|
|
12
|
-
import
|
|
12
|
+
import { PropsWithChildren } from 'react';
|
|
13
13
|
import { NetworkId, OrderSide, OrderEntity, API, WSMessage, OrderStatus, WS_WalletStatusEnum } from '@orderly.network/types';
|
|
14
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
14
15
|
import * as swr_subscription from 'swr/subscription';
|
|
15
16
|
import { Decimal } from '@orderly.network/utils';
|
|
16
17
|
export * from 'use-debounce';
|
|
@@ -98,6 +99,7 @@ interface OrderlyConfigContextState {
|
|
|
98
99
|
}
|
|
99
100
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
100
101
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
102
|
+
declare const useOrderlyContext: () => OrderlyConfigContextState;
|
|
101
103
|
|
|
102
104
|
declare type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
103
105
|
[K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
|
|
@@ -109,7 +111,7 @@ interface ConfigProviderProps {
|
|
|
109
111
|
brokerId: string;
|
|
110
112
|
networkId: NetworkId;
|
|
111
113
|
}
|
|
112
|
-
declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) =>
|
|
114
|
+
declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) => react_jsx_runtime.JSX.Element | null;
|
|
113
115
|
|
|
114
116
|
declare type ConnectedChain = {
|
|
115
117
|
id: string;
|
|
@@ -339,6 +341,7 @@ declare const useDeposit: (options?: useDepositOptions | undefined) => {
|
|
|
339
341
|
declare const useHoldingStream: () => {
|
|
340
342
|
data: API.Holding[] | undefined;
|
|
341
343
|
usdc: API.Holding | undefined;
|
|
344
|
+
balance: any;
|
|
342
345
|
isLoading: boolean;
|
|
343
346
|
};
|
|
344
347
|
|
|
@@ -429,4 +432,4 @@ declare const useSwap: () => {
|
|
|
429
432
|
status: WS_WalletStatusEnum;
|
|
430
433
|
};
|
|
431
434
|
|
|
432
|
-
export { ConfigProviderProps,
|
|
435
|
+
export { ConfigProviderProps, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ import { AccountState, Account, EventEmitter, ConfigKey, ConfigStore, OrderlyKey
|
|
|
9
9
|
export { default as useConstant } from 'use-constant';
|
|
10
10
|
import { WS } from '@orderly.network/net';
|
|
11
11
|
import * as react from 'react';
|
|
12
|
-
import
|
|
12
|
+
import { PropsWithChildren } from 'react';
|
|
13
13
|
import { NetworkId, OrderSide, OrderEntity, API, WSMessage, OrderStatus, WS_WalletStatusEnum } from '@orderly.network/types';
|
|
14
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
14
15
|
import * as swr_subscription from 'swr/subscription';
|
|
15
16
|
import { Decimal } from '@orderly.network/utils';
|
|
16
17
|
export * from 'use-debounce';
|
|
@@ -98,6 +99,7 @@ interface OrderlyConfigContextState {
|
|
|
98
99
|
}
|
|
99
100
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
100
101
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
102
|
+
declare const useOrderlyContext: () => OrderlyConfigContextState;
|
|
101
103
|
|
|
102
104
|
declare type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
103
105
|
[K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
|
|
@@ -109,7 +111,7 @@ interface ConfigProviderProps {
|
|
|
109
111
|
brokerId: string;
|
|
110
112
|
networkId: NetworkId;
|
|
111
113
|
}
|
|
112
|
-
declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) =>
|
|
114
|
+
declare const OrderlyConfigProvider: (props: PropsWithChildren<RequireAtLeastOne<ConfigProviderProps, "brokerId" | "configStore">>) => react_jsx_runtime.JSX.Element | null;
|
|
113
115
|
|
|
114
116
|
declare type ConnectedChain = {
|
|
115
117
|
id: string;
|
|
@@ -339,6 +341,7 @@ declare const useDeposit: (options?: useDepositOptions | undefined) => {
|
|
|
339
341
|
declare const useHoldingStream: () => {
|
|
340
342
|
data: API.Holding[] | undefined;
|
|
341
343
|
usdc: API.Holding | undefined;
|
|
344
|
+
balance: any;
|
|
342
345
|
isLoading: boolean;
|
|
343
346
|
};
|
|
344
347
|
|
|
@@ -429,4 +432,4 @@ declare const useSwap: () => {
|
|
|
429
432
|
status: WS_WalletStatusEnum;
|
|
430
433
|
};
|
|
431
434
|
|
|
432
|
-
export { ConfigProviderProps,
|
|
435
|
+
export { ConfigProviderProps, 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 };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var useConstant4 = require('use-constant');
|
|
|
8
8
|
var core = require('@orderly.network/core');
|
|
9
9
|
var types = require('@orderly.network/types');
|
|
10
10
|
var useSWRInfinite = require('swr/infinite');
|
|
11
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
11
12
|
var utils = require('@orderly.network/utils');
|
|
12
13
|
var useSWRSubscription = require('swr/subscription');
|
|
13
14
|
var ramda = require('ramda');
|
|
@@ -30,6 +31,9 @@ var OrderlyContext = React.createContext({
|
|
|
30
31
|
// configStore: new MemoryConfigStore(),
|
|
31
32
|
});
|
|
32
33
|
var OrderlyProvider = OrderlyContext.Provider;
|
|
34
|
+
var useOrderlyContext = () => {
|
|
35
|
+
return React.useContext(OrderlyContext);
|
|
36
|
+
};
|
|
33
37
|
|
|
34
38
|
// src/useConfig.ts
|
|
35
39
|
var useConfig = (key, defaultValue) => {
|
|
@@ -472,7 +476,7 @@ var OrderlyConfigProvider = (props) => {
|
|
|
472
476
|
if (!account5) {
|
|
473
477
|
return null;
|
|
474
478
|
}
|
|
475
|
-
return /* @__PURE__ */
|
|
479
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
476
480
|
OrderlyProvider,
|
|
477
481
|
{
|
|
478
482
|
value: {
|
|
@@ -480,10 +484,9 @@ var OrderlyConfigProvider = (props) => {
|
|
|
480
484
|
keyStore: innerKeyStore,
|
|
481
485
|
getWalletAdapter: innerGetWalletAdapter,
|
|
482
486
|
networkId
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
props.children
|
|
487
|
+
},
|
|
488
|
+
children: props.children
|
|
489
|
+
}
|
|
487
490
|
);
|
|
488
491
|
};
|
|
489
492
|
var WalletConnectorContext = React.createContext({});
|
|
@@ -1275,7 +1278,7 @@ var useHoldingStream = () => {
|
|
|
1275
1278
|
const usdc2 = data?.find((item) => item.token === "USDC");
|
|
1276
1279
|
return usdc2;
|
|
1277
1280
|
}, [data]);
|
|
1278
|
-
useSWRSubscription__default.default("holding", (_, { next }) => {
|
|
1281
|
+
const { data: balance } = useSWRSubscription__default.default("holding", (_, { next }) => {
|
|
1279
1282
|
const unsubscribe = ws.privateSubscribe(
|
|
1280
1283
|
{
|
|
1281
1284
|
id: "balance",
|
|
@@ -1307,6 +1310,7 @@ var useHoldingStream = () => {
|
|
|
1307
1310
|
return {
|
|
1308
1311
|
data,
|
|
1309
1312
|
usdc,
|
|
1313
|
+
balance,
|
|
1310
1314
|
isLoading
|
|
1311
1315
|
};
|
|
1312
1316
|
};
|
|
@@ -3506,6 +3510,17 @@ var usePrivateDataObserver = () => {
|
|
|
3506
3510
|
const ws = useWS();
|
|
3507
3511
|
const { mutate: mutate2 } = useSWR.useSWRConfig();
|
|
3508
3512
|
const { state } = useAccount();
|
|
3513
|
+
React.useEffect(() => {
|
|
3514
|
+
console.log("----!!!usePrivateDataObserver!!!----");
|
|
3515
|
+
}, []);
|
|
3516
|
+
React.useEffect(() => {
|
|
3517
|
+
const unsubscribe = ws.privateSubscribe("executionreport", {
|
|
3518
|
+
onMessage: (data) => {
|
|
3519
|
+
console.log(data);
|
|
3520
|
+
}
|
|
3521
|
+
});
|
|
3522
|
+
return () => unsubscribe?.();
|
|
3523
|
+
}, [state.accountId]);
|
|
3509
3524
|
React.useEffect(() => {
|
|
3510
3525
|
if (!state.accountId)
|
|
3511
3526
|
return;
|
|
@@ -3513,6 +3528,7 @@ var usePrivateDataObserver = () => {
|
|
|
3513
3528
|
const unsubscribe = ws.privateSubscribe("position", {
|
|
3514
3529
|
onMessage: (data) => {
|
|
3515
3530
|
const { positions: nextPostions } = data;
|
|
3531
|
+
console.log("ws-----data-----", data);
|
|
3516
3532
|
mutate2(key, (prevPositions) => {
|
|
3517
3533
|
if (!!prevPositions) {
|
|
3518
3534
|
return {
|
|
@@ -4200,6 +4216,7 @@ exports.useMutation = useMutation;
|
|
|
4200
4216
|
exports.useOrderEntry = useOrderEntry;
|
|
4201
4217
|
exports.useOrderStream = useOrderStream;
|
|
4202
4218
|
exports.useOrderbookStream = useOrderbookStream;
|
|
4219
|
+
exports.useOrderlyContext = useOrderlyContext;
|
|
4203
4220
|
exports.usePositionStream = usePositionStream;
|
|
4204
4221
|
exports.usePreLoadData = usePreLoadData;
|
|
4205
4222
|
exports.usePrivateDataObserver = usePrivateDataObserver;
|