diff --git a/packages/entrykit/src/useRecord.ts b/packages/entrykit/src/useRecord.ts deleted file mode 100644 index 3e7642e760..0000000000 --- a/packages/entrykit/src/useRecord.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { Table } from "@latticexyz/config"; -import { UseReadContractParameters, UseReadContractReturnType, useReadContract } from "wagmi"; -import IStoreReadAbi from "@latticexyz/store/out/IStoreRead.sol/IStoreRead.abi.json"; -import { - decodeValueArgs, - getKeySchema, - getKeyTuple, - getSchemaPrimitives, - getSchemaTypes, - getValueSchema, -} from "@latticexyz/protocol-parser/internal"; -import { Hex } from "viem"; -import { show } from "@ark/util"; - -// TODO: move to our own useQuery so we can control the query key - -export function useRecord({ - table, - key, - ...opts -}: Omit< - UseReadContractParameters, - "abi" | "functionName" | "args" -> & { - readonly table?: table; - readonly key?: getSchemaPrimitives>; -}): UseReadContractReturnType< - typeof IStoreReadAbi, - "getRecord", - readonly [Hex, readonly Hex[]], - show> -> { - return useReadContract( - table && key && opts.query?.enabled !== false - ? { - ...opts, - abi: IStoreReadAbi, - functionName: "getRecord", - args: [table.tableId, getKeyTuple(table, key)], - query: { - ...opts.query, - select: (data) => ({ - ...key, - ...decodeValueArgs(getSchemaTypes(getValueSchema(table)), { - staticData: (data as [Hex, Hex, Hex])[0], - encodedLengths: (data as [Hex, Hex, Hex])[1], - dynamicData: (data as [Hex, Hex, Hex])[2], - }), - }), - }, - } - : {}, - ); -}