Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya520 committed Oct 24, 2024
1 parent 5730540 commit 96e89b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions contract_manager/scripts/update_all_pricefeeds.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import {
HermesClient,
PriceFeedMetadata,
} from "@pythnetwork/hermes-client";
import { HermesClient, PriceFeedMetadata } from "@pythnetwork/hermes-client";
import { DefaultStore, toPrivateKey } from "../src";

const parser = yargs(hideBin(process.argv))
Expand All @@ -20,21 +17,22 @@ const parser = yargs(hideBin(process.argv))
desc: "Contract to update price feeds for (e.g mumbai_0xff1a0f4744e8582DF1aE09D5611b887B6a12925C)",
},
endpoint: {
type: "string",
desc: "Hermes endpoint to use, defaults to https://hermes.pyth.network",
},
type: "string",
desc: "Hermes endpoint to use, defaults to https://hermes.pyth.network",
},
});

// This script is intended to update all pricefeeds after we deploy pyth pricefeeds contract.
// It will fetch all pricefeeds from hermes and update the pricefeeds contract with the new pricefeeds.
async function main() {
const argv = await parser.argv;
let priceFeedsMetadata: PriceFeedMetadata[] = [];
const client = new HermesClient(argv.endpoint || "https://hermes.pyth.network");
const client = new HermesClient(
argv.endpoint || "https://hermes.pyth.network"
);
const contract = DefaultStore.contracts[argv.contract];
const privateKey = toPrivateKey(argv["private-key"]);


priceFeedsMetadata = await client.getPriceFeeds();

const priceFeedIds = priceFeedsMetadata.map((feed) => feed.id);
Expand All @@ -45,17 +43,17 @@ async function main() {
const chunkSize = 150;
for (let i = 0; i < priceFeedIds.length; i += chunkSize) {
const chunk = priceFeedIds.slice(i, i + chunkSize);
console.log(`length: ${chunk.length}`)
console.log(`length: ${chunk.length}`);
const updates = await client.getLatestPriceUpdates(chunk, {
parsed: false,
});
console.log(
await contract.executeUpdatePriceFeed(
privateKey,
updates.binary.data.map(update => Buffer.from(update, 'hex'))
updates.binary.data.map((update) => Buffer.from(update, "hex"))
)
);
}
}

main();
main();
2 changes: 1 addition & 1 deletion contract_manager/store/chains/EvmChains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -748,4 +748,4 @@
mainnet: true
rpcUrl: https://rpc.morphl2.io
networkId: 2818
type: EvmChain
type: EvmChain

0 comments on commit 96e89b3

Please sign in to comment.