From e3418e33123741a1e557c74fc458c97c2b3c444e Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Tue, 8 Oct 2024 16:11:30 -0400 Subject: [PATCH] write file --- scripts/transactions/mainPackageUpgrade.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/transactions/mainPackageUpgrade.ts b/scripts/transactions/mainPackageUpgrade.ts index 20a74b06..d7c4a7e3 100644 --- a/scripts/transactions/mainPackageUpgrade.ts +++ b/scripts/transactions/mainPackageUpgrade.ts @@ -4,6 +4,7 @@ import { execSync } from 'child_process'; import { upgradeCapID } from '../config/constants'; import path from 'path'; +import fs from 'fs'; const network = 'mainnet'; @@ -23,8 +24,11 @@ const mainPackageUpgrade = async () => { const upgradeCall = `sui client upgrade --upgrade-capability ${upgradeCapID[network]} --gas-budget 3000000000 --gas ${gasObjectId} --skip-dependency-verification --serialize-unsigned-transaction`; try { - // Execute the command with the absolute path - execSync(`cd ${packagesDir} && ${upgradeCall} > ${txFilePath}`); + // Execute the command with the specified working directory and capture the output + const output = execSync(upgradeCall, { cwd: packagesDir }); + + // Write the output to the tx-data.txt file + fs.writeFileSync(txFilePath, output.toString()); console.log('Upgrade transaction successfully created and saved to tx-data.txt'); } catch (error: any) { console.error('Error during protocol upgrade:', error.message);