@mysten/sui 2.5.0 → 2.6.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 +27 -0
- package/dist/bcs/index.d.mts +20 -20
- 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 +56 -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 +7 -41
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +7 -4
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +0 -22
- 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 +3 -33
- 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/signature_verification_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.client.d.mts +4 -4
- package/dist/jsonRpc/core.d.mts +6 -6
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +4 -2
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/keypairs/ed25519/keypair.d.mts +3 -1
- package/dist/keypairs/ed25519/keypair.d.mts.map +1 -1
- package/dist/keypairs/ed25519/keypair.mjs +5 -1
- package/dist/keypairs/ed25519/keypair.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +3 -3
- 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 +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 +2 -2
- package/dist/version.mjs.map +1 -1
- 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 +57 -18
- package/src/graphql/client.ts +96 -4
- package/src/graphql/core.ts +9 -75
- package/src/graphql/generated/queries.ts +19 -30
- package/src/graphql/generated/schema.graphql +4 -17
- package/src/graphql/generated/tada-env.ts +0 -24
- package/src/graphql/queries/getDynamicFields.graphql +8 -1
- package/src/graphql/queries/transactions.graphql +1 -3
- package/src/grpc/client.ts +62 -4
- package/src/grpc/core.ts +8 -39
- package/src/jsonRpc/core.ts +9 -7
- package/src/keypairs/ed25519/keypair.ts +5 -1
- package/src/transactions/executor/caching.ts +2 -2
- package/src/transactions/executor/parallel.ts +1 -2
- package/src/transactions/executor/serial.ts +1 -1
- package/src/version.ts +2 -2
package/src/graphql/core.ts
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
GetCoinMetadataDocument,
|
|
24
24
|
GetCoinsDocument,
|
|
25
25
|
GetCurrentSystemStateDocument,
|
|
26
|
-
GetDynamicFieldsDocument,
|
|
27
26
|
GetMoveFunctionDocument,
|
|
28
27
|
GetOwnedObjectsDocument,
|
|
29
28
|
GetReferenceGasPriceDocument,
|
|
@@ -36,8 +35,7 @@ import {
|
|
|
36
35
|
} from './generated/queries.js';
|
|
37
36
|
import { ObjectError, SimulationError } from '../client/errors.js';
|
|
38
37
|
import { chunk, fromBase64, toBase64 } from '@mysten/utils';
|
|
39
|
-
import {
|
|
40
|
-
import { deriveDynamicFieldID } from '../utils/dynamic-fields.js';
|
|
38
|
+
import { normalizeSuiAddress } from '../utils/sui-types.js';
|
|
41
39
|
import { formatMoveAbortMessage, parseTransactionEffectsBcs } from '../client/utils.js';
|
|
42
40
|
import type { OpenMoveTypeSignatureBody, OpenMoveTypeSignature } from './types.js';
|
|
43
41
|
import {
|
|
@@ -86,7 +84,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
86
84
|
return extractedData as NonNullable<Data>;
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
async getObjects<Include extends SuiClientTypes.ObjectInclude =
|
|
87
|
+
async getObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
|
|
90
88
|
options: SuiClientTypes.GetObjectsOptions<Include>,
|
|
91
89
|
): Promise<SuiClientTypes.GetObjectsResponse<Include>> {
|
|
92
90
|
const batches = chunk(options.objectIds, 50);
|
|
@@ -161,7 +159,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
161
159
|
objects: results,
|
|
162
160
|
};
|
|
163
161
|
}
|
|
164
|
-
async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude =
|
|
162
|
+
async listOwnedObjects<Include extends SuiClientTypes.ObjectInclude = {}>(
|
|
165
163
|
options: SuiClientTypes.ListOwnedObjectsOptions<Include>,
|
|
166
164
|
): Promise<SuiClientTypes.ListOwnedObjectsResponse<Include>> {
|
|
167
165
|
const objects = await this.#graphqlQuery(
|
|
@@ -326,7 +324,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
326
324
|
}),
|
|
327
325
|
};
|
|
328
326
|
}
|
|
329
|
-
async getTransaction<Include extends SuiClientTypes.TransactionInclude =
|
|
327
|
+
async getTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
330
328
|
options: SuiClientTypes.GetTransactionOptions<Include>,
|
|
331
329
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
332
330
|
const result = await this.#graphqlQuery(
|
|
@@ -347,7 +345,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
347
345
|
|
|
348
346
|
return parseTransaction(result, options.include);
|
|
349
347
|
}
|
|
350
|
-
async executeTransaction<Include extends SuiClientTypes.TransactionInclude =
|
|
348
|
+
async executeTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
351
349
|
options: SuiClientTypes.ExecuteTransactionOptions<Include>,
|
|
352
350
|
): Promise<SuiClientTypes.TransactionResult<Include>> {
|
|
353
351
|
const result = await this.#graphqlQuery(
|
|
@@ -367,16 +365,9 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
367
365
|
(result) => result.executeTransaction,
|
|
368
366
|
);
|
|
369
367
|
|
|
370
|
-
if (result.errors) {
|
|
371
|
-
if (result.errors.length === 1) {
|
|
372
|
-
throw new Error(result.errors[0]);
|
|
373
|
-
}
|
|
374
|
-
throw new AggregateError(result.errors.map((error) => new Error(error)));
|
|
375
|
-
}
|
|
376
|
-
|
|
377
368
|
return parseTransaction(result.effects?.transaction!, options.include);
|
|
378
369
|
}
|
|
379
|
-
async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude =
|
|
370
|
+
async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
|
|
380
371
|
options: SuiClientTypes.SimulateTransactionOptions<Include>,
|
|
381
372
|
): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
|
|
382
373
|
if (!(options.transaction instanceof Uint8Array)) {
|
|
@@ -407,10 +398,6 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
407
398
|
(result) => result.simulateTransaction,
|
|
408
399
|
);
|
|
409
400
|
|
|
410
|
-
if (result.error && !result.effects?.transaction) {
|
|
411
|
-
throw new SimulationError(result.error);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
401
|
const transactionResult = parseTransaction(result.effects?.transaction!, options.include);
|
|
415
402
|
|
|
416
403
|
const commandResults =
|
|
@@ -558,55 +545,7 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
558
545
|
async listDynamicFields(
|
|
559
546
|
options: SuiClientTypes.ListDynamicFieldsOptions,
|
|
560
547
|
): Promise<SuiClientTypes.ListDynamicFieldsResponse> {
|
|
561
|
-
|
|
562
|
-
{
|
|
563
|
-
query: GetDynamicFieldsDocument,
|
|
564
|
-
variables: {
|
|
565
|
-
parentId: options.parentId,
|
|
566
|
-
first: options.limit,
|
|
567
|
-
cursor: options.cursor,
|
|
568
|
-
},
|
|
569
|
-
},
|
|
570
|
-
(result) => result.address?.dynamicFields,
|
|
571
|
-
);
|
|
572
|
-
|
|
573
|
-
return {
|
|
574
|
-
dynamicFields: result.nodes.map((dynamicField): SuiClientTypes.DynamicFieldEntry => {
|
|
575
|
-
const valueType =
|
|
576
|
-
dynamicField.value?.__typename === 'MoveObject'
|
|
577
|
-
? dynamicField.value.contents?.type?.repr!
|
|
578
|
-
: dynamicField.value?.type?.repr!;
|
|
579
|
-
const isDynamicObject = dynamicField.value?.__typename === 'MoveObject';
|
|
580
|
-
const derivedNameType = isDynamicObject
|
|
581
|
-
? `0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>`
|
|
582
|
-
: dynamicField.name?.type?.repr!;
|
|
583
|
-
|
|
584
|
-
return {
|
|
585
|
-
$kind: isDynamicObject ? 'DynamicObject' : 'DynamicField',
|
|
586
|
-
fieldId: deriveDynamicFieldID(
|
|
587
|
-
options.parentId,
|
|
588
|
-
derivedNameType,
|
|
589
|
-
fromBase64(dynamicField.name?.bcs!),
|
|
590
|
-
),
|
|
591
|
-
type: normalizeStructTag(
|
|
592
|
-
isDynamicObject
|
|
593
|
-
? `0x2::dynamic_field::Field<0x2::dynamic_object_field::Wrapper<${dynamicField.name?.type?.repr}>,0x2::object::ID>`
|
|
594
|
-
: `0x2::dynamic_field::Field<${dynamicField.name?.type?.repr},${valueType}>`,
|
|
595
|
-
),
|
|
596
|
-
name: {
|
|
597
|
-
type: dynamicField.name?.type?.repr!,
|
|
598
|
-
bcs: fromBase64(dynamicField.name?.bcs!),
|
|
599
|
-
},
|
|
600
|
-
valueType,
|
|
601
|
-
childId:
|
|
602
|
-
isDynamicObject && dynamicField.value?.__typename === 'MoveObject'
|
|
603
|
-
? dynamicField.value.address
|
|
604
|
-
: undefined,
|
|
605
|
-
} as SuiClientTypes.DynamicFieldEntry;
|
|
606
|
-
}),
|
|
607
|
-
cursor: result.pageInfo.endCursor ?? null,
|
|
608
|
-
hasNextPage: result.pageInfo.hasNextPage,
|
|
609
|
-
};
|
|
548
|
+
return this.#graphqlClient.listDynamicFields(options);
|
|
610
549
|
}
|
|
611
550
|
|
|
612
551
|
async verifyZkLoginSignature(
|
|
@@ -765,12 +704,6 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
765
704
|
|
|
766
705
|
handleGraphQLErrors(errors);
|
|
767
706
|
|
|
768
|
-
if (data?.simulateTransaction?.error) {
|
|
769
|
-
throw new SimulationError(
|
|
770
|
-
`Transaction resolution failed: ${data.simulateTransaction.error}`,
|
|
771
|
-
);
|
|
772
|
-
}
|
|
773
|
-
|
|
774
707
|
const transactionEffects = data?.simulateTransaction?.effects?.transaction?.effects;
|
|
775
708
|
if (!options.onlyTransactionKind && transactionEffects?.status === ExecutionStatus.Failure) {
|
|
776
709
|
const executionError = parseGraphQLExecutionError(transactionEffects.executionError);
|
|
@@ -860,7 +793,7 @@ function mapOwner(owner: Object_Owner_FieldsFragment): SuiClientTypes.ObjectOwne
|
|
|
860
793
|
}
|
|
861
794
|
}
|
|
862
795
|
|
|
863
|
-
function parseTransaction<Include extends SuiClientTypes.TransactionInclude =
|
|
796
|
+
function parseTransaction<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
864
797
|
transaction: Transaction_FieldsFragment,
|
|
865
798
|
include?: Include,
|
|
866
799
|
): SuiClientTypes.TransactionResult<Include> {
|
|
@@ -961,6 +894,7 @@ function parseTransaction<Include extends SuiClientTypes.TransactionInclude = ob
|
|
|
961
894
|
sender: event.sender?.address!,
|
|
962
895
|
eventType,
|
|
963
896
|
bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
|
|
897
|
+
json: (event.contents?.json as Record<string, unknown>) ?? null,
|
|
964
898
|
};
|
|
965
899
|
}) ?? [])
|
|
966
900
|
: undefined) as SuiClientTypes.Transaction<Include>['events'],
|
|
@@ -1597,16 +1597,11 @@ export type ExecutionError = {
|
|
|
1597
1597
|
sourceLineNumber?: Maybe<Scalars['Int']['output']>;
|
|
1598
1598
|
};
|
|
1599
1599
|
|
|
1600
|
-
/** The execution result of a transaction, including the transaction effects
|
|
1600
|
+
/** The execution result of a transaction, including the transaction effects. */
|
|
1601
1601
|
export type ExecutionResult = {
|
|
1602
1602
|
__typename?: 'ExecutionResult';
|
|
1603
|
-
/** The effects of the transaction execution
|
|
1603
|
+
/** The effects of the transaction execution. */
|
|
1604
1604
|
effects?: Maybe<TransactionEffects>;
|
|
1605
|
-
/**
|
|
1606
|
-
* Errors that occurred during execution (e.g., network errors, validation failures).
|
|
1607
|
-
* These are distinct from execution failures within the transaction itself.
|
|
1608
|
-
*/
|
|
1609
|
-
errors?: Maybe<Array<Scalars['String']['output']>>;
|
|
1610
1605
|
};
|
|
1611
1606
|
|
|
1612
1607
|
/** The execution status of this transaction: success or failure. */
|
|
@@ -4157,21 +4152,11 @@ export type SharedInput = {
|
|
|
4157
4152
|
mutable?: Maybe<Scalars['Boolean']['output']>;
|
|
4158
4153
|
};
|
|
4159
4154
|
|
|
4160
|
-
/** The result of simulating a transaction, including the predicted effects
|
|
4155
|
+
/** The result of simulating a transaction, including the predicted effects. */
|
|
4161
4156
|
export type SimulationResult = {
|
|
4162
4157
|
__typename?: 'SimulationResult';
|
|
4163
|
-
/**
|
|
4164
|
-
* The predicted effects of the transaction if it were executed.
|
|
4165
|
-
*
|
|
4166
|
-
* `None` if the simulation failed due to an error.
|
|
4167
|
-
*/
|
|
4158
|
+
/** The predicted effects of the transaction if it were executed. */
|
|
4168
4159
|
effects?: Maybe<TransactionEffects>;
|
|
4169
|
-
/**
|
|
4170
|
-
* Error message if the simulation failed.
|
|
4171
|
-
*
|
|
4172
|
-
* `None` if the simulation was successful.
|
|
4173
|
-
*/
|
|
4174
|
-
error?: Maybe<Scalars['String']['output']>;
|
|
4175
4160
|
/** The intermediate outputs for each command of the transaction simulation, including contents of mutated references and return values. */
|
|
4176
4161
|
outputs?: Maybe<Array<CommandResult>>;
|
|
4177
4162
|
};
|
|
@@ -4644,12 +4629,13 @@ export type GetDynamicFieldsQueryVariables = Exact<{
|
|
|
4644
4629
|
parentId: Scalars['SuiAddress']['input'];
|
|
4645
4630
|
first?: InputMaybe<Scalars['Int']['input']>;
|
|
4646
4631
|
cursor?: InputMaybe<Scalars['String']['input']>;
|
|
4632
|
+
includeValue?: InputMaybe<Scalars['Boolean']['input']>;
|
|
4647
4633
|
}>;
|
|
4648
4634
|
|
|
4649
4635
|
|
|
4650
4636
|
export type GetDynamicFieldsQuery = { __typename?: 'Query', address?: { __typename?: 'Address', dynamicFields?: { __typename?: 'DynamicFieldConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'DynamicField', name?: { __typename?: 'MoveValue', bcs?: string | null, type?: { __typename?: 'MoveType', repr: string } | null } | null, value?:
|
|
4651
|
-
| { __typename: 'MoveObject', address: string, contents?: { __typename?: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null } | null }
|
|
4652
|
-
| { __typename: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null }
|
|
4637
|
+
| { __typename: 'MoveObject', address: string, contents?: { __typename?: 'MoveValue', bcs?: string | null, type?: { __typename?: 'MoveType', repr: string } | null } | null }
|
|
4638
|
+
| { __typename: 'MoveValue', bcs?: string | null, type?: { __typename?: 'MoveType', repr: string } | null }
|
|
4653
4639
|
| null }> } | null } | null };
|
|
4654
4640
|
|
|
4655
4641
|
export type GetMoveFunctionQueryVariables = Exact<{
|
|
@@ -4758,7 +4744,7 @@ export type SimulateTransactionQueryVariables = Exact<{
|
|
|
4758
4744
|
}>;
|
|
4759
4745
|
|
|
4760
4746
|
|
|
4761
|
-
export type SimulateTransactionQuery = { __typename?: 'Query', simulateTransaction: { __typename?: 'SimulationResult',
|
|
4747
|
+
export type SimulateTransactionQuery = { __typename?: 'Query', simulateTransaction: { __typename?: 'SimulationResult', effects?: { __typename?: 'TransactionEffects', transaction?: { __typename?: 'Transaction', digest: string, transactionJson?: unknown | null, transactionBcs?: string | null, signatures: Array<{ __typename?: 'UserSignature', signatureBytes?: string | null }>, effects?: { __typename?: 'TransactionEffects', status?: ExecutionStatus | null, effectsBcs?: string | null, effectsJson?: unknown | null, balanceChangesJson?: unknown | null, executionError?: { __typename?: 'ExecutionError', message: string, abortCode?: string | null, identifier?: string | null, constant?: string | null, sourceLineNumber?: number | null, instructionOffset?: number | null, module?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, function?: { __typename?: 'MoveFunction', name: string } | null } | null, epoch?: { __typename?: 'Epoch', epochId: number } | null, objectChanges?: { __typename?: 'ObjectChangeConnection', nodes: Array<{ __typename?: 'ObjectChange', address: string, outputState?: { __typename?: 'Object', asMoveObject?: { __typename?: 'MoveObject', contents?: { __typename?: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null } | null } | null } | null }> } | null, events?: { __typename?: 'EventConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, nodes: Array<{ __typename?: 'Event', transactionModule?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, sender?: { __typename?: 'Address', address: string } | null, contents?: { __typename?: 'MoveValue', bcs?: string | null, json?: unknown | null, type?: { __typename?: 'MoveType', repr: string } | null } | null }> } | null } | null } | null } | null, outputs?: Array<{ __typename?: 'CommandResult', returnValues?: Array<{ __typename?: 'CommandOutput', value?: { __typename?: 'MoveValue', bcs?: string | null } | null }> | null, mutatedReferences?: Array<{ __typename?: 'CommandOutput', value?: { __typename?: 'MoveValue', bcs?: string | null } | null }> | null }> | null } };
|
|
4762
4748
|
|
|
4763
4749
|
export type ExecuteTransactionMutationVariables = Exact<{
|
|
4764
4750
|
transactionDataBcs: Scalars['Base64']['input'];
|
|
@@ -4772,7 +4758,7 @@ export type ExecuteTransactionMutationVariables = Exact<{
|
|
|
4772
4758
|
}>;
|
|
4773
4759
|
|
|
4774
4760
|
|
|
4775
|
-
export type ExecuteTransactionMutation = { __typename?: 'Mutation', executeTransaction: { __typename?: 'ExecutionResult',
|
|
4761
|
+
export type ExecuteTransactionMutation = { __typename?: 'Mutation', executeTransaction: { __typename?: 'ExecutionResult', effects?: { __typename?: 'TransactionEffects', transaction?: { __typename?: 'Transaction', digest: string, transactionJson?: unknown | null, transactionBcs?: string | null, signatures: Array<{ __typename?: 'UserSignature', signatureBytes?: string | null }>, effects?: { __typename?: 'TransactionEffects', status?: ExecutionStatus | null, effectsBcs?: string | null, effectsJson?: unknown | null, balanceChangesJson?: unknown | null, executionError?: { __typename?: 'ExecutionError', message: string, abortCode?: string | null, identifier?: string | null, constant?: string | null, sourceLineNumber?: number | null, instructionOffset?: number | null, module?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, function?: { __typename?: 'MoveFunction', name: string } | null } | null, epoch?: { __typename?: 'Epoch', epochId: number } | null, objectChanges?: { __typename?: 'ObjectChangeConnection', nodes: Array<{ __typename?: 'ObjectChange', address: string, outputState?: { __typename?: 'Object', asMoveObject?: { __typename?: 'MoveObject', contents?: { __typename?: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null } | null } | null } | null }> } | null, events?: { __typename?: 'EventConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, nodes: Array<{ __typename?: 'Event', transactionModule?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, sender?: { __typename?: 'Address', address: string } | null, contents?: { __typename?: 'MoveValue', bcs?: string | null, json?: unknown | null, type?: { __typename?: 'MoveType', repr: string } | null } | null }> } | null } | null } | null } | null } };
|
|
4776
4762
|
|
|
4777
4763
|
export type GetTransactionBlockQueryVariables = Exact<{
|
|
4778
4764
|
digest: Scalars['String']['input'];
|
|
@@ -4785,9 +4771,9 @@ export type GetTransactionBlockQueryVariables = Exact<{
|
|
|
4785
4771
|
}>;
|
|
4786
4772
|
|
|
4787
4773
|
|
|
4788
|
-
export type GetTransactionBlockQuery = { __typename?: 'Query', transaction?: { __typename?: 'Transaction', digest: string, transactionJson?: unknown | null, transactionBcs?: string | null, signatures: Array<{ __typename?: 'UserSignature', signatureBytes?: string | null }>, effects?: { __typename?: 'TransactionEffects', status?: ExecutionStatus | null, effectsBcs?: string | null, effectsJson?: unknown | null, balanceChangesJson?: unknown | null, executionError?: { __typename?: 'ExecutionError', message: string, abortCode?: string | null, identifier?: string | null, constant?: string | null, sourceLineNumber?: number | null, instructionOffset?: number | null, module?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, function?: { __typename?: 'MoveFunction', name: string } | null } | null, epoch?: { __typename?: 'Epoch', epochId: number } | null, objectChanges?: { __typename?: 'ObjectChangeConnection', nodes: Array<{ __typename?: 'ObjectChange', address: string, outputState?: { __typename?: 'Object', asMoveObject?: { __typename?: 'MoveObject', contents?: { __typename?: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null } | null } | null } | null }> } | null, events?: { __typename?: 'EventConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, nodes: Array<{ __typename?: 'Event', transactionModule?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, sender?: { __typename?: 'Address', address: string } | null, contents?: { __typename?: 'MoveValue', bcs?: string | null, type?: { __typename?: 'MoveType', repr: string } | null } | null }> } | null } | null } | null };
|
|
4774
|
+
export type GetTransactionBlockQuery = { __typename?: 'Query', transaction?: { __typename?: 'Transaction', digest: string, transactionJson?: unknown | null, transactionBcs?: string | null, signatures: Array<{ __typename?: 'UserSignature', signatureBytes?: string | null }>, effects?: { __typename?: 'TransactionEffects', status?: ExecutionStatus | null, effectsBcs?: string | null, effectsJson?: unknown | null, balanceChangesJson?: unknown | null, executionError?: { __typename?: 'ExecutionError', message: string, abortCode?: string | null, identifier?: string | null, constant?: string | null, sourceLineNumber?: number | null, instructionOffset?: number | null, module?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, function?: { __typename?: 'MoveFunction', name: string } | null } | null, epoch?: { __typename?: 'Epoch', epochId: number } | null, objectChanges?: { __typename?: 'ObjectChangeConnection', nodes: Array<{ __typename?: 'ObjectChange', address: string, outputState?: { __typename?: 'Object', asMoveObject?: { __typename?: 'MoveObject', contents?: { __typename?: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null } | null } | null } | null }> } | null, events?: { __typename?: 'EventConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, nodes: Array<{ __typename?: 'Event', transactionModule?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, sender?: { __typename?: 'Address', address: string } | null, contents?: { __typename?: 'MoveValue', bcs?: string | null, json?: unknown | null, type?: { __typename?: 'MoveType', repr: string } | null } | null }> } | null } | null } | null };
|
|
4789
4775
|
|
|
4790
|
-
export type Transaction_FieldsFragment = { __typename?: 'Transaction', digest: string, transactionJson?: unknown | null, transactionBcs?: string | null, signatures: Array<{ __typename?: 'UserSignature', signatureBytes?: string | null }>, effects?: { __typename?: 'TransactionEffects', status?: ExecutionStatus | null, effectsBcs?: string | null, effectsJson?: unknown | null, balanceChangesJson?: unknown | null, executionError?: { __typename?: 'ExecutionError', message: string, abortCode?: string | null, identifier?: string | null, constant?: string | null, sourceLineNumber?: number | null, instructionOffset?: number | null, module?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, function?: { __typename?: 'MoveFunction', name: string } | null } | null, epoch?: { __typename?: 'Epoch', epochId: number } | null, objectChanges?: { __typename?: 'ObjectChangeConnection', nodes: Array<{ __typename?: 'ObjectChange', address: string, outputState?: { __typename?: 'Object', asMoveObject?: { __typename?: 'MoveObject', contents?: { __typename?: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null } | null } | null } | null }> } | null, events?: { __typename?: 'EventConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, nodes: Array<{ __typename?: 'Event', transactionModule?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, sender?: { __typename?: 'Address', address: string } | null, contents?: { __typename?: 'MoveValue', bcs?: string | null, type?: { __typename?: 'MoveType', repr: string } | null } | null }> } | null } | null };
|
|
4776
|
+
export type Transaction_FieldsFragment = { __typename?: 'Transaction', digest: string, transactionJson?: unknown | null, transactionBcs?: string | null, signatures: Array<{ __typename?: 'UserSignature', signatureBytes?: string | null }>, effects?: { __typename?: 'TransactionEffects', status?: ExecutionStatus | null, effectsBcs?: string | null, effectsJson?: unknown | null, balanceChangesJson?: unknown | null, executionError?: { __typename?: 'ExecutionError', message: string, abortCode?: string | null, identifier?: string | null, constant?: string | null, sourceLineNumber?: number | null, instructionOffset?: number | null, module?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, function?: { __typename?: 'MoveFunction', name: string } | null } | null, epoch?: { __typename?: 'Epoch', epochId: number } | null, objectChanges?: { __typename?: 'ObjectChangeConnection', nodes: Array<{ __typename?: 'ObjectChange', address: string, outputState?: { __typename?: 'Object', asMoveObject?: { __typename?: 'MoveObject', contents?: { __typename?: 'MoveValue', type?: { __typename?: 'MoveType', repr: string } | null } | null } | null } | null }> } | null, events?: { __typename?: 'EventConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, nodes: Array<{ __typename?: 'Event', transactionModule?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, sender?: { __typename?: 'Address', address: string } | null, contents?: { __typename?: 'MoveValue', bcs?: string | null, json?: unknown | null, type?: { __typename?: 'MoveType', repr: string } | null } | null }> } | null } | null };
|
|
4791
4777
|
|
|
4792
4778
|
export type ResolveTransactionQueryVariables = Exact<{
|
|
4793
4779
|
transaction: Scalars['JSON']['input'];
|
|
@@ -4795,7 +4781,7 @@ export type ResolveTransactionQueryVariables = Exact<{
|
|
|
4795
4781
|
}>;
|
|
4796
4782
|
|
|
4797
4783
|
|
|
4798
|
-
export type ResolveTransactionQuery = { __typename?: 'Query', simulateTransaction: { __typename?: 'SimulationResult',
|
|
4784
|
+
export type ResolveTransactionQuery = { __typename?: 'Query', simulateTransaction: { __typename?: 'SimulationResult', effects?: { __typename?: 'TransactionEffects', transaction?: { __typename?: 'Transaction', transactionBcs?: string | null, effects?: { __typename?: 'TransactionEffects', status?: ExecutionStatus | null, executionError?: { __typename?: 'ExecutionError', message: string, abortCode?: string | null, identifier?: string | null, constant?: string | null, sourceLineNumber?: number | null, instructionOffset?: number | null, module?: { __typename?: 'MoveModule', name: string, package?: { __typename?: 'MovePackage', address: string } | null } | null, function?: { __typename?: 'MoveFunction', name: string } | null } | null } | null } | null } | null } };
|
|
4799
4785
|
|
|
4800
4786
|
export type VerifyZkLoginSignatureQueryVariables = Exact<{
|
|
4801
4787
|
bytes: Scalars['Base64']['input'];
|
|
@@ -5004,6 +4990,7 @@ export const Transaction_FieldsFragmentDoc = new TypedDocumentString(`
|
|
|
5004
4990
|
repr
|
|
5005
4991
|
}
|
|
5006
4992
|
bcs
|
|
4993
|
+
json
|
|
5007
4994
|
}
|
|
5008
4995
|
}
|
|
5009
4996
|
}
|
|
@@ -5125,7 +5112,7 @@ export const GetCurrentSystemStateDocument = new TypedDocumentString(`
|
|
|
5125
5112
|
}
|
|
5126
5113
|
`) as unknown as TypedDocumentString<GetCurrentSystemStateQuery, GetCurrentSystemStateQueryVariables>;
|
|
5127
5114
|
export const GetDynamicFieldsDocument = new TypedDocumentString(`
|
|
5128
|
-
query getDynamicFields($parentId: SuiAddress!, $first: Int, $cursor: String) {
|
|
5115
|
+
query getDynamicFields($parentId: SuiAddress!, $first: Int, $cursor: String, $includeValue: Boolean = false) {
|
|
5129
5116
|
address(address: $parentId) {
|
|
5130
5117
|
dynamicFields(first: $first, after: $cursor) {
|
|
5131
5118
|
pageInfo {
|
|
@@ -5142,6 +5129,7 @@ export const GetDynamicFieldsDocument = new TypedDocumentString(`
|
|
|
5142
5129
|
value {
|
|
5143
5130
|
__typename
|
|
5144
5131
|
... on MoveValue {
|
|
5132
|
+
bcs @include(if: $includeValue)
|
|
5145
5133
|
type {
|
|
5146
5134
|
repr
|
|
5147
5135
|
}
|
|
@@ -5149,6 +5137,7 @@ export const GetDynamicFieldsDocument = new TypedDocumentString(`
|
|
|
5149
5137
|
... on MoveObject {
|
|
5150
5138
|
address
|
|
5151
5139
|
contents {
|
|
5140
|
+
bcs @include(if: $includeValue)
|
|
5152
5141
|
type {
|
|
5153
5142
|
repr
|
|
5154
5143
|
}
|
|
@@ -5312,7 +5301,6 @@ export const SimulateTransactionDocument = new TypedDocumentString(`
|
|
|
5312
5301
|
doGasSelection: $doGasSelection
|
|
5313
5302
|
checksEnabled: $checksEnabled
|
|
5314
5303
|
) {
|
|
5315
|
-
error
|
|
5316
5304
|
effects {
|
|
5317
5305
|
transaction {
|
|
5318
5306
|
...TRANSACTION_FIELDS
|
|
@@ -5397,6 +5385,7 @@ export const SimulateTransactionDocument = new TypedDocumentString(`
|
|
|
5397
5385
|
repr
|
|
5398
5386
|
}
|
|
5399
5387
|
bcs
|
|
5388
|
+
json
|
|
5400
5389
|
}
|
|
5401
5390
|
}
|
|
5402
5391
|
}
|
|
@@ -5408,7 +5397,6 @@ export const ExecuteTransactionDocument = new TypedDocumentString(`
|
|
|
5408
5397
|
transactionDataBcs: $transactionDataBcs
|
|
5409
5398
|
signatures: $signatures
|
|
5410
5399
|
) {
|
|
5411
|
-
errors
|
|
5412
5400
|
effects {
|
|
5413
5401
|
transaction {
|
|
5414
5402
|
...TRANSACTION_FIELDS
|
|
@@ -5481,6 +5469,7 @@ export const ExecuteTransactionDocument = new TypedDocumentString(`
|
|
|
5481
5469
|
repr
|
|
5482
5470
|
}
|
|
5483
5471
|
bcs
|
|
5472
|
+
json
|
|
5484
5473
|
}
|
|
5485
5474
|
}
|
|
5486
5475
|
}
|
|
@@ -5557,6 +5546,7 @@ export const GetTransactionBlockDocument = new TypedDocumentString(`
|
|
|
5557
5546
|
repr
|
|
5558
5547
|
}
|
|
5559
5548
|
bcs
|
|
5549
|
+
json
|
|
5560
5550
|
}
|
|
5561
5551
|
}
|
|
5562
5552
|
}
|
|
@@ -5565,7 +5555,6 @@ export const GetTransactionBlockDocument = new TypedDocumentString(`
|
|
|
5565
5555
|
export const ResolveTransactionDocument = new TypedDocumentString(`
|
|
5566
5556
|
query resolveTransaction($transaction: JSON!, $doGasSelection: Boolean = true) {
|
|
5567
5557
|
simulateTransaction(transaction: $transaction, doGasSelection: $doGasSelection) {
|
|
5568
|
-
error
|
|
5569
5558
|
effects {
|
|
5570
5559
|
transaction {
|
|
5571
5560
|
transactionBcs
|
|
@@ -1465,18 +1465,13 @@ type ExecutionError {
|
|
|
1465
1465
|
}
|
|
1466
1466
|
|
|
1467
1467
|
"""
|
|
1468
|
-
The execution result of a transaction, including the transaction effects
|
|
1468
|
+
The execution result of a transaction, including the transaction effects.
|
|
1469
1469
|
"""
|
|
1470
1470
|
type ExecutionResult {
|
|
1471
1471
|
"""
|
|
1472
|
-
The effects of the transaction execution
|
|
1472
|
+
The effects of the transaction execution.
|
|
1473
1473
|
"""
|
|
1474
1474
|
effects: TransactionEffects
|
|
1475
|
-
"""
|
|
1476
|
-
Errors that occurred during execution (e.g., network errors, validation failures).
|
|
1477
|
-
These are distinct from execution failures within the transaction itself.
|
|
1478
|
-
"""
|
|
1479
|
-
errors: [String!]
|
|
1480
1475
|
}
|
|
1481
1476
|
|
|
1482
1477
|
"""
|
|
@@ -3329,7 +3324,7 @@ type Query {
|
|
|
3329
3324
|
"""
|
|
3330
3325
|
address(address: SuiAddress, name: String, rootVersion: UInt53, atCheckpoint: UInt53): Address
|
|
3331
3326
|
"""
|
|
3332
|
-
|
|
3327
|
+
The network's genesis checkpoint digest (uniquely identifies the network), Base58-encoded.
|
|
3333
3328
|
"""
|
|
3334
3329
|
chainIdentifier: String!
|
|
3335
3330
|
"""
|
|
@@ -3771,22 +3766,14 @@ type SharedInput {
|
|
|
3771
3766
|
}
|
|
3772
3767
|
|
|
3773
3768
|
"""
|
|
3774
|
-
The result of simulating a transaction, including the predicted effects
|
|
3769
|
+
The result of simulating a transaction, including the predicted effects.
|
|
3775
3770
|
"""
|
|
3776
3771
|
type SimulationResult {
|
|
3777
3772
|
"""
|
|
3778
3773
|
The predicted effects of the transaction if it were executed.
|
|
3779
|
-
|
|
3780
|
-
`None` if the simulation failed due to an error.
|
|
3781
3774
|
"""
|
|
3782
3775
|
effects: TransactionEffects
|
|
3783
3776
|
"""
|
|
3784
|
-
Error message if the simulation failed.
|
|
3785
|
-
|
|
3786
|
-
`None` if the simulation was successful.
|
|
3787
|
-
"""
|
|
3788
|
-
error: String
|
|
3789
|
-
"""
|
|
3790
3777
|
The intermediate outputs for each command of the transaction simulation, including contents of mutated references and return values.
|
|
3791
3778
|
"""
|
|
3792
3779
|
outputs: [CommandResult!]
|
|
@@ -4315,21 +4315,6 @@ const introspection = {
|
|
|
4315
4315
|
},
|
|
4316
4316
|
"args": [],
|
|
4317
4317
|
"isDeprecated": false
|
|
4318
|
-
},
|
|
4319
|
-
{
|
|
4320
|
-
"name": "errors",
|
|
4321
|
-
"type": {
|
|
4322
|
-
"kind": "LIST",
|
|
4323
|
-
"ofType": {
|
|
4324
|
-
"kind": "NON_NULL",
|
|
4325
|
-
"ofType": {
|
|
4326
|
-
"kind": "SCALAR",
|
|
4327
|
-
"name": "String"
|
|
4328
|
-
}
|
|
4329
|
-
}
|
|
4330
|
-
},
|
|
4331
|
-
"args": [],
|
|
4332
|
-
"isDeprecated": false
|
|
4333
4318
|
}
|
|
4334
4319
|
],
|
|
4335
4320
|
"interfaces": []
|
|
@@ -11572,15 +11557,6 @@ const introspection = {
|
|
|
11572
11557
|
"args": [],
|
|
11573
11558
|
"isDeprecated": false
|
|
11574
11559
|
},
|
|
11575
|
-
{
|
|
11576
|
-
"name": "error",
|
|
11577
|
-
"type": {
|
|
11578
|
-
"kind": "SCALAR",
|
|
11579
|
-
"name": "String"
|
|
11580
|
-
},
|
|
11581
|
-
"args": [],
|
|
11582
|
-
"isDeprecated": false
|
|
11583
|
-
},
|
|
11584
11560
|
{
|
|
11585
11561
|
"name": "outputs",
|
|
11586
11562
|
"type": {
|
|
@@ -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
|
}
|
|
@@ -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(
|