@injectivelabs/sdk-ts 1.17.2-alpha.9 → 1.17.2
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/cjs/{AbacusGrpcApi-vcp-9fNL.cjs → AbacusGrpcApi-DXSuhb6R.cjs} +1 -1
- package/dist/cjs/{BaseGrpcConsumer-DUwCngI6.cjs → BaseGrpcConsumer-EtEQfhmo.cjs} +47 -6
- package/dist/{esm/BaseGrpcConsumer-BbvNzhrS.d.ts → cjs/BaseGrpcConsumer-Vvj4lzyS.d.cts} +14 -2
- package/dist/cjs/{BaseIndexerGrpcConsumer-BGLVnJtw.cjs → BaseIndexerGrpcConsumer-CW1kTn-_.cjs} +1 -1
- package/dist/cjs/{ChainGrpcExchangeApi-DLpkgEyg.cjs → ChainGrpcExchangeApi-CF9ATYqN.cjs} +3 -3
- package/dist/cjs/{ChainRestTendermintApi-BiZOeKcG.cjs → ChainRestTendermintApi-vL0g-BF-.cjs} +2 -2
- package/dist/cjs/{DirectEthSecp256k1Wallet-CU18lti3.cjs → DirectEthSecp256k1Wallet-CIdxvYjL.cjs} +2 -2
- package/dist/cjs/{ExecArgNeptuneWithdraw-DOHeo3AJ.cjs → ExecArgNeptuneWithdraw-C-NQ72VM.cjs} +1 -1
- package/dist/cjs/{IndexerGrpcWeb3GwApi-BgWT2tWK.cjs → IndexerGrpcWeb3GwApi-C7kkr4Il.cjs} +2 -2
- package/dist/cjs/{MsgSetDenomMetadata-CUoGqV8P.cjs → MsgSetDenomMetadata-CKvxIq_t.cjs} +21 -10
- package/dist/cjs/{OLPGrpcApi-B9O9HcGv.cjs → OLPGrpcApi-BCCb6fBZ.cjs} +1 -1
- package/dist/cjs/{QueryTradingStrategyContractTotalStrategies-Bh8AXm4k.cjs → QueryTradingStrategyContractTotalStrategies-Ayot_18R.cjs} +3 -3
- package/dist/cjs/{IndexerGrpcAccountPortfolioStream-DO5_FF4l.cjs → StreamManagerV2-igv0mn2I.cjs} +1375 -378
- package/dist/cjs/{accounts-CXaUasU5.cjs → accounts-CHKUxDIf.cjs} +1 -1
- package/dist/{esm/any_pb-B1YYUSUf.d.ts → cjs/any_pb-CutLnOUR.d.cts} +2 -2
- package/dist/cjs/{chain-Cs9sNuT1.cjs → chain-CGHrf7gg.cjs} +4 -4
- package/dist/cjs/client/abacus.cjs +2 -2
- package/dist/cjs/client/abacus.d.cts +2 -2
- package/dist/cjs/client/chain.cjs +5 -5
- package/dist/cjs/client/chain.d.cts +9 -9
- package/dist/cjs/client/indexer.cjs +74 -60
- package/dist/cjs/client/indexer.d.cts +10 -10
- package/dist/cjs/client/olp.cjs +3 -3
- package/dist/cjs/client/olp.d.cts +2 -2
- package/dist/cjs/client/wasm.cjs +7 -7
- package/dist/cjs/client/wasm.d.cts +2 -2
- package/dist/cjs/core/accounts.cjs +2 -2
- package/dist/cjs/core/accounts.d.cts +9 -9
- package/dist/cjs/core/modules.cjs +10 -10
- package/dist/cjs/core/modules.d.cts +9 -9
- package/dist/cjs/core/tx.cjs +7 -7
- package/dist/cjs/core/tx.d.cts +9 -9
- package/dist/cjs/cosmjs.cjs +8 -8
- package/dist/cjs/cosmjs.d.cts +3 -3
- package/dist/cjs/exports.cjs +8 -8
- package/dist/cjs/exports.d.cts +3 -3
- package/dist/cjs/{index-Cc5Q73-y.d.cts → index-CGvISJoE.d.cts} +1 -1
- package/dist/cjs/{index-CKBod1ba.d.cts → index-CO3Y9drx.d.cts} +4 -3
- package/dist/cjs/{index-Cc4mqAsR.d.cts → index-D6ubyMlR.d.cts} +1 -1
- package/dist/{esm/index-DdGVE3_u.d.ts → cjs/index-DWbxb1AB.d.cts} +7 -13
- package/dist/cjs/{index-1Wy-0PTh.d.cts → index-DemZnO3c.d.cts} +969 -291
- package/dist/cjs/{index-Cqfc1ppG.d.cts → index-DjRtDAy5.d.cts} +241 -19
- package/dist/cjs/{index-B19YRG03.d.cts → index-lRWP4rKg.d.cts} +1 -1
- package/dist/cjs/index.cjs +92 -70
- package/dist/cjs/index.d.cts +10 -10
- package/dist/cjs/{service-DcwwCSxu.cjs → service-BCLvTVy_.cjs} +2 -2
- package/dist/cjs/service.cjs +3 -3
- package/dist/cjs/service.d.cts +4 -4
- package/dist/cjs/{tx-Cn0j2SRh.cjs → tx-VwbP3UdI.cjs} +6 -6
- package/dist/{esm/tx_pb-TiSRD5ay.d.ts → cjs/tx_pb-D-cNmrlO.d.cts} +4 -3
- package/dist/cjs/{types-NFV4P_J_.cjs → types-BTuy007B.cjs} +135 -7
- package/dist/cjs/types.cjs +7 -1
- package/dist/cjs/types.d.cts +4 -4
- package/dist/cjs/{utils-V1uXtT51.cjs → utils-CDl812vv.cjs} +44 -8
- package/dist/cjs/utils.cjs +3 -1
- package/dist/cjs/utils.d.cts +10 -10
- package/dist/esm/{AbacusGrpcApi-CXaVHTrN.js → AbacusGrpcApi-Ce1hRKuD.js} +1 -1
- package/dist/{cjs/BaseGrpcConsumer-PDufF0fz.d.cts → esm/BaseGrpcConsumer-6x4RlZ16.d.ts} +14 -2
- package/dist/esm/{BaseGrpcConsumer-DptVGP0n.js → BaseGrpcConsumer-BTWyD665.js} +48 -7
- package/dist/esm/{BaseIndexerGrpcConsumer-CjpUoGXy.js → BaseIndexerGrpcConsumer-BTZzA_Eg.js} +1 -1
- package/dist/esm/{ChainGrpcExchangeApi-C-2XsVVs.js → ChainGrpcExchangeApi-DqdCst2Z.js} +3 -3
- package/dist/esm/{ChainRestTendermintApi-CMrAg0Zm.js → ChainRestTendermintApi-BT_yOkAV.js} +2 -2
- package/dist/esm/{DirectEthSecp256k1Wallet-a9KiF9fA.js → DirectEthSecp256k1Wallet-BqxC1b40.js} +2 -2
- package/dist/esm/{ExecArgNeptuneWithdraw-DEljIeLd.js → ExecArgNeptuneWithdraw-uLf3HttI.js} +1 -1
- package/dist/esm/{IndexerGrpcWeb3GwApi-CtUYowus.js → IndexerGrpcWeb3GwApi-B2mgt9tE.js} +2 -2
- package/dist/esm/{MsgSetDenomMetadata-BhJMebO9.js → MsgSetDenomMetadata-CXgkQ3LF.js} +21 -10
- package/dist/esm/{OLPGrpcApi-CMwW7LXZ.js → OLPGrpcApi-DUCfcca_.js} +1 -1
- package/dist/esm/{QueryTradingStrategyContractTotalStrategies-7IjWZLsc.js → QueryTradingStrategyContractTotalStrategies-CZWdw3BE.js} +3 -3
- package/dist/esm/{IndexerGrpcAccountPortfolioStream-3AGGiB1c.js → StreamManagerV2-B9xiJYLj.js} +1116 -203
- package/dist/esm/{accounts-DFC9RYDH.js → accounts-C5HEaz0B.js} +1 -1
- package/dist/{cjs/any_pb-CP-3DVyl.d.cts → esm/any_pb-DBt7qvTr.d.ts} +2 -2
- package/dist/esm/{chain-phKWVf8c.js → chain-CHX5uSpc.js} +4 -4
- package/dist/esm/client/abacus.d.ts +2 -2
- package/dist/esm/client/abacus.js +2 -2
- package/dist/esm/client/chain.d.ts +9 -9
- package/dist/esm/client/chain.js +5 -5
- package/dist/esm/client/indexer.d.ts +10 -10
- package/dist/esm/client/indexer.js +7 -7
- package/dist/esm/client/olp.d.ts +2 -2
- package/dist/esm/client/olp.js +3 -3
- package/dist/esm/client/wasm.d.ts +2 -2
- package/dist/esm/client/wasm.js +7 -7
- package/dist/esm/core/accounts.d.ts +9 -9
- package/dist/esm/core/accounts.js +2 -2
- package/dist/esm/core/modules.d.ts +9 -9
- package/dist/esm/core/modules.js +10 -10
- package/dist/esm/core/tx.d.ts +9 -9
- package/dist/esm/core/tx.js +7 -7
- package/dist/esm/cosmjs.d.ts +3 -3
- package/dist/esm/cosmjs.js +8 -8
- package/dist/esm/exports.d.ts +3 -3
- package/dist/esm/exports.js +8 -8
- package/dist/esm/{index-BOKuUpVZ.d.ts → index--sg5xbEP.d.ts} +1 -1
- package/dist/esm/{index-B1R417vW.d.ts → index-B-SD0p02.d.ts} +241 -19
- package/dist/esm/{index-qFCOVI7n.d.ts → index-BJQt8IpY.d.ts} +1 -1
- package/dist/esm/{index-DS6aJrL5.d.ts → index-C_3bL-y4.d.ts} +1 -1
- package/dist/esm/{index-IV55OZfT.d.ts → index-Ch477yfL.d.ts} +984 -306
- package/dist/esm/{index-aNMYd-s0.d.ts → index-DOyiZiUK.d.ts} +4 -3
- package/dist/{cjs/index-D4uWOVE5.d.cts → esm/index-Dn4OxoMy.d.ts} +7 -13
- package/dist/esm/index.d.ts +10 -10
- package/dist/esm/index.js +18 -18
- package/dist/esm/{service-CoINtWpF.js → service-CnqMmybI.js} +2 -2
- package/dist/esm/service.d.ts +4 -4
- package/dist/esm/service.js +3 -3
- package/dist/esm/{tx-CcaVBSym.js → tx-DsGG15fH.js} +6 -6
- package/dist/{cjs/tx_pb-tECSPcSB.d.cts → esm/tx_pb-zz4o4hHG.d.ts} +4 -3
- package/dist/esm/types-68OuBiEQ.js +162 -0
- package/dist/esm/types.d.ts +4 -4
- package/dist/esm/types.js +2 -2
- package/dist/esm/{utils-DwGoPRTL.js → utils-BFBu_LnJ.js} +33 -9
- package/dist/esm/utils.d.ts +10 -10
- package/dist/esm/utils.js +2 -2
- package/package.json +11 -13
- package/dist/esm/types-Cq0sRR6y.js +0 -70
package/dist/esm/{IndexerGrpcAccountPortfolioStream-3AGGiB1c.js → StreamManagerV2-B9xiJYLj.js}
RENAMED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Jt as uint8ArrayToString, a as grpcPagingToPagingV2,
|
|
1
|
+
import { Jt as uint8ArrayToString, Xt as bigIntToNumber, Zt as bigIntToString, a as grpcPagingToPagingV2, nn as isJsonString } from "./utils-BFBu_LnJ.js";
|
|
2
2
|
import { t as _defineProperty } from "./defineProperty-Bq6QU9Te.js";
|
|
3
|
-
import { n as GrpcWebRpcTransport } from "./BaseGrpcConsumer-
|
|
4
|
-
import { t as BaseIndexerGrpcConsumer } from "./BaseIndexerGrpcConsumer-
|
|
3
|
+
import { n as GrpcWebRpcTransport } from "./BaseGrpcConsumer-BTWyD665.js";
|
|
4
|
+
import { t as BaseIndexerGrpcConsumer } from "./BaseIndexerGrpcConsumer-BTZzA_Eg.js";
|
|
5
5
|
import { t as BaseRestConsumer } from "./BaseRestConsumer-rK4eS4W8.js";
|
|
6
|
-
import { r as IndexerModule } from "./IndexerGrpcWeb3GwApi-
|
|
7
|
-
import { a as
|
|
6
|
+
import { r as IndexerModule } from "./IndexerGrpcWeb3GwApi-B2mgt9tE.js";
|
|
7
|
+
import { a as TradeDirection, c as GrpcStatusCode, d as StreamState, i as OrderState, l as StreamDisconnectReason, m as TokenVerification, p as TokenType, t as StreamOperation, u as StreamEvent } from "./types-68OuBiEQ.js";
|
|
8
8
|
import { BigNumber, toBigNumber, toHumanReadable } from "@injectivelabs/utils";
|
|
9
9
|
import { GeneralException, HttpRequestException, UnspecifiedErrorCode } from "@injectivelabs/exceptions";
|
|
10
|
-
import { OrderState, StreamOperation, TradeDirection } from "@injectivelabs/ts-types";
|
|
11
10
|
import { MitoAPIClient } from "@injectivelabs/mito-proto-ts-v2/generated/goadesign_goagen_mito_api_pb.client";
|
|
12
11
|
import * as GoadesignGoagenMitoApiPb from "@injectivelabs/mito-proto-ts-v2/generated/goadesign_goagen_mito_api_pb";
|
|
13
12
|
import * as InjectiveMetaRpcPb from "@injectivelabs/indexer-proto-ts-v2/generated/injective_meta_rpc_pb";
|
|
@@ -38,6 +37,7 @@ import * as InjectivePortfolioRpcPb from "@injectivelabs/indexer-proto-ts-v2/gen
|
|
|
38
37
|
import { InjectivePortfolioRPCClient } from "@injectivelabs/indexer-proto-ts-v2/generated/injective_portfolio_rpc_pb.client";
|
|
39
38
|
import * as InjectiveInsuranceRpcPb from "@injectivelabs/indexer-proto-ts-v2/generated/injective_insurance_rpc_pb";
|
|
40
39
|
import { InjectiveInsuranceRPCClient } from "@injectivelabs/indexer-proto-ts-v2/generated/injective_insurance_rpc_pb.client";
|
|
40
|
+
import { EventEmitter } from "eventemitter3";
|
|
41
41
|
|
|
42
42
|
//#region src/client/indexer/transformers/IndexerCommonTransformer.ts
|
|
43
43
|
var IndexerCommonTransformer = class {
|
|
@@ -129,7 +129,7 @@ var IndexerGrpcMitoTransformer = class IndexerGrpcMitoTransformer {
|
|
|
129
129
|
static portfolioResponseToPortfolio(portfolio) {
|
|
130
130
|
return {
|
|
131
131
|
pnl: portfolio.pnl,
|
|
132
|
-
totalValue:
|
|
132
|
+
totalValue: bigIntToNumber(portfolio.totalValue),
|
|
133
133
|
updatedAt: Number(portfolio.pnlUpdatedAt),
|
|
134
134
|
totalValueChartList: portfolio.totalValueChart.map(IndexerGrpcMitoTransformer.mitoPriceSnapshotToPriceSnapshot),
|
|
135
135
|
pnlChartList: portfolio.pnlChart.map(IndexerGrpcMitoTransformer.mitoPriceSnapshotToPriceSnapshot)
|
|
@@ -138,7 +138,7 @@ var IndexerGrpcMitoTransformer = class IndexerGrpcMitoTransformer {
|
|
|
138
138
|
static leaderboardResponseToLeaderboard(leaderboard) {
|
|
139
139
|
return {
|
|
140
140
|
epochId: leaderboard.epochId,
|
|
141
|
-
snapshotBlock:
|
|
141
|
+
snapshotBlock: bigIntToString(leaderboard.snapshotBlock),
|
|
142
142
|
updatedAt: Number(leaderboard.updatedAt),
|
|
143
143
|
entriesList: leaderboard.entries.map((entry) => ({
|
|
144
144
|
address: entry.address,
|
|
@@ -229,25 +229,25 @@ var IndexerGrpcMitoTransformer = class IndexerGrpcMitoTransformer {
|
|
|
229
229
|
stakedAmount: holder.stakedAmount,
|
|
230
230
|
holderAddress: holder.holderAddress,
|
|
231
231
|
lpAmountPercentage: holder.lpAmountPercentage,
|
|
232
|
-
redemptionLockTime:
|
|
232
|
+
redemptionLockTime: bigIntToString(holder.redemptionLockTime),
|
|
233
233
|
updatedAt: Number(holder.updatedAt)
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
static mitoMissionToMission(mission) {
|
|
237
237
|
return {
|
|
238
238
|
id: mission.id,
|
|
239
|
-
points:
|
|
239
|
+
points: bigIntToString(mission.points),
|
|
240
240
|
progress: mission.progress,
|
|
241
241
|
expected: mission.expected,
|
|
242
242
|
completed: mission.completed,
|
|
243
|
-
accruedPoints:
|
|
243
|
+
accruedPoints: bigIntToString(mission.accruedPoints),
|
|
244
244
|
updatedAt: Number(mission.updatedAt)
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
static mitoMissionLeaderboardEntryToMissionLeaderboardEntry(entry) {
|
|
248
248
|
return {
|
|
249
249
|
address: entry.address,
|
|
250
|
-
accruedPoints:
|
|
250
|
+
accruedPoints: bigIntToString(entry.accruedPoints)
|
|
251
251
|
};
|
|
252
252
|
}
|
|
253
253
|
static mitoIDOProgressToIDOProgress(progress) {
|
|
@@ -1296,15 +1296,15 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1296
1296
|
tokens: data.tokens,
|
|
1297
1297
|
delegatorShares: data.delegatorShares,
|
|
1298
1298
|
description: IndexerGrpcExplorerTransformer.grpcValidatorDescriptionToValidatorDescription(data.description),
|
|
1299
|
-
unbondingHeight:
|
|
1299
|
+
unbondingHeight: bigIntToNumber(data.unbondingHeight),
|
|
1300
1300
|
unbondingTime: data.unbondingTime,
|
|
1301
1301
|
commissionRate: data.commissionRate,
|
|
1302
1302
|
commissionMaxRate: data.commissionMaxRate,
|
|
1303
1303
|
commissionMaxChangeRate: data.commissionMaxChangeRate,
|
|
1304
1304
|
commissionUpdateTime: data.commissionUpdateTime,
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1305
|
+
signed: bigIntToNumber(data.signed),
|
|
1306
|
+
missed: bigIntToNumber(data.missed),
|
|
1307
|
+
proposed: bigIntToNumber(data.proposed),
|
|
1308
1308
|
uptimePercentage: data.uptimePercentage,
|
|
1309
1309
|
imageUrl: data.imageUrl,
|
|
1310
1310
|
timestamp: data.timestamp,
|
|
@@ -1315,14 +1315,14 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1315
1315
|
static streamTxResponseToTxs(response) {
|
|
1316
1316
|
return {
|
|
1317
1317
|
id: response.id,
|
|
1318
|
-
blockNumber: typeof response.blockNumber === "bigint" ? Number(response.blockNumber) : parseInt(response.blockNumber, 10),
|
|
1319
|
-
blockTimestamp: response.blockTimestamp,
|
|
1320
1318
|
hash: response.hash,
|
|
1321
|
-
|
|
1319
|
+
code: response.code,
|
|
1322
1320
|
messages: response.messages,
|
|
1323
|
-
txNumber: typeof response.txNumber === "bigint" ? Number(response.txNumber) : parseInt(response.txNumber, 10),
|
|
1324
1321
|
errorLog: response.errorLog,
|
|
1325
|
-
|
|
1322
|
+
codespace: response.codespace,
|
|
1323
|
+
blockTimestamp: response.blockTimestamp,
|
|
1324
|
+
txNumber: bigIntToNumber(response.txNumber),
|
|
1325
|
+
blockNumber: bigIntToNumber(response.blockNumber)
|
|
1326
1326
|
};
|
|
1327
1327
|
}
|
|
1328
1328
|
static grpcGasFeeToGasFee(gasFee) {
|
|
@@ -1331,43 +1331,43 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1331
1331
|
amount: amount.amount,
|
|
1332
1332
|
denom: amount.denom
|
|
1333
1333
|
})),
|
|
1334
|
-
gasLimit: typeof gasFee.gasLimit === "bigint" ? Number(gasFee.gasLimit) : parseInt(gasFee.gasLimit, 10),
|
|
1335
1334
|
payer: gasFee.payer,
|
|
1336
|
-
granter: gasFee.granter
|
|
1335
|
+
granter: gasFee.granter,
|
|
1336
|
+
gasLimit: bigIntToNumber(gasFee.gasLimit)
|
|
1337
1337
|
};
|
|
1338
1338
|
}
|
|
1339
1339
|
static grpcTransactionToBankMsgSendTransaction(tx) {
|
|
1340
1340
|
const data = tx.data;
|
|
1341
1341
|
const [message] = JSON.parse(uint8ArrayToString(data.messages));
|
|
1342
1342
|
return {
|
|
1343
|
-
blockNumber: typeof data.blockNumber === "bigint" ? Number(data.blockNumber) : parseInt(data.blockNumber, 10),
|
|
1344
|
-
blockTimestamp: data.blockTimestamp,
|
|
1345
1343
|
hash: data.hash,
|
|
1346
|
-
amount: message.value.amount[0].amount,
|
|
1347
|
-
denom: message.value.amount[0].denom,
|
|
1348
1344
|
sender: message.value.from_address,
|
|
1349
|
-
receiver: message.value.to_address
|
|
1345
|
+
receiver: message.value.to_address,
|
|
1346
|
+
blockTimestamp: data.blockTimestamp,
|
|
1347
|
+
denom: message.value.amount[0].denom,
|
|
1348
|
+
amount: message.value.amount[0].amount,
|
|
1349
|
+
blockNumber: bigIntToNumber(data.blockNumber)
|
|
1350
1350
|
};
|
|
1351
1351
|
}
|
|
1352
1352
|
static grpcTransactionToTransaction(tx) {
|
|
1353
1353
|
const data = tx.data;
|
|
1354
1354
|
return {
|
|
1355
1355
|
id: data.id,
|
|
1356
|
-
blockNumber: typeof data.blockNumber === "bigint" ? Number(data.blockNumber) : parseInt(data.blockNumber, 10),
|
|
1357
|
-
blockTimestamp: data.blockTimestamp,
|
|
1358
1356
|
hash: data.hash,
|
|
1359
1357
|
code: data.code,
|
|
1360
1358
|
info: data.info,
|
|
1361
|
-
gasWanted: typeof data.gasWanted === "bigint" ? Number(data.gasWanted) : parseInt(data.gasWanted, 10),
|
|
1362
|
-
gasUsed: typeof data.gasUsed === "bigint" ? Number(data.gasUsed) : parseInt(data.gasUsed, 10),
|
|
1363
|
-
codespace: data.codespace,
|
|
1364
1359
|
data: data.data,
|
|
1365
|
-
gasFee: IndexerGrpcExplorerTransformer.grpcGasFeeToGasFee(data.gasFee),
|
|
1366
1360
|
txType: data.txType,
|
|
1361
|
+
codespace: data.codespace,
|
|
1362
|
+
blockTimestamp: data.blockTimestamp,
|
|
1363
|
+
gasUsed: bigIntToNumber(data.gasUsed),
|
|
1364
|
+
gasWanted: bigIntToNumber(data.gasWanted),
|
|
1365
|
+
blockNumber: bigIntToNumber(data.blockNumber),
|
|
1366
|
+
gasFee: IndexerGrpcExplorerTransformer.grpcGasFeeToGasFee(data.gasFee),
|
|
1367
1367
|
signatures: data.signatures.map((signature) => ({
|
|
1368
1368
|
pubkey: signature.pubkey,
|
|
1369
1369
|
address: signature.address,
|
|
1370
|
-
sequence:
|
|
1370
|
+
sequence: bigIntToNumber(signature.sequence),
|
|
1371
1371
|
signature: signature.signature
|
|
1372
1372
|
})),
|
|
1373
1373
|
events: data.events.map((event) => ({
|
|
@@ -1384,14 +1384,14 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1384
1384
|
const messages = JSON.parse(uint8ArrayToString(tx.messages));
|
|
1385
1385
|
return {
|
|
1386
1386
|
...tx,
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
blockNumber:
|
|
1387
|
+
gasUsed: bigIntToNumber(tx.gasUsed),
|
|
1388
|
+
gasWanted: bigIntToNumber(tx.gasWanted),
|
|
1389
|
+
blockNumber: bigIntToNumber(tx.blockNumber),
|
|
1390
1390
|
signatures: tx.signatures.map((signature) => ({
|
|
1391
1391
|
pubkey: signature.pubkey,
|
|
1392
1392
|
address: signature.address,
|
|
1393
|
-
|
|
1394
|
-
|
|
1393
|
+
signature: signature.signature,
|
|
1394
|
+
sequence: bigIntToNumber(signature.sequence)
|
|
1395
1395
|
})),
|
|
1396
1396
|
gasFee: tx.gasFee ? IndexerGrpcExplorerTransformer.grpcGasFeeToGasFee(tx.gasFee) : {
|
|
1397
1397
|
gasLimit: 0,
|
|
@@ -1411,26 +1411,26 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1411
1411
|
}
|
|
1412
1412
|
static grpcBlockToBlock(block) {
|
|
1413
1413
|
return {
|
|
1414
|
-
height: typeof block.height === "bigint" ? Number(block.height) : parseInt(block.height, 10),
|
|
1415
|
-
proposer: block.proposer,
|
|
1416
1414
|
moniker: block.moniker,
|
|
1415
|
+
proposer: block.proposer,
|
|
1417
1416
|
blockHash: block.blockHash,
|
|
1417
|
+
timestamp: block.timestamp,
|
|
1418
1418
|
parentHash: block.parentHash,
|
|
1419
|
-
|
|
1420
|
-
numTxs:
|
|
1421
|
-
|
|
1419
|
+
height: bigIntToNumber(block.height),
|
|
1420
|
+
numTxs: bigIntToNumber(block.numTxs),
|
|
1421
|
+
numPreCommits: bigIntToNumber(block.numPreCommits)
|
|
1422
1422
|
};
|
|
1423
1423
|
}
|
|
1424
1424
|
static grpcBlockToBlockWithTxs(block) {
|
|
1425
1425
|
return {
|
|
1426
|
-
height: typeof block.height === "bigint" ? Number(block.height) : parseInt(block.height, 10),
|
|
1427
|
-
proposer: block.proposer,
|
|
1428
1426
|
moniker: block.moniker,
|
|
1427
|
+
proposer: block.proposer,
|
|
1429
1428
|
blockHash: block.blockHash,
|
|
1429
|
+
timestamp: block.timestamp,
|
|
1430
1430
|
parentHash: block.parentHash,
|
|
1431
|
-
|
|
1432
|
-
numTxs:
|
|
1433
|
-
|
|
1431
|
+
height: bigIntToNumber(block.height),
|
|
1432
|
+
numTxs: bigIntToNumber(block.numTxs),
|
|
1433
|
+
numPreCommits: bigIntToNumber(block.numPreCommits)
|
|
1434
1434
|
};
|
|
1435
1435
|
}
|
|
1436
1436
|
static grpcBlocksToBlocks(blocks) {
|
|
@@ -1450,88 +1450,88 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1450
1450
|
}
|
|
1451
1451
|
static grpcValidatorUptimeToValidatorUptime(validatorUptime) {
|
|
1452
1452
|
return {
|
|
1453
|
-
|
|
1454
|
-
|
|
1453
|
+
status: validatorUptime.status,
|
|
1454
|
+
blockNumber: bigIntToNumber(validatorUptime.blockNumber)
|
|
1455
1455
|
};
|
|
1456
1456
|
}
|
|
1457
1457
|
static grpcValidatorSlashingEventToValidatorSlashingEvent(validatorUptime) {
|
|
1458
1458
|
return {
|
|
1459
|
-
blockNumber: typeof validatorUptime.blockNumber === "bigint" ? Number(validatorUptime.blockNumber) : parseInt(validatorUptime.blockNumber, 10),
|
|
1460
|
-
blockTimestamp: validatorUptime.blockTimestamp,
|
|
1461
|
-
address: validatorUptime.address,
|
|
1462
|
-
power: typeof validatorUptime.power === "bigint" ? Number(validatorUptime.power) : parseInt(validatorUptime.power, 10),
|
|
1463
1459
|
reason: validatorUptime.reason,
|
|
1464
1460
|
jailed: validatorUptime.jailed,
|
|
1465
|
-
|
|
1461
|
+
address: validatorUptime.address,
|
|
1462
|
+
power: bigIntToNumber(validatorUptime.power),
|
|
1463
|
+
blockTimestamp: validatorUptime.blockTimestamp,
|
|
1464
|
+
blockNumber: bigIntToNumber(validatorUptime.blockNumber),
|
|
1465
|
+
missedBlocks: bigIntToNumber(validatorUptime.missedBlocks)
|
|
1466
1466
|
};
|
|
1467
1467
|
}
|
|
1468
1468
|
static grpcIBCTransferTxToIBCTransferTx(grpcIBCTransferTx) {
|
|
1469
1469
|
return {
|
|
1470
|
+
denom: grpcIBCTransferTx.denom,
|
|
1471
|
+
state: grpcIBCTransferTx.state,
|
|
1470
1472
|
sender: grpcIBCTransferTx.sender,
|
|
1473
|
+
amount: grpcIBCTransferTx.amount,
|
|
1474
|
+
dataHex: grpcIBCTransferTx.dataHex,
|
|
1471
1475
|
receiver: grpcIBCTransferTx.receiver,
|
|
1476
|
+
createdAt: grpcIBCTransferTx.createdAt,
|
|
1477
|
+
updatedAt: grpcIBCTransferTx.updatedAt,
|
|
1472
1478
|
sourcePort: grpcIBCTransferTx.sourcePort,
|
|
1479
|
+
txHashesList: grpcIBCTransferTx.txHashes,
|
|
1473
1480
|
sourceChannel: grpcIBCTransferTx.sourceChannel,
|
|
1481
|
+
timeoutHeight: grpcIBCTransferTx.timeoutHeight,
|
|
1474
1482
|
destinationPort: grpcIBCTransferTx.destinationPort,
|
|
1475
1483
|
destinationChannel: grpcIBCTransferTx.destinationChannel,
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
timeoutHeight: grpcIBCTransferTx.timeoutHeight,
|
|
1479
|
-
timeoutTimestamp: typeof grpcIBCTransferTx.timeoutTimestamp === "bigint" ? Number(grpcIBCTransferTx.timeoutTimestamp) : parseInt(grpcIBCTransferTx.timeoutTimestamp, 10),
|
|
1480
|
-
packetSequence: typeof grpcIBCTransferTx.packetSequence === "bigint" ? Number(grpcIBCTransferTx.packetSequence) : parseInt(grpcIBCTransferTx.packetSequence, 10),
|
|
1481
|
-
dataHex: grpcIBCTransferTx.dataHex,
|
|
1482
|
-
state: grpcIBCTransferTx.state,
|
|
1483
|
-
txHashesList: grpcIBCTransferTx.txHashes,
|
|
1484
|
-
createdAt: grpcIBCTransferTx.createdAt,
|
|
1485
|
-
updatedAt: grpcIBCTransferTx.updatedAt
|
|
1484
|
+
packetSequence: bigIntToNumber(grpcIBCTransferTx.packetSequence),
|
|
1485
|
+
timeoutTimestamp: bigIntToNumber(grpcIBCTransferTx.timeoutTimestamp)
|
|
1486
1486
|
};
|
|
1487
1487
|
}
|
|
1488
1488
|
static grpcPeggyDepositTx(grpcPeggyDepositTx) {
|
|
1489
1489
|
return {
|
|
1490
|
-
sender: grpcPeggyDepositTx.sender,
|
|
1491
|
-
receiver: grpcPeggyDepositTx.receiver,
|
|
1492
|
-
eventNonce: typeof grpcPeggyDepositTx.eventNonce === "bigint" ? Number(grpcPeggyDepositTx.eventNonce) : parseInt(grpcPeggyDepositTx.eventNonce, 10),
|
|
1493
|
-
eventHeight: typeof grpcPeggyDepositTx.eventHeight === "bigint" ? Number(grpcPeggyDepositTx.eventHeight) : parseInt(grpcPeggyDepositTx.eventHeight, 10),
|
|
1494
|
-
amount: grpcPeggyDepositTx.amount,
|
|
1495
1490
|
denom: grpcPeggyDepositTx.denom,
|
|
1496
|
-
orchestratorAddress: grpcPeggyDepositTx.orchestratorAddress,
|
|
1497
1491
|
state: grpcPeggyDepositTx.state,
|
|
1492
|
+
sender: grpcPeggyDepositTx.sender,
|
|
1493
|
+
amount: grpcPeggyDepositTx.amount,
|
|
1494
|
+
receiver: grpcPeggyDepositTx.receiver,
|
|
1498
1495
|
claimType: grpcPeggyDepositTx.claimType,
|
|
1499
|
-
txHashesList: grpcPeggyDepositTx.txHashes,
|
|
1500
1496
|
createdAt: grpcPeggyDepositTx.createdAt,
|
|
1501
|
-
updatedAt: grpcPeggyDepositTx.updatedAt
|
|
1497
|
+
updatedAt: grpcPeggyDepositTx.updatedAt,
|
|
1498
|
+
txHashesList: grpcPeggyDepositTx.txHashes,
|
|
1499
|
+
eventNonce: bigIntToNumber(grpcPeggyDepositTx.eventNonce),
|
|
1500
|
+
eventHeight: bigIntToNumber(grpcPeggyDepositTx.eventHeight),
|
|
1501
|
+
orchestratorAddress: grpcPeggyDepositTx.orchestratorAddress
|
|
1502
1502
|
};
|
|
1503
1503
|
}
|
|
1504
1504
|
static grpcPeggyWithdrawalTx(grpcPeggyWithdrawalTx) {
|
|
1505
1505
|
return {
|
|
1506
|
+
denom: grpcPeggyWithdrawalTx.denom,
|
|
1507
|
+
state: grpcPeggyWithdrawalTx.state,
|
|
1506
1508
|
sender: grpcPeggyWithdrawalTx.sender,
|
|
1507
|
-
receiver: grpcPeggyWithdrawalTx.receiver,
|
|
1508
1509
|
amount: grpcPeggyWithdrawalTx.amount,
|
|
1509
|
-
|
|
1510
|
+
receiver: grpcPeggyWithdrawalTx.receiver,
|
|
1510
1511
|
bridgeFee: grpcPeggyWithdrawalTx.bridgeFee,
|
|
1511
|
-
outgoingTxId: typeof grpcPeggyWithdrawalTx.outgoingTxId === "bigint" ? Number(grpcPeggyWithdrawalTx.outgoingTxId) : parseInt(grpcPeggyWithdrawalTx.outgoingTxId, 10),
|
|
1512
|
-
batchTimeout: typeof grpcPeggyWithdrawalTx.batchTimeout === "bigint" ? Number(grpcPeggyWithdrawalTx.batchTimeout) : parseInt(grpcPeggyWithdrawalTx.batchTimeout, 10),
|
|
1513
|
-
batchNonce: typeof grpcPeggyWithdrawalTx.batchNonce === "bigint" ? Number(grpcPeggyWithdrawalTx.batchNonce) : parseInt(grpcPeggyWithdrawalTx.batchNonce, 10),
|
|
1514
|
-
eventNonce: typeof grpcPeggyWithdrawalTx.eventNonce === "bigint" ? Number(grpcPeggyWithdrawalTx.eventNonce) : parseInt(grpcPeggyWithdrawalTx.eventNonce, 10),
|
|
1515
|
-
eventHeight: typeof grpcPeggyWithdrawalTx.eventHeight === "bigint" ? Number(grpcPeggyWithdrawalTx.eventHeight) : parseInt(grpcPeggyWithdrawalTx.eventHeight, 10),
|
|
1516
|
-
orchestratorAddress: grpcPeggyWithdrawalTx.orchestratorAddress,
|
|
1517
|
-
state: grpcPeggyWithdrawalTx.state,
|
|
1518
1512
|
claimType: grpcPeggyWithdrawalTx.claimType,
|
|
1519
|
-
txHashesList: grpcPeggyWithdrawalTx.txHashes,
|
|
1520
1513
|
createdAt: grpcPeggyWithdrawalTx.createdAt,
|
|
1521
|
-
updatedAt: grpcPeggyWithdrawalTx.updatedAt
|
|
1514
|
+
updatedAt: grpcPeggyWithdrawalTx.updatedAt,
|
|
1515
|
+
txHashesList: grpcPeggyWithdrawalTx.txHashes,
|
|
1516
|
+
batchNonce: bigIntToNumber(grpcPeggyWithdrawalTx.batchNonce),
|
|
1517
|
+
eventNonce: bigIntToNumber(grpcPeggyWithdrawalTx.eventNonce),
|
|
1518
|
+
eventHeight: bigIntToNumber(grpcPeggyWithdrawalTx.eventHeight),
|
|
1519
|
+
orchestratorAddress: grpcPeggyWithdrawalTx.orchestratorAddress,
|
|
1520
|
+
outgoingTxId: bigIntToNumber(grpcPeggyWithdrawalTx.outgoingTxId),
|
|
1521
|
+
batchTimeout: bigIntToNumber(grpcPeggyWithdrawalTx.batchTimeout)
|
|
1522
1522
|
};
|
|
1523
1523
|
}
|
|
1524
1524
|
static getExplorerStatsResponseToExplorerStats(response) {
|
|
1525
1525
|
return {
|
|
1526
|
-
assets:
|
|
1527
|
-
txsTotal:
|
|
1528
|
-
addresses:
|
|
1529
|
-
injSupply:
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
txsPerSecondInPast100Blocks:
|
|
1526
|
+
assets: bigIntToString(response.assets),
|
|
1527
|
+
txsTotal: bigIntToString(response.txsTotal),
|
|
1528
|
+
addresses: bigIntToString(response.addresses),
|
|
1529
|
+
injSupply: bigIntToString(response.injSupply),
|
|
1530
|
+
txsInPast30Days: bigIntToString(response.txs30D),
|
|
1531
|
+
txsInPast24Hours: bigIntToString(response.txs24H),
|
|
1532
|
+
txsPerSecondInPast24Hours: bigIntToString(response.txsPs24H),
|
|
1533
|
+
blockCountInPast24Hours: bigIntToString(response.blockCount24H),
|
|
1534
|
+
txsPerSecondInPast100Blocks: bigIntToString(response.txsPs100B)
|
|
1535
1535
|
};
|
|
1536
1536
|
}
|
|
1537
1537
|
static getTxsV2ResponseToTxs(response) {
|
|
@@ -1550,7 +1550,7 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1550
1550
|
signature: signature.signature,
|
|
1551
1551
|
sequence: (() => {
|
|
1552
1552
|
try {
|
|
1553
|
-
return
|
|
1553
|
+
return bigIntToNumber(signature.sequence);
|
|
1554
1554
|
} catch (_unused3) {
|
|
1555
1555
|
return 0;
|
|
1556
1556
|
}
|
|
@@ -1558,12 +1558,12 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1558
1558
|
}));
|
|
1559
1559
|
const claimIds = tx.claimIds.map((claimId) => {
|
|
1560
1560
|
try {
|
|
1561
|
-
return
|
|
1561
|
+
return bigIntToNumber(claimId);
|
|
1562
1562
|
} catch (_unused4) {
|
|
1563
1563
|
return 0;
|
|
1564
1564
|
}
|
|
1565
1565
|
});
|
|
1566
|
-
const blockNumber =
|
|
1566
|
+
const blockNumber = bigIntToNumber(tx.blockNumber);
|
|
1567
1567
|
return {
|
|
1568
1568
|
logs,
|
|
1569
1569
|
info: "",
|
|
@@ -1596,7 +1596,7 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1596
1596
|
};
|
|
1597
1597
|
}
|
|
1598
1598
|
static grpcAccountTxV2ToTransaction(tx) {
|
|
1599
|
-
var _tx$gasFee, _tx$gasFee2, _tx$
|
|
1599
|
+
var _tx$gasFee, _tx$gasFee2, _tx$gasFee$granter, _tx$gasFee3, _tx$gasFee$payer, _tx$gasFee4;
|
|
1600
1600
|
return {
|
|
1601
1601
|
id: tx.id,
|
|
1602
1602
|
hash: tx.hash,
|
|
@@ -1609,27 +1609,27 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1609
1609
|
amount: amount.amount,
|
|
1610
1610
|
denom: amount.denom
|
|
1611
1611
|
})),
|
|
1612
|
-
gasLimit:
|
|
1613
|
-
granter: (_tx$gasFee$granter = (_tx$
|
|
1614
|
-
payer: (_tx$gasFee$payer = (_tx$
|
|
1612
|
+
gasLimit: bigIntToNumber((_tx$gasFee2 = tx.gasFee) === null || _tx$gasFee2 === void 0 ? void 0 : _tx$gasFee2.gasLimit),
|
|
1613
|
+
granter: (_tx$gasFee$granter = (_tx$gasFee3 = tx.gasFee) === null || _tx$gasFee3 === void 0 ? void 0 : _tx$gasFee3.granter) !== null && _tx$gasFee$granter !== void 0 ? _tx$gasFee$granter : "",
|
|
1614
|
+
payer: (_tx$gasFee$payer = (_tx$gasFee4 = tx.gasFee) === null || _tx$gasFee4 === void 0 ? void 0 : _tx$gasFee4.payer) !== null && _tx$gasFee$payer !== void 0 ? _tx$gasFee$payer : ""
|
|
1615
1615
|
},
|
|
1616
1616
|
events: tx.events,
|
|
1617
1617
|
errorLog: tx.errorLog,
|
|
1618
1618
|
codespace: tx.codespace,
|
|
1619
|
-
gasUsed:
|
|
1619
|
+
gasUsed: bigIntToNumber(tx.gasUsed),
|
|
1620
1620
|
blockTimestamp: tx.blockTimestamp,
|
|
1621
|
-
gasWanted:
|
|
1622
|
-
blockNumber:
|
|
1621
|
+
gasWanted: bigIntToNumber(tx.gasWanted),
|
|
1622
|
+
blockNumber: bigIntToNumber(tx.blockNumber),
|
|
1623
1623
|
signatures: tx.signatures.map((signature) => ({
|
|
1624
1624
|
address: signature.address,
|
|
1625
1625
|
pubkey: signature.pubkey,
|
|
1626
1626
|
signature: signature.signature,
|
|
1627
|
-
sequence:
|
|
1627
|
+
sequence: bigIntToNumber(signature.sequence)
|
|
1628
1628
|
})),
|
|
1629
1629
|
messages: transactionV2MessagesToMessagesNoThrow(tx.messages),
|
|
1630
1630
|
logs: parseStringToObjectLikeNoThrow(tx.logs),
|
|
1631
1631
|
data: "/" + uint8ArrayToString(tx.data).split("/").pop(),
|
|
1632
|
-
claimIds: tx.claimIds.map((claimId) =>
|
|
1632
|
+
claimIds: tx.claimIds.map((claimId) => bigIntToNumber(claimId))
|
|
1633
1633
|
};
|
|
1634
1634
|
}
|
|
1635
1635
|
static getBlocksV2ResponseToBlocks(response) {
|
|
@@ -1645,9 +1645,9 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1645
1645
|
blockHash: block.blockHash,
|
|
1646
1646
|
timestamp: block.timestamp,
|
|
1647
1647
|
parentHash: block.parentHash,
|
|
1648
|
-
height:
|
|
1649
|
-
numTxs:
|
|
1650
|
-
numPreCommits:
|
|
1648
|
+
height: bigIntToNumber(block.height),
|
|
1649
|
+
numTxs: bigIntToNumber(block.numTxs),
|
|
1650
|
+
numPreCommits: bigIntToNumber(block.numPreCommits)
|
|
1651
1651
|
};
|
|
1652
1652
|
}
|
|
1653
1653
|
static getContractTxsV2ResponseToContractTxs(response) {
|
|
@@ -1657,7 +1657,7 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1657
1657
|
};
|
|
1658
1658
|
}
|
|
1659
1659
|
static grpcContractTxV2ToTransaction(tx) {
|
|
1660
|
-
var _tx$
|
|
1660
|
+
var _tx$gasFee5;
|
|
1661
1661
|
return {
|
|
1662
1662
|
messages: transactionV2MessagesToMessagesNoThrow(tx.messages),
|
|
1663
1663
|
code: tx.code,
|
|
@@ -1665,18 +1665,18 @@ var IndexerGrpcExplorerTransformer = class IndexerGrpcExplorerTransformer {
|
|
|
1665
1665
|
type: tx.txType,
|
|
1666
1666
|
txHash: tx.hash,
|
|
1667
1667
|
error_log: tx.errorLog,
|
|
1668
|
-
height:
|
|
1669
|
-
tx_number:
|
|
1670
|
-
time:
|
|
1668
|
+
height: bigIntToNumber(tx.blockNumber),
|
|
1669
|
+
tx_number: bigIntToNumber(tx.txNumber),
|
|
1670
|
+
time: bigIntToNumber(tx.blockUnixTimestamp),
|
|
1671
1671
|
amount: getContractTransactionV2Amount(tx),
|
|
1672
1672
|
logs: JSON.parse(uint8ArrayToString(tx.logs)),
|
|
1673
1673
|
data: "/" + uint8ArrayToString(tx.data).split("/").pop(),
|
|
1674
|
-
fee: toHumanReadable(((_tx$
|
|
1674
|
+
fee: toHumanReadable(((_tx$gasFee5 = tx.gasFee) === null || _tx$gasFee5 === void 0 || (_tx$gasFee5 = _tx$gasFee5.amount[0]) === null || _tx$gasFee5 === void 0 ? void 0 : _tx$gasFee5.amount) || "0"),
|
|
1675
1675
|
signatures: tx.signatures.map((signature) => ({
|
|
1676
1676
|
address: signature.address,
|
|
1677
1677
|
pubkey: signature.pubkey,
|
|
1678
1678
|
signature: signature.signature,
|
|
1679
|
-
sequence:
|
|
1679
|
+
sequence: bigIntToNumber(signature.sequence)
|
|
1680
1680
|
}))
|
|
1681
1681
|
};
|
|
1682
1682
|
}
|
|
@@ -1710,8 +1710,8 @@ var IndexerGrpcReferralTransformer = class {
|
|
|
1710
1710
|
var IndexerOracleStreamTransformer = class {};
|
|
1711
1711
|
_defineProperty(IndexerOracleStreamTransformer, "pricesStreamCallback", (response) => ({
|
|
1712
1712
|
price: response.price,
|
|
1713
|
-
|
|
1714
|
-
|
|
1713
|
+
timestamp: bigIntToNumber(response.timestamp),
|
|
1714
|
+
operation: StreamOperation.Update
|
|
1715
1715
|
}));
|
|
1716
1716
|
_defineProperty(IndexerOracleStreamTransformer, "pricesByMarketsCallback", (response) => ({ ...response }));
|
|
1717
1717
|
|
|
@@ -1949,7 +1949,7 @@ _defineProperty(IndexerAccountStreamTransformer, "balanceStreamCallback", (respo
|
|
|
1949
1949
|
const balance = response.balance;
|
|
1950
1950
|
return {
|
|
1951
1951
|
balance: balance ? IndexerGrpcAccountTransformer.grpcBalanceToBalance(balance) : void 0,
|
|
1952
|
-
operation: StreamOperation
|
|
1952
|
+
operation: StreamOperation.Update,
|
|
1953
1953
|
timestamp: response.timestamp
|
|
1954
1954
|
};
|
|
1955
1955
|
});
|
|
@@ -1964,7 +1964,7 @@ _defineProperty(IndexerAuctionStreamTransformer, "bidsStreamCallback", (response
|
|
|
1964
1964
|
bid: {
|
|
1965
1965
|
bidder: response.bidder,
|
|
1966
1966
|
bidAmount: response.bidAmount,
|
|
1967
|
-
bidTimestamp:
|
|
1967
|
+
bidTimestamp: bigIntToNumber(response.timestamp)
|
|
1968
1968
|
},
|
|
1969
1969
|
operation: StreamOperation.Insert
|
|
1970
1970
|
}));
|
|
@@ -2185,8 +2185,8 @@ _defineProperty(IndexerArchiverStreamTransformer, "spotAverageEntriesStreamCallb
|
|
|
2185
2185
|
const averageEntry = response.averageEntry;
|
|
2186
2186
|
return {
|
|
2187
2187
|
averageEntry: averageEntry ? IndexerGrpcArchiverTransformer.grpcSpotAverageEntryToSpotAverageEntry(averageEntry) : void 0,
|
|
2188
|
-
operation: StreamOperation
|
|
2189
|
-
timestamp:
|
|
2188
|
+
operation: StreamOperation.Update,
|
|
2189
|
+
timestamp: bigIntToNumber(response.timestamp)
|
|
2190
2190
|
};
|
|
2191
2191
|
});
|
|
2192
2192
|
|
|
@@ -2198,15 +2198,15 @@ _defineProperty(IndexerArchiverStreamTransformer, "spotAverageEntriesStreamCallb
|
|
|
2198
2198
|
var ExplorerStreamTransformer = class {};
|
|
2199
2199
|
_defineProperty(ExplorerStreamTransformer, "blocksStreamCallback", (response) => ({
|
|
2200
2200
|
block: IndexerGrpcExplorerTransformer.grpcBlockToBlock(response),
|
|
2201
|
-
operation: StreamOperation
|
|
2201
|
+
operation: StreamOperation.Insert
|
|
2202
2202
|
}));
|
|
2203
2203
|
_defineProperty(ExplorerStreamTransformer, "blocksWithTxsStreamCallback", (response) => ({
|
|
2204
2204
|
block: IndexerGrpcExplorerTransformer.grpcBlockToBlockWithTxs(response),
|
|
2205
|
-
operation: StreamOperation
|
|
2205
|
+
operation: StreamOperation.Insert
|
|
2206
2206
|
}));
|
|
2207
2207
|
_defineProperty(ExplorerStreamTransformer, "transactionsStreamCallback", (response) => ({
|
|
2208
2208
|
block: IndexerGrpcExplorerTransformer.streamTxResponseToTxs(response),
|
|
2209
|
-
operation: StreamOperation
|
|
2209
|
+
operation: StreamOperation.Insert
|
|
2210
2210
|
}));
|
|
2211
2211
|
|
|
2212
2212
|
//#endregion
|
|
@@ -2271,13 +2271,7 @@ var IndexerGrpcDerivativeTransformer = class IndexerGrpcDerivativeTransformer {
|
|
|
2271
2271
|
const pagination = response.paging;
|
|
2272
2272
|
return {
|
|
2273
2273
|
orders: IndexerGrpcDerivativeTransformer.grpcOrdersToOrders(orders),
|
|
2274
|
-
pagination: pagination
|
|
2275
|
-
to: pagination.to,
|
|
2276
|
-
from: pagination.from,
|
|
2277
|
-
total: Number(pagination.total),
|
|
2278
|
-
countBySubaccount: pagination.countBySubaccount,
|
|
2279
|
-
next: pagination.next
|
|
2280
|
-
} : void 0
|
|
2274
|
+
pagination: grpcPagingToPagingV2(pagination)
|
|
2281
2275
|
};
|
|
2282
2276
|
}
|
|
2283
2277
|
static orderHistoryResponseToOrderHistory(response, isConditional) {
|
|
@@ -2285,13 +2279,7 @@ var IndexerGrpcDerivativeTransformer = class IndexerGrpcDerivativeTransformer {
|
|
|
2285
2279
|
const pagination = response.paging;
|
|
2286
2280
|
return {
|
|
2287
2281
|
orderHistory: IndexerGrpcDerivativeTransformer.grpcOrderHistoryListToOrderHistoryList(orderHistory, isConditional),
|
|
2288
|
-
pagination: pagination
|
|
2289
|
-
to: pagination.to,
|
|
2290
|
-
from: pagination.from,
|
|
2291
|
-
total: Number(pagination.total),
|
|
2292
|
-
countBySubaccount: pagination.countBySubaccount,
|
|
2293
|
-
next: pagination.next
|
|
2294
|
-
} : void 0
|
|
2282
|
+
pagination: grpcPagingToPagingV2(pagination)
|
|
2295
2283
|
};
|
|
2296
2284
|
}
|
|
2297
2285
|
static positionsResponseToPositions(response) {
|
|
@@ -2299,13 +2287,7 @@ var IndexerGrpcDerivativeTransformer = class IndexerGrpcDerivativeTransformer {
|
|
|
2299
2287
|
const pagination = response.paging;
|
|
2300
2288
|
return {
|
|
2301
2289
|
positions: IndexerGrpcDerivativeTransformer.grpcPositionsToPositions(positions),
|
|
2302
|
-
pagination: pagination
|
|
2303
|
-
to: pagination.to,
|
|
2304
|
-
from: pagination.from,
|
|
2305
|
-
total: Number(pagination.total),
|
|
2306
|
-
countBySubaccount: pagination.countBySubaccount,
|
|
2307
|
-
next: pagination.next
|
|
2308
|
-
} : void 0
|
|
2290
|
+
pagination: grpcPagingToPagingV2(pagination)
|
|
2309
2291
|
};
|
|
2310
2292
|
}
|
|
2311
2293
|
static positionsV2ResponseToPositionsV2(response) {
|
|
@@ -2313,13 +2295,7 @@ var IndexerGrpcDerivativeTransformer = class IndexerGrpcDerivativeTransformer {
|
|
|
2313
2295
|
const pagination = response.paging;
|
|
2314
2296
|
return {
|
|
2315
2297
|
positions: IndexerGrpcDerivativeTransformer.grpcPositionsV2ToPositionsV2(positions),
|
|
2316
|
-
pagination: pagination
|
|
2317
|
-
to: pagination.to,
|
|
2318
|
-
from: pagination.from,
|
|
2319
|
-
total: Number(pagination.total),
|
|
2320
|
-
countBySubaccount: pagination.countBySubaccount,
|
|
2321
|
-
next: pagination.next
|
|
2322
|
-
} : void 0
|
|
2298
|
+
pagination: grpcPagingToPagingV2(pagination)
|
|
2323
2299
|
};
|
|
2324
2300
|
}
|
|
2325
2301
|
static tradesResponseToTrades(response) {
|
|
@@ -2327,13 +2303,7 @@ var IndexerGrpcDerivativeTransformer = class IndexerGrpcDerivativeTransformer {
|
|
|
2327
2303
|
const pagination = response.paging;
|
|
2328
2304
|
return {
|
|
2329
2305
|
trades: IndexerGrpcDerivativeTransformer.grpcTradesToTrades(trades),
|
|
2330
|
-
pagination: pagination
|
|
2331
|
-
to: pagination.to,
|
|
2332
|
-
from: pagination.from,
|
|
2333
|
-
total: Number(pagination.total),
|
|
2334
|
-
countBySubaccount: pagination.countBySubaccount,
|
|
2335
|
-
next: pagination.next
|
|
2336
|
-
} : void 0
|
|
2306
|
+
pagination: grpcPagingToPagingV2(pagination)
|
|
2337
2307
|
};
|
|
2338
2308
|
}
|
|
2339
2309
|
static subaccountTradesListResponseToSubaccountTradesList(response) {
|
|
@@ -2345,13 +2315,7 @@ var IndexerGrpcDerivativeTransformer = class IndexerGrpcDerivativeTransformer {
|
|
|
2345
2315
|
const pagination = response.paging;
|
|
2346
2316
|
return {
|
|
2347
2317
|
fundingPayments: IndexerGrpcDerivativeTransformer.grpcFundingPaymentsToFundingPayments(fundingPayments),
|
|
2348
|
-
pagination: pagination
|
|
2349
|
-
to: pagination.to,
|
|
2350
|
-
from: pagination.from,
|
|
2351
|
-
total: Number(pagination.total),
|
|
2352
|
-
countBySubaccount: pagination.countBySubaccount,
|
|
2353
|
-
next: pagination.next
|
|
2354
|
-
} : void 0
|
|
2318
|
+
pagination: grpcPagingToPagingV2(pagination)
|
|
2355
2319
|
};
|
|
2356
2320
|
}
|
|
2357
2321
|
static fundingRatesResponseToFundingRates(response) {
|
|
@@ -2359,13 +2323,7 @@ var IndexerGrpcDerivativeTransformer = class IndexerGrpcDerivativeTransformer {
|
|
|
2359
2323
|
const pagination = response.paging;
|
|
2360
2324
|
return {
|
|
2361
2325
|
fundingRates: IndexerGrpcDerivativeTransformer.grpcFundingRatesToFundingRates(fundingRates),
|
|
2362
|
-
pagination: pagination
|
|
2363
|
-
to: pagination.to,
|
|
2364
|
-
from: pagination.from,
|
|
2365
|
-
total: Number(pagination.total),
|
|
2366
|
-
countBySubaccount: pagination.countBySubaccount,
|
|
2367
|
-
next: pagination.next
|
|
2368
|
-
} : void 0
|
|
2326
|
+
pagination: grpcPagingToPagingV2(pagination)
|
|
2369
2327
|
};
|
|
2370
2328
|
}
|
|
2371
2329
|
static orderbookV2ResponseToOrderbookV2(response) {
|
|
@@ -2398,13 +2356,7 @@ var IndexerGrpcDerivativeTransformer = class IndexerGrpcDerivativeTransformer {
|
|
|
2398
2356
|
const pagination = response.paging;
|
|
2399
2357
|
return {
|
|
2400
2358
|
markets: IndexerGrpcDerivativeTransformer.grpcBinaryOptionsMarketsToBinaryOptionsMarkets(markets),
|
|
2401
|
-
pagination:
|
|
2402
|
-
to: (pagination === null || pagination === void 0 ? void 0 : pagination.to) || 0,
|
|
2403
|
-
from: (pagination === null || pagination === void 0 ? void 0 : pagination.from) || 0,
|
|
2404
|
-
total: Number((pagination === null || pagination === void 0 ? void 0 : pagination.total) || 0),
|
|
2405
|
-
countBySubaccount: Number((pagination === null || pagination === void 0 ? void 0 : pagination.countBySubaccount) || 0),
|
|
2406
|
-
next: (pagination === null || pagination === void 0 ? void 0 : pagination.next) || []
|
|
2407
|
-
}
|
|
2359
|
+
pagination: grpcPagingToPagingV2(pagination)
|
|
2408
2360
|
};
|
|
2409
2361
|
}
|
|
2410
2362
|
static binaryOptionsMarketsResponseToBinaryOptionsMarkets(response) {
|
|
@@ -2585,7 +2537,11 @@ var IndexerGrpcDerivativeTransformer = class IndexerGrpcDerivativeTransformer {
|
|
|
2585
2537
|
liquidationPrice: position.liquidationPrice,
|
|
2586
2538
|
markPrice: position.markPrice,
|
|
2587
2539
|
ticker: position.ticker,
|
|
2588
|
-
updatedAt: Number(position.updatedAt)
|
|
2540
|
+
updatedAt: Number(position.updatedAt),
|
|
2541
|
+
fundingSum: position.fundingSum,
|
|
2542
|
+
fundingLast: position.fundingLast,
|
|
2543
|
+
cumulativeFundingEntry: position.cumulativeFundingEntry,
|
|
2544
|
+
effectiveCumulativeFundingEntry: position.effectiveCumulativeFundingEntry
|
|
2589
2545
|
};
|
|
2590
2546
|
}
|
|
2591
2547
|
static grpcPositionsToPositions(positions) {
|
|
@@ -4616,7 +4572,7 @@ var IndexerRestLeaderboardChronosApi = class extends BaseRestConsumer {
|
|
|
4616
4572
|
};
|
|
4617
4573
|
|
|
4618
4574
|
//#endregion
|
|
4619
|
-
//#region src/client/indexer/grpc_stream/streamHelpers.ts
|
|
4575
|
+
//#region src/client/indexer/grpc_stream/stream/streamHelpers.ts
|
|
4620
4576
|
/**
|
|
4621
4577
|
* Creates a subscription wrapper for V2 streaming with proper cancellation support.
|
|
4622
4578
|
*
|
|
@@ -4650,7 +4606,7 @@ function createStreamSubscription(stream, handleResponse, onEndCallback, onStatu
|
|
|
4650
4606
|
}
|
|
4651
4607
|
|
|
4652
4608
|
//#endregion
|
|
4653
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcSpotStream.ts
|
|
4609
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcSpotStream.ts
|
|
4654
4610
|
/**
|
|
4655
4611
|
* @category Indexer Grpc Stream
|
|
4656
4612
|
* @description Provides streaming access to spot market data from Injective Indexer
|
|
@@ -4662,9 +4618,9 @@ var IndexerGrpcSpotStream = class {
|
|
|
4662
4618
|
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
4663
4619
|
this.client = new InjectiveSpotExchangeRPCClient(this.transport);
|
|
4664
4620
|
}
|
|
4665
|
-
/** @deprecated - use
|
|
4666
|
-
|
|
4667
|
-
throw new GeneralException(/* @__PURE__ */ new Error("deprecated - use
|
|
4621
|
+
/** @deprecated - use streamOrderbookV2 */
|
|
4622
|
+
streamOrderbook(_args) {
|
|
4623
|
+
throw new GeneralException(/* @__PURE__ */ new Error("deprecated - use streamOrderbookV2"));
|
|
4668
4624
|
}
|
|
4669
4625
|
/**
|
|
4670
4626
|
* Stream spot orders
|
|
@@ -4677,7 +4633,7 @@ var IndexerGrpcSpotStream = class {
|
|
|
4677
4633
|
* @param params.onStatusCallback - Called on stream errors
|
|
4678
4634
|
* @returns Subscription object with unsubscribe method
|
|
4679
4635
|
*/
|
|
4680
|
-
|
|
4636
|
+
streamOrders({ marketId, subaccountId, orderSide, callback, onEndCallback, onStatusCallback }) {
|
|
4681
4637
|
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
4682
4638
|
const request = InjectiveSpotExchangeRpcPb.StreamOrdersRequest.create();
|
|
4683
4639
|
if (marketId) request.marketId = marketId;
|
|
@@ -4701,7 +4657,7 @@ var IndexerGrpcSpotStream = class {
|
|
|
4701
4657
|
* @param params.onStatusCallback - Called on stream errors
|
|
4702
4658
|
* @returns Subscription object with unsubscribe method
|
|
4703
4659
|
*/
|
|
4704
|
-
|
|
4660
|
+
streamOrderHistory({ marketId, subaccountId, orderTypes, executionTypes, direction, state, callback, onEndCallback, onStatusCallback }) {
|
|
4705
4661
|
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
4706
4662
|
const request = InjectiveSpotExchangeRpcPb.StreamOrdersHistoryRequest.create();
|
|
4707
4663
|
if (subaccountId) request.subaccountId = subaccountId;
|
|
@@ -4729,7 +4685,7 @@ var IndexerGrpcSpotStream = class {
|
|
|
4729
4685
|
* @param params.onStatusCallback - Called on stream errors
|
|
4730
4686
|
* @returns Subscription object with unsubscribe method
|
|
4731
4687
|
*/
|
|
4732
|
-
|
|
4688
|
+
streamTrades({ marketIds, marketId, subaccountIds, subaccountId, pagination, direction, executionSide, callback, onEndCallback, onStatusCallback }) {
|
|
4733
4689
|
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
4734
4690
|
const request = InjectiveSpotExchangeRpcPb.StreamTradesRequest.create();
|
|
4735
4691
|
if (marketIds) request.marketIds = marketIds;
|
|
@@ -4755,7 +4711,7 @@ var IndexerGrpcSpotStream = class {
|
|
|
4755
4711
|
* @param params.onStatusCallback - Called on stream errors
|
|
4756
4712
|
* @returns Subscription object with unsubscribe method
|
|
4757
4713
|
*/
|
|
4758
|
-
|
|
4714
|
+
streamMarkets({ marketIds, callback, onEndCallback, onStatusCallback }) {
|
|
4759
4715
|
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
4760
4716
|
const request = InjectiveSpotExchangeRpcPb.StreamMarketsRequest.create();
|
|
4761
4717
|
if (marketIds) request.marketIds = marketIds;
|
|
@@ -4772,7 +4728,7 @@ var IndexerGrpcSpotStream = class {
|
|
|
4772
4728
|
* @param params.onStatusCallback - Called on stream errors
|
|
4773
4729
|
* @returns Subscription object with unsubscribe method
|
|
4774
4730
|
*/
|
|
4775
|
-
|
|
4731
|
+
streamOrderbooksV2({ marketIds, callback, onEndCallback, onStatusCallback }) {
|
|
4776
4732
|
if (!marketIds || marketIds.length === 0) throw new Error("marketIds is required and cannot be empty");
|
|
4777
4733
|
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
4778
4734
|
const request = InjectiveSpotExchangeRpcPb.StreamOrderbookV2Request.create();
|
|
@@ -4790,7 +4746,7 @@ var IndexerGrpcSpotStream = class {
|
|
|
4790
4746
|
* @param params.onStatusCallback - Called on stream errors
|
|
4791
4747
|
* @returns Subscription object with unsubscribe method
|
|
4792
4748
|
*/
|
|
4793
|
-
|
|
4749
|
+
streamOrderbookUpdates({ marketIds, callback, onEndCallback, onStatusCallback }) {
|
|
4794
4750
|
if (!marketIds || marketIds.length === 0) throw new Error("marketIds is required and cannot be empty");
|
|
4795
4751
|
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
4796
4752
|
const request = InjectiveSpotExchangeRpcPb.StreamOrderbookUpdateRequest.create();
|
|
@@ -4802,7 +4758,7 @@ var IndexerGrpcSpotStream = class {
|
|
|
4802
4758
|
};
|
|
4803
4759
|
|
|
4804
4760
|
//#endregion
|
|
4805
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcMitoStream.ts
|
|
4761
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcMitoStream.ts
|
|
4806
4762
|
/**
|
|
4807
4763
|
* @category Indexer Grpc Stream
|
|
4808
4764
|
* @description Provides streaming access to Mito vault data from Injective Indexer
|
|
@@ -4917,7 +4873,7 @@ var IndexerGrpcMitoStream = class {
|
|
|
4917
4873
|
};
|
|
4918
4874
|
|
|
4919
4875
|
//#endregion
|
|
4920
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcOracleStream.ts
|
|
4876
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcOracleStream.ts
|
|
4921
4877
|
/**
|
|
4922
4878
|
* @category Indexer Grpc Stream
|
|
4923
4879
|
* @description Provides streaming access to oracle price data from Injective Indexer
|
|
@@ -4971,7 +4927,7 @@ var IndexerGrpcOracleStream = class {
|
|
|
4971
4927
|
};
|
|
4972
4928
|
|
|
4973
4929
|
//#endregion
|
|
4974
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcAccountStream.ts
|
|
4930
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcAccountStream.ts
|
|
4975
4931
|
/**
|
|
4976
4932
|
* @category Indexer Grpc Stream
|
|
4977
4933
|
* @description Provides streaming access to account data from the Injective Indexer
|
|
@@ -5004,7 +4960,7 @@ var IndexerGrpcAccountStream = class {
|
|
|
5004
4960
|
};
|
|
5005
4961
|
|
|
5006
4962
|
//#endregion
|
|
5007
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcAuctionStream.ts
|
|
4963
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcAuctionStream.ts
|
|
5008
4964
|
/**
|
|
5009
4965
|
* @category Indexer Grpc Stream
|
|
5010
4966
|
* @description Provides streaming access to auction data from Injective Indexer
|
|
@@ -5034,7 +4990,7 @@ var IndexerGrpcAuctionStream = class {
|
|
|
5034
4990
|
};
|
|
5035
4991
|
|
|
5036
4992
|
//#endregion
|
|
5037
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcTradingStream.ts
|
|
4993
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcTradingStream.ts
|
|
5038
4994
|
/**
|
|
5039
4995
|
* @category Indexer Grid Strategy Grpc Stream
|
|
5040
4996
|
* @description Provides streaming access to grid strategy data from Injective Indexer
|
|
@@ -5069,7 +5025,7 @@ var IndexerGrpcTradingStream = class {
|
|
|
5069
5025
|
};
|
|
5070
5026
|
|
|
5071
5027
|
//#endregion
|
|
5072
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcArchiverStream.ts
|
|
5028
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcArchiverStream.ts
|
|
5073
5029
|
/**
|
|
5074
5030
|
* @category Indexer Grpc Stream
|
|
5075
5031
|
* @description Provides streaming access to archiver data from Injective Indexer
|
|
@@ -5102,7 +5058,7 @@ var IndexerGrpcArchiverStream = class {
|
|
|
5102
5058
|
};
|
|
5103
5059
|
|
|
5104
5060
|
//#endregion
|
|
5105
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcExplorerStream.ts
|
|
5061
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcExplorerStream.ts
|
|
5106
5062
|
/**
|
|
5107
5063
|
* @category Indexer Grpc Stream
|
|
5108
5064
|
* @description Provides streaming access to blockchain explorer data from Injective Indexer
|
|
@@ -5162,7 +5118,7 @@ var IndexerGrpcExplorerStream = class {
|
|
|
5162
5118
|
};
|
|
5163
5119
|
|
|
5164
5120
|
//#endregion
|
|
5165
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcDerivativesStream.ts
|
|
5121
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcDerivativesStream.ts
|
|
5166
5122
|
/**
|
|
5167
5123
|
* @category Indexer Grpc Stream
|
|
5168
5124
|
* @description Provides streaming access to derivatives market data from Injective Indexer
|
|
@@ -5352,7 +5308,7 @@ var IndexerGrpcDerivativesStream = class {
|
|
|
5352
5308
|
};
|
|
5353
5309
|
|
|
5354
5310
|
//#endregion
|
|
5355
|
-
//#region src/client/indexer/grpc_stream/IndexerGrpcAccountPortfolioStream.ts
|
|
5311
|
+
//#region src/client/indexer/grpc_stream/stream/IndexerGrpcAccountPortfolioStream.ts
|
|
5356
5312
|
/**
|
|
5357
5313
|
* @category Indexer Grpc Stream
|
|
5358
5314
|
* @description Provides streaming access to account portfolio data from Injective Indexer
|
|
@@ -5389,4 +5345,961 @@ var IndexerGrpcAccountPortfolioStream = class {
|
|
|
5389
5345
|
};
|
|
5390
5346
|
|
|
5391
5347
|
//#endregion
|
|
5392
|
-
|
|
5348
|
+
//#region src/client/indexer/grpc_stream/stream/StreamManager.ts
|
|
5349
|
+
/**
|
|
5350
|
+
* StreamManager - Simple registry for managing multiple V1 stream subscriptions by key
|
|
5351
|
+
*
|
|
5352
|
+
* This is a lightweight utility for storing and canceling multiple V1 RxJS-based streams.
|
|
5353
|
+
* For V2 streams with advanced lifecycle management and retry logic, use StreamManagerV2.
|
|
5354
|
+
*/
|
|
5355
|
+
var StreamManager = class {
|
|
5356
|
+
constructor() {
|
|
5357
|
+
_defineProperty(this, "streams", /* @__PURE__ */ new Map());
|
|
5358
|
+
}
|
|
5359
|
+
set(stream, streamKey) {
|
|
5360
|
+
if (this.streams.has(streamKey)) throw new Error(`Stream ${streamKey} already exists`);
|
|
5361
|
+
this.streams.set(streamKey, stream);
|
|
5362
|
+
}
|
|
5363
|
+
get(streamKey) {
|
|
5364
|
+
if (!this.streams.has(streamKey)) throw new Error(`Stream ${streamKey} is not found`);
|
|
5365
|
+
return this.streams.get(streamKey);
|
|
5366
|
+
}
|
|
5367
|
+
exists(streamKey) {
|
|
5368
|
+
return this.streams.has(streamKey);
|
|
5369
|
+
}
|
|
5370
|
+
cancelAll() {
|
|
5371
|
+
this.streams.forEach((stream) => {
|
|
5372
|
+
stream.cancel();
|
|
5373
|
+
});
|
|
5374
|
+
this.streams = /* @__PURE__ */ new Map();
|
|
5375
|
+
}
|
|
5376
|
+
cancel(streamKey) {
|
|
5377
|
+
if (!this.streams.has(streamKey)) throw new Error(`Stream ${streamKey} is not found`);
|
|
5378
|
+
this.streams.get(streamKey).cancel();
|
|
5379
|
+
this.streams.delete(streamKey);
|
|
5380
|
+
}
|
|
5381
|
+
cancelIfExists(streamKey) {
|
|
5382
|
+
if (!this.streams.has(streamKey)) return;
|
|
5383
|
+
this.streams.get(streamKey).cancel();
|
|
5384
|
+
this.streams.delete(streamKey);
|
|
5385
|
+
}
|
|
5386
|
+
};
|
|
5387
|
+
|
|
5388
|
+
//#endregion
|
|
5389
|
+
//#region src/client/indexer/grpc_stream/streamV2/streamHelpersV2.ts
|
|
5390
|
+
/**
|
|
5391
|
+
* Extracts detailed error information from a gRPC/RpcError object.
|
|
5392
|
+
*
|
|
5393
|
+
* gRPC-web errors typically have these properties:
|
|
5394
|
+
* - code: gRPC status code (number)
|
|
5395
|
+
* - message: Error message
|
|
5396
|
+
* - name: 'RpcError'
|
|
5397
|
+
* - methodName: The RPC method that failed
|
|
5398
|
+
* - serviceName: The service name
|
|
5399
|
+
* - metadata: Response metadata/trailers
|
|
5400
|
+
*/
|
|
5401
|
+
function extractGrpcError(error) {
|
|
5402
|
+
let code = GrpcStatusCode.UNKNOWN;
|
|
5403
|
+
let details = "Unknown stream error";
|
|
5404
|
+
let metadata = void 0;
|
|
5405
|
+
if (error && typeof error === "object") {
|
|
5406
|
+
if ("code" in error && typeof error.code === "number") code = error.code;
|
|
5407
|
+
if ("message" in error && typeof error.message === "string") details = error.message;
|
|
5408
|
+
else if ("details" in error && typeof error.details === "string") details = error.details;
|
|
5409
|
+
const errorObj = error;
|
|
5410
|
+
metadata = {
|
|
5411
|
+
originalError: error,
|
|
5412
|
+
..."name" in errorObj && { errorName: errorObj.name },
|
|
5413
|
+
..."methodName" in errorObj && { methodName: errorObj.methodName },
|
|
5414
|
+
..."serviceName" in errorObj && { serviceName: errorObj.serviceName },
|
|
5415
|
+
..."metadata" in errorObj && { grpcMetadata: errorObj.metadata }
|
|
5416
|
+
};
|
|
5417
|
+
} else if (error instanceof Error) {
|
|
5418
|
+
details = error.message;
|
|
5419
|
+
metadata = {
|
|
5420
|
+
originalError: error,
|
|
5421
|
+
stack: error.stack
|
|
5422
|
+
};
|
|
5423
|
+
}
|
|
5424
|
+
return {
|
|
5425
|
+
code,
|
|
5426
|
+
details,
|
|
5427
|
+
metadata
|
|
5428
|
+
};
|
|
5429
|
+
}
|
|
5430
|
+
/**
|
|
5431
|
+
* Creates an event-based subscription for StreamManager V2.
|
|
5432
|
+
* This emits 'error' and 'complete' events instead of using callbacks.
|
|
5433
|
+
*
|
|
5434
|
+
* Error Handling:
|
|
5435
|
+
* - gRPC errors are extracted with full metadata and emitted as 'error' events
|
|
5436
|
+
* - User callback errors are caught and emitted separately to distinguish from stream errors
|
|
5437
|
+
* - Aborted streams don't emit any events (clean shutdown)
|
|
5438
|
+
*
|
|
5439
|
+
* @param stream - The ServerStreamingCall from the V2 client
|
|
5440
|
+
* @param handleResponse - Callback to process each stream response
|
|
5441
|
+
* @returns StreamSubscription with event emitters for error/complete
|
|
5442
|
+
*/
|
|
5443
|
+
function createStreamSubscriptionV2(stream, handleResponse) {
|
|
5444
|
+
const emitter = new EventEmitter();
|
|
5445
|
+
const abortController = new AbortController();
|
|
5446
|
+
let hasEmittedTerminalEvent = false;
|
|
5447
|
+
const subscription = {
|
|
5448
|
+
unsubscribe: () => {
|
|
5449
|
+
abortController.abort();
|
|
5450
|
+
emitter.removeAllListeners();
|
|
5451
|
+
},
|
|
5452
|
+
on: (event, handler) => {
|
|
5453
|
+
emitter.on(event, handler);
|
|
5454
|
+
},
|
|
5455
|
+
off: (event, handler) => {
|
|
5456
|
+
emitter.off(event, handler);
|
|
5457
|
+
}
|
|
5458
|
+
};
|
|
5459
|
+
(async () => {
|
|
5460
|
+
try {
|
|
5461
|
+
for await (const response of stream.responses) {
|
|
5462
|
+
if (abortController.signal.aborted) return;
|
|
5463
|
+
try {
|
|
5464
|
+
handleResponse(response);
|
|
5465
|
+
} catch (callbackError) {
|
|
5466
|
+
if (!abortController.signal.aborted && !hasEmittedTerminalEvent) {
|
|
5467
|
+
hasEmittedTerminalEvent = true;
|
|
5468
|
+
const streamError = {
|
|
5469
|
+
code: GrpcStatusCode.INTERNAL,
|
|
5470
|
+
details: callbackError instanceof Error ? `Callback error: ${callbackError.message}` : "Callback error: Unknown",
|
|
5471
|
+
metadata: {
|
|
5472
|
+
type: "callback-error",
|
|
5473
|
+
originalError: callbackError,
|
|
5474
|
+
stack: callbackError instanceof Error ? callbackError.stack : void 0
|
|
5475
|
+
}
|
|
5476
|
+
};
|
|
5477
|
+
emitter.emit("error", streamError);
|
|
5478
|
+
}
|
|
5479
|
+
return;
|
|
5480
|
+
}
|
|
5481
|
+
}
|
|
5482
|
+
if (!abortController.signal.aborted && !hasEmittedTerminalEvent) {
|
|
5483
|
+
hasEmittedTerminalEvent = true;
|
|
5484
|
+
emitter.emit("complete");
|
|
5485
|
+
}
|
|
5486
|
+
} catch (error) {
|
|
5487
|
+
if (!abortController.signal.aborted && !hasEmittedTerminalEvent) {
|
|
5488
|
+
hasEmittedTerminalEvent = true;
|
|
5489
|
+
const streamError = extractGrpcError(error);
|
|
5490
|
+
emitter.emit("error", streamError);
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5493
|
+
})();
|
|
5494
|
+
return subscription;
|
|
5495
|
+
}
|
|
5496
|
+
|
|
5497
|
+
//#endregion
|
|
5498
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcSpotStreamV2.ts
|
|
5499
|
+
var IndexerGrpcSpotStreamV2 = class {
|
|
5500
|
+
constructor(endpoint, metadata) {
|
|
5501
|
+
_defineProperty(this, "client", void 0);
|
|
5502
|
+
_defineProperty(this, "transport", void 0);
|
|
5503
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
5504
|
+
this.client = new InjectiveSpotExchangeRPCClient(this.transport);
|
|
5505
|
+
}
|
|
5506
|
+
/**
|
|
5507
|
+
* Stream spot orderbook updates
|
|
5508
|
+
* @param params.marketIds - Array of market IDs to stream
|
|
5509
|
+
* @param params.callback - Called for each orderbook update
|
|
5510
|
+
* @returns StreamSubscription
|
|
5511
|
+
*/
|
|
5512
|
+
streamOrderbookUpdates({ marketIds, callback }) {
|
|
5513
|
+
if (!marketIds || marketIds.length === 0) throw new Error("marketIds is required");
|
|
5514
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5515
|
+
const request = InjectiveSpotExchangeRpcPb.StreamOrderbookUpdateRequest.create();
|
|
5516
|
+
request.marketIds = marketIds;
|
|
5517
|
+
return createStreamSubscriptionV2(this.client.streamOrderbookUpdate(request), (response) => {
|
|
5518
|
+
callback(IndexerSpotStreamTransformer.orderbookUpdateStreamCallback(response));
|
|
5519
|
+
});
|
|
5520
|
+
}
|
|
5521
|
+
/**
|
|
5522
|
+
* Stream spot orders
|
|
5523
|
+
* @param params.marketId - Optional market ID to filter
|
|
5524
|
+
* @param params.subaccountId - Optional subaccount ID to filter
|
|
5525
|
+
* @param params.orderSide - Optional order side to filter
|
|
5526
|
+
* @param params.callback - Called for each order update
|
|
5527
|
+
* @returns StreamSubscription
|
|
5528
|
+
*/
|
|
5529
|
+
streamOrders({ marketId, subaccountId, orderSide, callback }) {
|
|
5530
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5531
|
+
const request = InjectiveSpotExchangeRpcPb.StreamOrdersRequest.create();
|
|
5532
|
+
if (marketId) request.marketId = marketId;
|
|
5533
|
+
if (subaccountId) request.subaccountId = subaccountId;
|
|
5534
|
+
if (orderSide) request.orderSide = orderSide;
|
|
5535
|
+
return createStreamSubscriptionV2(this.client.streamOrders(request), (response) => {
|
|
5536
|
+
callback(IndexerSpotStreamTransformer.ordersStreamCallback(response));
|
|
5537
|
+
});
|
|
5538
|
+
}
|
|
5539
|
+
/**
|
|
5540
|
+
* Stream spot order history
|
|
5541
|
+
* @param params.subaccountId - Optional subaccount ID to filter
|
|
5542
|
+
* @param params.marketId - Optional market ID to filter
|
|
5543
|
+
* @param params.orderTypes - Optional order types to filter
|
|
5544
|
+
* @param params.direction - Optional direction to filter
|
|
5545
|
+
* @param params.state - Optional state to filter
|
|
5546
|
+
* @param params.executionTypes - Optional execution types to filter
|
|
5547
|
+
* @param params.callback - Called for each order history update
|
|
5548
|
+
* @returns StreamSubscription
|
|
5549
|
+
*/
|
|
5550
|
+
streamOrderHistory({ subaccountId, marketId, orderTypes, direction, state, executionTypes, callback }) {
|
|
5551
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5552
|
+
const request = InjectiveSpotExchangeRpcPb.StreamOrdersHistoryRequest.create();
|
|
5553
|
+
if (subaccountId) request.subaccountId = subaccountId;
|
|
5554
|
+
if (marketId) request.marketId = marketId;
|
|
5555
|
+
if (orderTypes) request.orderTypes = orderTypes;
|
|
5556
|
+
if (direction) request.direction = direction;
|
|
5557
|
+
if (state) request.state = state;
|
|
5558
|
+
if (executionTypes) request.executionTypes = executionTypes;
|
|
5559
|
+
return createStreamSubscriptionV2(this.client.streamOrdersHistory(request), (response) => {
|
|
5560
|
+
callback(IndexerSpotStreamTransformer.orderHistoryStreamCallback(response));
|
|
5561
|
+
});
|
|
5562
|
+
}
|
|
5563
|
+
/**
|
|
5564
|
+
* Stream spot trades
|
|
5565
|
+
* @param params.marketId - Optional market ID to filter
|
|
5566
|
+
* @param params.marketIds - Optional array of market IDs to filter
|
|
5567
|
+
* @param params.subaccountId - Optional subaccount ID to filter
|
|
5568
|
+
* @param params.subaccountIds - Optional array of subaccount IDs to filter
|
|
5569
|
+
* @param params.executionSide - Optional execution side to filter
|
|
5570
|
+
* @param params.direction - Optional direction to filter
|
|
5571
|
+
* @param params.executionTypes - Optional execution types to filter
|
|
5572
|
+
* @param params.callback - Called for each trade update
|
|
5573
|
+
* @returns StreamSubscription
|
|
5574
|
+
*/
|
|
5575
|
+
streamTrades({ marketId, marketIds, subaccountId, subaccountIds, executionSide, direction, executionTypes, callback }) {
|
|
5576
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5577
|
+
const request = InjectiveSpotExchangeRpcPb.StreamTradesRequest.create();
|
|
5578
|
+
if (marketId) request.marketId = marketId;
|
|
5579
|
+
if (marketIds) request.marketIds = marketIds;
|
|
5580
|
+
if (subaccountId) request.subaccountId = subaccountId;
|
|
5581
|
+
if (subaccountIds) request.subaccountIds = subaccountIds;
|
|
5582
|
+
if (executionSide) request.executionSide = executionSide;
|
|
5583
|
+
if (direction) request.direction = direction;
|
|
5584
|
+
if (executionTypes) request.executionTypes = executionTypes;
|
|
5585
|
+
return createStreamSubscriptionV2(this.client.streamTrades(request), (response) => {
|
|
5586
|
+
callback(IndexerSpotStreamTransformer.tradesStreamCallback(response));
|
|
5587
|
+
});
|
|
5588
|
+
}
|
|
5589
|
+
};
|
|
5590
|
+
|
|
5591
|
+
//#endregion
|
|
5592
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcMitoStreamV2.ts
|
|
5593
|
+
var IndexerGrpcMitoStreamV2 = class {
|
|
5594
|
+
constructor(endpoint, metadata) {
|
|
5595
|
+
_defineProperty(this, "client", void 0);
|
|
5596
|
+
_defineProperty(this, "transport", void 0);
|
|
5597
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
5598
|
+
this.client = new MitoAPIClient(this.transport);
|
|
5599
|
+
}
|
|
5600
|
+
/**
|
|
5601
|
+
* Stream vault transfers
|
|
5602
|
+
* @param params.vault - Optional vault address to filter
|
|
5603
|
+
* @param params.account - Optional account address to filter
|
|
5604
|
+
* @param params.callback - Called for each transfer update
|
|
5605
|
+
* @returns StreamSubscription
|
|
5606
|
+
*/
|
|
5607
|
+
streamTransfers({ vault, account, callback }) {
|
|
5608
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5609
|
+
const request = GoadesignGoagenMitoApiPb.StreamTransfersRequest.create();
|
|
5610
|
+
if (vault) request.vault = vault;
|
|
5611
|
+
if (account) request.account = account;
|
|
5612
|
+
return createStreamSubscriptionV2(this.client.streamTransfers(request), (response) => {
|
|
5613
|
+
callback(IndexerGrpcMitoStreamTransformer.transfersStreamCallback(response));
|
|
5614
|
+
});
|
|
5615
|
+
}
|
|
5616
|
+
/**
|
|
5617
|
+
* Stream vault information
|
|
5618
|
+
* @param params.vault - Optional vault address to filter
|
|
5619
|
+
* @param params.callback - Called for each vault update
|
|
5620
|
+
* @returns StreamSubscription
|
|
5621
|
+
*/
|
|
5622
|
+
streamVault({ vault, callback }) {
|
|
5623
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5624
|
+
const request = GoadesignGoagenMitoApiPb.StreamVaultRequest.create();
|
|
5625
|
+
if (vault) request.vault = vault;
|
|
5626
|
+
return createStreamSubscriptionV2(this.client.streamVault(request), (response) => {
|
|
5627
|
+
callback(IndexerGrpcMitoStreamTransformer.vaultStreamCallback(response));
|
|
5628
|
+
});
|
|
5629
|
+
}
|
|
5630
|
+
/**
|
|
5631
|
+
* Stream vault holder subscriptions
|
|
5632
|
+
* @param params.holderAddress - The holder address to stream subscriptions for
|
|
5633
|
+
* @param params.vaultAddress - Optional vault address to filter
|
|
5634
|
+
* @param params.stakingContractAddress - Optional staking contract address to filter
|
|
5635
|
+
* @param params.callback - Called for each subscription update
|
|
5636
|
+
* @returns StreamSubscription
|
|
5637
|
+
*/
|
|
5638
|
+
streamVaultHolderSubscriptions({ holderAddress, vaultAddress, stakingContractAddress, callback }) {
|
|
5639
|
+
if (!holderAddress) throw new Error("holderAddress is required");
|
|
5640
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5641
|
+
const request = GoadesignGoagenMitoApiPb.StreamHolderSubscriptionRequest.create();
|
|
5642
|
+
request.holderAddress = holderAddress;
|
|
5643
|
+
if (vaultAddress) request.vaultAddress = vaultAddress;
|
|
5644
|
+
if (stakingContractAddress) request.stakingContractAddress = stakingContractAddress;
|
|
5645
|
+
return createStreamSubscriptionV2(this.client.streamHolderSubscription(request), (response) => {
|
|
5646
|
+
callback(IndexerGrpcMitoStreamTransformer.vaultHolderSubscriptionStreamCallback(response));
|
|
5647
|
+
});
|
|
5648
|
+
}
|
|
5649
|
+
/**
|
|
5650
|
+
* Stream staking rewards by account
|
|
5651
|
+
* @param params.staker - The staker address to stream rewards for
|
|
5652
|
+
* @param params.stakingContractAddress - The staking contract address
|
|
5653
|
+
* @param params.callback - Called for each reward update
|
|
5654
|
+
* @returns StreamSubscription
|
|
5655
|
+
*/
|
|
5656
|
+
streamStakingRewardsByAccount({ staker, stakingContractAddress, callback }) {
|
|
5657
|
+
if (!staker) throw new Error("staker is required");
|
|
5658
|
+
if (!stakingContractAddress) throw new Error("stakingContractAddress is required");
|
|
5659
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5660
|
+
const request = GoadesignGoagenMitoApiPb.StreamStakingRewardByAccountRequest.create();
|
|
5661
|
+
request.staker = staker;
|
|
5662
|
+
request.stakingContractAddress = stakingContractAddress;
|
|
5663
|
+
return createStreamSubscriptionV2(this.client.streamStakingRewardByAccount(request), (response) => {
|
|
5664
|
+
callback(IndexerGrpcMitoStreamTransformer.stakingRewardByAccountStreamCallback(response));
|
|
5665
|
+
});
|
|
5666
|
+
}
|
|
5667
|
+
/**
|
|
5668
|
+
* Stream historical staking data
|
|
5669
|
+
* @param params.staker - The staker address to stream data for
|
|
5670
|
+
* @param params.stakingContractAddress - The staking contract address
|
|
5671
|
+
* @param params.callback - Called for each historical staking update
|
|
5672
|
+
* @returns StreamSubscription
|
|
5673
|
+
*/
|
|
5674
|
+
streamHistoricalStaking({ staker, stakingContractAddress, callback }) {
|
|
5675
|
+
if (!staker) throw new Error("staker is required");
|
|
5676
|
+
if (!stakingContractAddress) throw new Error("stakingContractAddress is required");
|
|
5677
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5678
|
+
const request = GoadesignGoagenMitoApiPb.StreamHistoricalStakingRequest.create();
|
|
5679
|
+
request.staker = staker;
|
|
5680
|
+
request.stakingContractAddress = stakingContractAddress;
|
|
5681
|
+
return createStreamSubscriptionV2(this.client.streamHistoricalStaking(request), (response) => {
|
|
5682
|
+
callback(IndexerGrpcMitoStreamTransformer.historicalStakingStreamCallback(response));
|
|
5683
|
+
});
|
|
5684
|
+
}
|
|
5685
|
+
};
|
|
5686
|
+
|
|
5687
|
+
//#endregion
|
|
5688
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcOracleStreamV2.ts
|
|
5689
|
+
var IndexerGrpcOracleStreamV2 = class {
|
|
5690
|
+
constructor(endpoint, metadata) {
|
|
5691
|
+
_defineProperty(this, "client", void 0);
|
|
5692
|
+
_defineProperty(this, "transport", void 0);
|
|
5693
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
5694
|
+
this.client = new InjectiveOracleRPCClient(this.transport);
|
|
5695
|
+
}
|
|
5696
|
+
/**
|
|
5697
|
+
* Stream oracle price updates
|
|
5698
|
+
* @param params.oracleType - The oracle type to stream prices for
|
|
5699
|
+
* @param params.baseSymbol - Optional base symbol filter
|
|
5700
|
+
* @param params.quoteSymbol - Optional quote symbol filter
|
|
5701
|
+
* @param params.callback - Called for each price update
|
|
5702
|
+
* @returns StreamSubscription
|
|
5703
|
+
*/
|
|
5704
|
+
streamOraclePrices({ oracleType, baseSymbol, quoteSymbol, callback }) {
|
|
5705
|
+
if (!oracleType) throw new Error("oracleType is required");
|
|
5706
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5707
|
+
const request = InjectiveOracleRpcPb.StreamPricesRequest.create();
|
|
5708
|
+
if (baseSymbol) request.baseSymbol = baseSymbol;
|
|
5709
|
+
if (quoteSymbol) request.quoteSymbol = quoteSymbol;
|
|
5710
|
+
request.oracleType = oracleType;
|
|
5711
|
+
return createStreamSubscriptionV2(this.client.streamPrices(request), (response) => {
|
|
5712
|
+
callback(IndexerOracleStreamTransformer.pricesStreamCallback(response));
|
|
5713
|
+
});
|
|
5714
|
+
}
|
|
5715
|
+
/**
|
|
5716
|
+
* Stream oracle prices by markets
|
|
5717
|
+
* @param params.marketIds - Optional array of market IDs to filter
|
|
5718
|
+
* @param params.callback - Called for each price update
|
|
5719
|
+
* @returns StreamSubscription
|
|
5720
|
+
*/
|
|
5721
|
+
streamOraclePricesByMarkets({ marketIds, callback }) {
|
|
5722
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5723
|
+
const request = InjectiveOracleRpcPb.StreamPricesByMarketsRequest.create();
|
|
5724
|
+
if (marketIds) request.marketIds = marketIds;
|
|
5725
|
+
return createStreamSubscriptionV2(this.client.streamPricesByMarkets(request), (response) => {
|
|
5726
|
+
callback(IndexerOracleStreamTransformer.pricesByMarketsCallback(response));
|
|
5727
|
+
});
|
|
5728
|
+
}
|
|
5729
|
+
};
|
|
5730
|
+
|
|
5731
|
+
//#endregion
|
|
5732
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcAccountStreamV2.ts
|
|
5733
|
+
var IndexerGrpcAccountStreamV2 = class {
|
|
5734
|
+
constructor(endpoint, metadata) {
|
|
5735
|
+
_defineProperty(this, "client", void 0);
|
|
5736
|
+
_defineProperty(this, "transport", void 0);
|
|
5737
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
5738
|
+
this.client = new InjectiveAccountsRPCClient(this.transport);
|
|
5739
|
+
}
|
|
5740
|
+
/**
|
|
5741
|
+
* Stream subaccount balance updates
|
|
5742
|
+
* @param params.subaccountId - The subaccount ID to stream balance for
|
|
5743
|
+
* @param params.callback - Called for each balance update
|
|
5744
|
+
* @returns StreamSubscription
|
|
5745
|
+
*/
|
|
5746
|
+
streamSubaccountBalance({ subaccountId, callback }) {
|
|
5747
|
+
if (!subaccountId) throw new Error("subaccountId is required");
|
|
5748
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5749
|
+
const request = InjectiveAccountsRpcPb.StreamSubaccountBalanceRequest.create();
|
|
5750
|
+
request.subaccountId = subaccountId;
|
|
5751
|
+
return createStreamSubscriptionV2(this.client.streamSubaccountBalance(request), (response) => {
|
|
5752
|
+
callback(IndexerAccountStreamTransformer.balanceStreamCallback(response));
|
|
5753
|
+
});
|
|
5754
|
+
}
|
|
5755
|
+
};
|
|
5756
|
+
|
|
5757
|
+
//#endregion
|
|
5758
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcAuctionStreamV2.ts
|
|
5759
|
+
var IndexerGrpcAuctionStreamV2 = class {
|
|
5760
|
+
constructor(endpoint, metadata) {
|
|
5761
|
+
_defineProperty(this, "client", void 0);
|
|
5762
|
+
_defineProperty(this, "transport", void 0);
|
|
5763
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
5764
|
+
this.client = new InjectiveAuctionRPCClient(this.transport);
|
|
5765
|
+
}
|
|
5766
|
+
/**
|
|
5767
|
+
* Stream auction bids
|
|
5768
|
+
* @param params.callback - Called for each bid update
|
|
5769
|
+
* @returns StreamSubscription
|
|
5770
|
+
*/
|
|
5771
|
+
streamBids({ callback }) {
|
|
5772
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5773
|
+
const request = InjectiveAuctionRpcPb.StreamBidsRequest.create();
|
|
5774
|
+
return createStreamSubscriptionV2(this.client.streamBids(request), (response) => {
|
|
5775
|
+
callback(IndexerAuctionStreamTransformer.bidsStreamCallback(response));
|
|
5776
|
+
});
|
|
5777
|
+
}
|
|
5778
|
+
};
|
|
5779
|
+
|
|
5780
|
+
//#endregion
|
|
5781
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcTradingStreamV2.ts
|
|
5782
|
+
var IndexerGrpcTradingStreamV2 = class {
|
|
5783
|
+
constructor(endpoint, metadata) {
|
|
5784
|
+
_defineProperty(this, "client", void 0);
|
|
5785
|
+
_defineProperty(this, "transport", void 0);
|
|
5786
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
5787
|
+
this.client = new InjectiveTradingRPCClient(this.transport);
|
|
5788
|
+
}
|
|
5789
|
+
/**
|
|
5790
|
+
* Stream grid strategies
|
|
5791
|
+
* @param params.marketId - Optional market ID to filter strategies
|
|
5792
|
+
* @param params.accountAddresses - Optional array of account addresses to filter
|
|
5793
|
+
* @param params.callback - Called for each strategy update
|
|
5794
|
+
* @returns StreamSubscription
|
|
5795
|
+
*/
|
|
5796
|
+
streamGridStrategies({ marketId, accountAddresses, callback }) {
|
|
5797
|
+
if ((!accountAddresses || accountAddresses.length === 0) && !marketId) throw new Error("accountAddresses or marketId is required");
|
|
5798
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5799
|
+
const request = InjectiveTradingRpcPb.StreamStrategyRequest.create();
|
|
5800
|
+
if (accountAddresses) request.accountAddresses = accountAddresses;
|
|
5801
|
+
if (marketId) request.marketId = marketId;
|
|
5802
|
+
return createStreamSubscriptionV2(this.client.streamStrategy(request), (response) => {
|
|
5803
|
+
callback(response);
|
|
5804
|
+
});
|
|
5805
|
+
}
|
|
5806
|
+
};
|
|
5807
|
+
|
|
5808
|
+
//#endregion
|
|
5809
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcArchiverStreamV2.ts
|
|
5810
|
+
var IndexerGrpcArchiverStreamV2 = class {
|
|
5811
|
+
constructor(endpoint, metadata) {
|
|
5812
|
+
_defineProperty(this, "client", void 0);
|
|
5813
|
+
_defineProperty(this, "transport", void 0);
|
|
5814
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
5815
|
+
this.client = new InjectiveArchiverRPCClient(this.transport);
|
|
5816
|
+
}
|
|
5817
|
+
/**
|
|
5818
|
+
* Stream spot average entries
|
|
5819
|
+
* @param params.account - The account address to stream entries for
|
|
5820
|
+
* @param params.callback - Called for each average entry update
|
|
5821
|
+
* @returns StreamSubscription
|
|
5822
|
+
*/
|
|
5823
|
+
streamSpotAverageEntries({ account, callback }) {
|
|
5824
|
+
if (!account) throw new Error("account is required");
|
|
5825
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5826
|
+
const request = InjectiveArchiverRpcPb.StreamSpotAverageEntriesRequest.create();
|
|
5827
|
+
request.account = account;
|
|
5828
|
+
return createStreamSubscriptionV2(this.client.streamSpotAverageEntries(request), (response) => {
|
|
5829
|
+
callback(IndexerArchiverStreamTransformer.spotAverageEntriesStreamCallback(response));
|
|
5830
|
+
});
|
|
5831
|
+
}
|
|
5832
|
+
};
|
|
5833
|
+
|
|
5834
|
+
//#endregion
|
|
5835
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcExplorerStreamV2.ts
|
|
5836
|
+
var IndexerGrpcExplorerStreamV2 = class {
|
|
5837
|
+
constructor(endpoint, metadata) {
|
|
5838
|
+
_defineProperty(this, "client", void 0);
|
|
5839
|
+
_defineProperty(this, "transport", void 0);
|
|
5840
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
5841
|
+
this.client = new InjectiveExplorerRPCClient(this.transport);
|
|
5842
|
+
}
|
|
5843
|
+
/**
|
|
5844
|
+
* Stream block updates
|
|
5845
|
+
* @param params.callback - Called for each block update
|
|
5846
|
+
* @returns StreamSubscription
|
|
5847
|
+
*/
|
|
5848
|
+
streamBlocks({ callback }) {
|
|
5849
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5850
|
+
const request = InjectiveExplorerRpcPb.StreamBlocksRequest.create();
|
|
5851
|
+
return createStreamSubscriptionV2(this.client.streamBlocks(request), (response) => {
|
|
5852
|
+
callback(ExplorerStreamTransformer.blocksStreamCallback(response));
|
|
5853
|
+
});
|
|
5854
|
+
}
|
|
5855
|
+
/**
|
|
5856
|
+
* Stream blocks with transactions
|
|
5857
|
+
* @param params.callback - Called for each block with transactions update
|
|
5858
|
+
* @returns StreamSubscription
|
|
5859
|
+
*/
|
|
5860
|
+
streamBlocksWithTxs({ callback }) {
|
|
5861
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5862
|
+
const request = InjectiveExplorerRpcPb.StreamBlocksRequest.create();
|
|
5863
|
+
return createStreamSubscriptionV2(this.client.streamBlocks(request), (response) => {
|
|
5864
|
+
callback(ExplorerStreamTransformer.blocksWithTxsStreamCallback(response));
|
|
5865
|
+
});
|
|
5866
|
+
}
|
|
5867
|
+
/**
|
|
5868
|
+
* Stream transaction updates
|
|
5869
|
+
* @param params.callback - Called for each transaction update
|
|
5870
|
+
* @returns StreamSubscription
|
|
5871
|
+
*/
|
|
5872
|
+
streamTransactions({ callback }) {
|
|
5873
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5874
|
+
const request = InjectiveExplorerRpcPb.StreamTxsRequest.create();
|
|
5875
|
+
return createStreamSubscriptionV2(this.client.streamTxs(request), (response) => {
|
|
5876
|
+
callback(ExplorerStreamTransformer.transactionsStreamCallback(response));
|
|
5877
|
+
});
|
|
5878
|
+
}
|
|
5879
|
+
};
|
|
5880
|
+
|
|
5881
|
+
//#endregion
|
|
5882
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcDerivativesStreamV2.ts
|
|
5883
|
+
var IndexerGrpcDerivativesStreamV2 = class {
|
|
5884
|
+
constructor(endpoint, metadata) {
|
|
5885
|
+
_defineProperty(this, "client", void 0);
|
|
5886
|
+
_defineProperty(this, "transport", void 0);
|
|
5887
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
5888
|
+
this.client = new InjectiveDerivativeExchangeRPCClient(this.transport);
|
|
5889
|
+
}
|
|
5890
|
+
/**
|
|
5891
|
+
* Stream derivative orders
|
|
5892
|
+
* @param params.marketId - Optional market ID to filter
|
|
5893
|
+
* @param params.subaccountId - Optional subaccount ID to filter
|
|
5894
|
+
* @param params.orderSide - Optional order side to filter
|
|
5895
|
+
* @param params.callback - Called for each order update
|
|
5896
|
+
* @returns StreamSubscription
|
|
5897
|
+
*/
|
|
5898
|
+
streamOrders({ marketId, subaccountId, orderSide, callback }) {
|
|
5899
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5900
|
+
const request = InjectiveDerivativeExchangeRpcPb.StreamOrdersRequest.create();
|
|
5901
|
+
if (marketId) request.marketId = marketId;
|
|
5902
|
+
if (subaccountId) request.subaccountId = subaccountId;
|
|
5903
|
+
if (orderSide) request.orderSide = orderSide;
|
|
5904
|
+
return createStreamSubscriptionV2(this.client.streamOrders(request), (response) => {
|
|
5905
|
+
callback(IndexerDerivativeStreamTransformer.ordersStreamCallback(response));
|
|
5906
|
+
});
|
|
5907
|
+
}
|
|
5908
|
+
/**
|
|
5909
|
+
* Stream derivative order history
|
|
5910
|
+
* @param params.subaccountId - Optional subaccount ID to filter
|
|
5911
|
+
* @param params.marketId - Optional market ID to filter
|
|
5912
|
+
* @param params.orderTypes - Optional order types to filter
|
|
5913
|
+
* @param params.direction - Optional direction to filter
|
|
5914
|
+
* @param params.state - Optional state to filter
|
|
5915
|
+
* @param params.executionTypes - Optional execution types to filter
|
|
5916
|
+
* @param params.callback - Called for each order history update
|
|
5917
|
+
* @returns StreamSubscription
|
|
5918
|
+
*/
|
|
5919
|
+
streamOrdersHistory({ subaccountId, marketId, orderTypes, direction, state, executionTypes, callback }) {
|
|
5920
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5921
|
+
const request = InjectiveDerivativeExchangeRpcPb.StreamOrdersHistoryRequest.create();
|
|
5922
|
+
if (subaccountId) request.subaccountId = subaccountId;
|
|
5923
|
+
if (marketId) request.marketId = marketId;
|
|
5924
|
+
if (orderTypes) request.orderTypes = orderTypes;
|
|
5925
|
+
if (direction) request.direction = direction;
|
|
5926
|
+
if (state) request.state = state;
|
|
5927
|
+
if (executionTypes) request.executionTypes = executionTypes;
|
|
5928
|
+
return createStreamSubscriptionV2(this.client.streamOrdersHistory(request), (response) => {
|
|
5929
|
+
callback(IndexerDerivativeStreamTransformer.orderHistoryStreamCallback(response));
|
|
5930
|
+
});
|
|
5931
|
+
}
|
|
5932
|
+
/**
|
|
5933
|
+
* Stream derivative trades
|
|
5934
|
+
* @param params.marketId - Optional market ID to filter
|
|
5935
|
+
* @param params.marketIds - Optional array of market IDs to filter
|
|
5936
|
+
* @param params.subaccountId - Optional subaccount ID to filter
|
|
5937
|
+
* @param params.subaccountIds - Optional array of subaccount IDs to filter
|
|
5938
|
+
* @param params.executionSide - Optional execution side to filter
|
|
5939
|
+
* @param params.direction - Optional direction to filter
|
|
5940
|
+
* @param params.pagination - Optional pagination options
|
|
5941
|
+
* @param params.callback - Called for each trade update
|
|
5942
|
+
* @returns StreamSubscription
|
|
5943
|
+
*/
|
|
5944
|
+
streamTrades({ marketIds, marketId, subaccountIds, subaccountId, executionSide, direction, pagination, callback }) {
|
|
5945
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5946
|
+
const request = InjectiveDerivativeExchangeRpcPb.StreamTradesRequest.create();
|
|
5947
|
+
if (marketIds) request.marketIds = marketIds;
|
|
5948
|
+
if (marketId) request.marketId = marketId;
|
|
5949
|
+
if (subaccountIds) request.subaccountIds = subaccountIds;
|
|
5950
|
+
if (subaccountId) request.subaccountId = subaccountId;
|
|
5951
|
+
if (executionSide) request.executionSide = executionSide;
|
|
5952
|
+
if (direction) request.direction = direction;
|
|
5953
|
+
if (pagination) {
|
|
5954
|
+
if (pagination.skip !== void 0) request.skip = BigInt(pagination.skip);
|
|
5955
|
+
if (pagination.limit !== void 0) request.limit = pagination.limit;
|
|
5956
|
+
}
|
|
5957
|
+
return createStreamSubscriptionV2(this.client.streamTrades(request), (response) => {
|
|
5958
|
+
callback(IndexerDerivativeStreamTransformer.tradesStreamCallback(response));
|
|
5959
|
+
});
|
|
5960
|
+
}
|
|
5961
|
+
/**
|
|
5962
|
+
* Stream derivative positions
|
|
5963
|
+
* @param params.marketId - Optional market ID to filter
|
|
5964
|
+
* @param params.address - Optional address to filter
|
|
5965
|
+
* @param params.subaccountId - Optional subaccount ID to filter
|
|
5966
|
+
* @param params.callback - Called for each position update
|
|
5967
|
+
* @returns StreamSubscription
|
|
5968
|
+
*/
|
|
5969
|
+
streamPositions({ marketId, address, subaccountId, callback }) {
|
|
5970
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5971
|
+
const request = InjectiveDerivativeExchangeRpcPb.StreamPositionsRequest.create();
|
|
5972
|
+
if (marketId) request.marketId = marketId;
|
|
5973
|
+
if (address) request.accountAddress = address;
|
|
5974
|
+
if (subaccountId) request.subaccountId = subaccountId;
|
|
5975
|
+
return createStreamSubscriptionV2(this.client.streamPositions(request), (response) => {
|
|
5976
|
+
callback(IndexerDerivativeStreamTransformer.positionStreamCallback(response));
|
|
5977
|
+
});
|
|
5978
|
+
}
|
|
5979
|
+
/**
|
|
5980
|
+
* Stream derivative markets
|
|
5981
|
+
* @param params.marketIds - Optional array of market IDs to filter
|
|
5982
|
+
* @param params.callback - Called for each market update
|
|
5983
|
+
* @returns StreamSubscription
|
|
5984
|
+
*/
|
|
5985
|
+
streamMarkets({ marketIds, callback }) {
|
|
5986
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
5987
|
+
const request = InjectiveDerivativeExchangeRpcPb.StreamMarketRequest.create();
|
|
5988
|
+
if (marketIds && marketIds.length) request.marketIds = marketIds;
|
|
5989
|
+
return createStreamSubscriptionV2(this.client.streamMarket(request), (response) => {
|
|
5990
|
+
callback(response);
|
|
5991
|
+
});
|
|
5992
|
+
}
|
|
5993
|
+
/**
|
|
5994
|
+
* Stream derivative orderbooks V2
|
|
5995
|
+
* @param params.marketIds - Array of market IDs to stream
|
|
5996
|
+
* @param params.callback - Called for each orderbook update
|
|
5997
|
+
* @returns StreamSubscription
|
|
5998
|
+
*/
|
|
5999
|
+
streamOrderbooksV2({ marketIds, callback }) {
|
|
6000
|
+
if (!marketIds || marketIds.length === 0) throw new Error("marketIds is required and cannot be empty");
|
|
6001
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
6002
|
+
const request = InjectiveDerivativeExchangeRpcPb.StreamOrderbookV2Request.create();
|
|
6003
|
+
request.marketIds = marketIds;
|
|
6004
|
+
return createStreamSubscriptionV2(this.client.streamOrderbookV2(request), (response) => {
|
|
6005
|
+
callback(IndexerDerivativeStreamTransformer.orderbookV2StreamCallback(response));
|
|
6006
|
+
});
|
|
6007
|
+
}
|
|
6008
|
+
/**
|
|
6009
|
+
* Stream derivative orderbook updates
|
|
6010
|
+
* @param params.marketIds - Array of market IDs to stream
|
|
6011
|
+
* @param params.callback - Called for each orderbook update
|
|
6012
|
+
* @returns StreamSubscription
|
|
6013
|
+
*/
|
|
6014
|
+
streamOrderbookUpdates({ marketIds, callback }) {
|
|
6015
|
+
if (!marketIds || marketIds.length === 0) throw new Error("marketIds is required and cannot be empty");
|
|
6016
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
6017
|
+
const request = InjectiveDerivativeExchangeRpcPb.StreamOrderbookUpdateRequest.create();
|
|
6018
|
+
request.marketIds = marketIds;
|
|
6019
|
+
return createStreamSubscriptionV2(this.client.streamOrderbookUpdate(request), (response) => {
|
|
6020
|
+
callback(IndexerDerivativeStreamTransformer.orderbookUpdateStreamCallback(response));
|
|
6021
|
+
});
|
|
6022
|
+
}
|
|
6023
|
+
/**
|
|
6024
|
+
* Stream derivative positions V2
|
|
6025
|
+
* @param params.marketId - Optional market ID to filter
|
|
6026
|
+
* @param params.address - Optional address to filter
|
|
6027
|
+
* @param params.subaccountId - Optional subaccount ID to filter
|
|
6028
|
+
* @param params.callback - Called for each position update
|
|
6029
|
+
* @returns StreamSubscription
|
|
6030
|
+
*/
|
|
6031
|
+
streamPositionsV2({ marketId, address, subaccountId, callback }) {
|
|
6032
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
6033
|
+
const request = InjectiveDerivativeExchangeRpcPb.StreamPositionsV2Request.create();
|
|
6034
|
+
if (marketId) request.marketId = marketId;
|
|
6035
|
+
if (address) request.accountAddress = address;
|
|
6036
|
+
if (subaccountId) request.subaccountId = subaccountId;
|
|
6037
|
+
return createStreamSubscriptionV2(this.client.streamPositionsV2(request), (response) => {
|
|
6038
|
+
callback(IndexerDerivativeStreamTransformer.positionV2StreamCallback(response));
|
|
6039
|
+
});
|
|
6040
|
+
}
|
|
6041
|
+
};
|
|
6042
|
+
|
|
6043
|
+
//#endregion
|
|
6044
|
+
//#region src/client/indexer/grpc_stream/streamV2/IndexerGrpcAccountPortfolioStreamV2.ts
|
|
6045
|
+
var IndexerGrpcAccountPortfolioStreamV2 = class {
|
|
6046
|
+
constructor(endpoint, metadata) {
|
|
6047
|
+
_defineProperty(this, "client", void 0);
|
|
6048
|
+
_defineProperty(this, "transport", void 0);
|
|
6049
|
+
this.transport = new GrpcWebRpcTransport(endpoint, metadata);
|
|
6050
|
+
this.client = new InjectivePortfolioRPCClient(this.transport);
|
|
6051
|
+
}
|
|
6052
|
+
/**
|
|
6053
|
+
* Stream account portfolio updates
|
|
6054
|
+
* @param params.accountAddress - The account address to stream portfolio for
|
|
6055
|
+
* @param params.subaccountId - Optional subaccount ID to filter
|
|
6056
|
+
* @param params.type - Optional portfolio type to filter
|
|
6057
|
+
* @param params.callback - Called for each portfolio update
|
|
6058
|
+
* @returns StreamSubscription
|
|
6059
|
+
*/
|
|
6060
|
+
streamAccountPortfolio({ accountAddress, subaccountId, type, callback }) {
|
|
6061
|
+
if (!accountAddress) throw new Error("accountAddress is required");
|
|
6062
|
+
if (typeof callback !== "function") throw new Error("callback must be a function");
|
|
6063
|
+
const request = InjectivePortfolioRpcPb.StreamAccountPortfolioRequest.create();
|
|
6064
|
+
request.accountAddress = accountAddress;
|
|
6065
|
+
if (subaccountId) request.subaccountId = subaccountId;
|
|
6066
|
+
if (type) request.type = type;
|
|
6067
|
+
return createStreamSubscriptionV2(this.client.streamAccountPortfolio(request), (response) => {
|
|
6068
|
+
callback(IndexerAccountPortfolioStreamTransformer.accountPortfolioStreamCallback(response));
|
|
6069
|
+
});
|
|
6070
|
+
}
|
|
6071
|
+
};
|
|
6072
|
+
|
|
6073
|
+
//#endregion
|
|
6074
|
+
//#region src/client/indexer/grpc_stream/streamV2/StreamManagerV2.ts
|
|
6075
|
+
/**
|
|
6076
|
+
* Default retry configuration
|
|
6077
|
+
*/
|
|
6078
|
+
const DEFAULT_RETRY_CONFIG = {
|
|
6079
|
+
enabled: true,
|
|
6080
|
+
maxAttempts: 5,
|
|
6081
|
+
initialDelayMs: 1e3,
|
|
6082
|
+
maxDelayMs: 3e4,
|
|
6083
|
+
backoffMultiplier: 2,
|
|
6084
|
+
persistent: true
|
|
6085
|
+
};
|
|
6086
|
+
/**
|
|
6087
|
+
* Maps gRPC status code to disconnect reason
|
|
6088
|
+
*/
|
|
6089
|
+
function mapGrpcCodeToReason(code) {
|
|
6090
|
+
switch (code) {
|
|
6091
|
+
case GrpcStatusCode.CANCELLED: return StreamDisconnectReason.UserStopped;
|
|
6092
|
+
case GrpcStatusCode.UNAVAILABLE: return StreamDisconnectReason.NetworkError;
|
|
6093
|
+
case GrpcStatusCode.DEADLINE_EXCEEDED: return StreamDisconnectReason.Timeout;
|
|
6094
|
+
case GrpcStatusCode.UNAUTHENTICATED:
|
|
6095
|
+
case GrpcStatusCode.PERMISSION_DENIED: return StreamDisconnectReason.AuthenticationError;
|
|
6096
|
+
case GrpcStatusCode.RESOURCE_EXHAUSTED: return StreamDisconnectReason.RateLimited;
|
|
6097
|
+
case GrpcStatusCode.INVALID_ARGUMENT:
|
|
6098
|
+
case GrpcStatusCode.NOT_FOUND:
|
|
6099
|
+
case GrpcStatusCode.ALREADY_EXISTS:
|
|
6100
|
+
case GrpcStatusCode.OUT_OF_RANGE:
|
|
6101
|
+
case GrpcStatusCode.UNIMPLEMENTED:
|
|
6102
|
+
case GrpcStatusCode.FAILED_PRECONDITION: return StreamDisconnectReason.InvalidRequest;
|
|
6103
|
+
case GrpcStatusCode.UNKNOWN:
|
|
6104
|
+
case GrpcStatusCode.INTERNAL:
|
|
6105
|
+
case GrpcStatusCode.DATA_LOSS:
|
|
6106
|
+
case GrpcStatusCode.ABORTED:
|
|
6107
|
+
default: return StreamDisconnectReason.StreamError;
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6110
|
+
/**
|
|
6111
|
+
* Determines if a disconnect reason should trigger a retry
|
|
6112
|
+
*/
|
|
6113
|
+
function isRetryableReason(reason) {
|
|
6114
|
+
switch (reason) {
|
|
6115
|
+
case StreamDisconnectReason.NetworkError:
|
|
6116
|
+
case StreamDisconnectReason.Timeout:
|
|
6117
|
+
case StreamDisconnectReason.RateLimited:
|
|
6118
|
+
case StreamDisconnectReason.StreamError:
|
|
6119
|
+
case StreamDisconnectReason.StreamEnded: return true;
|
|
6120
|
+
case StreamDisconnectReason.UserStopped:
|
|
6121
|
+
case StreamDisconnectReason.MaxRetries:
|
|
6122
|
+
case StreamDisconnectReason.AuthenticationError:
|
|
6123
|
+
case StreamDisconnectReason.InvalidRequest: return false;
|
|
6124
|
+
default: return false;
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6127
|
+
/**
|
|
6128
|
+
* StreamManagerV2 - Manages gRPC stream connections with automatic retry
|
|
6129
|
+
*
|
|
6130
|
+
* V2 Features:
|
|
6131
|
+
* - Event-based lifecycle (on/off methods)
|
|
6132
|
+
* - Automatic retry with exponential backoff
|
|
6133
|
+
* - Persistent retry mode
|
|
6134
|
+
* - Comprehensive gRPC error code mapping
|
|
6135
|
+
* - Distinguishes retryable vs non-retryable errors
|
|
6136
|
+
*
|
|
6137
|
+
*/
|
|
6138
|
+
var StreamManagerV2 = class extends EventEmitter {
|
|
6139
|
+
constructor(config) {
|
|
6140
|
+
super();
|
|
6141
|
+
_defineProperty(this, "config", void 0);
|
|
6142
|
+
_defineProperty(this, "state", StreamState.Idle);
|
|
6143
|
+
_defineProperty(this, "subscription", null);
|
|
6144
|
+
_defineProperty(this, "retryTimeoutId", null);
|
|
6145
|
+
_defineProperty(this, "retryAttempt", 0);
|
|
6146
|
+
this.config = {
|
|
6147
|
+
id: config.id,
|
|
6148
|
+
streamFactory: config.streamFactory,
|
|
6149
|
+
onData: config.onData,
|
|
6150
|
+
retryConfig: {
|
|
6151
|
+
...DEFAULT_RETRY_CONFIG,
|
|
6152
|
+
...config.retryConfig
|
|
6153
|
+
}
|
|
6154
|
+
};
|
|
6155
|
+
const originalEmit = this.emit.bind(this);
|
|
6156
|
+
this.emit = ((event, ...args) => {
|
|
6157
|
+
if (event === StreamEvent.Data && args.length > 0) this.handleData(args[0]);
|
|
6158
|
+
return originalEmit(event, ...args);
|
|
6159
|
+
});
|
|
6160
|
+
}
|
|
6161
|
+
start() {
|
|
6162
|
+
if (this.state !== StreamState.Idle && this.state !== StreamState.Stopped) {
|
|
6163
|
+
this.emit(StreamEvent.Warn, { message: `Stream already started (state: ${this.state})` });
|
|
6164
|
+
return;
|
|
6165
|
+
}
|
|
6166
|
+
this.connect();
|
|
6167
|
+
}
|
|
6168
|
+
stop() {
|
|
6169
|
+
this.handleDisconnect(StreamDisconnectReason.UserStopped);
|
|
6170
|
+
}
|
|
6171
|
+
getId() {
|
|
6172
|
+
return this.config.id;
|
|
6173
|
+
}
|
|
6174
|
+
/**
|
|
6175
|
+
* Destroy the stream manager and clean up all resources
|
|
6176
|
+
* Call this when the stream manager is no longer needed
|
|
6177
|
+
*/
|
|
6178
|
+
destroy() {
|
|
6179
|
+
this.stop();
|
|
6180
|
+
this.removeAllListeners();
|
|
6181
|
+
}
|
|
6182
|
+
getState() {
|
|
6183
|
+
return this.state;
|
|
6184
|
+
}
|
|
6185
|
+
updateState(newState) {
|
|
6186
|
+
const oldState = this.state;
|
|
6187
|
+
this.state = newState;
|
|
6188
|
+
this.emit(StreamEvent.StateChange, {
|
|
6189
|
+
from: oldState,
|
|
6190
|
+
to: newState
|
|
6191
|
+
});
|
|
6192
|
+
}
|
|
6193
|
+
clearSubscription() {
|
|
6194
|
+
if (!this.subscription) return;
|
|
6195
|
+
this.subscription.unsubscribe();
|
|
6196
|
+
this.subscription = null;
|
|
6197
|
+
}
|
|
6198
|
+
clearRetryTimeout() {
|
|
6199
|
+
if (!this.retryTimeoutId) return;
|
|
6200
|
+
clearTimeout(this.retryTimeoutId);
|
|
6201
|
+
this.retryTimeoutId = null;
|
|
6202
|
+
}
|
|
6203
|
+
calculateNextBackoff(reason) {
|
|
6204
|
+
const baseDelay = reason === StreamDisconnectReason.RateLimited ? Math.max(this.config.retryConfig.initialDelayMs, 5e3) : this.config.retryConfig.initialDelayMs;
|
|
6205
|
+
if (this.config.retryConfig.maxAttempts > 0 && this.retryAttempt >= this.config.retryConfig.maxAttempts) return this.config.retryConfig.persistent ? this.config.retryConfig.maxDelayMs : null;
|
|
6206
|
+
const nextBackoffDelay = baseDelay * Math.pow(this.config.retryConfig.backoffMultiplier, this.retryAttempt);
|
|
6207
|
+
return Math.min(nextBackoffDelay, this.config.retryConfig.maxDelayMs);
|
|
6208
|
+
}
|
|
6209
|
+
scheduleRetry(reason) {
|
|
6210
|
+
if (!this.config.retryConfig.enabled) return;
|
|
6211
|
+
const nextBackoff = this.calculateNextBackoff(reason);
|
|
6212
|
+
if (nextBackoff === null) {
|
|
6213
|
+
this.handleMaxRetriesReached();
|
|
6214
|
+
return;
|
|
6215
|
+
}
|
|
6216
|
+
this.retryTimeoutId = setTimeout(() => {
|
|
6217
|
+
this.retryAttempt++;
|
|
6218
|
+
this.emit(StreamEvent.Retry, {
|
|
6219
|
+
attempt: this.retryAttempt,
|
|
6220
|
+
delayMs: nextBackoff,
|
|
6221
|
+
nextBackoff: this.calculateNextBackoff(reason)
|
|
6222
|
+
});
|
|
6223
|
+
this.connect();
|
|
6224
|
+
}, nextBackoff);
|
|
6225
|
+
}
|
|
6226
|
+
handleMaxRetriesReached() {
|
|
6227
|
+
this.emit(StreamEvent.Error, { message: `Max retries (${this.config.retryConfig.maxAttempts}) reached` });
|
|
6228
|
+
this.handleDisconnect(StreamDisconnectReason.MaxRetries);
|
|
6229
|
+
}
|
|
6230
|
+
handleError(error) {
|
|
6231
|
+
const errorInfo = this.extractErrorInfo(error);
|
|
6232
|
+
this.emit(StreamEvent.Error, errorInfo);
|
|
6233
|
+
const reason = mapGrpcCodeToReason(error && typeof error === "object" && "code" in error ? error.code : GrpcStatusCode.UNKNOWN);
|
|
6234
|
+
this.handleDisconnect(reason);
|
|
6235
|
+
}
|
|
6236
|
+
/**
|
|
6237
|
+
* Handles incoming data - calls user callback
|
|
6238
|
+
* Called automatically when user emits 'data' event from streamFactory callback
|
|
6239
|
+
*/
|
|
6240
|
+
handleData(response) {
|
|
6241
|
+
try {
|
|
6242
|
+
this.config.onData(response);
|
|
6243
|
+
} catch (error) {
|
|
6244
|
+
this.handleError(error);
|
|
6245
|
+
}
|
|
6246
|
+
}
|
|
6247
|
+
handleConnected(isReconnect) {
|
|
6248
|
+
this.updateState(StreamState.Connected);
|
|
6249
|
+
this.retryAttempt = 0;
|
|
6250
|
+
this.emit(StreamEvent.Connect, {
|
|
6251
|
+
isReconnect,
|
|
6252
|
+
attempt: 0
|
|
6253
|
+
});
|
|
6254
|
+
}
|
|
6255
|
+
handleDisconnect(reason) {
|
|
6256
|
+
this.clearSubscription();
|
|
6257
|
+
this.clearRetryTimeout();
|
|
6258
|
+
const willRetry = isRetryableReason(reason) && this.config.retryConfig.enabled;
|
|
6259
|
+
this.emit(StreamEvent.Disconnect, {
|
|
6260
|
+
reason,
|
|
6261
|
+
willRetry,
|
|
6262
|
+
attempt: this.retryAttempt
|
|
6263
|
+
});
|
|
6264
|
+
if (willRetry) {
|
|
6265
|
+
this.updateState(StreamState.Reconnecting);
|
|
6266
|
+
this.scheduleRetry(reason);
|
|
6267
|
+
} else this.updateState(StreamState.Stopped);
|
|
6268
|
+
}
|
|
6269
|
+
connect() {
|
|
6270
|
+
this.clearSubscription();
|
|
6271
|
+
const isReconnect = this.state === StreamState.Reconnecting;
|
|
6272
|
+
this.updateState(isReconnect ? StreamState.Reconnecting : StreamState.Connecting);
|
|
6273
|
+
try {
|
|
6274
|
+
this.subscription = this.config.streamFactory();
|
|
6275
|
+
this.subscription.on("error", (error) => {
|
|
6276
|
+
this.handleError(error);
|
|
6277
|
+
});
|
|
6278
|
+
this.subscription.on("complete", () => {
|
|
6279
|
+
this.handleDisconnect(StreamDisconnectReason.StreamEnded);
|
|
6280
|
+
});
|
|
6281
|
+
this.handleConnected(isReconnect);
|
|
6282
|
+
} catch (error) {
|
|
6283
|
+
this.handleError(error);
|
|
6284
|
+
}
|
|
6285
|
+
}
|
|
6286
|
+
/**
|
|
6287
|
+
* Extracts error message, code, and details from an error object
|
|
6288
|
+
*/
|
|
6289
|
+
extractErrorInfo(error) {
|
|
6290
|
+
if (error && typeof error === "object" && "details" in error) return {
|
|
6291
|
+
message: error.details,
|
|
6292
|
+
code: error.code,
|
|
6293
|
+
details: error
|
|
6294
|
+
};
|
|
6295
|
+
const code = error && typeof error === "object" && "code" in error ? error.code : void 0;
|
|
6296
|
+
return {
|
|
6297
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
6298
|
+
code,
|
|
6299
|
+
details: error instanceof Error ? error.stack : error
|
|
6300
|
+
};
|
|
6301
|
+
}
|
|
6302
|
+
};
|
|
6303
|
+
|
|
6304
|
+
//#endregion
|
|
6305
|
+
export { IndexerGrpcMegaVaultTransformer as $, IndexerGrpcInsuranceFundApi as A, IndexerGrpcAccountApi as B, IndexerGrpcSpotStream as C, IndexerRestMarketChronosApi as D, IndexerRestDerivativesChronosApi as E, IndexerGrpcArchiverApi as F, IndexerAccountPortfolioStreamTransformer as G, IndexerGrpcSpotApi as H, IndexerGrpcCampaignApi as I, IndexerGrpcAccountPortfolioTransformer as J, IndexerGrpcInsuranceFundTransformer as K, IndexerGrpcExplorerApi as L, IndexerGrpcDerivativesApi as M, IndexerGrpcMegaVaultApi as N, IndexerRestSpotChronosApi as O, IndexerGrpcReferralApi as P, IndexerArchiverStreamTransformer as Q, IndexerGrpcTradingApi as R, IndexerGrpcMitoStream as S, IndexerRestLeaderboardChronosApi as T, IndexerGrpcMetaApi as U, IndexerGrpcOracleApi as V, IndexerGrpcMitoApi as W, IndexerGrpcDerivativeTransformer as X, IndexerGrpcMitoStreamTransformer as Y, ExplorerStreamTransformer as Z, IndexerGrpcArchiverStream as _, IndexerGrpcArchiverStreamV2 as a, IndexerGrpcExplorerTransformer as at, IndexerGrpcAccountStream as b, IndexerGrpcAccountStreamV2 as c, IndexerGrpcAccountTransformer as ct, IndexerGrpcSpotStreamV2 as d, IndexerCampaignTransformer as dt, IndexerAuctionStreamTransformer as et, createStreamSubscriptionV2 as f, IndexerGrpcSpotTransformer as ft, IndexerGrpcExplorerStream as g, IndexerGrpcDerivativesStream as h, IndexerGrpcExplorerStreamV2 as i, IndexerGrpcReferralTransformer as it, IndexerGrpcAccountPortfolioApi as j, IndexerRestExplorerApi as k, IndexerGrpcOracleStreamV2 as l, IndexerSpotStreamTransformer as lt, IndexerGrpcAccountPortfolioStream as m, IndexerGrpcAccountPortfolioStreamV2 as n, IndexerRestExplorerTransformer as nt, IndexerGrpcTradingStreamV2 as o, IndexerGrpcArchiverTransformer as ot, StreamManager as p, IndexerGrpcMitoTransformer as pt, IndexerDerivativeStreamTransformer as q, IndexerGrpcDerivativesStreamV2 as r, IndexerOracleStreamTransformer as rt, IndexerGrpcAuctionStreamV2 as s, IndexerGrpcAuctionTransformer as st, StreamManagerV2 as t, IndexerAccountStreamTransformer as tt, IndexerGrpcMitoStreamV2 as u, IndexerGrpcOracleTransformer as ut, IndexerGrpcTradingStream as v, createStreamSubscription as w, IndexerGrpcOracleStream as x, IndexerGrpcAuctionStream as y, IndexerGrpcAuctionApi as z };
|