[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>
This commit is contained in:
parent
a7383a3648
commit
5e44fa4c95
|
@ -55889,7 +55889,7 @@
|
||||||
},
|
},
|
||||||
"price_pusher": {
|
"price_pusher": {
|
||||||
"name": "@pythnetwork/price-pusher",
|
"name": "@pythnetwork/price-pusher",
|
||||||
"version": "5.3.1",
|
"version": "5.4.1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@injectivelabs/sdk-ts": "1.10.72",
|
"@injectivelabs/sdk-ts": "1.10.72",
|
||||||
|
@ -57320,7 +57320,7 @@
|
||||||
},
|
},
|
||||||
"price_service/client/js": {
|
"price_service/client/js": {
|
||||||
"name": "@pythnetwork/price-service-client",
|
"name": "@pythnetwork/price-service-client",
|
||||||
"version": "1.5.0",
|
"version": "1.6.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pythnetwork/price-service-sdk": "*",
|
"@pythnetwork/price-service-sdk": "*",
|
||||||
|
@ -57846,7 +57846,7 @@
|
||||||
},
|
},
|
||||||
"target_chains/aptos/sdk/js": {
|
"target_chains/aptos/sdk/js": {
|
||||||
"name": "@pythnetwork/pyth-aptos-js",
|
"name": "@pythnetwork/pyth-aptos-js",
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pythnetwork/price-service-client": "*",
|
"@pythnetwork/price-service-client": "*",
|
||||||
|
@ -57937,7 +57937,7 @@
|
||||||
},
|
},
|
||||||
"target_chains/cosmwasm/sdk/js": {
|
"target_chains/cosmwasm/sdk/js": {
|
||||||
"name": "@pythnetwork/pyth-terra-js",
|
"name": "@pythnetwork/pyth-terra-js",
|
||||||
"version": "1.2.0",
|
"version": "1.3.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pythnetwork/price-service-client": "*",
|
"@pythnetwork/price-service-client": "*",
|
||||||
|
@ -58980,7 +58980,7 @@
|
||||||
},
|
},
|
||||||
"target_chains/ethereum/sdk/js": {
|
"target_chains/ethereum/sdk/js": {
|
||||||
"name": "@pythnetwork/pyth-evm-js",
|
"name": "@pythnetwork/pyth-evm-js",
|
||||||
"version": "1.18.0",
|
"version": "1.19.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pythnetwork/price-service-client": "*",
|
"@pythnetwork/price-service-client": "*",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/price-service-client",
|
"name": "@pythnetwork/price-service-client",
|
||||||
"version": "1.5.0",
|
"version": "1.6.0",
|
||||||
"description": "Pyth price service client",
|
"description": "Pyth price service client",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Pyth Data Association"
|
"name": "Pyth Data Association"
|
||||||
|
|
|
@ -174,6 +174,32 @@ export class PriceServiceConnection {
|
||||||
return [response.data.vaa, response.data.publishTime];
|
return [response.data.vaa, response.data.publishTime];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the PriceFeed 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 publish time
|
||||||
|
* is old and the price service endpoint does not have a db backend for historical requests.
|
||||||
|
* 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)
|
||||||
|
*
|
||||||
|
* @param priceId Hex-encoded price id.
|
||||||
|
* @param publishTime Epoch timestamp in seconds.
|
||||||
|
* @returns PriceFeed
|
||||||
|
*/
|
||||||
|
async getPriceFeed(
|
||||||
|
priceId: HexString,
|
||||||
|
publishTime: EpochTimeStamp
|
||||||
|
): Promise<PriceFeed> {
|
||||||
|
const response = await this.httpClient.get("/api/get_price_feed", {
|
||||||
|
params: {
|
||||||
|
id: priceId,
|
||||||
|
publish_time: publishTime,
|
||||||
|
verbose: this.priceFeedRequestConfig.verbose,
|
||||||
|
binary: this.priceFeedRequestConfig.binary,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return PriceFeed.fromJson(response.data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the list of available price feed ids.
|
* 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.
|
* This will throw an axios error if there is a network problem or the price service returns a non-ok response.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/pyth-aptos-js",
|
"name": "@pythnetwork/pyth-aptos-js",
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"description": "Pyth Network Aptos Utilities",
|
"description": "Pyth Network Aptos Utilities",
|
||||||
"homepage": "https://pyth.network",
|
"homepage": "https://pyth.network",
|
||||||
"author": {
|
"author": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/pyth-terra-js",
|
"name": "@pythnetwork/pyth-terra-js",
|
||||||
"version": "1.2.0",
|
"version": "1.3.0",
|
||||||
"description": "Pyth Network Terra Utils in JS",
|
"description": "Pyth Network Terra Utils in JS",
|
||||||
"homepage": "https://pyth.network",
|
"homepage": "https://pyth.network",
|
||||||
"author": {
|
"author": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/pyth-evm-js",
|
"name": "@pythnetwork/pyth-evm-js",
|
||||||
"version": "1.18.0",
|
"version": "1.19.0",
|
||||||
"description": "Pyth Network EVM Utils in JS",
|
"description": "Pyth Network EVM Utils in JS",
|
||||||
"homepage": "https://pyth.network",
|
"homepage": "https://pyth.network",
|
||||||
"author": {
|
"author": {
|
||||||
|
|
Loading…
Reference in New Issue