All files / src/api/tokens fetchers.ts

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

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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59              10x               10x 1x 1x                 10x 1x 1x                 10x       1x 1x                 10x       1x 1x    
import {
  FungibleTokensMetadataList,
  NonFungibleTokensMetadataList,
  NonFungibleTokenMetadata,
  FungibleTokenMetadata,
} from '@stacks/stacks-blockchain-api-types';
import { BaseListParams } from '../types';
import { fetchJson, generateUrl, tokensEndpoint } from '../utils';
 
/**
 * Get list of fungible tokens metadata
 *
 * @see https://docs.micro-stacks.dev/modules/core/api/tokens#fetchftmetadatalist
 */
 
export async function fetchFtMetadataList({ url }: BaseListParams) {
  const path = generateUrl(`${tokensEndpoint(url)}/ft/metadata`, {});
  return fetchJson<FungibleTokensMetadataList>(path);
}
 
/**
 * Get list of non fungible tokens metadata
 *
 * @see https://docs.micro-stacks.dev/modules/core/api/tokens#fetchnftmetadatalist
 */
 
export async function fetchNftMetadataList({ url }: BaseListParams) {
  const path = generateUrl(`${tokensEndpoint(url)}/nft/metadata`, {});
  return fetchJson<NonFungibleTokensMetadataList>(path);
}
 
/**
 * Non fungible tokens metadata for contract id
 *
 * @see https://docs.micro-stacks.dev/modules/core/api/tokens#fetchnftmetadataforcontractid
 */
 
export async function fetchNftMetadataForContractId({
  url,
  contractId,
}: BaseListParams & { contractId: string }) {
  const path = generateUrl(`${tokensEndpoint(url)}/${contractId}/nft/metadata`, {});
  return fetchJson<NonFungibleTokenMetadata>(path);
}
 
/**
 * Fungible tokens metadata for contract id
 *
 * @see https://docs.micro-stacks.dev/modules/core/api/tokens#fetchftmetadataforcontractid
 */
 
export async function fetchFtMetadataForContractId({
  url,
  contractId,
}: BaseListParams & { contractId: string }) {
  const path = generateUrl(`${tokensEndpoint(url)}/${contractId}/ft/metadata`, {});
  return fetchJson<FungibleTokenMetadata>(path);
}