UNPKG

sui-explorer-local

Version:
30 lines (26 loc) 752 B
// Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 import { useSuiClient } from '@mysten/dapp-kit'; import { normalizeSuiAddress } from '@mysten/sui.js/utils'; import { useQuery } from '@tanstack/react-query'; const defaultOptions = { showType: true, showContent: true, showOwner: true, showPreviousTransaction: true, showStorageRebate: true, showDisplay: true, }; export function useGetObject(objectId?: string | null) { const client = useSuiClient(); const normalizedObjId = objectId && normalizeSuiAddress(objectId); return useQuery({ queryKey: ['object', normalizedObjId], queryFn: () => client.getObject({ id: normalizedObjId!, options: defaultOptions, }), enabled: !!normalizedObjId, }); }