Skip to content

Commit 5e44fa4

Browse files
lvn-ryuali-behjati
andauthored
[price_service] js client: getPriceFeed() (#922)
* [price_service] js client: getPriceFeed() * Fix pre-commit * Bump package versions --------- Co-authored-by: Ali Behjati <bahjatia@gmail.com>
1 parent a7383a3 commit 5e44fa4

File tree

6 files changed

+35
-9
lines changed

6 files changed

+35
-9
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

price_service/client/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/price-service-client",
3-
"version": "1.5.0",
3+
"version": "1.6.0",
44
"description": "Pyth price service client",
55
"author": {
66
"name": "Pyth Data Association"

price_service/client/js/src/PriceServiceConnection.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,32 @@ export class PriceServiceConnection {
174174
return [response.data.vaa, response.data.publishTime];
175175
}
176176

177+
/**
178+
* Fetch the PriceFeed of the given price id that is published since the given publish time.
179+
* This will throw an error if the given publish time is in the future, or if the publish time
180+
* is old and the price service endpoint does not have a db backend for historical requests.
181+
* 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)
182+
*
183+
* @param priceId Hex-encoded price id.
184+
* @param publishTime Epoch timestamp in seconds.
185+
* @returns PriceFeed
186+
*/
187+
async getPriceFeed(
188+
priceId: HexString,
189+
publishTime: EpochTimeStamp
190+
): Promise<PriceFeed> {
191+
const response = await this.httpClient.get("/api/get_price_feed", {
192+
params: {
193+
id: priceId,
194+
publish_time: publishTime,
195+
verbose: this.priceFeedRequestConfig.verbose,
196+
binary: this.priceFeedRequestConfig.binary,
197+
},
198+
});
199+
200+
return PriceFeed.fromJson(response.data);
201+
}
202+
177203
/**
178204
* Fetch the list of available price feed ids.
179205
* This will throw an axios error if there is a network problem or the price service returns a non-ok response.

target_chains/aptos/sdk/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-aptos-js",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Pyth Network Aptos Utilities",
55
"homepage": "https://pyth.network",
66
"author": {

target_chains/cosmwasm/sdk/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-terra-js",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "Pyth Network Terra Utils in JS",
55
"homepage": "https://pyth.network",
66
"author": {

target_chains/ethereum/sdk/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-evm-js",
3-
"version": "1.18.0",
3+
"version": "1.19.0",
44
"description": "Pyth Network EVM Utils in JS",
55
"homepage": "https://pyth.network",
66
"author": {

0 commit comments

Comments
 (0)