From 7e134495140f2710e1285d450f8efb66c4832e21 Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Sun, 17 Mar 2024 12:06:06 -0500 Subject: [PATCH] Update contract addresses file on deploy --- ethereum/package.json | 4 +++- ethereum/scripts/deploy.js | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ethereum/package.json b/ethereum/package.json index 48f9291..a070033 100644 --- a/ethereum/package.json +++ b/ethereum/package.json @@ -6,7 +6,9 @@ "scripts": { "test": "hardhat test", "automatic-staking-local": "hardhat run --network localhost scripts/automatic-staking.js", - "automatic-staking-sepolia": "hardhat run --network sepolia scripts/automatic-staking.js" + "automatic-staking-sepolia": "hardhat run --network sepolia scripts/automatic-staking.js", + "deploy-local": "hardhat run --network localhost scripts/deploy.js", + "deploy-sepolia": "hardhat run --network sepolia scripts/deploy.js" }, "author": "", "license": "ISC", diff --git a/ethereum/scripts/deploy.js b/ethereum/scripts/deploy.js index b53a67d..278f38e 100644 --- a/ethereum/scripts/deploy.js +++ b/ethereum/scripts/deploy.js @@ -3,6 +3,8 @@ const fs = require('fs'); const contractAddresses = require('../../contract-addresses.json'); +const contractAddressesWritePath = '../contract-addresses.json'; + const network = process.env.HARDHAT_NETWORK; async function main() { @@ -19,7 +21,8 @@ async function main() { console.log(`Work1 deployed to ${work1.target}`); contractAddresses[network].Work1 = work1.target; - fs.writeFileSync('../../contract-addresses.json', JSON.stringify(contractAddresses, null, 2)); + fs.writeFileSync(contractAddressesWritePath, JSON.stringify(contractAddresses, null, 2)); + console.log('Wrote file', fs.realpathSync(contractAddressesWritePath)); } // We recommend this pattern to be able to use async/await everywhere