@dojoengine/sdk
Version:
Dojo SDK: Build onchain and provable apps faster
30 lines (27 loc) • 1.18 kB
TypeScript
import { F } from './hydration-Cvr-9VdO.js';
import { UseQueryOptions } from '@tanstack/react-query';
/**
* Simple function to query Torii instance over sql endpoint.
*
* This endpoint is mainly meant to be used as analytical query system.
* For more informations and examples, head over to `examples/example-vite-react-sql` example
*
*
* @template Input - The type your data have raw, just straight out of sql
* @template Output - The type that will have your data after going through `formatFn`
* @param {string} toriiUrl - Torii url
* @param {string} query - Your raw sql query
* @param {(rows: Input) => Output} formatFn - Format function callback
* @returns {Promise<Output>} - Formatted data
*/
declare function queryTorii<Input, Output>(toriiUrl: string, query: string, formatFn: (rows: Input) => Output): Promise<Output>;
/**
*
*/
declare function useToriiSQLQuery<Output, Input>(query: string, formatFn: (rows: Input) => Output, defaultValue?: UseQueryOptions<Output>["placeholderData"], toriiUrl?: string): {
data: F<Output>;
error: Error | null;
isPending: false;
isRefetching: boolean;
};
export { queryTorii, useToriiSQLQuery };