@mysten/sui 2.5.1 → 2.7.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 +29 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/client/core-resolver.mjs +6 -3
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.d.mts +8 -8
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs +11 -5
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/types.d.mts +73 -18
- package/dist/client/types.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +16 -1
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +50 -2
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +5 -5
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +28 -49
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +25 -7
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +706 -98
- package/dist/grpc/client.d.mts +16 -1
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +42 -2
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +5 -5
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +18 -35
- 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/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/object.d.mts +38 -1
- package/dist/grpc/proto/sui/rpc/v2/object.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/object.mjs +26 -1
- package/dist/grpc/proto/sui/rpc/v2/object.mjs.map +1 -1
- 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.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +8 -0
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs +23 -12
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
- package/dist/grpc/proto/types.d.mts +2 -2
- package/dist/grpc/proto/types.mjs +2 -1
- package/dist/jsonRpc/core.d.mts +6 -6
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +14 -5
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +6 -6
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/executor/caching.mjs.map +1 -1
- package/dist/transactions/executor/parallel.d.mts +1 -1
- package/dist/transactions/executor/parallel.d.mts.map +1 -1
- package/dist/transactions/executor/parallel.mjs.map +1 -1
- package/dist/transactions/executor/serial.d.mts +1 -1
- package/dist/transactions/executor/serial.d.mts.map +1 -1
- package/dist/transactions/executor/serial.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/package.json +1 -1
- package/src/client/core-resolver.ts +9 -8
- package/src/client/core.ts +28 -18
- package/src/client/types.ts +73 -18
- package/src/graphql/client.ts +96 -4
- package/src/graphql/core.ts +43 -88
- package/src/graphql/generated/queries.ts +271 -44
- package/src/graphql/generated/schema.graphql +328 -25
- package/src/graphql/generated/tada-env.ts +779 -58
- package/src/graphql/queries/getDynamicFields.graphql +8 -1
- package/src/graphql/queries/objects.graphql +10 -0
- package/src/graphql/queries/transactions.graphql +1 -3
- package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -1
- package/src/grpc/client.ts +62 -4
- package/src/grpc/core.ts +42 -39
- package/src/grpc/proto/sui/rpc/v2/object.ts +44 -0
- package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +16 -0
- package/src/jsonRpc/core.ts +18 -7
- package/src/transactions/executor/caching.ts +2 -2
- package/src/transactions/executor/parallel.ts +1 -1
- package/src/transactions/executor/serial.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
# Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
# SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
query getDynamicFields(
|
|
4
|
+
query getDynamicFields(
|
|
5
|
+
$parentId: SuiAddress!
|
|
6
|
+
$first: Int
|
|
7
|
+
$cursor: String
|
|
8
|
+
$includeValue: Boolean = false
|
|
9
|
+
) {
|
|
5
10
|
address(address: $parentId) {
|
|
6
11
|
dynamicFields(first: $first, after: $cursor) {
|
|
7
12
|
pageInfo {
|
|
@@ -18,6 +23,7 @@ query getDynamicFields($parentId: SuiAddress!, $first: Int, $cursor: String) {
|
|
|
18
23
|
value {
|
|
19
24
|
__typename
|
|
20
25
|
... on MoveValue {
|
|
26
|
+
bcs @include(if: $includeValue)
|
|
21
27
|
type {
|
|
22
28
|
repr
|
|
23
29
|
}
|
|
@@ -25,6 +31,7 @@ query getDynamicFields($parentId: SuiAddress!, $first: Int, $cursor: String) {
|
|
|
25
31
|
... on MoveObject {
|
|
26
32
|
address
|
|
27
33
|
contents {
|
|
34
|
+
bcs @include(if: $includeValue)
|
|
28
35
|
type {
|
|
29
36
|
repr
|
|
30
37
|
}
|
|
@@ -10,6 +10,7 @@ query getOwnedObjects(
|
|
|
10
10
|
$includePreviousTransaction: Boolean = false
|
|
11
11
|
$includeObjectBcs: Boolean = false
|
|
12
12
|
$includeJson: Boolean = false
|
|
13
|
+
$includeDisplay: Boolean = false
|
|
13
14
|
) {
|
|
14
15
|
address(address: $owner) {
|
|
15
16
|
objects(first: $limit, after: $cursor, filter: $filter) {
|
|
@@ -30,6 +31,7 @@ query multiGetObjects(
|
|
|
30
31
|
$includePreviousTransaction: Boolean = false
|
|
31
32
|
$includeObjectBcs: Boolean = false
|
|
32
33
|
$includeJson: Boolean = false
|
|
34
|
+
$includeDisplay: Boolean = false
|
|
33
35
|
) {
|
|
34
36
|
multiGetObjects(keys: $objectKeys) {
|
|
35
37
|
...OBJECT_FIELDS
|
|
@@ -45,6 +47,10 @@ fragment OBJECT_FIELDS on Object {
|
|
|
45
47
|
contents {
|
|
46
48
|
bcs @include(if: $includeContent)
|
|
47
49
|
json @include(if: $includeJson)
|
|
50
|
+
display @include(if: $includeDisplay) {
|
|
51
|
+
output
|
|
52
|
+
errors
|
|
53
|
+
}
|
|
48
54
|
type {
|
|
49
55
|
repr
|
|
50
56
|
}
|
|
@@ -69,6 +75,10 @@ fragment MOVE_OBJECT_FIELDS on MoveObject {
|
|
|
69
75
|
contents {
|
|
70
76
|
bcs @include(if: $includeContent)
|
|
71
77
|
json @include(if: $includeJson)
|
|
78
|
+
display @include(if: $includeDisplay) {
|
|
79
|
+
output
|
|
80
|
+
errors
|
|
81
|
+
}
|
|
72
82
|
type {
|
|
73
83
|
repr
|
|
74
84
|
}
|
|
@@ -18,7 +18,6 @@ query simulateTransaction(
|
|
|
18
18
|
doGasSelection: $doGasSelection
|
|
19
19
|
checksEnabled: $checksEnabled
|
|
20
20
|
) {
|
|
21
|
-
error
|
|
22
21
|
effects {
|
|
23
22
|
transaction {
|
|
24
23
|
...TRANSACTION_FIELDS
|
|
@@ -50,7 +49,6 @@ mutation executeTransaction(
|
|
|
50
49
|
$includeBcs: Boolean = false
|
|
51
50
|
) {
|
|
52
51
|
executeTransaction(transactionDataBcs: $transactionDataBcs, signatures: $signatures) {
|
|
53
|
-
errors
|
|
54
52
|
effects {
|
|
55
53
|
transaction {
|
|
56
54
|
...TRANSACTION_FIELDS
|
|
@@ -138,6 +136,7 @@ fragment TRANSACTION_FIELDS on Transaction {
|
|
|
138
136
|
repr
|
|
139
137
|
}
|
|
140
138
|
bcs
|
|
139
|
+
json
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
}
|
|
@@ -146,7 +145,6 @@ fragment TRANSACTION_FIELDS on Transaction {
|
|
|
146
145
|
|
|
147
146
|
query resolveTransaction($transaction: JSON!, $doGasSelection: Boolean = true) {
|
|
148
147
|
simulateTransaction(transaction: $transaction, doGasSelection: $doGasSelection) {
|
|
149
|
-
error
|
|
150
148
|
effects {
|
|
151
149
|
transaction {
|
|
152
150
|
transactionBcs
|
package/src/grpc/client.ts
CHANGED
|
@@ -13,6 +13,9 @@ import { SubscriptionServiceClient } from './proto/sui/rpc/v2/subscription_servi
|
|
|
13
13
|
import { GrpcCoreClient } from './core.js';
|
|
14
14
|
import type { SuiClientTypes } from '../client/index.js';
|
|
15
15
|
import { BaseClient } from '../client/index.js';
|
|
16
|
+
import { DynamicField_DynamicFieldKind } from './proto/sui/rpc/v2/state_service.js';
|
|
17
|
+
import { normalizeStructTag } from '../utils/sui-types.js';
|
|
18
|
+
import { fromBase64, toBase64 } from '@mysten/utils';
|
|
16
19
|
import { NameServiceClient } from './proto/sui/rpc/v2/name_service.client.js';
|
|
17
20
|
import type { TransactionPlugin } from '../transactions/index.js';
|
|
18
21
|
|
|
@@ -38,6 +41,21 @@ export function isSuiGrpcClient(client: unknown): client is SuiGrpcClient {
|
|
|
38
41
|
);
|
|
39
42
|
}
|
|
40
43
|
|
|
44
|
+
export interface DynamicFieldInclude {
|
|
45
|
+
value?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type DynamicFieldEntryWithValue<Include extends DynamicFieldInclude = {}> =
|
|
49
|
+
SuiClientTypes.DynamicFieldEntry & {
|
|
50
|
+
value: Include extends { value: true } ? SuiClientTypes.DynamicFieldValue : undefined;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export interface ListDynamicFieldsWithValueResponse<Include extends DynamicFieldInclude = {}> {
|
|
54
|
+
hasNextPage: boolean;
|
|
55
|
+
cursor: string | null;
|
|
56
|
+
dynamicFields: DynamicFieldEntryWithValue<Include>[];
|
|
57
|
+
}
|
|
58
|
+
|
|
41
59
|
export class SuiGrpcClient extends BaseClient implements SuiClientTypes.TransportMethods {
|
|
42
60
|
core: GrpcCoreClient;
|
|
43
61
|
get mvr(): SuiClientTypes.MvrMethods {
|
|
@@ -148,10 +166,50 @@ export class SuiGrpcClient extends BaseClient implements SuiClientTypes.Transpor
|
|
|
148
166
|
return this.core.getReferenceGasPrice();
|
|
149
167
|
}
|
|
150
168
|
|
|
151
|
-
listDynamicFields(
|
|
152
|
-
input: SuiClientTypes.ListDynamicFieldsOptions,
|
|
153
|
-
): Promise<
|
|
154
|
-
|
|
169
|
+
async listDynamicFields<Include extends DynamicFieldInclude = {}>(
|
|
170
|
+
input: SuiClientTypes.ListDynamicFieldsOptions & { include?: Include & DynamicFieldInclude },
|
|
171
|
+
): Promise<ListDynamicFieldsWithValueResponse<Include>> {
|
|
172
|
+
const includeValue = input.include?.value ?? false;
|
|
173
|
+
const paths = ['field_id', 'name', 'value_type', 'kind', 'child_id'];
|
|
174
|
+
if (includeValue) {
|
|
175
|
+
paths.push('value');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const response = await this.stateService.listDynamicFields({
|
|
179
|
+
parent: input.parentId,
|
|
180
|
+
pageToken: input.cursor ? fromBase64(input.cursor) : undefined,
|
|
181
|
+
pageSize: input.limit,
|
|
182
|
+
readMask: {
|
|
183
|
+
paths,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
dynamicFields: response.response.dynamicFields.map(
|
|
189
|
+
(field): DynamicFieldEntryWithValue<Include> => {
|
|
190
|
+
const isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;
|
|
191
|
+
const fieldType = isDynamicObject
|
|
192
|
+
? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${field.name?.name!}>,0x2::object::ID>`
|
|
193
|
+
: `0x2::dynamic_field::Field<${field.name?.name!},${field.valueType!}>`;
|
|
194
|
+
return {
|
|
195
|
+
$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
|
|
196
|
+
fieldId: field.fieldId!,
|
|
197
|
+
name: {
|
|
198
|
+
type: field.name?.name!,
|
|
199
|
+
bcs: field.name?.value!,
|
|
200
|
+
},
|
|
201
|
+
valueType: field.valueType!,
|
|
202
|
+
type: normalizeStructTag(fieldType),
|
|
203
|
+
childId: field.childId,
|
|
204
|
+
value: (includeValue
|
|
205
|
+
? { type: field.valueType!, bcs: field.value?.value ?? new Uint8Array() }
|
|
206
|
+
: undefined) as DynamicFieldEntryWithValue<Include>['value'],
|
|
207
|
+
} as DynamicFieldEntryWithValue<Include>;
|
|
208
|
+
},
|
|
209
|
+
),
|
|
210
|
+
cursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,
|
|
211
|
+
hasNextPage: response.response.nextPageToken !== undefined,
|
|
212
|
+
};
|
|
155
213
|
}
|
|
156
214
|
|
|
157
215
|
getDynamicField(
|
package/src/grpc/core.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { CoreClient, formatMoveAbortMessage, SimulationError } from '../client/i
|
|
|
6
6
|
import type { SuiGrpcClient } from './client.js';
|
|
7
7
|
import type { Owner } from './proto/sui/rpc/v2/owner.js';
|
|
8
8
|
import { Owner_OwnerKind } from './proto/sui/rpc/v2/owner.js';
|
|
9
|
-
import { DynamicField_DynamicFieldKind } from './proto/sui/rpc/v2/state_service.js';
|
|
10
9
|
import { chunk, fromBase64, toBase64 } from '@mysten/utils';
|
|
11
10
|
import type { ExecutedTransaction } from './proto/sui/rpc/v2/executed_transaction.js';
|
|
12
11
|
import type { TransactionEffects } from './proto/sui/rpc/v2/effects.js';
|
|
@@ -56,7 +55,7 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
56
55
|
this.#client = client;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
async getObjects<Include extends SuiClientTypes.ObjectInclude =
|
|
58
|
+
async getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
|
|
60
59
|
options: SuiClientTypes.GetObjectsOptions<Include>,
|
|
61
60
|
): Promise<SuiClientTypes.GetObjectsResponse<Include>> {
|
|
62
61
|
const batches = chunk(options.objectIds, 50);
|
|
@@ -75,6 +74,9 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
75
74
|
if (options.include?.json) {
|
|
76
75
|
paths.push('json');
|
|
77
76
|
}
|
|
77
|
+
if (options.include?.display) {
|
|
78
|
+
paths.push('display');
|
|
79
|
+
}
|
|
78
80
|
|
|
79
81
|
for (const batch of batches) {
|
|
80
82
|
const response = await this.#client.ledgerService.batchGetObjects({
|
|
@@ -111,6 +113,11 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
111
113
|
: null
|
|
112
114
|
: undefined;
|
|
113
115
|
|
|
116
|
+
const displayData = mapDisplayProto(
|
|
117
|
+
options.include?.display,
|
|
118
|
+
object.result.object.display,
|
|
119
|
+
);
|
|
120
|
+
|
|
114
121
|
return {
|
|
115
122
|
objectId: object.result.object.objectId!,
|
|
116
123
|
version: object.result.object.version?.toString()!,
|
|
@@ -122,6 +129,7 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
122
129
|
undefined) as SuiClientTypes.Object<Include>['previousTransaction'],
|
|
123
130
|
objectBcs: objectBcs as SuiClientTypes.Object<Include>['objectBcs'],
|
|
124
131
|
json: jsonContent as SuiClientTypes.Object<Include>['json'],
|
|
132
|
+
display: displayData as SuiClientTypes.Object<Include>['display'],
|
|
125
133
|
};
|
|
126
134
|
}),
|
|
127
135
|
);
|
|
@@ -131,7 +139,7 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
131
139
|
objects: results,
|
|
132
140
|
};
|
|
133
141
|
}
|
|
134
|
-
async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude =
|
|
142
|
+
async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
|
|
135
143
|
options: SuiClientTypes.ListOwnedObjectsOptions<Include>,
|
|
136
144
|
): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>> {
|
|
137
145
|
const paths = ['owner', 'object_type', 'digest', 'version', 'object_id'];
|
|
@@ -147,6 +155,9 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
147
155
|
if (options.include?.json) {
|
|
148
156
|
paths.push('json');
|
|
149
157
|
}
|
|
158
|
+
if (options.include?.display) {
|
|
159
|
+
paths.push('display');
|
|
160
|
+
}
|
|
150
161
|
|
|
151
162
|
const response = await this.#client.stateService.listOwnedObjects({
|
|
152
163
|
owner: options.owner,
|
|
@@ -176,6 +187,10 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
176
187
|
? (Value.toJson(object.json) as Record<string, unknown>)
|
|
177
188
|
: null
|
|
178
189
|
: undefined) as SuiClientTypes.Object<Include>['json'],
|
|
190
|
+
display: mapDisplayProto(
|
|
191
|
+
options.include?.display,
|
|
192
|
+
object.display,
|
|
193
|
+
) as SuiClientTypes.Object<Include>['display'],
|
|
179
194
|
}),
|
|
180
195
|
);
|
|
181
196
|
|
|
@@ -285,7 +300,7 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
285
300
|
})),
|
|
286
301
|
};
|
|
287
302
|
}
|
|
288
|
-
async getTransaction<Include extends SuiClientTypes.TransactionInclude =
|
|
303
|
+
async getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
289
304
|
options: SuiClientTypes.GetTransactionOptions<Include>,
|
|
290
305
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
291
306
|
const paths = ['digest', 'transaction.digest', 'signatures', 'effects.status'];
|
|
@@ -327,7 +342,7 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
327
342
|
|
|
328
343
|
return parseTransaction(response.transaction, options.include);
|
|
329
344
|
}
|
|
330
|
-
async executeTransaction<Include extends SuiClientTypes.TransactionInclude =
|
|
345
|
+
async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
331
346
|
options: SuiClientTypes.ExecuteTransactionOptions<Include>,
|
|
332
347
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
333
348
|
const paths = ['digest', 'transaction.digest', 'signatures', 'effects.status'];
|
|
@@ -377,7 +392,7 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
377
392
|
|
|
378
393
|
return parseTransaction(response.transaction!, options.include);
|
|
379
394
|
}
|
|
380
|
-
async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude =
|
|
395
|
+
async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
|
|
381
396
|
options: SuiClientTypes.SimulateTransactionOptions<Include>,
|
|
382
397
|
): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
|
|
383
398
|
const paths = [
|
|
@@ -561,38 +576,7 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
561
576
|
async listDynamicFields(
|
|
562
577
|
options: SuiClientTypes.ListDynamicFieldsOptions,
|
|
563
578
|
): Promise<SuiClientTypes.ListDynamicFieldsResponse> {
|
|
564
|
-
|
|
565
|
-
parent: options.parentId,
|
|
566
|
-
pageToken: options.cursor ? fromBase64(options.cursor) : undefined,
|
|
567
|
-
pageSize: options.limit,
|
|
568
|
-
readMask: {
|
|
569
|
-
paths: ['field_id', 'name', 'value_type', 'kind', 'child_id'],
|
|
570
|
-
},
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
return {
|
|
574
|
-
dynamicFields: response.response.dynamicFields.map(
|
|
575
|
-
(field): SuiClientTypes.DynamicFieldEntry => {
|
|
576
|
-
const isDynamicObject = field.kind === DynamicField_DynamicFieldKind.OBJECT;
|
|
577
|
-
const fieldType = isDynamicObject
|
|
578
|
-
? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${field.name?.name!}>,0x2::object::ID>`
|
|
579
|
-
: `0x2::dynamic_field::Field<${field.name?.name!},${field.valueType!}>`;
|
|
580
|
-
return {
|
|
581
|
-
$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
|
|
582
|
-
fieldId: field.fieldId!,
|
|
583
|
-
name: {
|
|
584
|
-
type: field.name?.name!,
|
|
585
|
-
bcs: field.name?.value!,
|
|
586
|
-
},
|
|
587
|
-
valueType: field.valueType!,
|
|
588
|
-
type: normalizeStructTag(fieldType),
|
|
589
|
-
childId: field.childId,
|
|
590
|
-
} as SuiClientTypes.DynamicFieldEntry;
|
|
591
|
-
},
|
|
592
|
-
),
|
|
593
|
-
cursor: response.response.nextPageToken ? toBase64(response.response.nextPageToken) : null,
|
|
594
|
-
hasNextPage: response.response.nextPageToken !== undefined,
|
|
595
|
-
};
|
|
579
|
+
return this.#client.listDynamicFields(options);
|
|
596
580
|
}
|
|
597
581
|
|
|
598
582
|
async verifyZkLoginSignature(
|
|
@@ -784,6 +768,24 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
784
768
|
}
|
|
785
769
|
}
|
|
786
770
|
|
|
771
|
+
function mapDisplayProto(
|
|
772
|
+
include: boolean | undefined,
|
|
773
|
+
display: { output?: Value; errors?: Value } | undefined,
|
|
774
|
+
): SuiClientTypes.Display | null | undefined {
|
|
775
|
+
if (!include) return undefined;
|
|
776
|
+
if (display === undefined) return null;
|
|
777
|
+
return {
|
|
778
|
+
output:
|
|
779
|
+
display.output !== undefined
|
|
780
|
+
? (Value.toJson(display.output) as Record<string, string> | null)
|
|
781
|
+
: null,
|
|
782
|
+
errors:
|
|
783
|
+
display.errors !== undefined
|
|
784
|
+
? (Value.toJson(display.errors) as Record<string, string> | null)
|
|
785
|
+
: null,
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
|
|
787
789
|
function mapOwner(owner: Owner | null | undefined): SuiClientTypes.ObjectOwner | null {
|
|
788
790
|
if (!owner) {
|
|
789
791
|
return null;
|
|
@@ -1170,7 +1172,7 @@ export function parseTransactionEffects({
|
|
|
1170
1172
|
};
|
|
1171
1173
|
}
|
|
1172
1174
|
|
|
1173
|
-
function parseTransaction<Include extends SuiClientTypes.TransactionInclude =
|
|
1175
|
+
function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
1174
1176
|
transaction: ExecutedTransaction,
|
|
1175
1177
|
include?: Include,
|
|
1176
1178
|
): SuiClientTypes.TransactionResult<Include> {
|
|
@@ -1248,6 +1250,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
|
|
|
1248
1250
|
sender: normalizeSuiAddress(event.sender!),
|
|
1249
1251
|
eventType: event.eventType!,
|
|
1250
1252
|
bcs: event.contents?.value ?? new Uint8Array(),
|
|
1253
|
+
json: event.json ? (Value.toJson(event.json) as Record<string, unknown>) : null,
|
|
1251
1254
|
})) ?? [])
|
|
1252
1255
|
: undefined) as SuiClientTypes.Transaction<Include>['events'],
|
|
1253
1256
|
};
|
|
@@ -107,6 +107,13 @@ export interface Object {
|
|
|
107
107
|
* @generated from protobuf field: optional uint64 balance = 101;
|
|
108
108
|
*/
|
|
109
109
|
balance?: bigint;
|
|
110
|
+
/**
|
|
111
|
+
* JSON rendering of the object based on an on-chain template.
|
|
112
|
+
* This will not be set if the value's type does not have an associated `Display` template.
|
|
113
|
+
*
|
|
114
|
+
* @generated from protobuf field: optional sui.rpc.v2.Display display = 102;
|
|
115
|
+
*/
|
|
116
|
+
display?: Display;
|
|
110
117
|
}
|
|
111
118
|
/**
|
|
112
119
|
* Set of Objects
|
|
@@ -121,6 +128,29 @@ export interface ObjectSet {
|
|
|
121
128
|
*/
|
|
122
129
|
objects: Object[];
|
|
123
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* A rendered JSON blob based on an on-chain template.
|
|
133
|
+
*
|
|
134
|
+
* @generated from protobuf message sui.rpc.v2.Display
|
|
135
|
+
*/
|
|
136
|
+
export interface Display {
|
|
137
|
+
/**
|
|
138
|
+
* Output for all successfully substituted display fields. Unsuccessful
|
|
139
|
+
* fields will be `null`, and will be accompanied by a field in `errors`,
|
|
140
|
+
* explaining the error.
|
|
141
|
+
*
|
|
142
|
+
* @generated from protobuf field: optional google.protobuf.Value output = 1;
|
|
143
|
+
*/
|
|
144
|
+
output?: Value;
|
|
145
|
+
/**
|
|
146
|
+
* If any fields failed to render, this will contain a mapping from failed
|
|
147
|
+
* field names to error messages. If all fields succeed, this will either be
|
|
148
|
+
* `null` or not set.
|
|
149
|
+
*
|
|
150
|
+
* @generated from protobuf field: optional google.protobuf.Value errors = 2;
|
|
151
|
+
*/
|
|
152
|
+
errors?: Value;
|
|
153
|
+
}
|
|
124
154
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
125
155
|
class Object$Type extends MessageType<Object> {
|
|
126
156
|
constructor() {
|
|
@@ -165,6 +195,7 @@ class Object$Type extends MessageType<Object> {
|
|
|
165
195
|
T: 4 /*ScalarType.UINT64*/,
|
|
166
196
|
L: 0 /*LongType.BIGINT*/,
|
|
167
197
|
},
|
|
198
|
+
{ no: 102, name: 'display', kind: 'message', T: () => Display },
|
|
168
199
|
]);
|
|
169
200
|
}
|
|
170
201
|
}
|
|
@@ -184,3 +215,16 @@ class ObjectSet$Type extends MessageType<ObjectSet> {
|
|
|
184
215
|
* @generated MessageType for protobuf message sui.rpc.v2.ObjectSet
|
|
185
216
|
*/
|
|
186
217
|
export const ObjectSet = new ObjectSet$Type();
|
|
218
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
219
|
+
class Display$Type extends MessageType<Display> {
|
|
220
|
+
constructor() {
|
|
221
|
+
super('sui.rpc.v2.Display', [
|
|
222
|
+
{ no: 1, name: 'output', kind: 'message', T: () => Value },
|
|
223
|
+
{ no: 2, name: 'errors', kind: 'message', T: () => Value },
|
|
224
|
+
]);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* @generated MessageType for protobuf message sui.rpc.v2.Display
|
|
229
|
+
*/
|
|
230
|
+
export const Display = new Display$Type();
|
|
@@ -111,6 +111,14 @@ export interface SimulateTransactionResponse {
|
|
|
111
111
|
* @generated from protobuf field: repeated sui.rpc.v2.CommandResult command_outputs = 2;
|
|
112
112
|
*/
|
|
113
113
|
commandOutputs: CommandResult[];
|
|
114
|
+
/**
|
|
115
|
+
* A suggested gas price to use, that is above RGP, in order to provide a
|
|
116
|
+
* better chance of the transaction being included in the presence of
|
|
117
|
+
* congested objects.
|
|
118
|
+
*
|
|
119
|
+
* @generated from protobuf field: optional uint64 suggested_gas_price = 3;
|
|
120
|
+
*/
|
|
121
|
+
suggestedGasPrice?: bigint;
|
|
114
122
|
}
|
|
115
123
|
/**
|
|
116
124
|
* An intermediate result/output from the execution of a single command
|
|
@@ -214,6 +222,14 @@ class SimulateTransactionResponse$Type extends MessageType<SimulateTransactionRe
|
|
|
214
222
|
repeat: 1 /*RepeatType.PACKED*/,
|
|
215
223
|
T: () => CommandResult,
|
|
216
224
|
},
|
|
225
|
+
{
|
|
226
|
+
no: 3,
|
|
227
|
+
name: 'suggested_gas_price',
|
|
228
|
+
kind: 'scalar',
|
|
229
|
+
opt: true,
|
|
230
|
+
T: 4 /*ScalarType.UINT64*/,
|
|
231
|
+
L: 0 /*LongType.BIGINT*/,
|
|
232
|
+
},
|
|
217
233
|
]);
|
|
218
234
|
}
|
|
219
235
|
}
|
package/src/jsonRpc/core.ts
CHANGED
|
@@ -115,7 +115,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
115
115
|
this.#jsonRpcClient = jsonRpcClient;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
async getObjects<Include extends SuiClientTypes.ObjectInclude =
|
|
118
|
+
async getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
|
|
119
119
|
options: SuiClientTypes.GetObjectsOptions<Include>,
|
|
120
120
|
) {
|
|
121
121
|
const batches = chunk(options.objectIds, 50);
|
|
@@ -131,6 +131,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
131
131
|
options.include?.previousTransaction || options.include?.objectBcs ? true : false,
|
|
132
132
|
showStorageRebate: options.include?.objectBcs ?? false,
|
|
133
133
|
showContent: options.include?.json ?? false,
|
|
134
|
+
showDisplay: options.include?.display ?? false,
|
|
134
135
|
},
|
|
135
136
|
signal: options.signal,
|
|
136
137
|
});
|
|
@@ -148,7 +149,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
148
149
|
objects: results,
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
|
-
async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude =
|
|
152
|
+
async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
|
|
152
153
|
options: SuiClientTypes.ListOwnedObjectsOptions<Include>,
|
|
153
154
|
) {
|
|
154
155
|
let filter: SuiObjectDataFilter | null = null;
|
|
@@ -175,6 +176,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
175
176
|
options.include?.previousTransaction || options.include?.objectBcs ? true : false,
|
|
176
177
|
showStorageRebate: options.include?.objectBcs ?? false,
|
|
177
178
|
showContent: options.include?.json ?? false,
|
|
179
|
+
showDisplay: options.include?.display ?? false,
|
|
178
180
|
},
|
|
179
181
|
filter,
|
|
180
182
|
signal: options.signal,
|
|
@@ -287,7 +289,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
287
289
|
cursor: null,
|
|
288
290
|
};
|
|
289
291
|
}
|
|
290
|
-
async getTransaction<Include extends SuiClientTypes.TransactionInclude =
|
|
292
|
+
async getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
291
293
|
options: SuiClientTypes.GetTransactionOptions<Include>,
|
|
292
294
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
293
295
|
const transaction = await this.#jsonRpcClient.getTransactionBlock({
|
|
@@ -307,7 +309,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
307
309
|
|
|
308
310
|
return parseTransaction(transaction, options.include);
|
|
309
311
|
}
|
|
310
|
-
async executeTransaction<Include extends SuiClientTypes.TransactionInclude =
|
|
312
|
+
async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
311
313
|
options: SuiClientTypes.ExecuteTransactionOptions<Include>,
|
|
312
314
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
313
315
|
const transaction = await this.#jsonRpcClient.executeTransactionBlock({
|
|
@@ -328,7 +330,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
328
330
|
|
|
329
331
|
return parseTransaction(transaction, options.include);
|
|
330
332
|
}
|
|
331
|
-
async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude =
|
|
333
|
+
async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
|
|
332
334
|
options: SuiClientTypes.SimulateTransactionOptions<Include>,
|
|
333
335
|
): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
|
|
334
336
|
if (!(options.transaction instanceof Uint8Array)) {
|
|
@@ -403,6 +405,7 @@ export class JSONRpcCoreClient extends CoreClient {
|
|
|
403
405
|
sender: event.sender,
|
|
404
406
|
eventType: event.type,
|
|
405
407
|
bcs: 'bcs' in event ? fromBase64(event.bcs) : new Uint8Array(),
|
|
408
|
+
json: (event.parsedJson as Record<string, unknown>) ?? null,
|
|
406
409
|
})) ?? [])
|
|
407
410
|
: undefined) as SuiClientTypes.Transaction<Include>['events'],
|
|
408
411
|
};
|
|
@@ -664,7 +667,7 @@ function serializeObjectToBcs(object: SuiObjectData): Uint8Array | undefined {
|
|
|
664
667
|
}
|
|
665
668
|
}
|
|
666
669
|
|
|
667
|
-
function parseObject<Include extends SuiClientTypes.ObjectInclude =
|
|
670
|
+
function parseObject<Include extends SuiClientTypes.ObjectInclude = {}>(
|
|
668
671
|
object: SuiObjectData,
|
|
669
672
|
include?: Include,
|
|
670
673
|
): SuiClientTypes.Object<Include> {
|
|
@@ -686,6 +689,12 @@ function parseObject<Include extends SuiClientTypes.ObjectInclude = object>(
|
|
|
686
689
|
? null
|
|
687
690
|
: undefined;
|
|
688
691
|
|
|
692
|
+
const displayData = include?.display
|
|
693
|
+
? object.display?.data != null
|
|
694
|
+
? { output: object.display.data as Record<string, string>, errors: null }
|
|
695
|
+
: null
|
|
696
|
+
: undefined;
|
|
697
|
+
|
|
689
698
|
return {
|
|
690
699
|
objectId: object.objectId,
|
|
691
700
|
version: object.version,
|
|
@@ -700,6 +709,7 @@ function parseObject<Include extends SuiClientTypes.ObjectInclude = object>(
|
|
|
700
709
|
: undefined) as SuiClientTypes.Object<Include>['previousTransaction'],
|
|
701
710
|
objectBcs: objectBcs as SuiClientTypes.Object<Include>['objectBcs'],
|
|
702
711
|
json: jsonContent as SuiClientTypes.Object<Include>['json'],
|
|
712
|
+
display: displayData as SuiClientTypes.Object<Include>['display'],
|
|
703
713
|
};
|
|
704
714
|
}
|
|
705
715
|
|
|
@@ -802,7 +812,7 @@ function parseOwnerAddress(owner: ObjectOwner): string | null {
|
|
|
802
812
|
throw new Error(`Unknown owner type: ${JSON.stringify(owner)}`);
|
|
803
813
|
}
|
|
804
814
|
|
|
805
|
-
function parseTransaction<Include extends SuiClientTypes.TransactionInclude =
|
|
815
|
+
function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
806
816
|
transaction: SuiTransactionBlockResponse,
|
|
807
817
|
include?: Include,
|
|
808
818
|
): SuiClientTypes.TransactionResult<Include> {
|
|
@@ -886,6 +896,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
|
|
|
886
896
|
sender: event.sender,
|
|
887
897
|
eventType: event.type,
|
|
888
898
|
bcs: 'bcs' in event ? fromBase64(event.bcs) : new Uint8Array(),
|
|
899
|
+
json: (event.parsedJson as Record<string, unknown>) ?? null,
|
|
889
900
|
})) ?? [])
|
|
890
901
|
: undefined) as SuiClientTypes.Transaction<Include>['events'],
|
|
891
902
|
};
|
|
@@ -15,7 +15,7 @@ import { isTransaction } from '../Transaction.js';
|
|
|
15
15
|
export interface ExecuteTransactionOptions<Include extends SuiClientTypes.TransactionInclude = {}> {
|
|
16
16
|
transaction: Transaction | Uint8Array;
|
|
17
17
|
signatures: string[];
|
|
18
|
-
include?: Include;
|
|
18
|
+
include?: Include & SuiClientTypes.TransactionInclude;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export class CachingTransactionExecutor {
|
|
@@ -93,7 +93,7 @@ export class CachingTransactionExecutor {
|
|
|
93
93
|
}: {
|
|
94
94
|
transaction: Transaction;
|
|
95
95
|
signer: Signer;
|
|
96
|
-
include?: Include;
|
|
96
|
+
include?: Include & SuiClientTypes.TransactionInclude;
|
|
97
97
|
}): Promise<SuiClientTypes.TransactionResult<Include & { effects: true }>> {
|
|
98
98
|
transaction.setSenderIfNotSet(signer.toSuiAddress());
|
|
99
99
|
const bytes = await this.buildTransaction({ transaction });
|
|
@@ -128,7 +128,7 @@ export class ParallelTransactionExecutor {
|
|
|
128
128
|
|
|
129
129
|
async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
130
130
|
transaction: Transaction,
|
|
131
|
-
include?: Include,
|
|
131
|
+
include?: Include & SuiClientTypes.TransactionInclude,
|
|
132
132
|
additionalSignatures: string[] = [],
|
|
133
133
|
): Promise<SuiClientTypes.TransactionResult<Include & { effects: true }>> {
|
|
134
134
|
const { promise, resolve, reject } =
|
|
@@ -164,7 +164,7 @@ export class SerialTransactionExecutor {
|
|
|
164
164
|
|
|
165
165
|
executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
166
166
|
transaction: Transaction | Uint8Array,
|
|
167
|
-
include?: Include,
|
|
167
|
+
include?: Include & SuiClientTypes.TransactionInclude,
|
|
168
168
|
additionalSignatures: string[] = [],
|
|
169
169
|
): Promise<SuiClientTypes.TransactionResult<Include & { effects: true }>> {
|
|
170
170
|
return this.#queue.runTask(async () => {
|
package/src/version.ts
CHANGED