@orderly.network/hooks 0.0.54 → 0.0.56

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,6 +1,6 @@
1
1
  import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
2
2
  export { SWRConfig, SWRConfiguration, default as useSWR } from 'swr';
3
- import { SWRMutationConfiguration } from 'swr/mutation';
3
+ import { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation';
4
4
  import * as _orderly_network_core from '@orderly.network/core';
5
5
  import { Account, AccountState, ConfigStore, OrderlyKeyStore, getWalletAdapterFunc, IContract, EventEmitter } from '@orderly.network/core';
6
6
  import * as react from 'react';
@@ -10,6 +10,7 @@ import { WS } from '@orderly.network/net';
10
10
  import { OrderSide, OrderEntity, API, WSMessage } from '@orderly.network/types';
11
11
  import * as swr__internal from 'swr/_internal';
12
12
  import * as swr_subscription from 'swr/subscription';
13
+ export * from 'use-debounce';
13
14
 
14
15
  type useQueryOptions<T> = SWRConfiguration & {
15
16
  formatter?: (data: any) => T;
@@ -23,6 +24,17 @@ type useQueryOptions<T> = SWRConfiguration & {
23
24
  */
24
25
  declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
25
26
 
27
+ /**
28
+ * useQuery
29
+ * @description for public api
30
+ * @param query
31
+ * @param options
32
+ */
33
+ declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any> & {
34
+ formatter?: ((data: any) => R) | undefined;
35
+ init?: RequestInit | undefined;
36
+ }) | undefined) => SWRMutationResponse;
37
+
26
38
  type HTTP_METHOD = "POST" | "PUT" | "DELETE";
27
39
  declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E> | undefined) => [any, any];
28
40
 
@@ -34,6 +46,12 @@ declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: S
34
46
  */
35
47
  declare const usePrivateQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
36
48
 
49
+ declare const useBoolean: (initialValue?: boolean) => [boolean, {
50
+ setTrue: () => void;
51
+ setFalse: () => void;
52
+ toggle: () => void;
53
+ }];
54
+
37
55
  declare const useTradingView: () => {};
38
56
 
39
57
  declare const usePrivateObserve: <T>() => {
@@ -288,16 +306,25 @@ declare const useWithdraw: () => {
288
306
 
289
307
  type useDepositOptions = {
290
308
  address?: string;
309
+ decimals?: number;
291
310
  };
292
311
  declare const useDeposit: (options?: useDepositOptions) => {
312
+ dst: {
313
+ symbol: string;
314
+ address: string;
315
+ decimals: number;
316
+ network: string;
317
+ chainId: number;
318
+ };
293
319
  balance: string;
294
320
  allowance: string;
321
+ isNativeToken: boolean;
295
322
  balanceRevalidating: boolean;
296
323
  allowanceRevalidating: boolean;
297
324
  approve: (amount: string | undefined) => Promise<any>;
298
325
  deposit: (amount: string) => Promise<any>;
299
326
  fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
300
- fetchBalance: (address: string) => Promise<string>;
327
+ fetchBalance: (address: string, decimals?: number) => Promise<string>;
301
328
  };
302
329
 
303
330
  declare const useHoldingStream: () => {
@@ -373,4 +400,52 @@ declare namespace index {
373
400
  };
374
401
  }
375
402
 
376
- export { AppStateErrors, DataSourceProvider, OrderStatus, OrderlyAppConfig, OrderlyContext, OrderlyContextState, OrderlyProvider, index as apis, useAccount, useAccountInfo, useAccountInstance, useAppState, useBalance, useChain, useChains, useCollateral, useConfig, useDeposit, useEventEmitter, useExecutionReport, useFetures, useFundingRate, useHoldingStream, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateObserve, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw };
403
+ declare const useWooSwapQuery: () => {
404
+ query: (inputs: any) => Promise<any> | undefined;
405
+ loading: boolean;
406
+ };
407
+
408
+ declare const useWooCrossSwapQuery: () => {
409
+ query: (inputs: any) => Promise<any> | undefined;
410
+ loading: boolean;
411
+ };
412
+
413
+ declare enum MessageStatus {
414
+ INITIALIZING = "WAITTING",
415
+ INFLIGHT = "INFLIGHT",
416
+ DELIVERED = "DELIVERED",
417
+ FAILED = "FAILED"
418
+ }
419
+ declare const useCrossSwap: () => {
420
+ swap: (inputs: {
421
+ address: string;
422
+ src: {
423
+ fromToken: string;
424
+ fromAmount: string;
425
+ bridgeToken: string;
426
+ minBridgeAmount: string;
427
+ };
428
+ dst: {
429
+ chainId: string;
430
+ bridgedToken: string;
431
+ toToken: string;
432
+ minToAmount: string;
433
+ airdropNativeAmount: string;
434
+ };
435
+ }) => Promise<{} | undefined>;
436
+ loading: boolean;
437
+ status: MessageStatus;
438
+ message: any;
439
+ };
440
+
441
+ declare const useSwap: () => {
442
+ swap: (inputs: {
443
+ fromToken: string;
444
+ fromAmount: string;
445
+ toToken: string;
446
+ minToAmount: string;
447
+ }) => Promise<{} | undefined>;
448
+ loading: boolean;
449
+ };
450
+
451
+ export { AppStateErrors, DataSourceProvider, OrderStatus, OrderlyAppConfig, OrderlyContext, OrderlyContextState, OrderlyProvider, index 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, usePrivateObserve, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSwap, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
2
2
  export { SWRConfig, SWRConfiguration, default as useSWR } from 'swr';
3
- import { SWRMutationConfiguration } from 'swr/mutation';
3
+ import { SWRMutationConfiguration, SWRMutationResponse } from 'swr/mutation';
4
4
  import * as _orderly_network_core from '@orderly.network/core';
5
5
  import { Account, AccountState, ConfigStore, OrderlyKeyStore, getWalletAdapterFunc, IContract, EventEmitter } from '@orderly.network/core';
6
6
  import * as react from 'react';
@@ -10,6 +10,7 @@ import { WS } from '@orderly.network/net';
10
10
  import { OrderSide, OrderEntity, API, WSMessage } from '@orderly.network/types';
11
11
  import * as swr__internal from 'swr/_internal';
12
12
  import * as swr_subscription from 'swr/subscription';
13
+ export * from 'use-debounce';
13
14
 
14
15
  type useQueryOptions<T> = SWRConfiguration & {
15
16
  formatter?: (data: any) => T;
@@ -23,6 +24,17 @@ type useQueryOptions<T> = SWRConfiguration & {
23
24
  */
24
25
  declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
25
26
 
27
+ /**
28
+ * useQuery
29
+ * @description for public api
30
+ * @param query
31
+ * @param options
32
+ */
33
+ declare const useLazyQuery: <T, R = any>(query: Parameters<typeof useSWR>["0"], options?: (SWRMutationConfiguration<any, any> & {
34
+ formatter?: ((data: any) => R) | undefined;
35
+ init?: RequestInit | undefined;
36
+ }) | undefined) => SWRMutationResponse;
37
+
26
38
  type HTTP_METHOD = "POST" | "PUT" | "DELETE";
27
39
  declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: SWRMutationConfiguration<T, E> | undefined) => [any, any];
28
40
 
@@ -34,6 +46,12 @@ declare const useMutation: <T, E>(url: string, method?: HTTP_METHOD, options?: S
34
46
  */
35
47
  declare const usePrivateQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
36
48
 
49
+ declare const useBoolean: (initialValue?: boolean) => [boolean, {
50
+ setTrue: () => void;
51
+ setFalse: () => void;
52
+ toggle: () => void;
53
+ }];
54
+
37
55
  declare const useTradingView: () => {};
38
56
 
39
57
  declare const usePrivateObserve: <T>() => {
@@ -288,16 +306,25 @@ declare const useWithdraw: () => {
288
306
 
289
307
  type useDepositOptions = {
290
308
  address?: string;
309
+ decimals?: number;
291
310
  };
292
311
  declare const useDeposit: (options?: useDepositOptions) => {
312
+ dst: {
313
+ symbol: string;
314
+ address: string;
315
+ decimals: number;
316
+ network: string;
317
+ chainId: number;
318
+ };
293
319
  balance: string;
294
320
  allowance: string;
321
+ isNativeToken: boolean;
295
322
  balanceRevalidating: boolean;
296
323
  allowanceRevalidating: boolean;
297
324
  approve: (amount: string | undefined) => Promise<any>;
298
325
  deposit: (amount: string) => Promise<any>;
299
326
  fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
300
- fetchBalance: (address: string) => Promise<string>;
327
+ fetchBalance: (address: string, decimals?: number) => Promise<string>;
301
328
  };
302
329
 
303
330
  declare const useHoldingStream: () => {
@@ -373,4 +400,52 @@ declare namespace index {
373
400
  };
374
401
  }
375
402
 
376
- export { AppStateErrors, DataSourceProvider, OrderStatus, OrderlyAppConfig, OrderlyContext, OrderlyContextState, OrderlyProvider, index as apis, useAccount, useAccountInfo, useAccountInstance, useAppState, useBalance, useChain, useChains, useCollateral, useConfig, useDeposit, useEventEmitter, useExecutionReport, useFetures, useFundingRate, useHoldingStream, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateObserve, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw };
403
+ declare const useWooSwapQuery: () => {
404
+ query: (inputs: any) => Promise<any> | undefined;
405
+ loading: boolean;
406
+ };
407
+
408
+ declare const useWooCrossSwapQuery: () => {
409
+ query: (inputs: any) => Promise<any> | undefined;
410
+ loading: boolean;
411
+ };
412
+
413
+ declare enum MessageStatus {
414
+ INITIALIZING = "WAITTING",
415
+ INFLIGHT = "INFLIGHT",
416
+ DELIVERED = "DELIVERED",
417
+ FAILED = "FAILED"
418
+ }
419
+ declare const useCrossSwap: () => {
420
+ swap: (inputs: {
421
+ address: string;
422
+ src: {
423
+ fromToken: string;
424
+ fromAmount: string;
425
+ bridgeToken: string;
426
+ minBridgeAmount: string;
427
+ };
428
+ dst: {
429
+ chainId: string;
430
+ bridgedToken: string;
431
+ toToken: string;
432
+ minToAmount: string;
433
+ airdropNativeAmount: string;
434
+ };
435
+ }) => Promise<{} | undefined>;
436
+ loading: boolean;
437
+ status: MessageStatus;
438
+ message: any;
439
+ };
440
+
441
+ declare const useSwap: () => {
442
+ swap: (inputs: {
443
+ fromToken: string;
444
+ fromAmount: string;
445
+ toToken: string;
446
+ minToAmount: string;
447
+ }) => Promise<{} | undefined>;
448
+ loading: boolean;
449
+ };
450
+
451
+ export { AppStateErrors, DataSourceProvider, OrderStatus, OrderlyAppConfig, OrderlyContext, OrderlyContextState, OrderlyProvider, index 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, usePrivateObserve, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSwap, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };