@onelabs/suins
Version:
39 lines (38 loc) • 973 B
JavaScript
import axios from "axios";
import axiosRetry from "axios-retry";
class PriceServiceConnection {
/**
* 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?.timeout || 5e3
});
axiosRetry(this.httpClient, {
retries: 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) {
const response = await this.httpClient.get("/api/latest_vaas", {
params: {
ids: priceIds
}
});
return response.data;
}
}
export {
PriceServiceConnection
};
//# sourceMappingURL=PriceServiceConnection.js.map