@orderly.network/hooks 0.0.5 → 0.0.7

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 CHANGED
@@ -1,14 +1,16 @@
1
1
  import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
2
2
  export { SWRConfiguration, default as useSWR } from 'swr';
3
3
  import { SWRMutationConfiguration } from 'swr/mutation';
4
- import { AccountState, ConfigStore, WSMessage } from '@orderly.network/core';
5
- import { API, OrderEntity, OrderSide } from '@orderly.network/types';
6
- import { WebSocketClient } from '@orderly.network/net';
4
+ import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, WSMessage } from '@orderly.network/core';
5
+ import { SystemStateEnum, ExchangeStatusEnum, OrderEntity, API, OrderSide } from '@orderly.network/types';
6
+ import { WebSocketClient, WS } from '@orderly.network/net';
7
7
  export { useEventCallback, useObservable } from 'rxjs-hooks';
8
8
  export { default as useConstant } from 'use-constant';
9
9
  import * as react from 'react';
10
+ import { FC, PropsWithChildren } from 'react';
10
11
  import { FormikErrors, FormikState } from 'formik';
11
12
  import * as swr__internal from 'swr/_internal';
13
+ import * as swr_subscription from 'swr/subscription';
12
14
 
13
15
  type useQueryOptions<T> = SWRConfiguration & {
14
16
  formatter?: (data: any) => T;
@@ -20,7 +22,7 @@ type useQueryOptions<T> = SWRConfiguration & {
20
22
  * @param query
21
23
  * @param options
22
24
  */
23
- declare const useQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
25
+ declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
24
26
 
25
27
  declare const useMutation: <T, E>(url: string, options?: SWRMutationConfiguration<T, E> | undefined) => {
26
28
  mutation: (data: any) => Promise<any>;
@@ -36,7 +38,7 @@ declare const useMutation: <T, E>(url: string, options?: SWRMutationConfiguratio
36
38
  * @param query
37
39
  * @param options
38
40
  */
39
- declare const usePrivateQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
41
+ declare const usePrivateQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
40
42
 
41
43
  declare const useTradingView: () => {};
42
44
 
@@ -49,17 +51,33 @@ declare const useTopicObserve: <T>(topic: string) => {
49
51
  };
50
52
 
51
53
  declare const useAccount: () => {
52
- account: AccountState;
54
+ account: Account;
55
+ state: AccountState;
53
56
  login: (address: string) => void;
54
- info: API.AccountInfo | undefined;
57
+ };
58
+
59
+ declare const useAppState: () => {
60
+ systemState: SystemStateEnum;
61
+ exchangeState: ExchangeStatusEnum;
55
62
  };
56
63
 
57
64
  declare const useWebSocketClient: () => WebSocketClient;
58
65
 
59
- interface OrderlyContextState {
66
+ declare const DataSourceProvider: FC<PropsWithChildren>;
67
+
68
+ declare const useWS: () => WS;
69
+
70
+ interface OrderlyAppConfig {
71
+ logoUrl: string;
72
+ theme: any;
73
+ }
74
+ interface OrderlyContextState extends OrderlyAppConfig {
60
75
  fetcher?: (url: string, init: RequestInit) => Promise<any>;
61
76
  apiBaseUrl: string;
62
77
  configStore: ConfigStore;
78
+ keyStore: OrderlyKeyStore;
79
+ walletAdapter: WalletAdapter;
80
+ networkId: string;
63
81
  }
64
82
  declare const OrderlyContext: react.Context<OrderlyContextState>;
65
83
  declare const OrderlyProvider: react.Provider<OrderlyContextState>;
@@ -131,12 +149,16 @@ declare const useFetures: () => {
131
149
 
132
150
  declare const useSymbolsInfo: () => any;
133
151
 
152
+ declare const useAccountInfo: () => swr__internal.SWRResponse<API.AccountInfo, any, any>;
153
+
134
154
  declare const useTokenInfo: () => any;
135
155
 
136
156
  declare const useMarketsStream: () => {
137
157
  data: WSMessage.Ticker[] | null;
138
158
  };
139
159
 
160
+ declare const useMarkPricesStream: () => swr_subscription.SWRSubscriptionResponse<any, any>;
161
+
140
162
  declare const useTickerStream: (symbol: string) => any;
141
163
 
142
164
  declare const useFundingRate$1: (symbol: string) => {
@@ -162,7 +184,7 @@ declare enum OrderStatus {
162
184
  declare const useOrderStream: ({ status, symbol, }?: {
163
185
  symbol?: string | undefined;
164
186
  status?: OrderStatus | undefined;
165
- }) => (API.OrderExt[] | {
187
+ }) => (any[] | {
166
188
  cancelAllOrders: () => void;
167
189
  updateOrder: (id: string, data: any) => void;
168
190
  cancelOrder: (id: string) => void;
@@ -246,4 +268,4 @@ declare namespace index {
246
268
  };
247
269
  }
248
270
 
249
- export { OrderStatus, OrderlyContext, OrderlyContextState, OrderlyProvider, index as apis, useAccount, useCollateral, useFetures, useFundingRate$1 as useFundingRate, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbook, usePositionStream, usePrivateObserve, usePrivateQuery, useQuery, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWebSocketClient };
271
+ export { DataSourceProvider, OrderStatus, OrderlyAppConfig, OrderlyContext, OrderlyContextState, OrderlyProvider, index as apis, useAccount, useAccountInfo, useAppState, useCollateral, useFetures, useFundingRate$1 as useFundingRate, useMarkPricesStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbook, usePositionStream, usePrivateObserve, usePrivateQuery, useQuery, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWebSocketClient };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
2
2
  export { SWRConfiguration, default as useSWR } from 'swr';
3
3
  import { SWRMutationConfiguration } from 'swr/mutation';
4
- import { AccountState, ConfigStore, WSMessage } from '@orderly.network/core';
5
- import { API, OrderEntity, OrderSide } from '@orderly.network/types';
6
- import { WebSocketClient } from '@orderly.network/net';
4
+ import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, WSMessage } from '@orderly.network/core';
5
+ import { SystemStateEnum, ExchangeStatusEnum, OrderEntity, API, OrderSide } from '@orderly.network/types';
6
+ import { WebSocketClient, WS } from '@orderly.network/net';
7
7
  export { useEventCallback, useObservable } from 'rxjs-hooks';
8
8
  export { default as useConstant } from 'use-constant';
9
9
  import * as react from 'react';
10
+ import { FC, PropsWithChildren } from 'react';
10
11
  import { FormikErrors, FormikState } from 'formik';
11
12
  import * as swr__internal from 'swr/_internal';
13
+ import * as swr_subscription from 'swr/subscription';
12
14
 
13
15
  type useQueryOptions<T> = SWRConfiguration & {
14
16
  formatter?: (data: any) => T;
@@ -20,7 +22,7 @@ type useQueryOptions<T> = SWRConfiguration & {
20
22
  * @param query
21
23
  * @param options
22
24
  */
23
- declare const useQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
25
+ declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
24
26
 
25
27
  declare const useMutation: <T, E>(url: string, options?: SWRMutationConfiguration<T, E> | undefined) => {
26
28
  mutation: (data: any) => Promise<any>;
@@ -36,7 +38,7 @@ declare const useMutation: <T, E>(url: string, options?: SWRMutationConfiguratio
36
38
  * @param query
37
39
  * @param options
38
40
  */
39
- declare const usePrivateQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
41
+ declare const usePrivateQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
40
42
 
41
43
  declare const useTradingView: () => {};
42
44
 
@@ -49,17 +51,33 @@ declare const useTopicObserve: <T>(topic: string) => {
49
51
  };
50
52
 
51
53
  declare const useAccount: () => {
52
- account: AccountState;
54
+ account: Account;
55
+ state: AccountState;
53
56
  login: (address: string) => void;
54
- info: API.AccountInfo | undefined;
57
+ };
58
+
59
+ declare const useAppState: () => {
60
+ systemState: SystemStateEnum;
61
+ exchangeState: ExchangeStatusEnum;
55
62
  };
56
63
 
57
64
  declare const useWebSocketClient: () => WebSocketClient;
58
65
 
59
- interface OrderlyContextState {
66
+ declare const DataSourceProvider: FC<PropsWithChildren>;
67
+
68
+ declare const useWS: () => WS;
69
+
70
+ interface OrderlyAppConfig {
71
+ logoUrl: string;
72
+ theme: any;
73
+ }
74
+ interface OrderlyContextState extends OrderlyAppConfig {
60
75
  fetcher?: (url: string, init: RequestInit) => Promise<any>;
61
76
  apiBaseUrl: string;
62
77
  configStore: ConfigStore;
78
+ keyStore: OrderlyKeyStore;
79
+ walletAdapter: WalletAdapter;
80
+ networkId: string;
63
81
  }
64
82
  declare const OrderlyContext: react.Context<OrderlyContextState>;
65
83
  declare const OrderlyProvider: react.Provider<OrderlyContextState>;
@@ -131,12 +149,16 @@ declare const useFetures: () => {
131
149
 
132
150
  declare const useSymbolsInfo: () => any;
133
151
 
152
+ declare const useAccountInfo: () => swr__internal.SWRResponse<API.AccountInfo, any, any>;
153
+
134
154
  declare const useTokenInfo: () => any;
135
155
 
136
156
  declare const useMarketsStream: () => {
137
157
  data: WSMessage.Ticker[] | null;
138
158
  };
139
159
 
160
+ declare const useMarkPricesStream: () => swr_subscription.SWRSubscriptionResponse<any, any>;
161
+
140
162
  declare const useTickerStream: (symbol: string) => any;
141
163
 
142
164
  declare const useFundingRate$1: (symbol: string) => {
@@ -162,7 +184,7 @@ declare enum OrderStatus {
162
184
  declare const useOrderStream: ({ status, symbol, }?: {
163
185
  symbol?: string | undefined;
164
186
  status?: OrderStatus | undefined;
165
- }) => (API.OrderExt[] | {
187
+ }) => (any[] | {
166
188
  cancelAllOrders: () => void;
167
189
  updateOrder: (id: string, data: any) => void;
168
190
  cancelOrder: (id: string) => void;
@@ -246,4 +268,4 @@ declare namespace index {
246
268
  };
247
269
  }
248
270
 
249
- export { OrderStatus, OrderlyContext, OrderlyContextState, OrderlyProvider, index as apis, useAccount, useCollateral, useFetures, useFundingRate$1 as useFundingRate, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbook, usePositionStream, usePrivateObserve, usePrivateQuery, useQuery, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWebSocketClient };
271
+ export { DataSourceProvider, OrderStatus, OrderlyAppConfig, OrderlyContext, OrderlyContextState, OrderlyProvider, index as apis, useAccount, useAccountInfo, useAppState, useCollateral, useFetures, useFundingRate$1 as useFundingRate, useMarkPricesStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbook, usePositionStream, usePrivateObserve, usePrivateQuery, useQuery, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWebSocketClient };