浏览代码

feat(price-service/sdk): add prev_publish_time metadata

Ali Behjati 2 年之前
父节点
当前提交
65ecd890ae

+ 6 - 6
package-lock.json

@@ -57438,7 +57438,7 @@
     },
     "price_service/client/js": {
       "name": "@pythnetwork/price-service-client",
-      "version": "1.7.0",
+      "version": "1.8.0",
       "license": "Apache-2.0",
       "dependencies": {
         "@pythnetwork/price-service-sdk": "*",
@@ -57528,7 +57528,7 @@
     },
     "price_service/sdk/js": {
       "name": "@pythnetwork/price-service-sdk",
-      "version": "1.3.0",
+      "version": "1.4.0",
       "license": "Apache-2.0",
       "devDependencies": {
         "@types/jest": "^29.4.0",
@@ -57964,7 +57964,7 @@
     },
     "target_chains/aptos/sdk/js": {
       "name": "@pythnetwork/pyth-aptos-js",
-      "version": "1.3.0",
+      "version": "1.4.0",
       "license": "Apache-2.0",
       "dependencies": {
         "@pythnetwork/price-service-client": "*",
@@ -58133,7 +58133,7 @@
     },
     "target_chains/cosmwasm/sdk/js": {
       "name": "@pythnetwork/pyth-terra-js",
-      "version": "1.4.0",
+      "version": "1.5.0",
       "license": "Apache-2.0",
       "dependencies": {
         "@pythnetwork/price-service-client": "*",
@@ -59547,7 +59547,7 @@
     },
     "target_chains/ethereum/sdk/js": {
       "name": "@pythnetwork/pyth-evm-js",
-      "version": "1.28.0",
+      "version": "1.29.0",
       "license": "Apache-2.0",
       "dependencies": {
         "@pythnetwork/price-service-client": "*",
@@ -59678,7 +59678,7 @@
     },
     "target_chains/sui/sdk/js": {
       "name": "@pythnetwork/pyth-sui-js",
-      "version": "1.1.0",
+      "version": "1.2.0",
       "license": "Apache-2.0",
       "dependencies": {
         "@mysten/sui.js": "^0.37.1",

+ 1 - 1
price_service/client/js/package.json

@@ -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"

+ 1 - 1
price_service/sdk/js/package.json

@@ -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",

+ 8 - 0
price_service/sdk/js/src/index.ts

@@ -100,6 +100,10 @@ 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;
@@ -107,12 +111,14 @@ export class PriceFeedMetadata {
     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 {
@@ -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,
     });
   }
 
@@ -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);

+ 9 - 0
price_service/sdk/js/src/schemas/PriceFeed.ts

@@ -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
    */
@@ -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",

+ 5 - 0
price_service/sdk/js/src/schemas/price_feed.json

@@ -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"
         }
       }
     }

+ 1 - 1
target_chains/aptos/sdk/js/package.json

@@ -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": {

+ 1 - 1
target_chains/cosmwasm/sdk/js/package.json

@@ -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": {

+ 1 - 1
target_chains/ethereum/sdk/js/package.json

@@ -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": {

+ 1 - 1
target_chains/sui/sdk/js/package.json

@@ -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": {

+ 3 - 4
target_chains/sui/sdk/js/src/examples/SuiRelay.ts

@@ -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,
   })
@@ -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);