From b2928a903b37ce596b05d67c43d916a67e9f4258 Mon Sep 17 00:00:00 2001 From: hayes-mysten <135670682+hayes-mysten@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:34:35 -0800 Subject: [PATCH] Vladilen11/main (#20684) ## Description Describe the changes or additions included in this PR. ## Test plan How did you test the new or updated feature? --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API: --------- Co-authored-by: vladilen11 --- .changeset/few-lions-battle.md | 5 + .../src/utils/transaction/getOwnerType.ts | 1 + .../src/utils/transaction/groupByOwner.ts | 1 + .../src/generated/queries.ts | 137 +++++++++++++- sdk/graphql-transport/src/mappers/move.ts | 41 +++++ .../src/mappers/transaction-block.ts | 1 + sdk/graphql-transport/src/methods.ts | 18 +- .../queries/getNormalizedMoveModule.graphql | 38 ++++ sdk/typescript/scripts/generate.ts | 3 + sdk/typescript/src/client/types/generated.ts | 169 ++++++++++++------ sdk/typescript/src/client/types/params.ts | 6 +- .../test/e2e/data/dynamic_fields/Move.lock | 2 +- 12 files changed, 355 insertions(+), 67 deletions(-) create mode 100644 .changeset/few-lions-battle.md diff --git a/.changeset/few-lions-battle.md b/.changeset/few-lions-battle.md new file mode 100644 index 0000000000000..fa90b308940e4 --- /dev/null +++ b/.changeset/few-lions-battle.md @@ -0,0 +1,5 @@ +--- +'@mysten/sui': minor +--- + +Update generated openrpc types which removes deprecated/non-functional filters for events diff --git a/apps/core/src/utils/transaction/getOwnerType.ts b/apps/core/src/utils/transaction/getOwnerType.ts index 4dc63d2dc3880..6689e28d6541a 100644 --- a/apps/core/src/utils/transaction/getOwnerType.ts +++ b/apps/core/src/utils/transaction/getOwnerType.ts @@ -9,6 +9,7 @@ export const getOwnerType = (change: SuiObjectChange) => { if ('AddressOwner' in change.owner) return 'AddressOwner'; if ('ObjectOwner' in change.owner) return 'ObjectOwner'; if ('Shared' in change.owner) return 'Shared'; + if ('ConsensusV2' in change.owner) return 'ConsensusV2'; } return change.owner; }; diff --git a/apps/core/src/utils/transaction/groupByOwner.ts b/apps/core/src/utils/transaction/groupByOwner.ts index 8f52d23110e47..d1d164a666314 100644 --- a/apps/core/src/utils/transaction/groupByOwner.ts +++ b/apps/core/src/utils/transaction/groupByOwner.ts @@ -10,6 +10,7 @@ const getOwner = (change: SuiObjectChangeWithDisplay) => { if ('AddressOwner' in change.owner) return change.owner.AddressOwner; if ('ObjectOwner' in change.owner) return change.owner.ObjectOwner; if ('Shared' in change.owner) return change.objectId; + if ('ConsensusV2' in change.owner) return change.owner.ConsensusV2.authenticator.SingleOwner; } return ''; }; diff --git a/sdk/graphql-transport/src/generated/queries.ts b/sdk/graphql-transport/src/generated/queries.ts index 1034d34ad036c..0bc8f12ea70f0 100644 --- a/sdk/graphql-transport/src/generated/queries.ts +++ b/sdk/graphql-transport/src/generated/queries.ts @@ -5509,7 +5509,7 @@ export type GetNormalizedMoveModuleQueryVariables = Exact<{ }>; -export type GetNormalizedMoveModuleQuery = { __typename?: 'Query', object?: { __typename?: 'Object', asMovePackage?: { __typename?: 'MovePackage', module?: { __typename?: 'MoveModule', name: string, fileFormatVersion: number, friends: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, package: { __typename?: 'MovePackage', address: any } }> }, structs?: { __typename?: 'MoveStructConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveStruct', name: string, abilities?: Array | null, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null }> } | null, functions?: { __typename?: 'MoveFunctionConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveFunction', name: string, visibility?: MoveVisibility | null, isEntry?: boolean | null, parameters?: Array<{ __typename?: 'OpenMoveType', signature: any }> | null, typeParameters?: Array<{ __typename?: 'MoveFunctionTypeParameter', constraints: Array }> | null, return?: Array<{ __typename?: 'OpenMoveType', repr: string, signature: any }> | null }> } | null } | null } | null } | null }; +export type GetNormalizedMoveModuleQuery = { __typename?: 'Query', object?: { __typename?: 'Object', asMovePackage?: { __typename?: 'MovePackage', module?: { __typename?: 'MoveModule', name: string, fileFormatVersion: number, friends: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, package: { __typename?: 'MovePackage', address: any } }> }, structs?: { __typename?: 'MoveStructConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveStruct', name: string, abilities?: Array | null, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null }> } | null, enums?: { __typename?: 'MoveEnumConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveEnum', name: string, abilities?: Array | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null, variants?: Array<{ __typename?: 'MoveEnumVariant', name: string, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null }> | null }> } | null, functions?: { __typename?: 'MoveFunctionConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveFunction', name: string, visibility?: MoveVisibility | null, isEntry?: boolean | null, parameters?: Array<{ __typename?: 'OpenMoveType', signature: any }> | null, typeParameters?: Array<{ __typename?: 'MoveFunctionTypeParameter', constraints: Array }> | null, return?: Array<{ __typename?: 'OpenMoveType', repr: string, signature: any }> | null }> } | null } | null } | null } | null }; export type PaginateMoveModuleListsQueryVariables = Exact<{ packageId: Scalars['SuiAddress']['input']; @@ -5517,15 +5517,19 @@ export type PaginateMoveModuleListsQueryVariables = Exact<{ hasMoreFriends: Scalars['Boolean']['input']; hasMoreStructs: Scalars['Boolean']['input']; hasMoreFunctions: Scalars['Boolean']['input']; + hasMoreEnums: Scalars['Boolean']['input']; afterFriends?: InputMaybe; afterStructs?: InputMaybe; afterFunctions?: InputMaybe; + afterEnums?: InputMaybe; }>; -export type PaginateMoveModuleListsQuery = { __typename?: 'Query', object?: { __typename?: 'Object', asMovePackage?: { __typename?: 'MovePackage', module?: { __typename?: 'MoveModule', friends?: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, package: { __typename?: 'MovePackage', address: any } }> }, structs?: { __typename?: 'MoveStructConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveStruct', name: string, abilities?: Array | null, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null }> } | null, functions?: { __typename?: 'MoveFunctionConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveFunction', name: string, visibility?: MoveVisibility | null, isEntry?: boolean | null, parameters?: Array<{ __typename?: 'OpenMoveType', signature: any }> | null, typeParameters?: Array<{ __typename?: 'MoveFunctionTypeParameter', constraints: Array }> | null, return?: Array<{ __typename?: 'OpenMoveType', repr: string, signature: any }> | null }> } | null } | null } | null } | null }; +export type PaginateMoveModuleListsQuery = { __typename?: 'Query', object?: { __typename?: 'Object', asMovePackage?: { __typename?: 'MovePackage', module?: { __typename?: 'MoveModule', friends?: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, package: { __typename?: 'MovePackage', address: any } }> }, structs?: { __typename?: 'MoveStructConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveStruct', name: string, abilities?: Array | null, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null }> } | null, enums?: { __typename?: 'MoveEnumConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveEnum', name: string, abilities?: Array | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null, variants?: Array<{ __typename?: 'MoveEnumVariant', name: string, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null }> | null }> } | null, functions?: { __typename?: 'MoveFunctionConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveFunction', name: string, visibility?: MoveVisibility | null, isEntry?: boolean | null, parameters?: Array<{ __typename?: 'OpenMoveType', signature: any }> | null, typeParameters?: Array<{ __typename?: 'MoveFunctionTypeParameter', constraints: Array }> | null, return?: Array<{ __typename?: 'OpenMoveType', repr: string, signature: any }> | null }> } | null } | null } | null } | null }; -export type Rpc_Move_Module_FieldsFragment = { __typename?: 'MoveModule', name: string, fileFormatVersion: number, friends: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, package: { __typename?: 'MovePackage', address: any } }> }, structs?: { __typename?: 'MoveStructConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveStruct', name: string, abilities?: Array | null, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null }> } | null, functions?: { __typename?: 'MoveFunctionConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveFunction', name: string, visibility?: MoveVisibility | null, isEntry?: boolean | null, parameters?: Array<{ __typename?: 'OpenMoveType', signature: any }> | null, typeParameters?: Array<{ __typename?: 'MoveFunctionTypeParameter', constraints: Array }> | null, return?: Array<{ __typename?: 'OpenMoveType', repr: string, signature: any }> | null }> } | null }; +export type Rpc_Move_Module_FieldsFragment = { __typename?: 'MoveModule', name: string, fileFormatVersion: number, friends: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, package: { __typename?: 'MovePackage', address: any } }> }, structs?: { __typename?: 'MoveStructConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveStruct', name: string, abilities?: Array | null, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null }> } | null, enums?: { __typename?: 'MoveEnumConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveEnum', name: string, abilities?: Array | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null, variants?: Array<{ __typename?: 'MoveEnumVariant', name: string, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null }> | null }> } | null, functions?: { __typename?: 'MoveFunctionConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveFunction', name: string, visibility?: MoveVisibility | null, isEntry?: boolean | null, parameters?: Array<{ __typename?: 'OpenMoveType', signature: any }> | null, typeParameters?: Array<{ __typename?: 'MoveFunctionTypeParameter', constraints: Array }> | null, return?: Array<{ __typename?: 'OpenMoveType', repr: string, signature: any }> | null }> } | null }; + +export type Rpc_Move_Enum_FieldsFragment = { __typename?: 'MoveEnum', name: string, abilities?: Array | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null, variants?: Array<{ __typename?: 'MoveEnumVariant', name: string, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null }> | null }; export type GetNormalizedMoveModulesByPackageQueryVariables = Exact<{ packageId: Scalars['SuiAddress']['input']; @@ -5533,7 +5537,7 @@ export type GetNormalizedMoveModulesByPackageQueryVariables = Exact<{ }>; -export type GetNormalizedMoveModulesByPackageQuery = { __typename?: 'Query', object?: { __typename?: 'Object', asMovePackage?: { __typename?: 'MovePackage', address: any, modules?: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, fileFormatVersion: number, friends: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, package: { __typename?: 'MovePackage', address: any } }> }, structs?: { __typename?: 'MoveStructConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveStruct', name: string, abilities?: Array | null, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null }> } | null, functions?: { __typename?: 'MoveFunctionConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveFunction', name: string, visibility?: MoveVisibility | null, isEntry?: boolean | null, parameters?: Array<{ __typename?: 'OpenMoveType', signature: any }> | null, typeParameters?: Array<{ __typename?: 'MoveFunctionTypeParameter', constraints: Array }> | null, return?: Array<{ __typename?: 'OpenMoveType', repr: string, signature: any }> | null }> } | null }> } | null } | null } | null }; +export type GetNormalizedMoveModulesByPackageQuery = { __typename?: 'Query', object?: { __typename?: 'Object', asMovePackage?: { __typename?: 'MovePackage', address: any, modules?: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, fileFormatVersion: number, friends: { __typename?: 'MoveModuleConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveModule', name: string, package: { __typename?: 'MovePackage', address: any } }> }, structs?: { __typename?: 'MoveStructConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveStruct', name: string, abilities?: Array | null, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null }> } | null, enums?: { __typename?: 'MoveEnumConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveEnum', name: string, abilities?: Array | null, typeParameters?: Array<{ __typename?: 'MoveStructTypeParameter', isPhantom: boolean, constraints: Array }> | null, variants?: Array<{ __typename?: 'MoveEnumVariant', name: string, fields?: Array<{ __typename?: 'MoveField', name: string, type?: { __typename?: 'OpenMoveType', signature: any } | null }> | null }> | null }> } | null, functions?: { __typename?: 'MoveFunctionConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, endCursor?: string | null }, nodes: Array<{ __typename?: 'MoveFunction', name: string, visibility?: MoveVisibility | null, isEntry?: boolean | null, parameters?: Array<{ __typename?: 'OpenMoveType', signature: any }> | null, typeParameters?: Array<{ __typename?: 'MoveFunctionTypeParameter', constraints: Array }> | null, return?: Array<{ __typename?: 'OpenMoveType', repr: string, signature: any }> | null }> } | null }> } | null } | null } | null }; export type GetNormalizedMoveStructQueryVariables = Exact<{ packageId: Scalars['SuiAddress']['input']; @@ -5927,6 +5931,25 @@ export const Rpc_Move_Struct_FieldsFragmentDoc = new TypedDocumentString(` } } `, {"fragmentName":"RPC_MOVE_STRUCT_FIELDS"}) as unknown as TypedDocumentString; +export const Rpc_Move_Enum_FieldsFragmentDoc = new TypedDocumentString(` + fragment RPC_MOVE_ENUM_FIELDS on MoveEnum { + name + abilities + typeParameters { + isPhantom + constraints + } + variants { + name + fields { + name + type { + signature + } + } + } +} + `, {"fragmentName":"RPC_MOVE_ENUM_FIELDS"}) as unknown as TypedDocumentString; export const Rpc_Move_Function_FieldsFragmentDoc = new TypedDocumentString(` fragment RPC_MOVE_FUNCTION_FIELDS on MoveFunction { name @@ -5968,6 +5991,15 @@ export const Rpc_Move_Module_FieldsFragmentDoc = new TypedDocumentString(` ...RPC_MOVE_STRUCT_FIELDS } } + enums { + pageInfo { + hasNextPage + endCursor + } + nodes { + ...RPC_MOVE_ENUM_FIELDS + } + } fileFormatVersion functions { pageInfo { @@ -5994,6 +6026,23 @@ export const Rpc_Move_Module_FieldsFragmentDoc = new TypedDocumentString(` signature } } +fragment RPC_MOVE_ENUM_FIELDS on MoveEnum { + name + abilities + typeParameters { + isPhantom + constraints + } + variants { + name + fields { + name + type { + signature + } + } + } +} fragment RPC_MOVE_STRUCT_FIELDS on MoveStruct { name abilities @@ -7464,6 +7513,15 @@ fragment RPC_MOVE_MODULE_FIELDS on MoveModule { ...RPC_MOVE_STRUCT_FIELDS } } + enums { + pageInfo { + hasNextPage + endCursor + } + nodes { + ...RPC_MOVE_ENUM_FIELDS + } + } fileFormatVersion functions { pageInfo { @@ -7475,6 +7533,23 @@ fragment RPC_MOVE_MODULE_FIELDS on MoveModule { } } } +fragment RPC_MOVE_ENUM_FIELDS on MoveEnum { + name + abilities + typeParameters { + isPhantom + constraints + } + variants { + name + fields { + name + type { + signature + } + } + } +} fragment RPC_MOVE_STRUCT_FIELDS on MoveStruct { name abilities @@ -7490,7 +7565,7 @@ fragment RPC_MOVE_STRUCT_FIELDS on MoveStruct { } }`) as unknown as TypedDocumentString; export const PaginateMoveModuleListsDocument = new TypedDocumentString(` - query paginateMoveModuleLists($packageId: SuiAddress!, $module: String!, $hasMoreFriends: Boolean!, $hasMoreStructs: Boolean!, $hasMoreFunctions: Boolean!, $afterFriends: String, $afterStructs: String, $afterFunctions: String) { + query paginateMoveModuleLists($packageId: SuiAddress!, $module: String!, $hasMoreFriends: Boolean!, $hasMoreStructs: Boolean!, $hasMoreFunctions: Boolean!, $hasMoreEnums: Boolean!, $afterFriends: String, $afterStructs: String, $afterFunctions: String, $afterEnums: String) { object(address: $packageId) { asMovePackage { module(name: $module) { @@ -7515,6 +7590,15 @@ export const PaginateMoveModuleListsDocument = new TypedDocumentString(` ...RPC_MOVE_STRUCT_FIELDS } } + enums(after: $afterEnums) @include(if: $hasMoreEnums) { + pageInfo { + hasNextPage + endCursor + } + nodes { + ...RPC_MOVE_ENUM_FIELDS + } + } functions(after: $afterFunctions) @include(if: $hasMoreFunctions) { pageInfo { hasNextPage @@ -7543,6 +7627,23 @@ export const PaginateMoveModuleListsDocument = new TypedDocumentString(` signature } } +fragment RPC_MOVE_ENUM_FIELDS on MoveEnum { + name + abilities + typeParameters { + isPhantom + constraints + } + variants { + name + fields { + name + type { + signature + } + } + } +} fragment RPC_MOVE_STRUCT_FIELDS on MoveStruct { name abilities @@ -7612,6 +7713,15 @@ fragment RPC_MOVE_MODULE_FIELDS on MoveModule { ...RPC_MOVE_STRUCT_FIELDS } } + enums { + pageInfo { + hasNextPage + endCursor + } + nodes { + ...RPC_MOVE_ENUM_FIELDS + } + } fileFormatVersion functions { pageInfo { @@ -7623,6 +7733,23 @@ fragment RPC_MOVE_MODULE_FIELDS on MoveModule { } } } +fragment RPC_MOVE_ENUM_FIELDS on MoveEnum { + name + abilities + typeParameters { + isPhantom + constraints + } + variants { + name + fields { + name + type { + signature + } + } + } +} fragment RPC_MOVE_STRUCT_FIELDS on MoveStruct { name abilities diff --git a/sdk/graphql-transport/src/mappers/move.ts b/sdk/graphql-transport/src/mappers/move.ts index f0dce16677466..50c237d62c00b 100644 --- a/sdk/graphql-transport/src/mappers/move.ts +++ b/sdk/graphql-transport/src/mappers/move.ts @@ -5,6 +5,7 @@ import type { MoveStruct, MoveValue, SuiMoveAbility, + SuiMoveNormalizedEnum, SuiMoveNormalizedFunction, SuiMoveNormalizedModule, SuiMoveNormalizedStruct, @@ -13,6 +14,7 @@ import type { import { normalizeSuiAddress, parseStructTag } from '@mysten/sui/utils'; import type { + Rpc_Move_Enum_FieldsFragment, Rpc_Move_Function_FieldsFragment, Rpc_Move_Module_FieldsFragment, Rpc_Move_Struct_FieldsFragment, @@ -156,6 +158,7 @@ export function mapNormalizedMoveModule( ): SuiMoveNormalizedModule { const exposedFunctions: Record = {}; const structs: Record = {}; + const enums: Record = {}; module.functions?.nodes .filter((func) => func.visibility === 'PUBLIC' || func.isEntry || func.visibility === 'FRIEND') @@ -167,6 +170,10 @@ export function mapNormalizedMoveModule( structs[struct.name] = mapNormalizedMoveStruct(struct); }); + module.enums?.nodes.forEach((enumNode) => { + enums[enumNode.name] = mapNormalizedMoveEnum(enumNode); + }); + return { address: toShortTypeString(address), name: module.name, @@ -177,6 +184,7 @@ export function mapNormalizedMoveModule( name: friend.name, })) ?? [], structs, + enums: module.enums ? enums : undefined, exposedFunctions, }; } @@ -295,3 +303,36 @@ export function moveDataToRpcContent(data: MoveData, layout: MoveTypeLayout): Mo throw new Error('Invalid move data: ' + JSON.stringify(data)); } + +export function mapNormalizedMoveEnum( + enumNode: Rpc_Move_Enum_FieldsFragment, +): SuiMoveNormalizedEnum { + return { + abilities: { + abilities: + enumNode.abilities?.map( + (ability) => `${ability[0]}${ability.slice(1).toLowerCase()}` as SuiMoveAbility, + ) ?? [], + }, + typeParameters: + enumNode.typeParameters?.map((param) => ({ + isPhantom: param.isPhantom!, + constraints: { + abilities: + param.constraints?.map( + (constraint) => + `${constraint[0]}${constraint.slice(1).toLowerCase()}` as SuiMoveAbility, + ) ?? [], + }, + })) ?? [], + variants: Object.fromEntries( + enumNode.variants?.map((variant) => [ + variant.name, + variant.fields?.map((field) => ({ + name: field.name, + type: mapOpenMoveType(field.type?.signature), + })) ?? [], + ]) ?? [], + ), + }; +} diff --git a/sdk/graphql-transport/src/mappers/transaction-block.ts b/sdk/graphql-transport/src/mappers/transaction-block.ts index cb0d4256163a3..85d3f5d6a7b0f 100644 --- a/sdk/graphql-transport/src/mappers/transaction-block.ts +++ b/sdk/graphql-transport/src/mappers/transaction-block.ts @@ -66,6 +66,7 @@ export function mapGraphQLTransactionBlockToRpcTransactionBlock( timestampMs: new Date(event.timestamp).getTime().toString(), transactionModule: `${event.sendingModule?.package.address}::${event.sendingModule?.name}`, type: toShortTypeString(event.contents.type?.repr)!, + bcsEncoding: 'base64', })) ?? [], rawTransaction: options?.showRawInput ? mapRawTransaction(transactionBlock) : undefined, ...(options?.showInput diff --git a/sdk/graphql-transport/src/methods.ts b/sdk/graphql-transport/src/methods.ts index 3f5c2404015ba..73797671f4d99 100644 --- a/sdk/graphql-transport/src/methods.ts +++ b/sdk/graphql-transport/src/methods.ts @@ -325,9 +325,11 @@ export const RPC_METHODS: { let hasMoreFriends = moveModule.friends?.pageInfo.hasNextPage ?? false; let hasMoreFunctions = moveModule.functions?.pageInfo.hasNextPage ?? false; let hasMoreStructs = moveModule.structs?.pageInfo.hasNextPage ?? false; + let hasMoreEnums = moveModule.enums?.pageInfo.hasNextPage ?? false; let afterFriends = moveModule.friends?.pageInfo.endCursor; let afterFunctions = moveModule.functions?.pageInfo.endCursor; let afterStructs = moveModule.structs?.pageInfo.endCursor; + let afterEnums = moveModule.enums?.pageInfo.endCursor; while (hasMoreFriends || hasMoreStructs || hasMoreFunctions) { const page = await transport.graphqlQuery( @@ -339,9 +341,11 @@ export const RPC_METHODS: { hasMoreFriends, hasMoreFunctions, hasMoreStructs, + hasMoreEnums, afterFriends, afterFunctions, afterStructs, + afterEnums, }, }, (data) => data.object?.asMovePackage?.module, @@ -350,12 +354,15 @@ export const RPC_METHODS: { moveModule.friends.nodes.push(...(page.friends?.nodes ?? [])); moveModule.functions?.nodes.push(...(page.functions?.nodes ?? [])); moveModule.structs?.nodes.push(...(page.structs?.nodes ?? [])); + moveModule.enums?.nodes.push(...(page.enums?.nodes ?? [])); hasMoreFriends = page.friends?.pageInfo.hasNextPage ?? false; hasMoreFunctions = page.functions?.pageInfo.hasNextPage ?? false; hasMoreStructs = page.structs?.pageInfo.hasNextPage ?? false; + hasMoreEnums = page.enums?.pageInfo.hasNextPage ?? false; afterFriends = page.friends?.pageInfo.endCursor; afterFunctions = page.functions?.pageInfo.endCursor; afterStructs = page.structs?.pageInfo.endCursor; + afterEnums = page.enums?.pageInfo.endCursor; } } @@ -380,11 +387,13 @@ export const RPC_METHODS: { let hasMoreFriends = moveModule.friends?.pageInfo.hasNextPage ?? false; let hasMoreFunctions = moveModule.functions?.pageInfo.hasNextPage ?? false; let hasMoreStructs = moveModule.structs?.pageInfo.hasNextPage ?? false; + let hasMoreEnums = moveModule.enums?.pageInfo.hasNextPage ?? false; let afterFriends = moveModule.friends?.pageInfo.endCursor; let afterFunctions = moveModule.functions?.pageInfo.endCursor; let afterStructs = moveModule.structs?.pageInfo.endCursor; + let afterEnums = moveModule.enums?.pageInfo.endCursor; - while (hasMoreFriends || hasMoreStructs || hasMoreFunctions) { + while (hasMoreFriends || hasMoreStructs || hasMoreFunctions || hasMoreEnums) { const page = await transport.graphqlQuery( { query: PaginateMoveModuleListsDocument, @@ -394,9 +403,11 @@ export const RPC_METHODS: { hasMoreFriends, hasMoreFunctions, hasMoreStructs, + hasMoreEnums, afterFriends, afterFunctions, afterStructs, + afterEnums, }, }, (data) => data.object?.asMovePackage?.module, @@ -405,12 +416,15 @@ export const RPC_METHODS: { moveModule.friends.nodes.push(...(page.friends?.nodes ?? [])); moveModule.functions?.nodes.push(...(page.functions?.nodes ?? [])); moveModule.structs?.nodes.push(...(page.structs?.nodes ?? [])); + moveModule.enums?.nodes.push(...(page.enums?.nodes ?? [])); hasMoreFriends = page.friends?.pageInfo.hasNextPage ?? false; hasMoreFunctions = page.functions?.pageInfo.hasNextPage ?? false; hasMoreStructs = page.structs?.pageInfo.hasNextPage ?? false; + hasMoreEnums = page.enums?.pageInfo.hasNextPage ?? false; afterFriends = page.friends?.pageInfo.endCursor; afterFunctions = page.functions?.pageInfo.endCursor; afterStructs = page.structs?.pageInfo.endCursor; + afterEnums = page.enums?.pageInfo.endCursor; } return mapNormalizedMoveModule(moveModule, normalizeSuiAddress(pkg)); @@ -889,6 +903,7 @@ export const RPC_METHODS: { nextCursor: (pagination.last ? pageInfo.startCursor : pageInfo.endCursor) as never, data: events.map((event) => ({ bcs: event.contents.bcs, + bcsEncoding: 'base64', id: { eventSeq: '', // TODO txDigest: '', // TODO @@ -975,6 +990,7 @@ export const RPC_METHODS: { return { data: fields.map((field) => ({ bcsName: field.name?.bcs && toBase58(fromBase64(field.name.bcs)), + bcsEncoding: 'base58', digest: (field.value?.__typename === 'MoveObject' ? field.value.digest : undefined)!, name: { type: toShortTypeString(field.name?.type.repr)!, diff --git a/sdk/graphql-transport/src/queries/getNormalizedMoveModule.graphql b/sdk/graphql-transport/src/queries/getNormalizedMoveModule.graphql index a6c683fa045c3..d2be5d016772b 100644 --- a/sdk/graphql-transport/src/queries/getNormalizedMoveModule.graphql +++ b/sdk/graphql-transport/src/queries/getNormalizedMoveModule.graphql @@ -17,9 +17,11 @@ query paginateMoveModuleLists( $hasMoreFriends: Boolean! $hasMoreStructs: Boolean! $hasMoreFunctions: Boolean! + $hasMoreEnums: Boolean! $afterFriends: String $afterStructs: String $afterFunctions: String + $afterEnums: String ) { object(address: $packageId) { asMovePackage { @@ -45,6 +47,15 @@ query paginateMoveModuleLists( ...RPC_MOVE_STRUCT_FIELDS } } + enums(after: $afterEnums) @include(if: $hasMoreEnums) { + pageInfo { + hasNextPage + endCursor + } + nodes { + ...RPC_MOVE_ENUM_FIELDS + } + } functions(after: $afterFunctions) @include(if: $hasMoreFunctions) { pageInfo { hasNextPage @@ -82,6 +93,15 @@ fragment RPC_MOVE_MODULE_FIELDS on MoveModule { ...RPC_MOVE_STRUCT_FIELDS } } + enums { + pageInfo { + hasNextPage + endCursor + } + nodes { + ...RPC_MOVE_ENUM_FIELDS + } + } fileFormatVersion functions { pageInfo { @@ -93,3 +113,21 @@ fragment RPC_MOVE_MODULE_FIELDS on MoveModule { } } } + +fragment RPC_MOVE_ENUM_FIELDS on MoveEnum { + name + abilities + typeParameters { + isPhantom + constraints + } + variants { + name + fields { + name + type { + signature + } + } + } +} diff --git a/sdk/typescript/scripts/generate.ts b/sdk/typescript/scripts/generate.ts index e8b70d7ef725c..7b2a5fd2951b7 100644 --- a/sdk/typescript/scripts/generate.ts +++ b/sdk/typescript/scripts/generate.ts @@ -586,6 +586,9 @@ async function generateTypeReference( await Promise.all(type.items.map((t) => generateTypeReference(t, namespace))), ); } + if (!type.items) { + return ts.factory.createTupleTypeNode([]); + } return ts.factory.createArrayTypeNode(await generateTypeReference(type.items, namespace)); case 'object': return withDescription( diff --git a/sdk/typescript/src/client/types/generated.ts b/sdk/typescript/src/client/types/generated.ts index 021527e2a1963..f64d254ed8776 100644 --- a/sdk/typescript/src/client/types/generated.ts +++ b/sdk/typescript/src/client/types/generated.ts @@ -10,6 +10,11 @@ * /crates/sui-open-rpc/spec/openrpc.json */ +export type Authenticator = + /** The contained SuiAddress exclusively has all permissions: read, write, delete, transfer */ + { + SingleOwner: string; + }; export interface Balance { coinObjectCount: number; coinType: string; @@ -164,15 +169,27 @@ export interface DryRunTransactionBlockResponse { input: TransactionBlockData; objectChanges: SuiObjectChange[]; } -export interface DynamicFieldInfo { - bcsName: string; - digest: string; - name: DynamicFieldName; - objectId: string; - objectType: string; - type: DynamicFieldType; - version: string; -} +export type DynamicFieldInfo = + | { + digest: string; + name: DynamicFieldName; + objectId: string; + objectType: string; + type: DynamicFieldType; + version: string; + bcsEncoding: 'base64'; + bcsName: string; + } + | { + digest: string; + name: DynamicFieldName; + objectId: string; + objectType: string; + type: DynamicFieldType; + version: string; + bcsEncoding: 'base58'; + bcsName: string; + }; export interface DynamicFieldName { type: string; value: unknown; @@ -200,38 +217,64 @@ export interface EndOfEpochData { */ nextEpochProtocolVersion: string; } -export interface SuiEvent { - /** Base 58 encoded bcs bytes of the move event */ - bcs: string; - /** - * Sequential event ID, ie (transaction seq number, event seq number). 1) Serves as a unique event ID - * for each fullnode 2) Also serves to sequence events for the purposes of pagination and querying. A - * higher id is an event seen later by that fullnode. This ID is the "cursor" for event querying. - */ - id: EventId; - /** Move package where this event was emitted. */ - packageId: string; - /** Parsed json value of the event */ - parsedJson: unknown; - /** Sender's Sui address. */ - sender: string; - /** UTC timestamp in milliseconds since epoch (1/1/1970) */ - timestampMs?: string | null; - /** Move module where this event was emitted. */ - transactionModule: string; - /** Move event type. */ - type: string; -} +export type SuiEvent = + | { + /** + * Sequential event ID, ie (transaction seq number, event seq number). 1) Serves as a unique event ID + * for each fullnode 2) Also serves to sequence events for the purposes of pagination and querying. A + * higher id is an event seen later by that fullnode. This ID is the "cursor" for event querying. + */ + id: EventId; + /** Move package where this event was emitted. */ + packageId: string; + /** Parsed json value of the event */ + parsedJson: unknown; + /** Sender's Sui address. */ + sender: string; + /** UTC timestamp in milliseconds since epoch (1/1/1970) */ + timestampMs?: string | null; + /** Move module where this event was emitted. */ + transactionModule: string; + /** Move event type. */ + type: string; + bcs: string; + bcsEncoding: 'base64'; + } + | { + /** + * Sequential event ID, ie (transaction seq number, event seq number). 1) Serves as a unique event ID + * for each fullnode 2) Also serves to sequence events for the purposes of pagination and querying. A + * higher id is an event seen later by that fullnode. This ID is the "cursor" for event querying. + */ + id: EventId; + /** Move package where this event was emitted. */ + packageId: string; + /** Parsed json value of the event */ + parsedJson: unknown; + /** Sender's Sui address. */ + sender: string; + /** UTC timestamp in milliseconds since epoch (1/1/1970) */ + timestampMs?: string | null; + /** Move module where this event was emitted. */ + transactionModule: string; + /** Move event type. */ + type: string; + bcs: string; + bcsEncoding: 'base58'; + }; export type SuiEventFilter = - /** Query by sender address. */ + /** Return all events. */ + | { + All: []; + } /** Return events that match any of the given filters. Only supported on event subscriptions. */ + | { + Any: SuiEventFilter[]; + } /** Query by sender address. */ | { Sender: string; } /** Return events emitted by the given transaction. */ | { Transaction: string; - } /** Return events emitted in a specified Package. */ - | { - Package: string; } /** * Return events emitted in a specified Move module. If the event is defined in Module A but emitted in * a tx with Module B, query `MoveModule` by module B returns the event. Query `MoveEventModule` by @@ -262,12 +305,6 @@ export type SuiEventFilter = /** the Move package ID */ package: string; }; - } - | { - MoveEventField: { - path: string; - value: unknown; - }; } /** Return events emitted in [start_time, end_time] interval */ | { TimeRange: { @@ -276,22 +313,8 @@ export type SuiEventFilter = /** left endpoint of time interval, milliseconds since epoch, inclusive */ startTime: string; }; - } - | { - All: SuiEventFilter[]; - } - | { - Any: SuiEventFilter[]; - } - | { - And: [SuiEventFilter, SuiEventFilter]; - } - | { - Or: [SuiEventFilter, SuiEventFilter]; }; -/** - * Unique ID of a Sui Event, the ID is a combination of transaction digest and event seq number. - */ +/** Unique ID of a Sui Event, the ID is a combination of transaction digest and event seq number. */ export interface EventId { eventSeq: string; txDigest: string; @@ -648,7 +671,22 @@ export type ObjectOwner = initial_shared_version: string; }; } - | 'Immutable'; + | 'Immutable' /** + * Object is sequenced via consensus. Ownership is managed by the configured authenticator. + * + * Note: wondering what happened to `V1`? `Shared` above was the V1 of consensus objects. + */ + | { + ConsensusV2: { + /** The authentication mode of the object */ + authenticator: Authenticator; + /** + * The version at which the object most recently became a consensus object. This serves the same + * function as `initial_shared_version`, except it may change if the object's Owner type changes. + */ + start_version: string; + }; + }; /** * `next_cursor` points to the last item in the page; Reading with `next_cursor` will start from the * next item after `next_cursor` if `next_cursor` is `Some`, otherwise it will start from the first @@ -954,6 +992,13 @@ export interface SuiMoveModuleId { address: string; name: string; } +export interface SuiMoveNormalizedEnum { + abilities: SuiMoveAbilitySet; + typeParameters: SuiMoveStructTypeParameter[]; + variants: { + [key: string]: SuiMoveNormalizedField[]; + }; +} export interface SuiMoveNormalizedField { name: string; type: SuiMoveNormalizedType; @@ -967,6 +1012,9 @@ export interface SuiMoveNormalizedFunction { } export interface SuiMoveNormalizedModule { address: string; + enums?: { + [key: string]: SuiMoveNormalizedEnum; + }; exposedFunctions: { [key: string]: SuiMoveNormalizedFunction; }; @@ -1465,7 +1513,7 @@ export interface SuiTransactionBlockResponseQuery { options?: SuiTransactionBlockResponseOptions | null; } export type TransactionFilter = - /** Query by checkpoint. */ + /** CURRENTLY NOT SUPPORTED. Query by checkpoint. */ | { Checkpoint: string; } /** Query by move function. */ @@ -1481,6 +1529,9 @@ export type TransactionFilter = } /** Query by changed object, including created, mutated and unwrapped objects. */ | { ChangedObject: string; + } /** Query for transactions that touch this object. */ + | { + AffectedObject: string; } /** Query by sender address. */ | { FromAddress: string; @@ -1493,7 +1544,7 @@ export type TransactionFilter = from: string; to: string; }; - } /** Query txs that have a given address as sender or recipient. */ + } /** CURRENTLY NOT SUPPORTED. Query txs that have a given address as sender or recipient. */ | { FromOrToAddress: { addr: string; diff --git a/sdk/typescript/src/client/types/params.ts b/sdk/typescript/src/client/types/params.ts index 3c1d030771b19..d14969e83ce45 100644 --- a/sdk/typescript/src/client/types/params.ts +++ b/sdk/typescript/src/client/types/params.ts @@ -204,7 +204,11 @@ export interface GetBalanceParams { */ coinType?: string | null | undefined; } -/** Return metadata(e.g., symbol, decimals) for a coin */ +/** + * Return metadata (e.g., symbol, decimals) for a coin. Note that if the coin's metadata was wrapped in + * the transaction that published its marker type, or the latest version of the metadata object is + * wrapped or deleted, it will not be found. + */ export interface GetCoinMetadataParams { /** type name for the coin (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC) */ coinType: string; diff --git a/sdk/typescript/test/e2e/data/dynamic_fields/Move.lock b/sdk/typescript/test/e2e/data/dynamic_fields/Move.lock index de346af015fae..52a726cbb7829 100644 --- a/sdk/typescript/test/e2e/data/dynamic_fields/Move.lock +++ b/sdk/typescript/test/e2e/data/dynamic_fields/Move.lock @@ -22,6 +22,6 @@ dependencies = [ ] [move.toolchain-version] -compiler-version = "1.38.0" +compiler-version = "1.40.0" edition = "2024.beta" flavor = "sui"