From 38c135048d1ea219128cef44d5899ccc260e4de4 Mon Sep 17 00:00:00 2001 From: nidhi-singh02 Date: Mon, 1 Sep 2025 15:32:25 +0400 Subject: [PATCH 1/3] moved batch deploy receiver to contract_manager --- .../scripts/batchDeployReceivers.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) rename {target_chains/ethereum/contracts => contract_manager}/scripts/batchDeployReceivers.ts (93%) diff --git a/target_chains/ethereum/contracts/scripts/batchDeployReceivers.ts b/contract_manager/scripts/batchDeployReceivers.ts similarity index 93% rename from target_chains/ethereum/contracts/scripts/batchDeployReceivers.ts rename to contract_manager/scripts/batchDeployReceivers.ts index 463232dc7c..e39df019b7 100644 --- a/target_chains/ethereum/contracts/scripts/batchDeployReceivers.ts +++ b/contract_manager/scripts/batchDeployReceivers.ts @@ -15,7 +15,7 @@ import Web3 from "web3"; import { CHAINS } from "@pythnetwork/xc-admin-common"; import * as fs from "fs"; -const { getDefaultConfig } = require("./contractManagerConfig"); +const { getDefaultConfig } = require("../../target_chains/ethereum/contracts/scripts/contractManagerConfig"); const parser = yargs(hideBin(process.argv)) .usage( @@ -46,7 +46,14 @@ const parser = yargs(hideBin(process.argv)) }); async function memoize(key: string, fn: () => Promise) { - const path = `./cache/${key}.json`; + const cacheDir = './cache'; + const path = `${cacheDir}/${key}.json`; + + // Ensure cache directory exists + if (!fs.existsSync(cacheDir)) { + fs.mkdirSync(cacheDir, { recursive: true }); + } + if (fs.existsSync(path)) { return JSON.parse(fs.readFileSync(path).toString()); } From cceb340416342f38c5dc8f91b99094b8fe126037 Mon Sep 17 00:00:00 2001 From: nidhi-singh02 Date: Mon, 1 Sep 2025 15:46:07 +0400 Subject: [PATCH 2/3] correct cache path --- contract_manager/scripts/batchDeployReceivers.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/contract_manager/scripts/batchDeployReceivers.ts b/contract_manager/scripts/batchDeployReceivers.ts index e39df019b7..6daa5b50dd 100644 --- a/contract_manager/scripts/batchDeployReceivers.ts +++ b/contract_manager/scripts/batchDeployReceivers.ts @@ -46,14 +46,9 @@ const parser = yargs(hideBin(process.argv)) }); async function memoize(key: string, fn: () => Promise) { - const cacheDir = './cache'; + const cacheDir = '../../target_chains/ethereum/contracts/cache'; const path = `${cacheDir}/${key}.json`; - // Ensure cache directory exists - if (!fs.existsSync(cacheDir)) { - fs.mkdirSync(cacheDir, { recursive: true }); - } - if (fs.existsSync(path)) { return JSON.parse(fs.readFileSync(path).toString()); } From 72f51a4d0731de301da31fe82e91a4deba7e4faf Mon Sep 17 00:00:00 2001 From: nidhi-singh02 Date: Mon, 1 Sep 2025 16:08:50 +0400 Subject: [PATCH 3/3] formating fix --- .../scripts/batchDeployReceivers.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/contract_manager/scripts/batchDeployReceivers.ts b/contract_manager/scripts/batchDeployReceivers.ts index 6daa5b50dd..73f65cfd4e 100644 --- a/contract_manager/scripts/batchDeployReceivers.ts +++ b/contract_manager/scripts/batchDeployReceivers.ts @@ -15,7 +15,7 @@ import Web3 from "web3"; import { CHAINS } from "@pythnetwork/xc-admin-common"; import * as fs from "fs"; -const { getDefaultConfig } = require("../../target_chains/ethereum/contracts/scripts/contractManagerConfig"); +import { getDefaultConfig } from "../../target_chains/ethereum/contracts/scripts/contractManagerConfig"; const parser = yargs(hideBin(process.argv)) .usage( @@ -45,10 +45,13 @@ const parser = yargs(hideBin(process.argv)) }, }); -async function memoize(key: string, fn: () => Promise) { - const cacheDir = '../../target_chains/ethereum/contracts/cache'; +async function memoize( + key: string, + fn: () => Promise, +): Promise { + const cacheDir = "../../target_chains/ethereum/contracts/cache"; const path = `${cacheDir}/${key}.json`; - + if (fs.existsSync(path)) { return JSON.parse(fs.readFileSync(path).toString()); } @@ -61,11 +64,14 @@ async function main() { const argv = await parser.argv; const privateKey = argv["private-key"]; const network = argv["network"]; - const setupInfo = require(argv["contract"] + "/ReceiverSetup.json"); - const implementationInfo = require( - argv["contract"] + "/ReceiverImplementation.json", + + const setupInfo = await import(argv["contract"] + "/ReceiverSetup.json"); + const implementationInfo = await import( + argv["contract"] + "/ReceiverImplementation.json" + ); + const receiverInfo = await import( + argv["contract"] + "/WormholeReceiver.json" ); - const receiverInfo = require(argv["contract"] + "/WormholeReceiver.json"); const payloads: Buffer[] = []; for (const chain of Object.values(DefaultStore.chains)) {