Skip to content

fiatconnect/fiatconnect-types

Repository files navigation

fiatconnect-types

Types used in the FiatConnect specification. Offered as standalone module for payment providers and wallets to both use for FiatConnect APIs and integrations.

Installation

From your project directory, run:

yarn add @fiatconnect/fiatconnect-types

or

npm i @fiatconnect/fiatconnect-types

Example usage

import { TransferStatus } from '@fiatconnect/fiatconnect-types'
import axios from 'axios'

export async function getTransferStatus(
  transferId: string,
): Promise<TransferStatus> {
  const response = await axios
    .create({ url: 'https://MOCK-PROVIDER-URL.fake' })
    .get(`/transfer/${transferId}/status`)
  return response.data.status
}

Zod Schemas

For each type exported from this package there is also a corresponding zod schema with the name {typeWithFirstCharLowercase}Schema. So for example TransferStatus has transferStatusSchema.

import {
  TransferStatus,
  transferStatusSchema,
} from '@fiatconnect/fiatconnect-types'
import axios from 'axios'
import { z } from 'zod'

export async function getTransferStatus(
  transferId: string,
): Promise<TransferStatus> {
  const response = await axios
    .create({ url: 'https://MOCK-PROVIDER-URL.fake' })
    .get(`/transfer/${transferId}/status`)

  // Will throw an error if the status does not match the schema
  transferStatusSchema.parse(response.data.status)
  return response.data.status
}

Contributing