export type ConsiderationObject = {asset_contract_address: string, token_id: string}; export type FulfillerObject = {address: string}; export type OfferObject = {chain: string, hash: string, protocol_address: string}; export type FullfillmentDataRequest = {consideration?: ConsiderationObject | undefined, fulfiller: FulfillerObject, include_optional_creator_fees?: (boolean | null) | undefined, offer: OfferObject, units_to_fill?: (number | null) | undefined}; export type CreateApiApiV2OffersFulfillmentDataArgs = {body: FullfillmentDataRequest}; export type CreateApiApiV2OffersFulfillmentDataOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Fulfill an offer * * POST /api/v2/offers/fulfillment_data */ export const createApiApiV2OffersFulfillmentData = async (args: CreateApiApiV2OffersFulfillmentDataArgs, options?: CreateApiApiV2OffersFulfillmentDataOptions) => { const {baseUrl = "https://api.opensea.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/offers/fulfillment_data${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };