@orderly.network/hooks 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { createContext, useContext, useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
2
|
import useSWR, { useSWRConfig } from 'swr';
|
|
3
3
|
export { default as useSWR } from 'swr';
|
|
4
|
-
import { WS, get, mutate
|
|
4
|
+
import { WS, get, mutate } from '@orderly.network/net';
|
|
5
5
|
import useSWRMutation from 'swr/mutation';
|
|
6
6
|
import useConstant from 'use-constant';
|
|
7
7
|
export { default as useConstant } from 'use-constant';
|
|
8
|
-
import { SimpleDI, Account
|
|
8
|
+
import { SimpleDI, Account } from '@orderly.network/core';
|
|
9
9
|
import { AccountStatusEnum, SystemStateEnum, ExchangeStatusEnum, OrderSide, OrderType } from '@orderly.network/types';
|
|
10
10
|
import { BehaviorSubject, merge } from 'rxjs';
|
|
11
11
|
import { map } from 'rxjs/operators';
|
|
@@ -1344,29 +1344,6 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
|
|
|
1344
1344
|
symbolConfig: symbolInfo[symbol]()
|
|
1345
1345
|
};
|
|
1346
1346
|
};
|
|
1347
|
-
var WS_NAME2 = "websocketClient";
|
|
1348
|
-
var useWebSocketClient = () => {
|
|
1349
|
-
const ws = useConstant(() => {
|
|
1350
|
-
let websocketClient = SimpleDI.get(WS_NAME2);
|
|
1351
|
-
if (!websocketClient) {
|
|
1352
|
-
websocketClient = new WebSocketClient({
|
|
1353
|
-
accountId: "OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY",
|
|
1354
|
-
networkId: "testnet",
|
|
1355
|
-
onSigntureRequest: (accountId) => __async(void 0, null, function* () {
|
|
1356
|
-
const signer = getMockSigner();
|
|
1357
|
-
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
1358
|
-
const result = yield signer.signText(timestamp.toString());
|
|
1359
|
-
return __spreadProps(__spreadValues({}, result), { timestamp });
|
|
1360
|
-
})
|
|
1361
|
-
});
|
|
1362
|
-
SimpleDI.registerByName(WS_NAME2, websocketClient);
|
|
1363
|
-
}
|
|
1364
|
-
return websocketClient;
|
|
1365
|
-
});
|
|
1366
|
-
return ws;
|
|
1367
|
-
};
|
|
1368
|
-
|
|
1369
|
-
// src/orderly/useFetures.ts
|
|
1370
1347
|
var useFetures = () => {
|
|
1371
1348
|
const { data, isLoading, error } = useQuery(
|
|
1372
1349
|
`/v1/public/futures`,
|
|
@@ -1375,14 +1352,8 @@ var useFetures = () => {
|
|
|
1375
1352
|
}
|
|
1376
1353
|
);
|
|
1377
1354
|
const [sortedData, setSortedData] = useState(data);
|
|
1378
|
-
|
|
1355
|
+
useWS();
|
|
1379
1356
|
useEffect(() => {
|
|
1380
|
-
const sub = ws.observe(`tickers`).subscribe((value) => {
|
|
1381
|
-
console.log("useTickers", value);
|
|
1382
|
-
});
|
|
1383
|
-
return () => {
|
|
1384
|
-
sub.unsubscribe();
|
|
1385
|
-
};
|
|
1386
1357
|
}, []);
|
|
1387
1358
|
useEffect(() => {
|
|
1388
1359
|
if (data) {
|