All files / src/api/search fetchers.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15    10x               10x 2x 2x    
import { SearchErrorResult, SearchSuccessResult } from '@stacks/stacks-blockchain-api-types';
import { BaseListParams } from '../types';
import { fetchJson, generateUrl, searchEndpoint } from '../utils';
 
/**
 * Search blocks, transactions, contracts, or accounts by hash/ID
 *
 * @see https://docs.micro-stacks.dev/modules/core/api/search#fetchsearch
 */
 
export async function fetchSearch({ url, id }: BaseListParams & { id: string }) {
  const path = generateUrl(`${searchEndpoint(url)}/` + id, {});
  return fetchJson<SearchErrorResult | SearchSuccessResult>(path);
}