@mysten/sui 2.11.0 → 2.12.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 (41) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/index.d.mts +20 -20
  4. package/dist/client/types.d.mts +8 -0
  5. package/dist/client/types.d.mts.map +1 -1
  6. package/dist/cryptography/signature.d.mts +6 -6
  7. package/dist/graphql/core.d.mts.map +1 -1
  8. package/dist/graphql/core.mjs +2 -1
  9. package/dist/graphql/core.mjs.map +1 -1
  10. package/dist/grpc/core.d.mts.map +1 -1
  11. package/dist/grpc/core.mjs +3 -1
  12. package/dist/grpc/core.mjs.map +1 -1
  13. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  14. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  15. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  16. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  17. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  18. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
  19. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  20. package/dist/jsonRpc/core.d.mts.map +1 -1
  21. package/dist/jsonRpc/core.mjs +30 -20
  22. package/dist/jsonRpc/core.mjs.map +1 -1
  23. package/dist/transactions/Transaction.d.mts +9 -9
  24. package/dist/transactions/Transaction.d.mts.map +1 -1
  25. package/dist/transactions/data/v1.d.mts +220 -220
  26. package/dist/transactions/data/v1.d.mts.map +1 -1
  27. package/dist/transactions/data/v2.d.mts +16 -16
  28. package/dist/transactions/data/v2.d.mts.map +1 -1
  29. package/dist/version.mjs +1 -1
  30. package/dist/version.mjs.map +1 -1
  31. package/dist/zklogin/bcs.d.mts +14 -14
  32. package/dist/zklogin/bcs.d.mts.map +1 -1
  33. package/docs/clients/core.md +15 -0
  34. package/docs/migrations/sui-2.0/json-rpc-migration.md +17 -1
  35. package/docs/utils/derived_objects.md +21 -0
  36. package/package.json +3 -3
  37. package/src/client/types.ts +8 -0
  38. package/src/graphql/core.ts +1 -0
  39. package/src/grpc/core.ts +5 -0
  40. package/src/jsonRpc/core.ts +50 -29
  41. package/src/version.ts +1 -1
@@ -1,31 +1,31 @@
1
- import * as _mysten_bcs817 from "@mysten/bcs";
1
+ import * as _mysten_bcs1111 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_bcs817.BcsStruct<{
6
- inputs: _mysten_bcs817.BcsStruct<{
7
- proofPoints: _mysten_bcs817.BcsStruct<{
8
- a: _mysten_bcs817.BcsType<string[], Iterable<string> & {
5
+ declare const zkLoginSignature: _mysten_bcs1111.BcsStruct<{
6
+ inputs: _mysten_bcs1111.BcsStruct<{
7
+ proofPoints: _mysten_bcs1111.BcsStruct<{
8
+ a: _mysten_bcs1111.BcsType<string[], Iterable<string> & {
9
9
  length: number;
10
10
  }, string>;
11
- b: _mysten_bcs817.BcsType<string[][], Iterable<Iterable<string> & {
11
+ b: _mysten_bcs1111.BcsType<string[][], Iterable<Iterable<string> & {
12
12
  length: number;
13
13
  }> & {
14
14
  length: number;
15
15
  }, string>;
16
- c: _mysten_bcs817.BcsType<string[], Iterable<string> & {
16
+ c: _mysten_bcs1111.BcsType<string[], Iterable<string> & {
17
17
  length: number;
18
18
  }, string>;
19
19
  }, string>;
20
- issBase64Details: _mysten_bcs817.BcsStruct<{
21
- value: _mysten_bcs817.BcsType<string, string, "string">;
22
- indexMod4: _mysten_bcs817.BcsType<number, number, "u8">;
20
+ issBase64Details: _mysten_bcs1111.BcsStruct<{
21
+ value: _mysten_bcs1111.BcsType<string, string, "string">;
22
+ indexMod4: _mysten_bcs1111.BcsType<number, number, "u8">;
23
23
  }, string>;
24
- headerBase64: _mysten_bcs817.BcsType<string, string, "string">;
25
- addressSeed: _mysten_bcs817.BcsType<string, string, "string">;
24
+ headerBase64: _mysten_bcs1111.BcsType<string, string, "string">;
25
+ addressSeed: _mysten_bcs1111.BcsType<string, string, "string">;
26
26
  }, string>;
27
- maxEpoch: _mysten_bcs817.BcsType<string, string | number | bigint, "u64">;
28
- userSignature: _mysten_bcs817.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
27
+ maxEpoch: _mysten_bcs1111.BcsType<string, string | number | bigint, "u64">;
28
+ userSignature: _mysten_bcs1111.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
29
29
  }, string>;
30
30
  type ZkLoginSignature = InferBcsInput<typeof zkLoginSignature>;
31
31
  type ZkLoginSignatureInputs = ZkLoginSignature['inputs'];
@@ -1 +1 @@
1
- {"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"sourcesContent":[],"mappings":";;;;cAMa,iCAAgB;;;MAAhB,CAAA,wBAgBX,CAAA,MAAA,EAAA,UAAA,CAAA,MAAA,CAAA,GAAA;;;;;;;;;;;;;;;;;;;;eAhB2B,wBAAA,WAAA,gBAAA,CAAA,UAAA,CAAA,MAAA,CAAA,EAAA,YAAA,CAAA;CAAA,EAAA,MAAA,CAAA;AAkBjB,KAAA,gBAAA,GAAmB,aAAqB,CAAA,OAAA,gBAAR,CAAA;AAChC,KAAA,sBAAA,GAAyB,gBAAA,CAAA,QAAgB,CAAA"}
1
+ {"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"sourcesContent":[],"mappings":";;;;cAMa,kCAAgB;;;MAAhB,CAAA,yBAgBX,CAAA,MAAA,EAAA,UAAA,CAAA,MAAA,CAAA,GAAA;;;;;;;;;;;;;;;;;;;;eAhB2B,yBAAA,WAAA,gBAAA,CAAA,UAAA,CAAA,MAAA,CAAA,EAAA,YAAA,CAAA;CAAA,EAAA,MAAA,CAAA;AAkBjB,KAAA,gBAAA,GAAmB,aAAqB,CAAA,OAAA,gBAAR,CAAA;AAChC,KAAA,sBAAA,GAAyB,gBAAA,CAAA,QAAgB,CAAA"}
@@ -342,6 +342,21 @@ console.log(result.effects);
342
342
  console.log(result.balanceChanges);
343
343
  ```
344
344
 
345
+ #### Disabling Checks
346
+
347
+ By default, `simulateTransaction` runs with full transaction validation. For example when inspecting
348
+ non-public or non-entry Move functions set `checksEnabled: false`:
349
+
350
+ ```typescript
351
+ const result = await client.core.simulateTransaction({
352
+ transaction: transactionBytes,
353
+ checksEnabled: false,
354
+ include: {
355
+ commandResults: true,
356
+ },
357
+ });
358
+ ```
359
+
345
360
  ### signAndExecuteTransaction
346
361
 
347
362
  Sign and execute a transaction in one step.
@@ -54,11 +54,27 @@ These JSON-RPC methods have direct replacements in the core API:
54
54
  | `multiGetObjects` | `getObjects` |
55
55
  | `getDynamicFields` | `listDynamicFields` |
56
56
  | `getDynamicFieldObject` | `getDynamicField` |
57
- | `devInspectTransactionBlock` | `simulateTransaction` |
57
+ | `devInspectTransactionBlock` | `simulateTransaction` with `checksEnabled: false` |
58
58
  | `dryRunTransactionBlock` | `simulateTransaction` |
59
59
  | `getNormalizedMoveFunction` | `getMoveFunction` |
60
60
  | `getMoveFunctionArgTypes` | `getMoveFunction` |
61
61
 
62
+ ### Example: Migrating devInspectTransactionBlock
63
+
64
+ ```diff
65
+ - const result = await jsonRpcClient.devInspectTransactionBlock({
66
+ - sender: '0xabc...',
67
+ - transactionBlock: tx,
68
+ - });
69
+ - const returnValues = result.results?.[0]?.returnValues;
70
+ + const result = await client.core.simulateTransaction({
71
+ + transaction: tx,
72
+ + checksEnabled: false,
73
+ + include: { commandResults: true },
74
+ + });
75
+ + const returnValues = result.commandResults?.[0]?.returnValues;
76
+ ```
77
+
62
78
  ### Example: Migrating getOwnedObjects
63
79
 
64
80
  ```diff
@@ -57,3 +57,24 @@ const key = bcsType.serialize({ value: 1 }).toBytes();
57
57
  // Derive the object ID for the key `DemoStruct { value: 1 }`.
58
58
  deriveObjectID('0xc0ffee', `0xc0ffee::demo::DemoStruct`, key);
59
59
  ```
60
+
61
+ ### Deriving with fieldless structs
62
+
63
+ In Move, structs with no user-defined fields automatically get a `dummy_field: bool` injected by the
64
+ compiler. This means their BCS encoding is not empty — it's a single `0x00` byte (the encoding of
65
+ `false`). You can treat this as a constant.
66
+
67
+ A real-world example is `0x2::coin_registry::CurrencyKey<T>`, which is a fieldless generic struct
68
+ used to derive `Currency` objects from the coin registry (`0xc`) based on their type:
69
+
70
+ ```typescript
71
+ // On-chain: `public struct CurrencyKey<phantom T>() has copy, store, drop`
72
+ // The compiler injects `dummy_field: bool`, always `false`.
73
+ const key = new Uint8Array([0]);
74
+
75
+ const coinType = '0x2::sui::SUI';
76
+ const currencyId = deriveObjectID('0xc', `0x2::coin_registry::CurrencyKey<${coinType}>`, key);
77
+ ```
78
+
79
+ This applies to any struct with no fields — phantom type parameters don't add any BCS-encoded data,
80
+ so the key is always `new Uint8Array([0])`.
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.11.0",
6
+ "version": "2.12.0",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -167,8 +167,8 @@
167
167
  "graphql": "^16.12.0",
168
168
  "poseidon-lite": "0.2.1",
169
169
  "valibot": "^1.2.0",
170
- "@mysten/utils": "^0.3.1",
171
- "@mysten/bcs": "^2.0.3"
170
+ "@mysten/bcs": "^2.0.3",
171
+ "@mysten/utils": "^0.3.1"
172
172
  },
173
173
  "scripts": {
174
174
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
@@ -442,6 +442,14 @@ export namespace SuiClientTypes {
442
442
  > extends CoreClientMethodOptions {
443
443
  transaction: Uint8Array | TransactionInstance;
444
444
  include?: Include & SimulateTransactionInclude;
445
+ /**
446
+ * When set to `false`, disables transaction validation checks during simulation.
447
+ * This allows inspecting non-public/non-entry Move functions and other transactions
448
+ * that would normally fail validation.
449
+ *
450
+ * Defaults to `true` (checks enabled).
451
+ */
452
+ checksEnabled?: boolean;
445
453
  }
446
454
 
447
455
  export interface GetReferenceGasPriceOptions extends CoreClientMethodOptions {}
@@ -406,6 +406,7 @@ export class GraphQLCoreClient extends CoreClient {
406
406
  includeObjectTypes: options.include?.objectTypes ?? false,
407
407
  includeCommandResults: options.include?.commandResults ?? false,
408
408
  includeBcs: options.include?.bcs ?? false,
409
+ checksEnabled: options.checksEnabled ?? true,
409
410
  },
410
411
  },
411
412
  (result) => result.simulateTransaction,
package/src/grpc/core.ts CHANGED
@@ -44,6 +44,7 @@ import {
44
44
  grpcTransactionToTransactionData,
45
45
  } from '../client/transaction-resolver.js';
46
46
  import { Value } from './proto/google/protobuf/struct.js';
47
+ import { SimulateTransactionRequest_TransactionChecks } from './proto/sui/rpc/v2/transaction_execution_service.js';
47
48
 
48
49
  export interface GrpcCoreClientOptions extends CoreClientOptions {
49
50
  client: SuiGrpcClient;
@@ -447,6 +448,10 @@ export class GrpcCoreClient extends CoreClient {
447
448
  paths,
448
449
  },
449
450
  doGasSelection: false,
451
+ checks:
452
+ options.checksEnabled === false
453
+ ? SimulateTransactionRequest_TransactionChecks.DISABLED
454
+ : SimulateTransactionRequest_TransactionChecks.ENABLED,
450
455
  });
451
456
 
452
457
  const transactionResult = parseTransaction(response.transaction!, options.include);
@@ -5,6 +5,8 @@ import { fromBase64, type InferBcsInput } from '@mysten/bcs';
5
5
 
6
6
  import { bcs, TypeTagSerializer } from '../bcs/index.js';
7
7
  import type {
8
+ DevInspectResults,
9
+ DryRunTransactionBlockResponse,
8
10
  ExecutionStatus as JsonRpcExecutionStatus,
9
11
  ObjectOwner,
10
12
  SuiMoveAbilitySet,
@@ -356,14 +358,44 @@ export class JSONRpcCoreClient extends CoreClient {
356
358
  })
357
359
  : (options.transaction as Uint8Array);
358
360
 
359
- const result = await this.#jsonRpcClient.dryRunTransactionBlock({
360
- transactionBlock: transactionBytes,
361
- signal: options.signal,
362
- });
361
+ const sender = tx.getData().sender ?? normalizeSuiAddress('0x0');
362
+ const checksDisabled = options.checksEnabled === false;
363
+
364
+ let dryRunResult: DryRunTransactionBlockResponse | null = null;
365
+ try {
366
+ dryRunResult = await this.#jsonRpcClient.dryRunTransactionBlock({
367
+ transactionBlock: transactionBytes,
368
+ signal: options.signal,
369
+ });
370
+ } catch (e) {
371
+ if (!checksDisabled) {
372
+ throw e;
373
+ }
374
+ }
375
+
376
+ let devInspectResult: DevInspectResults | null = null;
377
+ if (options.include?.commandResults || checksDisabled) {
378
+ try {
379
+ devInspectResult = await this.#jsonRpcClient.devInspectTransactionBlock({
380
+ sender,
381
+ transactionBlock: tx,
382
+ signal: options.signal,
383
+ });
384
+ } catch {}
385
+ }
386
+
387
+ const dryRunFailed = !dryRunResult || dryRunResult.effects.status.status !== 'success';
388
+ const effectsSource =
389
+ checksDisabled && dryRunFailed && devInspectResult
390
+ ? devInspectResult
391
+ : (dryRunResult ?? devInspectResult);
392
+ if (!effectsSource) {
393
+ throw new Error('simulateTransaction failed: no results from dryRun or devInspect');
394
+ }
363
395
 
364
396
  const { effects, objectTypes } = parseTransactionEffectsJson({
365
- effects: result.effects,
366
- objectChanges: result.objectChanges,
397
+ effects: effectsSource.effects,
398
+ objectChanges: dryRunResult?.objectChanges ?? [],
367
399
  });
368
400
 
369
401
  const transactionData: SuiClientTypes.Transaction<Include> = {
@@ -391,15 +423,15 @@ export class JSONRpcCoreClient extends CoreClient {
391
423
  bcs: (options.include?.bcs
392
424
  ? transactionBytes
393
425
  : undefined) as SuiClientTypes.Transaction<Include>['bcs'],
394
- balanceChanges: (options.include?.balanceChanges
395
- ? result.balanceChanges.map((change) => ({
426
+ balanceChanges: (options.include?.balanceChanges && dryRunResult
427
+ ? dryRunResult.balanceChanges.map((change) => ({
396
428
  coinType: normalizeStructTag(change.coinType),
397
429
  address: parseOwnerAddress(change.owner)!,
398
430
  amount: change.amount,
399
431
  }))
400
432
  : undefined) as SuiClientTypes.Transaction<Include>['balanceChanges'],
401
433
  events: (options.include?.events
402
- ? (result.events?.map((event) => ({
434
+ ? (effectsSource.events?.map((event) => ({
403
435
  packageId: event.packageId,
404
436
  module: event.transactionModule,
405
437
  sender: event.sender,
@@ -411,26 +443,15 @@ export class JSONRpcCoreClient extends CoreClient {
411
443
  };
412
444
 
413
445
  let commandResults: SuiClientTypes.CommandResult[] | undefined;
414
- if (options.include?.commandResults) {
415
- try {
416
- const sender = tx.getData().sender ?? normalizeSuiAddress('0x0');
417
- const devInspectResult = await this.#jsonRpcClient.devInspectTransactionBlock({
418
- sender,
419
- transactionBlock: tx,
420
- signal: options.signal,
421
- });
422
-
423
- if (devInspectResult.results) {
424
- commandResults = devInspectResult.results.map((result) => ({
425
- returnValues: (result.returnValues ?? []).map(([bytes]) => ({
426
- bcs: new Uint8Array(bytes),
427
- })),
428
- mutatedReferences: (result.mutableReferenceOutputs ?? []).map(([, bytes]) => ({
429
- bcs: new Uint8Array(bytes),
430
- })),
431
- }));
432
- }
433
- } catch {}
446
+ if (options.include?.commandResults && devInspectResult?.results) {
447
+ commandResults = devInspectResult.results.map((result) => ({
448
+ returnValues: (result.returnValues ?? []).map(([bytes]) => ({
449
+ bcs: new Uint8Array(bytes),
450
+ })),
451
+ mutatedReferences: (result.mutableReferenceOutputs ?? []).map(([, bytes]) => ({
452
+ bcs: new Uint8Array(bytes),
453
+ })),
454
+ }));
434
455
  }
435
456
 
436
457
  return effects.status.success
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.11.0';
6
+ export const PACKAGE_VERSION = '2.12.0';
7
7
  export const TARGETED_RPC_VERSION = '1.69.0';