@mysten/sui 2.20.4 → 2.22.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 +14 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +20 -20
- package/dist/cryptography/signature.d.mts +8 -8
- package/dist/grpc/client.d.mts +46 -6
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +9 -1
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +54 -67
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/index.d.mts +3 -3
- 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/effects.d.mts +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_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/object.d.mts +1 -1
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_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/transaction.d.mts +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +1 -1
- package/dist/grpc/proto/types.d.mts +2 -2
- 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 +3 -3
- package/src/grpc/client.ts +92 -20
- package/src/grpc/core.ts +119 -121
- package/src/grpc/index.ts +19 -2
- package/src/version.ts +1 -1
package/src/grpc/core.ts
CHANGED
|
@@ -8,7 +8,6 @@ import type { SuiGrpcClient } from './client.js';
|
|
|
8
8
|
import type { Owner } from './proto/sui/rpc/v2/owner.js';
|
|
9
9
|
import { Owner_OwnerKind } from './proto/sui/rpc/v2/owner.js';
|
|
10
10
|
import { chunk, fromBase64, toBase64 } from '@mysten/utils';
|
|
11
|
-
import type { ExecutedTransaction } from './proto/sui/rpc/v2/executed_transaction.js';
|
|
12
11
|
import type { TransactionEffects } from './proto/sui/rpc/v2/effects.js';
|
|
13
12
|
import {
|
|
14
13
|
UnchangedConsensusObject_UnchangedConsensusObjectKind,
|
|
@@ -45,11 +44,16 @@ import {
|
|
|
45
44
|
grpcTransactionToTransactionData,
|
|
46
45
|
} from '../client/transaction-resolver.js';
|
|
47
46
|
import { Value } from './proto/google/protobuf/struct.js';
|
|
48
|
-
import {
|
|
47
|
+
import { ExecutedTransaction } from './proto/sui/rpc/v2/executed_transaction.js';
|
|
48
|
+
import {
|
|
49
|
+
SimulateTransactionRequest_TransactionChecks,
|
|
50
|
+
SimulateTransactionResponse,
|
|
51
|
+
} from './proto/sui/rpc/v2/transaction_execution_service.js';
|
|
49
52
|
|
|
50
53
|
export interface GrpcCoreClientOptions extends CoreClientOptions {
|
|
51
54
|
client: SuiGrpcClient;
|
|
52
55
|
}
|
|
56
|
+
|
|
53
57
|
export class GrpcCoreClient extends CoreClient {
|
|
54
58
|
#client: SuiGrpcClient;
|
|
55
59
|
constructor({ client, ...options }: GrpcCoreClientOptions) {
|
|
@@ -330,37 +334,11 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
330
334
|
async getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
331
335
|
options: SuiClientTypes.GetTransactionOptions<Include>,
|
|
332
336
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
333
|
-
const paths = ['digest', 'transaction.digest', 'signatures', 'effects.status'];
|
|
334
|
-
if (options.include?.transaction) {
|
|
335
|
-
paths.push(
|
|
336
|
-
'transaction.sender',
|
|
337
|
-
'transaction.gas_payment',
|
|
338
|
-
'transaction.expiration',
|
|
339
|
-
'transaction.kind',
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
if (options.include?.bcs) {
|
|
343
|
-
paths.push('transaction.bcs');
|
|
344
|
-
}
|
|
345
|
-
if (options.include?.balanceChanges) {
|
|
346
|
-
paths.push('balance_changes');
|
|
347
|
-
}
|
|
348
|
-
if (options.include?.effects) {
|
|
349
|
-
paths.push('effects');
|
|
350
|
-
}
|
|
351
|
-
if (options.include?.events) {
|
|
352
|
-
paths.push('events');
|
|
353
|
-
}
|
|
354
|
-
if (options.include?.objectTypes) {
|
|
355
|
-
paths.push('effects.changed_objects.object_type');
|
|
356
|
-
paths.push('effects.changed_objects.object_id');
|
|
357
|
-
}
|
|
358
|
-
|
|
359
337
|
const { response } = await this.#client.ledgerService.getTransaction(
|
|
360
338
|
{
|
|
361
339
|
digest: options.digest,
|
|
362
340
|
readMask: {
|
|
363
|
-
paths,
|
|
341
|
+
paths: transactionReadMaskPaths(options.include),
|
|
364
342
|
},
|
|
365
343
|
},
|
|
366
344
|
{ abort: options.signal },
|
|
@@ -370,37 +348,15 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
370
348
|
throw new Error(`Transaction ${options.digest} not found`);
|
|
371
349
|
}
|
|
372
350
|
|
|
373
|
-
return
|
|
351
|
+
return withProtoJson(
|
|
352
|
+
parseGrpcTransactionResponse(response.transaction, { include: options.include }),
|
|
353
|
+
options.include,
|
|
354
|
+
() => ExecutedTransaction.toJson(response.transaction!),
|
|
355
|
+
);
|
|
374
356
|
}
|
|
375
357
|
async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
376
358
|
options: SuiClientTypes.ExecuteTransactionOptions<Include>,
|
|
377
359
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
378
|
-
const paths = ['digest', 'transaction.digest', 'signatures', 'effects.status'];
|
|
379
|
-
if (options.include?.transaction) {
|
|
380
|
-
paths.push(
|
|
381
|
-
'transaction.sender',
|
|
382
|
-
'transaction.gas_payment',
|
|
383
|
-
'transaction.expiration',
|
|
384
|
-
'transaction.kind',
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
if (options.include?.bcs) {
|
|
388
|
-
paths.push('transaction.bcs');
|
|
389
|
-
}
|
|
390
|
-
if (options.include?.balanceChanges) {
|
|
391
|
-
paths.push('balance_changes');
|
|
392
|
-
}
|
|
393
|
-
if (options.include?.effects) {
|
|
394
|
-
paths.push('effects');
|
|
395
|
-
}
|
|
396
|
-
if (options.include?.events) {
|
|
397
|
-
paths.push('events');
|
|
398
|
-
}
|
|
399
|
-
if (options.include?.objectTypes) {
|
|
400
|
-
paths.push('effects.changed_objects.object_type');
|
|
401
|
-
paths.push('effects.changed_objects.object_id');
|
|
402
|
-
}
|
|
403
|
-
|
|
404
360
|
const { response } = await this.#client.transactionExecutionService.executeTransaction(
|
|
405
361
|
{
|
|
406
362
|
transaction: {
|
|
@@ -417,48 +373,22 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
417
373
|
},
|
|
418
374
|
})),
|
|
419
375
|
readMask: {
|
|
420
|
-
paths,
|
|
376
|
+
paths: transactionReadMaskPaths(options.include),
|
|
421
377
|
},
|
|
422
378
|
},
|
|
423
379
|
{ abort: options.signal },
|
|
424
380
|
);
|
|
425
381
|
|
|
426
|
-
return
|
|
382
|
+
return withProtoJson(
|
|
383
|
+
parseGrpcTransactionResponse(response.transaction!, { include: options.include }),
|
|
384
|
+
options.include,
|
|
385
|
+
() => ExecutedTransaction.toJson(response.transaction!),
|
|
386
|
+
);
|
|
427
387
|
}
|
|
428
388
|
async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
|
|
429
389
|
options: SuiClientTypes.SimulateTransactionOptions<Include>,
|
|
430
390
|
): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
|
|
431
|
-
const paths =
|
|
432
|
-
'transaction.digest',
|
|
433
|
-
'transaction.transaction.digest',
|
|
434
|
-
'transaction.signatures',
|
|
435
|
-
'transaction.effects.status',
|
|
436
|
-
];
|
|
437
|
-
if (options.include?.transaction) {
|
|
438
|
-
paths.push(
|
|
439
|
-
'transaction.transaction.sender',
|
|
440
|
-
'transaction.transaction.gas_payment',
|
|
441
|
-
'transaction.transaction.expiration',
|
|
442
|
-
'transaction.transaction.kind',
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
|
-
if (options.include?.bcs) {
|
|
446
|
-
paths.push('transaction.transaction.bcs');
|
|
447
|
-
}
|
|
448
|
-
if (options.include?.balanceChanges) {
|
|
449
|
-
paths.push('transaction.balance_changes');
|
|
450
|
-
}
|
|
451
|
-
if (options.include?.effects) {
|
|
452
|
-
paths.push('transaction.effects');
|
|
453
|
-
}
|
|
454
|
-
if (options.include?.events) {
|
|
455
|
-
paths.push('transaction.events');
|
|
456
|
-
}
|
|
457
|
-
if (options.include?.objectTypes) {
|
|
458
|
-
// Use effects.changed_objects to match JSON-RPC behavior (which uses objectChanges)
|
|
459
|
-
paths.push('transaction.effects.changed_objects.object_type');
|
|
460
|
-
paths.push('transaction.effects.changed_objects.object_id');
|
|
461
|
-
}
|
|
391
|
+
const paths = transactionReadMaskPaths(options.include, 'transaction.');
|
|
462
392
|
if (options.include?.commandResults) {
|
|
463
393
|
paths.push('command_outputs');
|
|
464
394
|
}
|
|
@@ -489,36 +419,11 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
489
419
|
{ abort: options.signal },
|
|
490
420
|
);
|
|
491
421
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
? response.commandOutputs.map((output) => ({
|
|
498
|
-
returnValues: (output.returnValues ?? []).map((rv) => ({
|
|
499
|
-
bcs: rv.value?.value ?? null,
|
|
500
|
-
})),
|
|
501
|
-
mutatedReferences: (output.mutatedByRef ?? []).map((mr) => ({
|
|
502
|
-
bcs: mr.value?.value ?? null,
|
|
503
|
-
})),
|
|
504
|
-
}))
|
|
505
|
-
: undefined;
|
|
506
|
-
|
|
507
|
-
if (transactionResult.$kind === 'Transaction') {
|
|
508
|
-
return {
|
|
509
|
-
$kind: 'Transaction',
|
|
510
|
-
Transaction: transactionResult.Transaction,
|
|
511
|
-
commandResults:
|
|
512
|
-
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
513
|
-
};
|
|
514
|
-
} else {
|
|
515
|
-
return {
|
|
516
|
-
$kind: 'FailedTransaction',
|
|
517
|
-
FailedTransaction: transactionResult.FailedTransaction,
|
|
518
|
-
commandResults:
|
|
519
|
-
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
520
|
-
};
|
|
521
|
-
}
|
|
422
|
+
return withProtoJson(
|
|
423
|
+
parseGrpcSimulateTransactionResponse(response, { include: options.include }),
|
|
424
|
+
options.include,
|
|
425
|
+
() => SimulateTransactionResponse.toJson(response),
|
|
426
|
+
);
|
|
522
427
|
}
|
|
523
428
|
async getReferenceGasPrice(
|
|
524
429
|
options?: SuiClientTypes.GetReferenceGasPriceOptions,
|
|
@@ -871,6 +776,54 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
871
776
|
}
|
|
872
777
|
}
|
|
873
778
|
|
|
779
|
+
function transactionReadMaskPaths(
|
|
780
|
+
include: SuiClientTypes.TransactionInclude | undefined,
|
|
781
|
+
prefix = '',
|
|
782
|
+
) {
|
|
783
|
+
const paths = ['digest', 'transaction.digest', 'signatures', 'effects.status'];
|
|
784
|
+
if (include?.transaction) {
|
|
785
|
+
paths.push(
|
|
786
|
+
'transaction.sender',
|
|
787
|
+
'transaction.gas_payment',
|
|
788
|
+
'transaction.expiration',
|
|
789
|
+
'transaction.kind',
|
|
790
|
+
);
|
|
791
|
+
}
|
|
792
|
+
if (include?.bcs) {
|
|
793
|
+
paths.push('transaction.bcs');
|
|
794
|
+
}
|
|
795
|
+
if (include?.balanceChanges) {
|
|
796
|
+
paths.push('balance_changes');
|
|
797
|
+
}
|
|
798
|
+
if (include?.effects) {
|
|
799
|
+
paths.push('effects');
|
|
800
|
+
}
|
|
801
|
+
if (include?.events) {
|
|
802
|
+
paths.push('events');
|
|
803
|
+
}
|
|
804
|
+
if (include?.objectTypes) {
|
|
805
|
+
paths.push('effects.changed_objects.object_type');
|
|
806
|
+
paths.push('effects.changed_objects.object_id');
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
return prefix ? paths.map((path) => prefix + path) : paths;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
function withProtoJson<Result>(
|
|
813
|
+
result: Result,
|
|
814
|
+
include: ({ protoJson?: boolean } & object) | undefined,
|
|
815
|
+
getProtoJson: () => unknown,
|
|
816
|
+
): Result {
|
|
817
|
+
if (!include?.protoJson) {
|
|
818
|
+
return result;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
return {
|
|
822
|
+
...result,
|
|
823
|
+
protoJson: getProtoJson(),
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
|
|
874
827
|
function mapDisplayProto(
|
|
875
828
|
include: boolean | undefined,
|
|
876
829
|
display: { output?: Value; errors?: Value } | undefined,
|
|
@@ -1275,10 +1228,15 @@ export function parseTransactionEffects({
|
|
|
1275
1228
|
};
|
|
1276
1229
|
}
|
|
1277
1230
|
|
|
1278
|
-
function
|
|
1231
|
+
export function parseGrpcTransactionResponse<
|
|
1232
|
+
Include extends SuiClientTypes.TransactionInclude = {},
|
|
1233
|
+
>(
|
|
1279
1234
|
transaction: ExecutedTransaction,
|
|
1280
|
-
|
|
1235
|
+
options?: {
|
|
1236
|
+
include?: Include & SuiClientTypes.TransactionInclude;
|
|
1237
|
+
},
|
|
1281
1238
|
): SuiClientTypes.TransactionResult<Include> {
|
|
1239
|
+
const include = options?.include;
|
|
1282
1240
|
const objectTypes: Record<string, string> = {};
|
|
1283
1241
|
if (include?.objectTypes) {
|
|
1284
1242
|
transaction.effects?.changedObjects?.forEach((change) => {
|
|
@@ -1369,6 +1327,46 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}
|
|
|
1369
1327
|
};
|
|
1370
1328
|
}
|
|
1371
1329
|
|
|
1330
|
+
export function parseGrpcSimulateTransactionResponse<
|
|
1331
|
+
Include extends SuiClientTypes.SimulateTransactionInclude = {},
|
|
1332
|
+
>(
|
|
1333
|
+
response: SimulateTransactionResponse,
|
|
1334
|
+
options?: {
|
|
1335
|
+
include?: Include & SuiClientTypes.SimulateTransactionInclude;
|
|
1336
|
+
},
|
|
1337
|
+
): SuiClientTypes.SimulateTransactionResult<Include> {
|
|
1338
|
+
const include = options?.include;
|
|
1339
|
+
const transactionResult = parseGrpcTransactionResponse(response.transaction!, { include });
|
|
1340
|
+
|
|
1341
|
+
const commandResults =
|
|
1342
|
+
include?.commandResults && response.commandOutputs
|
|
1343
|
+
? response.commandOutputs.map((output) => ({
|
|
1344
|
+
returnValues: (output.returnValues ?? []).map((rv) => ({
|
|
1345
|
+
bcs: rv.value?.value ?? null,
|
|
1346
|
+
})),
|
|
1347
|
+
mutatedReferences: (output.mutatedByRef ?? []).map((mr) => ({
|
|
1348
|
+
bcs: mr.value?.value ?? null,
|
|
1349
|
+
})),
|
|
1350
|
+
}))
|
|
1351
|
+
: undefined;
|
|
1352
|
+
|
|
1353
|
+
if (transactionResult.$kind === 'Transaction') {
|
|
1354
|
+
return {
|
|
1355
|
+
$kind: 'Transaction',
|
|
1356
|
+
Transaction: transactionResult.Transaction,
|
|
1357
|
+
commandResults:
|
|
1358
|
+
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
return {
|
|
1363
|
+
$kind: 'FailedTransaction',
|
|
1364
|
+
FailedTransaction: transactionResult.FailedTransaction,
|
|
1365
|
+
commandResults:
|
|
1366
|
+
commandResults as SuiClientTypes.SimulateTransactionResult<Include>['commandResults'],
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1372
1370
|
function parseNormalizedSuiMoveType(type: OpenSignature): SuiClientTypes.OpenSignature {
|
|
1373
1371
|
let reference: 'mutable' | 'immutable' | null = null;
|
|
1374
1372
|
|
package/src/grpc/index.ts
CHANGED
|
@@ -2,8 +2,25 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export { SuiGrpcClient, isSuiGrpcClient } from './client.js';
|
|
5
|
-
export {
|
|
6
|
-
|
|
5
|
+
export {
|
|
6
|
+
GrpcCoreClient,
|
|
7
|
+
parseGrpcSimulateTransactionResponse,
|
|
8
|
+
parseGrpcTransactionResponse,
|
|
9
|
+
} from './core.js';
|
|
10
|
+
export type {
|
|
11
|
+
GrpcExecuteTransactionOptions,
|
|
12
|
+
GrpcGetTransactionOptions,
|
|
13
|
+
GrpcSignAndExecuteTransactionOptions,
|
|
14
|
+
GrpcSimulateTransactionInclude,
|
|
15
|
+
GrpcSimulateTransactionOptions,
|
|
16
|
+
GrpcSimulateTransactionProtoJson,
|
|
17
|
+
GrpcSimulateTransactionResult,
|
|
18
|
+
GrpcTransactionInclude,
|
|
19
|
+
GrpcTransactionProtoJson,
|
|
20
|
+
GrpcTransactionResult,
|
|
21
|
+
GrpcWaitForTransactionOptions,
|
|
22
|
+
SuiGrpcClientOptions,
|
|
23
|
+
} from './client.js';
|
|
7
24
|
export type { GrpcCoreClientOptions } from './core.js';
|
|
8
25
|
|
|
9
26
|
// Re-export transports and types so users can configure custom transports
|
package/src/version.ts
CHANGED