export type Eip3009Fields = {caller_address?: string | undefined, chain_id?: number | undefined, from?: string | undefined, nonce?: string | undefined, signature?: string | undefined, to?: string | undefined, valid_after?: number | undefined, valid_before?: number | undefined, value?: number | undefined}; export type X402SettlementFields = {caller_address?: string | undefined, chain_id?: number | undefined, tx_hash?: string | undefined}; export type ToolUsageRequest = {eip3009?: Eip3009Fields | undefined, latency_ms?: number | undefined, tool_chain_id?: number | undefined, tool_endpoint?: string | undefined, tool_onchain_id?: number | undefined, tool_registry_address?: string | undefined, verification_type?: string | undefined, x402?: X402SettlementFields | undefined}; export type CreateApiApiV2ToolsUsageArgs = {body: ToolUsageRequest}; export type CreateApiApiV2ToolsUsageOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * [Beta] Report tool usage (metrics only) * * POST /api/v2/tools/usage */ export const createApiApiV2ToolsUsage = async (args: CreateApiApiV2ToolsUsageArgs, options?: CreateApiApiV2ToolsUsageOptions) => { 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/tools/usage${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() };