Quellcode durchsuchen

feat(pyth-sui-js): Migrate from price-service-client to hermes-client

Mike Rolish vor 1 Monat
Ursprung
Commit
af5f06505c

+ 2 - 2
pnpm-lock.yaml

@@ -3185,9 +3185,9 @@ importers:
       '@mysten/sui':
         specifier: ^1.3.0
         version: 1.26.1(typescript@5.8.2)
-      '@pythnetwork/price-service-client':
+      '@pythnetwork/hermes-client':
         specifier: workspace:*
-        version: link:../../../../price_service/client/js
+        version: link:../../../../apps/hermes/client/js
       buffer:
         specifier: ^6.0.3
         version: 6.0.3

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

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/pyth-sui-js",
-  "version": "2.2.0",
+  "version": "2.3.0",
   "description": "Pyth Network Sui Utilities",
   "homepage": "https://pyth.network",
   "author": {
@@ -55,7 +55,7 @@
   },
   "dependencies": {
     "@mysten/sui": "^1.3.0",
-    "@pythnetwork/price-service-client": "workspace:*",
+    "@pythnetwork/hermes-client": "workspace:*",
     "buffer": "^6.0.3"
   }
 }

+ 7 - 6
target_chains/sui/sdk/js/src/SuiPriceServiceConnection.ts

@@ -1,10 +1,11 @@
 import {
-  PriceServiceConnection,
-  HexString,
-} from "@pythnetwork/price-service-client";
+    HermesClient,
+    HexString,
+    PriceUpdate,
+} from "@pythnetwork/hermes-client";
 import { Buffer } from "buffer";
 
-export class SuiPriceServiceConnection extends PriceServiceConnection {
+export class SuiPriceServiceConnection extends HermesClient {
   /**
    * Gets price update data (either batch price attestation VAAs or accumulator messages, depending on the chosen endpoint), which then
    * can be submitted to the Pyth contract to update the prices. This will throw an axios error if there is a network problem or
@@ -15,7 +16,7 @@ export class SuiPriceServiceConnection extends PriceServiceConnection {
    */
   async getPriceFeedsUpdateData(priceIds: HexString[]): Promise<Buffer[]> {
     // Fetch the latest price feed update VAAs from the price service
-    const latestVaas = await this.getLatestVaas(priceIds);
-    return latestVaas.map((vaa) => Buffer.from(vaa, "base64"));
+    const latestVaas: PriceUpdate = await this.getLatestPriceUpdates(priceIds, { encoding: "base64", parsed: false });
+    return latestVaas.binary.data.map((vaa) => Buffer.from(vaa, "base64"));
   }
 }

+ 1 - 1
target_chains/sui/sdk/js/src/client.ts

@@ -2,7 +2,7 @@ import { SuiClient } from "@mysten/sui/client";
 import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
 import { Transaction } from "@mysten/sui/transactions";
 import { bcs } from "@mysten/sui/bcs";
-import { HexString } from "@pythnetwork/price-service-client";
+import { HexString } from "@pythnetwork/hermes-client";
 import { Buffer } from "buffer";
 
 const MAX_ARGUMENT_SIZE = 16 * 1024;

+ 11 - 4
target_chains/sui/sdk/js/src/index.ts

@@ -2,10 +2,17 @@ export { SuiPriceServiceConnection } from "./SuiPriceServiceConnection";
 export { SuiPythClient } from "./client";
 
 export {
+  AssetType,
+  BinaryPriceUpdate,
   DurationInMs,
+  DurationInSeconds,
+  EncodingType,
+  HermesClientConfig,
   HexString,
-  Price,
-  PriceFeed,
-  PriceServiceConnectionConfig,
+  PriceFeedMetadata,
+  PriceIdInput,
+  PriceUpdate,
+  PublisherCaps,
+  TwapsResponse,
   UnixTimestamp,
-} from "@pythnetwork/price-service-client";
+} from "@pythnetwork/hermes-client";