UNPKG

ponder-client

Version:
49 lines (44 loc) 1.16 kB
import { many, query as queryPonder, type Data, type Query, } from '../../index.js'; import schema from './schema.js'; const PONDER_ENDPOINT = 'https://api.ponder.xyz/graphql'; const FACTORY_ADDRESS = '0x1234567890123456789012345678901234567890'; const AFTER_CURSOR = '0x1234567890123456789012345678901234567890'; const query = { entities: many< 'Entity', (typeof schema.tables)['Entity'], { address: true; chainId: true }, { endCursor: true; hasNextPage: true; } >('Entity')( { limit: 10, where: { factory: FACTORY_ADDRESS, }, orderBy: 'address', orderDirection: 'asc', after: AFTER_CURSOR, }, { address: true, chainId: true, }, { endCursor: true, hasNextPage: true, }, ), } satisfies Query; const data: Data<typeof query> = await queryPonder(PONDER_ENDPOINT, query); console.log(typeof data.entities.items[0].address); // Hex console.log(typeof data.entities.items[0].chainId); // number console.log(typeof data.entities.pageInfo.endCursor); // string console.log(typeof data.entities.pageInfo.hasNextPage); // boolean