@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.
Files changed (475) hide show
  1. package/esm/configProvider.d.ts +17 -0
  2. package/esm/configProvider.d.ts.map +1 -0
  3. package/esm/configProvider.js +54 -0
  4. package/esm/dataProvider.d.ts +10 -0
  5. package/esm/dataProvider.d.ts.map +1 -0
  6. package/esm/dataProvider.js +29 -0
  7. package/esm/index.d.ts +33 -0
  8. package/esm/index.d.ts.map +1 -0
  9. package/esm/index.js +30 -0
  10. package/esm/middleware/signatureMiddleware.d.ts +3 -0
  11. package/esm/middleware/signatureMiddleware.d.ts.map +1 -0
  12. package/esm/middleware/signatureMiddleware.js +32 -0
  13. package/esm/orderly/orderlyHooks.d.ts +30 -0
  14. package/esm/orderly/orderlyHooks.d.ts.map +1 -0
  15. package/esm/orderly/orderlyHooks.js +27 -0
  16. package/esm/orderly/useAccountInfo.d.ts +3 -0
  17. package/esm/orderly/useAccountInfo.d.ts.map +1 -0
  18. package/esm/orderly/useAccountInfo.js +4 -0
  19. package/esm/orderly/useChain.d.ts +6 -0
  20. package/esm/orderly/useChain.d.ts.map +1 -0
  21. package/esm/orderly/useChain.js +22 -0
  22. package/esm/orderly/useChains.d.ts +34 -0
  23. package/esm/orderly/useChains.d.ts.map +1 -0
  24. package/esm/orderly/useChains.js +159 -0
  25. package/esm/orderly/useCollateral.d.ts +16 -0
  26. package/esm/orderly/useCollateral.d.ts.map +1 -0
  27. package/esm/orderly/useCollateral.js +72 -0
  28. package/esm/orderly/useDeposit.d.ts +38 -0
  29. package/esm/orderly/useDeposit.d.ts.map +1 -0
  30. package/esm/orderly/useDeposit.js +270 -0
  31. package/esm/orderly/useFundingRate.d.ts +11 -0
  32. package/esm/orderly/useFundingRate.d.ts.map +1 -0
  33. package/esm/orderly/useFundingRate.js +40 -0
  34. package/esm/orderly/useFundingRates.d.ts +2 -0
  35. package/esm/orderly/useFundingRates.d.ts.map +1 -0
  36. package/esm/orderly/useFundingRates.js +21 -0
  37. package/esm/orderly/useHoldingStream.d.ts +7 -0
  38. package/esm/orderly/useHoldingStream.d.ts.map +1 -0
  39. package/esm/orderly/useHoldingStream.js +47 -0
  40. package/esm/orderly/useIndexPrice.d.ts +2 -0
  41. package/esm/orderly/useIndexPrice.d.ts.map +1 -0
  42. package/esm/orderly/useIndexPrice.js +17 -0
  43. package/esm/orderly/useLeverage.d.ts +2 -0
  44. package/esm/orderly/useLeverage.d.ts.map +1 -0
  45. package/esm/orderly/useLeverage.js +34 -0
  46. package/esm/orderly/useMarginRatio.d.ts +7 -0
  47. package/esm/orderly/useMarginRatio.d.ts.map +1 -0
  48. package/esm/orderly/useMarginRatio.js +41 -0
  49. package/esm/orderly/useMarkPrice.d.ts +4 -0
  50. package/esm/orderly/useMarkPrice.d.ts.map +1 -0
  51. package/esm/orderly/useMarkPrice.js +29 -0
  52. package/esm/orderly/useMarkPricesStream.d.ts +2 -0
  53. package/esm/orderly/useMarkPricesStream.d.ts.map +1 -0
  54. package/esm/orderly/useMarkPricesStream.js +26 -0
  55. package/esm/orderly/useMarketTradeStream.d.ts +9 -0
  56. package/esm/orderly/useMarketTradeStream.d.ts.map +1 -0
  57. package/esm/orderly/useMarketTradeStream.js +51 -0
  58. package/esm/orderly/useMarkets.d.ts +36 -0
  59. package/esm/orderly/useMarkets.d.ts.map +1 -0
  60. package/esm/orderly/useMarkets.js +240 -0
  61. package/esm/orderly/useMarketsStream.d.ts +5 -0
  62. package/esm/orderly/useMarketsStream.d.ts.map +1 -0
  63. package/esm/orderly/useMarketsStream.js +57 -0
  64. package/esm/orderly/useMaxQty.d.ts +3 -0
  65. package/esm/orderly/useMaxQty.d.ts.map +1 -0
  66. package/esm/orderly/useMaxQty.js +114 -0
  67. package/esm/orderly/useOpenInterest.d.ts +2 -0
  68. package/esm/orderly/useOpenInterest.d.ts.map +1 -0
  69. package/esm/orderly/useOpenInterest.js +15 -0
  70. package/esm/orderly/useOrderEntry.d.ts +63 -0
  71. package/esm/orderly/useOrderEntry.d.ts.map +1 -0
  72. package/esm/orderly/useOrderEntry.js +504 -0
  73. package/esm/orderly/useOrderStream.d.ts +38 -0
  74. package/esm/orderly/useOrderStream.d.ts.map +1 -0
  75. package/esm/orderly/useOrderStream.js +180 -0
  76. package/esm/orderly/useOrderbookStream.d.ts +53 -0
  77. package/esm/orderly/useOrderbookStream.d.ts.map +1 -0
  78. package/esm/orderly/useOrderbookStream.js +309 -0
  79. package/esm/orderly/usePositionStream.d.ts +25 -0
  80. package/esm/orderly/usePositionStream.d.ts.map +1 -0
  81. package/esm/orderly/usePositionStream.js +232 -0
  82. package/esm/orderly/usePrivateDataObserver.d.ts +5 -0
  83. package/esm/orderly/usePrivateDataObserver.d.ts.map +1 -0
  84. package/esm/orderly/usePrivateDataObserver.js +126 -0
  85. package/esm/orderly/useSettleSubscription.d.ts +4 -0
  86. package/esm/orderly/useSettleSubscription.d.ts.map +1 -0
  87. package/esm/orderly/useSettleSubscription.js +20 -0
  88. package/esm/orderly/useSymbolPriceRange.d.ts +13 -0
  89. package/esm/orderly/useSymbolPriceRange.d.ts.map +1 -0
  90. package/esm/orderly/useSymbolPriceRange.js +39 -0
  91. package/esm/orderly/useSymbolsInfo.d.ts +2 -0
  92. package/esm/orderly/useSymbolsInfo.d.ts.map +1 -0
  93. package/esm/orderly/useSymbolsInfo.js +33 -0
  94. package/esm/orderly/useTickerStream.d.ts +3 -0
  95. package/esm/orderly/useTickerStream.d.ts.map +1 -0
  96. package/esm/orderly/useTickerStream.js +86 -0
  97. package/esm/orderly/useWalletSubscription.d.ts +4 -0
  98. package/esm/orderly/useWalletSubscription.d.ts.map +1 -0
  99. package/esm/orderly/useWalletSubscription.js +20 -0
  100. package/esm/orderly/useWithdraw.d.ts +14 -0
  101. package/esm/orderly/useWithdraw.d.ts.map +1 -0
  102. package/esm/orderly/useWithdraw.js +64 -0
  103. package/esm/orderlyContext.d.ts +17 -0
  104. package/esm/orderlyContext.d.ts.map +1 -0
  105. package/esm/orderlyContext.js +5 -0
  106. package/esm/services/dataCenter.d.ts +2 -0
  107. package/esm/services/dataCenter.d.ts.map +1 -0
  108. package/esm/services/dataCenter.js +13 -0
  109. package/esm/services/painter/backgroundPaint.d.ts +9 -0
  110. package/esm/services/painter/backgroundPaint.d.ts.map +1 -0
  111. package/esm/services/painter/backgroundPaint.js +41 -0
  112. package/esm/services/painter/basePaint.d.ts +90 -0
  113. package/esm/services/painter/basePaint.d.ts.map +1 -0
  114. package/esm/services/painter/basePaint.js +6 -0
  115. package/esm/services/painter/dataPaint.d.ts +16 -0
  116. package/esm/services/painter/dataPaint.d.ts.map +1 -0
  117. package/esm/services/painter/dataPaint.js +195 -0
  118. package/esm/services/painter/layout.config.d.ts +3 -0
  119. package/esm/services/painter/layout.config.d.ts.map +1 -0
  120. package/esm/services/painter/layout.config.js +52 -0
  121. package/esm/services/painter/painter.d.ts +12 -0
  122. package/esm/services/painter/painter.d.ts.map +1 -0
  123. package/esm/services/painter/painter.js +37 -0
  124. package/esm/services/painter/resource.d.ts +7 -0
  125. package/esm/services/painter/resource.d.ts.map +1 -0
  126. package/esm/services/painter/resource.js +15 -0
  127. package/esm/statusProvider.d.ts +8 -0
  128. package/esm/statusProvider.d.ts.map +1 -0
  129. package/esm/statusProvider.js +8 -0
  130. package/esm/unuse/apiPrefixMiddleware.d.ts +3 -0
  131. package/esm/unuse/apiPrefixMiddleware.d.ts.map +1 -0
  132. package/esm/unuse/apiPrefixMiddleware.js +29 -0
  133. package/esm/unuse/fn.d.ts +2 -0
  134. package/esm/unuse/fn.d.ts.map +1 -0
  135. package/esm/unuse/fn.js +6 -0
  136. package/esm/unuse/useBalance.d.ts +2 -0
  137. package/esm/unuse/useBalance.d.ts.map +1 -0
  138. package/esm/unuse/useBalance.js +12 -0
  139. package/esm/unuse/useFetures.d.ts +11 -0
  140. package/esm/unuse/useFetures.d.ts.map +1 -0
  141. package/esm/unuse/useFetures.js +39 -0
  142. package/esm/unuse/useRunOnce.d.ts +7 -0
  143. package/esm/unuse/useRunOnce.d.ts.map +1 -0
  144. package/esm/unuse/useRunOnce.js +17 -0
  145. package/esm/unuse/useSyncEnd.d.ts +2 -0
  146. package/esm/unuse/useSyncEnd.d.ts.map +1 -0
  147. package/esm/unuse/useSyncEnd.js +10 -0
  148. package/esm/unuse/useTokenInfo.d.ts +2 -0
  149. package/esm/unuse/useTokenInfo.d.ts.map +1 -0
  150. package/esm/unuse/useTokenInfo.js +20 -0
  151. package/esm/unuse/useUnsettlementPnL.d.ts +2 -0
  152. package/esm/unuse/useUnsettlementPnL.d.ts.map +1 -0
  153. package/esm/unuse/useUnsettlementPnL.js +20 -0
  154. package/esm/useAccount.d.ts +8 -0
  155. package/esm/useAccount.d.ts.map +1 -0
  156. package/esm/useAccount.js +59 -0
  157. package/esm/useAccountInstance.d.ts +3 -0
  158. package/esm/useAccountInstance.d.ts.map +1 -0
  159. package/esm/useAccountInstance.js +23 -0
  160. package/esm/useBoolean.d.ts +6 -0
  161. package/esm/useBoolean.d.ts.map +1 -0
  162. package/esm/useBoolean.js +8 -0
  163. package/esm/useConfig.d.ts +3 -0
  164. package/esm/useConfig.d.ts.map +1 -0
  165. package/esm/useConfig.js +12 -0
  166. package/esm/useEventEmitter.d.ts +3 -0
  167. package/esm/useEventEmitter.d.ts.map +1 -0
  168. package/esm/useEventEmitter.js +12 -0
  169. package/esm/useLazyQuery.d.ts +13 -0
  170. package/esm/useLazyQuery.d.ts.map +1 -0
  171. package/esm/useLazyQuery.js +35 -0
  172. package/esm/useLocalStorage.d.ts +2 -0
  173. package/esm/useLocalStorage.d.ts.map +1 -0
  174. package/esm/useLocalStorage.js +74 -0
  175. package/esm/useMediaQuery.d.ts +2 -0
  176. package/esm/useMediaQuery.d.ts.map +1 -0
  177. package/esm/useMediaQuery.js +36 -0
  178. package/esm/useMutation.d.ts +10 -0
  179. package/esm/useMutation.d.ts.map +1 -0
  180. package/esm/useMutation.js +64 -0
  181. package/esm/useObserve.d.ts +6 -0
  182. package/esm/useObserve.d.ts.map +1 -0
  183. package/esm/useObserve.js +8 -0
  184. package/esm/useParamsCheck.d.ts +4 -0
  185. package/esm/useParamsCheck.d.ts.map +1 -0
  186. package/esm/useParamsCheck.js +14 -0
  187. package/esm/usePoster.d.ts +14 -0
  188. package/esm/usePoster.d.ts.map +1 -0
  189. package/esm/usePoster.js +52 -0
  190. package/esm/usePreloadData.d.ts +5 -0
  191. package/esm/usePreloadData.d.ts.map +1 -0
  192. package/esm/usePreloadData.js +14 -0
  193. package/esm/usePrivateInfiniteQuery.d.ts +5 -0
  194. package/esm/usePrivateInfiniteQuery.d.ts.map +1 -0
  195. package/esm/usePrivateInfiniteQuery.js +25 -0
  196. package/esm/usePrivateQuery.d.ts +10 -0
  197. package/esm/usePrivateQuery.d.ts.map +1 -0
  198. package/esm/usePrivateQuery.js +26 -0
  199. package/esm/useQuery.d.ts +10 -0
  200. package/esm/useQuery.d.ts.map +1 -0
  201. package/esm/useQuery.js +20 -0
  202. package/esm/useSessionStorage.d.ts +2 -0
  203. package/esm/useSessionStorage.d.ts.map +1 -0
  204. package/esm/useSessionStorage.js +60 -0
  205. package/esm/useWS.d.ts +3 -0
  206. package/esm/useWS.d.ts.map +1 -0
  207. package/esm/useWS.js +51 -0
  208. package/esm/useWsStatus.d.ts +7 -0
  209. package/esm/useWsStatus.d.ts.map +1 -0
  210. package/esm/useWsStatus.js +41 -0
  211. package/esm/utils/createGetter.d.ts +4 -0
  212. package/esm/utils/createGetter.d.ts.map +1 -0
  213. package/esm/utils/createGetter.js +21 -0
  214. package/esm/utils/createOrder.d.ts +56 -0
  215. package/esm/utils/createOrder.d.ts.map +1 -0
  216. package/esm/utils/createOrder.js +324 -0
  217. package/esm/utils/fetcher.d.ts +6 -0
  218. package/esm/utils/fetcher.d.ts.map +1 -0
  219. package/esm/utils/fetcher.js +2 -0
  220. package/esm/utils/json.d.ts +2 -0
  221. package/esm/utils/json.d.ts.map +1 -0
  222. package/esm/utils/json.js +8 -0
  223. package/esm/utils/orderEntryHelper.d.ts +25 -0
  224. package/esm/utils/orderEntryHelper.d.ts.map +1 -0
  225. package/esm/utils/orderEntryHelper.js +242 -0
  226. package/esm/utils/parseHolding.d.ts +9 -0
  227. package/esm/utils/parseHolding.d.ts.map +1 -0
  228. package/esm/utils/parseHolding.js +21 -0
  229. package/esm/version.d.ts +10 -0
  230. package/esm/version.d.ts.map +1 -0
  231. package/esm/version.js +6 -0
  232. package/esm/walletConnectorContext.d.ts +30 -0
  233. package/esm/walletConnectorContext.d.ts.map +1 -0
  234. package/esm/walletConnectorContext.js +5 -0
  235. package/lib/configProvider.d.ts +17 -0
  236. package/lib/configProvider.d.ts.map +1 -0
  237. package/lib/configProvider.js +82 -0
  238. package/lib/dataProvider.d.ts +10 -0
  239. package/lib/dataProvider.d.ts.map +1 -0
  240. package/lib/dataProvider.js +34 -0
  241. package/lib/index.d.ts +33 -0
  242. package/lib/index.d.ts.map +1 -0
  243. package/lib/index.js +88 -0
  244. package/lib/middleware/signatureMiddleware.d.ts +3 -0
  245. package/lib/middleware/signatureMiddleware.d.ts.map +1 -0
  246. package/lib/middleware/signatureMiddleware.js +36 -0
  247. package/lib/orderly/orderlyHooks.d.ts +30 -0
  248. package/lib/orderly/orderlyHooks.d.ts.map +1 -0
  249. package/lib/orderly/orderlyHooks.js +58 -0
  250. package/lib/orderly/useAccountInfo.d.ts +3 -0
  251. package/lib/orderly/useAccountInfo.d.ts.map +1 -0
  252. package/lib/orderly/useAccountInfo.js +8 -0
  253. package/lib/orderly/useChain.d.ts +6 -0
  254. package/lib/orderly/useChain.d.ts.map +1 -0
  255. package/lib/orderly/useChain.js +26 -0
  256. package/lib/orderly/useChains.d.ts +34 -0
  257. package/lib/orderly/useChains.d.ts.map +1 -0
  258. package/lib/orderly/useChains.js +166 -0
  259. package/lib/orderly/useCollateral.d.ts +16 -0
  260. package/lib/orderly/useCollateral.d.ts.map +1 -0
  261. package/lib/orderly/useCollateral.js +76 -0
  262. package/lib/orderly/useDeposit.d.ts +38 -0
  263. package/lib/orderly/useDeposit.d.ts.map +1 -0
  264. package/lib/orderly/useDeposit.js +274 -0
  265. package/lib/orderly/useFundingRate.d.ts +11 -0
  266. package/lib/orderly/useFundingRate.d.ts.map +1 -0
  267. package/lib/orderly/useFundingRate.js +44 -0
  268. package/lib/orderly/useFundingRates.d.ts +2 -0
  269. package/lib/orderly/useFundingRates.d.ts.map +1 -0
  270. package/lib/orderly/useFundingRates.js +25 -0
  271. package/lib/orderly/useHoldingStream.d.ts +7 -0
  272. package/lib/orderly/useHoldingStream.d.ts.map +1 -0
  273. package/lib/orderly/useHoldingStream.js +54 -0
  274. package/lib/orderly/useIndexPrice.d.ts +2 -0
  275. package/lib/orderly/useIndexPrice.d.ts.map +1 -0
  276. package/lib/orderly/useIndexPrice.js +24 -0
  277. package/lib/orderly/useLeverage.d.ts +2 -0
  278. package/lib/orderly/useLeverage.d.ts.map +1 -0
  279. package/lib/orderly/useLeverage.js +38 -0
  280. package/lib/orderly/useMarginRatio.d.ts +7 -0
  281. package/lib/orderly/useMarginRatio.d.ts.map +1 -0
  282. package/lib/orderly/useMarginRatio.js +45 -0
  283. package/lib/orderly/useMarkPrice.d.ts +4 -0
  284. package/lib/orderly/useMarkPrice.d.ts.map +1 -0
  285. package/lib/orderly/useMarkPrice.js +33 -0
  286. package/lib/orderly/useMarkPricesStream.d.ts +2 -0
  287. package/lib/orderly/useMarkPricesStream.d.ts.map +1 -0
  288. package/lib/orderly/useMarkPricesStream.js +33 -0
  289. package/lib/orderly/useMarketTradeStream.d.ts +9 -0
  290. package/lib/orderly/useMarketTradeStream.d.ts.map +1 -0
  291. package/lib/orderly/useMarketTradeStream.js +55 -0
  292. package/lib/orderly/useMarkets.d.ts +36 -0
  293. package/lib/orderly/useMarkets.d.ts.map +1 -0
  294. package/lib/orderly/useMarkets.js +244 -0
  295. package/lib/orderly/useMarketsStream.d.ts +5 -0
  296. package/lib/orderly/useMarketsStream.d.ts.map +1 -0
  297. package/lib/orderly/useMarketsStream.js +64 -0
  298. package/lib/orderly/useMaxQty.d.ts +3 -0
  299. package/lib/orderly/useMaxQty.d.ts.map +1 -0
  300. package/lib/orderly/useMaxQty.js +118 -0
  301. package/lib/orderly/useOpenInterest.d.ts +2 -0
  302. package/lib/orderly/useOpenInterest.d.ts.map +1 -0
  303. package/lib/orderly/useOpenInterest.js +22 -0
  304. package/lib/orderly/useOrderEntry.d.ts +63 -0
  305. package/lib/orderly/useOrderEntry.d.ts.map +1 -0
  306. package/lib/orderly/useOrderEntry.js +508 -0
  307. package/lib/orderly/useOrderStream.d.ts +38 -0
  308. package/lib/orderly/useOrderStream.d.ts.map +1 -0
  309. package/lib/orderly/useOrderStream.js +187 -0
  310. package/lib/orderly/useOrderbookStream.d.ts +53 -0
  311. package/lib/orderly/useOrderbookStream.d.ts.map +1 -0
  312. package/lib/orderly/useOrderbookStream.js +315 -0
  313. package/lib/orderly/usePositionStream.d.ts +25 -0
  314. package/lib/orderly/usePositionStream.d.ts.map +1 -0
  315. package/lib/orderly/usePositionStream.js +236 -0
  316. package/lib/orderly/usePrivateDataObserver.d.ts +5 -0
  317. package/lib/orderly/usePrivateDataObserver.d.ts.map +1 -0
  318. package/lib/orderly/usePrivateDataObserver.js +130 -0
  319. package/lib/orderly/useSettleSubscription.d.ts +4 -0
  320. package/lib/orderly/useSettleSubscription.d.ts.map +1 -0
  321. package/lib/orderly/useSettleSubscription.js +27 -0
  322. package/lib/orderly/useSymbolPriceRange.d.ts +13 -0
  323. package/lib/orderly/useSymbolPriceRange.d.ts.map +1 -0
  324. package/lib/orderly/useSymbolPriceRange.js +43 -0
  325. package/lib/orderly/useSymbolsInfo.d.ts +2 -0
  326. package/lib/orderly/useSymbolsInfo.d.ts.map +1 -0
  327. package/lib/orderly/useSymbolsInfo.js +37 -0
  328. package/lib/orderly/useTickerStream.d.ts +3 -0
  329. package/lib/orderly/useTickerStream.d.ts.map +1 -0
  330. package/lib/orderly/useTickerStream.js +90 -0
  331. package/lib/orderly/useWalletSubscription.d.ts +4 -0
  332. package/lib/orderly/useWalletSubscription.d.ts.map +1 -0
  333. package/lib/orderly/useWalletSubscription.js +27 -0
  334. package/lib/orderly/useWithdraw.d.ts +14 -0
  335. package/lib/orderly/useWithdraw.d.ts.map +1 -0
  336. package/lib/orderly/useWithdraw.js +68 -0
  337. package/lib/orderlyContext.d.ts +17 -0
  338. package/lib/orderlyContext.d.ts.map +1 -0
  339. package/lib/orderlyContext.js +8 -0
  340. package/lib/services/dataCenter.d.ts +2 -0
  341. package/lib/services/dataCenter.d.ts.map +1 -0
  342. package/lib/services/dataCenter.js +15 -0
  343. package/lib/services/painter/backgroundPaint.d.ts +9 -0
  344. package/lib/services/painter/backgroundPaint.d.ts.map +1 -0
  345. package/lib/services/painter/backgroundPaint.js +45 -0
  346. package/lib/services/painter/basePaint.d.ts +90 -0
  347. package/lib/services/painter/basePaint.d.ts.map +1 -0
  348. package/lib/services/painter/basePaint.js +10 -0
  349. package/lib/services/painter/dataPaint.d.ts +16 -0
  350. package/lib/services/painter/dataPaint.d.ts.map +1 -0
  351. package/lib/services/painter/dataPaint.js +199 -0
  352. package/lib/services/painter/layout.config.d.ts +3 -0
  353. package/lib/services/painter/layout.config.d.ts.map +1 -0
  354. package/lib/services/painter/layout.config.js +55 -0
  355. package/lib/services/painter/painter.d.ts +12 -0
  356. package/lib/services/painter/painter.d.ts.map +1 -0
  357. package/lib/services/painter/painter.js +41 -0
  358. package/lib/services/painter/resource.d.ts +7 -0
  359. package/lib/services/painter/resource.d.ts.map +1 -0
  360. package/lib/services/painter/resource.js +19 -0
  361. package/lib/statusProvider.d.ts +8 -0
  362. package/lib/statusProvider.d.ts.map +1 -0
  363. package/lib/statusProvider.js +12 -0
  364. package/lib/unuse/apiPrefixMiddleware.d.ts +3 -0
  365. package/lib/unuse/apiPrefixMiddleware.d.ts.map +1 -0
  366. package/lib/unuse/apiPrefixMiddleware.js +33 -0
  367. package/lib/unuse/fn.d.ts +2 -0
  368. package/lib/unuse/fn.d.ts.map +1 -0
  369. package/lib/unuse/fn.js +9 -0
  370. package/lib/unuse/useBalance.d.ts +2 -0
  371. package/lib/unuse/useBalance.d.ts.map +1 -0
  372. package/lib/unuse/useBalance.js +19 -0
  373. package/lib/unuse/useFetures.d.ts +11 -0
  374. package/lib/unuse/useFetures.d.ts.map +1 -0
  375. package/lib/unuse/useFetures.js +43 -0
  376. package/lib/unuse/useRunOnce.d.ts +7 -0
  377. package/lib/unuse/useRunOnce.d.ts.map +1 -0
  378. package/lib/unuse/useRunOnce.js +21 -0
  379. package/lib/unuse/useSyncEnd.d.ts +2 -0
  380. package/lib/unuse/useSyncEnd.d.ts.map +1 -0
  381. package/lib/unuse/useSyncEnd.js +14 -0
  382. package/lib/unuse/useTokenInfo.d.ts +2 -0
  383. package/lib/unuse/useTokenInfo.d.ts.map +1 -0
  384. package/lib/unuse/useTokenInfo.js +24 -0
  385. package/lib/unuse/useUnsettlementPnL.d.ts +2 -0
  386. package/lib/unuse/useUnsettlementPnL.d.ts.map +1 -0
  387. package/lib/unuse/useUnsettlementPnL.js +24 -0
  388. package/lib/useAccount.d.ts +8 -0
  389. package/lib/useAccount.d.ts.map +1 -0
  390. package/lib/useAccount.js +63 -0
  391. package/lib/useAccountInstance.d.ts +3 -0
  392. package/lib/useAccountInstance.d.ts.map +1 -0
  393. package/lib/useAccountInstance.js +30 -0
  394. package/lib/useBoolean.d.ts +6 -0
  395. package/lib/useBoolean.d.ts.map +1 -0
  396. package/lib/useBoolean.js +12 -0
  397. package/lib/useConfig.d.ts +3 -0
  398. package/lib/useConfig.d.ts.map +1 -0
  399. package/lib/useConfig.js +16 -0
  400. package/lib/useEventEmitter.d.ts +3 -0
  401. package/lib/useEventEmitter.d.ts.map +1 -0
  402. package/lib/useEventEmitter.js +19 -0
  403. package/lib/useLazyQuery.d.ts +13 -0
  404. package/lib/useLazyQuery.d.ts.map +1 -0
  405. package/lib/useLazyQuery.js +42 -0
  406. package/lib/useLocalStorage.d.ts +2 -0
  407. package/lib/useLocalStorage.d.ts.map +1 -0
  408. package/lib/useLocalStorage.js +78 -0
  409. package/lib/useMediaQuery.d.ts +2 -0
  410. package/lib/useMediaQuery.d.ts.map +1 -0
  411. package/lib/useMediaQuery.js +40 -0
  412. package/lib/useMutation.d.ts +10 -0
  413. package/lib/useMutation.d.ts.map +1 -0
  414. package/lib/useMutation.js +71 -0
  415. package/lib/useObserve.d.ts +6 -0
  416. package/lib/useObserve.d.ts.map +1 -0
  417. package/lib/useObserve.js +12 -0
  418. package/lib/useParamsCheck.d.ts +4 -0
  419. package/lib/useParamsCheck.d.ts.map +1 -0
  420. package/lib/useParamsCheck.js +18 -0
  421. package/lib/usePoster.d.ts +14 -0
  422. package/lib/usePoster.d.ts.map +1 -0
  423. package/lib/usePoster.js +56 -0
  424. package/lib/usePreloadData.d.ts +5 -0
  425. package/lib/usePreloadData.d.ts.map +1 -0
  426. package/lib/usePreloadData.js +18 -0
  427. package/lib/usePrivateInfiniteQuery.d.ts +5 -0
  428. package/lib/usePrivateInfiniteQuery.d.ts.map +1 -0
  429. package/lib/usePrivateInfiniteQuery.js +32 -0
  430. package/lib/usePrivateQuery.d.ts +10 -0
  431. package/lib/usePrivateQuery.d.ts.map +1 -0
  432. package/lib/usePrivateQuery.js +33 -0
  433. package/lib/useQuery.d.ts +10 -0
  434. package/lib/useQuery.d.ts.map +1 -0
  435. package/lib/useQuery.js +27 -0
  436. package/lib/useSessionStorage.d.ts +2 -0
  437. package/lib/useSessionStorage.d.ts.map +1 -0
  438. package/lib/useSessionStorage.js +64 -0
  439. package/lib/useWS.d.ts +3 -0
  440. package/lib/useWS.d.ts.map +1 -0
  441. package/lib/useWS.js +58 -0
  442. package/lib/useWsStatus.d.ts +7 -0
  443. package/lib/useWsStatus.d.ts.map +1 -0
  444. package/lib/useWsStatus.js +45 -0
  445. package/lib/utils/createGetter.d.ts +4 -0
  446. package/lib/utils/createGetter.d.ts.map +1 -0
  447. package/lib/utils/createGetter.js +25 -0
  448. package/lib/utils/createOrder.d.ts +56 -0
  449. package/lib/utils/createOrder.d.ts.map +1 -0
  450. package/lib/utils/createOrder.js +337 -0
  451. package/lib/utils/fetcher.d.ts +6 -0
  452. package/lib/utils/fetcher.d.ts.map +1 -0
  453. package/lib/utils/fetcher.js +6 -0
  454. package/lib/utils/json.d.ts +2 -0
  455. package/lib/utils/json.d.ts.map +1 -0
  456. package/lib/utils/json.js +12 -0
  457. package/lib/utils/orderEntryHelper.d.ts +25 -0
  458. package/lib/utils/orderEntryHelper.d.ts.map +1 -0
  459. package/lib/utils/orderEntryHelper.js +250 -0
  460. package/lib/utils/parseHolding.d.ts +9 -0
  461. package/lib/utils/parseHolding.d.ts.map +1 -0
  462. package/lib/utils/parseHolding.js +25 -0
  463. package/lib/version.d.ts +10 -0
  464. package/lib/version.d.ts.map +1 -0
  465. package/lib/version.js +8 -0
  466. package/lib/walletConnectorContext.d.ts +30 -0
  467. package/lib/walletConnectorContext.d.ts.map +1 -0
  468. package/lib/walletConnectorContext.js +9 -0
  469. package/package.json +18 -13
  470. package/dist/index.d.mts +0 -548
  471. package/dist/index.d.ts +0 -548
  472. package/dist/index.js +0 -5412
  473. package/dist/index.js.map +0 -1
  474. package/dist/index.mjs +0 -5329
  475. 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,6 @@
1
+ export declare enum Subjects {
2
+ Orders = "orders",
3
+ Positions = "positions"
4
+ }
5
+ export declare const useObserve: <T>(key: string, initialValue: T) => [T, (value: T) => void];
6
+ //# sourceMappingURL=useObserve.d.ts.map
@@ -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,8 @@
1
+ export var Subjects;
2
+ (function (Subjects) {
3
+ Subjects["Orders"] = "orders";
4
+ Subjects["Positions"] = "positions";
5
+ })(Subjects || (Subjects = {}));
6
+ export const useObserve = (key, initialValue
7
+ // @ts-ignore
8
+ ) => { };
@@ -0,0 +1,4 @@
1
+ export declare const useParamsCheck: (params: {
2
+ brokerId?: string;
3
+ }) => void;
4
+ //# sourceMappingURL=useParamsCheck.d.ts.map
@@ -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"}
@@ -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,5 @@
1
+ export declare const usePreLoadData: () => {
2
+ error: any;
3
+ done: boolean;
4
+ };
5
+ //# sourceMappingURL=usePreloadData.d.ts.map
@@ -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"}
@@ -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,2 @@
1
+ export declare function useSessionStorage<T>(key: string, initialValue: T): [T, (data: any) => void];
2
+ //# sourceMappingURL=useSessionStorage.d.ts.map
@@ -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,3 @@
1
+ import { WS } from "@orderly.network/net";
2
+ export declare const useWS: () => WS;
3
+ //# sourceMappingURL=useWS.d.ts.map
@@ -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,7 @@
1
+ export declare enum WsNetworkStatus {
2
+ Connected = "connected",
3
+ Unstable = "unstable",
4
+ Disconnected = "disconnected"
5
+ }
6
+ export declare function useWsStatus(): WsNetworkStatus;
7
+ //# sourceMappingURL=useWsStatus.d.ts.map
@@ -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,4 @@
1
+ type objectDepth = 1 | 2;
2
+ export declare function createGetter<T extends Record<string, any>, K extends keyof T = string>(data: T, depth?: objectDepth): any;
3
+ export {};
4
+ //# sourceMappingURL=createGetter.d.ts.map
@@ -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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"}