From fa4ede8fbcec105cba4b9689bb5f6e76b7653b98 Mon Sep 17 00:00:00 2001 From: Moon Date: Sat, 19 Aug 2023 23:19:59 -0400 Subject: [PATCH] setup stuff --- hardhat.config.ts | 3 ++- scripts/deploy-base.ts | 18 ++++++++++++------ scripts/deploy-eth.ts | 6 +++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index c69ff51..91457b3 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -1,7 +1,8 @@ import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox"; import "hardhat-contract-sizer"; -import "dotenv/config"; +import dotenv from "dotenv"; +dotenv.config({ path: `.env.${process.env.NODE_ENV || "local"}` }); const config: HardhatUserConfig = { solidity: { diff --git a/scripts/deploy-base.ts b/scripts/deploy-base.ts index ea2431e..2a58fac 100644 --- a/scripts/deploy-base.ts +++ b/scripts/deploy-base.ts @@ -1,21 +1,27 @@ import { ethers } from "hardhat"; -import "dotenv/config"; +import fs from "fs/promises"; +import dotenv from "dotenv"; +const env = process.env.NODE_ENV || "local"; +dotenv.config({ path: `.env.${env}` }); async function main() { - if (!process.env.BRIDGE_ADDRESS) throw "Bridge address not defined"; - if (!process.env.ETH_TOKEN) throw "10grans Ethereum token address not defined"; + if (!process.env.BASE_BRIDGE_ADDRESS) throw "Bridge address not defined"; + const tenGransAddress = (await fs.readFile(`.10grans-eth-address.${env}`, "utf-8")).trim(); const TENGRANS = await ethers.deployContract( "TenGransBaseToken", [ - process.env.BRIDGE_ADDRESS, - process.env.ETH_TOKEN + process.env.BASE_BRIDGE_ADDRESS, + tenGransAddress ] ); await TENGRANS.waitForDeployment(); + const deployedAddress = await TENGRANS.getAddress(); - console.log(`Base 10grans deployed to: ${TENGRANS.target}`); + console.log(`Base 10grans deployed to: ${deployedAddress}`); + await fs.writeFile(`.10grans-base-address.${env}`, deployedAddress); + } // We recommend this pattern to be able to use async/await everywhere diff --git a/scripts/deploy-eth.ts b/scripts/deploy-eth.ts index ad5b1b6..1bd128d 100644 --- a/scripts/deploy-eth.ts +++ b/scripts/deploy-eth.ts @@ -1,11 +1,15 @@ import { ethers } from "hardhat"; +import fs from "fs/promises"; +const env = process.env.NODE_ENV || "local"; async function main() { const TENGRANS = await ethers.deployContract("TenGransEthToken"); await TENGRANS.waitForDeployment(); + const deployedAddress = await TENGRANS.getAddress(); - console.log(`Ethereum 10grans deployed to: ${TENGRANS.target}`); + console.log(`Ethereum 10grans deployed to: ${deployedAddress}`); + await fs.writeFile(`.10grans-eth-address.${env}`, deployedAddress); } // We recommend this pattern to be able to use async/await everywhere