@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/src/nord/client/Nord.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventEmitter } from
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
2
|
import {
|
|
3
3
|
Account,
|
|
4
4
|
ActionQuery,
|
|
@@ -23,14 +23,14 @@ import {
|
|
|
23
23
|
TradesResponse,
|
|
24
24
|
UserAccountIdsQuery,
|
|
25
25
|
UserAccountIdsResponse,
|
|
26
|
-
} from
|
|
27
|
-
import { NordWebSocketClient } from
|
|
28
|
-
import * as core from
|
|
29
|
-
import * as market from
|
|
30
|
-
import * as metrics from
|
|
31
|
-
import * as queries from
|
|
32
|
-
import { OrderbookSubscription, TradeSubscription } from
|
|
33
|
-
import { NordError } from
|
|
26
|
+
} from "../../types";
|
|
27
|
+
import { NordWebSocketClient } from "../../websocket/index";
|
|
28
|
+
import * as core from "../api/core";
|
|
29
|
+
import * as market from "../api/market";
|
|
30
|
+
import * as metrics from "../api/metrics";
|
|
31
|
+
import * as queries from "../api/queries";
|
|
32
|
+
import { OrderbookSubscription, TradeSubscription } from "../models/Subscriber";
|
|
33
|
+
import { NordError } from "../utils/NordError";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* User subscription interface
|
|
@@ -112,15 +112,15 @@ export class Nord {
|
|
|
112
112
|
deltasSubscriptions,
|
|
113
113
|
}: NordConfig) {
|
|
114
114
|
if (!webServerUrl) {
|
|
115
|
-
throw new NordError(
|
|
115
|
+
throw new NordError("webServerUrl is required");
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
if (!solanaProgramId) {
|
|
119
|
-
throw new NordError(
|
|
119
|
+
throw new NordError("solanaProgramId is required");
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
if (!solanaUrl) {
|
|
123
|
-
throw new NordError(
|
|
123
|
+
throw new NordError("solanaUrl is required");
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
this.webServerUrl = webServerUrl;
|
|
@@ -160,12 +160,12 @@ export class Nord {
|
|
|
160
160
|
// Initialize WebSocket clients for each endpoint with subscriptions
|
|
161
161
|
this.tradesWs = core.initWebSocketClient(
|
|
162
162
|
this.webServerUrl,
|
|
163
|
-
|
|
163
|
+
"trades",
|
|
164
164
|
trades,
|
|
165
165
|
);
|
|
166
166
|
this.deltasWs = core.initWebSocketClient(
|
|
167
167
|
this.webServerUrl,
|
|
168
|
-
|
|
168
|
+
"deltas",
|
|
169
169
|
deltas,
|
|
170
170
|
);
|
|
171
171
|
}
|
|
@@ -207,7 +207,7 @@ export class Nord {
|
|
|
207
207
|
this.symbolToMarketId.set(market.symbol, market.marketId);
|
|
208
208
|
});
|
|
209
209
|
} catch (error) {
|
|
210
|
-
throw new NordError(
|
|
210
|
+
throw new NordError("Failed to fetch Nord info", { cause: error });
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -320,7 +320,7 @@ export class Nord {
|
|
|
320
320
|
* @returns Current TPS value
|
|
321
321
|
* @throws {NordError} If the request fails
|
|
322
322
|
*/
|
|
323
|
-
async getCurrentTps(period: string =
|
|
323
|
+
async getCurrentTps(period: string = "1m") {
|
|
324
324
|
return metrics.getCurrentTps(this.webServerUrl, period);
|
|
325
325
|
}
|
|
326
326
|
|
|
@@ -331,7 +331,7 @@ export class Nord {
|
|
|
331
331
|
* @returns Peak TPS value
|
|
332
332
|
* @throws {NordError} If the request fails
|
|
333
333
|
*/
|
|
334
|
-
async getPeakTps(period: string =
|
|
334
|
+
async getPeakTps(period: string = "24h") {
|
|
335
335
|
return metrics.getPeakTps(this.webServerUrl, period);
|
|
336
336
|
}
|
|
337
337
|
|
|
@@ -342,7 +342,7 @@ export class Nord {
|
|
|
342
342
|
* @returns Median latency in milliseconds
|
|
343
343
|
* @throws {NordError} If the request fails
|
|
344
344
|
*/
|
|
345
|
-
async getMedianLatency(period: string =
|
|
345
|
+
async getMedianLatency(period: string = "1m") {
|
|
346
346
|
return metrics.getMedianLatency(this.webServerUrl, period);
|
|
347
347
|
}
|
|
348
348
|
|
|
@@ -461,7 +461,7 @@ export class Nord {
|
|
|
461
461
|
public getUserWebSocketClient(): NordWebSocketClient {
|
|
462
462
|
if (!this.userWs) {
|
|
463
463
|
// Initialize user WebSocket client on demand
|
|
464
|
-
this.userWs = core.initWebSocketClient(this.webServerUrl,
|
|
464
|
+
this.userWs = core.initWebSocketClient(this.webServerUrl, "user");
|
|
465
465
|
return this.userWs;
|
|
466
466
|
}
|
|
467
467
|
return this.userWs;
|
|
@@ -485,7 +485,7 @@ export class Nord {
|
|
|
485
485
|
return;
|
|
486
486
|
}
|
|
487
487
|
|
|
488
|
-
subscription.emit(
|
|
488
|
+
subscription.emit("message", update);
|
|
489
489
|
};
|
|
490
490
|
|
|
491
491
|
// Initialize deltas websocket if it doesn't exist
|
|
@@ -493,12 +493,12 @@ export class Nord {
|
|
|
493
493
|
this.initializeWebSockets();
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
-
this.deltasWs!.on(
|
|
496
|
+
this.deltasWs!.on("delta", handleDelta);
|
|
497
497
|
this.deltasWs!.subscribe([`deltas@${symbol}`]);
|
|
498
498
|
|
|
499
499
|
subscription.close = () => {
|
|
500
500
|
this.deltasWs!.unsubscribe([`deltas@${symbol}`]);
|
|
501
|
-
this.deltasWs!.removeListener(
|
|
501
|
+
this.deltasWs!.removeListener("delta", handleDelta);
|
|
502
502
|
subscription.removeAllListeners();
|
|
503
503
|
};
|
|
504
504
|
|
|
@@ -527,7 +527,7 @@ export class Nord {
|
|
|
527
527
|
return;
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
-
subscription.emit(
|
|
530
|
+
subscription.emit("message", update);
|
|
531
531
|
};
|
|
532
532
|
|
|
533
533
|
// Initialize trades websocket if it doesn't exist
|
|
@@ -535,12 +535,12 @@ export class Nord {
|
|
|
535
535
|
this.initializeWebSockets();
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
this.tradesWs!.on(
|
|
538
|
+
this.tradesWs!.on("trade", handleTrade);
|
|
539
539
|
this.tradesWs!.subscribe([`trades@${symbol}`]);
|
|
540
540
|
|
|
541
541
|
subscription.close = () => {
|
|
542
542
|
this.tradesWs!.unsubscribe([`trades@${symbol}`]);
|
|
543
|
-
this.tradesWs!.removeListener(
|
|
543
|
+
this.tradesWs!.removeListener("trade", handleTrade);
|
|
544
544
|
subscription.removeAllListeners();
|
|
545
545
|
};
|
|
546
546
|
|
|
@@ -598,7 +598,7 @@ export class Nord {
|
|
|
598
598
|
|
|
599
599
|
// Ensure market_id is provided
|
|
600
600
|
if (query.market_id === undefined) {
|
|
601
|
-
throw new NordError(
|
|
601
|
+
throw new NordError("market_id is required for orderbook query");
|
|
602
602
|
}
|
|
603
603
|
|
|
604
604
|
return market.getOrderbook(this.webServerUrl, query);
|
|
@@ -645,7 +645,7 @@ export class Nord {
|
|
|
645
645
|
try {
|
|
646
646
|
await market.getUserAccountIds(this.webServerUrl, { pubkey: address });
|
|
647
647
|
return true;
|
|
648
|
-
} catch
|
|
648
|
+
} catch {
|
|
649
649
|
return false;
|
|
650
650
|
}
|
|
651
651
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import * as anchor from
|
|
1
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
2
2
|
import {
|
|
3
3
|
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
4
4
|
getAssociatedTokenAddress,
|
|
5
5
|
TOKEN_2022_PROGRAM_ID,
|
|
6
|
-
} from
|
|
7
|
-
import { Connection, Keypair, PublicKey, Transaction } from
|
|
8
|
-
import Decimal from
|
|
9
|
-
import * as nacl from
|
|
10
|
-
import { SolanaBridgeClient } from
|
|
11
|
-
import { SPLTokenInfo } from
|
|
12
|
-
import { keypairFromPrivateKey } from
|
|
13
|
-
import { FillMode, Order, Side } from
|
|
6
|
+
} from "@solana/spl-token";
|
|
7
|
+
import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js";
|
|
8
|
+
import Decimal from "decimal.js";
|
|
9
|
+
import * as nacl from "tweetnacl";
|
|
10
|
+
import { SolanaBridgeClient } from "../../bridge/client";
|
|
11
|
+
import { SPLTokenInfo } from "../../bridge/types";
|
|
12
|
+
import { keypairFromPrivateKey } from "../../bridge/utils";
|
|
13
|
+
import { FillMode, Order, Side } from "../../types";
|
|
14
14
|
import {
|
|
15
15
|
BigIntValue,
|
|
16
16
|
checkedFetch,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
findToken,
|
|
19
19
|
optExpect,
|
|
20
20
|
toBN as utilsToBN,
|
|
21
|
-
} from
|
|
21
|
+
} from "../../utils";
|
|
22
22
|
import {
|
|
23
23
|
cancelOrder,
|
|
24
24
|
createSession,
|
|
@@ -26,9 +26,9 @@ import {
|
|
|
26
26
|
revokeSession,
|
|
27
27
|
transfer,
|
|
28
28
|
withdraw,
|
|
29
|
-
} from
|
|
30
|
-
import { NordError } from
|
|
31
|
-
import { Nord } from
|
|
29
|
+
} from "../api/actions";
|
|
30
|
+
import { NordError } from "../utils/NordError";
|
|
31
|
+
import { Nord } from "./Nord";
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Parameters for creating a NordUser instance
|
|
@@ -218,19 +218,19 @@ export class NordUser {
|
|
|
218
218
|
*/
|
|
219
219
|
constructor(params: NordUserParams) {
|
|
220
220
|
if (!params.nord) {
|
|
221
|
-
throw new NordError(
|
|
221
|
+
throw new NordError("Nord instance is required");
|
|
222
222
|
}
|
|
223
223
|
if (!params.address) {
|
|
224
|
-
throw new NordError(
|
|
224
|
+
throw new NordError("Address is required");
|
|
225
225
|
}
|
|
226
226
|
if (!params.walletSignFn) {
|
|
227
|
-
throw new NordError(
|
|
227
|
+
throw new NordError("Wallet sign function is required");
|
|
228
228
|
}
|
|
229
229
|
if (!params.sessionSignFn) {
|
|
230
|
-
throw new NordError(
|
|
230
|
+
throw new NordError("Session sign function is required");
|
|
231
231
|
}
|
|
232
232
|
if (!params.sessionPubKey) {
|
|
233
|
-
throw new NordError(
|
|
233
|
+
throw new NordError("Session public key is required");
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
this.nord = params.nord;
|
|
@@ -243,7 +243,7 @@ export class NordUser {
|
|
|
243
243
|
this.connection =
|
|
244
244
|
params.connection ||
|
|
245
245
|
new Connection(params.nord.solanaUrl, {
|
|
246
|
-
commitment:
|
|
246
|
+
commitment: "confirmed",
|
|
247
247
|
});
|
|
248
248
|
|
|
249
249
|
// Set sessionId if provided
|
|
@@ -255,7 +255,7 @@ export class NordUser {
|
|
|
255
255
|
try {
|
|
256
256
|
this.initBridgeClient();
|
|
257
257
|
} catch (error) {
|
|
258
|
-
console.warn(
|
|
258
|
+
console.warn("Failed to initialize bridge client:", error);
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
// Convert tokens from info endpoint to SPLTokenInfo
|
|
@@ -314,7 +314,7 @@ export class NordUser {
|
|
|
314
314
|
!this.nord.solanaProgramId
|
|
315
315
|
) {
|
|
316
316
|
throw new NordError(
|
|
317
|
-
|
|
317
|
+
"Solana public key, connection, and program ID are required to initialize bridge client",
|
|
318
318
|
);
|
|
319
319
|
}
|
|
320
320
|
|
|
@@ -322,14 +322,12 @@ export class NordUser {
|
|
|
322
322
|
const wallet: anchor.Wallet = {
|
|
323
323
|
publicKey: this.getSolanaPublicKey(),
|
|
324
324
|
signTransaction: async (tx: any) => {
|
|
325
|
-
await this.transactionSignFn(tx);
|
|
326
|
-
return tx;
|
|
325
|
+
return await this.transactionSignFn(tx);
|
|
327
326
|
},
|
|
328
327
|
signAllTransactions: async (txs: any[]) => {
|
|
329
328
|
return Promise.all(
|
|
330
329
|
txs.map(async (tx) => {
|
|
331
|
-
await this.transactionSignFn(tx);
|
|
332
|
-
return tx;
|
|
330
|
+
return await this.transactionSignFn(tx);
|
|
333
331
|
}),
|
|
334
332
|
);
|
|
335
333
|
},
|
|
@@ -345,7 +343,7 @@ export class NordUser {
|
|
|
345
343
|
{
|
|
346
344
|
rpcUrl: this.connection.rpcEndpoint,
|
|
347
345
|
programId: this.nord.solanaProgramId,
|
|
348
|
-
commitment:
|
|
346
|
+
commitment: "confirmed",
|
|
349
347
|
tokenInfos: this.splTokenInfos,
|
|
350
348
|
},
|
|
351
349
|
wallet,
|
|
@@ -375,7 +373,7 @@ export class NordUser {
|
|
|
375
373
|
message: Uint8Array | string,
|
|
376
374
|
): Promise<Uint8Array> => {
|
|
377
375
|
const messageBuffer =
|
|
378
|
-
typeof message ===
|
|
376
|
+
typeof message === "string"
|
|
379
377
|
? Buffer.from(message)
|
|
380
378
|
: Buffer.from(message);
|
|
381
379
|
|
|
@@ -401,7 +399,7 @@ export class NordUser {
|
|
|
401
399
|
}
|
|
402
400
|
|
|
403
401
|
// For other transaction types, would need specific implementation
|
|
404
|
-
throw new NordError(
|
|
402
|
+
throw new NordError("Unsupported transaction type for signing");
|
|
405
403
|
};
|
|
406
404
|
|
|
407
405
|
return new NordUser({
|
|
@@ -415,7 +413,7 @@ export class NordUser {
|
|
|
415
413
|
sessionPubKey: publicKey.toBytes(), // Use the public key derived from the private key as the session public key
|
|
416
414
|
});
|
|
417
415
|
} catch (error) {
|
|
418
|
-
throw new NordError(
|
|
416
|
+
throw new NordError("Failed to create NordUser from private key", {
|
|
419
417
|
cause: error,
|
|
420
418
|
});
|
|
421
419
|
}
|
|
@@ -431,7 +429,7 @@ export class NordUser {
|
|
|
431
429
|
async getAssociatedTokenAccount(mint: PublicKey): Promise<PublicKey> {
|
|
432
430
|
if (!this.getSolanaPublicKey()) {
|
|
433
431
|
throw new NordError(
|
|
434
|
-
|
|
432
|
+
"Solana public key is required to get associated token account",
|
|
435
433
|
);
|
|
436
434
|
}
|
|
437
435
|
|
|
@@ -444,7 +442,7 @@ export class NordUser {
|
|
|
444
442
|
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
445
443
|
);
|
|
446
444
|
} catch (error) {
|
|
447
|
-
throw new NordError(
|
|
445
|
+
throw new NordError("Failed to get associated token account", {
|
|
448
446
|
cause: error,
|
|
449
447
|
});
|
|
450
448
|
}
|
|
@@ -461,7 +459,7 @@ export class NordUser {
|
|
|
461
459
|
async depositSpl(amount: number, tokenId: number): Promise<string> {
|
|
462
460
|
if (!this.bridgeClient || !this.getSolanaPublicKey() || !this.connection) {
|
|
463
461
|
throw new NordError(
|
|
464
|
-
|
|
462
|
+
"Bridge client, Solana public key, and connection are required for deposit",
|
|
465
463
|
);
|
|
466
464
|
}
|
|
467
465
|
|
|
@@ -513,7 +511,7 @@ export class NordUser {
|
|
|
513
511
|
async withdrawSpl(claim: any): Promise<string> {
|
|
514
512
|
if (!this.bridgeClient || !this.getSolanaPublicKey() || !this.connection) {
|
|
515
513
|
throw new NordError(
|
|
516
|
-
|
|
514
|
+
"Bridge client, Solana public key, and connection are required for withdrawal",
|
|
517
515
|
);
|
|
518
516
|
}
|
|
519
517
|
|
|
@@ -546,9 +544,7 @@ export class NordUser {
|
|
|
546
544
|
secretKey: new Uint8Array(64), // Dummy secret key, not actually used
|
|
547
545
|
sign: async (tx: Transaction) => {
|
|
548
546
|
const message = tx.serializeMessage();
|
|
549
|
-
|
|
550
|
-
// todo: fixxxxx
|
|
551
|
-
// tx.addSignature(this.getSolanaPublicKey()!, signature);
|
|
547
|
+
await this.walletSignFn(message);
|
|
552
548
|
return tx;
|
|
553
549
|
},
|
|
554
550
|
};
|
|
@@ -563,7 +559,7 @@ export class NordUser {
|
|
|
563
559
|
transactionSigner as unknown as Keypair, // Type cast to satisfy the API
|
|
564
560
|
);
|
|
565
561
|
} catch (error) {
|
|
566
|
-
throw new NordError(
|
|
562
|
+
throw new NordError("Failed to withdraw SPL tokens", { cause: error });
|
|
567
563
|
}
|
|
568
564
|
}
|
|
569
565
|
|
|
@@ -584,7 +580,7 @@ export class NordUser {
|
|
|
584
580
|
async updateAccountId(): Promise<void> {
|
|
585
581
|
try {
|
|
586
582
|
if (!this.publicKey) {
|
|
587
|
-
throw new NordError(
|
|
583
|
+
throw new NordError("Public key is required to update account ID");
|
|
588
584
|
}
|
|
589
585
|
|
|
590
586
|
const resp = await this.nord.getUserAccountIds({
|
|
@@ -593,7 +589,7 @@ export class NordUser {
|
|
|
593
589
|
|
|
594
590
|
this.accountIds = resp.accountIds;
|
|
595
591
|
} catch (error) {
|
|
596
|
-
throw new NordError(
|
|
592
|
+
throw new NordError("Failed to update account ID", { cause: error });
|
|
597
593
|
}
|
|
598
594
|
}
|
|
599
595
|
|
|
@@ -608,7 +604,7 @@ export class NordUser {
|
|
|
608
604
|
size: number;
|
|
609
605
|
price: number;
|
|
610
606
|
marketId: number;
|
|
611
|
-
side:
|
|
607
|
+
side: "ask" | "bid";
|
|
612
608
|
originalOrderSize?: number;
|
|
613
609
|
clientOrderId?: number | null;
|
|
614
610
|
}
|
|
@@ -691,7 +687,7 @@ export class NordUser {
|
|
|
691
687
|
}) => {
|
|
692
688
|
return {
|
|
693
689
|
orderId: order.orderId,
|
|
694
|
-
isLong: order.side ===
|
|
690
|
+
isLong: order.side === "bid",
|
|
695
691
|
size: order.size,
|
|
696
692
|
price: order.price,
|
|
697
693
|
marketId: order.marketId,
|
|
@@ -758,7 +754,7 @@ export class NordUser {
|
|
|
758
754
|
private checkSessionValidity(): void {
|
|
759
755
|
if (this.sessionId === undefined || this.sessionId === BigInt(0)) {
|
|
760
756
|
throw new NordError(
|
|
761
|
-
|
|
757
|
+
"Invalid or empty session ID. Please create or refresh your session.",
|
|
762
758
|
);
|
|
763
759
|
}
|
|
764
760
|
}
|
|
@@ -780,7 +776,7 @@ export class NordUser {
|
|
|
780
776
|
this.getNonce(),
|
|
781
777
|
{
|
|
782
778
|
sizeDecimals: findToken(this.nord.tokens, tokenId).decimals,
|
|
783
|
-
sessionId: optExpect(this.sessionId,
|
|
779
|
+
sessionId: optExpect(this.sessionId, "No session"),
|
|
784
780
|
tokenId: tokenId,
|
|
785
781
|
amount,
|
|
786
782
|
},
|
|
@@ -814,7 +810,7 @@ export class NordUser {
|
|
|
814
810
|
await this.nord.getTimestamp(),
|
|
815
811
|
this.getNonce(),
|
|
816
812
|
{
|
|
817
|
-
sessionId: optExpect(this.sessionId,
|
|
813
|
+
sessionId: optExpect(this.sessionId, "No session"),
|
|
818
814
|
senderId: params.accountId,
|
|
819
815
|
sizeDecimals: market.sizeDecimals,
|
|
820
816
|
priceDecimals: market.priceDecimals,
|
|
@@ -828,7 +824,7 @@ export class NordUser {
|
|
|
828
824
|
},
|
|
829
825
|
);
|
|
830
826
|
} catch (error) {
|
|
831
|
-
throw new NordError(
|
|
827
|
+
throw new NordError("Failed to place order", { cause: error });
|
|
832
828
|
}
|
|
833
829
|
}
|
|
834
830
|
|
|
@@ -844,7 +840,7 @@ export class NordUser {
|
|
|
844
840
|
orderId: BigIntValue,
|
|
845
841
|
providedAccountId?: number,
|
|
846
842
|
): Promise<bigint> {
|
|
847
|
-
|
|
843
|
+
const accountId =
|
|
848
844
|
providedAccountId != null ? providedAccountId : this.accountIds?.[0];
|
|
849
845
|
try {
|
|
850
846
|
this.checkSessionValidity();
|
|
@@ -854,7 +850,7 @@ export class NordUser {
|
|
|
854
850
|
await this.nord.getTimestamp(),
|
|
855
851
|
this.getNonce(),
|
|
856
852
|
{
|
|
857
|
-
sessionId: optExpect(this.sessionId,
|
|
853
|
+
sessionId: optExpect(this.sessionId, "No session"),
|
|
858
854
|
senderId: accountId,
|
|
859
855
|
orderId,
|
|
860
856
|
},
|
|
@@ -883,16 +879,16 @@ export class NordUser {
|
|
|
883
879
|
await this.nord.getTimestamp(),
|
|
884
880
|
this.getNonce(),
|
|
885
881
|
{
|
|
886
|
-
sessionId: optExpect(this.sessionId,
|
|
887
|
-
fromAccountId: optExpect(params.fromAccountId,
|
|
888
|
-
toAccountId: optExpect(params.toAccountId,
|
|
882
|
+
sessionId: optExpect(this.sessionId, "No session"),
|
|
883
|
+
fromAccountId: optExpect(params.fromAccountId, "No source account"),
|
|
884
|
+
toAccountId: optExpect(params.toAccountId, "No target account"),
|
|
889
885
|
tokenId: params.tokenId,
|
|
890
886
|
tokenDecimals: token.decimals,
|
|
891
887
|
amount: params.amount,
|
|
892
888
|
},
|
|
893
889
|
);
|
|
894
890
|
} catch (error) {
|
|
895
|
-
throw new NordError(
|
|
891
|
+
throw new NordError("Failed to transfer tokens", { cause: error });
|
|
896
892
|
}
|
|
897
893
|
}
|
|
898
894
|
|
|
@@ -921,16 +917,16 @@ export class NordUser {
|
|
|
921
917
|
to: newUser,
|
|
922
918
|
tokenId: params.tokenId,
|
|
923
919
|
amount: params.amount,
|
|
924
|
-
fromAccountId: optExpect(this.accountIds?.[0],
|
|
920
|
+
fromAccountId: optExpect(this.accountIds?.[0], "No account ID"),
|
|
925
921
|
toAccountId: optExpect(
|
|
926
922
|
newUser.accountIds?.[0],
|
|
927
|
-
|
|
923
|
+
"No account ID for new user",
|
|
928
924
|
),
|
|
929
925
|
});
|
|
930
926
|
|
|
931
927
|
return newUser;
|
|
932
928
|
} catch (error) {
|
|
933
|
-
throw new NordError(
|
|
929
|
+
throw new NordError("Failed to create account", { cause: error });
|
|
934
930
|
}
|
|
935
931
|
}
|
|
936
932
|
|
|
@@ -961,9 +957,9 @@ export class NordUser {
|
|
|
961
957
|
// Check if error is rate limiting related
|
|
962
958
|
const isRateLimitError =
|
|
963
959
|
error instanceof Error &&
|
|
964
|
-
(error.message.includes(
|
|
965
|
-
error.message.includes(
|
|
966
|
-
error.message.includes(
|
|
960
|
+
(error.message.includes("rate limit") ||
|
|
961
|
+
error.message.includes("429") ||
|
|
962
|
+
error.message.includes("too many requests"));
|
|
967
963
|
|
|
968
964
|
if (!isRateLimitError) {
|
|
969
965
|
throw error;
|
|
@@ -1007,7 +1003,7 @@ export class NordUser {
|
|
|
1007
1003
|
|
|
1008
1004
|
if (!this.connection || !this.getSolanaPublicKey()) {
|
|
1009
1005
|
throw new NordError(
|
|
1010
|
-
|
|
1006
|
+
"Connection and Solana public key are required to get Solana balances",
|
|
1011
1007
|
);
|
|
1012
1008
|
}
|
|
1013
1009
|
|
|
@@ -1020,9 +1016,9 @@ export class NordUser {
|
|
|
1020
1016
|
() => this.connection!.getBalance(this.getSolanaPublicKey()),
|
|
1021
1017
|
maxRetries,
|
|
1022
1018
|
);
|
|
1023
|
-
balances[
|
|
1019
|
+
balances["SOL"] = solBalance / 1e9; // Convert lamports to SOL
|
|
1024
1020
|
if (includeTokenAccounts) {
|
|
1025
|
-
tokenAccounts[
|
|
1021
|
+
tokenAccounts["SOL"] = this.getSolanaPublicKey().toString();
|
|
1026
1022
|
}
|
|
1027
1023
|
|
|
1028
1024
|
// Get SPL token balances using mintAddr from Nord tokens
|
|
@@ -1060,7 +1056,7 @@ export class NordUser {
|
|
|
1060
1056
|
if (balance > 0 || includeZeroBalances) {
|
|
1061
1057
|
balances[token.symbol] = balance;
|
|
1062
1058
|
}
|
|
1063
|
-
} catch
|
|
1059
|
+
} catch {
|
|
1064
1060
|
// Token account might not exist yet, set balance to 0
|
|
1065
1061
|
if (includeZeroBalances) {
|
|
1066
1062
|
balances[token.symbol] = 0;
|
|
@@ -1084,7 +1080,7 @@ export class NordUser {
|
|
|
1084
1080
|
|
|
1085
1081
|
return includeTokenAccounts ? { balances, tokenAccounts } : { balances };
|
|
1086
1082
|
} catch (error) {
|
|
1087
|
-
throw new NordError(
|
|
1083
|
+
throw new NordError("Failed to get Solana token balances", {
|
|
1088
1084
|
cause: error,
|
|
1089
1085
|
});
|
|
1090
1086
|
}
|
|
@@ -1099,7 +1095,7 @@ export class NordUser {
|
|
|
1099
1095
|
try {
|
|
1100
1096
|
return new PublicKey(this.address);
|
|
1101
1097
|
} catch (error) {
|
|
1102
|
-
throw new NordError(
|
|
1098
|
+
throw new NordError("Invalid Solana address", { cause: error });
|
|
1103
1099
|
}
|
|
1104
1100
|
}
|
|
1105
1101
|
}
|
package/src/nord/index.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// Export main client classes
|
|
2
|
-
export { Nord } from
|
|
3
|
-
export { NordUser } from
|
|
2
|
+
export { Nord } from "./client/Nord";
|
|
3
|
+
export { NordUser } from "./client/NordUser";
|
|
4
4
|
|
|
5
5
|
// Export utility classes
|
|
6
|
-
export { NordError } from
|
|
6
|
+
export { NordError } from "./utils/NordError";
|
|
7
7
|
|
|
8
8
|
// Export API modules
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
9
|
+
export * from "./api/core";
|
|
10
|
+
export * from "./api/metrics";
|
|
11
|
+
export * from "./api/queries";
|
|
12
|
+
export * from "./api/market";
|
|
13
|
+
export * from "./api/actions";
|
|
14
14
|
|
|
15
15
|
// Export models
|
|
16
|
-
export * from
|
|
16
|
+
export * from "./models/Subscriber";
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
1
|
+
import { EventEmitter } from "events";
|
|
3
2
|
import {
|
|
4
|
-
DeltaEvent,
|
|
5
|
-
Trades,
|
|
6
3
|
Account,
|
|
7
|
-
|
|
4
|
+
DeltaEvent,
|
|
8
5
|
OrderbookResponse,
|
|
6
|
+
SubscriberConfig,
|
|
9
7
|
Trade,
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
Trades,
|
|
9
|
+
} from "../../types";
|
|
10
|
+
import { MAX_BUFFER_LEN } from "../../utils";
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Subscriber class for handling WebSocket subscriptions
|
|
@@ -32,7 +31,7 @@ export class Subscriber {
|
|
|
32
31
|
* Subscribe to WebSocket events
|
|
33
32
|
*/
|
|
34
33
|
subscribe(): void {
|
|
35
|
-
|
|
34
|
+
// TODO: Implement subscription logic
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -40,8 +39,8 @@ export class Subscriber {
|
|
|
40
39
|
* Interface for orderbook subscription
|
|
41
40
|
*/
|
|
42
41
|
export interface OrderbookSubscription extends EventEmitter {
|
|
43
|
-
on(event:
|
|
44
|
-
on(event:
|
|
42
|
+
on(event: "message", listener: (data: OrderbookResponse) => void): this;
|
|
43
|
+
on(event: "error", listener: (error: Error) => void): this;
|
|
45
44
|
close(): void;
|
|
46
45
|
removeAllListeners(event?: string): this;
|
|
47
46
|
}
|
|
@@ -50,8 +49,8 @@ export interface OrderbookSubscription extends EventEmitter {
|
|
|
50
49
|
* Interface for trade subscription
|
|
51
50
|
*/
|
|
52
51
|
export interface TradeSubscription extends EventEmitter {
|
|
53
|
-
on(event:
|
|
54
|
-
on(event:
|
|
52
|
+
on(event: "message", listener: (data: Trade[]) => void): this;
|
|
53
|
+
on(event: "error", listener: (error: Error) => void): this;
|
|
55
54
|
close(): void;
|
|
56
55
|
removeAllListeners(event?: string): this;
|
|
57
56
|
}
|
|
@@ -34,7 +34,7 @@ export class NordError extends Error {
|
|
|
34
34
|
constructor(message: string, options: NordErrorOptions = {}) {
|
|
35
35
|
super(message);
|
|
36
36
|
|
|
37
|
-
this.name =
|
|
37
|
+
this.name = "NordError";
|
|
38
38
|
this.cause = options.cause;
|
|
39
39
|
this.statusCode = options.statusCode;
|
|
40
40
|
this.details = options.details;
|
|
@@ -47,7 +47,7 @@ export class NordError extends Error {
|
|
|
47
47
|
// Handle nested errors
|
|
48
48
|
if (this.cause instanceof Error) {
|
|
49
49
|
this.stack =
|
|
50
|
-
this.stack +
|
|
50
|
+
this.stack + "\nCaused by: " + (this.cause.stack || this.cause.message);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|