@mysten/sui 1.28.2 → 1.29.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 (117) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +5 -4
  3. package/dist/cjs/client/client.d.ts +2 -1
  4. package/dist/cjs/client/client.js +7 -0
  5. package/dist/cjs/client/client.js.map +2 -2
  6. package/dist/cjs/experimental/core.d.ts +1 -1
  7. package/dist/cjs/experimental/core.js +3 -2
  8. package/dist/cjs/experimental/core.js.map +2 -2
  9. package/dist/cjs/experimental/transports/graphql.d.ts +26 -0
  10. package/dist/cjs/experimental/transports/graphql.js +310 -0
  11. package/dist/cjs/experimental/transports/graphql.js.map +7 -0
  12. package/dist/cjs/experimental/transports/jsonRPC.d.ts +5 -3
  13. package/dist/cjs/experimental/transports/jsonRPC.js +53 -105
  14. package/dist/cjs/experimental/transports/jsonRPC.js.map +3 -3
  15. package/dist/cjs/experimental/transports/utils.d.ts +6 -0
  16. package/dist/cjs/experimental/transports/utils.js +102 -0
  17. package/dist/cjs/experimental/transports/utils.js.map +7 -0
  18. package/dist/cjs/experimental/types.d.ts +21 -6
  19. package/dist/cjs/experimental/types.js.map +1 -1
  20. package/dist/cjs/faucet/faucet.d.ts +1 -1
  21. package/dist/cjs/faucet/faucet.js.map +1 -1
  22. package/dist/cjs/graphql/client.d.ts +10 -3
  23. package/dist/cjs/graphql/client.js +12 -4
  24. package/dist/cjs/graphql/client.js.map +3 -3
  25. package/dist/cjs/graphql/generated/queries.d.ts +5653 -0
  26. package/dist/cjs/graphql/generated/queries.js +722 -0
  27. package/dist/cjs/graphql/generated/queries.js.map +7 -0
  28. package/dist/cjs/multisig/publickey.d.ts +3 -3
  29. package/dist/cjs/multisig/publickey.js.map +2 -2
  30. package/dist/cjs/transactions/Commands.d.ts +2 -2
  31. package/dist/cjs/transactions/Commands.js.map +2 -2
  32. package/dist/cjs/transactions/Transaction.d.ts +10 -2
  33. package/dist/cjs/transactions/Transaction.js +165 -21
  34. package/dist/cjs/transactions/Transaction.js.map +3 -3
  35. package/dist/cjs/transactions/TransactionData.d.ts +4 -2
  36. package/dist/cjs/transactions/TransactionData.js +72 -41
  37. package/dist/cjs/transactions/TransactionData.js.map +2 -2
  38. package/dist/cjs/transactions/intents/CoinWithBalance.js.map +1 -1
  39. package/dist/cjs/verify/verify.d.ts +5 -5
  40. package/dist/cjs/verify/verify.js.map +2 -2
  41. package/dist/cjs/version.d.ts +2 -2
  42. package/dist/cjs/version.js +2 -2
  43. package/dist/cjs/version.js.map +1 -1
  44. package/dist/cjs/zklogin/publickey.d.ts +9 -3
  45. package/dist/cjs/zklogin/publickey.js +8 -30
  46. package/dist/cjs/zklogin/publickey.js.map +2 -2
  47. package/dist/esm/client/client.d.ts +2 -1
  48. package/dist/esm/client/client.js +7 -0
  49. package/dist/esm/client/client.js.map +2 -2
  50. package/dist/esm/experimental/core.d.ts +1 -1
  51. package/dist/esm/experimental/core.js +3 -2
  52. package/dist/esm/experimental/core.js.map +2 -2
  53. package/dist/esm/experimental/transports/graphql.d.ts +26 -0
  54. package/dist/esm/experimental/transports/graphql.js +303 -0
  55. package/dist/esm/experimental/transports/graphql.js.map +7 -0
  56. package/dist/esm/experimental/transports/jsonRPC.d.ts +5 -3
  57. package/dist/esm/experimental/transports/jsonRPC.js +52 -104
  58. package/dist/esm/experimental/transports/jsonRPC.js.map +2 -2
  59. package/dist/esm/experimental/transports/utils.d.ts +6 -0
  60. package/dist/esm/experimental/transports/utils.js +82 -0
  61. package/dist/esm/experimental/transports/utils.js.map +7 -0
  62. package/dist/esm/experimental/types.d.ts +21 -6
  63. package/dist/esm/faucet/faucet.d.ts +1 -1
  64. package/dist/esm/faucet/faucet.js.map +1 -1
  65. package/dist/esm/graphql/client.d.ts +10 -3
  66. package/dist/esm/graphql/client.js +12 -4
  67. package/dist/esm/graphql/client.js.map +2 -2
  68. package/dist/esm/graphql/generated/queries.d.ts +5653 -0
  69. package/dist/esm/graphql/generated/queries.js +702 -0
  70. package/dist/esm/graphql/generated/queries.js.map +7 -0
  71. package/dist/esm/multisig/publickey.d.ts +3 -3
  72. package/dist/esm/multisig/publickey.js.map +2 -2
  73. package/dist/esm/transactions/Commands.d.ts +2 -2
  74. package/dist/esm/transactions/Commands.js.map +2 -2
  75. package/dist/esm/transactions/Transaction.d.ts +10 -2
  76. package/dist/esm/transactions/Transaction.js +165 -21
  77. package/dist/esm/transactions/Transaction.js.map +3 -3
  78. package/dist/esm/transactions/TransactionData.d.ts +4 -2
  79. package/dist/esm/transactions/TransactionData.js +72 -41
  80. package/dist/esm/transactions/TransactionData.js.map +2 -2
  81. package/dist/esm/transactions/intents/CoinWithBalance.js.map +1 -1
  82. package/dist/esm/verify/verify.d.ts +5 -5
  83. package/dist/esm/verify/verify.js.map +2 -2
  84. package/dist/esm/version.d.ts +2 -2
  85. package/dist/esm/version.js +2 -2
  86. package/dist/esm/version.js.map +1 -1
  87. package/dist/esm/zklogin/publickey.d.ts +9 -3
  88. package/dist/esm/zklogin/publickey.js +8 -30
  89. package/dist/esm/zklogin/publickey.js.map +2 -2
  90. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  91. package/dist/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +4 -1
  93. package/src/client/client.ts +10 -0
  94. package/src/experimental/core.ts +5 -2
  95. package/src/experimental/transports/graphql.ts +421 -0
  96. package/src/experimental/transports/jsonRPC.ts +47 -132
  97. package/src/experimental/transports/utils.ts +117 -0
  98. package/src/experimental/types.ts +30 -7
  99. package/src/faucet/faucet.ts +1 -1
  100. package/src/graphql/client.ts +21 -3
  101. package/src/graphql/generated/queries.ts +6061 -0
  102. package/src/graphql/queries/getAllBalances.graphql +20 -0
  103. package/src/graphql/queries/getBalance.graphql +14 -0
  104. package/src/graphql/queries/getCoins.graphql +29 -0
  105. package/src/graphql/queries/getDynamicFields.graphql +36 -0
  106. package/src/graphql/queries/getReferenceGasPrice.graphql +8 -0
  107. package/src/graphql/queries/objects.graphql +89 -0
  108. package/src/graphql/queries/transactions.graphql +80 -0
  109. package/src/graphql/queries/verifyZkLoginSignature.graphql +16 -0
  110. package/src/multisig/publickey.ts +3 -3
  111. package/src/transactions/Commands.ts +3 -2
  112. package/src/transactions/Transaction.ts +215 -12
  113. package/src/transactions/TransactionData.ts +86 -46
  114. package/src/transactions/intents/CoinWithBalance.ts +1 -1
  115. package/src/verify/verify.ts +6 -6
  116. package/src/version.ts +2 -2
  117. package/src/zklogin/publickey.ts +23 -39
@@ -18,6 +18,7 @@ import { normalizeStructTag } from '../../utils/sui-types.js';
18
18
  import { Experimental_CoreClient } from '../core.js';
19
19
  import { ObjectError } from '../errors.js';
20
20
  import type { Experimental_SuiClientTypes } from '../types.js';
21
+ import { parseTransactionEffects } from './utils.js';
21
22
 
22
23
  export class JSONRpcTransport extends Experimental_CoreClient {
23
24
  #jsonRpcClient: SuiClient;
@@ -39,6 +40,7 @@ export class JSONRpcTransport extends Experimental_CoreClient {
39
40
  showType: true,
40
41
  showBcs: true,
41
42
  },
43
+ signal: options.signal,
42
44
  });
43
45
 
44
46
  for (const [idx, object] of objects.entries()) {
@@ -64,6 +66,7 @@ export class JSONRpcTransport extends Experimental_CoreClient {
64
66
  showType: true,
65
67
  showBcs: true,
66
68
  },
69
+ signal: options.signal,
67
70
  });
68
71
 
69
72
  return {
@@ -83,6 +86,9 @@ export class JSONRpcTransport extends Experimental_CoreClient {
83
86
  const coins = await this.#jsonRpcClient.getCoins({
84
87
  owner: options.address,
85
88
  coinType: options.coinType,
89
+ limit: options.limit,
90
+ cursor: options.cursor,
91
+ signal: options.signal,
86
92
  });
87
93
 
88
94
  return {
@@ -114,6 +120,7 @@ export class JSONRpcTransport extends Experimental_CoreClient {
114
120
  const balance = await this.#jsonRpcClient.getBalance({
115
121
  owner: options.address,
116
122
  coinType: options.coinType,
123
+ signal: options.signal,
117
124
  });
118
125
 
119
126
  return {
@@ -126,6 +133,7 @@ export class JSONRpcTransport extends Experimental_CoreClient {
126
133
  async getAllBalances(options: Experimental_SuiClientTypes.GetAllBalancesOptions) {
127
134
  const balances = await this.#jsonRpcClient.getAllBalances({
128
135
  owner: options.address,
136
+ signal: options.signal,
129
137
  });
130
138
 
131
139
  return {
@@ -146,6 +154,7 @@ export class JSONRpcTransport extends Experimental_CoreClient {
146
154
  showRawEffects: true,
147
155
  showEvents: true,
148
156
  },
157
+ signal: options.signal,
149
158
  });
150
159
 
151
160
  return {
@@ -162,6 +171,7 @@ export class JSONRpcTransport extends Experimental_CoreClient {
162
171
  showObjectChanges: true,
163
172
  showRawInput: true,
164
173
  },
174
+ signal: options.signal,
165
175
  });
166
176
 
167
177
  return {
@@ -172,6 +182,7 @@ export class JSONRpcTransport extends Experimental_CoreClient {
172
182
  const tx = Transaction.from(options.transaction);
173
183
  const result = await this.#jsonRpcClient.dryRunTransactionBlock({
174
184
  transactionBlock: options.transaction,
185
+ signal: options.signal,
175
186
  });
176
187
 
177
188
  return {
@@ -186,8 +197,10 @@ export class JSONRpcTransport extends Experimental_CoreClient {
186
197
  },
187
198
  };
188
199
  }
189
- async getReferenceGasPrice() {
190
- const referenceGasPrice = await this.#jsonRpcClient.getReferenceGasPrice();
200
+ async getReferenceGasPrice(options?: Experimental_SuiClientTypes.GetReferenceGasPriceOptions) {
201
+ const referenceGasPrice = await this.#jsonRpcClient.getReferenceGasPrice({
202
+ signal: options?.signal,
203
+ });
191
204
  return {
192
205
  referenceGasPrice: String(referenceGasPrice),
193
206
  };
@@ -201,20 +214,34 @@ export class JSONRpcTransport extends Experimental_CoreClient {
201
214
  });
202
215
 
203
216
  return {
204
- dynamicFields: dynamicFields.data.map((dynamicField) => ({
205
- id: dynamicField.objectId,
206
- version: dynamicField.version,
207
- digest: dynamicField.digest,
208
- type: dynamicField.objectType,
209
- name: {
210
- type: dynamicField.name.type,
211
- bcs: fromBase64(dynamicField.bcsName),
212
- },
213
- })),
217
+ dynamicFields: dynamicFields.data.map((dynamicField) => {
218
+ return {
219
+ id: dynamicField.objectId,
220
+ type: dynamicField.objectType,
221
+ name: {
222
+ type: dynamicField.name.type,
223
+ bcs: fromBase64(dynamicField.bcsName),
224
+ },
225
+ };
226
+ }),
214
227
  hasNextPage: dynamicFields.hasNextPage,
215
228
  cursor: dynamicFields.nextCursor,
216
229
  };
217
230
  }
231
+
232
+ async verifyZkLoginSignature(options: Experimental_SuiClientTypes.VerifyZkLoginSignatureOptions) {
233
+ const result = await this.#jsonRpcClient.verifyZkLoginSignature({
234
+ bytes: options.bytes,
235
+ signature: options.signature,
236
+ intentScope: options.intentScope,
237
+ author: options.author,
238
+ });
239
+
240
+ return {
241
+ success: result.success,
242
+ errors: result.errors,
243
+ };
244
+ }
218
245
  }
219
246
 
220
247
  function parseObject(object: SuiObjectData): Experimental_SuiClientTypes.ObjectResponse {
@@ -280,134 +307,22 @@ function parseTransaction(
280
307
  transaction: SuiTransactionBlockResponse,
281
308
  ): Experimental_SuiClientTypes.TransactionResponse {
282
309
  const parsedTx = bcs.SenderSignedData.parse(fromBase64(transaction.rawTransaction!))[0];
283
-
284
- return {
285
- digest: transaction.digest,
286
- effects: parseTransactionEffects({
287
- effects: new Uint8Array(transaction.rawEffects!),
288
- objectChanges: transaction.objectChanges ?? null,
289
- }),
290
- bcs: bcs.TransactionData.serialize(parsedTx.intentMessage.value).toBytes(),
291
- signatures: parsedTx.txSignatures,
292
- };
293
- }
294
-
295
- function parseTransactionEffects({
296
- effects,
297
- epoch,
298
- objectChanges,
299
- }: {
300
- effects: Uint8Array;
301
- objectChanges: SuiObjectChange[] | null;
302
- epoch?: string | null;
303
- }): Experimental_SuiClientTypes.TransactionEffects {
304
- const parsed = bcs.TransactionEffects.parse(effects);
305
310
  const objectTypes: Record<string, string> = {};
306
311
 
307
- objectChanges?.forEach((change) => {
312
+ transaction.objectChanges?.forEach((change) => {
308
313
  if (change.type !== 'published') {
309
314
  objectTypes[change.objectId] = change.objectType;
310
315
  }
311
316
  });
312
317
 
313
- switch (parsed.$kind) {
314
- case 'V1':
315
- return parseTransactionEffectsV1({ bytes: effects, effects: parsed.V1, epoch, objectTypes });
316
- case 'V2':
317
- return parseTransactionEffectsV2({ bytes: effects, effects: parsed.V2, epoch, objectTypes });
318
- default:
319
- throw new Error(
320
- `Unknown transaction effects version: ${(parsed as { $kind: string }).$kind}`,
321
- );
322
- }
323
- }
324
-
325
- function parseTransactionEffectsV1(_: {
326
- bytes: Uint8Array;
327
- effects: NonNullable<(typeof bcs.TransactionEffects.$inferType)['V1']>;
328
- epoch?: string | null;
329
- objectTypes: Record<string, string>;
330
- }): Experimental_SuiClientTypes.TransactionEffects {
331
- throw new Error('V1 effects are not supported yet');
332
- }
333
-
334
- function parseTransactionEffectsV2({
335
- bytes,
336
- effects,
337
- epoch,
338
- objectTypes,
339
- }: {
340
- bytes: Uint8Array;
341
- effects: NonNullable<(typeof bcs.TransactionEffects.$inferType)['V2']>;
342
- epoch?: string | null;
343
- objectTypes: Record<string, string>;
344
- }): Experimental_SuiClientTypes.TransactionEffects {
345
- const changedObjects = effects.changedObjects.map(
346
- ([id, change]): Experimental_SuiClientTypes.ChangedObject => {
347
- return {
348
- id,
349
- inputState: change.inputState.$kind === 'Exist' ? 'Exists' : 'DoesNotExist',
350
- inputVersion: change.inputState.Exist?.[0][0] ?? null,
351
- inputDigest: change.inputState.Exist?.[0][1] ?? null,
352
- inputOwner: change.inputState.Exist?.[1] ?? null,
353
- outputState:
354
- change.outputState.$kind === 'NotExist' ? 'DoesNotExist' : change.outputState.$kind,
355
- outputVersion:
356
- change.outputState.$kind === 'PackageWrite'
357
- ? change.outputState.PackageWrite?.[0]
358
- : change.outputState.ObjectWrite
359
- ? effects.lamportVersion
360
- : null,
361
- outputDigest:
362
- change.outputState.$kind === 'PackageWrite'
363
- ? change.outputState.PackageWrite?.[1]
364
- : (change.outputState.ObjectWrite?.[0] ?? null),
365
- outputOwner: change.outputState.ObjectWrite ? change.outputState.ObjectWrite[1] : null,
366
- idOperation: change.idOperation.$kind,
367
- objectType: objectTypes[id] ?? null,
368
- };
369
- },
370
- );
371
-
372
318
  return {
373
- bcs: bytes,
374
- digest: effects.transactionDigest,
375
- version: 2,
376
- status:
377
- effects.status.$kind === 'Success'
378
- ? {
379
- success: true,
380
- error: null,
381
- }
382
- : {
383
- success: false,
384
- // TODO: add command
385
- error: effects.status.Failed.error.$kind,
386
- },
387
- epoch: epoch ?? null,
388
- gasUsed: effects.gasUsed,
389
- transactionDigest: effects.transactionDigest,
390
- gasObject:
391
- effects.gasObjectIndex === null ? null : (changedObjects[effects.gasObjectIndex] ?? null),
392
- eventsDigest: effects.eventsDigest,
393
- dependencies: effects.dependencies,
394
- lamportVersion: effects.lamportVersion,
395
- changedObjects,
396
- unchangedSharedObjects: effects.unchangedSharedObjects.map(
397
- ([objectId, object]): Experimental_SuiClientTypes.UnchangedSharedObject => {
398
- return {
399
- kind: object.$kind,
400
- objectId: objectId,
401
- version:
402
- object.$kind === 'ReadOnlyRoot'
403
- ? object.ReadOnlyRoot[0]
404
- : (object[object.$kind] as string | null),
405
- digest: object.$kind === 'ReadOnlyRoot' ? object.ReadOnlyRoot[1] : null,
406
- objectType: objectTypes[objectId] ?? null,
407
- };
408
- },
409
- ),
410
- auxiliaryDataDigest: effects.auxDataDigest,
319
+ digest: transaction.digest,
320
+ effects: parseTransactionEffects({
321
+ effects: new Uint8Array(transaction.rawEffects!),
322
+ objectTypes,
323
+ }),
324
+ bcs: bcs.TransactionData.serialize(parsedTx.intentMessage.value).toBytes(),
325
+ signatures: parsedTx.txSignatures,
411
326
  };
412
327
  }
413
328
 
@@ -0,0 +1,117 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { bcs } from '../../bcs/index.js';
5
+ import type { Experimental_SuiClientTypes } from '../types.js';
6
+
7
+ export function parseTransactionEffects({
8
+ effects,
9
+ epoch,
10
+ objectTypes,
11
+ }: {
12
+ effects: Uint8Array;
13
+ objectTypes: Record<string, string>;
14
+ epoch?: string | null;
15
+ }): Experimental_SuiClientTypes.TransactionEffects {
16
+ const parsed = bcs.TransactionEffects.parse(effects);
17
+
18
+ switch (parsed.$kind) {
19
+ case 'V1':
20
+ return parseTransactionEffectsV1({ bytes: effects, effects: parsed.V1, epoch, objectTypes });
21
+ case 'V2':
22
+ return parseTransactionEffectsV2({ bytes: effects, effects: parsed.V2, epoch, objectTypes });
23
+ default:
24
+ throw new Error(
25
+ `Unknown transaction effects version: ${(parsed as { $kind: string }).$kind}`,
26
+ );
27
+ }
28
+ }
29
+
30
+ function parseTransactionEffectsV1(_: {
31
+ bytes: Uint8Array;
32
+ effects: NonNullable<(typeof bcs.TransactionEffects.$inferType)['V1']>;
33
+ epoch?: string | null;
34
+ objectTypes: Record<string, string>;
35
+ }): Experimental_SuiClientTypes.TransactionEffects {
36
+ throw new Error('V1 effects are not supported yet');
37
+ }
38
+
39
+ function parseTransactionEffectsV2({
40
+ bytes,
41
+ effects,
42
+ epoch,
43
+ objectTypes,
44
+ }: {
45
+ bytes: Uint8Array;
46
+ effects: NonNullable<(typeof bcs.TransactionEffects.$inferType)['V2']>;
47
+ epoch?: string | null;
48
+ objectTypes: Record<string, string>;
49
+ }): Experimental_SuiClientTypes.TransactionEffects {
50
+ const changedObjects = effects.changedObjects.map(
51
+ ([id, change]): Experimental_SuiClientTypes.ChangedObject => {
52
+ return {
53
+ id,
54
+ inputState: change.inputState.$kind === 'Exist' ? 'Exists' : 'DoesNotExist',
55
+ inputVersion: change.inputState.Exist?.[0][0] ?? null,
56
+ inputDigest: change.inputState.Exist?.[0][1] ?? null,
57
+ inputOwner: change.inputState.Exist?.[1] ?? null,
58
+ outputState:
59
+ change.outputState.$kind === 'NotExist' ? 'DoesNotExist' : change.outputState.$kind,
60
+ outputVersion:
61
+ change.outputState.$kind === 'PackageWrite'
62
+ ? change.outputState.PackageWrite?.[0]
63
+ : change.outputState.ObjectWrite
64
+ ? effects.lamportVersion
65
+ : null,
66
+ outputDigest:
67
+ change.outputState.$kind === 'PackageWrite'
68
+ ? change.outputState.PackageWrite?.[1]
69
+ : (change.outputState.ObjectWrite?.[0] ?? null),
70
+ outputOwner: change.outputState.ObjectWrite ? change.outputState.ObjectWrite[1] : null,
71
+ idOperation: change.idOperation.$kind,
72
+ objectType: objectTypes[id] ?? null,
73
+ };
74
+ },
75
+ );
76
+
77
+ return {
78
+ bcs: bytes,
79
+ digest: effects.transactionDigest,
80
+ version: 2,
81
+ status:
82
+ effects.status.$kind === 'Success'
83
+ ? {
84
+ success: true,
85
+ error: null,
86
+ }
87
+ : {
88
+ success: false,
89
+ // TODO: add command
90
+ error: effects.status.Failed.error.$kind,
91
+ },
92
+ epoch: epoch ?? null,
93
+ gasUsed: effects.gasUsed,
94
+ transactionDigest: effects.transactionDigest,
95
+ gasObject:
96
+ effects.gasObjectIndex === null ? null : (changedObjects[effects.gasObjectIndex] ?? null),
97
+ eventsDigest: effects.eventsDigest,
98
+ dependencies: effects.dependencies,
99
+ lamportVersion: effects.lamportVersion,
100
+ changedObjects,
101
+ unchangedSharedObjects: effects.unchangedSharedObjects.map(
102
+ ([objectId, object]): Experimental_SuiClientTypes.UnchangedSharedObject => {
103
+ return {
104
+ kind: object.$kind,
105
+ objectId: objectId,
106
+ version:
107
+ object.$kind === 'ReadOnlyRoot'
108
+ ? object.ReadOnlyRoot[0]
109
+ : (object[object.$kind] as string | null),
110
+ digest: object.$kind === 'ReadOnlyRoot' ? object.ReadOnlyRoot[1] : null,
111
+ objectType: objectTypes[objectId] ?? null,
112
+ };
113
+ },
114
+ ),
115
+ auxiliaryDataDigest: effects.auxDataDigest,
116
+ };
117
+ }
@@ -69,6 +69,8 @@ export namespace Experimental_SuiClientTypes {
69
69
  export interface GetCoinsOptions extends CoreClientMethodOptions {
70
70
  address: string;
71
71
  coinType: string;
72
+ limit?: number;
73
+ cursor?: string | null;
72
74
  }
73
75
 
74
76
  export interface GetDynamicFieldsOptions extends CoreClientMethodOptions {
@@ -119,11 +121,9 @@ export namespace Experimental_SuiClientTypes {
119
121
  hasNextPage: boolean;
120
122
  cursor: string | null;
121
123
  dynamicFields: {
122
- name: DynamicFieldName;
123
124
  id: string;
124
- version: string;
125
- digest: string;
126
125
  type: string;
126
+ name: DynamicFieldName;
127
127
  }[];
128
128
  }
129
129
 
@@ -190,11 +190,11 @@ export namespace Experimental_SuiClientTypes {
190
190
  export interface TransactionResponse {
191
191
  digest: string;
192
192
  signatures: string[];
193
+ effects: TransactionEffects;
193
194
  // TODO: Return parsed data:
194
- // We need structured representations of effects, events, and transaction data
195
+ // We need structured representations events, and transaction data
195
196
  bcs: Uint8Array;
196
- effects: TransactionEffects;
197
- events?: Uint8Array;
197
+ // events?: Uint8Array;
198
198
  }
199
199
 
200
200
  export interface GetTransactionOptions extends CoreClientMethodOptions {
@@ -222,14 +222,37 @@ export namespace Experimental_SuiClientTypes {
222
222
  transaction: TransactionResponse;
223
223
  }
224
224
 
225
+ export interface GetReferenceGasPriceOptions extends CoreClientMethodOptions {}
226
+
225
227
  export interface TransportMethods {
226
- getReferenceGasPrice?: () => Promise<GetReferenceGasPriceResponse>;
228
+ getReferenceGasPrice?: (
229
+ options?: GetReferenceGasPriceOptions,
230
+ ) => Promise<GetReferenceGasPriceResponse>;
227
231
  }
228
232
 
229
233
  export interface GetReferenceGasPriceResponse {
230
234
  referenceGasPrice: string;
231
235
  }
232
236
 
237
+ /** ZkLogin methods */
238
+ export interface VerifyZkLoginSignatureOptions extends CoreClientMethodOptions {
239
+ bytes: string;
240
+ signature: string;
241
+ intentScope: 'TransactionData' | 'PersonalMessage';
242
+ author: string;
243
+ }
244
+
245
+ export interface ZkLoginVerifyResponse {
246
+ success: boolean;
247
+ errors: string[];
248
+ }
249
+
250
+ export interface TransportMethods {
251
+ verifyZkLoginSignature?: (
252
+ options: VerifyZkLoginSignatureOptions,
253
+ ) => Promise<ZkLoginVerifyResponse>;
254
+ }
255
+
233
256
  /** ObjectOwner types */
234
257
 
235
258
  export interface AddressOwner {
@@ -31,7 +31,7 @@ type BatchStatusFaucetResponse = {
31
31
 
32
32
  type FaucetResponseV2 = {
33
33
  status: 'Success' | FaucetFailure;
34
- coin_sent: FaucetCoinInfo | null;
34
+ coins_sent: FaucetCoinInfo[] | null;
35
35
  };
36
36
 
37
37
  type FaucetFailure = {
@@ -5,6 +5,10 @@ import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
5
5
  import type { TadaDocumentNode } from 'gql.tada';
6
6
  import type { DocumentNode } from 'graphql';
7
7
  import { print } from 'graphql';
8
+ import { Experimental_BaseClient } from '../experimental/index.js';
9
+ import type { Experimental_SuiClientTypes } from '../experimental/index.js';
10
+ import { GraphQLTransport } from '../experimental/transports/graphql.js';
11
+ import type { TypedDocumentString } from './generated/queries.js';
8
12
 
9
13
  export type GraphQLDocument<
10
14
  Result = Record<string, unknown>,
@@ -12,6 +16,7 @@ export type GraphQLDocument<
12
16
  > =
13
17
  | string
14
18
  | DocumentNode
19
+ | TypedDocumentString<Result, Variables>
15
20
  | TypedDocumentNode<Result, Variables>
16
21
  | TadaDocumentNode<Result, Variables>;
17
22
 
@@ -22,6 +27,7 @@ export type GraphQLQueryOptions<
22
27
  query: GraphQLDocument<Result, Variables>;
23
28
  operationName?: string;
24
29
  extensions?: Record<string, unknown>;
30
+ signal?: AbortSignal;
25
31
  } & (Variables extends { [key: string]: never }
26
32
  ? { variables?: Variables }
27
33
  : {
@@ -45,23 +51,31 @@ export interface SuiGraphQLClientOptions<Queries extends Record<string, GraphQLD
45
51
  fetch?: typeof fetch;
46
52
  headers?: Record<string, string>;
47
53
  queries?: Queries;
54
+ network?: Experimental_SuiClientTypes.Network;
48
55
  }
49
56
 
50
57
  export class SuiGraphQLRequestError extends Error {}
51
58
 
52
- // eslint-disable-next-line @typescript-eslint/ban-types
53
- export class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> = {}> {
59
+ export class SuiGraphQLClient<
60
+ // eslint-disable-next-line @typescript-eslint/ban-types
61
+ Queries extends Record<string, GraphQLDocument> = {},
62
+ > extends Experimental_BaseClient {
54
63
  #url: string;
55
64
  #queries: Queries;
56
65
  #headers: Record<string, string>;
57
66
  #fetch: typeof fetch;
67
+ core: GraphQLTransport = new GraphQLTransport(this);
58
68
 
59
69
  constructor({
60
70
  url,
61
71
  fetch: fetchFn = fetch,
62
72
  headers = {},
63
73
  queries = {} as Queries,
74
+ network = 'unknown',
64
75
  }: SuiGraphQLClientOptions<Queries>) {
76
+ super({
77
+ network,
78
+ });
65
79
  this.#url = url;
66
80
  this.#queries = queries;
67
81
  this.#headers = headers;
@@ -78,11 +92,15 @@ export class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> =
78
92
  ...this.#headers,
79
93
  },
80
94
  body: JSON.stringify({
81
- query: typeof options.query === 'string' ? String(options.query) : print(options.query),
95
+ query:
96
+ typeof options.query === 'string' || options.query instanceof String
97
+ ? String(options.query)
98
+ : print(options.query),
82
99
  variables: options.variables,
83
100
  extensions: options.extensions,
84
101
  operationName: options.operationName,
85
102
  }),
103
+ signal: options.signal,
86
104
  });
87
105
 
88
106
  if (!res.ok) {