UNPKG

@mysten/suins

Version:
35 lines (33 loc) 1.03 kB
import axios from "axios"; import axiosRetry from "axios-retry"; //#region src/pyth/PriceServiceConnection.ts var PriceServiceConnection = class { /** * Constructs a new Connection. * * @param endpoint endpoint URL to the price service. * @param config Optional configuration for custom setups. */ constructor(endpoint, config) { this.httpClient = axios.create({ baseURL: endpoint, timeout: (config === null || config === void 0 ? void 0 : config.timeout) || 5e3 }); axiosRetry(this.httpClient, { retries: (config === null || config === void 0 ? void 0 : config.httpRetries) || 3, retryDelay: axiosRetry.exponentialDelay }); } /** * Fetch latest VAAs of given price IDs. * * @param priceIds Array of hex-encoded price IDs. * @returns Array of base64 encoded VAAs. */ async getLatestVaas(priceIds) { return (await this.httpClient.get("/api/latest_vaas", { params: { ids: priceIds } })).data; } }; //#endregion export { PriceServiceConnection }; //# sourceMappingURL=PriceServiceConnection.mjs.map