ponder-client
Version:
Type-safe, lightweight Ponder client
50 lines (45 loc) • 1.03 kB
text/typescript
import {
many,
query as queryPonder,
type Data,
type Query,
} from '../../index.js';
import schema from './schema.js';
const ponderApiEndpoint = 'https://scope-ponder-production.up.railway.app';
const query = {
moduleExecutions: many<
'ModuleExecution',
(typeof schema.tables)['ModuleExecution'],
{ id: true; module: true },
{
startCursor: true;
endCursor: true;
hasPreviousPage: true;
hasNextPage: true;
}
>('ModuleExecution')(
{
limit: 10,
where: {
chainId: 1,
success: false,
account: '0x051d6e9bd1d8f714eda4c99f5c2464256941f1cd',
block: 100n,
},
orderBy: 'block',
orderDirection: 'desc',
},
{
id: true,
module: true,
},
{
startCursor: true,
endCursor: true,
hasPreviousPage: true,
hasNextPage: true,
},
),
} satisfies Query;
const data: Data<typeof query> = await queryPonder(ponderApiEndpoint, query);
console.log(data.moduleExecutions);