@orderly.network/hooks 1.1.4-rc.4 → 1.1.4
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/esm/configProvider.d.ts +17 -0
- package/esm/configProvider.d.ts.map +1 -0
- package/esm/configProvider.js +54 -0
- package/esm/dataProvider.d.ts +10 -0
- package/esm/dataProvider.d.ts.map +1 -0
- package/esm/dataProvider.js +29 -0
- package/esm/index.d.ts +33 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +30 -0
- package/esm/middleware/signatureMiddleware.d.ts +3 -0
- package/esm/middleware/signatureMiddleware.d.ts.map +1 -0
- package/esm/middleware/signatureMiddleware.js +32 -0
- package/esm/orderly/orderlyHooks.d.ts +30 -0
- package/esm/orderly/orderlyHooks.d.ts.map +1 -0
- package/esm/orderly/orderlyHooks.js +27 -0
- package/esm/orderly/useAccountInfo.d.ts +3 -0
- package/esm/orderly/useAccountInfo.d.ts.map +1 -0
- package/esm/orderly/useAccountInfo.js +4 -0
- package/esm/orderly/useChain.d.ts +6 -0
- package/esm/orderly/useChain.d.ts.map +1 -0
- package/esm/orderly/useChain.js +22 -0
- package/esm/orderly/useChains.d.ts +34 -0
- package/esm/orderly/useChains.d.ts.map +1 -0
- package/esm/orderly/useChains.js +159 -0
- package/esm/orderly/useCollateral.d.ts +16 -0
- package/esm/orderly/useCollateral.d.ts.map +1 -0
- package/esm/orderly/useCollateral.js +72 -0
- package/esm/orderly/useDeposit.d.ts +38 -0
- package/esm/orderly/useDeposit.d.ts.map +1 -0
- package/esm/orderly/useDeposit.js +270 -0
- package/esm/orderly/useFundingRate.d.ts +11 -0
- package/esm/orderly/useFundingRate.d.ts.map +1 -0
- package/esm/orderly/useFundingRate.js +40 -0
- package/esm/orderly/useFundingRates.d.ts +2 -0
- package/esm/orderly/useFundingRates.d.ts.map +1 -0
- package/esm/orderly/useFundingRates.js +21 -0
- package/esm/orderly/useHoldingStream.d.ts +7 -0
- package/esm/orderly/useHoldingStream.d.ts.map +1 -0
- package/esm/orderly/useHoldingStream.js +47 -0
- package/esm/orderly/useIndexPrice.d.ts +2 -0
- package/esm/orderly/useIndexPrice.d.ts.map +1 -0
- package/esm/orderly/useIndexPrice.js +17 -0
- package/esm/orderly/useLeverage.d.ts +2 -0
- package/esm/orderly/useLeverage.d.ts.map +1 -0
- package/esm/orderly/useLeverage.js +34 -0
- package/esm/orderly/useMarginRatio.d.ts +7 -0
- package/esm/orderly/useMarginRatio.d.ts.map +1 -0
- package/esm/orderly/useMarginRatio.js +41 -0
- package/esm/orderly/useMarkPrice.d.ts +4 -0
- package/esm/orderly/useMarkPrice.d.ts.map +1 -0
- package/esm/orderly/useMarkPrice.js +29 -0
- package/esm/orderly/useMarkPricesStream.d.ts +2 -0
- package/esm/orderly/useMarkPricesStream.d.ts.map +1 -0
- package/esm/orderly/useMarkPricesStream.js +26 -0
- package/esm/orderly/useMarketTradeStream.d.ts +9 -0
- package/esm/orderly/useMarketTradeStream.d.ts.map +1 -0
- package/esm/orderly/useMarketTradeStream.js +51 -0
- package/esm/orderly/useMarkets.d.ts +36 -0
- package/esm/orderly/useMarkets.d.ts.map +1 -0
- package/esm/orderly/useMarkets.js +240 -0
- package/esm/orderly/useMarketsStream.d.ts +5 -0
- package/esm/orderly/useMarketsStream.d.ts.map +1 -0
- package/esm/orderly/useMarketsStream.js +57 -0
- package/esm/orderly/useMaxQty.d.ts +3 -0
- package/esm/orderly/useMaxQty.d.ts.map +1 -0
- package/esm/orderly/useMaxQty.js +114 -0
- package/esm/orderly/useOpenInterest.d.ts +2 -0
- package/esm/orderly/useOpenInterest.d.ts.map +1 -0
- package/esm/orderly/useOpenInterest.js +15 -0
- package/esm/orderly/useOrderEntry.d.ts +63 -0
- package/esm/orderly/useOrderEntry.d.ts.map +1 -0
- package/esm/orderly/useOrderEntry.js +504 -0
- package/esm/orderly/useOrderStream.d.ts +38 -0
- package/esm/orderly/useOrderStream.d.ts.map +1 -0
- package/esm/orderly/useOrderStream.js +180 -0
- package/esm/orderly/useOrderbookStream.d.ts +53 -0
- package/esm/orderly/useOrderbookStream.d.ts.map +1 -0
- package/esm/orderly/useOrderbookStream.js +309 -0
- package/esm/orderly/usePositionStream.d.ts +25 -0
- package/esm/orderly/usePositionStream.d.ts.map +1 -0
- package/esm/orderly/usePositionStream.js +232 -0
- package/esm/orderly/usePrivateDataObserver.d.ts +5 -0
- package/esm/orderly/usePrivateDataObserver.d.ts.map +1 -0
- package/esm/orderly/usePrivateDataObserver.js +126 -0
- package/esm/orderly/useSettleSubscription.d.ts +4 -0
- package/esm/orderly/useSettleSubscription.d.ts.map +1 -0
- package/esm/orderly/useSettleSubscription.js +20 -0
- package/esm/orderly/useSymbolPriceRange.d.ts +13 -0
- package/esm/orderly/useSymbolPriceRange.d.ts.map +1 -0
- package/esm/orderly/useSymbolPriceRange.js +39 -0
- package/esm/orderly/useSymbolsInfo.d.ts +2 -0
- package/esm/orderly/useSymbolsInfo.d.ts.map +1 -0
- package/esm/orderly/useSymbolsInfo.js +33 -0
- package/esm/orderly/useTickerStream.d.ts +3 -0
- package/esm/orderly/useTickerStream.d.ts.map +1 -0
- package/esm/orderly/useTickerStream.js +86 -0
- package/esm/orderly/useWalletSubscription.d.ts +4 -0
- package/esm/orderly/useWalletSubscription.d.ts.map +1 -0
- package/esm/orderly/useWalletSubscription.js +20 -0
- package/esm/orderly/useWithdraw.d.ts +14 -0
- package/esm/orderly/useWithdraw.d.ts.map +1 -0
- package/esm/orderly/useWithdraw.js +64 -0
- package/esm/orderlyContext.d.ts +17 -0
- package/esm/orderlyContext.d.ts.map +1 -0
- package/esm/orderlyContext.js +5 -0
- package/esm/services/dataCenter.d.ts +2 -0
- package/esm/services/dataCenter.d.ts.map +1 -0
- package/esm/services/dataCenter.js +13 -0
- package/esm/services/painter/backgroundPaint.d.ts +9 -0
- package/esm/services/painter/backgroundPaint.d.ts.map +1 -0
- package/esm/services/painter/backgroundPaint.js +41 -0
- package/esm/services/painter/basePaint.d.ts +90 -0
- package/esm/services/painter/basePaint.d.ts.map +1 -0
- package/esm/services/painter/basePaint.js +6 -0
- package/esm/services/painter/dataPaint.d.ts +16 -0
- package/esm/services/painter/dataPaint.d.ts.map +1 -0
- package/esm/services/painter/dataPaint.js +195 -0
- package/esm/services/painter/layout.config.d.ts +3 -0
- package/esm/services/painter/layout.config.d.ts.map +1 -0
- package/esm/services/painter/layout.config.js +52 -0
- package/esm/services/painter/painter.d.ts +12 -0
- package/esm/services/painter/painter.d.ts.map +1 -0
- package/esm/services/painter/painter.js +37 -0
- package/esm/services/painter/resource.d.ts +7 -0
- package/esm/services/painter/resource.d.ts.map +1 -0
- package/esm/services/painter/resource.js +15 -0
- package/esm/statusProvider.d.ts +8 -0
- package/esm/statusProvider.d.ts.map +1 -0
- package/esm/statusProvider.js +8 -0
- package/esm/unuse/apiPrefixMiddleware.d.ts +3 -0
- package/esm/unuse/apiPrefixMiddleware.d.ts.map +1 -0
- package/esm/unuse/apiPrefixMiddleware.js +29 -0
- package/esm/unuse/fn.d.ts +2 -0
- package/esm/unuse/fn.d.ts.map +1 -0
- package/esm/unuse/fn.js +6 -0
- package/esm/unuse/useBalance.d.ts +2 -0
- package/esm/unuse/useBalance.d.ts.map +1 -0
- package/esm/unuse/useBalance.js +12 -0
- package/esm/unuse/useFetures.d.ts +11 -0
- package/esm/unuse/useFetures.d.ts.map +1 -0
- package/esm/unuse/useFetures.js +39 -0
- package/esm/unuse/useRunOnce.d.ts +7 -0
- package/esm/unuse/useRunOnce.d.ts.map +1 -0
- package/esm/unuse/useRunOnce.js +17 -0
- package/esm/unuse/useSyncEnd.d.ts +2 -0
- package/esm/unuse/useSyncEnd.d.ts.map +1 -0
- package/esm/unuse/useSyncEnd.js +10 -0
- package/esm/unuse/useTokenInfo.d.ts +2 -0
- package/esm/unuse/useTokenInfo.d.ts.map +1 -0
- package/esm/unuse/useTokenInfo.js +20 -0
- package/esm/unuse/useUnsettlementPnL.d.ts +2 -0
- package/esm/unuse/useUnsettlementPnL.d.ts.map +1 -0
- package/esm/unuse/useUnsettlementPnL.js +20 -0
- package/esm/useAccount.d.ts +8 -0
- package/esm/useAccount.d.ts.map +1 -0
- package/esm/useAccount.js +59 -0
- package/esm/useAccountInstance.d.ts +3 -0
- package/esm/useAccountInstance.d.ts.map +1 -0
- package/esm/useAccountInstance.js +23 -0
- package/esm/useBoolean.d.ts +6 -0
- package/esm/useBoolean.d.ts.map +1 -0
- package/esm/useBoolean.js +8 -0
- package/esm/useConfig.d.ts +3 -0
- package/esm/useConfig.d.ts.map +1 -0
- package/esm/useConfig.js +12 -0
- package/esm/useEventEmitter.d.ts +3 -0
- package/esm/useEventEmitter.d.ts.map +1 -0
- package/esm/useEventEmitter.js +12 -0
- package/esm/useLazyQuery.d.ts +13 -0
- package/esm/useLazyQuery.d.ts.map +1 -0
- package/esm/useLazyQuery.js +35 -0
- package/esm/useLocalStorage.d.ts +2 -0
- package/esm/useLocalStorage.d.ts.map +1 -0
- package/esm/useLocalStorage.js +74 -0
- package/esm/useMediaQuery.d.ts +2 -0
- package/esm/useMediaQuery.d.ts.map +1 -0
- package/esm/useMediaQuery.js +36 -0
- package/esm/useMutation.d.ts +10 -0
- package/esm/useMutation.d.ts.map +1 -0
- package/esm/useMutation.js +64 -0
- package/esm/useObserve.d.ts +6 -0
- package/esm/useObserve.d.ts.map +1 -0
- package/esm/useObserve.js +8 -0
- package/esm/useParamsCheck.d.ts +4 -0
- package/esm/useParamsCheck.d.ts.map +1 -0
- package/esm/useParamsCheck.js +14 -0
- package/esm/usePoster.d.ts +14 -0
- package/esm/usePoster.d.ts.map +1 -0
- package/esm/usePoster.js +52 -0
- package/esm/usePreloadData.d.ts +5 -0
- package/esm/usePreloadData.d.ts.map +1 -0
- package/esm/usePreloadData.js +14 -0
- package/esm/usePrivateInfiniteQuery.d.ts +5 -0
- package/esm/usePrivateInfiniteQuery.d.ts.map +1 -0
- package/esm/usePrivateInfiniteQuery.js +25 -0
- package/esm/usePrivateQuery.d.ts +10 -0
- package/esm/usePrivateQuery.d.ts.map +1 -0
- package/esm/usePrivateQuery.js +26 -0
- package/esm/useQuery.d.ts +10 -0
- package/esm/useQuery.d.ts.map +1 -0
- package/esm/useQuery.js +20 -0
- package/esm/useSessionStorage.d.ts +2 -0
- package/esm/useSessionStorage.d.ts.map +1 -0
- package/esm/useSessionStorage.js +60 -0
- package/esm/useWS.d.ts +3 -0
- package/esm/useWS.d.ts.map +1 -0
- package/esm/useWS.js +51 -0
- package/esm/useWsStatus.d.ts +7 -0
- package/esm/useWsStatus.d.ts.map +1 -0
- package/esm/useWsStatus.js +41 -0
- package/esm/utils/createGetter.d.ts +4 -0
- package/esm/utils/createGetter.d.ts.map +1 -0
- package/esm/utils/createGetter.js +21 -0
- package/esm/utils/createOrder.d.ts +56 -0
- package/esm/utils/createOrder.d.ts.map +1 -0
- package/esm/utils/createOrder.js +324 -0
- package/esm/utils/fetcher.d.ts +6 -0
- package/esm/utils/fetcher.d.ts.map +1 -0
- package/esm/utils/fetcher.js +2 -0
- package/esm/utils/json.d.ts +2 -0
- package/esm/utils/json.d.ts.map +1 -0
- package/esm/utils/json.js +8 -0
- package/esm/utils/orderEntryHelper.d.ts +25 -0
- package/esm/utils/orderEntryHelper.d.ts.map +1 -0
- package/esm/utils/orderEntryHelper.js +242 -0
- package/esm/utils/parseHolding.d.ts +9 -0
- package/esm/utils/parseHolding.d.ts.map +1 -0
- package/esm/utils/parseHolding.js +21 -0
- package/esm/version.d.ts +10 -0
- package/esm/version.d.ts.map +1 -0
- package/esm/version.js +6 -0
- package/esm/walletConnectorContext.d.ts +30 -0
- package/esm/walletConnectorContext.d.ts.map +1 -0
- package/esm/walletConnectorContext.js +5 -0
- package/lib/configProvider.d.ts +17 -0
- package/lib/configProvider.d.ts.map +1 -0
- package/lib/configProvider.js +82 -0
- package/lib/dataProvider.d.ts +10 -0
- package/lib/dataProvider.d.ts.map +1 -0
- package/lib/dataProvider.js +34 -0
- package/lib/index.d.ts +33 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +88 -0
- package/lib/middleware/signatureMiddleware.d.ts +3 -0
- package/lib/middleware/signatureMiddleware.d.ts.map +1 -0
- package/lib/middleware/signatureMiddleware.js +36 -0
- package/lib/orderly/orderlyHooks.d.ts +30 -0
- package/lib/orderly/orderlyHooks.d.ts.map +1 -0
- package/lib/orderly/orderlyHooks.js +58 -0
- package/lib/orderly/useAccountInfo.d.ts +3 -0
- package/lib/orderly/useAccountInfo.d.ts.map +1 -0
- package/lib/orderly/useAccountInfo.js +8 -0
- package/lib/orderly/useChain.d.ts +6 -0
- package/lib/orderly/useChain.d.ts.map +1 -0
- package/lib/orderly/useChain.js +26 -0
- package/lib/orderly/useChains.d.ts +34 -0
- package/lib/orderly/useChains.d.ts.map +1 -0
- package/lib/orderly/useChains.js +166 -0
- package/lib/orderly/useCollateral.d.ts +16 -0
- package/lib/orderly/useCollateral.d.ts.map +1 -0
- package/lib/orderly/useCollateral.js +76 -0
- package/lib/orderly/useDeposit.d.ts +38 -0
- package/lib/orderly/useDeposit.d.ts.map +1 -0
- package/lib/orderly/useDeposit.js +274 -0
- package/lib/orderly/useFundingRate.d.ts +11 -0
- package/lib/orderly/useFundingRate.d.ts.map +1 -0
- package/lib/orderly/useFundingRate.js +44 -0
- package/lib/orderly/useFundingRates.d.ts +2 -0
- package/lib/orderly/useFundingRates.d.ts.map +1 -0
- package/lib/orderly/useFundingRates.js +25 -0
- package/lib/orderly/useHoldingStream.d.ts +7 -0
- package/lib/orderly/useHoldingStream.d.ts.map +1 -0
- package/lib/orderly/useHoldingStream.js +54 -0
- package/lib/orderly/useIndexPrice.d.ts +2 -0
- package/lib/orderly/useIndexPrice.d.ts.map +1 -0
- package/lib/orderly/useIndexPrice.js +24 -0
- package/lib/orderly/useLeverage.d.ts +2 -0
- package/lib/orderly/useLeverage.d.ts.map +1 -0
- package/lib/orderly/useLeverage.js +38 -0
- package/lib/orderly/useMarginRatio.d.ts +7 -0
- package/lib/orderly/useMarginRatio.d.ts.map +1 -0
- package/lib/orderly/useMarginRatio.js +45 -0
- package/lib/orderly/useMarkPrice.d.ts +4 -0
- package/lib/orderly/useMarkPrice.d.ts.map +1 -0
- package/lib/orderly/useMarkPrice.js +33 -0
- package/lib/orderly/useMarkPricesStream.d.ts +2 -0
- package/lib/orderly/useMarkPricesStream.d.ts.map +1 -0
- package/lib/orderly/useMarkPricesStream.js +33 -0
- package/lib/orderly/useMarketTradeStream.d.ts +9 -0
- package/lib/orderly/useMarketTradeStream.d.ts.map +1 -0
- package/lib/orderly/useMarketTradeStream.js +55 -0
- package/lib/orderly/useMarkets.d.ts +36 -0
- package/lib/orderly/useMarkets.d.ts.map +1 -0
- package/lib/orderly/useMarkets.js +244 -0
- package/lib/orderly/useMarketsStream.d.ts +5 -0
- package/lib/orderly/useMarketsStream.d.ts.map +1 -0
- package/lib/orderly/useMarketsStream.js +64 -0
- package/lib/orderly/useMaxQty.d.ts +3 -0
- package/lib/orderly/useMaxQty.d.ts.map +1 -0
- package/lib/orderly/useMaxQty.js +118 -0
- package/lib/orderly/useOpenInterest.d.ts +2 -0
- package/lib/orderly/useOpenInterest.d.ts.map +1 -0
- package/lib/orderly/useOpenInterest.js +22 -0
- package/lib/orderly/useOrderEntry.d.ts +63 -0
- package/lib/orderly/useOrderEntry.d.ts.map +1 -0
- package/lib/orderly/useOrderEntry.js +508 -0
- package/lib/orderly/useOrderStream.d.ts +38 -0
- package/lib/orderly/useOrderStream.d.ts.map +1 -0
- package/lib/orderly/useOrderStream.js +187 -0
- package/lib/orderly/useOrderbookStream.d.ts +53 -0
- package/lib/orderly/useOrderbookStream.d.ts.map +1 -0
- package/lib/orderly/useOrderbookStream.js +315 -0
- package/lib/orderly/usePositionStream.d.ts +25 -0
- package/lib/orderly/usePositionStream.d.ts.map +1 -0
- package/lib/orderly/usePositionStream.js +236 -0
- package/lib/orderly/usePrivateDataObserver.d.ts +5 -0
- package/lib/orderly/usePrivateDataObserver.d.ts.map +1 -0
- package/lib/orderly/usePrivateDataObserver.js +130 -0
- package/lib/orderly/useSettleSubscription.d.ts +4 -0
- package/lib/orderly/useSettleSubscription.d.ts.map +1 -0
- package/lib/orderly/useSettleSubscription.js +27 -0
- package/lib/orderly/useSymbolPriceRange.d.ts +13 -0
- package/lib/orderly/useSymbolPriceRange.d.ts.map +1 -0
- package/lib/orderly/useSymbolPriceRange.js +43 -0
- package/lib/orderly/useSymbolsInfo.d.ts +2 -0
- package/lib/orderly/useSymbolsInfo.d.ts.map +1 -0
- package/lib/orderly/useSymbolsInfo.js +37 -0
- package/lib/orderly/useTickerStream.d.ts +3 -0
- package/lib/orderly/useTickerStream.d.ts.map +1 -0
- package/lib/orderly/useTickerStream.js +90 -0
- package/lib/orderly/useWalletSubscription.d.ts +4 -0
- package/lib/orderly/useWalletSubscription.d.ts.map +1 -0
- package/lib/orderly/useWalletSubscription.js +27 -0
- package/lib/orderly/useWithdraw.d.ts +14 -0
- package/lib/orderly/useWithdraw.d.ts.map +1 -0
- package/lib/orderly/useWithdraw.js +68 -0
- package/lib/orderlyContext.d.ts +17 -0
- package/lib/orderlyContext.d.ts.map +1 -0
- package/lib/orderlyContext.js +8 -0
- package/lib/services/dataCenter.d.ts +2 -0
- package/lib/services/dataCenter.d.ts.map +1 -0
- package/lib/services/dataCenter.js +15 -0
- package/lib/services/painter/backgroundPaint.d.ts +9 -0
- package/lib/services/painter/backgroundPaint.d.ts.map +1 -0
- package/lib/services/painter/backgroundPaint.js +45 -0
- package/lib/services/painter/basePaint.d.ts +90 -0
- package/lib/services/painter/basePaint.d.ts.map +1 -0
- package/lib/services/painter/basePaint.js +10 -0
- package/lib/services/painter/dataPaint.d.ts +16 -0
- package/lib/services/painter/dataPaint.d.ts.map +1 -0
- package/lib/services/painter/dataPaint.js +199 -0
- package/lib/services/painter/layout.config.d.ts +3 -0
- package/lib/services/painter/layout.config.d.ts.map +1 -0
- package/lib/services/painter/layout.config.js +55 -0
- package/lib/services/painter/painter.d.ts +12 -0
- package/lib/services/painter/painter.d.ts.map +1 -0
- package/lib/services/painter/painter.js +41 -0
- package/lib/services/painter/resource.d.ts +7 -0
- package/lib/services/painter/resource.d.ts.map +1 -0
- package/lib/services/painter/resource.js +19 -0
- package/lib/statusProvider.d.ts +8 -0
- package/lib/statusProvider.d.ts.map +1 -0
- package/lib/statusProvider.js +12 -0
- package/lib/unuse/apiPrefixMiddleware.d.ts +3 -0
- package/lib/unuse/apiPrefixMiddleware.d.ts.map +1 -0
- package/lib/unuse/apiPrefixMiddleware.js +33 -0
- package/lib/unuse/fn.d.ts +2 -0
- package/lib/unuse/fn.d.ts.map +1 -0
- package/lib/unuse/fn.js +9 -0
- package/lib/unuse/useBalance.d.ts +2 -0
- package/lib/unuse/useBalance.d.ts.map +1 -0
- package/lib/unuse/useBalance.js +19 -0
- package/lib/unuse/useFetures.d.ts +11 -0
- package/lib/unuse/useFetures.d.ts.map +1 -0
- package/lib/unuse/useFetures.js +43 -0
- package/lib/unuse/useRunOnce.d.ts +7 -0
- package/lib/unuse/useRunOnce.d.ts.map +1 -0
- package/lib/unuse/useRunOnce.js +21 -0
- package/lib/unuse/useSyncEnd.d.ts +2 -0
- package/lib/unuse/useSyncEnd.d.ts.map +1 -0
- package/lib/unuse/useSyncEnd.js +14 -0
- package/lib/unuse/useTokenInfo.d.ts +2 -0
- package/lib/unuse/useTokenInfo.d.ts.map +1 -0
- package/lib/unuse/useTokenInfo.js +24 -0
- package/lib/unuse/useUnsettlementPnL.d.ts +2 -0
- package/lib/unuse/useUnsettlementPnL.d.ts.map +1 -0
- package/lib/unuse/useUnsettlementPnL.js +24 -0
- package/lib/useAccount.d.ts +8 -0
- package/lib/useAccount.d.ts.map +1 -0
- package/lib/useAccount.js +63 -0
- package/lib/useAccountInstance.d.ts +3 -0
- package/lib/useAccountInstance.d.ts.map +1 -0
- package/lib/useAccountInstance.js +30 -0
- package/lib/useBoolean.d.ts +6 -0
- package/lib/useBoolean.d.ts.map +1 -0
- package/lib/useBoolean.js +12 -0
- package/lib/useConfig.d.ts +3 -0
- package/lib/useConfig.d.ts.map +1 -0
- package/lib/useConfig.js +16 -0
- package/lib/useEventEmitter.d.ts +3 -0
- package/lib/useEventEmitter.d.ts.map +1 -0
- package/lib/useEventEmitter.js +19 -0
- package/lib/useLazyQuery.d.ts +13 -0
- package/lib/useLazyQuery.d.ts.map +1 -0
- package/lib/useLazyQuery.js +42 -0
- package/lib/useLocalStorage.d.ts +2 -0
- package/lib/useLocalStorage.d.ts.map +1 -0
- package/lib/useLocalStorage.js +78 -0
- package/lib/useMediaQuery.d.ts +2 -0
- package/lib/useMediaQuery.d.ts.map +1 -0
- package/lib/useMediaQuery.js +40 -0
- package/lib/useMutation.d.ts +10 -0
- package/lib/useMutation.d.ts.map +1 -0
- package/lib/useMutation.js +71 -0
- package/lib/useObserve.d.ts +6 -0
- package/lib/useObserve.d.ts.map +1 -0
- package/lib/useObserve.js +12 -0
- package/lib/useParamsCheck.d.ts +4 -0
- package/lib/useParamsCheck.d.ts.map +1 -0
- package/lib/useParamsCheck.js +18 -0
- package/lib/usePoster.d.ts +14 -0
- package/lib/usePoster.d.ts.map +1 -0
- package/lib/usePoster.js +56 -0
- package/lib/usePreloadData.d.ts +5 -0
- package/lib/usePreloadData.d.ts.map +1 -0
- package/lib/usePreloadData.js +18 -0
- package/lib/usePrivateInfiniteQuery.d.ts +5 -0
- package/lib/usePrivateInfiniteQuery.d.ts.map +1 -0
- package/lib/usePrivateInfiniteQuery.js +32 -0
- package/lib/usePrivateQuery.d.ts +10 -0
- package/lib/usePrivateQuery.d.ts.map +1 -0
- package/lib/usePrivateQuery.js +33 -0
- package/lib/useQuery.d.ts +10 -0
- package/lib/useQuery.d.ts.map +1 -0
- package/lib/useQuery.js +27 -0
- package/lib/useSessionStorage.d.ts +2 -0
- package/lib/useSessionStorage.d.ts.map +1 -0
- package/lib/useSessionStorage.js +64 -0
- package/lib/useWS.d.ts +3 -0
- package/lib/useWS.d.ts.map +1 -0
- package/lib/useWS.js +58 -0
- package/lib/useWsStatus.d.ts +7 -0
- package/lib/useWsStatus.d.ts.map +1 -0
- package/lib/useWsStatus.js +45 -0
- package/lib/utils/createGetter.d.ts +4 -0
- package/lib/utils/createGetter.d.ts.map +1 -0
- package/lib/utils/createGetter.js +25 -0
- package/lib/utils/createOrder.d.ts +56 -0
- package/lib/utils/createOrder.d.ts.map +1 -0
- package/lib/utils/createOrder.js +337 -0
- package/lib/utils/fetcher.d.ts +6 -0
- package/lib/utils/fetcher.d.ts.map +1 -0
- package/lib/utils/fetcher.js +6 -0
- package/lib/utils/json.d.ts +2 -0
- package/lib/utils/json.d.ts.map +1 -0
- package/lib/utils/json.js +12 -0
- package/lib/utils/orderEntryHelper.d.ts +25 -0
- package/lib/utils/orderEntryHelper.d.ts.map +1 -0
- package/lib/utils/orderEntryHelper.js +250 -0
- package/lib/utils/parseHolding.d.ts +9 -0
- package/lib/utils/parseHolding.d.ts.map +1 -0
- package/lib/utils/parseHolding.js +25 -0
- package/lib/version.d.ts +10 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +8 -0
- package/lib/walletConnectorContext.d.ts +30 -0
- package/lib/walletConnectorContext.d.ts.map +1 -0
- package/lib/walletConnectorContext.js +9 -0
- package/package.json +18 -13
- package/dist/index.d.mts +0 -548
- package/dist/index.d.ts +0 -548
- package/dist/index.js +0 -5412
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -5329
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import useSWRMutation from "swr/mutation";
|
|
2
|
+
import { mutate } from "@orderly.network/net";
|
|
3
|
+
import { useAccountInstance } from "./useAccountInstance";
|
|
4
|
+
import { useConfig } from "./useConfig";
|
|
5
|
+
const fetcher = (url, options) => {
|
|
6
|
+
const init = {
|
|
7
|
+
method: options.arg.method,
|
|
8
|
+
headers: {
|
|
9
|
+
...options.arg.signature,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
if (options.arg.data) {
|
|
13
|
+
init.body = JSON.stringify(options.arg.data);
|
|
14
|
+
}
|
|
15
|
+
if (typeof options.arg.params === "object" &&
|
|
16
|
+
Object.keys(options.arg.params).length) {
|
|
17
|
+
let search = new URLSearchParams(options.arg.params);
|
|
18
|
+
url = `${url}?${search.toString()}`;
|
|
19
|
+
}
|
|
20
|
+
return mutate(url, init);
|
|
21
|
+
};
|
|
22
|
+
export const useMutation = (url, method = "POST", options) => {
|
|
23
|
+
const apiBaseUrl = useConfig("apiBaseUrl");
|
|
24
|
+
let fullUrl = url;
|
|
25
|
+
if (!url.startsWith("http")) {
|
|
26
|
+
fullUrl = `${apiBaseUrl}${url}`;
|
|
27
|
+
}
|
|
28
|
+
const account = useAccountInstance();
|
|
29
|
+
const signer = account.signer;
|
|
30
|
+
const { trigger, data, error, reset, isMutating } = useSWRMutation(fullUrl,
|
|
31
|
+
// method === "POST" ? fetcher : deleteFetcher,
|
|
32
|
+
fetcher, options);
|
|
33
|
+
const mutation = async (data, params, options) => {
|
|
34
|
+
let newUrl = url;
|
|
35
|
+
if (typeof params === "object" && Object.keys(params).length) {
|
|
36
|
+
let search = new URLSearchParams(params);
|
|
37
|
+
newUrl = `${url}?${search.toString()}`;
|
|
38
|
+
}
|
|
39
|
+
const payload = {
|
|
40
|
+
method,
|
|
41
|
+
url: newUrl,
|
|
42
|
+
data,
|
|
43
|
+
};
|
|
44
|
+
const signature = await signer.sign(payload);
|
|
45
|
+
return trigger({
|
|
46
|
+
data,
|
|
47
|
+
params,
|
|
48
|
+
method,
|
|
49
|
+
signature: {
|
|
50
|
+
...signature,
|
|
51
|
+
"orderly-account-id": account.accountId,
|
|
52
|
+
},
|
|
53
|
+
}, options);
|
|
54
|
+
};
|
|
55
|
+
return [
|
|
56
|
+
mutation,
|
|
57
|
+
{
|
|
58
|
+
data,
|
|
59
|
+
error,
|
|
60
|
+
reset,
|
|
61
|
+
isMutating,
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useObserve.d.ts","sourceRoot":"","sources":["../src/useObserve.ts"],"names":[],"mappings":"AAEA,oBAAY,QAAQ;IAClB,MAAM,WAAW;IACjB,SAAS,cAAc;CACxB;AAED,eAAO,MAAM,UAAU,WAChB,MAAM,wCAGQ,IAAI,CAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useParamsCheck.d.ts","sourceRoot":"","sources":["../src/useParamsCheck.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,WAAY;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,SAc3D,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export const useParamsCheck = (params) => {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (!params.brokerId || params.brokerId === "orderly") {
|
|
5
|
+
console.warn("WARNING:" +
|
|
6
|
+
"\n" +
|
|
7
|
+
"========================" +
|
|
8
|
+
"\n" +
|
|
9
|
+
"[OrderlyConfigProvider]: please provide your brokerId" +
|
|
10
|
+
"\n" +
|
|
11
|
+
"========================");
|
|
12
|
+
}
|
|
13
|
+
}, [params.brokerId]);
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type drawOptions } from "./services/painter/basePaint";
|
|
2
|
+
export { type drawOptions } from "./services/painter/basePaint";
|
|
3
|
+
/**
|
|
4
|
+
* Generates a poster image based on position information. You can set the size, background color, font color, font size, and content position of the poster.
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare const usePoster: (trage: HTMLCanvasElement, options: drawOptions) => {
|
|
8
|
+
readonly error: Error | null;
|
|
9
|
+
/**
|
|
10
|
+
* Converts the poster to a data URL
|
|
11
|
+
*/
|
|
12
|
+
readonly toDataURL: (type?: string, encoderOptions?: number) => string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=usePoster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePoster.d.ts","sourceRoot":"","sources":["../src/usePoster.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,SAAS,UAIb,iBAAiB,WAIf,WAAW;;IAyClB;;OAEG;;CAGN,CAAC"}
|
package/esm/usePoster.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { mergeDeepRight } from "ramda";
|
|
3
|
+
import { PosterPainter } from "./services/painter/painter";
|
|
4
|
+
import { defaultLayoutConfig } from "./services/painter/layout.config";
|
|
5
|
+
/**
|
|
6
|
+
* Generates a poster image based on position information. You can set the size, background color, font color, font size, and content position of the poster.
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export const usePoster = (
|
|
10
|
+
/**
|
|
11
|
+
* The canvas element to draw the poster on
|
|
12
|
+
*/
|
|
13
|
+
trage,
|
|
14
|
+
/**
|
|
15
|
+
* The options to draw the poster
|
|
16
|
+
*/
|
|
17
|
+
options) => {
|
|
18
|
+
const [error, setError] = useState(null);
|
|
19
|
+
const painterRef = useRef(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
// Create the painter instance
|
|
22
|
+
if (trage && !painterRef.current) {
|
|
23
|
+
painterRef.current = new PosterPainter(trage);
|
|
24
|
+
painterRef.current.draw(mergeDeepRight({ layout: defaultLayoutConfig }, options));
|
|
25
|
+
}
|
|
26
|
+
}, [trage]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (painterRef.current) {
|
|
29
|
+
painterRef.current.draw(mergeDeepRight({ layout: defaultLayoutConfig }, options));
|
|
30
|
+
}
|
|
31
|
+
}, [options]);
|
|
32
|
+
// const draw = (dataSource: any) => {};
|
|
33
|
+
// const clear = () => {};
|
|
34
|
+
const toDataURL = (
|
|
35
|
+
/**
|
|
36
|
+
* The image MIME type
|
|
37
|
+
*/
|
|
38
|
+
type = "image/png",
|
|
39
|
+
/**
|
|
40
|
+
* The quality of the image
|
|
41
|
+
*/
|
|
42
|
+
encoderOptions = 1.0) => {
|
|
43
|
+
return trage.toDataURL(type, encoderOptions);
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
error,
|
|
47
|
+
/**
|
|
48
|
+
* Converts the poster to a data URL
|
|
49
|
+
*/
|
|
50
|
+
toDataURL,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePreloadData.d.ts","sourceRoot":"","sources":["../src/usePreloadData.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc;;;CAgB1B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useQuery } from ".";
|
|
3
|
+
export const usePreLoadData = () => {
|
|
4
|
+
const { error: tokenError, data: tokenData } = useQuery("https://api-evm.orderly.org/v1/public/token", {
|
|
5
|
+
revalidateOnFocus: false,
|
|
6
|
+
});
|
|
7
|
+
const isDone = useMemo(() => {
|
|
8
|
+
return !!tokenData;
|
|
9
|
+
}, [tokenData]);
|
|
10
|
+
return {
|
|
11
|
+
error: tokenError,
|
|
12
|
+
done: isDone,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type SWRInfiniteKeyLoader, type SWRInfiniteConfiguration } from "swr/infinite";
|
|
2
|
+
export declare const usePrivateInfiniteQuery: (getKey: SWRInfiniteKeyLoader, options?: (SWRInfiniteConfiguration<any, any, import("swr/_internal").BareFetcher<any>> & {
|
|
3
|
+
formatter?: ((data: any) => any) | undefined;
|
|
4
|
+
}) | undefined) => import("swr/infinite").SWRInfiniteResponse<any, any>;
|
|
5
|
+
//# sourceMappingURL=usePrivateInfiniteQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrivateInfiniteQuery.d.ts","sourceRoot":"","sources":["../src/usePrivateInfiniteQuery.ts"],"names":[],"mappings":"AAAA,OAAuB,EACrB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC9B,MAAM,cAAc,CAAC;AAMtB,eAAO,MAAM,uBAAuB,WAC1B,oBAAoB;wBAEP,GAAG,KAAK,GAAG;uEA4BjC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import useSWRInfinite from "swr/infinite";
|
|
2
|
+
import { signatureMiddleware } from "./middleware/signatureMiddleware";
|
|
3
|
+
import { get } from "@orderly.network/net";
|
|
4
|
+
import { useAccount } from "./useAccount";
|
|
5
|
+
import { AccountStatusEnum } from "@orderly.network/types";
|
|
6
|
+
export const usePrivateInfiniteQuery = (getKey, options) => {
|
|
7
|
+
const { formatter, ...restOptions } = options || {};
|
|
8
|
+
const account = useAccount();
|
|
9
|
+
const middleware = Array.isArray(restOptions?.use)
|
|
10
|
+
? restOptions?.use ?? []
|
|
11
|
+
: [];
|
|
12
|
+
const result = useSWRInfinite((pageIndex, previousPageData) => {
|
|
13
|
+
const queryKey = getKey(pageIndex, previousPageData);
|
|
14
|
+
if (account.state.status < AccountStatusEnum.EnableTrading || !queryKey) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return [queryKey, account.state.accountId];
|
|
18
|
+
}, (url, init) => {
|
|
19
|
+
return get(url, init, formatter);
|
|
20
|
+
}, {
|
|
21
|
+
...restOptions,
|
|
22
|
+
use: [signatureMiddleware, ...middleware],
|
|
23
|
+
});
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SWRResponse } from "swr";
|
|
2
|
+
import { useQueryOptions } from "./utils/fetcher";
|
|
3
|
+
/**
|
|
4
|
+
* usePrivateQuery
|
|
5
|
+
* @description for private api
|
|
6
|
+
* @param query
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
export declare const usePrivateQuery: <T>(query: string, options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
|
|
10
|
+
//# sourceMappingURL=usePrivateQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrivateQuery.d.ts","sourceRoot":"","sources":["../src/usePrivateQuery.ts"],"names":[],"mappings":"AAAA,OAAe,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAE1C,OAAO,EAAW,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI3D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,aACnB,MAAM,uEAsBd,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
import { signatureMiddleware } from "./middleware/signatureMiddleware";
|
|
3
|
+
import { fetcher } from "./utils/fetcher";
|
|
4
|
+
import { useAccount } from "./useAccount";
|
|
5
|
+
import { AccountStatusEnum } from "@orderly.network/types";
|
|
6
|
+
/**
|
|
7
|
+
* usePrivateQuery
|
|
8
|
+
* @description for private api
|
|
9
|
+
* @param query
|
|
10
|
+
* @param options
|
|
11
|
+
*/
|
|
12
|
+
export const usePrivateQuery = (query, options) => {
|
|
13
|
+
const { formatter, ...swrOptions } = options || {};
|
|
14
|
+
const account = useAccount();
|
|
15
|
+
const middleware = Array.isArray(options?.use) ? options?.use ?? [] : [];
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
return useSWR(() => account.state.status >= AccountStatusEnum.EnableTrading
|
|
18
|
+
? [query, account.state.accountId]
|
|
19
|
+
: null, (url, init) => {
|
|
20
|
+
return fetcher(url, init, { formatter });
|
|
21
|
+
}, {
|
|
22
|
+
...swrOptions,
|
|
23
|
+
use: [signatureMiddleware, ...middleware],
|
|
24
|
+
onError: (err) => { },
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import useSWR, { SWRResponse } from "swr";
|
|
2
|
+
import { useQueryOptions } from "./utils/fetcher";
|
|
3
|
+
/**
|
|
4
|
+
* useQuery
|
|
5
|
+
* @description for public api
|
|
6
|
+
* @param query
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
export declare const useQuery: <T>(query: Parameters<typeof useSWR>["0"], options?: useQueryOptions<T> | undefined) => SWRResponse<T, any, any>;
|
|
10
|
+
//# sourceMappingURL=useQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../src/useQuery.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAW,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,aACZ,WAAW,aAAa,CAAC,CAAC,GAAG,CAAC,uEAmBtC,CAAC"}
|
package/esm/useQuery.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
import { fetcher } from "./utils/fetcher";
|
|
3
|
+
import { useConfig } from "./useConfig";
|
|
4
|
+
/**
|
|
5
|
+
* useQuery
|
|
6
|
+
* @description for public api
|
|
7
|
+
* @param query
|
|
8
|
+
* @param options
|
|
9
|
+
*/
|
|
10
|
+
export const useQuery = (query, options) => {
|
|
11
|
+
const apiBaseUrl = useConfig("apiBaseUrl");
|
|
12
|
+
const { formatter, ...swrOptions } = options || {};
|
|
13
|
+
if (typeof apiBaseUrl === "undefined") {
|
|
14
|
+
throw new Error("please add OrderlyConfigProvider to your app");
|
|
15
|
+
}
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
return useSWR(query, (url, init) => fetcher(url.startsWith("http") ? url : `${apiBaseUrl}${url}`, init, {
|
|
18
|
+
formatter,
|
|
19
|
+
}), swrOptions);
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSessionStorage.d.ts","sourceRoot":"","sources":["../src/useSessionStorage.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,GACd,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC,CAuE1B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { parseJSON } from "./utils/json";
|
|
3
|
+
export function useSessionStorage(key, initialValue) {
|
|
4
|
+
// Get from session storage then
|
|
5
|
+
// parse stored json or return initialValue
|
|
6
|
+
const readValue = useCallback(() => {
|
|
7
|
+
// Prevent build error "window is undefined" but keep keep working
|
|
8
|
+
if (typeof window === "undefined") {
|
|
9
|
+
return initialValue;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const item = window.sessionStorage.getItem(key);
|
|
13
|
+
return item ? parseJSON(item) : initialValue;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.warn(`Error reading sessionStorage key “${key}”:`, error);
|
|
17
|
+
return initialValue;
|
|
18
|
+
}
|
|
19
|
+
}, [initialValue, key]);
|
|
20
|
+
const [storedValue, setStoredValue] = useState(readValue);
|
|
21
|
+
const setValue = (value) => {
|
|
22
|
+
// Prevent build error "window is undefined" but keeps working
|
|
23
|
+
if (typeof window == "undefined") {
|
|
24
|
+
console.warn(`Tried setting sessionStorage key “${key}” even though environment is not a client`);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
// Allow value to be a function so we have the same API as useState
|
|
28
|
+
const newValue = value instanceof Function ? value(storedValue) : value;
|
|
29
|
+
// Save to session storage
|
|
30
|
+
window.sessionStorage.setItem(key, JSON.stringify(newValue));
|
|
31
|
+
// Save state
|
|
32
|
+
setStoredValue(newValue);
|
|
33
|
+
// We dispatch a custom event so every useSessionStorage hook are notified
|
|
34
|
+
// window.dispatchEvent(new Event("session-storage"));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.warn(`Error setting sessionStorage key “${key}”:`, error);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setStoredValue(readValue());
|
|
42
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
+
}, []);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (typeof window == "undefined") {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
window.addEventListener("storage", handleStorageChange);
|
|
49
|
+
return () => {
|
|
50
|
+
window.removeEventListener("storage", handleStorageChange);
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
const handleStorageChange = useCallback((event) => {
|
|
54
|
+
if (event?.key && event.key !== key) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setStoredValue(readValue());
|
|
58
|
+
}, [key, readValue]);
|
|
59
|
+
return [storedValue, setValue];
|
|
60
|
+
}
|
package/esm/useWS.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWS.d.ts","sourceRoot":"","sources":["../src/useWS.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAO1C,eAAO,MAAM,KAAK,UAyDjB,CAAC"}
|
package/esm/useWS.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { Account, SimpleDI } from "@orderly.network/core";
|
|
3
|
+
import { WS } from "@orderly.network/net";
|
|
4
|
+
import useConstant from "use-constant";
|
|
5
|
+
import { AccountStatusEnum } from "@orderly.network/types";
|
|
6
|
+
import { OrderlyContext } from "./orderlyContext";
|
|
7
|
+
const WS_NAME = "nativeWebsocketClient";
|
|
8
|
+
export const useWS = () => {
|
|
9
|
+
const { configStore } = useContext(OrderlyContext);
|
|
10
|
+
// const prevAccountState = useRef<AccountState | null>(null);
|
|
11
|
+
const ws = useConstant(() => {
|
|
12
|
+
let websocketClient = SimpleDI.get(WS_NAME);
|
|
13
|
+
const account = SimpleDI.get(Account.instanceName);
|
|
14
|
+
if (!websocketClient) {
|
|
15
|
+
websocketClient = new WS({
|
|
16
|
+
networkId: configStore.get("networkId"),
|
|
17
|
+
publicUrl: configStore.get("publicWsUrl"),
|
|
18
|
+
privateUrl: configStore.get("privateWsUrl"),
|
|
19
|
+
onSigntureRequest: async (accountId) => {
|
|
20
|
+
const signer = account.signer;
|
|
21
|
+
const timestamp = new Date().getTime();
|
|
22
|
+
const result = await signer.signText(timestamp.toString());
|
|
23
|
+
return { ...result, timestamp };
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
// if user login, open the private websocket
|
|
27
|
+
if (account.stateValue.status === AccountStatusEnum.EnableTrading &&
|
|
28
|
+
account.stateValue.accountId) {
|
|
29
|
+
websocketClient.openPrivate(account.stateValue.accountId);
|
|
30
|
+
}
|
|
31
|
+
// open the pirvate websocket when user login
|
|
32
|
+
account.on("change:status", (nextState) => {
|
|
33
|
+
if (nextState.status === AccountStatusEnum.EnableTrading &&
|
|
34
|
+
nextState.accountId) {
|
|
35
|
+
websocketClient.openPrivate(nextState.accountId);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
websocketClient.closePrivate(1000, "switch account");
|
|
39
|
+
}
|
|
40
|
+
// prevAccountState.current = nextState;
|
|
41
|
+
});
|
|
42
|
+
if (typeof window !== "undefined") {
|
|
43
|
+
window["__Orderly_WS"] = websocketClient;
|
|
44
|
+
}
|
|
45
|
+
SimpleDI.registerByName(WS_NAME, websocketClient);
|
|
46
|
+
}
|
|
47
|
+
return websocketClient;
|
|
48
|
+
});
|
|
49
|
+
// auto open private when user login;
|
|
50
|
+
return ws;
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWsStatus.d.ts","sourceRoot":"","sources":["../src/useWsStatus.ts"],"names":[],"mappings":"AAGA,oBAAY,eAAe;IACzB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;CAC9B;AAED,wBAAgB,WAAW,oBAsC1B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useWS } from "./useWS";
|
|
3
|
+
export var WsNetworkStatus;
|
|
4
|
+
(function (WsNetworkStatus) {
|
|
5
|
+
WsNetworkStatus["Connected"] = "connected";
|
|
6
|
+
WsNetworkStatus["Unstable"] = "unstable";
|
|
7
|
+
WsNetworkStatus["Disconnected"] = "disconnected";
|
|
8
|
+
})(WsNetworkStatus || (WsNetworkStatus = {}));
|
|
9
|
+
export function useWsStatus() {
|
|
10
|
+
const ws = useWS();
|
|
11
|
+
const [wsStatus, setWsStatus] = useState(ws.client.public.readyState
|
|
12
|
+
? WsNetworkStatus.Connected
|
|
13
|
+
: WsNetworkStatus.Disconnected);
|
|
14
|
+
const connectCount = useRef(0);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
ws.on("status:change", (status) => {
|
|
17
|
+
console.log("status:change", status);
|
|
18
|
+
const { type, isPrivate } = status;
|
|
19
|
+
if (!isPrivate) {
|
|
20
|
+
switch (type) {
|
|
21
|
+
case "open":
|
|
22
|
+
connectCount.current = 0;
|
|
23
|
+
setWsStatus(WsNetworkStatus.Connected);
|
|
24
|
+
break;
|
|
25
|
+
case "close":
|
|
26
|
+
connectCount.current = 0;
|
|
27
|
+
setWsStatus(WsNetworkStatus.Disconnected);
|
|
28
|
+
break;
|
|
29
|
+
case "reconnecting":
|
|
30
|
+
connectCount.current++;
|
|
31
|
+
if (connectCount.current >= 3) {
|
|
32
|
+
setWsStatus(WsNetworkStatus.Unstable);
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return () => ws.off("websocket:status", () => { });
|
|
39
|
+
}, []);
|
|
40
|
+
return wsStatus;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGetter.d.ts","sourceRoot":"","sources":["../../src/utils/createGetter.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GAAG,CAAC,GAAG,CAAC,CAAC;AAGzB,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,EAC1B,IAAI,EAAE,CAAC,EAAE,KAAK,GAAE,WAAe,OAsBhC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function createGetter(data, depth = 2) {
|
|
2
|
+
return new Proxy(data || {}, {
|
|
3
|
+
get(target, property, receiver) {
|
|
4
|
+
if (depth === 1) {
|
|
5
|
+
return (defaultValue) => {
|
|
6
|
+
if (!target)
|
|
7
|
+
return defaultValue;
|
|
8
|
+
return target[property] ?? defaultValue;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return (key, defaultValue) => {
|
|
12
|
+
if (key) {
|
|
13
|
+
return target[property]?.[key] ?? defaultValue;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return target[property];
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { OrderType, type API, OrderEntity } from "@orderly.network/types";
|
|
2
|
+
export type VerifyResult = {
|
|
3
|
+
[P in keyof OrderEntity]?: {
|
|
4
|
+
type: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export type OrderFormEntity = Pick<OrderEntity, "order_price" | "order_quantity" | "total">;
|
|
9
|
+
type ValuesDepConfig = {
|
|
10
|
+
symbol: API.SymbolExt;
|
|
11
|
+
maxQty: number;
|
|
12
|
+
markPrice: number;
|
|
13
|
+
};
|
|
14
|
+
export interface OrderCreator {
|
|
15
|
+
create: (values: OrderEntity, configs: ValuesDepConfig) => OrderEntity;
|
|
16
|
+
validate: (values: OrderFormEntity, configs: ValuesDepConfig) => Promise<VerifyResult>;
|
|
17
|
+
}
|
|
18
|
+
export declare abstract class BaseOrderCreator implements OrderCreator {
|
|
19
|
+
abstract create(values: OrderEntity, config: ValuesDepConfig): OrderEntity;
|
|
20
|
+
abstract validate(values: OrderFormEntity, config: ValuesDepConfig): Promise<VerifyResult>;
|
|
21
|
+
baseOrder(data: OrderEntity): OrderEntity;
|
|
22
|
+
baseValidate(values: OrderFormEntity, configs: ValuesDepConfig): Promise<VerifyResult>;
|
|
23
|
+
fixOrderQuantity(order: Partial<OrderEntity>, config: ValuesDepConfig): OrderEntity;
|
|
24
|
+
}
|
|
25
|
+
export declare class LimitOrderCreator extends BaseOrderCreator {
|
|
26
|
+
create(values: OrderEntity, config: ValuesDepConfig): OrderEntity;
|
|
27
|
+
validate(values: OrderFormEntity, config: ValuesDepConfig): Promise<VerifyResult>;
|
|
28
|
+
}
|
|
29
|
+
export declare class MarketOrderCreator extends BaseOrderCreator {
|
|
30
|
+
create(values: OrderEntity): OrderEntity;
|
|
31
|
+
validate(values: OrderFormEntity, configs: ValuesDepConfig): Promise<VerifyResult>;
|
|
32
|
+
}
|
|
33
|
+
export declare class PostOnlyOrderCreator extends LimitOrderCreator {
|
|
34
|
+
}
|
|
35
|
+
export declare class FOKOrderCreator extends LimitOrderCreator {
|
|
36
|
+
}
|
|
37
|
+
export declare class IOCOrderCreator extends LimitOrderCreator {
|
|
38
|
+
}
|
|
39
|
+
export declare class StopLimitOrderCreator extends LimitOrderCreator {
|
|
40
|
+
create(values: OrderEntity, config: ValuesDepConfig): OrderEntity;
|
|
41
|
+
validate(values: OrderFormEntity, config: ValuesDepConfig): Promise<VerifyResult>;
|
|
42
|
+
}
|
|
43
|
+
export declare class StopMarketOrderCreator extends LimitOrderCreator {
|
|
44
|
+
create(values: OrderEntity, _: ValuesDepConfig): OrderEntity;
|
|
45
|
+
validate(values: OrderFormEntity, config: ValuesDepConfig): Promise<VerifyResult>;
|
|
46
|
+
}
|
|
47
|
+
export declare class GeneralOrderCreator extends BaseOrderCreator {
|
|
48
|
+
create(data: OrderEntity): OrderEntity;
|
|
49
|
+
validate(values: OrderFormEntity, configs: ValuesDepConfig): Promise<VerifyResult>;
|
|
50
|
+
}
|
|
51
|
+
export declare const availableOrderTypes: OrderType[];
|
|
52
|
+
export declare class OrderFactory {
|
|
53
|
+
static create(type: OrderType): OrderCreator | null;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=createOrder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOrder.d.ts","sourceRoot":"","sources":["../../src/utils/createOrder.ts"],"names":[],"mappings":"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"}
|