@mysten/sui 2.5.0 → 2.6.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 (75) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/bcs/index.d.mts +20 -20
  3. package/dist/client/core-resolver.mjs +6 -3
  4. package/dist/client/core-resolver.mjs.map +1 -1
  5. package/dist/client/core.d.mts +8 -8
  6. package/dist/client/core.d.mts.map +1 -1
  7. package/dist/client/core.mjs +11 -5
  8. package/dist/client/core.mjs.map +1 -1
  9. package/dist/client/types.d.mts +56 -18
  10. package/dist/client/types.d.mts.map +1 -1
  11. package/dist/cryptography/signature.d.mts +6 -6
  12. package/dist/graphql/client.d.mts +16 -1
  13. package/dist/graphql/client.d.mts.map +1 -1
  14. package/dist/graphql/client.mjs +50 -2
  15. package/dist/graphql/client.mjs.map +1 -1
  16. package/dist/graphql/core.d.mts +5 -5
  17. package/dist/graphql/core.d.mts.map +1 -1
  18. package/dist/graphql/core.mjs +7 -41
  19. package/dist/graphql/core.mjs.map +1 -1
  20. package/dist/graphql/generated/queries.d.mts.map +1 -1
  21. package/dist/graphql/generated/queries.mjs +7 -4
  22. package/dist/graphql/generated/queries.mjs.map +1 -1
  23. package/dist/graphql/generated/tada-env.d.mts +0 -22
  24. package/dist/grpc/client.d.mts +16 -1
  25. package/dist/grpc/client.d.mts.map +1 -1
  26. package/dist/grpc/client.mjs +42 -2
  27. package/dist/grpc/client.mjs.map +1 -1
  28. package/dist/grpc/core.d.mts +5 -5
  29. package/dist/grpc/core.d.mts.map +1 -1
  30. package/dist/grpc/core.mjs +3 -33
  31. package/dist/grpc/core.mjs.map +1 -1
  32. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  33. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  34. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  35. package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
  36. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  37. package/dist/jsonRpc/core.d.mts +6 -6
  38. package/dist/jsonRpc/core.d.mts.map +1 -1
  39. package/dist/jsonRpc/core.mjs +4 -2
  40. package/dist/jsonRpc/core.mjs.map +1 -1
  41. package/dist/keypairs/ed25519/keypair.d.mts +3 -1
  42. package/dist/keypairs/ed25519/keypair.d.mts.map +1 -1
  43. package/dist/keypairs/ed25519/keypair.mjs +5 -1
  44. package/dist/keypairs/ed25519/keypair.mjs.map +1 -1
  45. package/dist/transactions/Transaction.d.mts +3 -3
  46. package/dist/transactions/Transaction.d.mts.map +1 -1
  47. package/dist/transactions/executor/caching.mjs.map +1 -1
  48. package/dist/transactions/executor/parallel.d.mts +1 -1
  49. package/dist/transactions/executor/parallel.d.mts.map +1 -1
  50. package/dist/transactions/executor/parallel.mjs +1 -1
  51. package/dist/transactions/executor/parallel.mjs.map +1 -1
  52. package/dist/transactions/executor/serial.d.mts +1 -1
  53. package/dist/transactions/executor/serial.d.mts.map +1 -1
  54. package/dist/transactions/executor/serial.mjs.map +1 -1
  55. package/dist/version.mjs +2 -2
  56. package/dist/version.mjs.map +1 -1
  57. package/package.json +1 -1
  58. package/src/client/core-resolver.ts +9 -8
  59. package/src/client/core.ts +28 -18
  60. package/src/client/types.ts +57 -18
  61. package/src/graphql/client.ts +96 -4
  62. package/src/graphql/core.ts +9 -75
  63. package/src/graphql/generated/queries.ts +19 -30
  64. package/src/graphql/generated/schema.graphql +4 -17
  65. package/src/graphql/generated/tada-env.ts +0 -24
  66. package/src/graphql/queries/getDynamicFields.graphql +8 -1
  67. package/src/graphql/queries/transactions.graphql +1 -3
  68. package/src/grpc/client.ts +62 -4
  69. package/src/grpc/core.ts +8 -39
  70. package/src/jsonRpc/core.ts +9 -7
  71. package/src/keypairs/ed25519/keypair.ts +5 -1
  72. package/src/transactions/executor/caching.ts +2 -2
  73. package/src/transactions/executor/parallel.ts +1 -2
  74. package/src/transactions/executor/serial.ts +1 -1
  75. package/src/version.ts +2 -2
package/src/grpc/core.ts CHANGED
@@ -6,7 +6,6 @@ import { CoreClient, formatMoveAbortMessage, SimulationError } from '../client/i
6
6
  import type { SuiGrpcClient } from './client.js';
7
7
  import type { Owner } from './proto/sui/rpc/v2/owner.js';
8
8
  import { Owner_OwnerKind } from './proto/sui/rpc/v2/owner.js';
9
- import { DynamicField_DynamicFieldKind } from './proto/sui/rpc/v2/state_service.js';
10
9
  import { chunk, fromBase64, toBase64 } from '@mysten/utils';
11
10
  import type { ExecutedTransaction } from './proto/sui/rpc/v2/executed_transaction.js';
12
11
  import type { TransactionEffects } from './proto/sui/rpc/v2/effects.js';
@@ -56,7 +55,7 @@ export class GrpcCoreClient extends CoreClient {
56
55
  this.#client = client;
57
56
  }
58
57
 
59
- async getObjects<Include extends SuiClientTypes.ObjectInclude = object>(
58
+ async getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
60
59
  options: SuiClientTypes.GetObjectsOptions<Include>,
61
60
  ): Promise<SuiClientTypes.GetObjectsResponse<Include>> {
62
61
  const batches = chunk(options.objectIds, 50);
@@ -131,7 +130,7 @@ export class GrpcCoreClient extends CoreClient {
131
130
  objects: results,
132
131
  };
133
132
  }
134
- async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude = object>(
133
+ async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
135
134
  options: SuiClientTypes.ListOwnedObjectsOptions<Include>,
136
135
  ): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>> {
137
136
  const paths = ['owner', 'object_type', 'digest', 'version', 'object_id'];
@@ -285,7 +284,7 @@ export class GrpcCoreClient extends CoreClient {
285
284
  })),
286
285
  };
287
286
  }
288
- async getTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
287
+ async getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
289
288
  options: SuiClientTypes.GetTransactionOptions<Include>,
290
289
  ): Promise<SuiClientTypes.TransactionResult<Include>> {
291
290
  const paths = ['digest', 'transaction.digest', 'signatures', 'effects.status'];
@@ -327,7 +326,7 @@ export class GrpcCoreClient extends CoreClient {
327
326
 
328
327
  return parseTransaction(response.transaction, options.include);
329
328
  }
330
- async executeTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
329
+ async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
331
330
  options: SuiClientTypes.ExecuteTransactionOptions<Include>,
332
331
  ): Promise<SuiClientTypes.TransactionResult<Include>> {
333
332
  const paths = ['digest', 'transaction.digest', 'signatures', 'effects.status'];
@@ -377,7 +376,7 @@ export class GrpcCoreClient extends CoreClient {
377
376
 
378
377
  return parseTransaction(response.transaction!, options.include);
379
378
  }
380
- async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = object>(
379
+ async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
381
380
  options: SuiClientTypes.SimulateTransactionOptions<Include>,
382
381
  ): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
383
382
  const paths = [
@@ -561,38 +560,7 @@ export class GrpcCoreClient extends CoreClient {
561
560
  async listDynamicFields(
562
561
  options: SuiClientTypes.ListDynamicFieldsOptions,
563
562
  ): Promise<SuiClientTypes.ListDynamicFieldsResponse> {
564
- const response = await this.#client.stateService.listDynamicFields({
565
- parent: options.parentId,
566
- pageToken: options.cursor ? fromBase64(options.cursor) : undefined,
567
- pageSize: options.limit,
568
- readMask: {
569
- paths: ['field_id', 'name', 'value_type', 'kind', 'child_id'],
570
- },
571
- });
572
-
573
- return {
574
- dynamicFields: response.response.dynamicFields.map(
575
- (field): SuiClientTypes.DynamicFieldEntry => {
576
- const isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;
577
- const fieldType = isDynamicObject
578
- ? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${field.name?.name!}>,0x2::object::ID>`
579
- : `0x2::dynamic_field::Field<${field.name?.name!},${field.valueType!}>`;
580
- return {
581
- $kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
582
- fieldId: field.fieldId!,
583
- name: {
584
- type: field.name?.name!,
585
- bcs: field.name?.value!,
586
- },
587
- valueType: field.valueType!,
588
- type: normalizeStructTag(fieldType),
589
- childId: field.childId,
590
- } as SuiClientTypes.DynamicFieldEntry;
591
- },
592
- ),
593
- cursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,
594
- hasNextPage: response.response.nextPageToken !== undefined,
595
- };
563
+ return this.#client.listDynamicFields(options);
596
564
  }
597
565
 
598
566
  async verifyZkLoginSignature(
@@ -1170,7 +1138,7 @@ export function parseTransactionEffects({
1170
1138
  };
1171
1139
  }
1172
1140
 
1173
- function parseTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
1141
+ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
1174
1142
  transaction: ExecutedTransaction,
1175
1143
  include?: Include,
1176
1144
  ): SuiClientTypes.TransactionResult<Include> {
@@ -1248,6 +1216,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
1248
1216
  sender: normalizeSuiAddress(event.sender!),
1249
1217
  eventType: event.eventType!,
1250
1218
  bcs: event.contents?.value ?? new Uint8Array(),
1219
+ json: event.json ? (Value.toJson(event.json) as Record<string, unknown>) : null,
1251
1220
  })) ?? [])
1252
1221
  : undefined) as SuiClientTypes.Transaction<Include>['events'],
1253
1222
  };
@@ -115,7 +115,7 @@ export class JSONRpcCoreClient extends CoreClient {
115
115
  this.#jsonRpcClient = jsonRpcClient;
116
116
  }
117
117
 
118
- async getObjects<Include extends SuiClientTypes.ObjectInclude = object>(
118
+ async getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
119
119
  options: SuiClientTypes.GetObjectsOptions<Include>,
120
120
  ) {
121
121
  const batches = chunk(options.objectIds, 50);
@@ -148,7 +148,7 @@ export class JSONRpcCoreClient extends CoreClient {
148
148
  objects: results,
149
149
  };
150
150
  }
151
- async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude = object>(
151
+ async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
152
152
  options: SuiClientTypes.ListOwnedObjectsOptions<Include>,
153
153
  ) {
154
154
  let filter: SuiObjectDataFilter | null = null;
@@ -287,7 +287,7 @@ export class JSONRpcCoreClient extends CoreClient {
287
287
  cursor: null,
288
288
  };
289
289
  }
290
- async getTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
290
+ async getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
291
291
  options: SuiClientTypes.GetTransactionOptions<Include>,
292
292
  ): Promise<SuiClientTypes.TransactionResult<Include>> {
293
293
  const transaction = await this.#jsonRpcClient.getTransactionBlock({
@@ -307,7 +307,7 @@ export class JSONRpcCoreClient extends CoreClient {
307
307
 
308
308
  return parseTransaction(transaction, options.include);
309
309
  }
310
- async executeTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
310
+ async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
311
311
  options: SuiClientTypes.ExecuteTransactionOptions<Include>,
312
312
  ): Promise<SuiClientTypes.TransactionResult<Include>> {
313
313
  const transaction = await this.#jsonRpcClient.executeTransactionBlock({
@@ -328,7 +328,7 @@ export class JSONRpcCoreClient extends CoreClient {
328
328
 
329
329
  return parseTransaction(transaction, options.include);
330
330
  }
331
- async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = object>(
331
+ async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
332
332
  options: SuiClientTypes.SimulateTransactionOptions<Include>,
333
333
  ): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
334
334
  if (!(options.transaction instanceof Uint8Array)) {
@@ -403,6 +403,7 @@ export class JSONRpcCoreClient extends CoreClient {
403
403
  sender: event.sender,
404
404
  eventType: event.type,
405
405
  bcs: 'bcs' in event ? fromBase64(event.bcs) : new Uint8Array(),
406
+ json: (event.parsedJson as Record<string, unknown>) ?? null,
406
407
  })) ?? [])
407
408
  : undefined) as SuiClientTypes.Transaction<Include>['events'],
408
409
  };
@@ -664,7 +665,7 @@ function serializeObjectToBcs(object: SuiObjectData): Uint8Array | undefined {
664
665
  }
665
666
  }
666
667
 
667
- function parseObject<Include extends SuiClientTypes.ObjectInclude = object>(
668
+ function parseObject<Include extends SuiClientTypes.ObjectInclude = {}>(
668
669
  object: SuiObjectData,
669
670
  include?: Include,
670
671
  ): SuiClientTypes.Object<Include> {
@@ -802,7 +803,7 @@ function parseOwnerAddress(owner: ObjectOwner): string | null {
802
803
  throw new Error(`Unknown owner type: ${JSON.stringify(owner)}`);
803
804
  }
804
805
 
805
- function parseTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
806
+ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
806
807
  transaction: SuiTransactionBlockResponse,
807
808
  include?: Include,
808
809
  ): SuiClientTypes.TransactionResult<Include> {
@@ -886,6 +887,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
886
887
  sender: event.sender,
887
888
  eventType: event.type,
888
889
  bcs: 'bcs' in event ? fromBase64(event.bcs) : new Uint8Array(),
890
+ json: (event.parsedJson as Record<string, unknown>) ?? null,
889
891
  })) ?? [])
890
892
  : undefined) as SuiClientTypes.Transaction<Include>['events'],
891
893
  };
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { toHex } from '@mysten/bcs';
4
5
  import { ed25519 } from '@noble/curves/ed25519.js';
5
6
 
6
7
  import {
@@ -166,14 +167,17 @@ export class Ed25519Keypair extends Keypair {
166
167
  *
167
168
  * If path is none, it will default to m/44'/784'/0'/0'/0', otherwise the path must
168
169
  * be compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.
170
+ *
171
+ * @param seed - The seed as a hex string or Uint8Array.
169
172
  */
170
- static deriveKeypairFromSeed(seedHex: string, path?: string): Ed25519Keypair {
173
+ static deriveKeypairFromSeed(seed: string | Uint8Array, path?: string): Ed25519Keypair {
171
174
  if (path == null) {
172
175
  path = DEFAULT_ED25519_DERIVATION_PATH;
173
176
  }
174
177
  if (!isValidHardenedPath(path)) {
175
178
  throw new Error('Invalid derivation path');
176
179
  }
180
+ const seedHex = typeof seed === 'string' ? seed : toHex(seed);
177
181
  const { key } = derivePath(path, seedHex);
178
182
 
179
183
  return Ed25519Keypair.fromSecretKey(key);
@@ -15,7 +15,7 @@ import { isTransaction } from '../Transaction.js';
15
15
  export interface ExecuteTransactionOptions<Include extends SuiClientTypes.TransactionInclude = {}> {
16
16
  transaction: Transaction | Uint8Array;
17
17
  signatures: string[];
18
- include?: Include;
18
+ include?: Include & SuiClientTypes.TransactionInclude;
19
19
  }
20
20
 
21
21
  export class CachingTransactionExecutor {
@@ -93,7 +93,7 @@ export class CachingTransactionExecutor {
93
93
  }: {
94
94
  transaction: Transaction;
95
95
  signer: Signer;
96
- include?: Include;
96
+ include?: Include & SuiClientTypes.TransactionInclude;
97
97
  }): Promise<SuiClientTypes.TransactionResult<Include & { effects: true }>> {
98
98
  transaction.setSenderIfNotSet(signer.toSuiAddress());
99
99
  const bytes = await this.buildTransaction({ transaction });
@@ -128,7 +128,7 @@ export class ParallelTransactionExecutor {
128
128
 
129
129
  async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
130
130
  transaction: Transaction,
131
- include?: Include,
131
+ include?: Include & SuiClientTypes.TransactionInclude,
132
132
  additionalSignatures: string[] = [],
133
133
  ): Promise<SuiClientTypes.TransactionResult<Include & { effects: true }>> {
134
134
  const { promise, resolve, reject } =
@@ -262,7 +262,6 @@ export class ParallelTransactionExecutor {
262
262
  if (gasOwner === this.#signer.toSuiAddress()) {
263
263
  const totalUsed =
264
264
  BigInt(gasUsed.computationCost) +
265
- BigInt(gasUsed.storageCost) +
266
265
  BigInt(gasUsed.storageCost) -
267
266
  BigInt(gasUsed.storageRebate);
268
267
  const remainingBalance = coin.balance - totalUsed;
@@ -164,7 +164,7 @@ export class SerialTransactionExecutor {
164
164
 
165
165
  executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
166
166
  transaction: Transaction | Uint8Array,
167
- include?: Include,
167
+ include?: Include & SuiClientTypes.TransactionInclude,
168
168
  additionalSignatures: string[] = [],
169
169
  ): Promise<SuiClientTypes.TransactionResult<Include & { effects: true }>> {
170
170
  return this.#queue.runTask(async () => {
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.5.0';
7
- export const TARGETED_RPC_VERSION = '1.67.0';
6
+ export const PACKAGE_VERSION = '2.6.0';
7
+ export const TARGETED_RPC_VERSION = '1.68.0';