@mysten/sui 1.28.1 → 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 +14 -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 +2 -1
  7. package/dist/cjs/experimental/core.js +12 -1
  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 +27 -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 +2 -1
  51. package/dist/esm/experimental/core.js +12 -1
  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 +27 -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 +17 -1
  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 +38 -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
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mysten Labs <build@mystenlabs.com>",
4
4
  "description": "Sui TypeScript API(Work in Progress)",
5
5
  "homepage": "https://sdk.mystenlabs.com",
6
- "version": "1.28.1",
6
+ "version": "1.29.0",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -116,8 +116,10 @@
116
116
  "@graphql-codegen/cli": "^5.0.5",
117
117
  "@graphql-codegen/typed-document-node": "^5.1.1",
118
118
  "@graphql-codegen/typescript": "4.1.6",
119
+ "@graphql-codegen/typescript-document-nodes": "4.0.16",
119
120
  "@graphql-codegen/typescript-operations": "^4.6.0",
120
121
  "@iarna/toml": "^2.2.5",
122
+ "@parcel/watcher": "^2.5.1",
121
123
  "@types/node": "^22.13.17",
122
124
  "@types/tmp": "^0.2.6",
123
125
  "@types/ws": "^8.18.1",
@@ -150,6 +152,7 @@
150
152
  },
151
153
  "scripts": {
152
154
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
155
+ "codegen:graphql": "graphql-codegen --config graphql-codegen.ts",
153
156
  "codegen:version": "node genversion.mjs",
154
157
  "build": "node genversion.mjs && pnpm build:package",
155
158
  "build:package": "build-package",
@@ -98,6 +98,8 @@ import type {
98
98
  TryGetPastObjectParams,
99
99
  Unsubscribe,
100
100
  ValidatorsApy,
101
+ VerifyZkLoginSignatureParams,
102
+ ZkLoginVerifyResult,
101
103
  } from './types/index.js';
102
104
 
103
105
  export interface PaginationArguments<Cursor> {
@@ -883,6 +885,14 @@ export class SuiClient extends Experimental_BaseClient implements SelfRegisterin
883
885
  });
884
886
  }
885
887
 
888
+ async verifyZkLoginSignature(input: VerifyZkLoginSignatureParams): Promise<ZkLoginVerifyResult> {
889
+ return await this.transport.request({
890
+ method: 'sui_verifyZkLoginSignature',
891
+ params: [input.bytes, input.signature, input.intentScope, input.author],
892
+ signal: input.signal,
893
+ });
894
+ }
895
+
886
896
  /**
887
897
  * Wait for a transaction block result to be available over the API.
888
898
  * This can be used in conjunction with `executeTransactionBlock` to wait for the transaction to
@@ -17,6 +17,19 @@ export abstract class Experimental_CoreClient
17
17
  options: Experimental_SuiClientTypes.GetObjectsOptions,
18
18
  ): Promise<Experimental_SuiClientTypes.GetObjectsResponse>;
19
19
 
20
+ async getObject(
21
+ options: Experimental_SuiClientTypes.GetObjectOptions,
22
+ ): Promise<Experimental_SuiClientTypes.GetObjectResponse> {
23
+ const { objectId } = options;
24
+ const {
25
+ objects: [result],
26
+ } = await this.getObjects({ objectIds: [objectId], signal: options.signal });
27
+ if (result instanceof Error) {
28
+ throw result;
29
+ }
30
+ return { object: result };
31
+ }
32
+
20
33
  abstract getCoins(
21
34
  options: Experimental_SuiClientTypes.GetCoinsOptions,
22
35
  ): Promise<Experimental_SuiClientTypes.GetCoinsResponse>;
@@ -45,7 +58,9 @@ export abstract class Experimental_CoreClient
45
58
  options: Experimental_SuiClientTypes.DryRunTransactionOptions,
46
59
  ): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse>;
47
60
 
48
- abstract getReferenceGasPrice(): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse>;
61
+ abstract getReferenceGasPrice(
62
+ options?: Experimental_SuiClientTypes.GetReferenceGasPriceOptions,
63
+ ): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse>;
49
64
 
50
65
  abstract getDynamicFields(
51
66
  options: Experimental_SuiClientTypes.GetDynamicFieldsOptions,
@@ -63,6 +78,7 @@ export abstract class Experimental_CoreClient
63
78
  objects: [fieldObject],
64
79
  } = await this.getObjects({
65
80
  objectIds: [fieldId],
81
+ signal: options.signal,
66
82
  });
67
83
 
68
84
  if (fieldObject instanceof Error) {
@@ -0,0 +1,421 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { Experimental_CoreClient } from '../core.js';
5
+ import type { Experimental_SuiClientTypes } from '../types.js';
6
+ import type { GraphQLQueryOptions, SuiGraphQLClient } from '../../graphql/client.js';
7
+ import type {
8
+ Object_Owner_FieldsFragment,
9
+ Object_FieldsFragment,
10
+ Transaction_FieldsFragment,
11
+ } from '../../graphql/generated/queries.js';
12
+ import {
13
+ DryRunTransactionBlockDocument,
14
+ ExecuteTransactionBlockDocument,
15
+ GetAllBalancesDocument,
16
+ GetBalanceDocument,
17
+ GetCoinsDocument,
18
+ GetDynamicFieldsDocument,
19
+ GetOwnedObjectsDocument,
20
+ GetReferenceGasPriceDocument,
21
+ GetTransactionBlockDocument,
22
+ MultiGetObjectsDocument,
23
+ VerifyZkLoginSignatureDocument,
24
+ ZkLoginIntentScope,
25
+ } from '../../graphql/generated/queries.js';
26
+ import { ObjectError } from '../errors.js';
27
+ import { fromBase64, toBase64 } from '@mysten/utils';
28
+ import { normalizeStructTag, normalizeSuiAddress } from '../../utils/sui-types.js';
29
+ import { deriveDynamicFieldID } from '../../utils/dynamic-fields.js';
30
+ import { parseTransactionEffects } from './utils.js';
31
+
32
+ export class GraphQLTransport extends Experimental_CoreClient {
33
+ #graphqlClient: SuiGraphQLClient;
34
+
35
+ constructor(graphqlClient: SuiGraphQLClient) {
36
+ super({ network: graphqlClient.network });
37
+ this.#graphqlClient = graphqlClient;
38
+ }
39
+
40
+ async #graphqlQuery<
41
+ Result = Record<string, unknown>,
42
+ Variables = Record<string, unknown>,
43
+ Data = Result,
44
+ >(
45
+ options: GraphQLQueryOptions<Result, Variables>,
46
+ getData?: (result: Result) => Data,
47
+ ): Promise<NonNullable<Data>> {
48
+ const { data, errors } = await this.#graphqlClient.query(options);
49
+
50
+ handleGraphQLErrors(errors);
51
+
52
+ const extractedData = data && (getData ? getData(data) : data);
53
+
54
+ if (extractedData == null) {
55
+ throw new Error('Missing response data');
56
+ }
57
+
58
+ return extractedData as NonNullable<Data>;
59
+ }
60
+
61
+ async getObjects(
62
+ options: Experimental_SuiClientTypes.GetObjectsOptions,
63
+ ): Promise<Experimental_SuiClientTypes.GetObjectsResponse> {
64
+ const objects: Object_FieldsFragment[] = [];
65
+
66
+ let hasNextPage = true;
67
+ let cursor: string | null = null;
68
+
69
+ while (hasNextPage) {
70
+ const objectsPage = await this.#graphqlQuery(
71
+ {
72
+ query: MultiGetObjectsDocument,
73
+ variables: {
74
+ objectIds: options.objectIds,
75
+ cursor,
76
+ },
77
+ },
78
+ (result) => result.objects,
79
+ );
80
+
81
+ objects.push(...objectsPage.nodes);
82
+ hasNextPage = objectsPage.pageInfo.hasNextPage;
83
+ cursor = (objectsPage.pageInfo.endCursor ?? null) as string | null;
84
+ }
85
+
86
+ return {
87
+ objects: options.objectIds
88
+ .map((id) => normalizeSuiAddress(id))
89
+ .map(
90
+ (id) =>
91
+ objects.find((obj) => obj.address === id) ??
92
+ new ObjectError('notFound', `Object ${id} not found`),
93
+ )
94
+ .map((obj) => {
95
+ if (obj instanceof ObjectError) {
96
+ return obj;
97
+ }
98
+ return {
99
+ id: obj.address,
100
+ version: obj.version,
101
+ digest: obj.digest!,
102
+ owner: mapOwner(obj.owner!),
103
+ type: obj.asMoveObject?.contents?.type?.repr!,
104
+ content: fromBase64(obj.asMoveObject?.contents?.bcs!),
105
+ };
106
+ }),
107
+ };
108
+ }
109
+ async getOwnedObjects(
110
+ options: Experimental_SuiClientTypes.GetOwnedObjectsOptions,
111
+ ): Promise<Experimental_SuiClientTypes.GetOwnedObjectsResponse> {
112
+ const objects = await this.#graphqlQuery(
113
+ {
114
+ query: GetOwnedObjectsDocument,
115
+ variables: {
116
+ owner: options.address,
117
+ limit: options.limit,
118
+ cursor: options.cursor,
119
+ filter: options.type ? { type: options.type } : undefined,
120
+ },
121
+ },
122
+ (result) => result.address?.objects,
123
+ );
124
+
125
+ return {
126
+ objects: objects.nodes.map((obj) => ({
127
+ id: obj.address,
128
+ version: obj.version,
129
+ digest: obj.digest!,
130
+ owner: mapOwner(obj.owner!),
131
+ type: obj.contents?.type?.repr!,
132
+ content: fromBase64(obj.contents?.bcs!),
133
+ })),
134
+ hasNextPage: objects.pageInfo.hasNextPage,
135
+ cursor: objects.pageInfo.endCursor ?? null,
136
+ };
137
+ }
138
+ async getCoins(
139
+ options: Experimental_SuiClientTypes.GetCoinsOptions,
140
+ ): Promise<Experimental_SuiClientTypes.GetCoinsResponse> {
141
+ const coins = await this.#graphqlQuery(
142
+ {
143
+ query: GetCoinsDocument,
144
+ variables: {
145
+ owner: options.address,
146
+ cursor: options.cursor,
147
+ first: options.limit,
148
+ type: options.coinType,
149
+ },
150
+ },
151
+ (result) => result.address?.coins,
152
+ );
153
+
154
+ return {
155
+ cursor: coins.pageInfo.endCursor ?? null,
156
+ hasNextPage: coins.pageInfo.hasNextPage,
157
+ objects: coins.nodes.map((coin) => ({
158
+ id: coin.address,
159
+ version: coin.version,
160
+ digest: coin.digest!,
161
+ owner: mapOwner(coin.owner!),
162
+ type: coin.contents?.type?.repr!,
163
+ balance: coin.coinBalance,
164
+ content: fromBase64(coin.contents?.bcs!),
165
+ })),
166
+ };
167
+ }
168
+
169
+ async getBalance(
170
+ options: Experimental_SuiClientTypes.GetBalanceOptions,
171
+ ): Promise<Experimental_SuiClientTypes.GetBalanceResponse> {
172
+ const result = await this.#graphqlQuery(
173
+ {
174
+ query: GetBalanceDocument,
175
+ variables: { owner: options.address, type: options.coinType },
176
+ },
177
+ (result) => result.address?.balance,
178
+ );
179
+
180
+ return {
181
+ balance: {
182
+ coinType: result.coinType.repr,
183
+ balance: result.totalBalance,
184
+ },
185
+ };
186
+ }
187
+ async getAllBalances(
188
+ options: Experimental_SuiClientTypes.GetAllBalancesOptions,
189
+ ): Promise<Experimental_SuiClientTypes.GetAllBalancesResponse> {
190
+ const balances = await this.#graphqlQuery(
191
+ {
192
+ query: GetAllBalancesDocument,
193
+ variables: { owner: options.address },
194
+ },
195
+ (result) => result.address?.balances,
196
+ );
197
+
198
+ return {
199
+ cursor: balances.pageInfo.endCursor ?? null,
200
+ hasNextPage: balances.pageInfo.hasNextPage,
201
+ balances: balances.nodes.map((balance) => ({
202
+ coinType: balance.coinType.repr,
203
+ balance: balance.totalBalance,
204
+ })),
205
+ };
206
+ }
207
+ async getTransaction(
208
+ options: Experimental_SuiClientTypes.GetTransactionOptions,
209
+ ): Promise<Experimental_SuiClientTypes.GetTransactionResponse> {
210
+ const result = await this.#graphqlQuery(
211
+ {
212
+ query: GetTransactionBlockDocument,
213
+ variables: { digest: options.digest },
214
+ },
215
+ (result) => result.transactionBlock,
216
+ );
217
+
218
+ return {
219
+ transaction: parseTransaction(result),
220
+ };
221
+ }
222
+ async executeTransaction(
223
+ options: Experimental_SuiClientTypes.ExecuteTransactionOptions,
224
+ ): Promise<Experimental_SuiClientTypes.ExecuteTransactionResponse> {
225
+ const result = await this.#graphqlQuery(
226
+ {
227
+ query: ExecuteTransactionBlockDocument,
228
+ variables: { txBytes: toBase64(options.transaction), signatures: options.signatures },
229
+ },
230
+ (result) => result.executeTransactionBlock,
231
+ );
232
+
233
+ if (result.errors) {
234
+ if (result.errors.length === 1) {
235
+ throw new Error(result.errors[0]);
236
+ }
237
+ throw new AggregateError(result.errors.map((error) => new Error(error)));
238
+ }
239
+
240
+ return {
241
+ transaction: parseTransaction(result.effects.transactionBlock!),
242
+ };
243
+ }
244
+ async dryRunTransaction(
245
+ options: Experimental_SuiClientTypes.DryRunTransactionOptions,
246
+ ): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse> {
247
+ const result = await this.#graphqlQuery(
248
+ {
249
+ query: DryRunTransactionBlockDocument,
250
+ variables: { txBytes: toBase64(options.transaction) },
251
+ },
252
+ (result) => result.dryRunTransactionBlock,
253
+ );
254
+
255
+ if (result.error) {
256
+ throw new Error(result.error);
257
+ }
258
+
259
+ return {
260
+ transaction: parseTransaction(result.transaction!),
261
+ };
262
+ }
263
+ async getReferenceGasPrice(): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse> {
264
+ const result = await this.#graphqlQuery(
265
+ {
266
+ query: GetReferenceGasPriceDocument,
267
+ },
268
+ (result) => result.epoch?.referenceGasPrice,
269
+ );
270
+
271
+ return {
272
+ referenceGasPrice: result.referenceGasPrice,
273
+ };
274
+ }
275
+
276
+ async getDynamicFields(
277
+ options: Experimental_SuiClientTypes.GetDynamicFieldsOptions,
278
+ ): Promise<Experimental_SuiClientTypes.GetDynamicFieldsResponse> {
279
+ const result = await this.#graphqlQuery(
280
+ {
281
+ query: GetDynamicFieldsDocument,
282
+ variables: { parentId: options.parentId },
283
+ },
284
+ (result) => result.owner?.dynamicFields,
285
+ );
286
+
287
+ return {
288
+ dynamicFields: result.nodes.map((dynamicField) => {
289
+ const valueType =
290
+ dynamicField.value?.__typename === 'MoveObject'
291
+ ? dynamicField.value.contents?.type?.repr!
292
+ : dynamicField.value?.type.repr!;
293
+ return {
294
+ id: deriveDynamicFieldID(
295
+ options.parentId,
296
+ dynamicField.name?.type.repr!,
297
+ dynamicField.name?.bcs!,
298
+ ),
299
+ type: normalizeStructTag(
300
+ dynamicField.value?.__typename === 'MoveObject'
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
+ };
310
+ }),
311
+ cursor: result.pageInfo.endCursor ?? null,
312
+ hasNextPage: result.pageInfo.hasNextPage,
313
+ };
314
+ }
315
+
316
+ async verifyZkLoginSignature(
317
+ options: Experimental_SuiClientTypes.VerifyZkLoginSignatureOptions,
318
+ ): Promise<Experimental_SuiClientTypes.ZkLoginVerifyResponse> {
319
+ const intentScope =
320
+ options.intentScope === 'TransactionData'
321
+ ? ZkLoginIntentScope.TransactionData
322
+ : ZkLoginIntentScope.PersonalMessage;
323
+
324
+ const result = await this.#graphqlQuery(
325
+ {
326
+ query: VerifyZkLoginSignatureDocument,
327
+ variables: {
328
+ bytes: options.bytes,
329
+ signature: options.signature,
330
+ intentScope,
331
+ author: options.author,
332
+ },
333
+ },
334
+ (result) => result.verifyZkloginSignature,
335
+ );
336
+
337
+ return {
338
+ success: result.success,
339
+ errors: result.errors,
340
+ };
341
+ }
342
+ }
343
+ export type GraphQLResponseErrors = Array<{
344
+ message: string;
345
+ locations?: { line: number; column: number }[];
346
+ path?: (string | number)[];
347
+ }>;
348
+
349
+ function handleGraphQLErrors(errors: GraphQLResponseErrors | undefined): void {
350
+ if (!errors || errors.length === 0) return;
351
+
352
+ const errorInstances = errors.map((error) => new GraphQLResponseError(error));
353
+
354
+ if (errorInstances.length === 1) {
355
+ throw errorInstances[0];
356
+ }
357
+
358
+ throw new AggregateError(errorInstances);
359
+ }
360
+
361
+ class GraphQLResponseError extends Error {
362
+ locations?: Array<{ line: number; column: number }>;
363
+
364
+ constructor(error: GraphQLResponseErrors[0]) {
365
+ super(error.message);
366
+ this.locations = error.locations;
367
+ }
368
+ }
369
+
370
+ function mapOwner(owner: Object_Owner_FieldsFragment): Experimental_SuiClientTypes.ObjectOwner {
371
+ switch (owner.__typename) {
372
+ case 'AddressOwner':
373
+ return { $kind: 'AddressOwner', AddressOwner: owner.owner?.asAddress?.address };
374
+ case 'ConsensusV2':
375
+ return { $kind: 'ConsensusV2', ConsensusV2: owner.authenticator!.address };
376
+ case 'Immutable':
377
+ return { $kind: 'Immutable', Immutable: true };
378
+ case 'Parent':
379
+ return { $kind: 'ObjectOwner', ObjectOwner: owner.parent?.address };
380
+ case 'Shared':
381
+ return { $kind: 'Shared', Shared: owner.initialSharedVersion };
382
+ }
383
+ }
384
+
385
+ function parseTransaction(
386
+ transaction: Transaction_FieldsFragment,
387
+ ): Experimental_SuiClientTypes.TransactionResponse {
388
+ const objectTypes: Record<string, string> = {};
389
+
390
+ transaction.effects?.unchangedSharedObjects.nodes.forEach((node) => {
391
+ if (node.__typename === 'SharedObjectRead') {
392
+ const type = node.object?.asMoveObject?.contents?.type.repr;
393
+ const address = node.object?.asMoveObject?.address;
394
+
395
+ if (type && address) {
396
+ objectTypes[address] = type;
397
+ }
398
+ }
399
+ });
400
+
401
+ transaction.effects?.objectChanges.nodes.forEach((node) => {
402
+ const address = node.address;
403
+ const type =
404
+ node.inputState?.asMoveObject?.contents?.type.repr ??
405
+ node.outputState?.asMoveObject?.contents?.type.repr;
406
+
407
+ if (address && type) {
408
+ objectTypes[address] = type;
409
+ }
410
+ });
411
+
412
+ return {
413
+ digest: transaction.digest!,
414
+ effects: parseTransactionEffects({
415
+ effects: new Uint8Array(transaction.effects?.bcs!),
416
+ objectTypes,
417
+ }),
418
+ bcs: transaction.bcs!,
419
+ signatures: transaction.signatures!,
420
+ };
421
+ }