@mysten/sui 2.10.0 → 2.11.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/cryptography/signature.d.mts +6 -6
  4. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  5. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  6. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  7. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  8. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  9. package/dist/jsonRpc/http-transport.d.mts +1 -17
  10. package/dist/jsonRpc/http-transport.d.mts.map +1 -1
  11. package/dist/jsonRpc/http-transport.mjs +0 -23
  12. package/dist/jsonRpc/http-transport.mjs.map +1 -1
  13. package/dist/jsonRpc/index.d.mts +3 -3
  14. package/dist/jsonRpc/types/common.d.mts +1 -2
  15. package/dist/jsonRpc/types/common.d.mts.map +1 -1
  16. package/dist/jsonRpc/types/index.d.mts +1 -1
  17. package/dist/transactions/Transaction.d.mts +6 -6
  18. package/dist/transactions/Transaction.d.mts.map +1 -1
  19. package/dist/version.mjs +1 -1
  20. package/dist/version.mjs.map +1 -1
  21. package/dist/zklogin/bcs.d.mts +14 -14
  22. package/package.json +4 -6
  23. package/src/jsonRpc/http-transport.ts +0 -52
  24. package/src/jsonRpc/index.ts +0 -1
  25. package/src/jsonRpc/types/common.ts +0 -1
  26. package/src/version.ts +1 -1
  27. package/dist/jsonRpc/rpc-websocket-client.d.mts +0 -26
  28. package/dist/jsonRpc/rpc-websocket-client.d.mts.map +0 -1
  29. package/dist/jsonRpc/rpc-websocket-client.mjs +0 -135
  30. package/dist/jsonRpc/rpc-websocket-client.mjs.map +0 -1
  31. package/src/jsonRpc/rpc-websocket-client.ts +0 -241
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mysten/sui.js
2
2
 
3
+ ## 2.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 319aae1: Remove WebSocket client and streaming subscription APIs from the JSON-RPC transport. The
8
+ `subscribe` method, `WebSocketConstructor` option, `websocket` option,
9
+ `JsonRpcTransportSubscribeOptions` type, and `Unsubscribe` type have been removed from the public
10
+ API.
11
+
3
12
  ## 2.10.0
4
13
 
5
14
  ### Minor Changes
@@ -1,22 +1,22 @@
1
1
  import { TypeTag as TypeTag$1 } from "./types.mjs";
2
- import * as _mysten_bcs823 from "@mysten/bcs";
2
+ import * as _mysten_bcs830 from "@mysten/bcs";
3
3
  import { BcsType } from "@mysten/bcs";
4
4
 
5
5
  //#region src/bcs/bcs.d.ts
6
6
 
7
7
  declare const TypeTag: BcsType<string, string | TypeTag$1, string>;
8
- declare function IntentMessage<T extends BcsType<any>>(T: T): _mysten_bcs823.BcsStruct<{
9
- intent: _mysten_bcs823.BcsStruct<{
10
- scope: _mysten_bcs823.BcsEnum<{
8
+ declare function IntentMessage<T extends BcsType<any>>(T: T): _mysten_bcs830.BcsStruct<{
9
+ intent: _mysten_bcs830.BcsStruct<{
10
+ scope: _mysten_bcs830.BcsEnum<{
11
11
  TransactionData: null;
12
12
  TransactionEffects: null;
13
13
  CheckpointSummary: null;
14
14
  PersonalMessage: null;
15
15
  }, "IntentScope">;
16
- version: _mysten_bcs823.BcsEnum<{
16
+ version: _mysten_bcs830.BcsEnum<{
17
17
  V0: null;
18
18
  }, "IntentVersion">;
19
- appId: _mysten_bcs823.BcsEnum<{
19
+ appId: _mysten_bcs830.BcsEnum<{
20
20
  Sui: null;
21
21
  }, "AppId">;
22
22
  }, string>;
@@ -26,6 +26,12 @@ declare function toSerializedSignature({
26
26
  * Decodes a serialized signature into its constituent components: the signature scheme, the actual signature, and the public key
27
27
  */
28
28
  declare function parseSerializedSignature(serializedSignature: string): {
29
+ serializedSignature: string;
30
+ signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
31
+ signature: Uint8Array<ArrayBuffer>;
32
+ publicKey: Uint8Array<ArrayBuffer>;
33
+ bytes: Uint8Array<ArrayBuffer>;
34
+ } | {
29
35
  signatureScheme: "Passkey";
30
36
  serializedSignature: string;
31
37
  signature: Uint8Array<ArrayBufferLike>;
@@ -33,12 +39,6 @@ declare function parseSerializedSignature(serializedSignature: string): {
33
39
  clientDataJson: string;
34
40
  userSignature: Uint8Array<ArrayBuffer>;
35
41
  publicKey: Uint8Array<ArrayBuffer>;
36
- } | {
37
- serializedSignature: string;
38
- signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
39
- signature: Uint8Array<ArrayBuffer>;
40
- publicKey: Uint8Array<ArrayBuffer>;
41
- bytes: Uint8Array<ArrayBuffer>;
42
42
  } | {
43
43
  serializedSignature: string;
44
44
  signatureScheme: "ZkLogin";
@@ -1,6 +1,6 @@
1
1
  import { BatchGetObjectsRequest, BatchGetObjectsResponse, BatchGetTransactionsRequest, BatchGetTransactionsResponse, GetCheckpointRequest, GetCheckpointResponse, GetEpochRequest, GetEpochResponse, GetObjectRequest, GetObjectResponse, GetServiceInfoRequest, GetServiceInfoResponse, GetTransactionRequest, GetTransactionResponse } from "./ledger_service.mjs";
2
- import * as _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts
@@ -46,9 +46,9 @@ interface ILedgerServiceClient {
46
46
  declare class LedgerServiceClient implements ILedgerServiceClient, ServiceInfo {
47
47
  private readonly _transport;
48
48
  typeName: string;
49
- methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
49
+ methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
50
50
  options: {
51
- [extensionName: string]: _protobuf_ts_runtime5.JsonValue;
51
+ [extensionName: string]: _protobuf_ts_runtime1.JsonValue;
52
52
  };
53
53
  constructor(_transport: RpcTransport);
54
54
  /**
@@ -1,6 +1,6 @@
1
1
  import { VerifySignatureRequest, VerifySignatureResponse } from "./signature_verification_service.mjs";
2
- import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts
@@ -22,9 +22,9 @@ interface ISignatureVerificationServiceClient {
22
22
  declare class SignatureVerificationServiceClient implements ISignatureVerificationServiceClient, ServiceInfo {
23
23
  private readonly _transport;
24
24
  typeName: string;
25
- methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
25
+ methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
26
26
  options: {
27
- [extensionName: string]: _protobuf_ts_runtime0.JsonValue;
27
+ [extensionName: string]: _protobuf_ts_runtime5.JsonValue;
28
28
  };
29
29
  constructor(_transport: RpcTransport);
30
30
  /**
@@ -1,6 +1,6 @@
1
1
  import { GetBalanceRequest, GetBalanceResponse, GetCoinInfoRequest, GetCoinInfoResponse, ListBalancesRequest, ListBalancesResponse, ListDynamicFieldsRequest, ListDynamicFieldsResponse, ListOwnedObjectsRequest, ListOwnedObjectsResponse } from "./state_service.mjs";
2
- import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime3 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc3 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/state_service.client.d.ts
@@ -36,9 +36,9 @@ interface IStateServiceClient {
36
36
  declare class StateServiceClient implements IStateServiceClient, ServiceInfo {
37
37
  private readonly _transport;
38
38
  typeName: string;
39
- methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
39
+ methods: _protobuf_ts_runtime_rpc3.MethodInfo<any, any>[];
40
40
  options: {
41
- [extensionName: string]: _protobuf_ts_runtime1.JsonValue;
41
+ [extensionName: string]: _protobuf_ts_runtime3.JsonValue;
42
42
  };
43
43
  constructor(_transport: RpcTransport);
44
44
  /**
@@ -1,6 +1,6 @@
1
1
  import { SubscribeCheckpointsRequest, SubscribeCheckpointsResponse } from "./subscription_service.mjs";
2
- import * as _protobuf_ts_runtime3 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc3 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServerStreamingCall, ServiceInfo } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts
@@ -32,9 +32,9 @@ interface ISubscriptionServiceClient {
32
32
  declare class SubscriptionServiceClient implements ISubscriptionServiceClient, ServiceInfo {
33
33
  private readonly _transport;
34
34
  typeName: string;
35
- methods: _protobuf_ts_runtime_rpc3.MethodInfo<any, any>[];
35
+ methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
36
36
  options: {
37
- [extensionName: string]: _protobuf_ts_runtime3.JsonValue;
37
+ [extensionName: string]: _protobuf_ts_runtime4.JsonValue;
38
38
  };
39
39
  constructor(_transport: RpcTransport);
40
40
  /**
@@ -1,6 +1,6 @@
1
1
  import { ExecuteTransactionRequest, ExecuteTransactionResponse, SimulateTransactionRequest, SimulateTransactionResponse } from "./transaction_execution_service.mjs";
2
- import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts
@@ -24,9 +24,9 @@ interface ITransactionExecutionServiceClient {
24
24
  declare class TransactionExecutionServiceClient implements ITransactionExecutionServiceClient, ServiceInfo {
25
25
  private readonly _transport;
26
26
  typeName: string;
27
- methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
27
+ methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
28
28
  options: {
29
- [extensionName: string]: _protobuf_ts_runtime4.JsonValue;
29
+ [extensionName: string]: _protobuf_ts_runtime0.JsonValue;
30
30
  };
31
31
  constructor(_transport: RpcTransport);
32
32
  /**
@@ -1,7 +1,4 @@
1
- import { WebsocketClientOptions } from "./rpc-websocket-client.mjs";
2
-
3
1
  //#region src/jsonRpc/http-transport.d.ts
4
-
5
2
  /**
6
3
  * An object defining headers to be passed to the RPC server
7
4
  */
@@ -10,39 +7,26 @@ type HttpHeaders = {
10
7
  };
11
8
  interface JsonRpcHTTPTransportOptions {
12
9
  fetch?: typeof fetch;
13
- WebSocketConstructor?: typeof WebSocket;
14
10
  url: string;
15
11
  rpc?: {
16
12
  headers?: HttpHeaders;
17
13
  url?: string;
18
14
  };
19
- websocket?: WebsocketClientOptions & {
20
- url?: string;
21
- };
22
15
  }
23
16
  interface JsonRpcTransportRequestOptions {
24
17
  method: string;
25
18
  params: unknown[];
26
19
  signal?: AbortSignal;
27
20
  }
28
- interface JsonRpcTransportSubscribeOptions<T> {
29
- method: string;
30
- unsubscribe: string;
31
- params: unknown[];
32
- onMessage: (event: T) => void;
33
- signal?: AbortSignal;
34
- }
35
21
  interface JsonRpcTransport {
36
22
  request<T = unknown>(input: JsonRpcTransportRequestOptions): Promise<T>;
37
- subscribe<T = unknown>(input: JsonRpcTransportSubscribeOptions<T>): Promise<() => Promise<boolean>>;
38
23
  }
39
24
  declare class JsonRpcHTTPTransport implements JsonRpcTransport {
40
25
  #private;
41
26
  constructor(options: JsonRpcHTTPTransportOptions);
42
27
  fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
43
28
  request<T>(input: JsonRpcTransportRequestOptions): Promise<T>;
44
- subscribe<T>(input: JsonRpcTransportSubscribeOptions<T>): Promise<() => Promise<boolean>>;
45
29
  }
46
30
  //#endregion
47
- export { HttpHeaders, JsonRpcHTTPTransport, JsonRpcHTTPTransportOptions, JsonRpcTransport, JsonRpcTransportRequestOptions, JsonRpcTransportSubscribeOptions };
31
+ export { HttpHeaders, JsonRpcHTTPTransport, JsonRpcHTTPTransportOptions, JsonRpcTransport, JsonRpcTransportRequestOptions };
48
32
  //# sourceMappingURL=http-transport.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http-transport.d.mts","names":[],"sources":["../../src/jsonRpc/http-transport.ts"],"sourcesContent":[],"mappings":";;;;;;AAWA;AAEiB,KAFL,WAAA,GAEK;EACD,CAAA,MAAA,EAAA,MAAA,CAAA,EAAA,MAAA;CACe;AAGnB,UALK,2BAAA,CAKL;EAGC,KAAA,CAAA,EAAA,OAPG,KAOH;EAAsB,oBAAA,CAAA,EAAA,OANJ,SAMI;EAKlB,GAAA,EAAA,MAAA;EAMA,GAAA,CAAA,EAAA;IAQA,OAAA,CAAA,EAtBL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CAAA,EAnBV,WAmBU;IAIR,GAAA,CAAA,EAAA,MAAA;EAAoB,CAAA;;AAAc,UAlB/B,8BAAA,CAkB+B;EAYvB,MAAA,EAAA,MAAA;EAAyC,MAAA,EAAA,OAAA,EAAA;EAAR,MAAA,CAAA,EA3BhD,WA2BgD;;AApBG,UAJ5C,gBAAA,CAI4C;8BAHhC,iCAAiC,QAAQ;;cAGzD,oBAAA,YAAgC;;uBAIvB;eAIR,oBAAoB,cAAc,QAAQ;oBAY/B,iCAAiC,QAAQ"}
@@ -1,12 +1,10 @@
1
1
  import { PACKAGE_VERSION, TARGETED_RPC_VERSION } from "../version.mjs";
2
2
  import { JsonRpcError, SuiHTTPStatusError } from "./errors.mjs";
3
- import { WebsocketClient } from "./rpc-websocket-client.mjs";
4
3
 
5
4
  //#region src/jsonRpc/http-transport.ts
6
5
  var JsonRpcHTTPTransport = class {
7
6
  #requestId = 0;
8
7
  #options;
9
- #websocketClient;
10
8
  constructor(options) {
11
9
  this.#options = options;
12
10
  }
@@ -15,17 +13,6 @@ var JsonRpcHTTPTransport = class {
15
13
  if (!fetchFn) throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");
16
14
  return fetchFn(input, init);
17
15
  }
18
- #getWebsocketClient() {
19
- if (!this.#websocketClient) {
20
- const WebSocketConstructor = this.#options.WebSocketConstructor ?? WebSocket;
21
- if (!WebSocketConstructor) throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");
22
- this.#websocketClient = new WebsocketClient(this.#options.websocket?.url ?? this.#options.url, {
23
- WebSocketConstructor,
24
- ...this.#options.websocket
25
- });
26
- }
27
- return this.#websocketClient;
28
- }
29
16
  async request(input) {
30
17
  this.#requestId += 1;
31
18
  const res = await this.fetch(this.#options.rpc?.url ?? this.#options.url, {
@@ -51,16 +38,6 @@ var JsonRpcHTTPTransport = class {
51
38
  if ("error" in data && data.error != null) throw new JsonRpcError(data.error.message, data.error.code);
52
39
  return data.result;
53
40
  }
54
- async subscribe(input) {
55
- const unsubscribe = await this.#getWebsocketClient().subscribe(input);
56
- if (input.signal) {
57
- input.signal.throwIfAborted();
58
- input.signal.addEventListener("abort", () => {
59
- unsubscribe();
60
- });
61
- }
62
- return async () => !!await unsubscribe();
63
- }
64
41
  };
65
42
 
66
43
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"http-transport.mjs","names":["#options","#websocketClient","#requestId","#getWebsocketClient"],"sources":["../../src/jsonRpc/http-transport.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PACKAGE_VERSION, TARGETED_RPC_VERSION } from '../version.js';\nimport { JsonRpcError, SuiHTTPStatusError } from './errors.js';\nimport type { WebsocketClientOptions } from './rpc-websocket-client.js';\nimport { WebsocketClient } from './rpc-websocket-client.js';\n\n/**\n * An object defining headers to be passed to the RPC server\n */\nexport type HttpHeaders = { [header: string]: string };\n\nexport interface JsonRpcHTTPTransportOptions {\n\tfetch?: typeof fetch;\n\tWebSocketConstructor?: typeof WebSocket;\n\turl: string;\n\trpc?: {\n\t\theaders?: HttpHeaders;\n\t\turl?: string;\n\t};\n\twebsocket?: WebsocketClientOptions & {\n\t\turl?: string;\n\t};\n}\n\nexport interface JsonRpcTransportRequestOptions {\n\tmethod: string;\n\tparams: unknown[];\n\tsignal?: AbortSignal;\n}\n\nexport interface JsonRpcTransportSubscribeOptions<T> {\n\tmethod: string;\n\tunsubscribe: string;\n\tparams: unknown[];\n\tonMessage: (event: T) => void;\n\tsignal?: AbortSignal;\n}\n\nexport interface JsonRpcTransport {\n\trequest<T = unknown>(input: JsonRpcTransportRequestOptions): Promise<T>;\n\tsubscribe<T = unknown>(\n\t\tinput: JsonRpcTransportSubscribeOptions<T>,\n\t): Promise<() => Promise<boolean>>;\n}\n\nexport class JsonRpcHTTPTransport implements JsonRpcTransport {\n\t#requestId = 0;\n\t#options: JsonRpcHTTPTransportOptions;\n\t#websocketClient?: WebsocketClient;\n\n\tconstructor(options: JsonRpcHTTPTransportOptions) {\n\t\tthis.#options = options;\n\t}\n\n\tfetch(input: RequestInfo, init?: RequestInit): Promise<Response> {\n\t\tconst fetchFn = this.#options.fetch ?? fetch;\n\n\t\tif (!fetchFn) {\n\t\t\tthrow new Error(\n\t\t\t\t'The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.',\n\t\t\t);\n\t\t}\n\n\t\treturn fetchFn(input, init);\n\t}\n\n\t#getWebsocketClient(): WebsocketClient {\n\t\tif (!this.#websocketClient) {\n\t\t\tconst WebSocketConstructor = this.#options.WebSocketConstructor ?? WebSocket;\n\t\t\tif (!WebSocketConstructor) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.#websocketClient = new WebsocketClient(\n\t\t\t\tthis.#options.websocket?.url ?? this.#options.url,\n\t\t\t\t{\n\t\t\t\t\tWebSocketConstructor,\n\t\t\t\t\t...this.#options.websocket,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn this.#websocketClient;\n\t}\n\n\tasync request<T>(input: JsonRpcTransportRequestOptions): Promise<T> {\n\t\tthis.#requestId += 1;\n\n\t\tconst res = await this.fetch(this.#options.rpc?.url ?? this.#options.url, {\n\t\t\tmethod: 'POST',\n\t\t\tsignal: input.signal,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Client-Sdk-Type': 'typescript',\n\t\t\t\t'Client-Sdk-Version': PACKAGE_VERSION,\n\t\t\t\t'Client-Target-Api-Version': TARGETED_RPC_VERSION,\n\t\t\t\t'Client-Request-Method': input.method,\n\t\t\t\t...this.#options.rpc?.headers,\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tjsonrpc: '2.0',\n\t\t\t\tid: this.#requestId,\n\t\t\t\tmethod: input.method,\n\t\t\t\tparams: input.params,\n\t\t\t}),\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new SuiHTTPStatusError(\n\t\t\t\t`Unexpected status code: ${res.status}`,\n\t\t\t\tres.status,\n\t\t\t\tres.statusText,\n\t\t\t);\n\t\t}\n\n\t\tconst data = await res.json();\n\n\t\tif ('error' in data && data.error != null) {\n\t\t\tthrow new JsonRpcError(data.error.message, data.error.code);\n\t\t}\n\n\t\treturn data.result;\n\t}\n\n\tasync subscribe<T>(input: JsonRpcTransportSubscribeOptions<T>): Promise<() => Promise<boolean>> {\n\t\tconst unsubscribe = await this.#getWebsocketClient().subscribe(input);\n\n\t\tif (input.signal) {\n\t\t\tinput.signal.throwIfAborted();\n\t\t\tinput.signal.addEventListener('abort', () => {\n\t\t\t\tunsubscribe();\n\t\t\t});\n\t\t}\n\n\t\treturn async () => !!(await unsubscribe());\n\t}\n}\n"],"mappings":";;;;;AA+CA,IAAa,uBAAb,MAA8D;CAC7D,aAAa;CACb;CACA;CAEA,YAAY,SAAsC;AACjD,QAAKA,UAAW;;CAGjB,MAAM,OAAoB,MAAuC;EAChE,MAAM,UAAU,MAAKA,QAAS,SAAS;AAEvC,MAAI,CAAC,QACJ,OAAM,IAAI,MACT,8HACA;AAGF,SAAO,QAAQ,OAAO,KAAK;;CAG5B,sBAAuC;AACtC,MAAI,CAAC,MAAKC,iBAAkB;GAC3B,MAAM,uBAAuB,MAAKD,QAAS,wBAAwB;AACnE,OAAI,CAAC,qBACJ,OAAM,IAAI,MACT,kIACA;AAGF,SAAKC,kBAAmB,IAAI,gBAC3B,MAAKD,QAAS,WAAW,OAAO,MAAKA,QAAS,KAC9C;IACC;IACA,GAAG,MAAKA,QAAS;IACjB,CACD;;AAGF,SAAO,MAAKC;;CAGb,MAAM,QAAW,OAAmD;AACnE,QAAKC,aAAc;EAEnB,MAAM,MAAM,MAAM,KAAK,MAAM,MAAKF,QAAS,KAAK,OAAO,MAAKA,QAAS,KAAK;GACzE,QAAQ;GACR,QAAQ,MAAM;GACd,SAAS;IACR,gBAAgB;IAChB,mBAAmB;IACnB,sBAAsB;IACtB,6BAA6B;IAC7B,yBAAyB,MAAM;IAC/B,GAAG,MAAKA,QAAS,KAAK;IACtB;GACD,MAAM,KAAK,UAAU;IACpB,SAAS;IACT,IAAI,MAAKE;IACT,QAAQ,MAAM;IACd,QAAQ,MAAM;IACd,CAAC;GACF,CAAC;AAEF,MAAI,CAAC,IAAI,GACR,OAAM,IAAI,mBACT,2BAA2B,IAAI,UAC/B,IAAI,QACJ,IAAI,WACJ;EAGF,MAAM,OAAO,MAAM,IAAI,MAAM;AAE7B,MAAI,WAAW,QAAQ,KAAK,SAAS,KACpC,OAAM,IAAI,aAAa,KAAK,MAAM,SAAS,KAAK,MAAM,KAAK;AAG5D,SAAO,KAAK;;CAGb,MAAM,UAAa,OAA6E;EAC/F,MAAM,cAAc,MAAM,MAAKC,oBAAqB,CAAC,UAAU,MAAM;AAErE,MAAI,MAAM,QAAQ;AACjB,SAAM,OAAO,gBAAgB;AAC7B,SAAM,OAAO,iBAAiB,eAAe;AAC5C,iBAAa;KACZ;;AAGH,SAAO,YAAY,CAAC,CAAE,MAAM,aAAa"}
1
+ {"version":3,"file":"http-transport.mjs","names":["#options","#requestId"],"sources":["../../src/jsonRpc/http-transport.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PACKAGE_VERSION, TARGETED_RPC_VERSION } from '../version.js';\nimport { JsonRpcError, SuiHTTPStatusError } from './errors.js';\n\n/**\n * An object defining headers to be passed to the RPC server\n */\nexport type HttpHeaders = { [header: string]: string };\n\nexport interface JsonRpcHTTPTransportOptions {\n\tfetch?: typeof fetch;\n\turl: string;\n\trpc?: {\n\t\theaders?: HttpHeaders;\n\t\turl?: string;\n\t};\n}\n\nexport interface JsonRpcTransportRequestOptions {\n\tmethod: string;\n\tparams: unknown[];\n\tsignal?: AbortSignal;\n}\n\nexport interface JsonRpcTransport {\n\trequest<T = unknown>(input: JsonRpcTransportRequestOptions): Promise<T>;\n}\n\nexport class JsonRpcHTTPTransport implements JsonRpcTransport {\n\t#requestId = 0;\n\t#options: JsonRpcHTTPTransportOptions;\n\n\tconstructor(options: JsonRpcHTTPTransportOptions) {\n\t\tthis.#options = options;\n\t}\n\n\tfetch(input: RequestInfo, init?: RequestInit): Promise<Response> {\n\t\tconst fetchFn = this.#options.fetch ?? fetch;\n\n\t\tif (!fetchFn) {\n\t\t\tthrow new Error(\n\t\t\t\t'The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.',\n\t\t\t);\n\t\t}\n\n\t\treturn fetchFn(input, init);\n\t}\n\n\tasync request<T>(input: JsonRpcTransportRequestOptions): Promise<T> {\n\t\tthis.#requestId += 1;\n\n\t\tconst res = await this.fetch(this.#options.rpc?.url ?? this.#options.url, {\n\t\t\tmethod: 'POST',\n\t\t\tsignal: input.signal,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Client-Sdk-Type': 'typescript',\n\t\t\t\t'Client-Sdk-Version': PACKAGE_VERSION,\n\t\t\t\t'Client-Target-Api-Version': TARGETED_RPC_VERSION,\n\t\t\t\t'Client-Request-Method': input.method,\n\t\t\t\t...this.#options.rpc?.headers,\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tjsonrpc: '2.0',\n\t\t\t\tid: this.#requestId,\n\t\t\t\tmethod: input.method,\n\t\t\t\tparams: input.params,\n\t\t\t}),\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new SuiHTTPStatusError(\n\t\t\t\t`Unexpected status code: ${res.status}`,\n\t\t\t\tres.status,\n\t\t\t\tres.statusText,\n\t\t\t);\n\t\t}\n\n\t\tconst data = await res.json();\n\n\t\tif ('error' in data && data.error != null) {\n\t\t\tthrow new JsonRpcError(data.error.message, data.error.code);\n\t\t}\n\n\t\treturn data.result;\n\t}\n}\n"],"mappings":";;;;AA8BA,IAAa,uBAAb,MAA8D;CAC7D,aAAa;CACb;CAEA,YAAY,SAAsC;AACjD,QAAKA,UAAW;;CAGjB,MAAM,OAAoB,MAAuC;EAChE,MAAM,UAAU,MAAKA,QAAS,SAAS;AAEvC,MAAI,CAAC,QACJ,OAAM,IAAI,MACT,8HACA;AAGF,SAAO,QAAQ,OAAO,KAAK;;CAG5B,MAAM,QAAW,OAAmD;AACnE,QAAKC,aAAc;EAEnB,MAAM,MAAM,MAAM,KAAK,MAAM,MAAKD,QAAS,KAAK,OAAO,MAAKA,QAAS,KAAK;GACzE,QAAQ;GACR,QAAQ,MAAM;GACd,SAAS;IACR,gBAAgB;IAChB,mBAAmB;IACnB,sBAAsB;IACtB,6BAA6B;IAC7B,yBAAyB,MAAM;IAC/B,GAAG,MAAKA,QAAS,KAAK;IACtB;GACD,MAAM,KAAK,UAAU;IACpB,SAAS;IACT,IAAI,MAAKC;IACT,QAAQ,MAAM;IACd,QAAQ,MAAM;IACd,CAAC;GACF,CAAC;AAEF,MAAI,CAAC,IAAI,GACR,OAAM,IAAI,mBACT,2BAA2B,IAAI,UAC/B,IAAI,QACJ,IAAI,WACJ;EAGF,MAAM,OAAO,MAAM,IAAI,MAAM;AAE7B,MAAI,WAAW,QAAQ,KAAK,SAAS,KACpC,OAAM,IAAI,aAAa,KAAK,MAAM,SAAS,KAAK,MAAM,KAAK;AAG5D,SAAO,KAAK"}
@@ -1,12 +1,12 @@
1
- import { HttpHeaders, JsonRpcHTTPTransport, JsonRpcHTTPTransportOptions, JsonRpcTransport, JsonRpcTransportRequestOptions, JsonRpcTransportSubscribeOptions } from "./http-transport.mjs";
1
+ import { HttpHeaders, JsonRpcHTTPTransport, JsonRpcHTTPTransportOptions, JsonRpcTransport, JsonRpcTransportRequestOptions } from "./http-transport.mjs";
2
2
  import { AccumulatorEvent, AccumulatorOperation, AccumulatorValue, Balance, BalanceChange, Checkpoint, CheckpointCommitment, CheckpointId, Claim, CoinMetadata, CoinStruct, CoinSupply, CommitteeInfo, CompressedSignature, ConsensusDeterminedVersionAssignments, DelegatedStake, DevInspectArgs, DevInspectResults, DisplayFieldsResponse, DryRunTransactionBlockResponse, DynamicFieldInfo, DynamicFieldName, DynamicFieldType, ECMHLiveObjectSetDigest, EndOfEpochData, EventId, ExecuteTransactionRequestType, ExecutionStatus, GasCostSummary, GetPastObjectRequest, InputObjectKind, MoveCallParams, MoveCallSuiTransaction, MoveStruct, MoveValue, MoveVariant, MultiSig, MultiSigLegacy, MultiSigPublicKey, MultiSigPublicKeyLegacy, ObjectOwner, ObjectRead, ObjectResponseError, ObjectValueKind, OwnedObjectRef, PaginatedCheckpoints, PaginatedCoins, PaginatedDynamicFieldInfos, PaginatedEvents, PaginatedObjectsResponse, PaginatedStrings, PaginatedTransactionResponse, PasskeyAuthenticator, ProtocolConfig, ProtocolConfigValue, PublicKey, RPCTransactionRequestParams, RawData, Signature, StakeObject, SuiActiveJwk, SuiArgument, SuiAuthenticatorStateExpire, SuiCallArg, SuiChangeEpoch, SuiEndOfEpochTransactionKind, SuiEvent, SuiEventFilter, SuiExecutionResult, SuiGasData, SuiJWK, SuiJwkId, SuiMoveAbility, SuiMoveAbilitySet, SuiMoveAbort, SuiMoveFunctionArgType, SuiMoveModuleId, SuiMoveNormalizedEnum, SuiMoveNormalizedField, SuiMoveNormalizedFunction, SuiMoveNormalizedModule, SuiMoveNormalizedStruct, SuiMoveNormalizedType, SuiMoveStructTypeParameter, SuiMoveVisibility, SuiObjectChange, SuiObjectData, SuiObjectDataFilter, SuiObjectDataOptions, SuiObjectRef, SuiObjectResponse, SuiObjectResponseQuery, SuiParsedData, SuiReservation, SuiSystemStateSummary, SuiTransaction, SuiTransactionBlock, SuiTransactionBlockBuilderMode, SuiTransactionBlockKind, SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions, SuiTransactionBlockResponseQuery, SuiValidatorSummary, SuiWithdrawFrom, SuiWithdrawalTypeArg, TransactionBlockBytes, TransactionBlockData, TransactionBlockEffectsModifiedAtVersions, TransactionEffects, TransactionFilter, TransferObjectParams, TypeOrigin, UpgradeInfo, ValidatorApy, ValidatorsApy, ZkLoginAuthenticator, ZkLoginInputs, ZkLoginIntentScope, ZkLoginProof, ZkLoginVerifyResult } from "./types/generated.mjs";
3
3
  import { AddressMetrics, AllEpochsAddressMetrics, CheckpointPage, DynamicFieldPage, EndOfEpochInfo, EpochInfo, EpochMetrics, EpochMetricsPage, EpochPage, MoveCallMetric, MoveCallMetrics, NetworkMetrics, ProgrammableTransaction, ResolvedNameServiceNames, SuiMoveNormalizedModules, SuiMoveObject, SuiMovePackage } from "./types/chain.mjs";
4
4
  import { CoinBalance } from "./types/coins.mjs";
5
- import { Order, Unsubscribe } from "./types/common.mjs";
5
+ import { Order } from "./types/common.mjs";
6
6
  import { SuiObjectChangeCreated, SuiObjectChangeDeleted, SuiObjectChangeMutated, SuiObjectChangePublished, SuiObjectChangeTransferred, SuiObjectChangeWrapped } from "./types/changes.mjs";
7
7
  import { DevInspectTransactionBlockParams, DryRunTransactionBlockParams, ExecuteTransactionBlockParams, GetAllBalancesParams, GetAllCoinsParams, GetBalanceParams, GetChainIdentifierParams, GetCheckpointParams, GetCheckpointsParams, GetCoinMetadataParams, GetCoinsParams, GetCommitteeInfoParams, GetDynamicFieldObjectParams, GetDynamicFieldsParams, GetEventsParams, GetLatestCheckpointSequenceNumberParams, GetLatestSuiSystemStateParams, GetMoveFunctionArgTypesParams, GetNormalizedMoveFunctionParams, GetNormalizedMoveModuleParams, GetNormalizedMoveModulesByPackageParams, GetNormalizedMoveStructParams, GetObjectParams, GetOwnedObjectsParams, GetProtocolConfigParams, GetReferenceGasPriceParams, GetStakesByIdsParams, GetStakesParams, GetTotalSupplyParams, GetTotalTransactionBlocksParams, GetTransactionBlockParams, GetValidatorsApyParams, MultiGetObjectsParams, MultiGetTransactionBlocksParams, QueryEventsParams, QueryTransactionBlocksParams, ResolveNameServiceAddressParams, ResolveNameServiceNamesParams, SubscribeEventParams, SubscribeTransactionParams, TryGetPastObjectParams, TryMultiGetPastObjectsParams, UnsafeBatchTransactionParams, UnsafeMergeCoinsParams, UnsafeMoveCallParams, UnsafePayAllSuiParams, UnsafePayParams, UnsafePaySuiParams, UnsafePublishParams, UnsafeRequestAddStakeParams, UnsafeRequestWithdrawStakeParams, UnsafeSplitCoinEqualParams, UnsafeSplitCoinParams, UnsafeTransferObjectParams, UnsafeTransferSuiParams, VerifyZkLoginSignatureParams } from "./types/params.mjs";
8
8
  import "./types/index.mjs";
9
9
  import { OrderArguments, PaginationArguments, SuiJsonRpcClient, SuiJsonRpcClientOptions, isSuiJsonRpcClient } from "./client.mjs";
10
10
  import { JsonRpcError, SuiHTTPStatusError, SuiHTTPTransportError } from "./errors.mjs";
11
11
  import { getJsonRpcFullnodeUrl } from "./network.mjs";
12
- export { AccumulatorEvent, AccumulatorOperation, AccumulatorValue, AddressMetrics, AllEpochsAddressMetrics, Balance, BalanceChange, Checkpoint, CheckpointCommitment, CheckpointId, CheckpointPage, Claim, CoinBalance, CoinMetadata, CoinStruct, CoinSupply, CommitteeInfo, CompressedSignature, ConsensusDeterminedVersionAssignments, DelegatedStake, DevInspectArgs, DevInspectResults, DevInspectTransactionBlockParams, DisplayFieldsResponse, DryRunTransactionBlockParams, DryRunTransactionBlockResponse, DynamicFieldInfo, DynamicFieldName, DynamicFieldPage, DynamicFieldType, ECMHLiveObjectSetDigest, EndOfEpochData, EndOfEpochInfo, EpochInfo, EpochMetrics, EpochMetricsPage, EpochPage, EventId, ExecuteTransactionBlockParams, ExecuteTransactionRequestType, ExecutionStatus, GasCostSummary, GetAllBalancesParams, GetAllCoinsParams, GetBalanceParams, GetChainIdentifierParams, GetCheckpointParams, GetCheckpointsParams, GetCoinMetadataParams, GetCoinsParams, GetCommitteeInfoParams, GetDynamicFieldObjectParams, GetDynamicFieldsParams, GetEventsParams, GetLatestCheckpointSequenceNumberParams, GetLatestSuiSystemStateParams, GetMoveFunctionArgTypesParams, GetNormalizedMoveFunctionParams, GetNormalizedMoveModuleParams, GetNormalizedMoveModulesByPackageParams, GetNormalizedMoveStructParams, GetObjectParams, GetOwnedObjectsParams, GetPastObjectRequest, GetProtocolConfigParams, GetReferenceGasPriceParams, GetStakesByIdsParams, GetStakesParams, GetTotalSupplyParams, GetTotalTransactionBlocksParams, GetTransactionBlockParams, GetValidatorsApyParams, type HttpHeaders, InputObjectKind, JsonRpcError, JsonRpcHTTPTransport, type JsonRpcHTTPTransportOptions, type JsonRpcTransport, type JsonRpcTransportRequestOptions, type JsonRpcTransportSubscribeOptions, MoveCallMetric, MoveCallMetrics, MoveCallParams, MoveCallSuiTransaction, MoveStruct, MoveValue, MoveVariant, MultiGetObjectsParams, MultiGetTransactionBlocksParams, MultiSig, MultiSigLegacy, MultiSigPublicKey, MultiSigPublicKeyLegacy, NetworkMetrics, ObjectOwner, ObjectRead, ObjectResponseError, ObjectValueKind, Order, type OrderArguments, OwnedObjectRef, PaginatedCheckpoints, PaginatedCoins, PaginatedDynamicFieldInfos, PaginatedEvents, PaginatedObjectsResponse, PaginatedStrings, PaginatedTransactionResponse, type PaginationArguments, PasskeyAuthenticator, ProgrammableTransaction, ProtocolConfig, ProtocolConfigValue, PublicKey, QueryEventsParams, QueryTransactionBlocksParams, RPCTransactionRequestParams, RawData, ResolveNameServiceAddressParams, ResolveNameServiceNamesParams, ResolvedNameServiceNames, Signature, StakeObject, SubscribeEventParams, SubscribeTransactionParams, SuiActiveJwk, SuiArgument, SuiAuthenticatorStateExpire, SuiCallArg, SuiChangeEpoch, SuiEndOfEpochTransactionKind, SuiEvent, SuiEventFilter, SuiExecutionResult, SuiGasData, SuiHTTPStatusError, SuiHTTPTransportError, SuiJWK, SuiJsonRpcClient, type SuiJsonRpcClientOptions, SuiJwkId, SuiMoveAbility, SuiMoveAbilitySet, SuiMoveAbort, SuiMoveFunctionArgType, SuiMoveModuleId, SuiMoveNormalizedEnum, SuiMoveNormalizedField, SuiMoveNormalizedFunction, SuiMoveNormalizedModule, SuiMoveNormalizedModules, SuiMoveNormalizedStruct, SuiMoveNormalizedType, SuiMoveObject, SuiMovePackage, SuiMoveStructTypeParameter, SuiMoveVisibility, SuiObjectChange, SuiObjectChangeCreated, SuiObjectChangeDeleted, SuiObjectChangeMutated, SuiObjectChangePublished, SuiObjectChangeTransferred, SuiObjectChangeWrapped, SuiObjectData, SuiObjectDataFilter, SuiObjectDataOptions, SuiObjectRef, SuiObjectResponse, SuiObjectResponseQuery, SuiParsedData, SuiReservation, SuiSystemStateSummary, SuiTransaction, SuiTransactionBlock, SuiTransactionBlockBuilderMode, SuiTransactionBlockKind, SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions, SuiTransactionBlockResponseQuery, SuiValidatorSummary, SuiWithdrawFrom, SuiWithdrawalTypeArg, TransactionBlockBytes, TransactionBlockData, TransactionBlockEffectsModifiedAtVersions, TransactionEffects, TransactionFilter, TransferObjectParams, TryGetPastObjectParams, TryMultiGetPastObjectsParams, TypeOrigin, UnsafeBatchTransactionParams, UnsafeMergeCoinsParams, UnsafeMoveCallParams, UnsafePayAllSuiParams, UnsafePayParams, UnsafePaySuiParams, UnsafePublishParams, UnsafeRequestAddStakeParams, UnsafeRequestWithdrawStakeParams, UnsafeSplitCoinEqualParams, UnsafeSplitCoinParams, UnsafeTransferObjectParams, UnsafeTransferSuiParams, Unsubscribe, UpgradeInfo, ValidatorApy, ValidatorsApy, VerifyZkLoginSignatureParams, ZkLoginAuthenticator, ZkLoginInputs, ZkLoginIntentScope, ZkLoginProof, ZkLoginVerifyResult, getJsonRpcFullnodeUrl, isSuiJsonRpcClient };
12
+ export { AccumulatorEvent, AccumulatorOperation, AccumulatorValue, AddressMetrics, AllEpochsAddressMetrics, Balance, BalanceChange, Checkpoint, CheckpointCommitment, CheckpointId, CheckpointPage, Claim, CoinBalance, CoinMetadata, CoinStruct, CoinSupply, CommitteeInfo, CompressedSignature, ConsensusDeterminedVersionAssignments, DelegatedStake, DevInspectArgs, DevInspectResults, DevInspectTransactionBlockParams, DisplayFieldsResponse, DryRunTransactionBlockParams, DryRunTransactionBlockResponse, DynamicFieldInfo, DynamicFieldName, DynamicFieldPage, DynamicFieldType, ECMHLiveObjectSetDigest, EndOfEpochData, EndOfEpochInfo, EpochInfo, EpochMetrics, EpochMetricsPage, EpochPage, EventId, ExecuteTransactionBlockParams, ExecuteTransactionRequestType, ExecutionStatus, GasCostSummary, GetAllBalancesParams, GetAllCoinsParams, GetBalanceParams, GetChainIdentifierParams, GetCheckpointParams, GetCheckpointsParams, GetCoinMetadataParams, GetCoinsParams, GetCommitteeInfoParams, GetDynamicFieldObjectParams, GetDynamicFieldsParams, GetEventsParams, GetLatestCheckpointSequenceNumberParams, GetLatestSuiSystemStateParams, GetMoveFunctionArgTypesParams, GetNormalizedMoveFunctionParams, GetNormalizedMoveModuleParams, GetNormalizedMoveModulesByPackageParams, GetNormalizedMoveStructParams, GetObjectParams, GetOwnedObjectsParams, GetPastObjectRequest, GetProtocolConfigParams, GetReferenceGasPriceParams, GetStakesByIdsParams, GetStakesParams, GetTotalSupplyParams, GetTotalTransactionBlocksParams, GetTransactionBlockParams, GetValidatorsApyParams, type HttpHeaders, InputObjectKind, JsonRpcError, JsonRpcHTTPTransport, type JsonRpcHTTPTransportOptions, type JsonRpcTransport, type JsonRpcTransportRequestOptions, MoveCallMetric, MoveCallMetrics, MoveCallParams, MoveCallSuiTransaction, MoveStruct, MoveValue, MoveVariant, MultiGetObjectsParams, MultiGetTransactionBlocksParams, MultiSig, MultiSigLegacy, MultiSigPublicKey, MultiSigPublicKeyLegacy, NetworkMetrics, ObjectOwner, ObjectRead, ObjectResponseError, ObjectValueKind, Order, type OrderArguments, OwnedObjectRef, PaginatedCheckpoints, PaginatedCoins, PaginatedDynamicFieldInfos, PaginatedEvents, PaginatedObjectsResponse, PaginatedStrings, PaginatedTransactionResponse, type PaginationArguments, PasskeyAuthenticator, ProgrammableTransaction, ProtocolConfig, ProtocolConfigValue, PublicKey, QueryEventsParams, QueryTransactionBlocksParams, RPCTransactionRequestParams, RawData, ResolveNameServiceAddressParams, ResolveNameServiceNamesParams, ResolvedNameServiceNames, Signature, StakeObject, SubscribeEventParams, SubscribeTransactionParams, SuiActiveJwk, SuiArgument, SuiAuthenticatorStateExpire, SuiCallArg, SuiChangeEpoch, SuiEndOfEpochTransactionKind, SuiEvent, SuiEventFilter, SuiExecutionResult, SuiGasData, SuiHTTPStatusError, SuiHTTPTransportError, SuiJWK, SuiJsonRpcClient, type SuiJsonRpcClientOptions, SuiJwkId, SuiMoveAbility, SuiMoveAbilitySet, SuiMoveAbort, SuiMoveFunctionArgType, SuiMoveModuleId, SuiMoveNormalizedEnum, SuiMoveNormalizedField, SuiMoveNormalizedFunction, SuiMoveNormalizedModule, SuiMoveNormalizedModules, SuiMoveNormalizedStruct, SuiMoveNormalizedType, SuiMoveObject, SuiMovePackage, SuiMoveStructTypeParameter, SuiMoveVisibility, SuiObjectChange, SuiObjectChangeCreated, SuiObjectChangeDeleted, SuiObjectChangeMutated, SuiObjectChangePublished, SuiObjectChangeTransferred, SuiObjectChangeWrapped, SuiObjectData, SuiObjectDataFilter, SuiObjectDataOptions, SuiObjectRef, SuiObjectResponse, SuiObjectResponseQuery, SuiParsedData, SuiReservation, SuiSystemStateSummary, SuiTransaction, SuiTransactionBlock, SuiTransactionBlockBuilderMode, SuiTransactionBlockKind, SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions, SuiTransactionBlockResponseQuery, SuiValidatorSummary, SuiWithdrawFrom, SuiWithdrawalTypeArg, TransactionBlockBytes, TransactionBlockData, TransactionBlockEffectsModifiedAtVersions, TransactionEffects, TransactionFilter, TransferObjectParams, TryGetPastObjectParams, TryMultiGetPastObjectsParams, TypeOrigin, UnsafeBatchTransactionParams, UnsafeMergeCoinsParams, UnsafeMoveCallParams, UnsafePayAllSuiParams, UnsafePayParams, UnsafePaySuiParams, UnsafePublishParams, UnsafeRequestAddStakeParams, UnsafeRequestWithdrawStakeParams, UnsafeSplitCoinEqualParams, UnsafeSplitCoinParams, UnsafeTransferObjectParams, UnsafeTransferSuiParams, UpgradeInfo, ValidatorApy, ValidatorsApy, VerifyZkLoginSignatureParams, ZkLoginAuthenticator, ZkLoginInputs, ZkLoginIntentScope, ZkLoginProof, ZkLoginVerifyResult, getJsonRpcFullnodeUrl, isSuiJsonRpcClient };
@@ -1,6 +1,5 @@
1
1
  //#region src/jsonRpc/types/common.d.ts
2
2
  type Order = 'ascending' | 'descending';
3
- type Unsubscribe = () => Promise<boolean>;
4
3
  //#endregion
5
- export { Order, Unsubscribe };
4
+ export { Order };
6
5
  //# sourceMappingURL=common.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.mts","names":[],"sources":["../../../src/jsonRpc/types/common.ts"],"sourcesContent":[],"mappings":";KAGY,KAAA;AAAA,KACA,WAAA,GADK,GAAA,GACe,OADf,CAAA,OAAA,CAAA"}
1
+ {"version":3,"file":"common.d.mts","names":[],"sources":["../../../src/jsonRpc/types/common.ts"],"sourcesContent":[],"mappings":";KAGY,KAAA"}
@@ -1,6 +1,6 @@
1
1
  import { AccumulatorEvent, AccumulatorOperation, AccumulatorValue, Balance, BalanceChange, Checkpoint, CheckpointCommitment, CheckpointId, Claim, CoinMetadata, CoinStruct, CoinSupply, CommitteeInfo, CompressedSignature, ConsensusDeterminedVersionAssignments, DelegatedStake, DevInspectArgs, DevInspectResults, DisplayFieldsResponse, DryRunTransactionBlockResponse, DynamicFieldInfo, DynamicFieldName, DynamicFieldType, ECMHLiveObjectSetDigest, EndOfEpochData, EventId, ExecuteTransactionRequestType, ExecutionStatus, GasCostSummary, GetPastObjectRequest, InputObjectKind, MoveCallParams, MoveCallSuiTransaction, MoveStruct, MoveValue, MoveVariant, MultiSig, MultiSigLegacy, MultiSigPublicKey, MultiSigPublicKeyLegacy, ObjectOwner, ObjectRead, ObjectResponseError, ObjectValueKind, OwnedObjectRef, PaginatedCheckpoints, PaginatedCoins, PaginatedDynamicFieldInfos, PaginatedEvents, PaginatedObjectsResponse, PaginatedStrings, PaginatedTransactionResponse, PasskeyAuthenticator, ProtocolConfig, ProtocolConfigValue, PublicKey, RPCTransactionRequestParams, RawData, Signature, StakeObject, SuiActiveJwk, SuiArgument, SuiAuthenticatorStateExpire, SuiCallArg, SuiChangeEpoch, SuiEndOfEpochTransactionKind, SuiEvent, SuiEventFilter, SuiExecutionResult, SuiGasData, SuiJWK, SuiJwkId, SuiMoveAbility, SuiMoveAbilitySet, SuiMoveAbort, SuiMoveFunctionArgType, SuiMoveModuleId, SuiMoveNormalizedEnum, SuiMoveNormalizedField, SuiMoveNormalizedFunction, SuiMoveNormalizedModule, SuiMoveNormalizedStruct, SuiMoveNormalizedType, SuiMoveStructTypeParameter, SuiMoveVisibility, SuiObjectChange, SuiObjectData, SuiObjectDataFilter, SuiObjectDataOptions, SuiObjectRef, SuiObjectResponse, SuiObjectResponseQuery, SuiParsedData, SuiReservation, SuiSystemStateSummary, SuiTransaction, SuiTransactionBlock, SuiTransactionBlockBuilderMode, SuiTransactionBlockKind, SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions, SuiTransactionBlockResponseQuery, SuiValidatorSummary, SuiWithdrawFrom, SuiWithdrawalTypeArg, TransactionBlockBytes, TransactionBlockData, TransactionBlockEffectsModifiedAtVersions, TransactionEffects, TransactionFilter, TransferObjectParams, TypeOrigin, UpgradeInfo, ValidatorApy, ValidatorsApy, ZkLoginAuthenticator, ZkLoginInputs, ZkLoginIntentScope, ZkLoginProof, ZkLoginVerifyResult } from "./generated.mjs";
2
2
  import { AddressMetrics, AllEpochsAddressMetrics, CheckpointPage, DynamicFieldPage, EndOfEpochInfo, EpochInfo, EpochMetrics, EpochMetricsPage, EpochPage, MoveCallMetric, MoveCallMetrics, NetworkMetrics, ProgrammableTransaction, ResolvedNameServiceNames, SuiMoveNormalizedModules, SuiMoveObject, SuiMovePackage } from "./chain.mjs";
3
3
  import { CoinBalance } from "./coins.mjs";
4
- import { Order, Unsubscribe } from "./common.mjs";
4
+ import { Order } from "./common.mjs";
5
5
  import { SuiObjectChangeCreated, SuiObjectChangeDeleted, SuiObjectChangeMutated, SuiObjectChangePublished, SuiObjectChangeTransferred, SuiObjectChangeWrapped } from "./changes.mjs";
6
6
  import { DevInspectTransactionBlockParams, DryRunTransactionBlockParams, ExecuteTransactionBlockParams, GetAllBalancesParams, GetAllCoinsParams, GetBalanceParams, GetChainIdentifierParams, GetCheckpointParams, GetCheckpointsParams, GetCoinMetadataParams, GetCoinsParams, GetCommitteeInfoParams, GetDynamicFieldObjectParams, GetDynamicFieldsParams, GetEventsParams, GetLatestCheckpointSequenceNumberParams, GetLatestSuiSystemStateParams, GetMoveFunctionArgTypesParams, GetNormalizedMoveFunctionParams, GetNormalizedMoveModuleParams, GetNormalizedMoveModulesByPackageParams, GetNormalizedMoveStructParams, GetObjectParams, GetOwnedObjectsParams, GetProtocolConfigParams, GetReferenceGasPriceParams, GetStakesByIdsParams, GetStakesParams, GetTotalSupplyParams, GetTotalTransactionBlocksParams, GetTransactionBlockParams, GetValidatorsApyParams, MultiGetObjectsParams, MultiGetTransactionBlocksParams, QueryEventsParams, QueryTransactionBlocksParams, ResolveNameServiceAddressParams, ResolveNameServiceNamesParams, SubscribeEventParams, SubscribeTransactionParams, TryGetPastObjectParams, TryMultiGetPastObjectsParams, UnsafeBatchTransactionParams, UnsafeMergeCoinsParams, UnsafeMoveCallParams, UnsafePayAllSuiParams, UnsafePayParams, UnsafePaySuiParams, UnsafePublishParams, UnsafeRequestAddStakeParams, UnsafeRequestWithdrawStakeParams, UnsafeSplitCoinEqualParams, UnsafeSplitCoinParams, UnsafeTransferObjectParams, UnsafeTransferSuiParams, VerifyZkLoginSignatureParams } from "./params.mjs";
@@ -8,7 +8,7 @@ import { createPure } from "./pure.mjs";
8
8
  import { SignatureWithBytes, Signer } from "../cryptography/keypair.mjs";
9
9
  import "../cryptography/index.mjs";
10
10
  import { ClientWithCoreApi } from "../client/core.mjs";
11
- import * as _mysten_bcs1124 from "@mysten/bcs";
11
+ import * as _mysten_bcs810 from "@mysten/bcs";
12
12
  import { SerializedBcs } from "@mysten/bcs";
13
13
  import { InferInput } from "valibot";
14
14
 
@@ -77,7 +77,7 @@ declare class Transaction {
77
77
  getData(): {
78
78
  version: 2;
79
79
  sender?: string | null | undefined;
80
- expiration?: _mysten_bcs1124.EnumOutputShapeWithKeys<{
80
+ expiration?: _mysten_bcs810.EnumOutputShapeWithKeys<{
81
81
  None: true;
82
82
  Epoch: string | number;
83
83
  ValidDuring: {
@@ -99,8 +99,8 @@ declare class Transaction {
99
99
  digest: string;
100
100
  }[] | null;
101
101
  };
102
- inputs: _mysten_bcs1124.EnumOutputShapeWithKeys<{
103
- Object: _mysten_bcs1124.EnumOutputShapeWithKeys<{
102
+ inputs: _mysten_bcs810.EnumOutputShapeWithKeys<{
103
+ Object: _mysten_bcs810.EnumOutputShapeWithKeys<{
104
104
  ImmOrOwnedObject: {
105
105
  objectId: string;
106
106
  version: string | number;
@@ -139,13 +139,13 @@ declare class Transaction {
139
139
  Balance: string;
140
140
  $kind: "Balance";
141
141
  };
142
- withdrawFrom: _mysten_bcs1124.EnumOutputShapeWithKeys<{
142
+ withdrawFrom: _mysten_bcs810.EnumOutputShapeWithKeys<{
143
143
  Sender: true;
144
144
  Sponsor: true;
145
145
  }, "Sender" | "Sponsor">;
146
146
  };
147
147
  }, "Object" | "Pure" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
148
- commands: _mysten_bcs1124.EnumOutputShapeWithKeys<{
148
+ commands: _mysten_bcs810.EnumOutputShapeWithKeys<{
149
149
  MoveCall: {
150
150
  package: string;
151
151
  module: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Transaction.d.mts","names":[],"sources":["../../src/transactions/Transaction.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;KAoCY,yBAAA,GACT,QAAQ,kBAAkB;;;WAEtB,gBACC,QAAQ,kBAAkB;EAJtB,KAAA,EAAA,OAAA;EACiB,IAAA,CAAA,EAAA,MAAA;CAAlB,CAAA,CAAA,G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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA5mBtD,kBAAkB,WAAW;;;;;;;;;;UA0CjC,kBACA;;;;;;;;;qBA2CW,mBAAmB;;;;;;;;;wBAQhB,mBAAmB;;;;;;;;;2BAQhB,mBAAmB;;;;;;gBAsB9B,kBAAkB,IAAI;uBACf,4BAA4B,sBAAsB,qBAC1D,gBAAgB,IAC1B;gBACW,yDACU,sBAAsB,KAC3C;oCAwGqB,sBAAsB,wDACtC,6CAA6C,UAU8B,QACjF;;qBAGY,UAAU,QAAQ;;;0BAIlB,8CACH,wCAAqC;;;;;;;MAS6C;;;;aAWnF;;;;;;YAMD;MACR;;eAWW;;;;;;iBAOI,sBAAsB;;;;iBAKtB,sBAAsB;;MAElC;4BASO,gDACD,sBAAsB,8BAA2B;;;;;eAe/C;;MAEX;;;;;;;;;;;;;;;;;;;;;;;;mBA8CqB,8BAAmC;;gBAmBrC,cAAc,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2DrB,0BAA+B,QAAQ,WAAW;;;aAW5D;MAER;mCAsJoC,8BAA2B"}
package/dist/version.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/version.ts
2
- const PACKAGE_VERSION = "2.10.0";
2
+ const PACKAGE_VERSION = "2.11.0";
3
3
  const TARGETED_RPC_VERSION = "1.69.0";
4
4
 
5
5
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.10.0';\nexport const TARGETED_RPC_VERSION = '1.69.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.11.0';\nexport const TARGETED_RPC_VERSION = '1.69.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
@@ -1,31 +1,31 @@
1
- import * as _mysten_bcs810 from "@mysten/bcs";
1
+ import * as _mysten_bcs817 from "@mysten/bcs";
2
2
  import { InferBcsInput } from "@mysten/bcs";
3
3
 
4
4
  //#region src/zklogin/bcs.d.ts
5
- declare const zkLoginSignature: _mysten_bcs810.BcsStruct<{
6
- inputs: _mysten_bcs810.BcsStruct<{
7
- proofPoints: _mysten_bcs810.BcsStruct<{
8
- a: _mysten_bcs810.BcsType<string[], Iterable<string> & {
5
+ declare const zkLoginSignature: _mysten_bcs817.BcsStruct<{
6
+ inputs: _mysten_bcs817.BcsStruct<{
7
+ proofPoints: _mysten_bcs817.BcsStruct<{
8
+ a: _mysten_bcs817.BcsType<string[], Iterable<string> & {
9
9
  length: number;
10
10
  }, string>;
11
- b: _mysten_bcs810.BcsType<string[][], Iterable<Iterable<string> & {
11
+ b: _mysten_bcs817.BcsType<string[][], Iterable<Iterable<string> & {
12
12
  length: number;
13
13
  }> & {
14
14
  length: number;
15
15
  }, string>;
16
- c: _mysten_bcs810.BcsType<string[], Iterable<string> & {
16
+ c: _mysten_bcs817.BcsType<string[], Iterable<string> & {
17
17
  length: number;
18
18
  }, string>;
19
19
  }, string>;
20
- issBase64Details: _mysten_bcs810.BcsStruct<{
21
- value: _mysten_bcs810.BcsType<string, string, "string">;
22
- indexMod4: _mysten_bcs810.BcsType<number, number, "u8">;
20
+ issBase64Details: _mysten_bcs817.BcsStruct<{
21
+ value: _mysten_bcs817.BcsType<string, string, "string">;
22
+ indexMod4: _mysten_bcs817.BcsType<number, number, "u8">;
23
23
  }, string>;
24
- headerBase64: _mysten_bcs810.BcsType<string, string, "string">;
25
- addressSeed: _mysten_bcs810.BcsType<string, string, "string">;
24
+ headerBase64: _mysten_bcs817.BcsType<string, string, "string">;
25
+ addressSeed: _mysten_bcs817.BcsType<string, string, "string">;
26
26
  }, string>;
27
- maxEpoch: _mysten_bcs810.BcsType<string, string | number | bigint, "u64">;
28
- userSignature: _mysten_bcs810.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
27
+ maxEpoch: _mysten_bcs817.BcsType<string, string | number | bigint, "u64">;
28
+ userSignature: _mysten_bcs817.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
29
29
  }, string>;
30
30
  type ZkLoginSignature = InferBcsInput<typeof zkLoginSignature>;
31
31
  type ZkLoginSignatureInputs = ZkLoginSignature['inputs'];
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mysten Labs <build@mystenlabs.com>",
4
4
  "description": "Sui TypeScript API",
5
5
  "homepage": "https://sdk.mystenlabs.com",
6
- "version": "2.10.0",
6
+ "version": "2.11.0",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -142,7 +142,6 @@
142
142
  "@parcel/watcher": "^2.5.4",
143
143
  "@types/node": "^25.0.8",
144
144
  "@types/tmp": "^0.2.6",
145
- "@types/ws": "^8.18.1",
146
145
  "cross-env": "^10.1.0",
147
146
  "graphql-config": "^5.1.5",
148
147
  "msw": "^2.12.7",
@@ -152,8 +151,7 @@
152
151
  "vite": "^7.3.1",
153
152
  "vite-tsconfig-paths": "^6.0.4",
154
153
  "vitest": "^4.0.17",
155
- "wait-on": "^9.0.3",
156
- "ws": "^8.19.0"
154
+ "wait-on": "^9.0.3"
157
155
  },
158
156
  "dependencies": {
159
157
  "@graphql-typed-document-node/core": "^3.2.0",
@@ -169,8 +167,8 @@
169
167
  "graphql": "^16.12.0",
170
168
  "poseidon-lite": "0.2.1",
171
169
  "valibot": "^1.2.0",
172
- "@mysten/bcs": "^2.0.3",
173
- "@mysten/utils": "^0.3.1"
170
+ "@mysten/utils": "^0.3.1",
171
+ "@mysten/bcs": "^2.0.3"
174
172
  },
175
173
  "scripts": {
176
174
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
@@ -3,8 +3,6 @@
3
3
 
4
4
  import { PACKAGE_VERSION, TARGETED_RPC_VERSION } from '../version.js';
5
5
  import { JsonRpcError, SuiHTTPStatusError } from './errors.js';
6
- import type { WebsocketClientOptions } from './rpc-websocket-client.js';
7
- import { WebsocketClient } from './rpc-websocket-client.js';
8
6
 
9
7
  /**
10
8
  * An object defining headers to be passed to the RPC server
@@ -13,15 +11,11 @@ export type HttpHeaders = { [header: string]: string };
13
11
 
14
12
  export interface JsonRpcHTTPTransportOptions {
15
13
  fetch?: typeof fetch;
16
- WebSocketConstructor?: typeof WebSocket;
17
14
  url: string;
18
15
  rpc?: {
19
16
  headers?: HttpHeaders;
20
17
  url?: string;
21
18
  };
22
- websocket?: WebsocketClientOptions & {
23
- url?: string;
24
- };
25
19
  }
26
20
 
27
21
  export interface JsonRpcTransportRequestOptions {
@@ -30,25 +24,13 @@ export interface JsonRpcTransportRequestOptions {
30
24
  signal?: AbortSignal;
31
25
  }
32
26
 
33
- export interface JsonRpcTransportSubscribeOptions<T> {
34
- method: string;
35
- unsubscribe: string;
36
- params: unknown[];
37
- onMessage: (event: T) => void;
38
- signal?: AbortSignal;
39
- }
40
-
41
27
  export interface JsonRpcTransport {
42
28
  request<T = unknown>(input: JsonRpcTransportRequestOptions): Promise<T>;
43
- subscribe<T = unknown>(
44
- input: JsonRpcTransportSubscribeOptions<T>,
45
- ): Promise<() => Promise<boolean>>;
46
29
  }
47
30
 
48
31
  export class JsonRpcHTTPTransport implements JsonRpcTransport {
49
32
  #requestId = 0;
50
33
  #options: JsonRpcHTTPTransportOptions;
51
- #websocketClient?: WebsocketClient;
52
34
 
53
35
  constructor(options: JsonRpcHTTPTransportOptions) {
54
36
  this.#options = options;
@@ -66,27 +48,6 @@ export class JsonRpcHTTPTransport implements JsonRpcTransport {
66
48
  return fetchFn(input, init);
67
49
  }
68
50
 
69
- #getWebsocketClient(): WebsocketClient {
70
- if (!this.#websocketClient) {
71
- const WebSocketConstructor = this.#options.WebSocketConstructor ?? WebSocket;
72
- if (!WebSocketConstructor) {
73
- throw new Error(
74
- 'The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.',
75
- );
76
- }
77
-
78
- this.#websocketClient = new WebsocketClient(
79
- this.#options.websocket?.url ?? this.#options.url,
80
- {
81
- WebSocketConstructor,
82
- ...this.#options.websocket,
83
- },
84
- );
85
- }
86
-
87
- return this.#websocketClient;
88
- }
89
-
90
51
  async request<T>(input: JsonRpcTransportRequestOptions): Promise<T> {
91
52
  this.#requestId += 1;
92
53
 
@@ -125,17 +86,4 @@ export class JsonRpcHTTPTransport implements JsonRpcTransport {
125
86
 
126
87
  return data.result;
127
88
  }
128
-
129
- async subscribe<T>(input: JsonRpcTransportSubscribeOptions<T>): Promise<() => Promise<boolean>> {
130
- const unsubscribe = await this.#getWebsocketClient().subscribe(input);
131
-
132
- if (input.signal) {
133
- input.signal.throwIfAborted();
134
- input.signal.addEventListener('abort', () => {
135
- unsubscribe();
136
- });
137
- }
138
-
139
- return async () => !!(await unsubscribe());
140
- }
141
89
  }
@@ -4,7 +4,6 @@
4
4
  export {
5
5
  type JsonRpcTransport,
6
6
  type JsonRpcTransportRequestOptions,
7
- type JsonRpcTransportSubscribeOptions,
8
7
  type HttpHeaders,
9
8
  type JsonRpcHTTPTransportOptions,
10
9
  JsonRpcHTTPTransport,
@@ -2,4 +2,3 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export type Order = 'ascending' | 'descending';
5
- export type Unsubscribe = () => Promise<boolean>;
package/src/version.ts CHANGED
@@ -3,5 +3,5 @@
3
3
 
4
4
  // This file is generated by genversion.mjs. Do not edit it directly.
5
5
 
6
- export const PACKAGE_VERSION = '2.10.0';
6
+ export const PACKAGE_VERSION = '2.11.0';
7
7
  export const TARGETED_RPC_VERSION = '1.69.0';
@@ -1,26 +0,0 @@
1
- //#region src/jsonRpc/rpc-websocket-client.d.ts
2
-
3
- /**
4
- * Configuration options for the websocket connection
5
- */
6
- type WebsocketClientOptions = {
7
- /**
8
- * Custom WebSocket class to use. Defaults to the global WebSocket class, if available.
9
- */
10
- WebSocketConstructor?: typeof WebSocket;
11
- /**
12
- * Milliseconds before timing out while calling an RPC method
13
- */
14
- callTimeout?: number;
15
- /**
16
- * Milliseconds between attempts to connect
17
- */
18
- reconnectTimeout?: number;
19
- /**
20
- * Maximum number of times to try connecting before giving up
21
- */
22
- maxReconnects?: number;
23
- };
24
- //#endregion
25
- export { WebsocketClientOptions };
26
- //# sourceMappingURL=rpc-websocket-client.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rpc-websocket-client.d.mts","names":[],"sources":["../../src/jsonRpc/rpc-websocket-client.ts"],"sourcesContent":[],"mappings":";;;;;KA8CY,sBAAA;;;;gCAImB"}
@@ -1,135 +0,0 @@
1
- import { JsonRpcError } from "./errors.mjs";
2
-
3
- //#region src/jsonRpc/rpc-websocket-client.ts
4
- function getWebsocketUrl(httpUrl) {
5
- const url = new URL(httpUrl);
6
- url.protocol = url.protocol.replace("http", "ws");
7
- return url.toString();
8
- }
9
- const DEFAULT_CLIENT_OPTIONS = {
10
- WebSocketConstructor: typeof WebSocket !== "undefined" ? WebSocket : void 0,
11
- callTimeout: 3e4,
12
- reconnectTimeout: 3e3,
13
- maxReconnects: 5
14
- };
15
- var WebsocketClient = class {
16
- #requestId = 0;
17
- #disconnects = 0;
18
- #webSocket = null;
19
- #connectionPromise = null;
20
- #subscriptions = /* @__PURE__ */ new Set();
21
- #pendingRequests = /* @__PURE__ */ new Map();
22
- constructor(endpoint, options = {}) {
23
- this.endpoint = endpoint;
24
- this.options = {
25
- ...DEFAULT_CLIENT_OPTIONS,
26
- ...options
27
- };
28
- if (!this.options.WebSocketConstructor) throw new Error("Missing WebSocket constructor");
29
- if (this.endpoint.startsWith("http")) this.endpoint = getWebsocketUrl(this.endpoint);
30
- }
31
- async makeRequest(method, params, signal) {
32
- const webSocket = await this.#setupWebSocket();
33
- return new Promise((resolve, reject) => {
34
- this.#requestId += 1;
35
- this.#pendingRequests.set(this.#requestId, {
36
- resolve,
37
- reject,
38
- timeout: setTimeout(() => {
39
- this.#pendingRequests.delete(this.#requestId);
40
- reject(/* @__PURE__ */ new Error(`Request timeout: ${method}`));
41
- }, this.options.callTimeout)
42
- });
43
- signal?.addEventListener("abort", () => {
44
- this.#pendingRequests.delete(this.#requestId);
45
- reject(signal.reason);
46
- });
47
- webSocket.send(JSON.stringify({
48
- jsonrpc: "2.0",
49
- id: this.#requestId,
50
- method,
51
- params
52
- }));
53
- }).then(({ error, result }) => {
54
- if (error) throw new JsonRpcError(error.message, error.code);
55
- return result;
56
- });
57
- }
58
- #setupWebSocket() {
59
- if (this.#connectionPromise) return this.#connectionPromise;
60
- this.#connectionPromise = new Promise((resolve) => {
61
- this.#webSocket?.close();
62
- this.#webSocket = new this.options.WebSocketConstructor(this.endpoint);
63
- this.#webSocket.addEventListener("open", () => {
64
- this.#disconnects = 0;
65
- resolve(this.#webSocket);
66
- });
67
- this.#webSocket.addEventListener("close", () => {
68
- this.#disconnects++;
69
- if (this.#disconnects <= this.options.maxReconnects) setTimeout(() => {
70
- this.#reconnect();
71
- }, this.options.reconnectTimeout);
72
- });
73
- this.#webSocket.addEventListener("message", ({ data }) => {
74
- let json;
75
- try {
76
- json = JSON.parse(data);
77
- } catch (error) {
78
- console.error(new Error(`Failed to parse RPC message: ${data}`, { cause: error }));
79
- return;
80
- }
81
- if ("id" in json && json.id != null && this.#pendingRequests.has(json.id)) {
82
- const { resolve: resolve$1, timeout } = this.#pendingRequests.get(json.id);
83
- clearTimeout(timeout);
84
- resolve$1(json);
85
- } else if ("params" in json) {
86
- const { params } = json;
87
- this.#subscriptions.forEach((subscription) => {
88
- if (subscription.subscriptionId === params.subscription) {
89
- if (params.subscription === subscription.subscriptionId) subscription.onMessage(params.result);
90
- }
91
- });
92
- }
93
- });
94
- });
95
- return this.#connectionPromise;
96
- }
97
- async #reconnect() {
98
- this.#webSocket?.close();
99
- this.#connectionPromise = null;
100
- return Promise.allSettled([...this.#subscriptions].map((subscription) => subscription.subscribe(this)));
101
- }
102
- async subscribe(input) {
103
- const subscription = new RpcSubscription(input);
104
- this.#subscriptions.add(subscription);
105
- await subscription.subscribe(this);
106
- return () => subscription.unsubscribe(this);
107
- }
108
- };
109
- var RpcSubscription = class {
110
- constructor(input) {
111
- this.subscriptionId = null;
112
- this.subscribed = false;
113
- this.input = input;
114
- }
115
- onMessage(message) {
116
- if (this.subscribed) this.input.onMessage(message);
117
- }
118
- async unsubscribe(client) {
119
- const { subscriptionId } = this;
120
- this.subscribed = false;
121
- if (subscriptionId == null) return false;
122
- this.subscriptionId = null;
123
- return client.makeRequest(this.input.unsubscribe, [subscriptionId]);
124
- }
125
- async subscribe(client) {
126
- this.subscriptionId = null;
127
- this.subscribed = true;
128
- const newSubscriptionId = await client.makeRequest(this.input.method, this.input.params, this.input.signal);
129
- if (this.subscribed) this.subscriptionId = newSubscriptionId;
130
- }
131
- };
132
-
133
- //#endregion
134
- export { WebsocketClient };
135
- //# sourceMappingURL=rpc-websocket-client.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rpc-websocket-client.mjs","names":["#setupWebSocket","#requestId","#pendingRequests","#connectionPromise","#webSocket","#disconnects","#reconnect","#subscriptions"],"sources":["../../src/jsonRpc/rpc-websocket-client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JsonRpcError } from './errors.js';\n\nfunction getWebsocketUrl(httpUrl: string): string {\n\tconst url = new URL(httpUrl);\n\turl.protocol = url.protocol.replace('http', 'ws');\n\treturn url.toString();\n}\n\ntype JsonRpcMessage =\n\t| {\n\t\t\tid: number;\n\t\t\tresult: never;\n\t\t\terror: {\n\t\t\t\tcode: number;\n\t\t\t\tmessage: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\tid: number;\n\t\t\tresult: unknown;\n\t\t\terror: never;\n\t }\n\t| {\n\t\t\tmethod: string;\n\t\t\tparams: NotificationMessageParams;\n\t };\n\ntype NotificationMessageParams = {\n\tsubscription?: number;\n\tresult: object;\n};\n\ntype SubscriptionRequest<T = any> = {\n\tmethod: string;\n\tunsubscribe: string;\n\tparams: any[];\n\tonMessage: (event: T) => void;\n\tsignal?: AbortSignal;\n};\n\n/**\n * Configuration options for the websocket connection\n */\nexport type WebsocketClientOptions = {\n\t/**\n\t * Custom WebSocket class to use. Defaults to the global WebSocket class, if available.\n\t */\n\tWebSocketConstructor?: typeof WebSocket;\n\t/**\n\t * Milliseconds before timing out while calling an RPC method\n\t */\n\tcallTimeout?: number;\n\t/**\n\t * Milliseconds between attempts to connect\n\t */\n\treconnectTimeout?: number;\n\t/**\n\t * Maximum number of times to try connecting before giving up\n\t */\n\tmaxReconnects?: number;\n};\n\nexport const DEFAULT_CLIENT_OPTIONS = {\n\t// We fudge the typing because we also check for undefined in the constructor:\n\tWebSocketConstructor: (typeof WebSocket !== 'undefined'\n\t\t? WebSocket\n\t\t: undefined) as typeof WebSocket,\n\tcallTimeout: 30000,\n\treconnectTimeout: 3000,\n\tmaxReconnects: 5,\n} satisfies WebsocketClientOptions;\n\nexport class WebsocketClient {\n\tendpoint: string;\n\toptions: Required<WebsocketClientOptions>;\n\t#requestId = 0;\n\t#disconnects = 0;\n\t#webSocket: WebSocket | null = null;\n\t#connectionPromise: Promise<WebSocket> | null = null;\n\t#subscriptions = new Set<RpcSubscription>();\n\t#pendingRequests = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tresolve: (result: Extract<JsonRpcMessage, { id: number }>) => void;\n\t\t\treject: (reason: unknown) => void;\n\t\t\ttimeout: ReturnType<typeof setTimeout>;\n\t\t}\n\t>();\n\n\tconstructor(endpoint: string, options: WebsocketClientOptions = {}) {\n\t\tthis.endpoint = endpoint;\n\t\tthis.options = { ...DEFAULT_CLIENT_OPTIONS, ...options };\n\n\t\tif (!this.options.WebSocketConstructor) {\n\t\t\tthrow new Error('Missing WebSocket constructor');\n\t\t}\n\n\t\tif (this.endpoint.startsWith('http')) {\n\t\t\tthis.endpoint = getWebsocketUrl(this.endpoint);\n\t\t}\n\t}\n\n\tasync makeRequest<T>(method: string, params: any[], signal?: AbortSignal): Promise<T> {\n\t\tconst webSocket = await this.#setupWebSocket();\n\n\t\treturn new Promise<Extract<JsonRpcMessage, { id: number }>>((resolve, reject) => {\n\t\t\tthis.#requestId += 1;\n\t\t\tthis.#pendingRequests.set(this.#requestId, {\n\t\t\t\tresolve: resolve,\n\t\t\t\treject,\n\t\t\t\ttimeout: setTimeout(() => {\n\t\t\t\t\tthis.#pendingRequests.delete(this.#requestId);\n\t\t\t\t\treject(new Error(`Request timeout: ${method}`));\n\t\t\t\t}, this.options.callTimeout),\n\t\t\t});\n\n\t\t\tsignal?.addEventListener('abort', () => {\n\t\t\t\tthis.#pendingRequests.delete(this.#requestId);\n\t\t\t\treject(signal.reason);\n\t\t\t});\n\n\t\t\twebSocket.send(JSON.stringify({ jsonrpc: '2.0', id: this.#requestId, method, params }));\n\t\t}).then(({ error, result }) => {\n\t\t\tif (error) {\n\t\t\t\tthrow new JsonRpcError(error.message, error.code);\n\t\t\t}\n\n\t\t\treturn result as T;\n\t\t});\n\t}\n\n\t#setupWebSocket() {\n\t\tif (this.#connectionPromise) {\n\t\t\treturn this.#connectionPromise;\n\t\t}\n\n\t\tthis.#connectionPromise = new Promise<WebSocket>((resolve) => {\n\t\t\tthis.#webSocket?.close();\n\t\t\tthis.#webSocket = new this.options.WebSocketConstructor(this.endpoint);\n\n\t\t\tthis.#webSocket.addEventListener('open', () => {\n\t\t\t\tthis.#disconnects = 0;\n\t\t\t\tresolve(this.#webSocket!);\n\t\t\t});\n\n\t\t\tthis.#webSocket.addEventListener('close', () => {\n\t\t\t\tthis.#disconnects++;\n\t\t\t\tif (this.#disconnects <= this.options.maxReconnects) {\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis.#reconnect();\n\t\t\t\t\t}, this.options.reconnectTimeout);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthis.#webSocket.addEventListener('message', ({ data }: { data: string }) => {\n\t\t\t\tlet json: JsonRpcMessage;\n\t\t\t\ttry {\n\t\t\t\t\tjson = JSON.parse(data) as JsonRpcMessage;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(new Error(`Failed to parse RPC message: ${data}`, { cause: error }));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ('id' in json && json.id != null && this.#pendingRequests.has(json.id)) {\n\t\t\t\t\tconst { resolve, timeout } = this.#pendingRequests.get(json.id)!;\n\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve(json);\n\t\t\t\t} else if ('params' in json) {\n\t\t\t\t\tconst { params } = json;\n\t\t\t\t\tthis.#subscriptions.forEach((subscription) => {\n\t\t\t\t\t\tif (subscription.subscriptionId === params.subscription)\n\t\t\t\t\t\t\tif (params.subscription === subscription.subscriptionId) {\n\t\t\t\t\t\t\t\tsubscription.onMessage(params.result);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn this.#connectionPromise;\n\t}\n\n\tasync #reconnect() {\n\t\tthis.#webSocket?.close();\n\t\tthis.#connectionPromise = null;\n\n\t\treturn Promise.allSettled(\n\t\t\t[...this.#subscriptions].map((subscription) => subscription.subscribe(this)),\n\t\t);\n\t}\n\n\tasync subscribe<T>(input: SubscriptionRequest<T>) {\n\t\tconst subscription = new RpcSubscription(input);\n\t\tthis.#subscriptions.add(subscription);\n\t\tawait subscription.subscribe(this);\n\t\treturn () => subscription.unsubscribe(this);\n\t}\n}\n\nclass RpcSubscription {\n\tsubscriptionId: number | null = null;\n\tinput: SubscriptionRequest<any>;\n\tsubscribed = false;\n\n\tconstructor(input: SubscriptionRequest) {\n\t\tthis.input = input;\n\t}\n\n\tonMessage(message: unknown) {\n\t\tif (this.subscribed) {\n\t\t\tthis.input.onMessage(message);\n\t\t}\n\t}\n\n\tasync unsubscribe(client: WebsocketClient) {\n\t\tconst { subscriptionId } = this;\n\t\tthis.subscribed = false;\n\t\tif (subscriptionId == null) return false;\n\t\tthis.subscriptionId = null;\n\n\t\treturn client.makeRequest(this.input.unsubscribe, [subscriptionId]);\n\t}\n\n\tasync subscribe(client: WebsocketClient) {\n\t\tthis.subscriptionId = null;\n\t\tthis.subscribed = true;\n\t\tconst newSubscriptionId = await client.makeRequest<number>(\n\t\t\tthis.input.method,\n\t\t\tthis.input.params,\n\t\t\tthis.input.signal,\n\t\t);\n\n\t\tif (this.subscribed) {\n\t\t\tthis.subscriptionId = newSubscriptionId;\n\t\t}\n\t}\n}\n"],"mappings":";;;AAKA,SAAS,gBAAgB,SAAyB;CACjD,MAAM,MAAM,IAAI,IAAI,QAAQ;AAC5B,KAAI,WAAW,IAAI,SAAS,QAAQ,QAAQ,KAAK;AACjD,QAAO,IAAI,UAAU;;AAyDtB,MAAa,yBAAyB;CAErC,sBAAuB,OAAO,cAAc,cACzC,YACA;CACH,aAAa;CACb,kBAAkB;CAClB,eAAe;CACf;AAED,IAAa,kBAAb,MAA6B;CAG5B,aAAa;CACb,eAAe;CACf,aAA+B;CAC/B,qBAAgD;CAChD,iCAAiB,IAAI,KAAsB;CAC3C,mCAAmB,IAAI,KAOpB;CAEH,YAAY,UAAkB,UAAkC,EAAE,EAAE;AACnE,OAAK,WAAW;AAChB,OAAK,UAAU;GAAE,GAAG;GAAwB,GAAG;GAAS;AAExD,MAAI,CAAC,KAAK,QAAQ,qBACjB,OAAM,IAAI,MAAM,gCAAgC;AAGjD,MAAI,KAAK,SAAS,WAAW,OAAO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oB,MAAM,OAAO,YACtC,KAAK,MAAM,QACX,KAAK,MAAM,QACX,KAAK,MAAM,OACX;AAED,MAAI,KAAK,WACR,MAAK,iBAAiB"}
@@ -1,241 +0,0 @@
1
- // Copyright (c) Mysten Labs, Inc.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { JsonRpcError } from './errors.js';
5
-
6
- function getWebsocketUrl(httpUrl: string): string {
7
- const url = new URL(httpUrl);
8
- url.protocol = url.protocol.replace('http', 'ws');
9
- return url.toString();
10
- }
11
-
12
- type JsonRpcMessage =
13
- | {
14
- id: number;
15
- result: never;
16
- error: {
17
- code: number;
18
- message: string;
19
- };
20
- }
21
- | {
22
- id: number;
23
- result: unknown;
24
- error: never;
25
- }
26
- | {
27
- method: string;
28
- params: NotificationMessageParams;
29
- };
30
-
31
- type NotificationMessageParams = {
32
- subscription?: number;
33
- result: object;
34
- };
35
-
36
- type SubscriptionRequest<T = any> = {
37
- method: string;
38
- unsubscribe: string;
39
- params: any[];
40
- onMessage: (event: T) => void;
41
- signal?: AbortSignal;
42
- };
43
-
44
- /**
45
- * Configuration options for the websocket connection
46
- */
47
- export type WebsocketClientOptions = {
48
- /**
49
- * Custom WebSocket class to use. Defaults to the global WebSocket class, if available.
50
- */
51
- WebSocketConstructor?: typeof WebSocket;
52
- /**
53
- * Milliseconds before timing out while calling an RPC method
54
- */
55
- callTimeout?: number;
56
- /**
57
- * Milliseconds between attempts to connect
58
- */
59
- reconnectTimeout?: number;
60
- /**
61
- * Maximum number of times to try connecting before giving up
62
- */
63
- maxReconnects?: number;
64
- };
65
-
66
- export const DEFAULT_CLIENT_OPTIONS = {
67
- // We fudge the typing because we also check for undefined in the constructor:
68
- WebSocketConstructor: (typeof WebSocket !== 'undefined'
69
- ? WebSocket
70
- : undefined) as typeof WebSocket,
71
- callTimeout: 30000,
72
- reconnectTimeout: 3000,
73
- maxReconnects: 5,
74
- } satisfies WebsocketClientOptions;
75
-
76
- export class WebsocketClient {
77
- endpoint: string;
78
- options: Required<WebsocketClientOptions>;
79
- #requestId = 0;
80
- #disconnects = 0;
81
- #webSocket: WebSocket | null = null;
82
- #connectionPromise: Promise<WebSocket> | null = null;
83
- #subscriptions = new Set<RpcSubscription>();
84
- #pendingRequests = new Map<
85
- number,
86
- {
87
- resolve: (result: Extract<JsonRpcMessage, { id: number }>) => void;
88
- reject: (reason: unknown) => void;
89
- timeout: ReturnType<typeof setTimeout>;
90
- }
91
- >();
92
-
93
- constructor(endpoint: string, options: WebsocketClientOptions = {}) {
94
- this.endpoint = endpoint;
95
- this.options = { ...DEFAULT_CLIENT_OPTIONS, ...options };
96
-
97
- if (!this.options.WebSocketConstructor) {
98
- throw new Error('Missing WebSocket constructor');
99
- }
100
-
101
- if (this.endpoint.startsWith('http')) {
102
- this.endpoint = getWebsocketUrl(this.endpoint);
103
- }
104
- }
105
-
106
- async makeRequest<T>(method: string, params: any[], signal?: AbortSignal): Promise<T> {
107
- const webSocket = await this.#setupWebSocket();
108
-
109
- return new Promise<Extract<JsonRpcMessage, { id: number }>>((resolve, reject) => {
110
- this.#requestId += 1;
111
- this.#pendingRequests.set(this.#requestId, {
112
- resolve: resolve,
113
- reject,
114
- timeout: setTimeout(() => {
115
- this.#pendingRequests.delete(this.#requestId);
116
- reject(new Error(`Request timeout: ${method}`));
117
- }, this.options.callTimeout),
118
- });
119
-
120
- signal?.addEventListener('abort', () => {
121
- this.#pendingRequests.delete(this.#requestId);
122
- reject(signal.reason);
123
- });
124
-
125
- webSocket.send(JSON.stringify({ jsonrpc: '2.0', id: this.#requestId, method, params }));
126
- }).then(({ error, result }) => {
127
- if (error) {
128
- throw new JsonRpcError(error.message, error.code);
129
- }
130
-
131
- return result as T;
132
- });
133
- }
134
-
135
- #setupWebSocket() {
136
- if (this.#connectionPromise) {
137
- return this.#connectionPromise;
138
- }
139
-
140
- this.#connectionPromise = new Promise<WebSocket>((resolve) => {
141
- this.#webSocket?.close();
142
- this.#webSocket = new this.options.WebSocketConstructor(this.endpoint);
143
-
144
- this.#webSocket.addEventListener('open', () => {
145
- this.#disconnects = 0;
146
- resolve(this.#webSocket!);
147
- });
148
-
149
- this.#webSocket.addEventListener('close', () => {
150
- this.#disconnects++;
151
- if (this.#disconnects <= this.options.maxReconnects) {
152
- setTimeout(() => {
153
- this.#reconnect();
154
- }, this.options.reconnectTimeout);
155
- }
156
- });
157
-
158
- this.#webSocket.addEventListener('message', ({ data }: { data: string }) => {
159
- let json: JsonRpcMessage;
160
- try {
161
- json = JSON.parse(data) as JsonRpcMessage;
162
- } catch (error) {
163
- console.error(new Error(`Failed to parse RPC message: ${data}`, { cause: error }));
164
- return;
165
- }
166
-
167
- if ('id' in json && json.id != null && this.#pendingRequests.has(json.id)) {
168
- const { resolve, timeout } = this.#pendingRequests.get(json.id)!;
169
-
170
- clearTimeout(timeout);
171
- resolve(json);
172
- } else if ('params' in json) {
173
- const { params } = json;
174
- this.#subscriptions.forEach((subscription) => {
175
- if (subscription.subscriptionId === params.subscription)
176
- if (params.subscription === subscription.subscriptionId) {
177
- subscription.onMessage(params.result);
178
- }
179
- });
180
- }
181
- });
182
- });
183
-
184
- return this.#connectionPromise;
185
- }
186
-
187
- async #reconnect() {
188
- this.#webSocket?.close();
189
- this.#connectionPromise = null;
190
-
191
- return Promise.allSettled(
192
- [...this.#subscriptions].map((subscription) => subscription.subscribe(this)),
193
- );
194
- }
195
-
196
- async subscribe<T>(input: SubscriptionRequest<T>) {
197
- const subscription = new RpcSubscription(input);
198
- this.#subscriptions.add(subscription);
199
- await subscription.subscribe(this);
200
- return () => subscription.unsubscribe(this);
201
- }
202
- }
203
-
204
- class RpcSubscription {
205
- subscriptionId: number | null = null;
206
- input: SubscriptionRequest<any>;
207
- subscribed = false;
208
-
209
- constructor(input: SubscriptionRequest) {
210
- this.input = input;
211
- }
212
-
213
- onMessage(message: unknown) {
214
- if (this.subscribed) {
215
- this.input.onMessage(message);
216
- }
217
- }
218
-
219
- async unsubscribe(client: WebsocketClient) {
220
- const { subscriptionId } = this;
221
- this.subscribed = false;
222
- if (subscriptionId == null) return false;
223
- this.subscriptionId = null;
224
-
225
- return client.makeRequest(this.input.unsubscribe, [subscriptionId]);
226
- }
227
-
228
- async subscribe(client: WebsocketClient) {
229
- this.subscriptionId = null;
230
- this.subscribed = true;
231
- const newSubscriptionId = await client.makeRequest<number>(
232
- this.input.method,
233
- this.input.params,
234
- this.input.signal,
235
- );
236
-
237
- if (this.subscribed) {
238
- this.subscriptionId = newSubscriptionId;
239
- }
240
- }
241
- }