@mysten/sui 2.24.0 → 2.26.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 +69 -0
- package/dist/bcs/bcs.d.mts +6 -6
- 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/errors.d.mts +31 -2
- package/dist/client/errors.d.mts.map +1 -1
- package/dist/client/errors.mjs +15 -13
- package/dist/client/errors.mjs.map +1 -1
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.mjs +2 -2
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/mvr.mjs +1 -0
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +5 -1
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +15 -2
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +4 -4
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +61 -18
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +16 -0
- package/dist/grpc/client.d.mts +5 -1
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +14 -2
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +29 -12
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_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/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/subscription_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/client.d.mts.map +1 -1
- package/dist/jsonRpc/client.mjs +60 -15
- package/dist/jsonRpc/client.mjs.map +1 -1
- package/dist/jsonRpc/core.d.mts +1 -1
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +73 -22
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +6 -6
- package/dist/transactions/data/v1.d.mts +220 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.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/docs/bcs.md +2 -2
- package/docs/clients/core.md +150 -710
- package/docs/clients/executing.md +113 -0
- package/docs/clients/graphql.md +80 -70
- package/docs/clients/grpc.md +223 -208
- package/docs/clients/index.md +56 -67
- package/docs/clients/querying.md +539 -0
- package/docs/llms-index.md +6 -5
- package/docs/migrations/sui-2.0/json-rpc-migration.md +3 -1
- package/docs/transactions/signing-and-execution.md +8 -28
- package/package.json +1 -1
- package/src/client/core.ts +1 -0
- package/src/client/errors.ts +39 -23
- package/src/client/index.ts +9 -1
- package/src/client/mvr.ts +6 -0
- package/src/graphql/client.ts +29 -2
- package/src/graphql/core.ts +53 -16
- package/src/graphql/generated/schema.graphql +11 -1
- package/src/graphql/generated/tada-env.ts +20 -0
- package/src/grpc/client.ts +28 -2
- package/src/grpc/core.ts +90 -65
- package/src/jsonRpc/client.ts +15 -0
- package/src/jsonRpc/core.ts +102 -24
- package/src/version.ts +1 -1
- package/docs/clients/json-rpc.md +0 -243
package/src/grpc/core.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { CoreClientOptions, SuiClientTypes } from '../client/index.js';
|
|
5
|
-
import {
|
|
4
|
+
import type { CoreClientOptions, ObjectErrorReason, SuiClientTypes } from '../client/index.js';
|
|
5
|
+
import {
|
|
6
|
+
CoreClient,
|
|
7
|
+
formatMoveAbortMessage,
|
|
8
|
+
ObjectError,
|
|
9
|
+
SimulationError,
|
|
10
|
+
TransactionError,
|
|
11
|
+
} from '../client/index.js';
|
|
6
12
|
import { raceSignal } from '../client/mvr.js';
|
|
7
13
|
import type { SuiGrpcClient } from './client.js';
|
|
8
14
|
import type { Owner } from './proto/sui/rpc/v2/owner.js';
|
|
@@ -55,6 +61,7 @@ import type { QueryEnd, QueryOptions } from './proto/sui/rpc/v2/query_options.js
|
|
|
55
61
|
import { Ordering, QueryEndReason } from './proto/sui/rpc/v2/query_options.js';
|
|
56
62
|
import type { ResolvedPagination } from '../client/query-filters.js';
|
|
57
63
|
import { RpcError } from '@protobuf-ts/runtime-rpc';
|
|
64
|
+
import { GrpcStatusCode } from '@protobuf-ts/grpcweb-transport';
|
|
58
65
|
import {
|
|
59
66
|
resolveEventFilter,
|
|
60
67
|
resolvePagination,
|
|
@@ -69,8 +76,8 @@ export interface GrpcCoreClientOptions extends CoreClientOptions {
|
|
|
69
76
|
|
|
70
77
|
function isNameServiceResolutionMiss(error: unknown): boolean {
|
|
71
78
|
if (!(error instanceof RpcError)) return false;
|
|
72
|
-
if (error.code ===
|
|
73
|
-
if (error.code !==
|
|
79
|
+
if (error.code === GrpcStatusCode[GrpcStatusCode.NOT_FOUND]) return true;
|
|
80
|
+
if (error.code !== GrpcStatusCode[GrpcStatusCode.RESOURCE_EXHAUSTED]) return false;
|
|
74
81
|
|
|
75
82
|
try {
|
|
76
83
|
// The gRPC service currently reports expired names as RESOURCE_EXHAUSTED without a
|
|
@@ -124,51 +131,62 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
124
131
|
);
|
|
125
132
|
|
|
126
133
|
results.push(
|
|
127
|
-
...response.response.objects.map(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
134
|
+
...response.response.objects.map(
|
|
135
|
+
(object, index): SuiClientTypes.Object<Include> | ObjectError => {
|
|
136
|
+
if (object.result.oneofKind === 'error') {
|
|
137
|
+
const error = object.result.error;
|
|
138
|
+
const reason: ObjectErrorReason =
|
|
139
|
+
error.code === GrpcStatusCode.NOT_FOUND ? 'notFound' : 'unknown';
|
|
140
|
+
return new ObjectError(String(error.code), error.message, {
|
|
141
|
+
cause: error,
|
|
142
|
+
reason,
|
|
143
|
+
objectId: batch[index],
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (object.result.oneofKind !== 'object') {
|
|
148
|
+
return new ObjectError('unknown', 'Unexpected result type', {
|
|
149
|
+
reason: 'unknown',
|
|
150
|
+
objectId: batch[index],
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const bcsContent = object.result.object.contents?.value ?? undefined;
|
|
155
|
+
const objectBcs = object.result.object.bcs?.value ?? undefined;
|
|
156
|
+
|
|
157
|
+
// Package objects have type "package" which is not a struct tag, so don't normalize it
|
|
158
|
+
const objectType = object.result.object.objectType;
|
|
159
|
+
const type =
|
|
160
|
+
objectType && objectType.includes('::')
|
|
161
|
+
? normalizeStructTag(objectType)
|
|
162
|
+
: (objectType ?? '');
|
|
163
|
+
|
|
164
|
+
const jsonContent = options.include?.json
|
|
165
|
+
? object.result.object.json
|
|
166
|
+
? (Value.toJson(object.result.object.json) as Record<string, unknown>)
|
|
167
|
+
: null
|
|
168
|
+
: undefined;
|
|
169
|
+
|
|
170
|
+
const displayData = mapDisplayProto(
|
|
171
|
+
options.include?.display,
|
|
172
|
+
object.result.object.display,
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
objectId: object.result.object.objectId!,
|
|
177
|
+
version: object.result.object.version?.toString()!,
|
|
178
|
+
digest: object.result.object.digest!,
|
|
179
|
+
content: bcsContent as SuiClientTypes.Object<Include>['content'],
|
|
180
|
+
owner: mapOwner(object.result.object.owner)!,
|
|
181
|
+
type,
|
|
182
|
+
previousTransaction: (object.result.object.previousTransaction ??
|
|
183
|
+
undefined) as SuiClientTypes.Object<Include>['previousTransaction'],
|
|
184
|
+
objectBcs: objectBcs as SuiClientTypes.Object<Include>['objectBcs'],
|
|
185
|
+
json: jsonContent as SuiClientTypes.Object<Include>['json'],
|
|
186
|
+
display: displayData as SuiClientTypes.Object<Include>['display'],
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
),
|
|
172
190
|
);
|
|
173
191
|
}
|
|
174
192
|
|
|
@@ -362,25 +380,32 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
362
380
|
async getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
363
381
|
options: SuiClientTypes.GetTransactionOptions<Include>,
|
|
364
382
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
365
|
-
|
|
366
|
-
{
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
383
|
+
try {
|
|
384
|
+
const { response } = await this.#client.ledgerService.getTransaction(
|
|
385
|
+
{
|
|
386
|
+
digest: options.digest,
|
|
387
|
+
readMask: {
|
|
388
|
+
paths: transactionReadMaskPaths(options.include),
|
|
389
|
+
},
|
|
370
390
|
},
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
);
|
|
391
|
+
{ abort: options.signal },
|
|
392
|
+
);
|
|
374
393
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
394
|
+
if (!response.transaction) {
|
|
395
|
+
throw new TransactionError('notFound', options.digest);
|
|
396
|
+
}
|
|
378
397
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
398
|
+
return withProtoJson(
|
|
399
|
+
parseGrpcTransactionResponse(response.transaction, { include: options.include }),
|
|
400
|
+
options.include,
|
|
401
|
+
() => ExecutedTransaction.toJson(response.transaction!),
|
|
402
|
+
);
|
|
403
|
+
} catch (error) {
|
|
404
|
+
if (error instanceof RpcError && error.code === GrpcStatusCode[GrpcStatusCode.NOT_FOUND]) {
|
|
405
|
+
throw new TransactionError('notFound', options.digest, { cause: error });
|
|
406
|
+
}
|
|
407
|
+
throw error;
|
|
408
|
+
}
|
|
384
409
|
}
|
|
385
410
|
async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
386
411
|
options: SuiClientTypes.ExecuteTransactionOptions<Include>,
|
package/src/jsonRpc/client.ts
CHANGED
|
@@ -220,6 +220,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
220
220
|
coinType = (
|
|
221
221
|
await this.core.mvr.resolveType({
|
|
222
222
|
type: coinType,
|
|
223
|
+
signal,
|
|
223
224
|
})
|
|
224
225
|
).type;
|
|
225
226
|
}
|
|
@@ -272,6 +273,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
272
273
|
coinType = (
|
|
273
274
|
await this.core.mvr.resolveType({
|
|
274
275
|
type: coinType,
|
|
276
|
+
signal,
|
|
275
277
|
})
|
|
276
278
|
).type;
|
|
277
279
|
}
|
|
@@ -309,6 +311,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
309
311
|
coinType = (
|
|
310
312
|
await this.core.mvr.resolveType({
|
|
311
313
|
type: coinType,
|
|
314
|
+
signal,
|
|
312
315
|
})
|
|
313
316
|
).type;
|
|
314
317
|
}
|
|
@@ -330,6 +333,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
330
333
|
coinType = (
|
|
331
334
|
await this.core.mvr.resolveType({
|
|
332
335
|
type: coinType,
|
|
336
|
+
signal,
|
|
333
337
|
})
|
|
334
338
|
).type;
|
|
335
339
|
}
|
|
@@ -371,6 +375,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
371
375
|
pkg = (
|
|
372
376
|
await this.core.mvr.resolvePackage({
|
|
373
377
|
package: pkg,
|
|
378
|
+
signal,
|
|
374
379
|
})
|
|
375
380
|
).package;
|
|
376
381
|
}
|
|
@@ -396,6 +401,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
396
401
|
pkg = (
|
|
397
402
|
await this.core.mvr.resolvePackage({
|
|
398
403
|
package: pkg,
|
|
404
|
+
signal,
|
|
399
405
|
})
|
|
400
406
|
).package;
|
|
401
407
|
}
|
|
@@ -421,6 +427,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
421
427
|
pkg = (
|
|
422
428
|
await this.core.mvr.resolvePackage({
|
|
423
429
|
package: pkg,
|
|
430
|
+
signal,
|
|
424
431
|
})
|
|
425
432
|
).package;
|
|
426
433
|
}
|
|
@@ -447,6 +454,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
447
454
|
pkg = (
|
|
448
455
|
await this.core.mvr.resolvePackage({
|
|
449
456
|
package: pkg,
|
|
457
|
+
signal,
|
|
450
458
|
})
|
|
451
459
|
).package;
|
|
452
460
|
}
|
|
@@ -473,6 +481,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
473
481
|
pkg = (
|
|
474
482
|
await this.core.mvr.resolvePackage({
|
|
475
483
|
package: pkg,
|
|
484
|
+
signal,
|
|
476
485
|
})
|
|
477
486
|
).package;
|
|
478
487
|
}
|
|
@@ -506,6 +515,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
506
515
|
package: (
|
|
507
516
|
await this.core.mvr.resolvePackage({
|
|
508
517
|
package: filter.MoveModule.package,
|
|
518
|
+
signal: input.signal,
|
|
509
519
|
})
|
|
510
520
|
).package,
|
|
511
521
|
};
|
|
@@ -513,6 +523,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
513
523
|
filter.StructType = (
|
|
514
524
|
await this.core.mvr.resolveType({
|
|
515
525
|
type: filter.StructType,
|
|
526
|
+
signal: input.signal,
|
|
516
527
|
})
|
|
517
528
|
).type;
|
|
518
529
|
}
|
|
@@ -603,6 +614,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
603
614
|
package: (
|
|
604
615
|
await this.core.mvr.resolvePackage({
|
|
605
616
|
package: filter.MoveFunction.package,
|
|
617
|
+
signal,
|
|
606
618
|
})
|
|
607
619
|
).package,
|
|
608
620
|
},
|
|
@@ -820,6 +832,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
820
832
|
MoveEventType: (
|
|
821
833
|
await this.core.mvr.resolveType({
|
|
822
834
|
type: query.MoveEventType,
|
|
835
|
+
signal,
|
|
823
836
|
})
|
|
824
837
|
).type,
|
|
825
838
|
};
|
|
@@ -833,6 +846,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
833
846
|
package: (
|
|
834
847
|
await this.core.mvr.resolvePackage({
|
|
835
848
|
package: query.MoveEventModule.package,
|
|
849
|
+
signal,
|
|
836
850
|
})
|
|
837
851
|
).package,
|
|
838
852
|
},
|
|
@@ -847,6 +861,7 @@ export class SuiJsonRpcClient extends BaseClient {
|
|
|
847
861
|
package: (
|
|
848
862
|
await this.core.mvr.resolvePackage({
|
|
849
863
|
package: query.MoveModule.package,
|
|
864
|
+
signal,
|
|
850
865
|
})
|
|
851
866
|
).package,
|
|
852
867
|
},
|
package/src/jsonRpc/core.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
EventId,
|
|
11
11
|
ExecutionStatus as JsonRpcExecutionStatus,
|
|
12
12
|
ObjectOwner,
|
|
13
|
+
ObjectResponseError,
|
|
13
14
|
SuiMoveAbilitySet,
|
|
14
15
|
SuiMoveAbort,
|
|
15
16
|
SuiMoveNormalizedType,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
resolveTransactionFilter,
|
|
27
28
|
validateTransactionQuery,
|
|
28
29
|
} from '../client/query-filters.js';
|
|
30
|
+
import { raceSignal } from '../client/mvr.js';
|
|
29
31
|
import { Transaction } from '../transactions/Transaction.js';
|
|
30
32
|
import { computeGasBudget, coreClientResolveTransactionPlugin } from '../client/core-resolver.js';
|
|
31
33
|
import { TransactionDataBuilder } from '../transactions/TransactionData.js';
|
|
@@ -35,16 +37,73 @@ import { deriveDynamicFieldID } from '../utils/dynamic-fields.js';
|
|
|
35
37
|
import { SUI_FRAMEWORK_ADDRESS, SUI_SYSTEM_ADDRESS } from '../utils/constants.js';
|
|
36
38
|
import { CoreClient } from '../client/core.js';
|
|
37
39
|
import type { SuiClientTypes } from '../client/types.js';
|
|
38
|
-
import { ObjectError } from '../client/errors.js';
|
|
40
|
+
import { ObjectError, TransactionError } from '../client/errors.js';
|
|
39
41
|
import {
|
|
40
42
|
formatMoveAbortMessage,
|
|
41
43
|
parseTransactionBcs,
|
|
42
44
|
parseTransactionEffectsBcs,
|
|
43
45
|
} from '../client/index.js';
|
|
44
46
|
import type { SuiJsonRpcClient } from './client.js';
|
|
47
|
+
import { JsonRpcError } from './errors.js';
|
|
45
48
|
|
|
46
49
|
const MAX_GAS = 50_000_000_000;
|
|
47
50
|
|
|
51
|
+
function mapJsonRpcObjectError(
|
|
52
|
+
response: ObjectResponseError,
|
|
53
|
+
requestedObjectId?: string,
|
|
54
|
+
): ObjectError {
|
|
55
|
+
switch (response.code) {
|
|
56
|
+
case 'notExists':
|
|
57
|
+
return new ObjectError(response.code, `Object ${response.object_id} does not exist`, {
|
|
58
|
+
cause: response,
|
|
59
|
+
reason: 'notFound',
|
|
60
|
+
objectId: requestedObjectId ?? response.object_id,
|
|
61
|
+
});
|
|
62
|
+
case 'dynamicFieldNotFound':
|
|
63
|
+
return new ObjectError(
|
|
64
|
+
response.code,
|
|
65
|
+
`Dynamic field not found for object ${response.parent_object_id}`,
|
|
66
|
+
{
|
|
67
|
+
cause: response,
|
|
68
|
+
reason: 'notFound',
|
|
69
|
+
objectId: requestedObjectId ?? response.parent_object_id,
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
case 'deleted':
|
|
73
|
+
return new ObjectError(response.code, `Object ${response.object_id} has been deleted`, {
|
|
74
|
+
cause: response,
|
|
75
|
+
reason: 'deleted',
|
|
76
|
+
objectId: requestedObjectId ?? response.object_id,
|
|
77
|
+
});
|
|
78
|
+
case 'displayError':
|
|
79
|
+
return new ObjectError(response.code, `Display error: ${response.error}`, {
|
|
80
|
+
cause: response,
|
|
81
|
+
reason: 'unknown',
|
|
82
|
+
objectId: requestedObjectId,
|
|
83
|
+
});
|
|
84
|
+
case 'unknown':
|
|
85
|
+
default:
|
|
86
|
+
return new ObjectError(
|
|
87
|
+
response.code,
|
|
88
|
+
`Unknown error while loading object${requestedObjectId ? ` ${requestedObjectId}` : ''}`,
|
|
89
|
+
{
|
|
90
|
+
cause: response,
|
|
91
|
+
reason: 'unknown',
|
|
92
|
+
objectId: requestedObjectId,
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function isJsonRpcTransactionNotFound(error: unknown, digest: string): boolean {
|
|
99
|
+
if (!(error instanceof JsonRpcError) || error.code !== -32602) return false;
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
error.message === `Invalid Params: Transaction ${digest} not found` ||
|
|
103
|
+
error.message === `Could not find the referenced transaction [TransactionDigest(${digest})].`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
48
107
|
function parseJsonRpcExecutionStatus(
|
|
49
108
|
status: JsonRpcExecutionStatus,
|
|
50
109
|
abortError?: SuiMoveAbort | null,
|
|
@@ -159,7 +218,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
159
218
|
|
|
160
219
|
for (const [idx, object] of objects.entries()) {
|
|
161
220
|
if (object.error) {
|
|
162
|
-
results.push(
|
|
221
|
+
results.push(mapJsonRpcObjectError(object.error, batch[idx]));
|
|
163
222
|
} else {
|
|
164
223
|
results.push(parseObject(object.data!, options.include));
|
|
165
224
|
}
|
|
@@ -210,7 +269,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
210
269
|
return {
|
|
211
270
|
objects: objects.data.map((result) => {
|
|
212
271
|
if (result.error) {
|
|
213
|
-
throw
|
|
272
|
+
throw mapJsonRpcObjectError(result.error);
|
|
214
273
|
}
|
|
215
274
|
|
|
216
275
|
return parseObject(result.data!, options.include);
|
|
@@ -282,7 +341,9 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
282
341
|
async getCoinMetadata(
|
|
283
342
|
options: SuiClientTypes.GetCoinMetadataOptions,
|
|
284
343
|
): Promise<SuiClientTypes.GetCoinMetadataResponse> {
|
|
285
|
-
const coinType = (
|
|
344
|
+
const coinType = (
|
|
345
|
+
await this.mvr.resolveType({ type: options.coinType, signal: options.signal })
|
|
346
|
+
).type;
|
|
286
347
|
|
|
287
348
|
const result = await this.#jsonRpcClient.getCoinMetadata({
|
|
288
349
|
coinType,
|
|
@@ -337,22 +398,29 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
337
398
|
async getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
338
399
|
options: SuiClientTypes.GetTransactionOptions<Include>,
|
|
339
400
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
401
|
+
try {
|
|
402
|
+
const transaction = await this.#jsonRpcClient.getTransactionBlock({
|
|
403
|
+
digest: options.digest,
|
|
404
|
+
options: {
|
|
405
|
+
// showRawInput is always needed to extract signatures from SenderSignedData
|
|
406
|
+
showRawInput: true,
|
|
407
|
+
// showEffects is always needed to get status
|
|
408
|
+
showEffects: true,
|
|
409
|
+
showObjectChanges: options.include?.objectTypes ?? false,
|
|
410
|
+
showRawEffects: options.include?.effects ?? false,
|
|
411
|
+
showEvents: options.include?.events ?? false,
|
|
412
|
+
showBalanceChanges: options.include?.balanceChanges ?? false,
|
|
413
|
+
},
|
|
414
|
+
signal: options.signal,
|
|
415
|
+
});
|
|
354
416
|
|
|
355
|
-
|
|
417
|
+
return parseTransaction(transaction, options.include);
|
|
418
|
+
} catch (error) {
|
|
419
|
+
if (isJsonRpcTransactionNotFound(error, options.digest)) {
|
|
420
|
+
throw new TransactionError('notFound', options.digest, { cause: error });
|
|
421
|
+
}
|
|
422
|
+
throw error;
|
|
423
|
+
}
|
|
356
424
|
}
|
|
357
425
|
/**
|
|
358
426
|
* @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
|
|
@@ -402,7 +470,9 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
402
470
|
overrides: {
|
|
403
471
|
gasData: {
|
|
404
472
|
budget: data.gasData.budget ?? String(MAX_GAS),
|
|
405
|
-
price:
|
|
473
|
+
price:
|
|
474
|
+
data.gasData.price ??
|
|
475
|
+
String(await this.#jsonRpcClient.getReferenceGasPrice({ signal: options.signal })),
|
|
406
476
|
payment: data.gasData.payment ?? [],
|
|
407
477
|
},
|
|
408
478
|
},
|
|
@@ -627,6 +697,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
627
697
|
parentId: options.parentId,
|
|
628
698
|
limit: options.limit,
|
|
629
699
|
cursor: options.cursor,
|
|
700
|
+
signal: options.signal,
|
|
630
701
|
});
|
|
631
702
|
|
|
632
703
|
return {
|
|
@@ -775,6 +846,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
775
846
|
*/
|
|
776
847
|
async verifyZkLoginSignature(options: SuiClientTypes.VerifyZkLoginSignatureOptions) {
|
|
777
848
|
const result = await this.#jsonRpcClient.verifyZkLoginSignature({
|
|
849
|
+
signal: options.signal,
|
|
778
850
|
bytes: options.bytes,
|
|
779
851
|
signature: options.signature,
|
|
780
852
|
intentScope: options.intentScope,
|
|
@@ -829,12 +901,14 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
829
901
|
async getMoveFunction(
|
|
830
902
|
options: SuiClientTypes.GetMoveFunctionOptions,
|
|
831
903
|
): Promise<SuiClientTypes.GetMoveFunctionResponse> {
|
|
832
|
-
const resolvedPackageId = (
|
|
833
|
-
.package
|
|
904
|
+
const resolvedPackageId = (
|
|
905
|
+
await this.mvr.resolvePackage({ package: options.packageId, signal: options.signal })
|
|
906
|
+
).package;
|
|
834
907
|
const result = await this.#jsonRpcClient.getNormalizedMoveFunction({
|
|
835
908
|
package: resolvedPackageId,
|
|
836
909
|
module: options.moduleName,
|
|
837
910
|
function: options.name,
|
|
911
|
+
signal: options.signal,
|
|
838
912
|
});
|
|
839
913
|
|
|
840
914
|
return {
|
|
@@ -859,14 +933,18 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
859
933
|
* from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
|
|
860
934
|
*/
|
|
861
935
|
async getChainIdentifier(
|
|
862
|
-
|
|
936
|
+
options?: SuiClientTypes.GetChainIdentifierOptions,
|
|
863
937
|
): Promise<SuiClientTypes.GetChainIdentifierResponse> {
|
|
864
|
-
|
|
938
|
+
// The result is cached and shared across callers, so the underlying request must
|
|
939
|
+
// not carry any single caller's signal. Isolate cancellation per-caller instead.
|
|
940
|
+
const cached = this.cache.read(['chainIdentifier'], async () => {
|
|
865
941
|
const checkpoint = await this.#jsonRpcClient.getCheckpoint({ id: '0' });
|
|
866
942
|
return {
|
|
867
943
|
chainIdentifier: checkpoint.digest,
|
|
868
944
|
};
|
|
869
945
|
});
|
|
946
|
+
|
|
947
|
+
return raceSignal(Promise.resolve(cached), options?.signal);
|
|
870
948
|
}
|
|
871
949
|
}
|
|
872
950
|
|
package/src/version.ts
CHANGED