@pythnetwork/pyth-sui-js
Version:
Pyth Network Sui Utilities
22 lines (21 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SuiPriceServiceConnection = void 0;
const price_service_client_1 = require("@pythnetwork/price-service-client");
const buffer_1 = require("buffer");
class SuiPriceServiceConnection extends price_service_client_1.PriceServiceConnection {
/**
* Gets price update data (either batch price attestation VAAs or accumulator messages, depending on the chosen endpoint), which then
* can be submitted to the Pyth contract to update the prices. This will throw an axios error if there is a network problem or
* the price service returns a non-ok response (e.g: Invalid price ids)
*
* @param priceIds Array of hex-encoded price ids.
* @returns Array of buffers containing the price update data.
*/
async getPriceFeedsUpdateData(priceIds) {
// Fetch the latest price feed update VAAs from the price service
const latestVaas = await this.getLatestVaas(priceIds);
return latestVaas.map((vaa) => buffer_1.Buffer.from(vaa, "base64"));
}
}
exports.SuiPriceServiceConnection = SuiPriceServiceConnection;