import { AxiosInstance } from "axios" ; import FormData from 'form-data' ; import { assertExists } from "." ; export type AddToIpfs = ( value : string ) => Promise < string > ; export default function provideAddToIpfs ( ipfsHttpClient ) { assertExists ( ipfsHttpClient , 'ipfsHttpClient' ) ; return async function addToIpfs ( value ) { const formData = new FormData ( ) ; formData . append ( 'value' , value ) ; const { data } = await ipfsHttpClient . post ( '/api/v0/add' , formData , { headers : formData . getHeaders ( ) } ) ; return data . Hash ; } ; }