@mysten/sui 2.20.3 → 2.21.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.
- package/CHANGELOG.md +18 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +20 -20
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs +4 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/mvr.mjs +29 -7
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +1 -1
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +13 -5
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +68 -46
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/index.d.mts +2 -2
- package/dist/grpc/index.mjs +2 -2
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/jsonRpc/client.d.mts +160 -0
- package/dist/jsonRpc/client.d.mts.map +1 -1
- package/dist/jsonRpc/client.mjs +142 -0
- package/dist/jsonRpc/client.mjs.map +1 -1
- package/dist/jsonRpc/core.d.mts +80 -0
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +80 -0
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/jsonRpc/errors.d.mts +12 -0
- package/dist/jsonRpc/errors.d.mts.map +1 -1
- package/dist/jsonRpc/errors.mjs +12 -0
- package/dist/jsonRpc/errors.mjs.map +1 -1
- package/dist/jsonRpc/http-transport.d.mts +30 -0
- package/dist/jsonRpc/http-transport.d.mts.map +1 -1
- package/dist/jsonRpc/http-transport.mjs +16 -0
- package/dist/jsonRpc/http-transport.mjs.map +1 -1
- package/dist/jsonRpc/network.d.mts +4 -0
- package/dist/jsonRpc/network.d.mts.map +1 -1
- package/dist/jsonRpc/network.mjs +4 -0
- package/dist/jsonRpc/network.mjs.map +1 -1
- package/dist/jsonRpc/types/chain.d.mts +68 -0
- package/dist/jsonRpc/types/chain.d.mts.map +1 -1
- package/dist/jsonRpc/types/changes.d.mts +24 -0
- package/dist/jsonRpc/types/changes.d.mts.map +1 -1
- package/dist/jsonRpc/types/coins.d.mts +4 -0
- package/dist/jsonRpc/types/coins.d.mts.map +1 -1
- package/dist/jsonRpc/types/common.d.mts +4 -0
- package/dist/jsonRpc/types/common.d.mts.map +1 -1
- package/dist/jsonRpc/types/generated.d.mts +497 -16
- package/dist/jsonRpc/types/generated.d.mts.map +1 -1
- package/dist/jsonRpc/types/params.d.mts +289 -41
- package/dist/jsonRpc/types/params.d.mts.map +1 -1
- package/dist/transactions/Transaction.d.mts +9 -9
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/client/core.ts +1 -0
- package/src/client/mvr.ts +39 -6
- package/src/grpc/client.ts +10 -7
- package/src/grpc/core.ts +251 -168
- package/src/grpc/index.ts +5 -1
- package/src/jsonRpc/client.ts +160 -0
- package/src/jsonRpc/core.ts +80 -0
- package/src/jsonRpc/errors.ts +12 -0
- package/src/jsonRpc/http-transport.ts +30 -0
- package/src/jsonRpc/network.ts +4 -0
- package/src/jsonRpc/types/chain.ts +68 -0
- package/src/jsonRpc/types/changes.ts +24 -0
- package/src/jsonRpc/types/coins.ts +4 -0
- package/src/jsonRpc/types/common.ts +4 -0
- package/src/jsonRpc/types/generated.ts +497 -16
- package/src/jsonRpc/types/params.ts +289 -41
- package/src/version.ts +1 -1
package/src/grpc/core.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { CoreClientOptions, SuiClientTypes } from '../client/index.js';
|
|
5
5
|
import { CoreClient, formatMoveAbortMessage, SimulationError } from '../client/index.js';
|
|
6
|
+
import { raceSignal } from '../client/mvr.js';
|
|
6
7
|
import type { SuiGrpcClient } from './client.js';
|
|
7
8
|
import type { Owner } from './proto/sui/rpc/v2/owner.js';
|
|
8
9
|
import { Owner_OwnerKind } from './proto/sui/rpc/v2/owner.js';
|
|
@@ -44,6 +45,7 @@ import {
|
|
|
44
45
|
grpcTransactionToTransactionData,
|
|
45
46
|
} from '../client/transaction-resolver.js';
|
|
46
47
|
import { Value } from './proto/google/protobuf/struct.js';
|
|
48
|
+
import type { SimulateTransactionResponse } from './proto/sui/rpc/v2/transaction_execution_service.js';
|
|
47
49
|
import { SimulateTransactionRequest_TransactionChecks } from './proto/sui/rpc/v2/transaction_execution_service.js';
|
|
48
50
|
|
|
49
51
|
export interface GrpcCoreClientOptions extends CoreClientOptions {
|
|
@@ -80,12 +82,15 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
for (const batch of batches) {
|
|
83
|
-
const response = await this.#client.ledgerService.batchGetObjects(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const response = await this.#client.ledgerService.batchGetObjects(
|
|
86
|
+
{
|
|
87
|
+
requests: batch.map((id) => ({ objectId: id })),
|
|
88
|
+
readMask: {
|
|
89
|
+
paths,
|
|
90
|
+
},
|
|
87
91
|
},
|
|
88
|
-
|
|
92
|
+
{ abort: options.signal },
|
|
93
|
+
);
|
|
89
94
|
|
|
90
95
|
results.push(
|
|
91
96
|
...response.response.objects.map((object): SuiClientTypes.Object<Include> | Error => {
|
|
@@ -160,17 +165,20 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
160
165
|
paths.push('display');
|
|
161
166
|
}
|
|
162
167
|
|
|
163
|
-
const response = await this.#client.stateService.listOwnedObjects(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
const response = await this.#client.stateService.listOwnedObjects(
|
|
169
|
+
{
|
|
170
|
+
owner: options.owner,
|
|
171
|
+
objectType: options.type
|
|
172
|
+
? (await this.mvr.resolveType({ type: options.type, signal: options.signal })).type
|
|
173
|
+
: undefined,
|
|
174
|
+
pageToken: options.cursor ? fromBase64(options.cursor) : undefined,
|
|
175
|
+
pageSize: options.limit,
|
|
176
|
+
readMask: {
|
|
177
|
+
paths,
|
|
178
|
+
},
|
|
172
179
|
},
|
|
173
|
-
|
|
180
|
+
{ abort: options.signal },
|
|
181
|
+
);
|
|
174
182
|
|
|
175
183
|
const objects = response.response.objects.map(
|
|
176
184
|
(object): SuiClientTypes.Object<Include> => ({
|
|
@@ -207,15 +215,18 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
207
215
|
const paths = ['owner', 'object_type', 'digest', 'version', 'object_id', 'balance'];
|
|
208
216
|
const coinType = options.coinType ?? SUI_TYPE_ARG;
|
|
209
217
|
|
|
210
|
-
const response = await this.#client.stateService.listOwnedObjects(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
218
|
+
const response = await this.#client.stateService.listOwnedObjects(
|
|
219
|
+
{
|
|
220
|
+
owner: options.owner,
|
|
221
|
+
objectType: `0x2::coin::Coin<${(await this.mvr.resolveType({ type: coinType, signal: options.signal })).type}>`,
|
|
222
|
+
pageToken: options.cursor ? fromBase64(options.cursor) : undefined,
|
|
223
|
+
pageSize: options.limit,
|
|
224
|
+
readMask: {
|
|
225
|
+
paths,
|
|
226
|
+
},
|
|
217
227
|
},
|
|
218
|
-
|
|
228
|
+
{ abort: options.signal },
|
|
229
|
+
);
|
|
219
230
|
|
|
220
231
|
return {
|
|
221
232
|
objects: response.response.objects.map(
|
|
@@ -237,10 +248,13 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
237
248
|
options: SuiClientTypes.GetBalanceOptions,
|
|
238
249
|
): Promise<SuiClientTypes.GetBalanceResponse> {
|
|
239
250
|
const coinType = options.coinType ?? SUI_TYPE_ARG;
|
|
240
|
-
const result = await this.#client.stateService.getBalance(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
251
|
+
const result = await this.#client.stateService.getBalance(
|
|
252
|
+
{
|
|
253
|
+
owner: options.owner,
|
|
254
|
+
coinType: (await this.mvr.resolveType({ type: coinType, signal: options.signal })).type,
|
|
255
|
+
},
|
|
256
|
+
{ abort: options.signal },
|
|
257
|
+
);
|
|
244
258
|
|
|
245
259
|
return {
|
|
246
260
|
balance: {
|
|
@@ -255,14 +269,23 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
255
269
|
async getCoinMetadata(
|
|
256
270
|
options: SuiClientTypes.GetCoinMetadataOptions,
|
|
257
271
|
): Promise<SuiClientTypes.GetCoinMetadataResponse> {
|
|
258
|
-
const coinType = (
|
|
272
|
+
const coinType = (
|
|
273
|
+
await this.mvr.resolveType({ type: options.coinType, signal: options.signal })
|
|
274
|
+
).type;
|
|
259
275
|
|
|
260
276
|
let response;
|
|
261
277
|
try {
|
|
262
|
-
({ response } = await this.#client.stateService.getCoinInfo(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
278
|
+
({ response } = await this.#client.stateService.getCoinInfo(
|
|
279
|
+
{
|
|
280
|
+
coinType,
|
|
281
|
+
},
|
|
282
|
+
{ abort: options.signal },
|
|
283
|
+
));
|
|
284
|
+
} catch (error) {
|
|
285
|
+
// Don't swallow cancellation — only treat the coin as missing on real errors.
|
|
286
|
+
if (options.signal?.aborted) {
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
266
289
|
return { coinMetadata: null };
|
|
267
290
|
}
|
|
268
291
|
|
|
@@ -285,11 +308,14 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
285
308
|
async listBalances(
|
|
286
309
|
options: SuiClientTypes.ListBalancesOptions,
|
|
287
310
|
): Promise<SuiClientTypes.ListBalancesResponse> {
|
|
288
|
-
const result = await this.#client.stateService.listBalances(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
311
|
+
const result = await this.#client.stateService.listBalances(
|
|
312
|
+
{
|
|
313
|
+
owner: options.owner,
|
|
314
|
+
pageToken: options.cursor ? fromBase64(options.cursor) : undefined,
|
|
315
|
+
pageSize: options.limit,
|
|
316
|
+
},
|
|
317
|
+
{ abort: options.signal },
|
|
318
|
+
);
|
|
293
319
|
|
|
294
320
|
return {
|
|
295
321
|
hasNextPage: !!result.response.nextPageToken,
|
|
@@ -331,18 +357,21 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
331
357
|
paths.push('effects.changed_objects.object_id');
|
|
332
358
|
}
|
|
333
359
|
|
|
334
|
-
const { response } = await this.#client.ledgerService.getTransaction(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
360
|
+
const { response } = await this.#client.ledgerService.getTransaction(
|
|
361
|
+
{
|
|
362
|
+
digest: options.digest,
|
|
363
|
+
readMask: {
|
|
364
|
+
paths,
|
|
365
|
+
},
|
|
338
366
|
},
|
|
339
|
-
|
|
367
|
+
{ abort: options.signal },
|
|
368
|
+
);
|
|
340
369
|
|
|
341
370
|
if (!response.transaction) {
|
|
342
371
|
throw new Error(`Transaction ${options.digest} not found`);
|
|
343
372
|
}
|
|
344
373
|
|
|
345
|
-
return
|
|
374
|
+
return parseGrpcTransactionResponse(response.transaction, { include: options.include });
|
|
346
375
|
}
|
|
347
376
|
async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
348
377
|
options: SuiClientTypes.ExecuteTransactionOptions<Include>,
|
|
@@ -373,26 +402,29 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
373
402
|
paths.push('effects.changed_objects.object_id');
|
|
374
403
|
}
|
|
375
404
|
|
|
376
|
-
const { response } = await this.#client.transactionExecutionService.executeTransaction(
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
signatures: options.signatures.map((signature) => ({
|
|
383
|
-
bcs: {
|
|
384
|
-
value: fromBase64(signature),
|
|
405
|
+
const { response } = await this.#client.transactionExecutionService.executeTransaction(
|
|
406
|
+
{
|
|
407
|
+
transaction: {
|
|
408
|
+
bcs: {
|
|
409
|
+
value: options.transaction,
|
|
410
|
+
},
|
|
385
411
|
},
|
|
386
|
-
|
|
387
|
-
|
|
412
|
+
signatures: options.signatures.map((signature) => ({
|
|
413
|
+
bcs: {
|
|
414
|
+
value: fromBase64(signature),
|
|
415
|
+
},
|
|
416
|
+
signature: {
|
|
417
|
+
oneofKind: undefined,
|
|
418
|
+
},
|
|
419
|
+
})),
|
|
420
|
+
readMask: {
|
|
421
|
+
paths,
|
|
388
422
|
},
|
|
389
|
-
})),
|
|
390
|
-
readMask: {
|
|
391
|
-
paths,
|
|
392
423
|
},
|
|
393
|
-
|
|
424
|
+
{ abort: options.signal },
|
|
425
|
+
);
|
|
394
426
|
|
|
395
|
-
return
|
|
427
|
+
return parseGrpcTransactionResponse(response.transaction!, { include: options.include });
|
|
396
428
|
}
|
|
397
429
|
async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
|
|
398
430
|
options: SuiClientTypes.SimulateTransactionOptions<Include>,
|
|
@@ -436,72 +468,56 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
436
468
|
await options.transaction.prepareForSerialization({ client: this });
|
|
437
469
|
}
|
|
438
470
|
|
|
439
|
-
const { response } = await this.#client.transactionExecutionService.simulateTransaction(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
471
|
+
const { response } = await this.#client.transactionExecutionService.simulateTransaction(
|
|
472
|
+
{
|
|
473
|
+
transaction:
|
|
474
|
+
options.transaction instanceof Uint8Array
|
|
475
|
+
? {
|
|
476
|
+
bcs: {
|
|
477
|
+
value: options.transaction,
|
|
478
|
+
},
|
|
479
|
+
}
|
|
480
|
+
: transactionToGrpcTransaction(options.transaction),
|
|
481
|
+
readMask: {
|
|
482
|
+
paths,
|
|
483
|
+
},
|
|
484
|
+
doGasSelection: false,
|
|
485
|
+
checks:
|
|
486
|
+
options.checksEnabled === false
|
|
487
|
+
? SimulateTransactionRequest_TransactionChecks.DISABLED
|
|
488
|
+
: SimulateTransactionRequest_TransactionChecks.ENABLED,
|
|
450
489
|
},
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
options.checksEnabled === false
|
|
454
|
-
? SimulateTransactionRequest_TransactionChecks.DISABLED
|
|
455
|
-
: SimulateTransactionRequest_TransactionChecks.ENABLED,
|
|
456
|
-
});
|
|
490
|
+
{ abort: options.signal },
|
|
491
|
+
);
|
|
457
492
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
// Add command results if requested
|
|
461
|
-
const commandResults =
|
|
462
|
-
options.include?.commandResults && response.commandOutputs
|
|
463
|
-
? response.commandOutputs.map((output) => ({
|
|
464
|
-
returnValues: (output.returnValues ?? []).map((rv) => ({
|
|
465
|
-
bcs: rv.value?.value ?? null,
|
|
466
|
-
})),
|
|
467
|
-
mutatedReferences: (output.mutatedByRef ?? []).map((mr) => ({
|
|
468
|
-
bcs: mr.value?.value ?? null,
|
|
469
|
-
})),
|
|
470
|
-
}))
|
|
471
|
-
: undefined;
|
|
472
|
-
|
|
473
|
-
if (transactionResult.$kind === 'Transaction') {
|
|
474
|
-
return {
|
|
475
|
-
$kind: 'Transaction',
|
|
476
|
-
Transaction: transactionResult.Transaction,
|
|
477
|
-
commandResults:
|
|
478
|
-
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
479
|
-
};
|
|
480
|
-
} else {
|
|
481
|
-
return {
|
|
482
|
-
$kind: 'FailedTransaction',
|
|
483
|
-
FailedTransaction: transactionResult.FailedTransaction,
|
|
484
|
-
commandResults:
|
|
485
|
-
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
486
|
-
};
|
|
487
|
-
}
|
|
493
|
+
return parseGrpcSimulateTransactionResponse(response, { include: options.include });
|
|
488
494
|
}
|
|
489
|
-
async getReferenceGasPrice(
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
495
|
+
async getReferenceGasPrice(
|
|
496
|
+
options?: SuiClientTypes.GetReferenceGasPriceOptions,
|
|
497
|
+
): Promise<SuiClientTypes.GetReferenceGasPriceResponse> {
|
|
498
|
+
const response = await this.#client.ledgerService.getEpoch(
|
|
499
|
+
{
|
|
500
|
+
readMask: {
|
|
501
|
+
paths: ['reference_gas_price'],
|
|
502
|
+
},
|
|
493
503
|
},
|
|
494
|
-
|
|
504
|
+
{ abort: options?.signal },
|
|
505
|
+
);
|
|
495
506
|
|
|
496
507
|
return {
|
|
497
508
|
referenceGasPrice: response.response.epoch?.referenceGasPrice?.toString() ?? '',
|
|
498
509
|
};
|
|
499
510
|
}
|
|
500
511
|
|
|
501
|
-
async getProtocolConfig(
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
512
|
+
async getProtocolConfig(
|
|
513
|
+
options?: SuiClientTypes.GetProtocolConfigOptions,
|
|
514
|
+
): Promise<SuiClientTypes.GetProtocolConfigResponse> {
|
|
515
|
+
const response = await this.#client.ledgerService.getEpoch(
|
|
516
|
+
{
|
|
517
|
+
readMask: { paths: ['protocol_config'] },
|
|
518
|
+
},
|
|
519
|
+
{ abort: options?.signal },
|
|
520
|
+
);
|
|
505
521
|
|
|
506
522
|
const protocolConfig = response.response.epoch?.protocolConfig;
|
|
507
523
|
if (!protocolConfig) {
|
|
@@ -525,26 +541,31 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
525
541
|
};
|
|
526
542
|
}
|
|
527
543
|
|
|
528
|
-
async getCurrentSystemState(
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
544
|
+
async getCurrentSystemState(
|
|
545
|
+
options?: SuiClientTypes.GetCurrentSystemStateOptions,
|
|
546
|
+
): Promise<SuiClientTypes.GetCurrentSystemStateResponse> {
|
|
547
|
+
const response = await this.#client.ledgerService.getEpoch(
|
|
548
|
+
{
|
|
549
|
+
readMask: {
|
|
550
|
+
paths: [
|
|
551
|
+
'system_state.version',
|
|
552
|
+
'system_state.epoch',
|
|
553
|
+
'system_state.protocol_version',
|
|
554
|
+
'system_state.reference_gas_price',
|
|
555
|
+
'system_state.epoch_start_timestamp_ms',
|
|
556
|
+
'system_state.safe_mode',
|
|
557
|
+
'system_state.safe_mode_storage_rewards',
|
|
558
|
+
'system_state.safe_mode_computation_rewards',
|
|
559
|
+
'system_state.safe_mode_storage_rebates',
|
|
560
|
+
'system_state.safe_mode_non_refundable_storage_fee',
|
|
561
|
+
'system_state.parameters',
|
|
562
|
+
'system_state.storage_fund',
|
|
563
|
+
'system_state.stake_subsidy',
|
|
564
|
+
],
|
|
565
|
+
},
|
|
546
566
|
},
|
|
547
|
-
|
|
567
|
+
{ abort: options?.signal },
|
|
568
|
+
);
|
|
548
569
|
|
|
549
570
|
const epoch = response.response.epoch;
|
|
550
571
|
const systemState = epoch?.systemState;
|
|
@@ -624,22 +645,25 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
624
645
|
? bcs.byteVector().serialize(messageBytes).toBytes()
|
|
625
646
|
: messageBytes;
|
|
626
647
|
|
|
627
|
-
const { response } = await this.#client.signatureVerificationService.verifySignature(
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
signature: {
|
|
633
|
-
bcs: {
|
|
634
|
-
value: fromBase64(options.signature),
|
|
648
|
+
const { response } = await this.#client.signatureVerificationService.verifySignature(
|
|
649
|
+
{
|
|
650
|
+
message: {
|
|
651
|
+
name: options.intentScope,
|
|
652
|
+
value: messageValue,
|
|
635
653
|
},
|
|
636
654
|
signature: {
|
|
637
|
-
|
|
655
|
+
bcs: {
|
|
656
|
+
value: fromBase64(options.signature),
|
|
657
|
+
},
|
|
658
|
+
signature: {
|
|
659
|
+
oneofKind: undefined,
|
|
660
|
+
},
|
|
638
661
|
},
|
|
662
|
+
address: options.address,
|
|
663
|
+
jwks: [],
|
|
639
664
|
},
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
});
|
|
665
|
+
{ abort: options.signal },
|
|
666
|
+
);
|
|
643
667
|
|
|
644
668
|
return {
|
|
645
669
|
success: response.isValid ?? false,
|
|
@@ -652,9 +676,12 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
652
676
|
): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {
|
|
653
677
|
const name =
|
|
654
678
|
(
|
|
655
|
-
await this.#client.nameService.reverseLookupName(
|
|
656
|
-
|
|
657
|
-
|
|
679
|
+
await this.#client.nameService.reverseLookupName(
|
|
680
|
+
{
|
|
681
|
+
address: options.address,
|
|
682
|
+
},
|
|
683
|
+
{ abort: options.signal },
|
|
684
|
+
)
|
|
658
685
|
).response.record?.name ?? null;
|
|
659
686
|
return {
|
|
660
687
|
data: {
|
|
@@ -666,13 +693,17 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
666
693
|
async getMoveFunction(
|
|
667
694
|
options: SuiClientTypes.GetMoveFunctionOptions,
|
|
668
695
|
): Promise<SuiClientTypes.GetMoveFunctionResponse> {
|
|
669
|
-
const resolvedPackageId = (
|
|
670
|
-
.package
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
696
|
+
const resolvedPackageId = (
|
|
697
|
+
await this.mvr.resolvePackage({ package: options.packageId, signal: options.signal })
|
|
698
|
+
).package;
|
|
699
|
+
const { response } = await this.#client.movePackageService.getFunction(
|
|
700
|
+
{
|
|
701
|
+
packageId: resolvedPackageId,
|
|
702
|
+
moduleName: options.moduleName,
|
|
703
|
+
name: options.name,
|
|
704
|
+
},
|
|
705
|
+
{ abort: options.signal },
|
|
706
|
+
);
|
|
676
707
|
|
|
677
708
|
let visibility: 'public' | 'private' | 'friend' | 'unknown' = 'unknown';
|
|
678
709
|
|
|
@@ -722,17 +753,24 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
722
753
|
}
|
|
723
754
|
|
|
724
755
|
async getChainIdentifier(
|
|
725
|
-
|
|
756
|
+
options?: SuiClientTypes.GetChainIdentifierOptions,
|
|
726
757
|
): Promise<SuiClientTypes.GetChainIdentifierResponse> {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
758
|
+
// The result is cached and shared across callers, so the underlying request must
|
|
759
|
+
// not carry any single caller's signal. Isolate cancellation per-caller instead.
|
|
760
|
+
return raceSignal(
|
|
761
|
+
Promise.resolve(
|
|
762
|
+
this.cache.read(['chainIdentifier'], async () => {
|
|
763
|
+
const { response } = await this.#client.ledgerService.getServiceInfo({});
|
|
764
|
+
if (!response.chainId) {
|
|
765
|
+
throw new Error('Chain identifier not found in service info');
|
|
766
|
+
}
|
|
767
|
+
return {
|
|
768
|
+
chainIdentifier: response.chainId,
|
|
769
|
+
};
|
|
770
|
+
}),
|
|
771
|
+
),
|
|
772
|
+
options?.signal,
|
|
773
|
+
);
|
|
736
774
|
}
|
|
737
775
|
|
|
738
776
|
resolveTransactionPlugin() {
|
|
@@ -1209,10 +1247,15 @@ export function parseTransactionEffects({
|
|
|
1209
1247
|
};
|
|
1210
1248
|
}
|
|
1211
1249
|
|
|
1212
|
-
function
|
|
1250
|
+
export function parseGrpcTransactionResponse<
|
|
1251
|
+
Include extends SuiClientTypes.TransactionInclude = {},
|
|
1252
|
+
>(
|
|
1213
1253
|
transaction: ExecutedTransaction,
|
|
1214
|
-
|
|
1254
|
+
options?: {
|
|
1255
|
+
include?: Include & SuiClientTypes.TransactionInclude;
|
|
1256
|
+
},
|
|
1215
1257
|
): SuiClientTypes.TransactionResult<Include> {
|
|
1258
|
+
const include = options?.include;
|
|
1216
1259
|
const objectTypes: Record<string, string> = {};
|
|
1217
1260
|
if (include?.objectTypes) {
|
|
1218
1261
|
transaction.effects?.changedObjects?.forEach((change) => {
|
|
@@ -1303,6 +1346,46 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
|
|
|
1303
1346
|
};
|
|
1304
1347
|
}
|
|
1305
1348
|
|
|
1349
|
+
export function parseGrpcSimulateTransactionResponse<
|
|
1350
|
+
Include extends SuiClientTypes.SimulateTransactionInclude = {},
|
|
1351
|
+
>(
|
|
1352
|
+
response: SimulateTransactionResponse,
|
|
1353
|
+
options?: {
|
|
1354
|
+
include?: Include & SuiClientTypes.SimulateTransactionInclude;
|
|
1355
|
+
},
|
|
1356
|
+
): SuiClientTypes.SimulateTransactionResult<Include> {
|
|
1357
|
+
const include = options?.include;
|
|
1358
|
+
const transactionResult = parseGrpcTransactionResponse(response.transaction!, { include });
|
|
1359
|
+
|
|
1360
|
+
const commandResults =
|
|
1361
|
+
include?.commandResults && response.commandOutputs
|
|
1362
|
+
? response.commandOutputs.map((output) => ({
|
|
1363
|
+
returnValues: (output.returnValues ?? []).map((rv) => ({
|
|
1364
|
+
bcs: rv.value?.value ?? null,
|
|
1365
|
+
})),
|
|
1366
|
+
mutatedReferences: (output.mutatedByRef ?? []).map((mr) => ({
|
|
1367
|
+
bcs: mr.value?.value ?? null,
|
|
1368
|
+
})),
|
|
1369
|
+
}))
|
|
1370
|
+
: undefined;
|
|
1371
|
+
|
|
1372
|
+
if (transactionResult.$kind === 'Transaction') {
|
|
1373
|
+
return {
|
|
1374
|
+
$kind: 'Transaction',
|
|
1375
|
+
Transaction: transactionResult.Transaction,
|
|
1376
|
+
commandResults:
|
|
1377
|
+
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
return {
|
|
1382
|
+
$kind: 'FailedTransaction',
|
|
1383
|
+
FailedTransaction: transactionResult.FailedTransaction,
|
|
1384
|
+
commandResults:
|
|
1385
|
+
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1306
1389
|
function parseNormalizedSuiMoveType(type: OpenSignature): SuiClientTypes.OpenSignature {
|
|
1307
1390
|
let reference: 'mutable' | 'immutable' | null = null;
|
|
1308
1391
|
|
package/src/grpc/index.ts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export { SuiGrpcClient, isSuiGrpcClient } from './client.js';
|
|
5
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
GrpcCoreClient,
|
|
7
|
+
parseGrpcSimulateTransactionResponse,
|
|
8
|
+
parseGrpcTransactionResponse,
|
|
9
|
+
} from './core.js';
|
|
6
10
|
export type { SuiGrpcClientOptions } from './client.js';
|
|
7
11
|
export type { GrpcCoreClientOptions } from './core.js';
|
|
8
12
|
|