Skip to content

Commit

Permalink
feat(price-service/sdk): add prev_publish_time metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati committed Sep 22, 2023
1 parent f533106 commit 65ecd89
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 16 deletions.
12 changes: 6 additions & 6 deletions 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 price_service/client/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/price-service-client",
"version": "1.7.0",
"version": "1.8.0",
"description": "Pyth price service client",
"author": {
"name": "Pyth Data Association"
Expand Down
2 changes: 1 addition & 1 deletion price_service/sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/price-service-sdk",
"version": "1.3.0",
"version": "1.4.0",
"description": "Pyth price service SDK",
"homepage": "https://pyth.network",
"main": "lib/index.js",
Expand Down
8 changes: 8 additions & 0 deletions price_service/sdk/js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,25 @@ export class PriceFeedMetadata {
* Pythnet slot number of the price
*/
slot?: number;
/**
* The time that the previous price was published
*/
prevPublishTime?: number;

constructor(metadata: {
attestationTime?: number;
emitterChain: number;
receiveTime?: number;
sequenceNumber?: number;
slot?: number;
prevPublishTime?: number;
}) {
this.attestationTime = metadata.attestationTime;
this.emitterChain = metadata.emitterChain;
this.priceServiceReceiveTime = metadata.receiveTime;
this.sequenceNumber = metadata.sequenceNumber;
this.slot = metadata.slot;
this.prevPublishTime = metadata.prevPublishTime;
}

static fromJson(json: any): PriceFeedMetadata | undefined {
Expand All @@ -126,6 +132,7 @@ export class PriceFeedMetadata {
receiveTime: jsonFeed.price_service_receive_time,
sequenceNumber: jsonFeed.sequence_number,
slot: jsonFeed.slot,
prevPublishTime: jsonFeed.prev_publish_time,
});
}

Expand All @@ -136,6 +143,7 @@ export class PriceFeedMetadata {
price_service_receive_time: this.priceServiceReceiveTime,
sequence_number: this.sequenceNumber,
slot: this.slot,
prev_publish_time: this.prevPublishTime,
};
// this is done to avoid sending undefined values to the server
return Convert.priceFeedMetadataToJson(jsonFeed);
Expand Down
9 changes: 9 additions & 0 deletions price_service/sdk/js/src/schemas/PriceFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export interface PriceFeedMetadata {
* Chain of the emitter
*/
emitter_chain: number;
/**
* The time that the previous price was published
*/
prev_publish_time?: number;
/**
* The time that the price service received the price
*/
Expand Down Expand Up @@ -294,6 +298,11 @@ const typeMap: any = {
typ: u(undefined, 0),
},
{ json: "emitter_chain", js: "emitter_chain", typ: 0 },
{
json: "prev_publish_time",
js: "prev_publish_time",
typ: u(undefined, 0),
},
{
json: "price_service_receive_time",
js: "price_service_receive_time",
Expand Down
5 changes: 5 additions & 0 deletions price_service/sdk/js/src/schemas/price_feed.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
"description": "Pythnet slot number of the price",
"type": "integer",
"format": "int64"
},
"prev_publish_time": {
"description": "The time that the previous price was published",
"type": "integer",
"format": "int64"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion target_chains/aptos/sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/pyth-aptos-js",
"version": "1.3.0",
"version": "1.4.0",
"description": "Pyth Network Aptos Utilities",
"homepage": "https://pyth.network",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion target_chains/cosmwasm/sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/pyth-terra-js",
"version": "1.4.0",
"version": "1.5.0",
"description": "Pyth Network Terra Utils in JS",
"homepage": "https://pyth.network",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion target_chains/ethereum/sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/pyth-evm-js",
"version": "1.28.0",
"version": "1.29.0",
"description": "Pyth Network EVM Utils in JS",
"homepage": "https://pyth.network",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion target_chains/sui/sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/pyth-sui-js",
"version": "1.1.0",
"version": "1.2.0",
"description": "Pyth Network Sui Utilities",
"homepage": "https://pyth.network",
"author": {
Expand Down
7 changes: 3 additions & 4 deletions target_chains/sui/sdk/js/src/examples/SuiRelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ const argvPromise = yargs(hideBin(process.argv))
type: "array",
demandOption: true,
})
.option("price-service", {
description:
"Endpoint URL for the price service. e.g: https://xc-mainnet.pyth.network",
.option("hermes", {
description: "Endpoint URL for Hermes. e.g: https://hermes.pyth.network",
type: "string",
demandOption: true,
})
Expand Down Expand Up @@ -52,7 +51,7 @@ async function run() {
const argv = await argvPromise;

// Fetch the latest price feed update data from the Price Service
const connection = new SuiPriceServiceConnection(argv["price-service"]);
const connection = new SuiPriceServiceConnection(argv["hermes"]);
const feeds = argv["feed-id"] as string[];
const priceFeedUpdateData = await connection.getPriceFeedsUpdateData(feeds);

Expand Down

0 comments on commit 65ecd89

Please sign in to comment.