@mysten/sui 2.34.0 → 2.35.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 (60) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/client/core-resolver.mjs +1 -1
  3. package/dist/client/types.d.mts +18 -1
  4. package/dist/client/types.d.mts.map +1 -1
  5. package/dist/client/utils.d.mts.map +1 -1
  6. package/dist/client/utils.mjs +10 -1
  7. package/dist/client/utils.mjs.map +1 -1
  8. package/dist/cryptography/signature.d.mts +6 -6
  9. package/dist/graphql/client.d.mts +4 -3
  10. package/dist/graphql/client.d.mts.map +1 -1
  11. package/dist/graphql/client.mjs.map +1 -1
  12. package/dist/graphql/core.d.mts.map +1 -1
  13. package/dist/graphql/core.mjs +7 -4
  14. package/dist/graphql/core.mjs.map +1 -1
  15. package/dist/graphql/generated/queries.mjs +7 -0
  16. package/dist/graphql/generated/queries.mjs.map +1 -1
  17. package/dist/grpc/client.d.mts +4 -3
  18. package/dist/grpc/client.d.mts.map +1 -1
  19. package/dist/grpc/client.mjs.map +1 -1
  20. package/dist/grpc/core.d.mts.map +1 -1
  21. package/dist/grpc/core.mjs +8 -4
  22. package/dist/grpc/core.mjs.map +1 -1
  23. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
  24. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  25. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  26. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  27. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  28. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  29. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  30. package/dist/jsonRpc/core.d.mts.map +1 -1
  31. package/dist/jsonRpc/core.mjs +7 -4
  32. package/dist/jsonRpc/core.mjs.map +1 -1
  33. package/dist/transactions/Transaction.d.mts +10 -8
  34. package/dist/transactions/Transaction.d.mts.map +1 -1
  35. package/dist/transactions/Transaction.mjs +4 -2
  36. package/dist/transactions/Transaction.mjs.map +1 -1
  37. package/dist/utils/constants.d.mts +6 -1
  38. package/dist/utils/constants.d.mts.map +1 -1
  39. package/dist/utils/constants.mjs +6 -1
  40. package/dist/utils/constants.mjs.map +1 -1
  41. package/dist/utils/index.d.mts +2 -2
  42. package/dist/utils/index.mjs +2 -2
  43. package/dist/version.mjs +1 -1
  44. package/dist/version.mjs.map +1 -1
  45. package/dist/zklogin/bcs.d.mts +14 -14
  46. package/docs/clients/executing.md +7 -1
  47. package/package.json +1 -1
  48. package/src/client/types.ts +18 -1
  49. package/src/client/utils.ts +10 -0
  50. package/src/graphql/client.ts +4 -3
  51. package/src/graphql/core.ts +9 -3
  52. package/src/graphql/generated/queries.ts +8 -1
  53. package/src/graphql/queries/transactions.graphql +7 -0
  54. package/src/grpc/client.ts +4 -3
  55. package/src/grpc/core.ts +11 -4
  56. package/src/jsonRpc/core.ts +5 -0
  57. package/src/transactions/Transaction.ts +4 -2
  58. package/src/utils/constants.ts +6 -0
  59. package/src/utils/index.ts +1 -0
  60. package/src/version.ts +1 -1
@@ -43,6 +43,7 @@ import { chunk, fromBase64, toBase64 } from '@mysten/utils';
43
43
  import { normalizeStructTag, normalizeSuiAddress } from '../utils/sui-types.js';
44
44
  import {
45
45
  formatMoveAbortMessage,
46
+ isMockedGasObjectId,
46
47
  parseTransactionEffectsBcs,
47
48
  transactionBytesHaveEmptyGasPayment,
48
49
  } from '../client/utils.js';
@@ -422,9 +423,9 @@ export class GraphQLCoreClient extends CoreClient {
422
423
  await options.transaction.prepareForSerialization({ client: this });
423
424
  }
424
425
 
425
- // A gas payment explicitly set to an empty list means gas is paid from the sender's
426
- // address balance, so the server needs to perform gas selection rather than simulating
427
- // with a mocked gas coin.
426
+ // A gas payment explicitly set to an empty list means the server should select real gas
427
+ // (from the sender's address balance or coin objects) rather than simulating with a
428
+ // mocked gas coin.
428
429
  const doGasSelection =
429
430
  options.doGasSelection ??
430
431
  (options.transaction instanceof Uint8Array
@@ -459,6 +460,9 @@ export class GraphQLCoreClient extends CoreClient {
459
460
  );
460
461
 
461
462
  const transactionResult = parseTransaction(result.effects?.transaction!, options.include);
463
+ const gasPaymentMocked = isMockedGasObjectId(
464
+ result.effects?.transaction?.effects?.gasEffects?.gasObject?.address,
465
+ );
462
466
 
463
467
  const commandResults =
464
468
  options.include?.commandResults && result.outputs
@@ -478,6 +482,7 @@ export class GraphQLCoreClient extends CoreClient {
478
482
  Transaction: transactionResult.Transaction,
479
483
  commandResults:
480
484
  commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
485
+ gasPaymentMocked,
481
486
  };
482
487
  } else {
483
488
  return {
@@ -485,6 +490,7 @@ export class GraphQLCoreClient extends CoreClient {
485
490
  FailedTransaction: transactionResult.FailedTransaction,
486
491
  commandResults:
487
492
  commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
493
+ gasPaymentMocked,
488
494
  };
489
495
  }
490
496
  }
@@ -380,7 +380,7 @@ export type SimulateTransactionQueryVariables = Exact<{
380
380
  }>;
381
381
 
382
382
 
383
- export type SimulateTransactionQuery = { simulateTransaction: { effects: { transaction: { digest: string, transactionJson?: unknown, transactionBcs?: string | null, signatures: Array<{ signatureBytes: string | null }>, effects: { status: ExecutionStatus | null, timestamp: string | null, effectsBcs?: string | null, effectsJson?: unknown, balanceChangesJson?: unknown, checkpoint: { sequenceNumber: number } | null, executionError: { message: string, abortCode: string | null, identifier: string | null, constant: string | null, sourceLineNumber: number | null, instructionOffset: number | null, module: { name: string, package: { address: string } | null } | null, function: { name: string } | null } | null, epoch: { epochId: number } | null, objectChanges?: { nodes: Array<{ address: string, outputState: { asMoveObject: { contents: { type: { repr: string } | null } | null } | null } | null }> } | null, events?: { pageInfo: { hasNextPage: boolean }, nodes: Array<{ transactionModule: { name: string, package: { address: string } | null } | null, sender: { address: string } | null, contents: { bcs: string | null, json: unknown, type: { repr: string } | null } | null }> } | null } | null } | null } | null, outputs?: Array<{ returnValues: Array<{ value: { bcs: string | null } | null }> | null, mutatedReferences: Array<{ value: { bcs: string | null } | null }> | null }> | null } };
383
+ export type SimulateTransactionQuery = { simulateTransaction: { effects: { transaction: { digest: string, transactionJson?: unknown, transactionBcs?: string | null, effects: { status: ExecutionStatus | null, timestamp: string | null, effectsBcs?: string | null, effectsJson?: unknown, balanceChangesJson?: unknown, gasEffects: { gasObject: { address: string } | null } | null, checkpoint: { sequenceNumber: number } | null, executionError: { message: string, abortCode: string | null, identifier: string | null, constant: string | null, sourceLineNumber: number | null, instructionOffset: number | null, module: { name: string, package: { address: string } | null } | null, function: { name: string } | null } | null, epoch: { epochId: number } | null, objectChanges?: { nodes: Array<{ address: string, outputState: { asMoveObject: { contents: { type: { repr: string } | null } | null } | null } | null }> } | null, events?: { pageInfo: { hasNextPage: boolean }, nodes: Array<{ transactionModule: { name: string, package: { address: string } | null } | null, sender: { address: string } | null, contents: { bcs: string | null, json: unknown, type: { repr: string } | null } | null }> } | null } | null, signatures: Array<{ signatureBytes: string | null }> } | null } | null, outputs?: Array<{ returnValues: Array<{ value: { bcs: string | null } | null }> | null, mutatedReferences: Array<{ value: { bcs: string | null } | null }> | null }> | null } };
384
384
 
385
385
  export type ExecuteTransactionMutationVariables = Exact<{
386
386
  transactionDataBcs: string;
@@ -1047,6 +1047,13 @@ export const SimulateTransactionDocument = new TypedDocumentString(`
1047
1047
  effects {
1048
1048
  transaction {
1049
1049
  ...TRANSACTION_FIELDS
1050
+ effects {
1051
+ gasEffects {
1052
+ gasObject {
1053
+ address
1054
+ }
1055
+ }
1056
+ }
1050
1057
  }
1051
1058
  }
1052
1059
  outputs @include(if: $includeCommandResults) {
@@ -21,6 +21,13 @@ query simulateTransaction(
21
21
  effects {
22
22
  transaction {
23
23
  ...TRANSACTION_FIELDS
24
+ effects {
25
+ gasEffects {
26
+ gasObject {
27
+ address
28
+ }
29
+ }
30
+ }
24
31
  }
25
32
  }
26
33
  outputs @include(if: $includeCommandResults) {
@@ -130,9 +130,10 @@ export interface GrpcSimulateTransactionOptions<
130
130
  * Overrides whether the server selects gas payment during simulation.
131
131
  *
132
132
  * When not set, gas selection is enabled only when the transaction's gas payment is explicitly
133
- * set to an empty list (`[]`), which indicates gas is paid from the sender's address balance.
134
- * Transactions with gas coins set are simulated as-is, and transactions without a gas payment
135
- * are simulated with a mocked gas coin.
133
+ * set to an empty list (`[]`); the server then pays gas from the sender's address balance or
134
+ * coin objects. Transactions with gas coins set are simulated as-is, and transactions without a
135
+ * gas payment are simulated with a mocked gas coin (reported as `gasPaymentMocked` on the
136
+ * result).
136
137
  */
137
138
  doGasSelection?: boolean;
138
139
  }
package/src/grpc/core.ts CHANGED
@@ -50,7 +50,7 @@ import {
50
50
  grpcTransactionToTransactionData,
51
51
  } from '../client/transaction-resolver.js';
52
52
  import { setAddressBalanceTransactionExpirationFromSimulatedEpoch } from '../client/address-balance-transaction-expiration.js';
53
- import { transactionBytesHaveEmptyGasPayment } from '../client/utils.js';
53
+ import { isMockedGasObjectId, transactionBytesHaveEmptyGasPayment } from '../client/utils.js';
54
54
  import { Value } from './proto/google/protobuf/struct.js';
55
55
  import { ExecutedTransaction } from './proto/sui/rpc/v2/executed_transaction.js';
56
56
  import {
@@ -457,14 +457,18 @@ export class GrpcCoreClient extends CoreClient {
457
457
  if (options.include?.commandResults) {
458
458
  paths.push('command_outputs');
459
459
  }
460
+ if (!options.include?.effects) {
461
+ // The gas object ID is always needed to report whether a mocked gas coin was used
462
+ paths.push('transaction.effects.gas_object.object_id');
463
+ }
460
464
 
461
465
  if (!(options.transaction instanceof Uint8Array)) {
462
466
  await options.transaction.prepareForSerialization({ client: this });
463
467
  }
464
468
 
465
- // A gas payment explicitly set to an empty list means gas is paid from the sender's
466
- // address balance, so the server needs to perform gas selection rather than simulating
467
- // with a mocked gas coin.
469
+ // A gas payment explicitly set to an empty list means the server should select real gas
470
+ // (from the sender's address balance or coin objects) rather than simulating with a
471
+ // mocked gas coin.
468
472
  const doGasSelection =
469
473
  options.doGasSelection ??
470
474
  (options.transaction instanceof Uint8Array
@@ -1621,6 +1625,7 @@ export function parseGrpcSimulateTransactionResponse<
1621
1625
  ): SuiClientTypes.SimulateTransactionResult<Include> {
1622
1626
  const include = options?.include;
1623
1627
  const transactionResult = parseGrpcTransactionResponse(response.transaction!, { include });
1628
+ const gasPaymentMocked = isMockedGasObjectId(response.transaction?.effects?.gasObject?.objectId);
1624
1629
 
1625
1630
  const commandResults =
1626
1631
  include?.commandResults && response.commandOutputs
@@ -1640,6 +1645,7 @@ export function parseGrpcSimulateTransactionResponse<
1640
1645
  Transaction: transactionResult.Transaction,
1641
1646
  commandResults:
1642
1647
  commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
1648
+ gasPaymentMocked,
1643
1649
  };
1644
1650
  }
1645
1651
 
@@ -1648,6 +1654,7 @@ export function parseGrpcSimulateTransactionResponse<
1648
1654
  FailedTransaction: transactionResult.FailedTransaction,
1649
1655
  commandResults:
1650
1656
  commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
1657
+ gasPaymentMocked,
1651
1658
  };
1652
1659
  }
1653
1660
 
@@ -43,6 +43,7 @@ import {
43
43
  parseTransactionBcs,
44
44
  parseTransactionEffectsBcs,
45
45
  } from '../client/index.js';
46
+ import { isMockedGasObjectId } from '../client/utils.js';
46
47
  import type { SuiJsonRpcClient } from './client.js';
47
48
  import { JsonRpcError } from './errors.js';
48
49
 
@@ -576,18 +577,22 @@ export class JSONRpcCoreClient extends CoreClient {
576
577
  }));
577
578
  }
578
579
 
580
+ const gasPaymentMocked = isMockedGasObjectId(effects.gasObject?.objectId);
581
+
579
582
  return effects.status.success
580
583
  ? {
581
584
  $kind: 'Transaction',
582
585
  Transaction: transactionData,
583
586
  commandResults:
584
587
  commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
588
+ gasPaymentMocked,
585
589
  }
586
590
  : {
587
591
  $kind: 'FailedTransaction',
588
592
  FailedTransaction: transactionData,
589
593
  commandResults:
590
594
  commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
595
+ gasPaymentMocked,
591
596
  };
592
597
  }
593
598
  /**
@@ -355,7 +355,8 @@ export class Transaction {
355
355
 
356
356
  /**
357
357
  * Creates a Coin<T> of the specified type and amount (defaults to SUI).
358
- * Sourced from address balance when available, falling back to owned coins.
358
+ * Sourced from address balance when available, falling back to owned coins. For SUI, falls back
359
+ * to the gas coin instead unless `useGasCoin` is `false`.
359
360
  * With `allowance`, spends only from the funder's address balance under that allowance.
360
361
  * Allowance IDs are resolved using the build client; app-bound allowances also require an app type and SpendPermit.
361
362
  */
@@ -370,7 +371,8 @@ export class Transaction {
370
371
 
371
372
  /**
372
373
  * Creates a Balance<T> of the specified type and amount (defaults to SUI).
373
- * Sourced from address balance when available, falling back to owned coins.
374
+ * Sourced from address balance when available, falling back to owned coins. For SUI, falls back
375
+ * to the gas coin instead unless `useGasCoin` is `false`.
374
376
  * With `allowance`, spends only from the funder's address balance under that allowance.
375
377
  * Allowance IDs are resolved using the build client; app-bound allowances also require an app type and SpendPermit.
376
378
  */
@@ -22,3 +22,9 @@ export const SUI_COIN_REGISTRY_OBJECT_ID =
22
22
  '0x000000000000000000000000000000000000000000000000000000000000000c';
23
23
  export const SUI_DENY_LIST_OBJECT_ID =
24
24
  '0x0000000000000000000000000000000000000000000000000000000000000403';
25
+ /**
26
+ * Object ID of the gas coin the node substitutes when a transaction is simulated without a gas
27
+ * payment. See `gasPaymentMocked` on `SimulateTransactionResult`.
28
+ */
29
+ export const MOCKED_GAS_OBJECT_ID =
30
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
@@ -30,6 +30,7 @@ export {
30
30
  SUI_RANDOM_OBJECT_ID,
31
31
  SUI_COIN_REGISTRY_OBJECT_ID,
32
32
  SUI_DENY_LIST_OBJECT_ID,
33
+ MOCKED_GAS_OBJECT_ID,
33
34
  } from './constants.js';
34
35
 
35
36
  export { isValidNamedPackage, isValidNamedType } from './move-registry.js';
package/src/version.ts CHANGED
@@ -3,4 +3,4 @@
3
3
 
4
4
  // This file is generated by genversion.mjs. Do not edit it directly.
5
5
 
6
- export const PACKAGE_VERSION = '2.34.0';
6
+ export const PACKAGE_VERSION = '2.35.0';