Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyth-common-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyth-common-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/pyth-common-js",
"version": "1.3.0",
"version": "1.4.0",
"description": "Pyth Network Common Utils in JS",
"author": {
"name": "Pyth Data Association"
Expand Down
24 changes: 24 additions & 0 deletions pyth-common-js/src/PriceServiceConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,30 @@ export class PriceServiceConnection {
return response.data;
}

/**
* Fetch the earliest VAA of the given price id that is published since the given publish time.
* This will throw an error if the given publish time is in the future, or if the price service does not have a db backend.
* 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 id)
*
* This function is coupled to wormhole implemntation.
*
* @param priceId Hex-encoded price id.
* @param publishTime Epoch timestamp in seconds.
* @returns Tuple of VAA and publishTime.
*/
async getVaa(
priceId: HexString,
publishTime: EpochTimeStamp
): Promise<[string, EpochTimeStamp]> {
const response = await this.httpClient.get("/api/get_vaa", {
params: {
id: priceId,
publish_time: publishTime,
},
});
return [response.data.vaa, response.data.publishTime];
}

/**
* Fetch the list of available price feed ids.
* This will throw an axios error if there is a network problem or the price service returns a non-ok response.
Expand Down