@n1xyz/nord-ts 0.0.4 → 0.0.5
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/bridge/client.d.ts +4 -4
- package/dist/bridge/client.js +4 -4
- package/dist/bridge/const.d.ts +2 -2
- package/dist/bridge/const.js +22 -22
- package/dist/bridge/index.d.ts +4 -4
- package/dist/bridge/types.d.ts +3 -3
- package/dist/bridge/utils.d.ts +4 -4
- package/dist/bridge/utils.js +10 -10
- package/dist/const.d.ts +1 -1
- package/dist/const.js +17 -17
- package/dist/gen/nord.d.ts +1 -4
- package/dist/idl/bridge.d.ts +1 -1
- package/dist/idl/bridge.js +185 -185
- package/dist/index.d.ts +8 -8
- package/dist/nord/api/actions.d.ts +3 -3
- package/dist/nord/api/actions.js +21 -21
- package/dist/nord/api/core.d.ts +3 -3
- package/dist/nord/api/core.js +12 -12
- package/dist/nord/api/market.d.ts +1 -1
- package/dist/nord/api/market.js +12 -12
- package/dist/nord/api/metrics.d.ts +1 -1
- package/dist/nord/api/metrics.js +6 -6
- package/dist/nord/api/queries.d.ts +1 -1
- package/dist/nord/api/queries.js +9 -9
- package/dist/nord/client/Nord.d.ts +4 -4
- package/dist/nord/client/Nord.js +18 -18
- package/dist/nord/client/NordUser.d.ts +7 -7
- package/dist/nord/client/NordUser.js +45 -49
- package/dist/nord/index.d.ts +9 -9
- package/dist/nord/models/Subscriber.d.ts +6 -6
- package/dist/nord/models/Subscriber.js +1 -5
- package/dist/nord/utils/NordError.js +2 -2
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +6 -6
- package/dist/utils.js +8 -8
- package/dist/websocket/NordWebSocketClient.d.ts +2 -2
- package/dist/websocket/NordWebSocketClient.js +38 -38
- package/dist/websocket/events.d.ts +1 -1
- package/dist/websocket/index.d.ts +2 -2
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +16 -16
- package/docs/assets/icons.js +17 -14
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +5 -4
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +1423 -1227
- package/docs/classes/Nord.html +190 -31
- package/docs/classes/NordError.html +24 -0
- package/docs/classes/NordUser.html +120 -35
- package/docs/classes/NordWebSocketClient.html +335 -0
- package/docs/classes/SolanaBridgeClient.html +86 -0
- package/docs/classes/Subscriber.html +10 -0
- package/docs/enums/FillMode.html +5 -5
- package/docs/enums/KeyType.html +4 -4
- package/docs/enums/MetricPeriod.html +9 -0
- package/docs/enums/PdaSeedType.html +9 -0
- package/docs/enums/PeakTpsPeriodUnit.html +7 -7
- package/docs/enums/Side.html +3 -3
- package/docs/enums/WebSocketMessageType.html +7 -0
- package/docs/functions/actionQueryRollman.html +6 -0
- package/docs/functions/actionsQueryRollman.html +6 -0
- package/docs/functions/aggregateMetrics-1.html +7 -0
- package/docs/functions/assert.html +1 -1
- package/docs/functions/bigIntToProtoU128.html +3 -3
- package/docs/functions/blockQueryRollman.html +6 -0
- package/docs/functions/blockSummaryQueryRollman.html +6 -0
- package/docs/functions/bridgeToBN.html +5 -0
- package/docs/functions/bufferToHex.html +4 -0
- package/docs/functions/cancelOrder.html +1 -0
- package/docs/functions/checkPubKeyLength.html +1 -1
- package/docs/functions/checkedFetch.html +4 -4
- package/docs/functions/createSession.html +1 -0
- package/docs/functions/decodeLengthDelimited.html +7 -6
- package/docs/functions/encodeLengthDelimited.html +4 -4
- package/docs/functions/fillModeToProtoFillMode.html +4 -4
- package/docs/functions/findMarket.html +1 -1
- package/docs/functions/findPda.html +6 -0
- package/docs/functions/findToken.html +1 -1
- package/docs/functions/fromBN.html +5 -0
- package/docs/functions/getAccount.html +6 -0
- package/docs/functions/getActionNonce.html +5 -0
- package/docs/functions/getCurrentTps.html +6 -0
- package/docs/functions/getInfo.html +5 -0
- package/docs/functions/getMedianLatency.html +6 -0
- package/docs/functions/getOrderbook.html +6 -0
- package/docs/functions/getPeakTps.html +6 -0
- package/docs/functions/getTimestamp.html +5 -0
- package/docs/functions/getTotalTransactions.html +5 -0
- package/docs/functions/getTrades.html +6 -0
- package/docs/functions/getUserAccountIds.html +6 -0
- package/docs/functions/hexToBuffer.html +4 -0
- package/docs/functions/initWebSocketClient.html +12 -0
- package/docs/functions/keypairFromPrivateKey.html +4 -0
- package/docs/functions/makeSigningFunction.html +4 -0
- package/docs/functions/makeWalletSignFn.html +5 -5
- package/docs/functions/marketsStats.html +5 -0
- package/docs/functions/optExpect.html +4 -4
- package/docs/functions/optMap.html +5 -5
- package/docs/functions/optUnwrap.html +2 -2
- package/docs/functions/panic.html +1 -1
- package/docs/functions/placeOrder.html +1 -0
- package/docs/functions/queryAction.html +6 -0
- package/docs/functions/queryBlock.html +6 -0
- package/docs/functions/queryLastNBlocks.html +5 -0
- package/docs/functions/queryPrometheus.html +6 -0
- package/docs/functions/queryRecentActions.html +6 -0
- package/docs/functions/queryRecentBlocks.html +6 -0
- package/docs/functions/revokeSession.html +1 -0
- package/docs/functions/shortenPublicKey.html +5 -0
- package/docs/functions/signAction.html +2 -2
- package/docs/functions/toBN.html +5 -0
- package/docs/functions/toScaledU128.html +5 -5
- package/docs/functions/toScaledU64.html +5 -5
- package/docs/functions/transfer.html +1 -0
- package/docs/functions/withdraw.html +1 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +39 -20
- package/docs/interfaces/Account.html +8 -8
- package/docs/interfaces/ActionInfo.html +8 -8
- package/docs/interfaces/ActionNonceResponse.html +3 -0
- package/docs/interfaces/ActionQuery.html +4 -4
- package/docs/interfaces/ActionResponse.html +8 -8
- package/docs/interfaces/ActionsExtendedInfo.html +10 -10
- package/docs/interfaces/ActionsQuery.html +5 -5
- package/docs/interfaces/ActionsResponse.html +6 -6
- package/docs/interfaces/AggregateMetrics.html +12 -12
- package/docs/interfaces/BlockFacts.html +10 -0
- package/docs/interfaces/BlockQuery.html +6 -6
- package/docs/interfaces/BlockResponse.html +6 -6
- package/docs/interfaces/BlockSummary.html +8 -8
- package/docs/interfaces/BlockSummaryResponse.html +6 -6
- package/docs/interfaces/DeltaEvent.html +6 -6
- package/docs/interfaces/DepositSplParams.html +10 -0
- package/docs/interfaces/Info.html +3 -3
- package/docs/interfaces/Market.html +8 -6
- package/docs/interfaces/MarketStats.html +7 -7
- package/docs/interfaces/MarketsStatsResponse.html +2 -2
- package/docs/interfaces/NordConfig.html +14 -5
- package/docs/interfaces/NordWebSocketClientEvents.html +4 -0
- package/docs/interfaces/NordWebSocketEvents.html +8 -0
- package/docs/interfaces/Order.html +6 -6
- package/docs/interfaces/OrderInfo.html +6 -6
- package/docs/interfaces/OrderbookEntry.html +4 -0
- package/docs/interfaces/OrderbookQuery.html +6 -0
- package/docs/interfaces/OrderbookResponse.html +6 -0
- package/docs/interfaces/OrderbookSubscription.html +159 -0
- package/docs/interfaces/PerpMarketStats.html +5 -5
- package/docs/interfaces/RollmanActionExtendedInfo.html +4 -4
- package/docs/interfaces/RollmanActionInfo.html +4 -4
- package/docs/interfaces/RollmanActionResponse.html +4 -4
- package/docs/interfaces/RollmanActionsResponse.html +2 -2
- package/docs/interfaces/RollmanBlockResponse.html +3 -3
- package/docs/interfaces/SPLTokenInfo.html +10 -0
- package/docs/interfaces/SolanaBridgeConfig.html +10 -0
- package/docs/interfaces/StateFacts.html +10 -0
- package/docs/interfaces/SubscriberConfig.html +3 -3
- package/docs/interfaces/TimestampResponse.html +3 -0
- package/docs/interfaces/Token.html +5 -5
- package/docs/interfaces/TokenInfo.html +5 -0
- package/docs/interfaces/Trade.html +5 -5
- package/docs/interfaces/TradeSubscription.html +159 -0
- package/docs/interfaces/Trades.html +5 -5
- package/docs/interfaces/TradesQuery.html +6 -0
- package/docs/interfaces/TradesResponse.html +7 -0
- package/docs/interfaces/TransferParams.html +8 -0
- package/docs/interfaces/UserAccountIdsQuery.html +3 -0
- package/docs/interfaces/UserAccountIdsResponse.html +3 -0
- package/docs/interfaces/WebSocketDeltaUpdate.html +9 -0
- package/docs/interfaces/WebSocketSubscription.html +4 -0
- package/docs/interfaces/WebSocketTradeUpdate.html +6 -0
- package/docs/interfaces/WebSocketUserUpdate.html +6 -0
- package/docs/interfaces/WithdrawalClaim.html +14 -0
- package/docs/interfaces/WithdrawalParams.html +8 -0
- package/docs/modules.html +1 -70
- package/docs/types/BigIntValue.html +2 -2
- package/docs/types/WebSocketMessage.html +1 -0
- package/docs/variables/DEBUG_KEYS.html +1 -1
- package/docs/variables/DEFAULT_FUNDING_AMOUNTS.html +1 -1
- package/docs/variables/DEV_TOKEN_INFOS.html +1 -1
- package/docs/variables/DEV_URL.html +1 -1
- package/docs/variables/MAX_BUFFER_LEN.html +1 -1
- package/docs/variables/SESSION_TTL.html +1 -1
- package/docs/variables/WEBSERVER_DEV_URL.html +1 -1
- package/docs/variables/ZERO_DECIMAL.html +1 -1
- package/docs/variables/_private.html +2 -0
- package/eslint.config.mjs +66 -0
- package/package.json +12 -13
- package/src/bridge/client.ts +10 -10
- package/src/bridge/const.ts +24 -24
- package/src/bridge/index.ts +4 -4
- package/src/bridge/types.ts +10 -10
- package/src/bridge/utils.ts +14 -14
- package/src/const.ts +18 -18
- package/src/gen/nord.ts +1 -4
- package/src/idl/bridge.ts +186 -186
- package/src/index.ts +8 -8
- package/src/nord/api/actions.ts +25 -25
- package/src/nord/api/core.ts +16 -16
- package/src/nord/api/market.ts +15 -15
- package/src/nord/api/metrics.ts +16 -16
- package/src/nord/api/queries.ts +12 -12
- package/src/nord/client/Nord.ts +27 -27
- package/src/nord/client/NordUser.ts +59 -63
- package/src/nord/index.ts +9 -9
- package/src/nord/models/Subscriber.ts +11 -12
- package/src/nord/utils/NordError.ts +2 -2
- package/src/types.ts +12 -12
- package/src/utils.ts +20 -20
- package/src/websocket/NordWebSocketClient.ts +42 -42
- package/src/websocket/events.ts +1 -1
- package/src/websocket/index.ts +2 -2
- package/tests/utils.spec.ts +24 -24
- package/tsconfig.eslint.json +12 -0
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -31
- package/dist/abis/ERC20_ABI.d.ts +0 -39
- package/dist/abis/ERC20_ABI.js +0 -313
- package/dist/abis/NORD_GETTERS_FACET_ABI.d.ts +0 -34
- package/dist/abis/NORD_GETTERS_FACET_ABI.js +0 -195
- package/dist/abis/NORD_RAMP_FACET_ABI.d.ts +0 -35
- package/dist/abis/NORD_RAMP_FACET_ABI.js +0 -144
- package/dist/abis/index.d.ts +0 -3
- package/dist/abis/index.js +0 -9
- package/dist/bridge/NordUser.d.ts +0 -78
- package/dist/bridge/NordUser.js +0 -196
- package/dist/client.d.ts +0 -70
- package/dist/client.js +0 -129
- package/dist/constants/endpoints.d.ts +0 -65
- package/dist/constants/endpoints.js +0 -68
- package/dist/models/account.d.ts +0 -58
- package/dist/models/account.js +0 -6
- package/dist/models/index.d.ts +0 -8
- package/dist/models/index.js +0 -28
- package/dist/models/market.d.ts +0 -137
- package/dist/models/market.js +0 -6
- package/dist/models/order.d.ts +0 -211
- package/dist/models/order.js +0 -6
- package/dist/models/token.d.ts +0 -50
- package/dist/models/token.js +0 -6
- package/dist/nord/Nord.d.ts +0 -249
- package/dist/nord/Nord.js +0 -388
- package/dist/nord/NordError.d.ts +0 -23
- package/dist/nord/NordError.js +0 -48
- package/dist/nord/NordImpl.d.ts +0 -11
- package/dist/nord/NordImpl.js +0 -26
- package/dist/nord/NordUser.d.ts +0 -243
- package/dist/nord/NordUser.js +0 -481
- package/dist/nord/Subscriber.d.ts +0 -37
- package/dist/nord/Subscriber.js +0 -29
- package/dist/nord/actions.d.ts +0 -101
- package/dist/nord/actions.js +0 -254
- package/dist/nord/api/index.d.ts +0 -1
- package/dist/nord/api/index.js +0 -17
- package/dist/nord/api/orderFunctions.d.ts +0 -168
- package/dist/nord/api/orderFunctions.js +0 -133
- package/dist/nord/core.d.ts +0 -48
- package/dist/nord/core.js +0 -97
- package/dist/nord/market.d.ts +0 -36
- package/dist/nord/market.js +0 -90
- package/dist/nord/metrics.d.ts +0 -67
- package/dist/nord/metrics.js +0 -124
- package/dist/nord/queries.d.ts +0 -81
- package/dist/nord/queries.js +0 -181
- package/dist/nord/types.d.ts +0 -88
- package/dist/nord/types.js +0 -2
- package/dist/nord/websocket.d.ts +0 -49
- package/dist/nord/websocket.js +0 -107
- package/dist/operations/account.d.ts +0 -58
- package/dist/operations/account.js +0 -112
- package/dist/operations/market.d.ts +0 -65
- package/dist/operations/market.js +0 -131
- package/dist/operations/orders.d.ts +0 -57
- package/dist/operations/orders.js +0 -129
- package/dist/solana/NordUser.d.ts +0 -78
- package/dist/solana/NordUser.js +0 -196
- package/dist/solana/client.d.ts +0 -139
- package/dist/solana/client.js +0 -360
- package/dist/solana/const.d.ts +0 -23
- package/dist/solana/const.js +0 -47
- package/dist/solana/index.d.ts +0 -5
- package/dist/solana/index.js +0 -23
- package/dist/solana/types.d.ts +0 -118
- package/dist/solana/types.js +0 -16
- package/dist/solana/utils.d.ts +0 -64
- package/dist/solana/utils.js +0 -131
- package/dist/types/api.d.ts +0 -152
- package/dist/types/api.js +0 -6
- package/dist/types/config.d.ts +0 -34
- package/dist/types/config.js +0 -6
- package/dist/utils/errors.d.ts +0 -96
- package/dist/utils/errors.js +0 -132
- package/dist/utils/http.d.ts +0 -35
- package/dist/utils/http.js +0 -105
- package/dist/websocket/client.d.ts +0 -93
- package/dist/websocket/client.js +0 -222
- package/dist/websocket.d.ts +0 -55
- package/dist/websocket.js +0 -211
- package/docs/interfaces/ERC20TokenInfo.html +0 -5
- package/docs/variables/DEV_CONTRACT_ADDRESS.html +0 -1
- package/docs/variables/ERC20_ABI.html +0 -1
- package/docs/variables/EVM_DEV_URL.html +0 -1
- package/docs/variables/FAUCET_PRIVATE_ADDRESS.html +0 -1
- package/docs/variables/NORD_GETTERS_FACET_ABI.html +0 -1
- package/docs/variables/NORD_RAMP_FACET_ABI.html +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export { bridgeToBN, fromBN, keypairFromPrivateKey, makeSigningFunction, findPda, bufferToHex, hexToBuffer, shortenPublicKey, } from
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./utils";
|
|
3
|
+
export * from "./const";
|
|
4
|
+
export * from "./nord";
|
|
5
|
+
export * from "./websocket/index";
|
|
6
|
+
export * from "./bridge/client";
|
|
7
|
+
export * from "./bridge/types";
|
|
8
|
+
export { bridgeToBN, fromBN, keypairFromPrivateKey, makeSigningFunction, findPda, bufferToHex, hexToBuffer, shortenPublicKey, } from "./bridge/utils";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Decimal from
|
|
2
|
-
import { FillMode, Side } from
|
|
3
|
-
import { BigIntValue } from
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
import { FillMode, Side } from "../../types";
|
|
3
|
+
import { BigIntValue } from "../../utils";
|
|
4
4
|
declare function createSessionImpl(sendFn: (encoded: Uint8Array) => Promise<Uint8Array>, walletSignFn: (message: string | Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
|
|
5
5
|
userPubkey: Uint8Array;
|
|
6
6
|
sessionPubkey: Uint8Array;
|
package/dist/nord/api/actions.js
CHANGED
|
@@ -54,9 +54,9 @@ async function walletSign(walletSignFn, message) {
|
|
|
54
54
|
function makeSendHttp(serverUrl) {
|
|
55
55
|
return async (body) => {
|
|
56
56
|
const response = await (0, utils_1.checkedFetch)(`${serverUrl}/action`, {
|
|
57
|
-
method:
|
|
57
|
+
method: "POST",
|
|
58
58
|
headers: {
|
|
59
|
-
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
60
|
},
|
|
61
61
|
body,
|
|
62
62
|
});
|
|
@@ -68,7 +68,7 @@ async function sendAction(sendFn, makeSignedMessage, action, actionErrorDesc) {
|
|
|
68
68
|
const body = await makeSignedMessage(encoded);
|
|
69
69
|
const rawResp = await sendFn(body);
|
|
70
70
|
const resp = (0, utils_1.decodeLengthDelimited)(rawResp, proto.Receipt);
|
|
71
|
-
if (resp.kind?.$case ===
|
|
71
|
+
if (resp.kind?.$case === "err") {
|
|
72
72
|
throw new Error(`Could not ${actionErrorDesc}, reason: ${proto.errorToJSON(resp.kind.value)}`);
|
|
73
73
|
}
|
|
74
74
|
return resp;
|
|
@@ -79,7 +79,7 @@ async function createSessionImpl(sendFn, walletSignFn, currentTimestamp, nonce,
|
|
|
79
79
|
let expiry = 0n;
|
|
80
80
|
if (params.expiryTimestamp !== undefined) {
|
|
81
81
|
expiry = params.expiryTimestamp;
|
|
82
|
-
(0, utils_1.assert)(expiry > currentTimestamp,
|
|
82
|
+
(0, utils_1.assert)(expiry > currentTimestamp, "Cannot set expiry timestamp in the past");
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
85
|
expiry = currentTimestamp + utils_1.SESSION_TTL;
|
|
@@ -88,7 +88,7 @@ async function createSessionImpl(sendFn, walletSignFn, currentTimestamp, nonce,
|
|
|
88
88
|
currentTimestamp,
|
|
89
89
|
nonce,
|
|
90
90
|
kind: {
|
|
91
|
-
$case:
|
|
91
|
+
$case: "createSession",
|
|
92
92
|
value: {
|
|
93
93
|
userPubkey: params.userPubkey,
|
|
94
94
|
blstPubkey: params.sessionPubkey,
|
|
@@ -96,8 +96,8 @@ async function createSessionImpl(sendFn, walletSignFn, currentTimestamp, nonce,
|
|
|
96
96
|
},
|
|
97
97
|
},
|
|
98
98
|
};
|
|
99
|
-
const resp = await sendAction(sendFn, (m) => walletSign(walletSignFn, m), action,
|
|
100
|
-
if (resp.kind?.$case ===
|
|
99
|
+
const resp = await sendAction(sendFn, (m) => walletSign(walletSignFn, m), action, "create a new session");
|
|
100
|
+
if (resp.kind?.$case === "createSessionResult") {
|
|
101
101
|
return resp.kind.value.sessionId;
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
@@ -112,13 +112,13 @@ async function revokeSessionImpl(sendFn, walletSignFn, currentTimestamp, nonce,
|
|
|
112
112
|
currentTimestamp,
|
|
113
113
|
nonce,
|
|
114
114
|
kind: {
|
|
115
|
-
$case:
|
|
115
|
+
$case: "revokeSession",
|
|
116
116
|
value: {
|
|
117
117
|
sessionId: BigInt(params.sessionId),
|
|
118
118
|
},
|
|
119
119
|
},
|
|
120
120
|
};
|
|
121
|
-
await sendAction(sendFn, (m) => walletSign(walletSignFn, m), action,
|
|
121
|
+
await sendAction(sendFn, (m) => walletSign(walletSignFn, m), action, "create a new session");
|
|
122
122
|
}
|
|
123
123
|
async function revokeSession(serverUrl, walletSignFn, currentTimestamp, nonce, params) {
|
|
124
124
|
return revokeSessionImpl(makeSendHttp(serverUrl), walletSignFn, currentTimestamp, nonce, params);
|
|
@@ -126,13 +126,13 @@ async function revokeSession(serverUrl, walletSignFn, currentTimestamp, nonce, p
|
|
|
126
126
|
async function withdrawImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
127
127
|
const amount = (0, utils_1.toScaledU64)(params.amount, params.sizeDecimals);
|
|
128
128
|
if (amount <= 0) {
|
|
129
|
-
throw new Error(
|
|
129
|
+
throw new Error("Withdraw amount must be positive");
|
|
130
130
|
}
|
|
131
131
|
const action = {
|
|
132
132
|
currentTimestamp,
|
|
133
133
|
nonce,
|
|
134
134
|
kind: {
|
|
135
|
-
$case:
|
|
135
|
+
$case: "withdraw",
|
|
136
136
|
value: {
|
|
137
137
|
sessionId: BigInt(params.sessionId),
|
|
138
138
|
tokenId: params.tokenId,
|
|
@@ -140,7 +140,7 @@ async function withdrawImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
|
140
140
|
},
|
|
141
141
|
},
|
|
142
142
|
};
|
|
143
|
-
await sendAction(sendFn, (m) => sessionSign(signFn, m), action,
|
|
143
|
+
await sendAction(sendFn, (m) => sessionSign(signFn, m), action, "withdraw");
|
|
144
144
|
}
|
|
145
145
|
async function withdraw(serverUrl, signFn, currentTimestamp, nonce, params) {
|
|
146
146
|
return withdrawImpl(makeSendHttp(serverUrl), signFn, currentTimestamp, nonce, params);
|
|
@@ -154,7 +154,7 @@ async function placeOrderImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
|
154
154
|
currentTimestamp,
|
|
155
155
|
nonce,
|
|
156
156
|
kind: {
|
|
157
|
-
$case:
|
|
157
|
+
$case: "placeOrder",
|
|
158
158
|
value: {
|
|
159
159
|
sessionId: BigInt(params.sessionId),
|
|
160
160
|
senderAccountId: params.senderId,
|
|
@@ -170,8 +170,8 @@ async function placeOrderImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
|
170
170
|
},
|
|
171
171
|
},
|
|
172
172
|
};
|
|
173
|
-
const resp = await sendAction(sendFn, (m) => sessionSign(signFn, m), action,
|
|
174
|
-
if (resp.kind?.$case ===
|
|
173
|
+
const resp = await sendAction(sendFn, (m) => sessionSign(signFn, m), action, "place the order");
|
|
174
|
+
if (resp.kind?.$case === "placeOrderResult") {
|
|
175
175
|
return resp.kind.value.posted?.orderId;
|
|
176
176
|
}
|
|
177
177
|
else {
|
|
@@ -186,7 +186,7 @@ async function cancelOrderImpl(sendFn, signFn, currentTimestamp, nonce, params)
|
|
|
186
186
|
currentTimestamp,
|
|
187
187
|
nonce: nonce,
|
|
188
188
|
kind: {
|
|
189
|
-
$case:
|
|
189
|
+
$case: "cancelOrderById",
|
|
190
190
|
value: {
|
|
191
191
|
orderId: BigInt(params.orderId),
|
|
192
192
|
sessionId: BigInt(params.sessionId),
|
|
@@ -195,8 +195,8 @@ async function cancelOrderImpl(sendFn, signFn, currentTimestamp, nonce, params)
|
|
|
195
195
|
},
|
|
196
196
|
},
|
|
197
197
|
};
|
|
198
|
-
const resp = await sendAction(sendFn, (m) => sessionSign(signFn, m), action,
|
|
199
|
-
if (resp.kind?.$case ===
|
|
198
|
+
const resp = await sendAction(sendFn, (m) => sessionSign(signFn, m), action, "cancel the order");
|
|
199
|
+
if (resp.kind?.$case === "cancelOrderResult") {
|
|
200
200
|
return resp.kind.value.orderId;
|
|
201
201
|
}
|
|
202
202
|
else {
|
|
@@ -211,7 +211,7 @@ async function transferImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
|
211
211
|
currentTimestamp,
|
|
212
212
|
nonce: nonce,
|
|
213
213
|
kind: {
|
|
214
|
-
$case:
|
|
214
|
+
$case: "transfer",
|
|
215
215
|
value: {
|
|
216
216
|
sessionId: BigInt(params.sessionId),
|
|
217
217
|
fromAccountId: params.fromAccountId,
|
|
@@ -221,8 +221,8 @@ async function transferImpl(sendFn, signFn, currentTimestamp, nonce, params) {
|
|
|
221
221
|
},
|
|
222
222
|
},
|
|
223
223
|
};
|
|
224
|
-
const resp = await sendAction(sendFn, (m) => sessionSign(signFn, m), action,
|
|
225
|
-
if (resp.kind?.$case ===
|
|
224
|
+
const resp = await sendAction(sendFn, (m) => sessionSign(signFn, m), action, "transfer asset to other account");
|
|
225
|
+
if (resp.kind?.$case === "transferred") {
|
|
226
226
|
if (resp.kind.value.accountCreated) {
|
|
227
227
|
return resp.kind.value.toUserAccount;
|
|
228
228
|
}
|
package/dist/nord/api/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Account, Info } from
|
|
2
|
-
import { NordWebSocketClient } from
|
|
1
|
+
import { Account, Info } from "../../types";
|
|
2
|
+
import { NordWebSocketClient } from "../../websocket/index";
|
|
3
3
|
/**
|
|
4
4
|
* Get the current timestamp from the Nord server
|
|
5
5
|
*
|
|
@@ -46,4 +46,4 @@ export declare function getAccount(webServerUrl: string, accountId: number): Pro
|
|
|
46
46
|
* @param initialSubscriptions - Optional array of initial subscriptions (e.g., ["trades@BTCUSDC"])
|
|
47
47
|
* @returns WebSocket client
|
|
48
48
|
*/
|
|
49
|
-
export declare function initWebSocketClient(webServerUrl: string, endpoint?:
|
|
49
|
+
export declare function initWebSocketClient(webServerUrl: string, endpoint?: "trades" | "deltas" | "user", initialSubscriptions?: string[]): NordWebSocketClient;
|
package/dist/nord/api/core.js
CHANGED
|
@@ -6,8 +6,8 @@ exports.getInfo = getInfo;
|
|
|
6
6
|
exports.getAccount = getAccount;
|
|
7
7
|
exports.initWebSocketClient = initWebSocketClient;
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
|
-
const NordError_1 = require("../utils/NordError");
|
|
10
9
|
const index_1 = require("../../websocket/index");
|
|
10
|
+
const NordError_1 = require("../utils/NordError");
|
|
11
11
|
/**
|
|
12
12
|
* Get the current timestamp from the Nord server
|
|
13
13
|
*
|
|
@@ -21,7 +21,7 @@ async function getTimestamp(webServerUrl) {
|
|
|
21
21
|
return BigInt(await response.json());
|
|
22
22
|
}
|
|
23
23
|
catch (error) {
|
|
24
|
-
throw new NordError_1.NordError(
|
|
24
|
+
throw new NordError_1.NordError("Failed to get timestamp", { cause: error });
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -38,7 +38,7 @@ async function getActionNonce(webServerUrl) {
|
|
|
38
38
|
return data.nonce;
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
41
|
-
throw new NordError_1.NordError(
|
|
41
|
+
throw new NordError_1.NordError("Failed to get action nonce", { cause: error });
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
@@ -54,7 +54,7 @@ async function getInfo(webServerUrl) {
|
|
|
54
54
|
return await response.json();
|
|
55
55
|
}
|
|
56
56
|
catch (error) {
|
|
57
|
-
throw new NordError_1.NordError(
|
|
57
|
+
throw new NordError_1.NordError("Failed to get info", { cause: error });
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
@@ -91,18 +91,18 @@ function initWebSocketClient(webServerUrl, endpoint, initialSubscriptions) {
|
|
|
91
91
|
try {
|
|
92
92
|
// Convert HTTP URL to WebSocket URL with specific endpoint
|
|
93
93
|
// If no specific endpoint is provided, we'll connect to trades by default
|
|
94
|
-
const specificEndpoint = endpoint ||
|
|
95
|
-
const wsUrl = webServerUrl.replace(/^http/,
|
|
94
|
+
const specificEndpoint = endpoint || "trades";
|
|
95
|
+
const wsUrl = webServerUrl.replace(/^http/, "ws") + `/ws/${specificEndpoint}`;
|
|
96
96
|
console.log(`Initializing WebSocket client with URL: ${wsUrl}`);
|
|
97
97
|
// Create and connect the WebSocket client
|
|
98
98
|
const ws = new index_1.NordWebSocketClient(wsUrl);
|
|
99
99
|
// Add error handler
|
|
100
|
-
ws.on(
|
|
101
|
-
console.error(
|
|
100
|
+
ws.on("error", (error) => {
|
|
101
|
+
console.error("Nord WebSocket error:", error);
|
|
102
102
|
});
|
|
103
103
|
// Add connected handler for debugging
|
|
104
|
-
ws.on(
|
|
105
|
-
console.log(
|
|
104
|
+
ws.on("connected", () => {
|
|
105
|
+
console.log("Nord WebSocket connected successfully");
|
|
106
106
|
// Subscribe to initial subscriptions if provided
|
|
107
107
|
if (initialSubscriptions && initialSubscriptions.length > 0) {
|
|
108
108
|
ws.subscribe(initialSubscriptions);
|
|
@@ -113,8 +113,8 @@ function initWebSocketClient(webServerUrl, endpoint, initialSubscriptions) {
|
|
|
113
113
|
return ws;
|
|
114
114
|
}
|
|
115
115
|
catch (error) {
|
|
116
|
-
console.error(
|
|
117
|
-
throw new NordError_1.NordError(
|
|
116
|
+
console.error("Failed to initialize WebSocket client:", error);
|
|
117
|
+
throw new NordError_1.NordError("Failed to initialize WebSocket client", {
|
|
118
118
|
cause: error,
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MarketsStatsResponse, OrderbookQuery, OrderbookResponse, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from
|
|
1
|
+
import { MarketsStatsResponse, OrderbookQuery, OrderbookResponse, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Get market statistics
|
|
4
4
|
*
|
package/dist/nord/api/market.js
CHANGED
|
@@ -19,7 +19,7 @@ async function marketsStats(webServerUrl) {
|
|
|
19
19
|
return await response.json();
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
22
|
-
throw new NordError_1.NordError(
|
|
22
|
+
throw new NordError_1.NordError("Failed to fetch markets stats", { cause: error });
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
@@ -33,21 +33,21 @@ async function marketsStats(webServerUrl) {
|
|
|
33
33
|
async function getTrades(webServerUrl, query) {
|
|
34
34
|
try {
|
|
35
35
|
const params = new URLSearchParams();
|
|
36
|
-
params.append(
|
|
36
|
+
params.append("accountId", query.accountId.toString());
|
|
37
37
|
if (query.since) {
|
|
38
|
-
params.append(
|
|
38
|
+
params.append("since", query.since);
|
|
39
39
|
}
|
|
40
40
|
if (query.until) {
|
|
41
|
-
params.append(
|
|
41
|
+
params.append("until", query.until);
|
|
42
42
|
}
|
|
43
43
|
if (query.pageId) {
|
|
44
|
-
params.append(
|
|
44
|
+
params.append("pageId", query.pageId);
|
|
45
45
|
}
|
|
46
46
|
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/trades?${params.toString()}`);
|
|
47
47
|
return await response.json();
|
|
48
48
|
}
|
|
49
49
|
catch (error) {
|
|
50
|
-
throw new NordError_1.NordError(
|
|
50
|
+
throw new NordError_1.NordError("Failed to get trades", { cause: error });
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -61,12 +61,12 @@ async function getTrades(webServerUrl, query) {
|
|
|
61
61
|
async function getUserAccountIds(webServerUrl, query) {
|
|
62
62
|
try {
|
|
63
63
|
const params = new URLSearchParams();
|
|
64
|
-
params.append(
|
|
64
|
+
params.append("pubkey", query.pubkey);
|
|
65
65
|
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/user?${params.toString()}`);
|
|
66
66
|
return await response.json();
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
|
-
throw new NordError_1.NordError(
|
|
69
|
+
throw new NordError_1.NordError("Failed to get user account IDs", { cause: error });
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
@@ -81,18 +81,18 @@ async function getOrderbook(webServerUrl, query) {
|
|
|
81
81
|
try {
|
|
82
82
|
const params = new URLSearchParams();
|
|
83
83
|
if (query.symbol) {
|
|
84
|
-
params.append(
|
|
84
|
+
params.append("symbol", query.symbol);
|
|
85
85
|
}
|
|
86
86
|
else if (query.market_id !== undefined) {
|
|
87
|
-
params.append(
|
|
87
|
+
params.append("market_id", query.market_id.toString());
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
|
-
throw new NordError_1.NordError(
|
|
90
|
+
throw new NordError_1.NordError("Either symbol or market_id must be provided for orderbook query");
|
|
91
91
|
}
|
|
92
92
|
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/orderbook?${params.toString()}`);
|
|
93
93
|
return await response.json();
|
|
94
94
|
}
|
|
95
95
|
catch (error) {
|
|
96
|
-
throw new NordError_1.NordError(
|
|
96
|
+
throw new NordError_1.NordError("Failed to get orderbook", { cause: error });
|
|
97
97
|
}
|
|
98
98
|
}
|
package/dist/nord/api/metrics.js
CHANGED
|
@@ -38,7 +38,7 @@ async function aggregateMetrics(webServerUrl, txPeakTpsPeriod = 1, txPeakTpsPeri
|
|
|
38
38
|
return await response.json();
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
41
|
-
throw new NordError_1.NordError(
|
|
41
|
+
throw new NordError_1.NordError("Failed to fetch aggregate metrics", { cause: error });
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
@@ -49,7 +49,7 @@ async function aggregateMetrics(webServerUrl, txPeakTpsPeriod = 1, txPeakTpsPeri
|
|
|
49
49
|
* @returns Current TPS value
|
|
50
50
|
* @throws {NordError} If the request fails
|
|
51
51
|
*/
|
|
52
|
-
async function getCurrentTps(webServerUrl, period =
|
|
52
|
+
async function getCurrentTps(webServerUrl, period = "1m") {
|
|
53
53
|
try {
|
|
54
54
|
return await queryPrometheus(webServerUrl, `sum(rate(nord_tx_count[${period}]))`);
|
|
55
55
|
}
|
|
@@ -67,7 +67,7 @@ async function getCurrentTps(webServerUrl, period = '1m') {
|
|
|
67
67
|
* @returns Peak TPS value
|
|
68
68
|
* @throws {NordError} If the request fails
|
|
69
69
|
*/
|
|
70
|
-
async function getPeakTps(webServerUrl, period =
|
|
70
|
+
async function getPeakTps(webServerUrl, period = "24h") {
|
|
71
71
|
try {
|
|
72
72
|
return await queryPrometheus(webServerUrl, `max_over_time(sum(rate(nord_tx_count[1m]))[${period}:])`);
|
|
73
73
|
}
|
|
@@ -85,7 +85,7 @@ async function getPeakTps(webServerUrl, period = '24h') {
|
|
|
85
85
|
* @returns Median latency in milliseconds
|
|
86
86
|
* @throws {NordError} If the request fails
|
|
87
87
|
*/
|
|
88
|
-
async function getMedianLatency(webServerUrl, period =
|
|
88
|
+
async function getMedianLatency(webServerUrl, period = "1m") {
|
|
89
89
|
try {
|
|
90
90
|
return await queryPrometheus(webServerUrl, `quantile_over_time(0.5, nord_tx_latency_ms[${period}])`);
|
|
91
91
|
}
|
|
@@ -104,10 +104,10 @@ async function getMedianLatency(webServerUrl, period = '1m') {
|
|
|
104
104
|
*/
|
|
105
105
|
async function getTotalTransactions(webServerUrl) {
|
|
106
106
|
try {
|
|
107
|
-
return await queryPrometheus(webServerUrl,
|
|
107
|
+
return await queryPrometheus(webServerUrl, "sum(nord_tx_count)");
|
|
108
108
|
}
|
|
109
109
|
catch (error) {
|
|
110
|
-
throw new NordError_1.NordError(
|
|
110
|
+
throw new NordError_1.NordError("Failed to get total transactions", { cause: error });
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionQuery, ActionResponse, ActionsResponse, BlockQuery, BlockResponse, BlockSummaryResponse, RollmanActionResponse, RollmanActionsResponse, RollmanBlockResponse } from
|
|
1
|
+
import { ActionQuery, ActionResponse, ActionsResponse, BlockQuery, BlockResponse, BlockSummaryResponse, RollmanActionResponse, RollmanActionsResponse, RollmanBlockResponse } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Query a specific block
|
|
4
4
|
*
|
package/dist/nord/api/queries.js
CHANGED
|
@@ -23,13 +23,13 @@ async function queryBlock(webServerUrl, query) {
|
|
|
23
23
|
try {
|
|
24
24
|
const params = new URLSearchParams();
|
|
25
25
|
if (query.block_number !== undefined) {
|
|
26
|
-
params.append(
|
|
26
|
+
params.append("block_height", query.block_number.toString());
|
|
27
27
|
}
|
|
28
28
|
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/block?${params.toString()}`);
|
|
29
29
|
return await response.json();
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
32
|
-
throw new NordError_1.NordError(
|
|
32
|
+
throw new NordError_1.NordError("Failed to query block", { cause: error });
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
@@ -45,7 +45,7 @@ async function queryLastNBlocks(webServerUrl) {
|
|
|
45
45
|
return await response.json();
|
|
46
46
|
}
|
|
47
47
|
catch (error) {
|
|
48
|
-
throw new NordError_1.NordError(
|
|
48
|
+
throw new NordError_1.NordError("Failed to query last N blocks", { cause: error });
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
@@ -79,13 +79,13 @@ async function queryAction(webServerUrl, query) {
|
|
|
79
79
|
try {
|
|
80
80
|
const params = new URLSearchParams();
|
|
81
81
|
if (query.action_id !== undefined) {
|
|
82
|
-
params.append(
|
|
82
|
+
params.append("action_id", query.action_id.toString());
|
|
83
83
|
}
|
|
84
84
|
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/action?${params.toString()}`);
|
|
85
85
|
return await response.json();
|
|
86
86
|
}
|
|
87
87
|
catch (error) {
|
|
88
|
-
throw new NordError_1.NordError(
|
|
88
|
+
throw new NordError_1.NordError("Failed to query action", { cause: error });
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -119,13 +119,13 @@ async function blockQueryRollman(webServerUrl, query) {
|
|
|
119
119
|
try {
|
|
120
120
|
const params = new URLSearchParams();
|
|
121
121
|
if (query.block_number !== undefined) {
|
|
122
|
-
params.append(
|
|
122
|
+
params.append("block_height", query.block_number.toString());
|
|
123
123
|
}
|
|
124
124
|
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/block?${params.toString()}`);
|
|
125
125
|
return await response.json();
|
|
126
126
|
}
|
|
127
127
|
catch (error) {
|
|
128
|
-
throw new NordError_1.NordError(
|
|
128
|
+
throw new NordError_1.NordError("Failed to query Rollman block", { cause: error });
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
@@ -157,13 +157,13 @@ async function actionQueryRollman(webServerUrl, query) {
|
|
|
157
157
|
try {
|
|
158
158
|
const params = new URLSearchParams();
|
|
159
159
|
if (query.action_id !== undefined) {
|
|
160
|
-
params.append(
|
|
160
|
+
params.append("action_id", query.action_id.toString());
|
|
161
161
|
}
|
|
162
162
|
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/action?${params.toString()}`);
|
|
163
163
|
return await response.json();
|
|
164
164
|
}
|
|
165
165
|
catch (error) {
|
|
166
|
-
throw new NordError_1.NordError(
|
|
166
|
+
throw new NordError_1.NordError("Failed to query Rollman action", { cause: error });
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EventEmitter } from
|
|
2
|
-
import { Account, ActionQuery, ActionResponse, ActionsResponse, AggregateMetrics, BlockQuery, BlockResponse, BlockSummaryResponse, Info, Market, MarketsStatsResponse, NordConfig, OrderbookQuery, OrderbookResponse, PeakTpsPeriodUnit, RollmanActionResponse, RollmanActionsResponse, RollmanBlockResponse, Token, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from
|
|
3
|
-
import { NordWebSocketClient } from
|
|
4
|
-
import { OrderbookSubscription, TradeSubscription } from
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { Account, ActionQuery, ActionResponse, ActionsResponse, AggregateMetrics, BlockQuery, BlockResponse, BlockSummaryResponse, Info, Market, MarketsStatsResponse, NordConfig, OrderbookQuery, OrderbookResponse, PeakTpsPeriodUnit, RollmanActionResponse, RollmanActionsResponse, RollmanBlockResponse, Token, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from "../../types";
|
|
3
|
+
import { NordWebSocketClient } from "../../websocket/index";
|
|
4
|
+
import { OrderbookSubscription, TradeSubscription } from "../models/Subscriber";
|
|
5
5
|
/**
|
|
6
6
|
* User subscription interface
|
|
7
7
|
*/
|
package/dist/nord/client/Nord.js
CHANGED
|
@@ -80,13 +80,13 @@ class Nord {
|
|
|
80
80
|
*/
|
|
81
81
|
this.userWs = null;
|
|
82
82
|
if (!webServerUrl) {
|
|
83
|
-
throw new NordError_1.NordError(
|
|
83
|
+
throw new NordError_1.NordError("webServerUrl is required");
|
|
84
84
|
}
|
|
85
85
|
if (!solanaProgramId) {
|
|
86
|
-
throw new NordError_1.NordError(
|
|
86
|
+
throw new NordError_1.NordError("solanaProgramId is required");
|
|
87
87
|
}
|
|
88
88
|
if (!solanaUrl) {
|
|
89
|
-
throw new NordError_1.NordError(
|
|
89
|
+
throw new NordError_1.NordError("solanaUrl is required");
|
|
90
90
|
}
|
|
91
91
|
this.webServerUrl = webServerUrl;
|
|
92
92
|
this.solanaProgramId = solanaProgramId;
|
|
@@ -116,8 +116,8 @@ class Nord {
|
|
|
116
116
|
const trades = tradesSubscriptions || this.tradesSubscriptions;
|
|
117
117
|
const deltas = deltasSubscriptions || this.deltasSubscriptions;
|
|
118
118
|
// Initialize WebSocket clients for each endpoint with subscriptions
|
|
119
|
-
this.tradesWs = core.initWebSocketClient(this.webServerUrl,
|
|
120
|
-
this.deltasWs = core.initWebSocketClient(this.webServerUrl,
|
|
119
|
+
this.tradesWs = core.initWebSocketClient(this.webServerUrl, "trades", trades);
|
|
120
|
+
this.deltasWs = core.initWebSocketClient(this.webServerUrl, "deltas", deltas);
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
123
|
* Get the current timestamp from the Nord server
|
|
@@ -154,7 +154,7 @@ class Nord {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
catch (error) {
|
|
157
|
-
throw new NordError_1.NordError(
|
|
157
|
+
throw new NordError_1.NordError("Failed to fetch Nord info", { cause: error });
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
@@ -251,7 +251,7 @@ class Nord {
|
|
|
251
251
|
* @returns Current TPS value
|
|
252
252
|
* @throws {NordError} If the request fails
|
|
253
253
|
*/
|
|
254
|
-
async getCurrentTps(period =
|
|
254
|
+
async getCurrentTps(period = "1m") {
|
|
255
255
|
return metrics.getCurrentTps(this.webServerUrl, period);
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
@@ -261,7 +261,7 @@ class Nord {
|
|
|
261
261
|
* @returns Peak TPS value
|
|
262
262
|
* @throws {NordError} If the request fails
|
|
263
263
|
*/
|
|
264
|
-
async getPeakTps(period =
|
|
264
|
+
async getPeakTps(period = "24h") {
|
|
265
265
|
return metrics.getPeakTps(this.webServerUrl, period);
|
|
266
266
|
}
|
|
267
267
|
/**
|
|
@@ -271,7 +271,7 @@ class Nord {
|
|
|
271
271
|
* @returns Median latency in milliseconds
|
|
272
272
|
* @throws {NordError} If the request fails
|
|
273
273
|
*/
|
|
274
|
-
async getMedianLatency(period =
|
|
274
|
+
async getMedianLatency(period = "1m") {
|
|
275
275
|
return metrics.getMedianLatency(this.webServerUrl, period);
|
|
276
276
|
}
|
|
277
277
|
/**
|
|
@@ -378,7 +378,7 @@ class Nord {
|
|
|
378
378
|
getUserWebSocketClient() {
|
|
379
379
|
if (!this.userWs) {
|
|
380
380
|
// Initialize user WebSocket client on demand
|
|
381
|
-
this.userWs = core.initWebSocketClient(this.webServerUrl,
|
|
381
|
+
this.userWs = core.initWebSocketClient(this.webServerUrl, "user");
|
|
382
382
|
return this.userWs;
|
|
383
383
|
}
|
|
384
384
|
return this.userWs;
|
|
@@ -395,17 +395,17 @@ class Nord {
|
|
|
395
395
|
if (update.symbol !== symbol) {
|
|
396
396
|
return;
|
|
397
397
|
}
|
|
398
|
-
subscription.emit(
|
|
398
|
+
subscription.emit("message", update);
|
|
399
399
|
};
|
|
400
400
|
// Initialize deltas websocket if it doesn't exist
|
|
401
401
|
if (!this.deltasWs) {
|
|
402
402
|
this.initializeWebSockets();
|
|
403
403
|
}
|
|
404
|
-
this.deltasWs.on(
|
|
404
|
+
this.deltasWs.on("delta", handleDelta);
|
|
405
405
|
this.deltasWs.subscribe([`deltas@${symbol}`]);
|
|
406
406
|
subscription.close = () => {
|
|
407
407
|
this.deltasWs.unsubscribe([`deltas@${symbol}`]);
|
|
408
|
-
this.deltasWs.removeListener(
|
|
408
|
+
this.deltasWs.removeListener("delta", handleDelta);
|
|
409
409
|
subscription.removeAllListeners();
|
|
410
410
|
};
|
|
411
411
|
return subscription;
|
|
@@ -422,17 +422,17 @@ class Nord {
|
|
|
422
422
|
if (update.symbol !== symbol) {
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
|
-
subscription.emit(
|
|
425
|
+
subscription.emit("message", update);
|
|
426
426
|
};
|
|
427
427
|
// Initialize trades websocket if it doesn't exist
|
|
428
428
|
if (!this.tradesWs) {
|
|
429
429
|
this.initializeWebSockets();
|
|
430
430
|
}
|
|
431
|
-
this.tradesWs.on(
|
|
431
|
+
this.tradesWs.on("trade", handleTrade);
|
|
432
432
|
this.tradesWs.subscribe([`trades@${symbol}`]);
|
|
433
433
|
subscription.close = () => {
|
|
434
434
|
this.tradesWs.unsubscribe([`trades@${symbol}`]);
|
|
435
|
-
this.tradesWs.removeListener(
|
|
435
|
+
this.tradesWs.removeListener("trade", handleTrade);
|
|
436
436
|
subscription.removeAllListeners();
|
|
437
437
|
};
|
|
438
438
|
return subscription;
|
|
@@ -481,7 +481,7 @@ class Nord {
|
|
|
481
481
|
}
|
|
482
482
|
// Ensure market_id is provided
|
|
483
483
|
if (query.market_id === undefined) {
|
|
484
|
-
throw new NordError_1.NordError(
|
|
484
|
+
throw new NordError_1.NordError("market_id is required for orderbook query");
|
|
485
485
|
}
|
|
486
486
|
return market.getOrderbook(this.webServerUrl, query);
|
|
487
487
|
}
|
|
@@ -524,7 +524,7 @@ class Nord {
|
|
|
524
524
|
await market.getUserAccountIds(this.webServerUrl, { pubkey: address });
|
|
525
525
|
return true;
|
|
526
526
|
}
|
|
527
|
-
catch
|
|
527
|
+
catch {
|
|
528
528
|
return false;
|
|
529
529
|
}
|
|
530
530
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Connection, PublicKey } from
|
|
2
|
-
import Decimal from
|
|
3
|
-
import { SolanaBridgeClient } from
|
|
4
|
-
import { SPLTokenInfo } from
|
|
5
|
-
import { FillMode, Order, Side } from
|
|
6
|
-
import { BigIntValue } from
|
|
7
|
-
import { Nord } from
|
|
1
|
+
import { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import Decimal from "decimal.js";
|
|
3
|
+
import { SolanaBridgeClient } from "../../bridge/client";
|
|
4
|
+
import { SPLTokenInfo } from "../../bridge/types";
|
|
5
|
+
import { FillMode, Order, Side } from "../../types";
|
|
6
|
+
import { BigIntValue } from "../../utils";
|
|
7
|
+
import { Nord } from "./Nord";
|
|
8
8
|
/**
|
|
9
9
|
* Parameters for creating a NordUser instance
|
|
10
10
|
*/
|