@mysten/sui 2.20.2 → 2.20.4

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 (91) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/index.d.mts +20 -20
  4. package/dist/client/core.d.mts.map +1 -1
  5. package/dist/client/core.mjs +4 -1
  6. package/dist/client/core.mjs.map +1 -1
  7. package/dist/client/mvr.d.mts.map +1 -1
  8. package/dist/client/mvr.mjs +29 -7
  9. package/dist/client/mvr.mjs.map +1 -1
  10. package/dist/client/transaction-resolver.mjs +1 -0
  11. package/dist/client/transaction-resolver.mjs.map +1 -1
  12. package/dist/cryptography/signature.d.mts +8 -8
  13. package/dist/graphql/core.mjs +3 -1
  14. package/dist/graphql/core.mjs.map +1 -1
  15. package/dist/graphql/generated/queries.d.mts.map +1 -1
  16. package/dist/graphql/generated/queries.mjs +6 -2
  17. package/dist/graphql/generated/queries.mjs.map +1 -1
  18. package/dist/grpc/client.d.mts.map +1 -1
  19. package/dist/grpc/client.mjs +1 -1
  20. package/dist/grpc/client.mjs.map +1 -1
  21. package/dist/grpc/core.d.mts +4 -4
  22. package/dist/grpc/core.d.mts.map +1 -1
  23. package/dist/grpc/core.mjs +45 -27
  24. package/dist/grpc/core.mjs.map +1 -1
  25. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  26. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  27. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  28. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  29. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  30. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  31. package/dist/jsonRpc/client.d.mts +160 -0
  32. package/dist/jsonRpc/client.d.mts.map +1 -1
  33. package/dist/jsonRpc/client.mjs +142 -0
  34. package/dist/jsonRpc/client.mjs.map +1 -1
  35. package/dist/jsonRpc/core.d.mts +80 -0
  36. package/dist/jsonRpc/core.d.mts.map +1 -1
  37. package/dist/jsonRpc/core.mjs +80 -0
  38. package/dist/jsonRpc/core.mjs.map +1 -1
  39. package/dist/jsonRpc/errors.d.mts +12 -0
  40. package/dist/jsonRpc/errors.d.mts.map +1 -1
  41. package/dist/jsonRpc/errors.mjs +12 -0
  42. package/dist/jsonRpc/errors.mjs.map +1 -1
  43. package/dist/jsonRpc/http-transport.d.mts +30 -0
  44. package/dist/jsonRpc/http-transport.d.mts.map +1 -1
  45. package/dist/jsonRpc/http-transport.mjs +16 -0
  46. package/dist/jsonRpc/http-transport.mjs.map +1 -1
  47. package/dist/jsonRpc/network.d.mts +4 -0
  48. package/dist/jsonRpc/network.d.mts.map +1 -1
  49. package/dist/jsonRpc/network.mjs +4 -0
  50. package/dist/jsonRpc/network.mjs.map +1 -1
  51. package/dist/jsonRpc/types/chain.d.mts +68 -0
  52. package/dist/jsonRpc/types/chain.d.mts.map +1 -1
  53. package/dist/jsonRpc/types/changes.d.mts +24 -0
  54. package/dist/jsonRpc/types/changes.d.mts.map +1 -1
  55. package/dist/jsonRpc/types/coins.d.mts +4 -0
  56. package/dist/jsonRpc/types/coins.d.mts.map +1 -1
  57. package/dist/jsonRpc/types/common.d.mts +4 -0
  58. package/dist/jsonRpc/types/common.d.mts.map +1 -1
  59. package/dist/jsonRpc/types/generated.d.mts +497 -16
  60. package/dist/jsonRpc/types/generated.d.mts.map +1 -1
  61. package/dist/jsonRpc/types/params.d.mts +289 -41
  62. package/dist/jsonRpc/types/params.d.mts.map +1 -1
  63. package/dist/transactions/Transaction.d.mts +9 -9
  64. package/dist/transactions/Transaction.d.mts.map +1 -1
  65. package/dist/transactions/data/v1.d.mts +220 -220
  66. package/dist/transactions/data/v1.d.mts.map +1 -1
  67. package/dist/transactions/data/v2.d.mts +16 -16
  68. package/dist/transactions/data/v2.d.mts.map +1 -1
  69. package/dist/version.mjs +1 -1
  70. package/dist/version.mjs.map +1 -1
  71. package/package.json +3 -3
  72. package/src/client/core.ts +1 -0
  73. package/src/client/mvr.ts +39 -6
  74. package/src/client/transaction-resolver.ts +1 -0
  75. package/src/graphql/core.ts +2 -0
  76. package/src/graphql/generated/queries.ts +211 -4923
  77. package/src/graphql/queries/transactions.graphql +10 -2
  78. package/src/grpc/client.ts +10 -7
  79. package/src/grpc/core.ts +204 -134
  80. package/src/jsonRpc/client.ts +160 -0
  81. package/src/jsonRpc/core.ts +80 -0
  82. package/src/jsonRpc/errors.ts +12 -0
  83. package/src/jsonRpc/http-transport.ts +30 -0
  84. package/src/jsonRpc/network.ts +4 -0
  85. package/src/jsonRpc/types/chain.ts +68 -0
  86. package/src/jsonRpc/types/changes.ts +24 -0
  87. package/src/jsonRpc/types/coins.ts +4 -0
  88. package/src/jsonRpc/types/common.ts +4 -0
  89. package/src/jsonRpc/types/generated.ts +497 -16
  90. package/src/jsonRpc/types/params.ts +289 -41
  91. package/src/version.ts +1 -1
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.20.2",
6
+ "version": "2.20.4",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -168,8 +168,8 @@
168
168
  "graphql": "^16.14.2",
169
169
  "poseidon-lite": "0.2.1",
170
170
  "valibot": "^1.4.1",
171
- "@mysten/bcs": "^2.1.0",
172
- "@mysten/utils": "^0.4.0"
171
+ "@mysten/utils": "^0.4.0",
172
+ "@mysten/bcs": "^2.1.0"
173
173
  },
174
174
  "scripts": {
175
175
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
@@ -133,6 +133,7 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
133
133
  (
134
134
  await this.core.mvr.resolveType({
135
135
  type: options.name.type,
136
+ signal: options.signal,
136
137
  })
137
138
  ).type,
138
139
  );
package/src/client/mvr.ts CHANGED
@@ -185,13 +185,15 @@ export class MvrClient implements SuiClientTypes.MvrMethods {
185
185
 
186
186
  async resolvePackage({
187
187
  package: name,
188
+ signal,
188
189
  }: SuiClientTypes.MvrResolvePackageOptions): Promise<SuiClientTypes.MvrResolvePackageResponse> {
190
+ signal?.throwIfAborted();
189
191
  if (!hasMvrName(name)) {
190
192
  return {
191
193
  package: name,
192
194
  };
193
195
  }
194
- const resolved = await this.#mvrPackageDataLoader.load(name);
196
+ const resolved = await raceSignal(this.#mvrPackageDataLoader.load(name), signal);
195
197
  return {
196
198
  package: resolved,
197
199
  };
@@ -199,7 +201,9 @@ export class MvrClient implements SuiClientTypes.MvrMethods {
199
201
 
200
202
  async resolveType({
201
203
  type,
204
+ signal,
202
205
  }: SuiClientTypes.MvrResolveTypeOptions): Promise<SuiClientTypes.MvrResolveTypeResponse> {
206
+ signal?.throwIfAborted();
203
207
  if (!hasMvrName(type)) {
204
208
  return {
205
209
  type,
@@ -207,7 +211,7 @@ export class MvrClient implements SuiClientTypes.MvrMethods {
207
211
  }
208
212
 
209
213
  const mvrTypes = [...extractMvrTypes(type)];
210
- const resolvedTypes = await this.#mvrTypeDataLoader.loadMany(mvrTypes);
214
+ const resolvedTypes = await raceSignal(this.#mvrTypeDataLoader.loadMany(mvrTypes), signal);
211
215
 
212
216
  const typeMap: Record<string, string> = {};
213
217
 
@@ -227,7 +231,9 @@ export class MvrClient implements SuiClientTypes.MvrMethods {
227
231
  async resolve({
228
232
  types = [],
229
233
  packages = [],
234
+ signal,
230
235
  }: SuiClientTypes.MvrResolveOptions): Promise<SuiClientTypes.MvrResolveResponse> {
236
+ signal?.throwIfAborted();
231
237
  const mvrTypes = new Set<string>();
232
238
 
233
239
  for (const type of types ?? []) {
@@ -235,10 +241,13 @@ export class MvrClient implements SuiClientTypes.MvrMethods {
235
241
  }
236
242
 
237
243
  const typesArray = [...mvrTypes];
238
- const [resolvedTypes, resolvedPackages] = await Promise.all([
239
- typesArray.length > 0 ? this.#mvrTypeDataLoader.loadMany(typesArray) : [],
240
- packages.length > 0 ? this.#mvrPackageDataLoader.loadMany(packages) : [],
241
- ]);
244
+ const [resolvedTypes, resolvedPackages] = await raceSignal(
245
+ Promise.all([
246
+ typesArray.length > 0 ? this.#mvrTypeDataLoader.loadMany(typesArray) : [],
247
+ packages.length > 0 ? this.#mvrPackageDataLoader.loadMany(packages) : [],
248
+ ]),
249
+ signal,
250
+ );
242
251
 
243
252
  const typeMap: Record<string, string> = {
244
253
  ...this.#overrides?.types,
@@ -378,6 +387,30 @@ export function hasMvrName(nameOrType: string) {
378
387
  );
379
388
  }
380
389
 
390
+ /**
391
+ * Races a promise against an optional AbortSignal. MVR resolution batches lookups
392
+ * from independent callers into a single request via a shared DataLoader, so a
393
+ * caller's signal cannot cancel the shared network request without affecting other
394
+ * callers. Instead, this rejects the awaiting caller as soon as its signal aborts
395
+ * (the underlying request continues in the background).
396
+ *
397
+ * The same isolation applies to any shared/cached request (e.g. `cache.read`).
398
+ */
399
+ export function raceSignal<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T> {
400
+ if (!signal) {
401
+ return promise;
402
+ }
403
+
404
+ return new Promise<T>((resolve, reject) => {
405
+ const onAbort = () => reject(signal.reason);
406
+ signal.addEventListener('abort', onAbort, { once: true });
407
+
408
+ promise.then(resolve, reject).finally(() => {
409
+ signal.removeEventListener('abort', onAbort);
410
+ });
411
+ });
412
+ }
413
+
381
414
  function isStructTag(type: string | StructTag): type is StructTag {
382
415
  return (
383
416
  typeof type === 'object' &&
@@ -288,6 +288,7 @@ export function applyGrpcResolvedTransaction(
288
288
  if (options?.onlyTransactionKind) {
289
289
  transactionData.applyResolvedData({
290
290
  ...resolved,
291
+ sender: null,
291
292
  gasData: {
292
293
  budget: null,
293
294
  owner: null,
@@ -740,6 +740,7 @@ export class GraphQLCoreClient extends CoreClient {
740
740
  doGasSelection:
741
741
  !options.onlyTransactionKind &&
742
742
  (snapshot.gasData.budget == null || snapshot.gasData.payment == null),
743
+ checksEnabled: !options.onlyTransactionKind,
743
744
  },
744
745
  });
745
746
 
@@ -767,6 +768,7 @@ export class GraphQLCoreClient extends CoreClient {
767
768
  if (options.onlyTransactionKind) {
768
769
  transactionData.applyResolvedData({
769
770
  ...resolved,
771
+ sender: null,
770
772
  gasData: {
771
773
  budget: null,
772
774
  owner: null,