@burningflames/inj-exchange-sdk 0.2.0 → 0.3.0
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/README.md +19 -10
- package/dist/clients/indexer.cjs +1 -1
- package/dist/clients/indexer.d.cts +1 -1
- package/dist/clients/indexer.d.ts +1 -1
- package/dist/clients/indexer.js +1 -1
- package/dist/{index-CWbL8bgV.d.cts → index-D9iUJ2dU.d.cts} +4 -2
- package/dist/{index-BOvbtaH9.d.ts → index-Zb1MmK7L.d.ts} +4 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{indexer-CJOiN_jd.js → indexer-D_9xZbW-.js} +18 -12
- package/dist/{indexer-BryK87hi.cjs → indexer-pTkAEtBo.cjs} +18 -12
- package/dist/{stream-D8ZvUQFy.cjs → stream-B2Mi9XL8.cjs} +2 -0
- package/dist/{stream-RhVNTED5.js → stream-CbXgyx26.js} +2 -0
- package/dist/{stream-BgKRWG60.d.cts → stream-ChRmJm8w.d.cts} +3 -1
- package/dist/{stream-BgKRWG60.d.ts → stream-ChRmJm8w.d.ts} +3 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -225,15 +225,24 @@ feed.start();
|
|
|
225
225
|
|
|
226
226
|
Events are `data`, `connect` (`isReconnect`, `attempt`), `retry` (the `delayMs` it
|
|
227
227
|
will wait and the `nextBackoff`), `disconnect` (`reason`, `willRetry`, `attempt`)
|
|
228
|
-
and `error`.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
`DEADLINE_EXCEEDED`, `RESOURCE_EXHAUSTED`, `UNKNOWN`, `INTERNAL`,
|
|
233
|
-
`ABORTED` are retried; anything else ends the stream and reports
|
|
234
|
-
readable as `DEFAULT_RETRY_CONFIG`, and the stream client's
|
|
235
|
-
replaces any part of it — `enabled: false` makes a dropped feed
|
|
236
|
-
silent.
|
|
228
|
+
and `error`. `feed.state` reads the lifecycle, and `StreamState.Failed` is the end
|
|
229
|
+
of it.
|
|
230
|
+
|
|
231
|
+
Retrying is on by default — five attempts, 1 s doubling to a 30 s cap. Only
|
|
232
|
+
`UNAVAILABLE`, `DEADLINE_EXCEEDED`, `RESOURCE_EXHAUSTED`, `UNKNOWN`, `INTERNAL`,
|
|
233
|
+
`DATA_LOSS` and `ABORTED` are retried; anything else ends the stream and reports
|
|
234
|
+
it. The policy is readable as `DEFAULT_RETRY_CONFIG`, and the stream client's
|
|
235
|
+
fourth argument replaces any part of it — `enabled: false` makes a dropped feed
|
|
236
|
+
loud instead of silent.
|
|
237
|
+
|
|
238
|
+
One message, or a connection that holds for `stableConnectionMs` (five seconds by
|
|
239
|
+
default), proves the subscription works and gives the whole budget back. So a feed
|
|
240
|
+
that delivers and then drops keeps coming back; `MAX_RETRIES` is for a stream that
|
|
241
|
+
cannot get a message at all. When the attempts are spent the stream is finished: it
|
|
242
|
+
emits `disconnect` with reason `max-retries` and an `error` named `MAX_RETRIES`,
|
|
243
|
+
moves to `Failed`, and `start()` throws from then on. Recover by building a new
|
|
244
|
+
stream from the same client — the client keeps its gRPC channel open, so that costs
|
|
245
|
+
an RPC, not a handshake.
|
|
237
246
|
|
|
238
247
|
## Markets used for the proofs
|
|
239
248
|
|
|
@@ -244,7 +253,7 @@ silent.
|
|
|
244
253
|
|
|
245
254
|
```sh
|
|
246
255
|
bun run check # oxlint, oxfmt --check, tsc --noEmit, bun test
|
|
247
|
-
bun test #
|
|
256
|
+
bun test # 68 tests: encodings, EIP-712 payload, decimal scaling, pagination, retry policy
|
|
248
257
|
bun run build # tsdown → dist/, ESM and CJS with declarations
|
|
249
258
|
bun run check:pack # the file list a publish would carry; refuses an unexpected one
|
|
250
259
|
bun pm pack # the publishable tarball
|
package/dist/clients/indexer.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_indexer = require("../indexer-
|
|
2
|
+
const require_indexer = require("../indexer-pTkAEtBo.cjs");
|
|
3
3
|
exports.DEFAULT_RETRY_CONFIG = require_indexer.DEFAULT_RETRY_CONFIG;
|
|
4
4
|
exports.IndexerAccountsApiClient = require_indexer.IndexerAccountsApiClient;
|
|
5
5
|
exports.IndexerAccountsStreamClient = require_indexer.IndexerAccountsStreamClient;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "../index-
|
|
1
|
+
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "../index-D9iUJ2dU.cjs";
|
|
2
2
|
export { DEFAULT_RETRY_CONFIG, IndexerAccountsApiClient, IndexerAccountsStreamClient, IndexerArchiverApiClient, IndexerDerivativesApiClient, IndexerDerivativesStreamClient, IndexerOracleApiClient, IndexerOracleStreamClient, IndexerPortfolioApiClient, IndexerPortfolioStreamClient, IndexerSpotApiClient, IndexerSpotStreamClient, StreamManager };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "../index-
|
|
1
|
+
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "../index-Zb1MmK7L.js";
|
|
2
2
|
export { DEFAULT_RETRY_CONFIG, IndexerAccountsApiClient, IndexerAccountsStreamClient, IndexerArchiverApiClient, IndexerDerivativesApiClient, IndexerDerivativesStreamClient, IndexerOracleApiClient, IndexerOracleStreamClient, IndexerPortfolioApiClient, IndexerPortfolioStreamClient, IndexerSpotApiClient, IndexerSpotStreamClient, StreamManager };
|
package/dist/clients/indexer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, a as IndexerAccountsStreamClient, f as IndexerArchiverApiClient, d as IndexerDerivativesApiClient, i as IndexerDerivativesStreamClient, u as IndexerOracleApiClient, r as IndexerOracleStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, c as IndexerSpotApiClient, t as IndexerSpotStreamClient, s as StreamManager } from "../indexer-
|
|
1
|
+
export { o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, a as IndexerAccountsStreamClient, f as IndexerArchiverApiClient, d as IndexerDerivativesApiClient, i as IndexerDerivativesStreamClient, u as IndexerOracleApiClient, r as IndexerOracleStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, c as IndexerSpotApiClient, t as IndexerSpotStreamClient, s as StreamManager } from "../indexer-D_9xZbW-.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChannelCredentials, ChannelOptions, ClientReadableStream } from "@grpc/grpc-js";
|
|
2
2
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
3
3
|
import { EventEmitter } from "eventemitter3";
|
|
4
|
-
import { r as StreamManagerRetryConfig, t as EventTypes } from "./stream-
|
|
4
|
+
import { i as StreamState, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-ChRmJm8w.cjs";
|
|
5
5
|
interface OrderStatesRequest {
|
|
6
6
|
spotOrderHashes: string[];
|
|
7
7
|
derivativeOrderHashes: string[];
|
|
@@ -2115,7 +2115,7 @@ declare const DEFAULT_RETRY_CONFIG: Readonly<StreamManagerRetryConfig>;
|
|
|
2115
2115
|
declare class StreamManager<StreamResponse> extends EventEmitter<EventTypes<StreamResponse>> {
|
|
2116
2116
|
private streamFactory;
|
|
2117
2117
|
private subscription;
|
|
2118
|
-
private
|
|
2118
|
+
private currentState;
|
|
2119
2119
|
private retryConfig;
|
|
2120
2120
|
private streamError;
|
|
2121
2121
|
private retryAttempts;
|
|
@@ -2123,6 +2123,8 @@ declare class StreamManager<StreamResponse> extends EventEmitter<EventTypes<Stre
|
|
|
2123
2123
|
private stableConnectionTimeout;
|
|
2124
2124
|
private path;
|
|
2125
2125
|
constructor(streamFactory: () => ClientReadableStream<StreamResponse>, path: string, retryConfig?: Partial<StreamManagerRetryConfig>);
|
|
2126
|
+
/** Where the stream is in its lifecycle; `Failed` is terminal. */
|
|
2127
|
+
get state(): StreamState;
|
|
2126
2128
|
start(): void;
|
|
2127
2129
|
stop(): void;
|
|
2128
2130
|
destroy(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChannelCredentials, ChannelOptions, ClientReadableStream } from "@grpc/grpc-js";
|
|
2
2
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
3
3
|
import { EventEmitter } from "eventemitter3";
|
|
4
|
-
import { r as StreamManagerRetryConfig, t as EventTypes } from "./stream-
|
|
4
|
+
import { i as StreamState, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-ChRmJm8w.js";
|
|
5
5
|
interface OrderStatesRequest {
|
|
6
6
|
spotOrderHashes: string[];
|
|
7
7
|
derivativeOrderHashes: string[];
|
|
@@ -2115,7 +2115,7 @@ declare const DEFAULT_RETRY_CONFIG: Readonly<StreamManagerRetryConfig>;
|
|
|
2115
2115
|
declare class StreamManager<StreamResponse> extends EventEmitter<EventTypes<StreamResponse>> {
|
|
2116
2116
|
private streamFactory;
|
|
2117
2117
|
private subscription;
|
|
2118
|
-
private
|
|
2118
|
+
private currentState;
|
|
2119
2119
|
private retryConfig;
|
|
2120
2120
|
private streamError;
|
|
2121
2121
|
private retryAttempts;
|
|
@@ -2123,6 +2123,8 @@ declare class StreamManager<StreamResponse> extends EventEmitter<EventTypes<Stre
|
|
|
2123
2123
|
private stableConnectionTimeout;
|
|
2124
2124
|
private path;
|
|
2125
2125
|
constructor(streamFactory: () => ClientReadableStream<StreamResponse>, path: string, retryConfig?: Partial<StreamManagerRetryConfig>);
|
|
2126
|
+
/** Where the stream is in its lifecycle; `Failed` is terminal. */
|
|
2127
|
+
get state(): StreamState;
|
|
2126
2128
|
start(): void;
|
|
2127
2129
|
stop(): void;
|
|
2128
2130
|
destroy(): void;
|
package/dist/index.cjs
CHANGED
|
@@ -4,12 +4,12 @@ const require_tx = require("./tx-DIg8nbnn.cjs");
|
|
|
4
4
|
const require_exchange = require("./exchange-CTLbPuA7.cjs");
|
|
5
5
|
const require_types = require("./types.cjs");
|
|
6
6
|
const require_errors = require("./errors-CKG7zTvs.cjs");
|
|
7
|
-
const require_stream = require("./stream-
|
|
7
|
+
const require_stream = require("./stream-B2Mi9XL8.cjs");
|
|
8
8
|
const require_msgs = require("./msgs-DNyc0UtV.cjs");
|
|
9
9
|
const require_decimal = require("./decimal-DJMaLHQO.cjs");
|
|
10
10
|
const require_chain = require("./chain-LTb0TjXc.cjs");
|
|
11
11
|
const require_tx$1 = require("./tx-BgpasOOk.cjs");
|
|
12
|
-
const require_indexer = require("./indexer-
|
|
12
|
+
const require_indexer = require("./indexer-pTkAEtBo.cjs");
|
|
13
13
|
const require_utils = require("./utils.cjs");
|
|
14
14
|
exports.ApiError = require_errors.ApiError;
|
|
15
15
|
exports.BroadcastMode = require_query.BroadcastMode;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,9 +3,9 @@ import { D as OrderType, E as OrderMask, I as SignDoc, L as SignMode, O as Marke
|
|
|
3
3
|
import { n as Eip712TypedDataField, t as Eip712TypedData } from "./eip712-88KVCEnw.cjs";
|
|
4
4
|
import { a as TxRaw, c as PaginationOption, i as StdFee, n as CreateTransactionResult, o as Msg, r as SignerDetails, s as Pagination, t as CreateTransactionParams } from "./tx-CCt0zqng.cjs";
|
|
5
5
|
import { ApiError } from "./types.cjs";
|
|
6
|
-
import { i as StreamState, n as StreamDisconnectReason, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-
|
|
6
|
+
import { i as StreamState, n as StreamDisconnectReason, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-ChRmJm8w.cjs";
|
|
7
7
|
import "./msgs.cjs";
|
|
8
8
|
import { a as ChainAuthZApiClient, i as ChainBankApiClient, n as ChainTendermintApiClient, o as ChainAuthApiClient, r as ChainExchangeApiClient, t as ChainTxApiClient } from "./index-BT_zyZW9.cjs";
|
|
9
|
-
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "./index-
|
|
9
|
+
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "./index-D9iUJ2dU.cjs";
|
|
10
10
|
import { a as sanitizeBlock, c as toPagination, d as hexToBytes, f as getEip712TypedDataV2, g as getInjectiveAddress, h as getEthereumAddress, i as createWeb3Extension, l as bytesToHex, m as toCosmosSdkDecString, n as createTxBytes, o as sanitizeLatestBlock, p as toChainFormat, r as createTxRawEIP712, s as toPageRequest, t as createTransaction, u as hexToBase64 } from "./index-BPpDV6JA.cjs";
|
|
11
11
|
export { ApiError, BroadcastMode, ChainAuthApiClient, ChainAuthZApiClient, ChainBankApiClient, ChainExchangeApiClient, ChainId, ChainTendermintApiClient, ChainTxApiClient, CreateTransactionParams, CreateTransactionResult, DEFAULT_RETRY_CONFIG, Eip712TypedData, Eip712TypedDataField, EventTypes, EvmChainId, ExecutionType, IndexerAccountsApiClient, IndexerAccountsStreamClient, IndexerArchiverApiClient, IndexerDerivativesApiClient, IndexerDerivativesStreamClient, IndexerOracleApiClient, IndexerOracleStreamClient, IndexerPortfolioApiClient, IndexerPortfolioStreamClient, IndexerSpotApiClient, IndexerSpotStreamClient, MarketStatus, Msg, MsgBatchCancelDerivativeOrders, MsgBatchCancelSpotOrders, MsgCancelDerivativeOrder, MsgCancelSpotOrder, MsgCreateDerivativeLimitOrder, MsgCreateDerivativeMarketOrder, MsgCreateSpotLimitOrder, MsgCreateSpotMarketOrder, MsgDeposit, MsgExternalTransfer, MsgIncreasePositionMargin, MsgSend, MsgSubaccountTransfer, MsgWithdraw, OrderMask, OrderSide, OrderType, Pagination, PaginationOption, type SignDoc, SignMode, SignerDetails, StdFee, StreamDisconnectReason, StreamManager, StreamManagerRetryConfig, StreamState, TxRaw, bytesToHex, createTransaction, createTxBytes, createTxRawEIP712, createWeb3Extension, getEip712TypedDataV2, getEthereumAddress, getInjectiveAddress, hexToBase64, hexToBytes, sanitizeBlock, sanitizeLatestBlock, toChainFormat, toCosmosSdkDecString, toPageRequest, toPagination };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { B as OrderMask, H as MarketStatus, M as OrderSide, T as SignMode, V as
|
|
|
3
3
|
import { ApiError } from "./types.js";
|
|
4
4
|
import { a as TxRaw, c as PaginationOption, i as StdFee, n as CreateTransactionResult, o as Msg, r as SignerDetails, s as Pagination, t as CreateTransactionParams } from "./tx-BRaw1C6e.js";
|
|
5
5
|
import "./msgs.js";
|
|
6
|
-
import { i as StreamState, n as StreamDisconnectReason, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-
|
|
6
|
+
import { i as StreamState, n as StreamDisconnectReason, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-ChRmJm8w.js";
|
|
7
7
|
import { n as Eip712TypedDataField, t as Eip712TypedData } from "./eip712-88KVCEnw.js";
|
|
8
8
|
import { a as ChainAuthZApiClient, i as ChainBankApiClient, n as ChainTendermintApiClient, o as ChainAuthApiClient, r as ChainExchangeApiClient, t as ChainTxApiClient } from "./index-BHLUinQA.js";
|
|
9
|
-
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "./index-
|
|
9
|
+
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "./index-Zb1MmK7L.js";
|
|
10
10
|
import { a as sanitizeBlock, c as toPagination, d as hexToBytes, f as getEip712TypedDataV2, g as getInjectiveAddress, h as getEthereumAddress, i as createWeb3Extension, l as bytesToHex, m as toCosmosSdkDecString, n as createTxBytes, o as sanitizeLatestBlock, p as toChainFormat, r as createTxRawEIP712, s as toPageRequest, t as createTransaction, u as hexToBase64 } from "./index-DfoLUPEo.js";
|
|
11
11
|
export { ApiError, BroadcastMode, ChainAuthApiClient, ChainAuthZApiClient, ChainBankApiClient, ChainExchangeApiClient, ChainId, ChainTendermintApiClient, ChainTxApiClient, CreateTransactionParams, CreateTransactionResult, DEFAULT_RETRY_CONFIG, Eip712TypedData, Eip712TypedDataField, EventTypes, EvmChainId, ExecutionType, IndexerAccountsApiClient, IndexerAccountsStreamClient, IndexerArchiverApiClient, IndexerDerivativesApiClient, IndexerDerivativesStreamClient, IndexerOracleApiClient, IndexerOracleStreamClient, IndexerPortfolioApiClient, IndexerPortfolioStreamClient, IndexerSpotApiClient, IndexerSpotStreamClient, MarketStatus, Msg, MsgBatchCancelDerivativeOrders, MsgBatchCancelSpotOrders, MsgCancelDerivativeOrder, MsgCancelSpotOrder, MsgCreateDerivativeLimitOrder, MsgCreateDerivativeMarketOrder, MsgCreateSpotLimitOrder, MsgCreateSpotMarketOrder, MsgDeposit, MsgExternalTransfer, MsgIncreasePositionMargin, MsgSend, MsgSubaccountTransfer, MsgWithdraw, OrderMask, OrderSide, OrderType, Pagination, PaginationOption, type SignDoc, SignMode, SignerDetails, StdFee, StreamDisconnectReason, StreamManager, StreamManagerRetryConfig, StreamState, TxRaw, bytesToHex, createTransaction, createTxBytes, createTxRawEIP712, createWeb3Extension, getEip712TypedDataV2, getEthereumAddress, getInjectiveAddress, hexToBase64, hexToBytes, sanitizeBlock, sanitizeLatestBlock, toChainFormat, toCosmosSdkDecString, toPageRequest, toPagination };
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import { u as SignMode } from "./tx-GN0SFql2.js";
|
|
|
3
3
|
import { N as OrderMask, P as OrderType, U as MarketStatus, d as ExecutionType } from "./exchange-BPRx-kFI.js";
|
|
4
4
|
import { ChainId, EvmChainId } from "./types.js";
|
|
5
5
|
import { t as ApiError } from "./errors-MWG_E5zA.js";
|
|
6
|
-
import { n as StreamState, t as StreamDisconnectReason } from "./stream-
|
|
6
|
+
import { n as StreamState, t as StreamDisconnectReason } from "./stream-CbXgyx26.js";
|
|
7
7
|
import { a as MsgDeposit, c as MsgCreateDerivativeMarketOrder, d as MsgCancelDerivativeOrder, f as MsgBatchCancelSpotOrders, i as MsgExternalTransfer, l as MsgCreateDerivativeLimitOrder, m as MsgSend, n as MsgSubaccountTransfer, o as MsgCreateSpotMarketOrder, p as MsgBatchCancelDerivativeOrders, r as MsgIncreasePositionMargin, s as MsgCreateSpotLimitOrder, t as MsgWithdraw, u as MsgCancelSpotOrder } from "./msgs-Bi5b52-R.js";
|
|
8
8
|
import { n as toCosmosSdkDecString, t as toChainFormat } from "./decimal-CIFXn110.js";
|
|
9
9
|
import { a as ChainAuthZApiClient, i as ChainBankApiClient, n as ChainTendermintApiClient, o as ChainAuthApiClient, r as ChainExchangeApiClient, t as ChainTxApiClient } from "./chain-CgjV0b1c.js";
|
|
10
10
|
import { a as sanitizeBlock, c as toPagination, i as createWeb3Extension, n as createTxBytes, o as sanitizeLatestBlock, r as createTxRawEIP712, s as toPageRequest, t as createTransaction } from "./tx-COcDYlg3.js";
|
|
11
|
-
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "./indexer-
|
|
11
|
+
import { a as IndexerAccountsStreamClient, c as IndexerSpotApiClient, d as IndexerDerivativesApiClient, f as IndexerArchiverApiClient, i as IndexerDerivativesStreamClient, l as IndexerPortfolioApiClient, n as IndexerPortfolioStreamClient, o as DEFAULT_RETRY_CONFIG, p as IndexerAccountsApiClient, r as IndexerOracleStreamClient, s as StreamManager, t as IndexerSpotStreamClient, u as IndexerOracleApiClient } from "./indexer-D_9xZbW-.js";
|
|
12
12
|
import { bytesToHex, getEip712TypedDataV2, getEthereumAddress, getInjectiveAddress, hexToBase64, hexToBytes } from "./utils.js";
|
|
13
13
|
export { ApiError, BroadcastMode, ChainAuthApiClient, ChainAuthZApiClient, ChainBankApiClient, ChainExchangeApiClient, ChainId, ChainTendermintApiClient, ChainTxApiClient, DEFAULT_RETRY_CONFIG, EvmChainId, ExecutionType, IndexerAccountsApiClient, IndexerAccountsStreamClient, IndexerArchiverApiClient, IndexerDerivativesApiClient, IndexerDerivativesStreamClient, IndexerOracleApiClient, IndexerOracleStreamClient, IndexerPortfolioApiClient, IndexerPortfolioStreamClient, IndexerSpotApiClient, IndexerSpotStreamClient, MarketStatus, MsgBatchCancelDerivativeOrders, MsgBatchCancelSpotOrders, MsgCancelDerivativeOrder, MsgCancelSpotOrder, MsgCreateDerivativeLimitOrder, MsgCreateDerivativeMarketOrder, MsgCreateSpotLimitOrder, MsgCreateSpotMarketOrder, MsgDeposit, MsgExternalTransfer, MsgIncreasePositionMargin, MsgSend, MsgSubaccountTransfer, MsgWithdraw, OrderMask, OrderSide, OrderType, SignMode, StreamDisconnectReason, StreamManager, StreamState, bytesToHex, createTransaction, createTxBytes, createTxRawEIP712, createWeb3Extension, getEip712TypedDataV2, getEthereumAddress, getInjectiveAddress, hexToBase64, hexToBytes, sanitizeBlock, sanitizeLatestBlock, toChainFormat, toCosmosSdkDecString, toPageRequest, toPagination };
|
|
@@ -2,7 +2,7 @@ import { credentials, makeGenericClientConstructor, status } from "@grpc/grpc-js
|
|
|
2
2
|
import { t as ApiManager } from "./ApiManager-VsZ_7GMj.js";
|
|
3
3
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
4
4
|
import { EventEmitter } from "eventemitter3";
|
|
5
|
-
import "./stream-
|
|
5
|
+
import "./stream-CbXgyx26.js";
|
|
6
6
|
import { n as getServiceAndMethodFromPath } from "./errors-MWG_E5zA.js";
|
|
7
7
|
// gen/exchange/injective_accounts_rpc.ts
|
|
8
8
|
function createBasePortfolioRequest() {
|
|
@@ -21450,7 +21450,7 @@ function ifRetryableError(code) {
|
|
|
21450
21450
|
var StreamManager = class extends EventEmitter {
|
|
21451
21451
|
streamFactory;
|
|
21452
21452
|
subscription = null;
|
|
21453
|
-
|
|
21453
|
+
currentState = 0;
|
|
21454
21454
|
retryConfig;
|
|
21455
21455
|
streamError = null;
|
|
21456
21456
|
retryAttempts = 0;
|
|
@@ -21466,15 +21466,20 @@ var StreamManager = class extends EventEmitter {
|
|
|
21466
21466
|
...retryConfig
|
|
21467
21467
|
};
|
|
21468
21468
|
}
|
|
21469
|
+
/** Where the stream is in its lifecycle; `Failed` is terminal. */
|
|
21470
|
+
get state() {
|
|
21471
|
+
return this.currentState;
|
|
21472
|
+
}
|
|
21469
21473
|
start() {
|
|
21470
21474
|
if (this.isDestroyed) throw new Error("Cannot start a destroyed stream");
|
|
21475
|
+
if (this.currentState == 6) throw new Error("Cannot start a stream that used up its retries; build a new stream from the client");
|
|
21471
21476
|
if (this.subscription) return;
|
|
21472
21477
|
this.subscription = this.streamFactory();
|
|
21473
21478
|
this.streamError = null;
|
|
21474
|
-
this.updateState(this.
|
|
21475
|
-
if (this.
|
|
21479
|
+
this.updateState(this.currentState == 0 || this.currentState == 4 ? 1 : 3);
|
|
21480
|
+
if (this.currentState == 3 || this.currentState == 1) this.scheduleConnectionStable();
|
|
21476
21481
|
this.subscription.on("data", (data) => {
|
|
21477
|
-
if (this.
|
|
21482
|
+
if (this.currentState == 3 || this.currentState == 1) this.markConnectionStable();
|
|
21478
21483
|
this.emit("data", data);
|
|
21479
21484
|
});
|
|
21480
21485
|
this.subscription.on("error", (error) => {
|
|
@@ -21484,7 +21489,7 @@ var StreamManager = class extends EventEmitter {
|
|
|
21484
21489
|
this.subscription.on("end", () => this.handleReconnection());
|
|
21485
21490
|
}
|
|
21486
21491
|
stop() {
|
|
21487
|
-
if (this.
|
|
21492
|
+
if (this.currentState == 0 || this.currentState == 5 || this.currentState == 6) return;
|
|
21488
21493
|
this.clearStableConnectionTimeout();
|
|
21489
21494
|
this.clearReconnectionTimeout();
|
|
21490
21495
|
this.clearSubscription();
|
|
@@ -21510,14 +21515,14 @@ var StreamManager = class extends EventEmitter {
|
|
|
21510
21515
|
});
|
|
21511
21516
|
}
|
|
21512
21517
|
get isDestroyed() {
|
|
21513
|
-
return this.
|
|
21518
|
+
return this.currentState == 5;
|
|
21514
21519
|
}
|
|
21515
21520
|
updateState(newState) {
|
|
21516
|
-
if (this.
|
|
21517
|
-
this.
|
|
21521
|
+
if (this.currentState === newState) return;
|
|
21522
|
+
this.currentState = newState;
|
|
21518
21523
|
}
|
|
21519
21524
|
handleReconnection() {
|
|
21520
|
-
if (this.
|
|
21525
|
+
if (this.currentState == 4 || this.currentState == 6) return;
|
|
21521
21526
|
this.clearStableConnectionTimeout();
|
|
21522
21527
|
this.clearReconnectionTimeout();
|
|
21523
21528
|
this.clearSubscription();
|
|
@@ -21530,10 +21535,10 @@ var StreamManager = class extends EventEmitter {
|
|
|
21530
21535
|
emittedError.methodName = path.methodName;
|
|
21531
21536
|
this.emit("error", emittedError);
|
|
21532
21537
|
}
|
|
21533
|
-
const reason = streamError ? "stream-error" : "stream-ended";
|
|
21534
21538
|
const retryAttemptsRemaining = this.retryAttempts < this.retryConfig.maxAttempts;
|
|
21535
21539
|
let willRetry = this.retryConfig.enabled && retryAttemptsRemaining;
|
|
21536
21540
|
if (willRetry && streamError) willRetry = ifRetryableError(streamError.code);
|
|
21541
|
+
const reason = !retryAttemptsRemaining ? "max-retries" : streamError ? "stream-error" : "stream-ended";
|
|
21537
21542
|
this.emit("disconnect", {
|
|
21538
21543
|
reason,
|
|
21539
21544
|
willRetry,
|
|
@@ -21549,7 +21554,7 @@ var StreamManager = class extends EventEmitter {
|
|
|
21549
21554
|
});
|
|
21550
21555
|
}
|
|
21551
21556
|
if (!willRetry) {
|
|
21552
|
-
this.updateState(4);
|
|
21557
|
+
this.updateState(retryAttemptsRemaining ? 4 : 6);
|
|
21553
21558
|
return;
|
|
21554
21559
|
}
|
|
21555
21560
|
this.updateState(3);
|
|
@@ -21574,6 +21579,7 @@ var StreamManager = class extends EventEmitter {
|
|
|
21574
21579
|
this.stableConnectionTimeout = null;
|
|
21575
21580
|
}
|
|
21576
21581
|
markConnectionStable() {
|
|
21582
|
+
if (this.currentState != 1 && this.currentState != 3) return;
|
|
21577
21583
|
this.updateState(2);
|
|
21578
21584
|
this.emit("connect", {
|
|
21579
21585
|
isReconnect: this.retryAttempts > 0,
|
|
@@ -2,7 +2,7 @@ let _grpc_grpc_js = require("@grpc/grpc-js");
|
|
|
2
2
|
const require_ApiManager = require("./ApiManager-BcwRSg4p.cjs");
|
|
3
3
|
let _bufbuild_protobuf_wire = require("@bufbuild/protobuf/wire");
|
|
4
4
|
let eventemitter3 = require("eventemitter3");
|
|
5
|
-
require("./stream-
|
|
5
|
+
require("./stream-B2Mi9XL8.cjs");
|
|
6
6
|
const require_errors = require("./errors-CKG7zTvs.cjs");
|
|
7
7
|
// gen/exchange/injective_accounts_rpc.ts
|
|
8
8
|
function createBasePortfolioRequest() {
|
|
@@ -21450,7 +21450,7 @@ function ifRetryableError(code) {
|
|
|
21450
21450
|
var StreamManager = class extends eventemitter3.EventEmitter {
|
|
21451
21451
|
streamFactory;
|
|
21452
21452
|
subscription = null;
|
|
21453
|
-
|
|
21453
|
+
currentState = 0;
|
|
21454
21454
|
retryConfig;
|
|
21455
21455
|
streamError = null;
|
|
21456
21456
|
retryAttempts = 0;
|
|
@@ -21466,15 +21466,20 @@ var StreamManager = class extends eventemitter3.EventEmitter {
|
|
|
21466
21466
|
...retryConfig
|
|
21467
21467
|
};
|
|
21468
21468
|
}
|
|
21469
|
+
/** Where the stream is in its lifecycle; `Failed` is terminal. */
|
|
21470
|
+
get state() {
|
|
21471
|
+
return this.currentState;
|
|
21472
|
+
}
|
|
21469
21473
|
start() {
|
|
21470
21474
|
if (this.isDestroyed) throw new Error("Cannot start a destroyed stream");
|
|
21475
|
+
if (this.currentState == 6) throw new Error("Cannot start a stream that used up its retries; build a new stream from the client");
|
|
21471
21476
|
if (this.subscription) return;
|
|
21472
21477
|
this.subscription = this.streamFactory();
|
|
21473
21478
|
this.streamError = null;
|
|
21474
|
-
this.updateState(this.
|
|
21475
|
-
if (this.
|
|
21479
|
+
this.updateState(this.currentState == 0 || this.currentState == 4 ? 1 : 3);
|
|
21480
|
+
if (this.currentState == 3 || this.currentState == 1) this.scheduleConnectionStable();
|
|
21476
21481
|
this.subscription.on("data", (data) => {
|
|
21477
|
-
if (this.
|
|
21482
|
+
if (this.currentState == 3 || this.currentState == 1) this.markConnectionStable();
|
|
21478
21483
|
this.emit("data", data);
|
|
21479
21484
|
});
|
|
21480
21485
|
this.subscription.on("error", (error) => {
|
|
@@ -21484,7 +21489,7 @@ var StreamManager = class extends eventemitter3.EventEmitter {
|
|
|
21484
21489
|
this.subscription.on("end", () => this.handleReconnection());
|
|
21485
21490
|
}
|
|
21486
21491
|
stop() {
|
|
21487
|
-
if (this.
|
|
21492
|
+
if (this.currentState == 0 || this.currentState == 5 || this.currentState == 6) return;
|
|
21488
21493
|
this.clearStableConnectionTimeout();
|
|
21489
21494
|
this.clearReconnectionTimeout();
|
|
21490
21495
|
this.clearSubscription();
|
|
@@ -21510,14 +21515,14 @@ var StreamManager = class extends eventemitter3.EventEmitter {
|
|
|
21510
21515
|
});
|
|
21511
21516
|
}
|
|
21512
21517
|
get isDestroyed() {
|
|
21513
|
-
return this.
|
|
21518
|
+
return this.currentState == 5;
|
|
21514
21519
|
}
|
|
21515
21520
|
updateState(newState) {
|
|
21516
|
-
if (this.
|
|
21517
|
-
this.
|
|
21521
|
+
if (this.currentState === newState) return;
|
|
21522
|
+
this.currentState = newState;
|
|
21518
21523
|
}
|
|
21519
21524
|
handleReconnection() {
|
|
21520
|
-
if (this.
|
|
21525
|
+
if (this.currentState == 4 || this.currentState == 6) return;
|
|
21521
21526
|
this.clearStableConnectionTimeout();
|
|
21522
21527
|
this.clearReconnectionTimeout();
|
|
21523
21528
|
this.clearSubscription();
|
|
@@ -21530,10 +21535,10 @@ var StreamManager = class extends eventemitter3.EventEmitter {
|
|
|
21530
21535
|
emittedError.methodName = path.methodName;
|
|
21531
21536
|
this.emit("error", emittedError);
|
|
21532
21537
|
}
|
|
21533
|
-
const reason = streamError ? "stream-error" : "stream-ended";
|
|
21534
21538
|
const retryAttemptsRemaining = this.retryAttempts < this.retryConfig.maxAttempts;
|
|
21535
21539
|
let willRetry = this.retryConfig.enabled && retryAttemptsRemaining;
|
|
21536
21540
|
if (willRetry && streamError) willRetry = ifRetryableError(streamError.code);
|
|
21541
|
+
const reason = !retryAttemptsRemaining ? "max-retries" : streamError ? "stream-error" : "stream-ended";
|
|
21537
21542
|
this.emit("disconnect", {
|
|
21538
21543
|
reason,
|
|
21539
21544
|
willRetry,
|
|
@@ -21549,7 +21554,7 @@ var StreamManager = class extends eventemitter3.EventEmitter {
|
|
|
21549
21554
|
});
|
|
21550
21555
|
}
|
|
21551
21556
|
if (!willRetry) {
|
|
21552
|
-
this.updateState(4);
|
|
21557
|
+
this.updateState(retryAttemptsRemaining ? 4 : 6);
|
|
21553
21558
|
return;
|
|
21554
21559
|
}
|
|
21555
21560
|
this.updateState(3);
|
|
@@ -21574,6 +21579,7 @@ var StreamManager = class extends eventemitter3.EventEmitter {
|
|
|
21574
21579
|
this.stableConnectionTimeout = null;
|
|
21575
21580
|
}
|
|
21576
21581
|
markConnectionStable() {
|
|
21582
|
+
if (this.currentState != 1 && this.currentState != 3) return;
|
|
21577
21583
|
this.updateState(2);
|
|
21578
21584
|
this.emit("connect", {
|
|
21579
21585
|
isReconnect: this.retryAttempts > 0,
|
|
@@ -6,6 +6,8 @@ let StreamState = /* @__PURE__ */ function(StreamState) {
|
|
|
6
6
|
StreamState[StreamState["Reconnecting"] = 3] = "Reconnecting";
|
|
7
7
|
StreamState[StreamState["Stopped"] = 4] = "Stopped";
|
|
8
8
|
StreamState[StreamState["Destroyed"] = 5] = "Destroyed";
|
|
9
|
+
/** Retries ran out: this stream is finished and cannot be started again. */
|
|
10
|
+
StreamState[StreamState["Failed"] = 6] = "Failed";
|
|
9
11
|
return StreamState;
|
|
10
12
|
}({});
|
|
11
13
|
let StreamDisconnectReason = /* @__PURE__ */ function(StreamDisconnectReason) {
|
|
@@ -6,6 +6,8 @@ let StreamState = /* @__PURE__ */ function(StreamState) {
|
|
|
6
6
|
StreamState[StreamState["Reconnecting"] = 3] = "Reconnecting";
|
|
7
7
|
StreamState[StreamState["Stopped"] = 4] = "Stopped";
|
|
8
8
|
StreamState[StreamState["Destroyed"] = 5] = "Destroyed";
|
|
9
|
+
/** Retries ran out: this stream is finished and cannot be started again. */
|
|
10
|
+
StreamState[StreamState["Failed"] = 6] = "Failed";
|
|
9
11
|
return StreamState;
|
|
10
12
|
}({});
|
|
11
13
|
let StreamDisconnectReason = /* @__PURE__ */ function(StreamDisconnectReason) {
|
|
@@ -5,7 +5,9 @@ declare enum StreamState {
|
|
|
5
5
|
Connected = 2,
|
|
6
6
|
Reconnecting = 3,
|
|
7
7
|
Stopped = 4,
|
|
8
|
-
Destroyed = 5
|
|
8
|
+
Destroyed = 5,
|
|
9
|
+
/** Retries ran out: this stream is finished and cannot be started again. */
|
|
10
|
+
Failed = 6
|
|
9
11
|
}
|
|
10
12
|
interface StreamManagerRetryConfig {
|
|
11
13
|
enabled: boolean;
|
|
@@ -5,7 +5,9 @@ declare enum StreamState {
|
|
|
5
5
|
Connected = 2,
|
|
6
6
|
Reconnecting = 3,
|
|
7
7
|
Stopped = 4,
|
|
8
|
-
Destroyed = 5
|
|
8
|
+
Destroyed = 5,
|
|
9
|
+
/** Retries ran out: this stream is finished and cannot be started again. */
|
|
10
|
+
Failed = 6
|
|
9
11
|
}
|
|
10
12
|
interface StreamManagerRetryConfig {
|
|
11
13
|
enabled: boolean;
|
package/dist/types.cjs
CHANGED
|
@@ -3,7 +3,7 @@ const require_query = require("./query-L1m6tP9I.cjs");
|
|
|
3
3
|
const require_tx = require("./tx-DIg8nbnn.cjs");
|
|
4
4
|
const require_exchange = require("./exchange-CTLbPuA7.cjs");
|
|
5
5
|
const require_errors = require("./errors-CKG7zTvs.cjs");
|
|
6
|
-
const require_stream = require("./stream-
|
|
6
|
+
const require_stream = require("./stream-B2Mi9XL8.cjs");
|
|
7
7
|
// types/chain/enums.ts
|
|
8
8
|
const ChainId = {
|
|
9
9
|
Mainnet: "injective-1",
|
package/dist/types.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { D as OrderType, E as OrderMask, I as SignDoc, L as SignMode, O as Marke
|
|
|
2
2
|
import { n as Eip712TypedDataField, t as Eip712TypedData } from "./eip712-88KVCEnw.cjs";
|
|
3
3
|
import { a as TxRaw, c as PaginationOption, i as StdFee, n as CreateTransactionResult, o as Msg, r as SignerDetails, s as Pagination, t as CreateTransactionParams } from "./tx-CCt0zqng.cjs";
|
|
4
4
|
import { ServiceError } from "@grpc/grpc-js";
|
|
5
|
-
import { i as StreamState, n as StreamDisconnectReason, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-
|
|
5
|
+
import { i as StreamState, n as StreamDisconnectReason, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-ChRmJm8w.cjs";
|
|
6
6
|
export declare class ApiError extends Error {
|
|
7
7
|
private code;
|
|
8
8
|
private details;
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { B as OrderMask, H as MarketStatus, M as OrderSide, T as SignMode, V as
|
|
|
2
2
|
import { n as Eip712TypedDataField, t as Eip712TypedData } from "./eip712-88KVCEnw.js";
|
|
3
3
|
import { a as TxRaw, c as PaginationOption, i as StdFee, n as CreateTransactionResult, o as Msg, r as SignerDetails, s as Pagination, t as CreateTransactionParams } from "./tx-BRaw1C6e.js";
|
|
4
4
|
import { ServiceError } from "@grpc/grpc-js";
|
|
5
|
-
import { i as StreamState, n as StreamDisconnectReason, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-
|
|
5
|
+
import { i as StreamState, n as StreamDisconnectReason, r as StreamManagerRetryConfig, t as EventTypes } from "./stream-ChRmJm8w.js";
|
|
6
6
|
export declare class ApiError extends Error {
|
|
7
7
|
private code;
|
|
8
8
|
private details;
|
package/dist/types.js
CHANGED
|
@@ -2,7 +2,7 @@ import { t as OrderSide, u as BroadcastMode } from "./query-DGTA8Lz_.js";
|
|
|
2
2
|
import { u as SignMode } from "./tx-GN0SFql2.js";
|
|
3
3
|
import { N as OrderMask, P as OrderType, U as MarketStatus, d as ExecutionType } from "./exchange-BPRx-kFI.js";
|
|
4
4
|
import { t as ApiError } from "./errors-MWG_E5zA.js";
|
|
5
|
-
import { n as StreamState, t as StreamDisconnectReason } from "./stream-
|
|
5
|
+
import { n as StreamState, t as StreamDisconnectReason } from "./stream-CbXgyx26.js";
|
|
6
6
|
// types/chain/enums.ts
|
|
7
7
|
const ChainId = {
|
|
8
8
|
Mainnet: "injective-1",
|
package/package.json
CHANGED