@hyperlane-xyz/sdk
Version:
The official SDK for the Hyperlane Network
27 lines • 1.02 kB
JavaScript
export class FeeQuotingClient {
baseUrl;
apiKey;
constructor(options) {
this.baseUrl = options.baseUrl.replace(/\/$/, '');
this.apiKey = options.apiKey;
}
async getQuote(params) {
const query = new URLSearchParams({
origin: params.origin,
router: params.router,
destination: String(params.destination),
salt: params.salt,
});
if (params.recipient)
query.set('recipient', params.recipient);
if (params.targetRouter)
query.set('targetRouter', params.targetRouter);
const res = await fetch(`${this.baseUrl}/quote/${params.command}?${query}`, { headers: { Authorization: `Bearer ${this.apiKey}` } });
if (!res.ok) {
const body = await res.json().catch(() => ({}));
throw new Error(`Fee quoting request failed (${res.status}): ${body.message ?? res.statusText}`);
}
return res.json();
}
}
//# sourceMappingURL=client.js.map