@mysten/sui 2.26.1 → 2.27.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 (71) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/bcs/pure.d.mts.map +1 -1
  3. package/dist/bcs/pure.mjs.map +1 -1
  4. package/dist/client/types.d.mts +10 -0
  5. package/dist/client/types.d.mts.map +1 -1
  6. package/dist/client/utils.mjs +67 -2
  7. package/dist/client/utils.mjs.map +1 -1
  8. package/dist/cryptography/signature-scheme.d.mts.map +1 -1
  9. package/dist/cryptography/signature-scheme.mjs.map +1 -1
  10. package/dist/cryptography/signature.d.mts +6 -6
  11. package/dist/graphql/client.d.mts.map +1 -1
  12. package/dist/graphql/client.mjs.map +1 -1
  13. package/dist/graphql/core.d.mts.map +1 -1
  14. package/dist/graphql/core.mjs +3 -0
  15. package/dist/graphql/core.mjs.map +1 -1
  16. package/dist/graphql/generated/queries.mjs +20 -0
  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.map +1 -1
  20. package/dist/grpc/core.d.mts.map +1 -1
  21. package/dist/grpc/core.mjs +6 -2
  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 +4 -0
  32. package/dist/jsonRpc/core.mjs.map +1 -1
  33. package/dist/transactions/Transaction.d.mts.map +1 -1
  34. package/dist/transactions/Transaction.mjs.map +1 -1
  35. package/dist/transactions/executor/parallel.d.mts.map +1 -1
  36. package/dist/transactions/executor/parallel.mjs.map +1 -1
  37. package/dist/transactions/executor/serial.d.mts.map +1 -1
  38. package/dist/transactions/executor/serial.mjs.map +1 -1
  39. package/dist/version.mjs +1 -1
  40. package/dist/version.mjs.map +1 -1
  41. package/docs/clients/grpc.md +1 -1
  42. package/docs/clients/index.md +1 -1
  43. package/docs/cryptography/index.md +1 -1
  44. package/docs/cryptography/keypairs.md +1 -1
  45. package/docs/cryptography/signers/index.md +1 -1
  46. package/docs/cryptography/signers/webcrypto.md +1 -1
  47. package/docs/llms-index.md +11 -11
  48. package/docs/migrations/0.38.md +1 -1
  49. package/docs/migrations/sui-2.0/dapp-kit.md +2 -3
  50. package/docs/migrations/sui-2.0/kiosk.md +1 -1
  51. package/docs/migrations/sui-2.0/sui.md +1 -1
  52. package/docs/transactions/signing-and-execution.md +14 -25
  53. package/docs/utils/derived_objects.md +1 -1
  54. package/docs/utils/index.md +1 -1
  55. package/package.json +25 -25
  56. package/src/bcs/pure.ts +1 -10
  57. package/src/bcs/types.ts +1 -3
  58. package/src/client/types.ts +11 -2
  59. package/src/client/utils.ts +99 -2
  60. package/src/cryptography/signature-scheme.ts +1 -6
  61. package/src/graphql/client.ts +1 -4
  62. package/src/graphql/core.ts +37 -36
  63. package/src/graphql/generated/queries.ts +25 -5
  64. package/src/graphql/queries/transactions.graphql +4 -0
  65. package/src/grpc/client.ts +1 -2
  66. package/src/grpc/core.ts +42 -34
  67. package/src/jsonRpc/core.ts +27 -27
  68. package/src/transactions/Transaction.ts +1 -2
  69. package/src/transactions/executor/parallel.ts +1 -2
  70. package/src/transactions/executor/serial.ts +1 -2
  71. package/src/version.ts +1 -1
package/src/grpc/core.ts CHANGED
@@ -240,28 +240,26 @@ export class GrpcCoreClient extends CoreClient {
240
240
  { abort: options.signal },
241
241
  );
242
242
 
243
- const objects = response.response.objects.map(
244
- (object): SuiClientTypes.Object<Include> => ({
245
- objectId: object.objectId!,
246
- version: object.version?.toString()!,
247
- digest: object.digest!,
248
- content: object.contents?.value as SuiClientTypes.Object<Include>['content'],
249
- owner: mapOwner(object.owner)!,
250
- type: object.objectType!,
251
- previousTransaction: (object.previousTransaction ??
252
- undefined) as SuiClientTypes.Object<Include>['previousTransaction'],
253
- objectBcs: object.bcs?.value as SuiClientTypes.Object<Include>['objectBcs'],
254
- json: (options.include?.json
255
- ? object.json
256
- ? (Value.toJson(object.json) as Record<string, unknown>)
257
- : null
258
- : undefined) as SuiClientTypes.Object<Include>['json'],
259
- display: mapDisplayProto(
260
- options.include?.display,
261
- object.display,
262
- ) as SuiClientTypes.Object<Include>['display'],
263
- }),
264
- );
243
+ const objects = response.response.objects.map((object): SuiClientTypes.Object<Include> => ({
244
+ objectId: object.objectId!,
245
+ version: object.version?.toString()!,
246
+ digest: object.digest!,
247
+ content: object.contents?.value as SuiClientTypes.Object<Include>['content'],
248
+ owner: mapOwner(object.owner)!,
249
+ type: object.objectType!,
250
+ previousTransaction: (object.previousTransaction ??
251
+ undefined) as SuiClientTypes.Object<Include>['previousTransaction'],
252
+ objectBcs: object.bcs?.value as SuiClientTypes.Object<Include>['objectBcs'],
253
+ json: (options.include?.json
254
+ ? object.json
255
+ ? (Value.toJson(object.json) as Record<string, unknown>)
256
+ : null
257
+ : undefined) as SuiClientTypes.Object<Include>['json'],
258
+ display: mapDisplayProto(
259
+ options.include?.display,
260
+ object.display,
261
+ ) as SuiClientTypes.Object<Include>['display'],
262
+ }));
265
263
 
266
264
  return {
267
265
  objects,
@@ -289,16 +287,14 @@ export class GrpcCoreClient extends CoreClient {
289
287
  );
290
288
 
291
289
  return {
292
- objects: response.response.objects.map(
293
- (object): SuiClientTypes.Coin => ({
294
- objectId: object.objectId!,
295
- version: object.version?.toString()!,
296
- digest: object.digest!,
297
- owner: mapOwner(object.owner)!,
298
- type: object.objectType!,
299
- balance: object.balance?.toString()!,
300
- }),
301
- ),
290
+ objects: response.response.objects.map((object): SuiClientTypes.Coin => ({
291
+ objectId: object.objectId!,
292
+ version: object.version?.toString()!,
293
+ digest: object.digest!,
294
+ owner: mapOwner(object.owner)!,
295
+ type: object.objectType!,
296
+ balance: object.balance?.toString()!,
297
+ })),
302
298
  cursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,
303
299
  hasNextPage: response.response.nextPageToken !== undefined,
304
300
  };
@@ -1044,7 +1040,14 @@ function transactionReadMaskPaths(
1044
1040
  include: SuiClientTypes.TransactionInclude | undefined,
1045
1041
  prefix = '',
1046
1042
  ): string[] {
1047
- const paths = ['digest', 'transaction.digest', 'signatures', 'effects.status'];
1043
+ const paths = [
1044
+ 'digest',
1045
+ 'transaction.digest',
1046
+ 'signatures',
1047
+ 'effects.status',
1048
+ 'timestamp',
1049
+ 'checkpoint',
1050
+ ];
1048
1051
 
1049
1052
  if (include?.transaction) {
1050
1053
  paths.push(
@@ -1446,7 +1449,7 @@ export function parseTransactionEffects({
1446
1449
  return {
1447
1450
  bcs: effects.bcs?.value!,
1448
1451
 
1449
- version: 2,
1452
+ version: effects.version ?? 2,
1450
1453
  status: effects.status?.success
1451
1454
  ? {
1452
1455
  success: true,
@@ -1559,6 +1562,11 @@ export function parseGrpcTransactionResponse<
1559
1562
  const result: SuiClientTypes.Transaction<Include> = {
1560
1563
  digest: transaction.digest!,
1561
1564
  epoch: transaction.effects?.epoch?.toString() ?? null,
1565
+ timestampMs: transaction.timestamp
1566
+ ? Number(transaction.timestamp.seconds) * 1000 +
1567
+ Math.floor(transaction.timestamp.nanos / 1_000_000)
1568
+ : null,
1569
+ checkpoint: transaction.checkpoint?.toString() ?? null,
1562
1570
  status,
1563
1571
  effects: effects as SuiClientTypes.Transaction<Include>['effects'],
1564
1572
  objectTypes: (include?.objectTypes
@@ -293,19 +293,17 @@ export class JSONRpcCoreClient extends CoreClient {
293
293
  });
294
294
 
295
295
  return {
296
- objects: coins.data.map(
297
- (coin): SuiClientTypes.Coin => ({
298
- objectId: coin.coinObjectId,
299
- version: coin.version,
300
- digest: coin.digest,
301
- balance: coin.balance,
302
- type: normalizeStructTag(`0x2::coin::Coin<${coin.coinType}>`),
303
- owner: {
304
- $kind: 'AddressOwner' as const,
305
- AddressOwner: options.owner,
306
- },
307
- }),
308
- ),
296
+ objects: coins.data.map((coin): SuiClientTypes.Coin => ({
297
+ objectId: coin.coinObjectId,
298
+ version: coin.version,
299
+ digest: coin.digest,
300
+ balance: coin.balance,
301
+ type: normalizeStructTag(`0x2::coin::Coin<${coin.coinType}>`),
302
+ owner: {
303
+ $kind: 'AddressOwner' as const,
304
+ AddressOwner: options.owner,
305
+ },
306
+ })),
309
307
  hasNextPage: coins.hasNextPage,
310
308
  cursor: coins.nextCursor ?? null,
311
309
  };
@@ -532,6 +530,8 @@ export class JSONRpcCoreClient extends CoreClient {
532
530
  const transactionData: SuiClientTypes.Transaction<Include> = {
533
531
  digest: TransactionDataBuilder.getDigestFromBytes(transactionBytes),
534
532
  epoch: null,
533
+ timestampMs: null,
534
+ checkpoint: null,
535
535
  status: effects.status,
536
536
  effects: (options.include?.effects
537
537
  ? effects
@@ -815,20 +815,18 @@ export class JSONRpcCoreClient extends CoreClient {
815
815
  });
816
816
 
817
817
  return {
818
- events: page.data.map(
819
- (event): SuiClientTypes.EventEntry => ({
820
- packageId: normalizeSuiAddress(event.packageId),
821
- module: event.transactionModule,
822
- sender: normalizeSuiAddress(event.sender),
823
- eventType: normalizeStructTag(event.type),
824
- bcs: event.bcsEncoding === 'base58' ? fromBase58(event.bcs) : fromBase64(event.bcs),
825
- json: (event.parsedJson as Record<string, unknown>) ?? null,
826
- // queryEvents responses do not include checkpoint information
827
- checkpoint: null,
828
- transactionDigest: event.id.txDigest,
829
- eventIndex: Number(event.id.eventSeq),
830
- }),
831
- ),
818
+ events: page.data.map((event): SuiClientTypes.EventEntry => ({
819
+ packageId: normalizeSuiAddress(event.packageId),
820
+ module: event.transactionModule,
821
+ sender: normalizeSuiAddress(event.sender),
822
+ eventType: normalizeStructTag(event.type),
823
+ bcs: event.bcsEncoding === 'base58' ? fromBase58(event.bcs) : fromBase64(event.bcs),
824
+ json: (event.parsedJson as Record<string, unknown>) ?? null,
825
+ // queryEvents responses do not include checkpoint information
826
+ checkpoint: null,
827
+ transactionDigest: event.id.txDigest,
828
+ eventIndex: Number(event.id.eventSeq),
829
+ })),
832
830
  hasNextPage: page.hasNextPage,
833
831
  startCursor: page.data.length ? JSON.stringify(page.data[0].id) : null,
834
832
  endCursor:
@@ -1232,6 +1230,8 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
1232
1230
  const result: SuiClientTypes.Transaction<Include> = {
1233
1231
  digest: transaction.digest,
1234
1232
  epoch: transaction.effects?.executedEpoch ?? null,
1233
+ timestampMs: transaction.timestampMs == null ? null : Number(transaction.timestampMs),
1234
+ checkpoint: transaction.checkpoint ?? null,
1235
1235
  status,
1236
1236
  effects: (include?.effects && effectsBytes
1237
1237
  ? parseTransactionEffectsBcs(effectsBytes)
@@ -50,8 +50,7 @@ export type TransactionResult = Extract<Argument, { Result: unknown }> &
50
50
  Extract<Argument, { NestedResult: unknown }>[];
51
51
 
52
52
  export type TransactionResultArgument =
53
- | Extract<Argument, { Result: unknown }>
54
- | readonly Extract<Argument, { NestedResult: unknown }>[];
53
+ Extract<Argument, { Result: unknown }> | readonly Extract<Argument, { NestedResult: unknown }>[];
55
54
 
56
55
  export type AsyncTransactionThunk<
57
56
  T extends TransactionResultArgument | void = TransactionResultArgument | void,
@@ -51,8 +51,7 @@ export interface ParallelTransactionExecutorAddressBalanceOptions extends Parall
51
51
 
52
52
  /** Options for ParallelTransactionExecutor - discriminated union based on gasMode */
53
53
  export type ParallelTransactionExecutorOptions =
54
- | ParallelTransactionExecutorCoinOptions
55
- | ParallelTransactionExecutorAddressBalanceOptions;
54
+ ParallelTransactionExecutorCoinOptions | ParallelTransactionExecutorAddressBalanceOptions;
56
55
 
57
56
  interface CoinWithBalance {
58
57
  id: string;
@@ -27,8 +27,7 @@ export interface SerialTransactionExecutorAddressBalanceOptions extends SerialTr
27
27
  }
28
28
 
29
29
  export type SerialTransactionExecutorOptions =
30
- | SerialTransactionExecutorCoinOptions
31
- | SerialTransactionExecutorAddressBalanceOptions;
30
+ SerialTransactionExecutorCoinOptions | SerialTransactionExecutorAddressBalanceOptions;
32
31
 
33
32
  export class SerialTransactionExecutor {
34
33
  #queue = new SerialQueue();
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.26.1';
6
+ export const PACKAGE_VERSION = '2.27.0';