UNPKG

@robertprp/intents-sdk

Version:

Shogun Network Intent-based cross-chain swaps SDK

34 lines (26 loc) 834 B
import { AUCTIONEER_URL } from '../../../constants.js'; import type { ApiResponse, ApiUserOrders } from '../../../types/api.js'; export class AuctioneerAPI { public aggregatedToken: string; constructor(aggregatedToken: string) { this.aggregatedToken = aggregatedToken; } public extend(token: string) { this.aggregatedToken = token; } public async getUserOrders() { const url = `${AUCTIONEER_URL}/user_intent`; const response = await fetch(url, { method: 'GET', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${this.aggregatedToken}`, }, }); const data: ApiResponse<ApiUserOrders> = await response.json(); if (!data.success) { throw new Error(`Failed to fetch user orders: ${data.error}`); } return data.data!; } }