All files / src/api/faucets fetchers.ts

100% Statements 9/9
100% Branches 1/1
100% Functions 2/2
100% Lines 9/9

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 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33      10x               10x         1x 1x 1x                 10x 1x 1x 1x    
import { RunFaucetResponse } from '@stacks/stacks-blockchain-api-types';
import { BaseListParams } from '../types';
import { FetchStxTokensParams } from './types';
import { fetchJsonPost, generateUrl, stxFaucetEndpoint, btcFaucetEndpoint } from '../utils';
 
/**
 * Get STX tokens
 *
 * @see https://docs.micro-stacks.dev/modules/core/api/faucets#fetchgetstxtokens
 */
 
export async function fetchGetStxTokens({
  url,
  address,
  stacking = false,
}: BaseListParams & FetchStxTokensParams) {
  const path = generateUrl(stxFaucetEndpoint(url), {});
  const body: FetchStxTokensParams = { address: address, stacking: stacking };
  return fetchJsonPost<RunFaucetResponse>(path, { body });
}
 
/**
 * Get BTC tokens
 *
 * @see https://docs.micro-stacks.dev/modules/core/api/faucets#fetchgetbtctokens
 */
 
export async function fetchGetBtcTokens({ url, address }: BaseListParams & { address: string }) {
  const path = generateUrl(btcFaucetEndpoint(url), {});
  const body: FetchStxTokensParams = { address: address };
  return fetchJsonPost<RunFaucetResponse>(path, { body });
}