@mysten/sui 2.5.1 → 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 (72) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/index.d.mts +20 -20
  4. package/dist/client/core-resolver.mjs +6 -3
  5. package/dist/client/core-resolver.mjs.map +1 -1
  6. package/dist/client/core.d.mts +8 -8
  7. package/dist/client/core.d.mts.map +1 -1
  8. package/dist/client/core.mjs +11 -5
  9. package/dist/client/core.mjs.map +1 -1
  10. package/dist/client/types.d.mts +56 -18
  11. package/dist/client/types.d.mts.map +1 -1
  12. package/dist/cryptography/signature.d.mts +14 -14
  13. package/dist/graphql/client.d.mts +16 -1
  14. package/dist/graphql/client.d.mts.map +1 -1
  15. package/dist/graphql/client.mjs +50 -2
  16. package/dist/graphql/client.mjs.map +1 -1
  17. package/dist/graphql/core.d.mts +5 -5
  18. package/dist/graphql/core.d.mts.map +1 -1
  19. package/dist/graphql/core.mjs +7 -41
  20. package/dist/graphql/core.mjs.map +1 -1
  21. package/dist/graphql/generated/queries.d.mts.map +1 -1
  22. package/dist/graphql/generated/queries.mjs +7 -4
  23. package/dist/graphql/generated/queries.mjs.map +1 -1
  24. package/dist/graphql/generated/tada-env.d.mts +0 -22
  25. package/dist/grpc/client.d.mts +16 -1
  26. package/dist/grpc/client.d.mts.map +1 -1
  27. package/dist/grpc/client.mjs +42 -2
  28. package/dist/grpc/client.mjs.map +1 -1
  29. package/dist/grpc/core.d.mts +5 -5
  30. package/dist/grpc/core.d.mts.map +1 -1
  31. package/dist/grpc/core.mjs +3 -33
  32. package/dist/grpc/core.mjs.map +1 -1
  33. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  34. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  35. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  36. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  37. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  38. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  39. package/dist/jsonRpc/core.d.mts +6 -6
  40. package/dist/jsonRpc/core.d.mts.map +1 -1
  41. package/dist/jsonRpc/core.mjs +4 -2
  42. package/dist/jsonRpc/core.mjs.map +1 -1
  43. package/dist/transactions/Transaction.d.mts +9 -9
  44. package/dist/transactions/Transaction.d.mts.map +1 -1
  45. package/dist/transactions/executor/caching.mjs.map +1 -1
  46. package/dist/transactions/executor/parallel.d.mts +1 -1
  47. package/dist/transactions/executor/parallel.d.mts.map +1 -1
  48. package/dist/transactions/executor/parallel.mjs.map +1 -1
  49. package/dist/transactions/executor/serial.d.mts +1 -1
  50. package/dist/transactions/executor/serial.d.mts.map +1 -1
  51. package/dist/transactions/executor/serial.mjs.map +1 -1
  52. package/dist/version.mjs +1 -1
  53. package/dist/version.mjs.map +1 -1
  54. package/dist/zklogin/bcs.d.mts +14 -14
  55. package/package.json +1 -1
  56. package/src/client/core-resolver.ts +9 -8
  57. package/src/client/core.ts +28 -18
  58. package/src/client/types.ts +57 -18
  59. package/src/graphql/client.ts +96 -4
  60. package/src/graphql/core.ts +9 -75
  61. package/src/graphql/generated/queries.ts +19 -30
  62. package/src/graphql/generated/schema.graphql +4 -17
  63. package/src/graphql/generated/tada-env.ts +0 -24
  64. package/src/graphql/queries/getDynamicFields.graphql +8 -1
  65. package/src/graphql/queries/transactions.graphql +1 -3
  66. package/src/grpc/client.ts +62 -4
  67. package/src/grpc/core.ts +8 -39
  68. package/src/jsonRpc/core.ts +9 -7
  69. package/src/transactions/executor/caching.ts +2 -2
  70. package/src/transactions/executor/parallel.ts +1 -1
  71. package/src/transactions/executor/serial.ts +1 -1
  72. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.5.1';\nexport const TARGETED_RPC_VERSION = '1.68.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.6.0';\nexport const TARGETED_RPC_VERSION = '1.68.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
@@ -1,31 +1,31 @@
1
- import * as _mysten_bcs817 from "@mysten/bcs";
1
+ import * as _mysten_bcs810 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_bcs810.BcsStruct<{
6
+ inputs: _mysten_bcs810.BcsStruct<{
7
+ proofPoints: _mysten_bcs810.BcsStruct<{
8
+ a: _mysten_bcs810.BcsType<string[], Iterable<string> & {
9
9
  length: number;
10
10
  }, string>;
11
- b: _mysten_bcs817.BcsType<string[][], Iterable<Iterable<string> & {
11
+ b: _mysten_bcs810.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_bcs810.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_bcs810.BcsStruct<{
21
+ value: _mysten_bcs810.BcsType<string, string, "string">;
22
+ indexMod4: _mysten_bcs810.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_bcs810.BcsType<string, string, "string">;
25
+ addressSeed: _mysten_bcs810.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_bcs810.BcsType<string, string | number | bigint, "u64">;
28
+ userSignature: _mysten_bcs810.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
29
29
  }, string>;
30
30
  type ZkLoginSignature = InferBcsInput<typeof zkLoginSignature>;
31
31
  type ZkLoginSignatureInputs = ZkLoginSignature['inputs'];
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.5.1",
6
+ "version": "2.6.0",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -112,7 +112,12 @@ async function setGasBudget(transactionData: TransactionDataBuilder, client: Cli
112
112
  // The current default is just picking _all_ coins we can which may not be ideal.
113
113
  async function setGasPayment(transactionData: TransactionDataBuilder, client: ClientWithCoreApi) {
114
114
  if (!transactionData.gasData.payment) {
115
- const gasPayer = transactionData.gasData.owner ?? transactionData.sender!;
115
+ const gasPayer = transactionData.gasData.owner ?? transactionData.sender;
116
+ if (!gasPayer) {
117
+ throw new Error('Either a gas owner or sender must be set to determine gas payment.');
118
+ }
119
+
120
+ const normalizedGasPayer = normalizeSuiAddress(gasPayer);
116
121
  let usesGasCoin = false;
117
122
  let withdrawals = 0n;
118
123
 
@@ -127,7 +132,7 @@ async function setGasPayment(transactionData: TransactionDataBuilder, client: Cl
127
132
  ? transactionData.sender
128
133
  : gasPayer;
129
134
 
130
- if (withdrawalOwner === gasPayer) {
135
+ if (withdrawalOwner && normalizeSuiAddress(withdrawalOwner) === normalizedGasPayer) {
131
136
  if (input.FundsWithdrawal.reservation.$kind === 'MaxAmountU64') {
132
137
  withdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);
133
138
  }
@@ -139,13 +144,9 @@ async function setGasPayment(transactionData: TransactionDataBuilder, client: Cl
139
144
  });
140
145
 
141
146
  const [suiBalance, coins] = await Promise.all([
142
- usesGasCoin || !transactionData.gasData.owner
143
- ? null
144
- : client.core.getBalance({
145
- owner: transactionData.gasData.owner,
146
- }),
147
+ usesGasCoin ? null : client.core.getBalance({ owner: gasPayer }),
147
148
  client.core.listCoins({
148
- owner: transactionData.gasData.owner || transactionData.sender!,
149
+ owner: gasPayer,
149
150
  coinType: SUI_TYPE_ARG,
150
151
  }),
151
152
  ]);
@@ -39,11 +39,11 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
39
39
  });
40
40
  }
41
41
 
42
- abstract getObjects<Include extends SuiClientTypes.ObjectInclude = object>(
42
+ abstract getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
43
43
  options: SuiClientTypes.GetObjectsOptions<Include>,
44
44
  ): Promise<SuiClientTypes.GetObjectsResponse<Include>>;
45
45
 
46
- async getObject<Include extends SuiClientTypes.ObjectInclude = object>(
46
+ async getObject<Include extends SuiClientTypes.ObjectInclude = {}>(
47
47
  options: SuiClientTypes.GetObjectOptions<Include>,
48
48
  ): Promise<SuiClientTypes.GetObjectResponse<Include>> {
49
49
  const { objectId } = options;
@@ -64,7 +64,7 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
64
64
  options: SuiClientTypes.ListCoinsOptions,
65
65
  ): Promise<SuiClientTypes.ListCoinsResponse>;
66
66
 
67
- abstract listOwnedObjects<Include extends SuiClientTypes.ObjectInclude = object>(
67
+ abstract listOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
68
68
  options: SuiClientTypes.ListOwnedObjectsOptions<Include>,
69
69
  ): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>>;
70
70
 
@@ -80,15 +80,15 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
80
80
  options: SuiClientTypes.GetCoinMetadataOptions,
81
81
  ): Promise<SuiClientTypes.GetCoinMetadataResponse>;
82
82
 
83
- abstract getTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
83
+ abstract getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
84
84
  options: SuiClientTypes.GetTransactionOptions<Include>,
85
85
  ): Promise<SuiClientTypes.TransactionResult<Include>>;
86
86
 
87
- abstract executeTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
87
+ abstract executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
88
88
  options: SuiClientTypes.ExecuteTransactionOptions<Include>,
89
89
  ): Promise<SuiClientTypes.TransactionResult<Include>>;
90
90
 
91
- abstract simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = object>(
91
+ abstract simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
92
92
  options: SuiClientTypes.SimulateTransactionOptions<Include>,
93
93
  ): Promise<SuiClientTypes.SimulateTransactionResult<Include>>;
94
94
 
@@ -151,8 +151,22 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
151
151
  const fieldType = parseStructTag(fieldObject.type);
152
152
  const content = await fieldObject.content;
153
153
 
154
+ const nameTypeParam = fieldType.typeParams[0];
155
+ const isDynamicObject =
156
+ typeof nameTypeParam !== 'string' &&
157
+ nameTypeParam.module === 'dynamic_object_field' &&
158
+ nameTypeParam.name === 'Wrapper';
159
+
160
+ const valueBcs = content.slice(SUI_ADDRESS_LENGTH + options.name.bcs.length);
161
+
162
+ const valueType =
163
+ typeof fieldType.typeParams[1] === 'string'
164
+ ? fieldType.typeParams[1]
165
+ : normalizeStructTag(fieldType.typeParams[1]);
166
+
154
167
  return {
155
168
  dynamicField: {
169
+ $kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
156
170
  fieldId: fieldObject.objectId,
157
171
  digest: fieldObject.digest,
158
172
  version: fieldObject.version,
@@ -160,23 +174,19 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
160
174
  previousTransaction: fieldObject.previousTransaction,
161
175
  name: {
162
176
  type:
163
- typeof fieldType.typeParams[0] === 'string'
164
- ? fieldType.typeParams[0]
165
- : normalizeStructTag(fieldType.typeParams[0]),
177
+ typeof nameTypeParam === 'string' ? nameTypeParam : normalizeStructTag(nameTypeParam),
166
178
  bcs: options.name.bcs,
167
179
  },
168
180
  value: {
169
- type:
170
- typeof fieldType.typeParams[1] === 'string'
171
- ? fieldType.typeParams[1]
172
- : normalizeStructTag(fieldType.typeParams[1]),
173
- bcs: content.slice(SUI_ADDRESS_LENGTH + options.name.bcs.length),
181
+ type: valueType,
182
+ bcs: valueBcs,
174
183
  },
175
- },
184
+ childId: isDynamicObject ? bcs.Address.parse(valueBcs) : undefined,
185
+ } as SuiClientTypes.GetDynamicFieldResponse['dynamicField'],
176
186
  };
177
187
  }
178
188
 
179
- async getDynamicObjectField<Include extends SuiClientTypes.ObjectInclude = object>(
189
+ async getDynamicObjectField<Include extends SuiClientTypes.ObjectInclude = {}>(
180
190
  options: SuiClientTypes.GetDynamicObjectFieldOptions<Include>,
181
191
  ): Promise<SuiClientTypes.GetDynamicObjectFieldResponse<Include>> {
182
192
  const resolvedNameType = (
@@ -196,7 +206,7 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
196
206
  });
197
207
 
198
208
  const { object } = await this.getObject({
199
- objectId: bcs.Address.parse(dynamicField.value.bcs),
209
+ objectId: dynamicField.childId!,
200
210
  signal: options.signal,
201
211
  include: options.include,
202
212
  });
@@ -204,7 +214,7 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
204
214
  return { object };
205
215
  }
206
216
 
207
- async waitForTransaction<Include extends SuiClientTypes.TransactionInclude = object>(
217
+ async waitForTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
208
218
  options: SuiClientTypes.WaitForTransactionOptions<Include>,
209
219
  ): Promise<SuiClientTypes.TransactionResult<Include>> {
210
220
  const { signal, timeout = 60 * 1000, include } = options;
@@ -58,9 +58,32 @@ export namespace SuiClientTypes {
58
58
  }
59
59
 
60
60
  export interface ObjectInclude {
61
+ /**
62
+ * Include the BCS-encoded Move struct content of the object.
63
+ *
64
+ * Returns the raw bytes of the object's Move struct fields — pass directly to
65
+ * generated BCS types (e.g., `MyStruct.parse(object.content)`).
66
+ */
61
67
  content?: boolean;
68
+ /**
69
+ * Include the digest of the transaction that last mutated this object.
70
+ */
62
71
  previousTransaction?: boolean;
72
+ /**
73
+ * Include the full BCS-encoded object envelope. Rarely needed — most metadata
74
+ * (owner, version, type) is already available as fields on the object response.
75
+ *
76
+ * Parse with `bcs.Object.parse(object.objectBcs)` from `@mysten/sui/bcs`.
77
+ * Do not pass to a Move struct parser — use `content` for that instead.
78
+ */
63
79
  objectBcs?: boolean;
80
+ /**
81
+ * Include the JSON representation of the object's Move struct content.
82
+ *
83
+ * **Warning:** The exact shape and field names of this data may vary between different
84
+ * API implementations (JSON-RPC vs gRPC or GraphQL). For consistent data across APIs,
85
+ * use the `content` field and parse the BCS data directly.
86
+ */
64
87
  json?: boolean;
65
88
  }
66
89
 
@@ -68,14 +91,14 @@ export namespace SuiClientTypes {
68
91
  Include extends ObjectInclude = {},
69
92
  > extends CoreClientMethodOptions {
70
93
  objectIds: string[];
71
- include?: Include;
94
+ include?: Include & ObjectInclude;
72
95
  }
73
96
 
74
97
  export interface GetObjectOptions<
75
98
  Include extends ObjectInclude = {},
76
99
  > extends CoreClientMethodOptions {
77
100
  objectId: string;
78
- include?: Include;
101
+ include?: Include & ObjectInclude;
79
102
  }
80
103
 
81
104
  export interface ListOwnedObjectsOptions<
@@ -85,7 +108,7 @@ export namespace SuiClientTypes {
85
108
  limit?: number;
86
109
  cursor?: string | null;
87
110
  type?: string;
88
- include?: Include;
111
+ include?: Include & ObjectInclude;
89
112
  }
90
113
 
91
114
  export interface ListCoinsOptions extends CoreClientMethodOptions {
@@ -133,8 +156,10 @@ export namespace SuiClientTypes {
133
156
  digest: string;
134
157
  owner: ObjectOwner;
135
158
  type: string;
159
+ /** BCS-encoded Move struct content — pass to generated BCS type parsers. */
136
160
  content: Include extends { content: true } ? Uint8Array<ArrayBuffer> : undefined;
137
161
  previousTransaction: Include extends { previousTransaction: true } ? string | null : undefined;
162
+ /** Full BCS-encoded object envelope — parse with `bcs.Object` not a struct parser. */
138
163
  objectBcs: Include extends { objectBcs: true } ? Uint8Array<ArrayBuffer> : undefined;
139
164
  /**
140
165
  * The JSON representation of the object's Move struct content.
@@ -162,6 +187,13 @@ export namespace SuiClientTypes {
162
187
  valueType: string;
163
188
  } & ({ $kind: 'DynamicField'; childId?: never } | { $kind: 'DynamicObject'; childId: string });
164
189
 
190
+ export type DynamicField = DynamicFieldEntry & {
191
+ value: DynamicFieldValue;
192
+ version: string;
193
+ digest: string;
194
+ previousTransaction: string | null;
195
+ };
196
+
165
197
  export interface ListDynamicFieldsResponse {
166
198
  hasNextPage: boolean;
167
199
  cursor: string | null;
@@ -169,15 +201,7 @@ export namespace SuiClientTypes {
169
201
  }
170
202
 
171
203
  export interface GetDynamicFieldResponse {
172
- dynamicField: {
173
- name: DynamicFieldName;
174
- value: DynamicFieldValue;
175
- fieldId: string;
176
- version: string;
177
- digest: string;
178
- type: string;
179
- previousTransaction: string | null;
180
- };
204
+ dynamicField: DynamicField;
181
205
  }
182
206
 
183
207
  export interface GetDynamicObjectFieldOptions<
@@ -185,7 +209,7 @@ export namespace SuiClientTypes {
185
209
  > extends CoreClientMethodOptions {
186
210
  parentId: string;
187
211
  name: DynamicFieldName;
188
- include?: Include;
212
+ include?: Include & ObjectInclude;
189
213
  }
190
214
 
191
215
  export interface GetDynamicObjectFieldResponse<out Include extends ObjectInclude = {}> {
@@ -313,15 +337,22 @@ export namespace SuiClientTypes {
313
337
  };
314
338
 
315
339
  export interface TransactionInclude {
340
+ /** Include balance changes caused by the transaction. */
316
341
  balanceChanges?: boolean;
342
+ /** Include parsed transaction effects (gas used, changed objects, status, etc.). */
317
343
  effects?: boolean;
344
+ /** Include events emitted by the transaction. */
318
345
  events?: boolean;
346
+ /** Include a map of object IDs to their types for all changed objects. */
319
347
  objectTypes?: boolean;
348
+ /** Include the parsed transaction data (sender, gas config, inputs, commands). */
320
349
  transaction?: boolean;
350
+ /** Include the raw BCS-encoded transaction bytes. */
321
351
  bcs?: boolean;
322
352
  }
323
353
 
324
354
  export interface SimulateTransactionInclude extends TransactionInclude {
355
+ /** Include return values and mutated references from each command (simulation only). */
325
356
  commandResults?: boolean;
326
357
  }
327
358
 
@@ -346,7 +377,7 @@ export namespace SuiClientTypes {
346
377
  Include extends TransactionInclude = {},
347
378
  > extends CoreClientMethodOptions {
348
379
  digest: string;
349
- include?: Include;
380
+ include?: Include & TransactionInclude;
350
381
  }
351
382
 
352
383
  export type WaitForTransactionOptions<Include extends TransactionInclude = {}> =
@@ -364,7 +395,7 @@ export namespace SuiClientTypes {
364
395
  Include extends TransactionInclude = {},
365
396
  > extends CoreClientMethodOptions {
366
397
  result: TransactionResult<any>;
367
- include?: Include;
398
+ include?: Include & TransactionInclude;
368
399
  timeout?: number;
369
400
  digest?: never;
370
401
  }
@@ -374,7 +405,7 @@ export namespace SuiClientTypes {
374
405
  > extends CoreClientMethodOptions {
375
406
  transaction: Uint8Array;
376
407
  signatures: string[];
377
- include?: Include;
408
+ include?: Include & TransactionInclude;
378
409
  }
379
410
 
380
411
  export interface SignAndExecuteTransactionOptions<
@@ -383,14 +414,14 @@ export namespace SuiClientTypes {
383
414
  transaction: Uint8Array | TransactionInstance;
384
415
  signer: Signer;
385
416
  additionalSignatures?: string[];
386
- include?: Include;
417
+ include?: Include & TransactionInclude;
387
418
  }
388
419
 
389
420
  export interface SimulateTransactionOptions<
390
421
  Include extends SimulateTransactionInclude = {},
391
422
  > extends CoreClientMethodOptions {
392
423
  transaction: Uint8Array | TransactionInstance;
393
- include?: Include;
424
+ include?: Include & SimulateTransactionInclude;
394
425
  }
395
426
 
396
427
  export interface GetReferenceGasPriceOptions extends CoreClientMethodOptions {}
@@ -816,6 +847,14 @@ export namespace SuiClientTypes {
816
847
  sender: string;
817
848
  eventType: string;
818
849
  bcs: Uint8Array;
850
+ /**
851
+ * The JSON representation of the event's Move struct data.
852
+ *
853
+ * **Warning:** The exact shape and field names of this data may vary between different
854
+ * API implementations (JSON-RPC vs gRPC or GraphQL). For consistent data across APIs use
855
+ * the `bcs` field and parse the BCS data directly.
856
+ */
857
+ json: Record<string, unknown> | null;
819
858
  }
820
859
 
821
860
  export interface MoveAbort {
@@ -9,6 +9,10 @@ import { BaseClient } from '../client/index.js';
9
9
  import type { SuiClientTypes } from '../client/index.js';
10
10
  import { GraphQLCoreClient } from './core.js';
11
11
  import type { TypedDocumentString } from './generated/queries.js';
12
+ import { GetDynamicFieldsDocument } from './generated/queries.js';
13
+ import { fromBase64 } from '@mysten/utils';
14
+ import { normalizeStructTag } from '../utils/sui-types.js';
15
+ import { deriveDynamicFieldID } from '../utils/dynamic-fields.js';
12
16
  import type { TransactionPlugin } from '../transactions/index.js';
13
17
 
14
18
  export type GraphQLDocument<
@@ -66,6 +70,21 @@ export function isSuiGraphQLClient(client: unknown): client is SuiGraphQLClient
66
70
  );
67
71
  }
68
72
 
73
+ export interface DynamicFieldInclude {
74
+ value?: boolean;
75
+ }
76
+
77
+ export type DynamicFieldEntryWithValue<Include extends DynamicFieldInclude = {}> =
78
+ SuiClientTypes.DynamicFieldEntry & {
79
+ value: Include extends { value: true } ? SuiClientTypes.DynamicFieldValue : undefined;
80
+ };
81
+
82
+ export interface ListDynamicFieldsWithValueResponse<Include extends DynamicFieldInclude = {}> {
83
+ hasNextPage: boolean;
84
+ cursor: string | null;
85
+ dynamicFields: DynamicFieldEntryWithValue<Include>[];
86
+ }
87
+
69
88
  export class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> = {}>
70
89
  extends BaseClient
71
90
  implements SuiClientTypes.TransportMethods
@@ -220,10 +239,83 @@ export class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> =
220
239
  return this.core.getReferenceGasPrice();
221
240
  }
222
241
 
223
- listDynamicFields(
224
- input: SuiClientTypes.ListDynamicFieldsOptions,
225
- ): Promise<SuiClientTypes.ListDynamicFieldsResponse> {
226
- return this.core.listDynamicFields(input);
242
+ async listDynamicFields<Include extends DynamicFieldInclude = {}>(
243
+ input: SuiClientTypes.ListDynamicFieldsOptions & { include?: Include & DynamicFieldInclude },
244
+ ): Promise<ListDynamicFieldsWithValueResponse<Include>> {
245
+ const includeValue = input.include?.value ?? false;
246
+
247
+ const { data, errors } = await this.query({
248
+ query: GetDynamicFieldsDocument,
249
+ variables: {
250
+ parentId: input.parentId,
251
+ first: input.limit,
252
+ cursor: input.cursor,
253
+ includeValue,
254
+ },
255
+ });
256
+
257
+ if (errors?.length) {
258
+ throw errors.length === 1
259
+ ? new Error(errors[0].message)
260
+ : new AggregateError(errors.map((e) => new Error(e.message)));
261
+ }
262
+
263
+ const result = data?.address?.dynamicFields;
264
+ if (!result) {
265
+ throw new Error('Missing response data');
266
+ }
267
+
268
+ return {
269
+ dynamicFields: result.nodes.map((dynamicField): DynamicFieldEntryWithValue<Include> => {
270
+ const valueType =
271
+ dynamicField.value?.__typename === 'MoveObject'
272
+ ? dynamicField.value.contents?.type?.repr!
273
+ : dynamicField.value?.type?.repr!;
274
+ const isDynamicObject = dynamicField.value?.__typename === 'MoveObject';
275
+ const derivedNameType = isDynamicObject
276
+ ? `0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>`
277
+ : dynamicField.name?.type?.repr!;
278
+
279
+ let value: SuiClientTypes.DynamicFieldValue | undefined;
280
+ if (includeValue) {
281
+ let valueBcs: Uint8Array;
282
+ if (dynamicField.value?.__typename === 'MoveValue') {
283
+ valueBcs = fromBase64(dynamicField.value.bcs ?? '');
284
+ } else if (dynamicField.value?.__typename === 'MoveObject') {
285
+ valueBcs = fromBase64(dynamicField.value.contents?.bcs ?? '');
286
+ } else {
287
+ valueBcs = new Uint8Array();
288
+ }
289
+ value = { type: valueType, bcs: valueBcs };
290
+ }
291
+
292
+ return {
293
+ $kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
294
+ fieldId: deriveDynamicFieldID(
295
+ input.parentId,
296
+ derivedNameType,
297
+ fromBase64(dynamicField.name?.bcs!),
298
+ ),
299
+ type: normalizeStructTag(
300
+ isDynamicObject
301
+ ? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>,0x2::object::ID>`
302
+ : `0x2::dynamic_field::Field<${dynamicField.name?.type?.repr},${valueType}>`,
303
+ ),
304
+ name: {
305
+ type: dynamicField.name?.type?.repr!,
306
+ bcs: fromBase64(dynamicField.name?.bcs!),
307
+ },
308
+ valueType,
309
+ childId:
310
+ isDynamicObject && dynamicField.value?.__typename === 'MoveObject'
311
+ ? dynamicField.value.address
312
+ : undefined,
313
+ value: (includeValue ? value : undefined) as DynamicFieldEntryWithValue<Include>['value'],
314
+ } as DynamicFieldEntryWithValue<Include>;
315
+ }),
316
+ cursor: result.pageInfo.endCursor ?? null,
317
+ hasNextPage: result.pageInfo.hasNextPage,
318
+ };
227
319
  }
228
320
 
229
321
  getDynamicField(