@mysten/sui 2.23.2 → 2.25.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 +67 -0
- package/README.md +9 -9
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/client/core.d.mts +1 -0
- 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 +1 -0
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/client/types.d.mts +7 -0
- package/dist/client/types.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +6 -1
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +18 -2
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +5 -4
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +60 -14
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +8 -1
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +16 -0
- package/dist/grpc/client.d.mts +6 -1
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +17 -2
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +1 -0
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +20 -0
- package/dist/grpc/core.mjs.map +1 -1
- 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/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/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 +6 -1
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +25 -7
- package/dist/jsonRpc/core.mjs.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 +151 -690
- package/docs/clients/executing.md +113 -0
- package/docs/clients/graphql.md +91 -46
- package/docs/clients/grpc.md +239 -142
- package/docs/clients/index.md +87 -51
- package/docs/clients/querying.md +539 -0
- package/docs/executors.md +28 -13
- package/docs/index.md +1 -1
- package/docs/llms-index.md +18 -17
- package/docs/migrations/sui-2.0/dapp-kit.md +3 -3
- package/docs/migrations/sui-2.0/deepbook-v3.md +2 -2
- package/docs/migrations/sui-2.0/index.md +46 -25
- package/docs/migrations/sui-2.0/json-rpc-migration.md +462 -284
- package/docs/migrations/sui-2.0/kiosk.md +10 -9
- package/docs/migrations/sui-2.0/sdk-maintainers.md +17 -11
- package/docs/migrations/sui-2.0/sui.md +47 -29
- package/docs/migrations/sui-2.0/suins.md +2 -2
- package/docs/migrations/sui-2.0/walrus.md +3 -3
- package/docs/migrations/sui-2.0/zksend.md +9 -8
- package/docs/sdk-building.md +7 -5
- package/docs/transactions/signing-and-execution.md +8 -28
- package/package.json +1 -1
- package/src/client/core.ts +5 -0
- package/src/client/mvr.ts +6 -0
- package/src/client/types.ts +11 -0
- package/src/graphql/client.ts +35 -2
- package/src/graphql/core.ts +57 -10
- package/src/graphql/generated/queries.ts +14 -0
- package/src/graphql/generated/schema.graphql +11 -1
- package/src/graphql/generated/tada-env.ts +20 -0
- package/src/graphql/queries/nameService.graphql +6 -0
- package/src/grpc/client.ts +34 -2
- package/src/grpc/core.ts +35 -0
- package/src/jsonRpc/client.ts +15 -0
- package/src/jsonRpc/core.ts +31 -6
- package/src/version.ts +1 -1
- package/docs/clients/json-rpc.md +0 -239
package/src/graphql/core.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { CoreClient } from '../client/core.js';
|
|
5
|
+
import { raceSignal } from '../client/mvr.js';
|
|
5
6
|
import type { SuiClientTypes } from '../client/types.js';
|
|
6
7
|
import { SUI_TYPE_ARG } from '../utils/constants.js';
|
|
7
8
|
import type { GraphQLQueryOptions, SuiGraphQLClient } from './client.js';
|
|
@@ -31,6 +32,7 @@ import {
|
|
|
31
32
|
ListEventsDocument,
|
|
32
33
|
ListTransactionsDocument,
|
|
33
34
|
MultiGetObjectsDocument,
|
|
35
|
+
ResolveNameServiceAddressDocument,
|
|
34
36
|
ResolveTransactionDocument,
|
|
35
37
|
SimulateTransactionDocument,
|
|
36
38
|
VerifyZkLoginSignatureDocument,
|
|
@@ -108,6 +110,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
108
110
|
const page = await this.#graphqlQuery(
|
|
109
111
|
{
|
|
110
112
|
query: MultiGetObjectsDocument,
|
|
113
|
+
signal: options.signal,
|
|
111
114
|
variables: {
|
|
112
115
|
objectKeys: batch.map((address) => ({ address })),
|
|
113
116
|
includeContent: options.include?.content ?? false,
|
|
@@ -186,12 +189,16 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
186
189
|
const objects = await this.#graphqlQuery(
|
|
187
190
|
{
|
|
188
191
|
query: GetOwnedObjectsDocument,
|
|
192
|
+
signal: options.signal,
|
|
189
193
|
variables: {
|
|
190
194
|
owner: options.owner,
|
|
191
195
|
limit: options.limit,
|
|
192
196
|
cursor: options.cursor,
|
|
193
197
|
filter: options.type
|
|
194
|
-
? {
|
|
198
|
+
? {
|
|
199
|
+
type: (await this.mvr.resolveType({ type: options.type, signal: options.signal }))
|
|
200
|
+
.type,
|
|
201
|
+
}
|
|
195
202
|
: undefined,
|
|
196
203
|
includeContent: options.include?.content ?? false,
|
|
197
204
|
includePreviousTransaction: options.include?.previousTransaction ?? false,
|
|
@@ -241,11 +248,12 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
241
248
|
const coins = await this.#graphqlQuery(
|
|
242
249
|
{
|
|
243
250
|
query: GetCoinsDocument,
|
|
251
|
+
signal: options.signal,
|
|
244
252
|
variables: {
|
|
245
253
|
owner: options.owner,
|
|
246
254
|
cursor: options.cursor,
|
|
247
255
|
first: options.limit,
|
|
248
|
-
type: `0x2::coin::Coin<${(await this.mvr.resolveType({ type: coinType })).type}>`,
|
|
256
|
+
type: `0x2::coin::Coin<${(await this.mvr.resolveType({ type: coinType, signal: options.signal })).type}>`,
|
|
249
257
|
},
|
|
250
258
|
},
|
|
251
259
|
(result) => result.address?.objects,
|
|
@@ -274,9 +282,10 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
274
282
|
const result = await this.#graphqlQuery(
|
|
275
283
|
{
|
|
276
284
|
query: GetBalanceDocument,
|
|
285
|
+
signal: options.signal,
|
|
277
286
|
variables: {
|
|
278
287
|
owner: options.owner,
|
|
279
|
-
coinType: (await this.mvr.resolveType({ type: coinType })).type,
|
|
288
|
+
coinType: (await this.mvr.resolveType({ type: coinType, signal: options.signal })).type,
|
|
280
289
|
},
|
|
281
290
|
},
|
|
282
291
|
(result) => result.address?.balance,
|
|
@@ -297,10 +306,13 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
297
306
|
async getCoinMetadata(
|
|
298
307
|
options: SuiClientTypes.GetCoinMetadataOptions,
|
|
299
308
|
): Promise<SuiClientTypes.GetCoinMetadataResponse> {
|
|
300
|
-
const coinType = (
|
|
309
|
+
const coinType = (
|
|
310
|
+
await this.mvr.resolveType({ type: options.coinType, signal: options.signal })
|
|
311
|
+
).type;
|
|
301
312
|
|
|
302
313
|
const { data, errors } = await this.#graphqlClient.query({
|
|
303
314
|
query: GetCoinMetadataDocument,
|
|
315
|
+
signal: options.signal,
|
|
304
316
|
variables: {
|
|
305
317
|
coinType,
|
|
306
318
|
},
|
|
@@ -330,6 +342,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
330
342
|
const balances = await this.#graphqlQuery(
|
|
331
343
|
{
|
|
332
344
|
query: GetAllBalancesDocument,
|
|
345
|
+
signal: options.signal,
|
|
333
346
|
variables: {
|
|
334
347
|
owner: options.owner,
|
|
335
348
|
limit: options.limit,
|
|
@@ -360,6 +373,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
360
373
|
const result = await this.#graphqlQuery(
|
|
361
374
|
{
|
|
362
375
|
query: GetTransactionBlockDocument,
|
|
376
|
+
signal: options.signal,
|
|
363
377
|
variables: {
|
|
364
378
|
digest: options.digest,
|
|
365
379
|
includeTransaction: options.include?.transaction ?? false,
|
|
@@ -381,6 +395,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
381
395
|
const result = await this.#graphqlQuery(
|
|
382
396
|
{
|
|
383
397
|
query: ExecuteTransactionDocument,
|
|
398
|
+
signal: options.signal,
|
|
384
399
|
variables: {
|
|
385
400
|
transactionDataBcs: toBase64(options.transaction),
|
|
386
401
|
signatures: options.signatures,
|
|
@@ -416,6 +431,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
416
431
|
const result = await this.#graphqlQuery(
|
|
417
432
|
{
|
|
418
433
|
query: SimulateTransactionDocument,
|
|
434
|
+
signal: options.signal,
|
|
419
435
|
variables: {
|
|
420
436
|
transaction:
|
|
421
437
|
options.transaction instanceof Uint8Array
|
|
@@ -469,10 +485,13 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
469
485
|
};
|
|
470
486
|
}
|
|
471
487
|
}
|
|
472
|
-
async getReferenceGasPrice(
|
|
488
|
+
async getReferenceGasPrice(
|
|
489
|
+
options?: SuiClientTypes.GetReferenceGasPriceOptions,
|
|
490
|
+
): Promise<SuiClientTypes.GetReferenceGasPriceResponse> {
|
|
473
491
|
const result = await this.#graphqlQuery(
|
|
474
492
|
{
|
|
475
493
|
query: GetReferenceGasPriceDocument,
|
|
494
|
+
signal: options?.signal,
|
|
476
495
|
},
|
|
477
496
|
(result) => result.epoch?.referenceGasPrice,
|
|
478
497
|
);
|
|
@@ -482,10 +501,13 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
482
501
|
};
|
|
483
502
|
}
|
|
484
503
|
|
|
485
|
-
async getProtocolConfig(
|
|
504
|
+
async getProtocolConfig(
|
|
505
|
+
options?: SuiClientTypes.GetProtocolConfigOptions,
|
|
506
|
+
): Promise<SuiClientTypes.GetProtocolConfigResponse> {
|
|
486
507
|
const result = await this.#graphqlQuery(
|
|
487
508
|
{
|
|
488
509
|
query: GetProtocolConfigDocument,
|
|
510
|
+
signal: options?.signal,
|
|
489
511
|
},
|
|
490
512
|
(result) => result.epoch?.protocolConfigs,
|
|
491
513
|
);
|
|
@@ -508,10 +530,13 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
508
530
|
};
|
|
509
531
|
}
|
|
510
532
|
|
|
511
|
-
async getCurrentSystemState(
|
|
533
|
+
async getCurrentSystemState(
|
|
534
|
+
options?: SuiClientTypes.GetCurrentSystemStateOptions,
|
|
535
|
+
): Promise<SuiClientTypes.GetCurrentSystemStateResponse> {
|
|
512
536
|
const result = await this.#graphqlQuery(
|
|
513
537
|
{
|
|
514
538
|
query: GetCurrentSystemStateDocument,
|
|
539
|
+
signal: options?.signal,
|
|
515
540
|
},
|
|
516
541
|
(result) => result.epoch,
|
|
517
542
|
);
|
|
@@ -743,6 +768,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
743
768
|
|
|
744
769
|
const { data } = await this.#graphqlClient.query({
|
|
745
770
|
query: VerifyZkLoginSignatureDocument,
|
|
771
|
+
signal: options.signal,
|
|
746
772
|
variables: {
|
|
747
773
|
bytes: options.bytes,
|
|
748
774
|
signature: options.signature,
|
|
@@ -776,14 +802,31 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
776
802
|
};
|
|
777
803
|
}
|
|
778
804
|
|
|
805
|
+
async resolveNameServiceAddress(
|
|
806
|
+
options: SuiClientTypes.ResolveNameServiceAddressOptions,
|
|
807
|
+
): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {
|
|
808
|
+
const { data, errors } = await this.#graphqlClient.query({
|
|
809
|
+
query: ResolveNameServiceAddressDocument,
|
|
810
|
+
signal: options.signal,
|
|
811
|
+
variables: { name: options.name },
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
handleGraphQLErrors(errors);
|
|
815
|
+
|
|
816
|
+
return { address: data?.address?.address ?? null };
|
|
817
|
+
}
|
|
818
|
+
|
|
779
819
|
async getMoveFunction(
|
|
780
820
|
options: SuiClientTypes.GetMoveFunctionOptions,
|
|
781
821
|
): Promise<SuiClientTypes.GetMoveFunctionResponse> {
|
|
782
822
|
const moveFunction = await this.#graphqlQuery(
|
|
783
823
|
{
|
|
784
824
|
query: GetMoveFunctionDocument,
|
|
825
|
+
signal: options.signal,
|
|
785
826
|
variables: {
|
|
786
|
-
package: (
|
|
827
|
+
package: (
|
|
828
|
+
await this.mvr.resolvePackage({ package: options.packageId, signal: options.signal })
|
|
829
|
+
).package,
|
|
787
830
|
module: options.moduleName,
|
|
788
831
|
function: options.name,
|
|
789
832
|
},
|
|
@@ -841,9 +884,11 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
841
884
|
}
|
|
842
885
|
|
|
843
886
|
async getChainIdentifier(
|
|
844
|
-
|
|
887
|
+
options?: SuiClientTypes.GetChainIdentifierOptions,
|
|
845
888
|
): Promise<SuiClientTypes.GetChainIdentifierResponse> {
|
|
846
|
-
|
|
889
|
+
// The result is cached and shared across callers, so the underlying request must
|
|
890
|
+
// not carry any single caller's signal. Isolate cancellation per-caller instead.
|
|
891
|
+
const cached = this.cache.read(['chainIdentifier'], async () => {
|
|
847
892
|
const checkpoint = await this.#graphqlQuery(
|
|
848
893
|
{
|
|
849
894
|
query: GetChainIdentifierDocument,
|
|
@@ -857,6 +902,8 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
857
902
|
chainIdentifier: checkpoint.digest,
|
|
858
903
|
};
|
|
859
904
|
});
|
|
905
|
+
|
|
906
|
+
return raceSignal(Promise.resolve(cached), options?.signal);
|
|
860
907
|
}
|
|
861
908
|
|
|
862
909
|
resolveTransactionPlugin() {
|
|
@@ -286,6 +286,13 @@ export type DefaultSuinsNameQueryVariables = Exact<{
|
|
|
286
286
|
|
|
287
287
|
export type DefaultSuinsNameQuery = { address: { defaultNameRecord: { domain: string } | null } | null };
|
|
288
288
|
|
|
289
|
+
export type ResolveNameServiceAddressQueryVariables = Exact<{
|
|
290
|
+
name: string;
|
|
291
|
+
}>;
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
export type ResolveNameServiceAddressQuery = { address: { address: string } | null };
|
|
295
|
+
|
|
289
296
|
export type GetOwnedObjectsQueryVariables = Exact<{
|
|
290
297
|
owner: string;
|
|
291
298
|
limit?: number | null | undefined;
|
|
@@ -904,6 +911,13 @@ export const DefaultSuinsNameDocument = new TypedDocumentString(`
|
|
|
904
911
|
}
|
|
905
912
|
}
|
|
906
913
|
`) as unknown as TypedDocumentString<DefaultSuinsNameQuery, DefaultSuinsNameQueryVariables>;
|
|
914
|
+
export const ResolveNameServiceAddressDocument = new TypedDocumentString(`
|
|
915
|
+
query resolveNameServiceAddress($name: String!) {
|
|
916
|
+
address(name: $name) {
|
|
917
|
+
address
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
`) as unknown as TypedDocumentString<ResolveNameServiceAddressQuery, ResolveNameServiceAddressQueryVariables>;
|
|
907
921
|
export const GetOwnedObjectsDocument = new TypedDocumentString(`
|
|
908
922
|
query getOwnedObjects($owner: SuiAddress!, $limit: Int, $cursor: String, $filter: ObjectFilter, $includeContent: Boolean = false, $includePreviousTransaction: Boolean = false, $includeObjectBcs: Boolean = false, $includeJson: Boolean = false, $includeDisplay: Boolean = false) {
|
|
909
923
|
address(address: $owner) {
|
|
@@ -1225,7 +1225,7 @@ type EndOfEpochTransaction {
|
|
|
1225
1225
|
transactions(first: Int, after: String, last: Int, before: String): EndOfEpochTransactionKindConnection
|
|
1226
1226
|
}
|
|
1227
1227
|
|
|
1228
|
-
union EndOfEpochTransactionKind = ChangeEpochTransaction | AuthenticatorStateCreateTransaction | AuthenticatorStateExpireTransaction | RandomnessStateCreateTransaction | CoinDenyListStateCreateTransaction | StoreExecutionTimeObservationsTransaction | BridgeStateCreateTransaction | BridgeCommitteeInitTransaction | AccumulatorRootCreateTransaction | CoinRegistryCreateTransaction | DisplayRegistryCreateTransaction | AddressAliasStateCreateTransaction | WriteAccumulatorStorageCostTransaction
|
|
1228
|
+
union EndOfEpochTransactionKind = ChangeEpochTransaction | AuthenticatorStateCreateTransaction | AuthenticatorStateExpireTransaction | RandomnessStateCreateTransaction | CoinDenyListStateCreateTransaction | StoreExecutionTimeObservationsTransaction | BridgeStateCreateTransaction | BridgeCommitteeInitTransaction | AccumulatorRootCreateTransaction | CoinRegistryCreateTransaction | DisplayRegistryCreateTransaction | AddressAliasStateCreateTransaction | WriteAccumulatorStorageCostTransaction | ForwardingAddressRegistryCreateTransaction
|
|
1229
1229
|
|
|
1230
1230
|
type EndOfEpochTransactionKindConnection {
|
|
1231
1231
|
"""
|
|
@@ -1578,6 +1578,16 @@ type FeatureFlag {
|
|
|
1578
1578
|
}
|
|
1579
1579
|
|
|
1580
1580
|
|
|
1581
|
+
"""
|
|
1582
|
+
System transaction for creating the forwarding address registry.
|
|
1583
|
+
"""
|
|
1584
|
+
type ForwardingAddressRegistryCreateTransaction {
|
|
1585
|
+
"""
|
|
1586
|
+
A workaround to define an empty variant of a GraphQL union.
|
|
1587
|
+
"""
|
|
1588
|
+
_: Boolean
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1581
1591
|
"""
|
|
1582
1592
|
Access to the gas inputs, after they have been smashed into one coin. The gas coin can only be used by reference, except for with `TransferObjectsTransaction` that can accept it by value.
|
|
1583
1593
|
"""
|
|
@@ -3697,6 +3697,10 @@ const introspection = {
|
|
|
3697
3697
|
"kind": "OBJECT",
|
|
3698
3698
|
"name": "DisplayRegistryCreateTransaction"
|
|
3699
3699
|
},
|
|
3700
|
+
{
|
|
3701
|
+
"kind": "OBJECT",
|
|
3702
|
+
"name": "ForwardingAddressRegistryCreateTransaction"
|
|
3703
|
+
},
|
|
3700
3704
|
{
|
|
3701
3705
|
"kind": "OBJECT",
|
|
3702
3706
|
"name": "RandomnessStateCreateTransaction"
|
|
@@ -4551,6 +4555,22 @@ const introspection = {
|
|
|
4551
4555
|
],
|
|
4552
4556
|
"interfaces": []
|
|
4553
4557
|
},
|
|
4558
|
+
{
|
|
4559
|
+
"kind": "OBJECT",
|
|
4560
|
+
"name": "ForwardingAddressRegistryCreateTransaction",
|
|
4561
|
+
"fields": [
|
|
4562
|
+
{
|
|
4563
|
+
"name": "_",
|
|
4564
|
+
"type": {
|
|
4565
|
+
"kind": "SCALAR",
|
|
4566
|
+
"name": "Boolean"
|
|
4567
|
+
},
|
|
4568
|
+
"args": [],
|
|
4569
|
+
"isDeprecated": false
|
|
4570
|
+
}
|
|
4571
|
+
],
|
|
4572
|
+
"interfaces": []
|
|
4573
|
+
},
|
|
4554
4574
|
{
|
|
4555
4575
|
"kind": "OBJECT",
|
|
4556
4576
|
"name": "GasCoin",
|
package/src/grpc/client.ts
CHANGED
|
@@ -246,8 +246,28 @@ export class SuiGrpcClient extends BaseClient implements SuiClientTypes.Transpor
|
|
|
246
246
|
return this.core.simulateTransaction(input) as Promise<GrpcSimulateTransactionResult<Include>>;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
getReferenceGasPrice(
|
|
250
|
-
|
|
249
|
+
getReferenceGasPrice(
|
|
250
|
+
input?: SuiClientTypes.GetReferenceGasPriceOptions,
|
|
251
|
+
): Promise<SuiClientTypes.GetReferenceGasPriceResponse> {
|
|
252
|
+
return this.core.getReferenceGasPrice(input);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
getCurrentSystemState(
|
|
256
|
+
input?: SuiClientTypes.GetCurrentSystemStateOptions,
|
|
257
|
+
): Promise<SuiClientTypes.GetCurrentSystemStateResponse> {
|
|
258
|
+
return this.core.getCurrentSystemState(input);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
getProtocolConfig(
|
|
262
|
+
input?: SuiClientTypes.GetProtocolConfigOptions,
|
|
263
|
+
): Promise<SuiClientTypes.GetProtocolConfigResponse> {
|
|
264
|
+
return this.core.getProtocolConfig(input);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
getChainIdentifier(
|
|
268
|
+
input?: SuiClientTypes.GetChainIdentifierOptions,
|
|
269
|
+
): Promise<SuiClientTypes.GetChainIdentifierResponse> {
|
|
270
|
+
return this.core.getChainIdentifier(input);
|
|
251
271
|
}
|
|
252
272
|
|
|
253
273
|
async listDynamicFields<Include extends DynamicFieldInclude = {}>(
|
|
@@ -305,6 +325,12 @@ export class SuiGrpcClient extends BaseClient implements SuiClientTypes.Transpor
|
|
|
305
325
|
return this.core.getDynamicField(input);
|
|
306
326
|
}
|
|
307
327
|
|
|
328
|
+
getDynamicObjectField<Include extends SuiClientTypes.ObjectInclude = {}>(
|
|
329
|
+
input: SuiClientTypes.GetDynamicObjectFieldOptions<Include>,
|
|
330
|
+
): Promise<SuiClientTypes.GetDynamicObjectFieldResponse<Include>> {
|
|
331
|
+
return this.core.getDynamicObjectField(input);
|
|
332
|
+
}
|
|
333
|
+
|
|
308
334
|
listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
309
335
|
input: SuiClientTypes.ListTransactionsOptions<Include>,
|
|
310
336
|
): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {
|
|
@@ -336,4 +362,10 @@ export class SuiGrpcClient extends BaseClient implements SuiClientTypes.Transpor
|
|
|
336
362
|
): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {
|
|
337
363
|
return this.core.defaultNameServiceName(input);
|
|
338
364
|
}
|
|
365
|
+
|
|
366
|
+
resolveNameServiceAddress(
|
|
367
|
+
input: SuiClientTypes.ResolveNameServiceAddressOptions,
|
|
368
|
+
): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {
|
|
369
|
+
return this.core.resolveNameServiceAddress(input);
|
|
370
|
+
}
|
|
339
371
|
}
|
package/src/grpc/core.ts
CHANGED
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
import type { QueryEnd, QueryOptions } from './proto/sui/rpc/v2/query_options.js';
|
|
55
55
|
import { Ordering, QueryEndReason } from './proto/sui/rpc/v2/query_options.js';
|
|
56
56
|
import type { ResolvedPagination } from '../client/query-filters.js';
|
|
57
|
+
import { RpcError } from '@protobuf-ts/runtime-rpc';
|
|
57
58
|
import {
|
|
58
59
|
resolveEventFilter,
|
|
59
60
|
resolvePagination,
|
|
@@ -66,6 +67,21 @@ export interface GrpcCoreClientOptions extends CoreClientOptions {
|
|
|
66
67
|
client: SuiGrpcClient;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
function isNameServiceResolutionMiss(error: unknown): boolean {
|
|
71
|
+
if (!(error instanceof RpcError)) return false;
|
|
72
|
+
if (error.code === 'NOT_FOUND') return true;
|
|
73
|
+
if (error.code !== 'RESOURCE_EXHAUSTED') return false;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
// The gRPC service currently reports expired names as RESOURCE_EXHAUSTED without a
|
|
77
|
+
// structured reason. grpc-web URI-encodes status messages, so decode before matching while
|
|
78
|
+
// preserving unrelated RESOURCE_EXHAUSTED failures such as capacity limits.
|
|
79
|
+
return decodeURIComponent(error.message) === 'name has expired';
|
|
80
|
+
} catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
69
85
|
export class GrpcCoreClient extends CoreClient {
|
|
70
86
|
#client: SuiGrpcClient;
|
|
71
87
|
constructor({ client, ...options }: GrpcCoreClientOptions) {
|
|
@@ -797,6 +813,25 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
797
813
|
};
|
|
798
814
|
}
|
|
799
815
|
|
|
816
|
+
async resolveNameServiceAddress(
|
|
817
|
+
options: SuiClientTypes.ResolveNameServiceAddressOptions,
|
|
818
|
+
): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {
|
|
819
|
+
try {
|
|
820
|
+
const { response } = await this.#client.nameService.lookupName(
|
|
821
|
+
{ name: options.name },
|
|
822
|
+
{ abort: options.signal },
|
|
823
|
+
);
|
|
824
|
+
|
|
825
|
+
return { address: response.record?.targetAddress ?? null };
|
|
826
|
+
} catch (error) {
|
|
827
|
+
if (isNameServiceResolutionMiss(error)) {
|
|
828
|
+
return { address: null };
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
throw error;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
800
835
|
async getMoveFunction(
|
|
801
836
|
options: SuiClientTypes.GetMoveFunctionOptions,
|
|
802
837
|
): Promise<SuiClientTypes.GetMoveFunctionResponse> {
|
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
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
resolveTransactionFilter,
|
|
27
27
|
validateTransactionQuery,
|
|
28
28
|
} from '../client/query-filters.js';
|
|
29
|
+
import { raceSignal } from '../client/mvr.js';
|
|
29
30
|
import { Transaction } from '../transactions/Transaction.js';
|
|
30
31
|
import { computeGasBudget, coreClientResolveTransactionPlugin } from '../client/core-resolver.js';
|
|
31
32
|
import { TransactionDataBuilder } from '../transactions/TransactionData.js';
|
|
@@ -282,7 +283,9 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
282
283
|
async getCoinMetadata(
|
|
283
284
|
options: SuiClientTypes.GetCoinMetadataOptions,
|
|
284
285
|
): Promise<SuiClientTypes.GetCoinMetadataResponse> {
|
|
285
|
-
const coinType = (
|
|
286
|
+
const coinType = (
|
|
287
|
+
await this.mvr.resolveType({ type: options.coinType, signal: options.signal })
|
|
288
|
+
).type;
|
|
286
289
|
|
|
287
290
|
const result = await this.#jsonRpcClient.getCoinMetadata({
|
|
288
291
|
coinType,
|
|
@@ -402,7 +405,9 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
402
405
|
overrides: {
|
|
403
406
|
gasData: {
|
|
404
407
|
budget: data.gasData.budget ?? String(MAX_GAS),
|
|
405
|
-
price:
|
|
408
|
+
price:
|
|
409
|
+
data.gasData.price ??
|
|
410
|
+
String(await this.#jsonRpcClient.getReferenceGasPrice({ signal: options.signal })),
|
|
406
411
|
payment: data.gasData.payment ?? [],
|
|
407
412
|
},
|
|
408
413
|
},
|
|
@@ -627,6 +632,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
627
632
|
parentId: options.parentId,
|
|
628
633
|
limit: options.limit,
|
|
629
634
|
cursor: options.cursor,
|
|
635
|
+
signal: options.signal,
|
|
630
636
|
});
|
|
631
637
|
|
|
632
638
|
return {
|
|
@@ -775,6 +781,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
775
781
|
*/
|
|
776
782
|
async verifyZkLoginSignature(options: SuiClientTypes.VerifyZkLoginSignatureOptions) {
|
|
777
783
|
const result = await this.#jsonRpcClient.verifyZkLoginSignature({
|
|
784
|
+
signal: options.signal,
|
|
778
785
|
bytes: options.bytes,
|
|
779
786
|
signature: options.signature,
|
|
780
787
|
intentScope: options.intentScope,
|
|
@@ -802,6 +809,18 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
802
809
|
};
|
|
803
810
|
}
|
|
804
811
|
|
|
812
|
+
/**
|
|
813
|
+
* @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
|
|
814
|
+
* from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
|
|
815
|
+
*/
|
|
816
|
+
async resolveNameServiceAddress(
|
|
817
|
+
options: SuiClientTypes.ResolveNameServiceAddressOptions,
|
|
818
|
+
): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {
|
|
819
|
+
return {
|
|
820
|
+
address: await this.#jsonRpcClient.resolveNameServiceAddress(options),
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
|
|
805
824
|
/**
|
|
806
825
|
* @deprecated JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use `SuiGrpcClient`
|
|
807
826
|
* from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
|
|
@@ -817,12 +836,14 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
817
836
|
async getMoveFunction(
|
|
818
837
|
options: SuiClientTypes.GetMoveFunctionOptions,
|
|
819
838
|
): Promise<SuiClientTypes.GetMoveFunctionResponse> {
|
|
820
|
-
const resolvedPackageId = (
|
|
821
|
-
.package
|
|
839
|
+
const resolvedPackageId = (
|
|
840
|
+
await this.mvr.resolvePackage({ package: options.packageId, signal: options.signal })
|
|
841
|
+
).package;
|
|
822
842
|
const result = await this.#jsonRpcClient.getNormalizedMoveFunction({
|
|
823
843
|
package: resolvedPackageId,
|
|
824
844
|
module: options.moduleName,
|
|
825
845
|
function: options.name,
|
|
846
|
+
signal: options.signal,
|
|
826
847
|
});
|
|
827
848
|
|
|
828
849
|
return {
|
|
@@ -847,14 +868,18 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
847
868
|
* from `@mysten/sui/grpc` or `SuiGraphQLClient` from `@mysten/sui/graphql` instead.
|
|
848
869
|
*/
|
|
849
870
|
async getChainIdentifier(
|
|
850
|
-
|
|
871
|
+
options?: SuiClientTypes.GetChainIdentifierOptions,
|
|
851
872
|
): Promise<SuiClientTypes.GetChainIdentifierResponse> {
|
|
852
|
-
|
|
873
|
+
// The result is cached and shared across callers, so the underlying request must
|
|
874
|
+
// not carry any single caller's signal. Isolate cancellation per-caller instead.
|
|
875
|
+
const cached = this.cache.read(['chainIdentifier'], async () => {
|
|
853
876
|
const checkpoint = await this.#jsonRpcClient.getCheckpoint({ id: '0' });
|
|
854
877
|
return {
|
|
855
878
|
chainIdentifier: checkpoint.digest,
|
|
856
879
|
};
|
|
857
880
|
});
|
|
881
|
+
|
|
882
|
+
return raceSignal(Promise.resolve(cached), options?.signal);
|
|
858
883
|
}
|
|
859
884
|
}
|
|
860
885
|
|
package/src/version.ts
CHANGED