@n1xyz/nord-ts 0.0.20 → 0.0.21
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/nord/api/core.d.ts +1 -1
- package/dist/nord/api/core.js +1 -13
- package/dist/nord/client/Nord.d.ts +3 -3
- package/dist/nord/client/Nord.js +4 -7
- package/dist/types.d.ts +1 -10
- package/dist/types.js +0 -2
- package/dist/websocket/NordWebSocketClient.d.ts +0 -11
- package/dist/websocket/NordWebSocketClient.js +0 -92
- package/package.json +2 -2
- package/src/nord/api/core.ts +1 -16
- package/src/nord/client/Nord.ts +7 -11
- package/src/types.ts +0 -11
- package/src/websocket/NordWebSocketClient.ts +0 -113
- package/dist/api/client.d.ts +0 -14
- package/dist/api/client.js +0 -45
- package/dist/bridge/client.d.ts +0 -151
- package/dist/bridge/client.js +0 -434
- package/dist/bridge/const.d.ts +0 -23
- package/dist/bridge/const.js +0 -47
- package/dist/bridge/index.d.ts +0 -4
- package/dist/bridge/index.js +0 -23
- package/dist/bridge/types.d.ts +0 -120
- package/dist/bridge/types.js +0 -18
- package/dist/bridge/utils.d.ts +0 -64
- package/dist/bridge/utils.js +0 -131
- package/dist/gen/common.d.ts +0 -68
- package/dist/gen/common.js +0 -215
- package/dist/idl/bridge.d.ts +0 -569
- package/dist/idl/bridge.js +0 -8
- package/dist/idl/bridge.json +0 -1506
- package/dist/idl/index.d.ts +0 -607
- package/dist/idl/index.js +0 -8
- package/dist/nord/api/market.d.ts +0 -36
- package/dist/nord/api/market.js +0 -96
- package/dist/nord/api/queries.d.ts +0 -46
- package/dist/nord/api/queries.js +0 -109
package/dist/nord/api/market.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.marketsStats = marketsStats;
|
|
4
|
-
exports.getTrades = getTrades;
|
|
5
|
-
exports.getUserAccountIds = getUserAccountIds;
|
|
6
|
-
exports.getOrderbook = getOrderbook;
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
8
|
-
const NordError_1 = require("../utils/NordError");
|
|
9
|
-
/**
|
|
10
|
-
* Get market statistics
|
|
11
|
-
*
|
|
12
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
13
|
-
* @returns Market statistics response
|
|
14
|
-
* @throws {NordError} If the request fails
|
|
15
|
-
*/
|
|
16
|
-
async function marketsStats(webServerUrl) {
|
|
17
|
-
try {
|
|
18
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/stats`);
|
|
19
|
-
return await response.json();
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
throw new NordError_1.NordError("Failed to fetch markets stats", { cause: error });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get trades for a market
|
|
27
|
-
*
|
|
28
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
29
|
-
* @param query - Trades query parameters
|
|
30
|
-
* @returns Trades response
|
|
31
|
-
* @throws {NordError} If the request fails
|
|
32
|
-
*/
|
|
33
|
-
async function getTrades(webServerUrl, query) {
|
|
34
|
-
try {
|
|
35
|
-
const params = new URLSearchParams();
|
|
36
|
-
params.append("accountId", query.accountId.toString());
|
|
37
|
-
if (query.since) {
|
|
38
|
-
params.append("since", query.since);
|
|
39
|
-
}
|
|
40
|
-
if (query.until) {
|
|
41
|
-
params.append("until", query.until);
|
|
42
|
-
}
|
|
43
|
-
if (query.pageId) {
|
|
44
|
-
params.append("pageId", query.pageId);
|
|
45
|
-
}
|
|
46
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/trades?${params.toString()}`);
|
|
47
|
-
return await response.json();
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
throw new NordError_1.NordError("Failed to get trades", { cause: error });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Get user account IDs
|
|
55
|
-
*
|
|
56
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
57
|
-
* @param query - User account IDs query parameters
|
|
58
|
-
* @returns User account IDs response
|
|
59
|
-
* @throws {NordError} If the request fails
|
|
60
|
-
*/
|
|
61
|
-
async function getUserAccountIds(webServerUrl, query) {
|
|
62
|
-
try {
|
|
63
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/user/${query.pubkey.toString()}`);
|
|
64
|
-
return await response.json();
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
throw new NordError_1.NordError("Failed to get user account IDs", { cause: error });
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get orderbook for a market
|
|
72
|
-
*
|
|
73
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
74
|
-
* @param query - Orderbook query parameters
|
|
75
|
-
* @returns Orderbook response
|
|
76
|
-
* @throws {NordError} If the request fails
|
|
77
|
-
*/
|
|
78
|
-
async function getOrderbook(webServerUrl, query) {
|
|
79
|
-
try {
|
|
80
|
-
const params = new URLSearchParams();
|
|
81
|
-
if (query.symbol) {
|
|
82
|
-
params.append("symbol", query.symbol);
|
|
83
|
-
}
|
|
84
|
-
else if (query.market_id !== undefined) {
|
|
85
|
-
params.append("market_id", query.market_id.toString());
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
throw new NordError_1.NordError("Either symbol or market_id must be provided for orderbook query");
|
|
89
|
-
}
|
|
90
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/orderbook?${params.toString()}`);
|
|
91
|
-
return await response.json();
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
throw new NordError_1.NordError("Failed to get orderbook", { cause: error });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ActionQuery, ActionResponse, ActionsResponse, RollmanActionResponse, RollmanActionsResponse } from "../../types";
|
|
2
|
-
/**
|
|
3
|
-
* Query a specific action
|
|
4
|
-
*
|
|
5
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
6
|
-
* @param query - Action query parameters
|
|
7
|
-
* @returns Action response
|
|
8
|
-
* @throws {NordError} If the request fails
|
|
9
|
-
*/
|
|
10
|
-
export declare function queryAction(webServerUrl: string, query: ActionQuery): Promise<ActionResponse>;
|
|
11
|
-
/**
|
|
12
|
-
* Query recent actions
|
|
13
|
-
*
|
|
14
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
15
|
-
* @param from - Starting action index
|
|
16
|
-
* @param to - Ending action index
|
|
17
|
-
* @returns Actions response
|
|
18
|
-
* @throws {NordError} If the request fails
|
|
19
|
-
*/
|
|
20
|
-
export declare function queryRecentActions(webServerUrl: string, from: number, to: number): Promise<ActionsResponse>;
|
|
21
|
-
/**
|
|
22
|
-
* Get the last action ID
|
|
23
|
-
*
|
|
24
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
25
|
-
* @returns Last action ID
|
|
26
|
-
* @throws {NordError} If the request fails
|
|
27
|
-
*/
|
|
28
|
-
export declare function getLastActionId(webServerUrl: string): Promise<number>;
|
|
29
|
-
/**
|
|
30
|
-
* Query an action from Rollman
|
|
31
|
-
*
|
|
32
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
33
|
-
* @param query - Action query parameters
|
|
34
|
-
* @returns Rollman action response
|
|
35
|
-
* @throws {NordError} If the request fails
|
|
36
|
-
*/
|
|
37
|
-
export declare function actionQueryRollman(webServerUrl: string, query: ActionQuery): Promise<RollmanActionResponse>;
|
|
38
|
-
/**
|
|
39
|
-
* Query actions from Rollman
|
|
40
|
-
*
|
|
41
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
42
|
-
* @param last_n - Number of recent actions to query
|
|
43
|
-
* @returns Rollman actions response
|
|
44
|
-
* @throws {NordError} If the request fails
|
|
45
|
-
*/
|
|
46
|
-
export declare function actionsQueryRollman(webServerUrl: string, last_n: number): Promise<RollmanActionsResponse>;
|
package/dist/nord/api/queries.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.queryAction = queryAction;
|
|
4
|
-
exports.queryRecentActions = queryRecentActions;
|
|
5
|
-
exports.getLastActionId = getLastActionId;
|
|
6
|
-
exports.actionQueryRollman = actionQueryRollman;
|
|
7
|
-
exports.actionsQueryRollman = actionsQueryRollman;
|
|
8
|
-
const utils_1 = require("../../utils");
|
|
9
|
-
const NordError_1 = require("../utils/NordError");
|
|
10
|
-
/**
|
|
11
|
-
* Query a specific action
|
|
12
|
-
*
|
|
13
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
14
|
-
* @param query - Action query parameters
|
|
15
|
-
* @returns Action response
|
|
16
|
-
* @throws {NordError} If the request fails
|
|
17
|
-
*/
|
|
18
|
-
async function queryAction(webServerUrl, query) {
|
|
19
|
-
try {
|
|
20
|
-
const params = new URLSearchParams();
|
|
21
|
-
if (query.action_id !== undefined) {
|
|
22
|
-
params.append("action_id", query.action_id.toString());
|
|
23
|
-
}
|
|
24
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/action?${params.toString()}`);
|
|
25
|
-
return await response.json();
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
throw new NordError_1.NordError("Failed to query action", { cause: error });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Query recent actions
|
|
33
|
-
*
|
|
34
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
35
|
-
* @param from - Starting action index
|
|
36
|
-
* @param to - Ending action index
|
|
37
|
-
* @returns Actions response
|
|
38
|
-
* @throws {NordError} If the request fails
|
|
39
|
-
*/
|
|
40
|
-
async function queryRecentActions(webServerUrl, from, to) {
|
|
41
|
-
try {
|
|
42
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/actions?from=${from}&to=${to}`);
|
|
43
|
-
return await response.json();
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
throw new NordError_1.NordError(`Failed to query recent actions (from ${from} to ${to})`, {
|
|
47
|
-
cause: error,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get the last action ID
|
|
53
|
-
*
|
|
54
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
55
|
-
* @returns Last action ID
|
|
56
|
-
* @throws {NordError} If the request fails
|
|
57
|
-
*/
|
|
58
|
-
async function getLastActionId(webServerUrl) {
|
|
59
|
-
try {
|
|
60
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/actions/last-id`);
|
|
61
|
-
const data = await response.json();
|
|
62
|
-
return data;
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
throw new NordError_1.NordError("Failed to get last action ID", {
|
|
66
|
-
cause: error,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Query an action from Rollman
|
|
72
|
-
*
|
|
73
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
74
|
-
* @param query - Action query parameters
|
|
75
|
-
* @returns Rollman action response
|
|
76
|
-
* @throws {NordError} If the request fails
|
|
77
|
-
*/
|
|
78
|
-
async function actionQueryRollman(webServerUrl, query) {
|
|
79
|
-
try {
|
|
80
|
-
const params = new URLSearchParams();
|
|
81
|
-
if (query.action_id !== undefined) {
|
|
82
|
-
params.append("action_id", query.action_id.toString());
|
|
83
|
-
}
|
|
84
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/action?${params.toString()}`);
|
|
85
|
-
return await response.json();
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
throw new NordError_1.NordError("Failed to query Rollman action", { cause: error });
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Query actions from Rollman
|
|
93
|
-
*
|
|
94
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
95
|
-
* @param last_n - Number of recent actions to query
|
|
96
|
-
* @returns Rollman actions response
|
|
97
|
-
* @throws {NordError} If the request fails
|
|
98
|
-
*/
|
|
99
|
-
async function actionsQueryRollman(webServerUrl, last_n) {
|
|
100
|
-
try {
|
|
101
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/actions?last_n=${last_n}`);
|
|
102
|
-
return await response.json();
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
throw new NordError_1.NordError(`Failed to query Rollman actions (last ${last_n})`, {
|
|
106
|
-
cause: error,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|