Skip to content

Commit 4281908

Browse files
committed
comments
1 parent 1ca310e commit 4281908

File tree

6 files changed

+39
-34
lines changed

6 files changed

+39
-34
lines changed

pnpm-lock.yaml

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

target_chains/solana/sdk/js/pyth_solana_receiver/examples/post_price_update.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
2-
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
32
import { InstructionWithEphemeralSigners, PythSolanaReceiver } from "../";
43
import { Wallet } from "@coral-xyz/anchor";
54
import fs from "fs";
65
import os from "os";
6+
import { HermesClient } from "@pythnetwork/hermes-client";
77

88
// Get price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
99
const SOL_PRICE_FEED_ID =
@@ -67,15 +67,17 @@ async function main() {
6767

6868
// Fetch price update data from Hermes
6969
async function getPriceUpdateData() {
70-
const priceServiceConnection = new PriceServiceConnection(
70+
const priceServiceConnection = new HermesClient(
7171
"https://hermes.pyth.network/",
72-
{ priceFeedRequestConfig: { binary: true } }
72+
{}
7373
);
7474

75-
return await priceServiceConnection.getLatestVaas([
76-
SOL_PRICE_FEED_ID,
77-
ETH_PRICE_FEED_ID,
78-
]);
75+
const response = await priceServiceConnection.getLatestPriceUpdates(
76+
[SOL_PRICE_FEED_ID, ETH_PRICE_FEED_ID],
77+
{ encoding: "base64" }
78+
);
79+
80+
return response.binary.data;
7981
}
8082

8183
// Load a solana keypair from an id.json file

target_chains/solana/sdk/js/pyth_solana_receiver/examples/post_price_update_from_benchmarks.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
2-
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
2+
import { HermesClient, PriceUpdate } from "@pythnetwork/hermes-client";
33
import { InstructionWithEphemeralSigners, PythSolanaReceiver } from "../";
44
import { Wallet } from "@coral-xyz/anchor";
55
import fs from "fs";
@@ -64,17 +64,16 @@ async function main() {
6464
}
6565

6666
// Fetch price update data from Hermes
67-
async function getPriceUpdateDataFromOneDayAgo() {
68-
const priceServiceConnection = new PriceServiceConnection(
69-
"https://hermes.pyth.network/",
70-
{ priceFeedRequestConfig: { binary: true } }
71-
);
67+
async function getPriceUpdateDataFromOneDayAgo(): Promise<string[]> {
68+
const hermesClient = new HermesClient("https://hermes.pyth.network/", {});
7269

7370
const oneDayAgo = Math.floor(Date.now() / 1000) - 86400;
74-
75-
return [
76-
(await priceServiceConnection.getVaa(SOL_PRICE_FEED_ID, oneDayAgo))[0],
77-
];
71+
const response = await hermesClient.getPriceUpdatesAtTimestamp(
72+
oneDayAgo,
73+
[SOL_PRICE_FEED_ID],
74+
{ encoding: "base64" }
75+
);
76+
return response.binary.data;
7877
}
7978

8079
// Load a solana keypair from an id.json file

target_chains/solana/sdk/js/pyth_solana_receiver/examples/post_price_update_instructions.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Connection, Keypair } from "@solana/web3.js";
2-
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
32
import { InstructionWithEphemeralSigners, PythSolanaReceiver } from "../";
43
import { Wallet } from "@coral-xyz/anchor";
54
import fs from "fs";
65
import os from "os";
6+
import { HermesClient } from "@pythnetwork/hermes-client";
77

88
// Get price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
99
const SOL_PRICE_FEED_ID =
@@ -58,15 +58,17 @@ async function main() {
5858

5959
// Fetch price update data from Hermes
6060
async function getPriceUpdateData() {
61-
const priceServiceConnection = new PriceServiceConnection(
61+
const priceServiceConnection = new HermesClient(
6262
"https://hermes.pyth.network/",
63-
{ priceFeedRequestConfig: { binary: true } }
63+
{}
6464
);
6565

66-
return await priceServiceConnection.getLatestVaas([
67-
SOL_PRICE_FEED_ID,
68-
ETH_PRICE_FEED_ID,
69-
]);
66+
const response = await priceServiceConnection.getLatestPriceUpdates(
67+
[SOL_PRICE_FEED_ID, ETH_PRICE_FEED_ID],
68+
{ encoding: "base64" }
69+
);
70+
71+
return response.binary.data;
7072
}
7173

7274
// Load a solana keypair from an id.json file

target_chains/solana/sdk/js/pyth_solana_receiver/examples/update_price_feed.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
2-
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
32
import { InstructionWithEphemeralSigners, PythSolanaReceiver } from "../";
43
import { Wallet } from "@coral-xyz/anchor";
54
import fs from "fs";
65
import os from "os";
6+
import { HermesClient } from "@pythnetwork/hermes-client";
77

88
// Get price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
99
const SOL_PRICE_FEED_ID =
@@ -67,15 +67,17 @@ async function main() {
6767

6868
// Fetch price update data from Hermes
6969
async function getPriceUpdateData() {
70-
const priceServiceConnection = new PriceServiceConnection(
70+
const priceServiceConnection = new HermesClient(
7171
"https://hermes.pyth.network/",
72-
{ priceFeedRequestConfig: { binary: true } }
72+
{}
7373
);
7474

75-
return await priceServiceConnection.getLatestVaas([
76-
SOL_PRICE_FEED_ID,
77-
ETH_PRICE_FEED_ID,
78-
]);
75+
const response = await priceServiceConnection.getLatestPriceUpdates(
76+
[SOL_PRICE_FEED_ID, ETH_PRICE_FEED_ID],
77+
{ encoding: "base64" }
78+
);
79+
80+
return response.binary.data;
7981
}
8082

8183
// Load a solana keypair from an id.json file

target_chains/solana/sdk/js/pyth_solana_receiver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
],
3131
"license": "Apache-2.0",
3232
"devDependencies": {
33-
"@pythnetwork/price-service-client": "workspace:*",
33+
"@pythnetwork/hermes-client": "workspace:*",
3434
"@types/jest": "^29.4.0",
3535
"@typescript-eslint/eslint-plugin": "^5.20.0",
3636
"@typescript-eslint/parser": "^5.20.0",

0 commit comments

Comments
 (0)