From c69ff2befc4181a31014a5166217e2765ac4e7c3 Mon Sep 17 00:00:00 2001 From: Mullapudi Pruthvik Date: Fri, 17 Feb 2023 19:17:58 +0530 Subject: [PATCH] feat(bsc): add config for deployment Ticket: BG-68541 --- .github/workflows/deploy_and_release.yml | 9 +++++--- hardhat.config.ts | 15 +++++++++++-- scripts/deploy.ts | 27 ++++++++++++++++++------ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy_and_release.yml b/.github/workflows/deploy_and_release.yml index 068c651..2b19280 100644 --- a/.github/workflows/deploy_and_release.yml +++ b/.github/workflows/deploy_and_release.yml @@ -21,6 +21,7 @@ jobs: ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }} POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }} + BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }} get-network: runs-on: ubuntu-latest needs: [lint-and-test] @@ -35,13 +36,13 @@ jobs: result-encoding: string script: | const tag = process.env.GITHUB_REF_NAME; - const regex = /v.*\-(eth|gteth|matic|tmatic)$/; + const regex = /v.*\-(eth|gteth|matic|tmatic|bsc|tbsc)$/; const network = tag.match(regex); return network ? network[1] : "gteth"; deploy-to-test: runs-on: ubuntu-latest needs: [lint-and-test, get-network] - if: ${{ (needs.get-network.outputs.network == 'gteth' ) || (needs.get-network.outputs.network == 'tmatic' ) }} + if: ${{ (needs.get-network.outputs.network == 'gteth' ) || (needs.get-network.outputs.network == 'tmatic' ) || (needs.get-network.outputs.network == 'tbsc' ) }} environment: testnet steps: - uses: actions/checkout@v2 @@ -58,6 +59,7 @@ jobs: ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }} POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }} + BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }} - name: Update release notes uses: actions/github-script@v6 with: @@ -89,7 +91,7 @@ jobs: deploy-to-prod: runs-on: ubuntu-latest needs: [lint-and-test, get-network] - if: ${{ (needs.get-network.outputs.network == 'eth' ) || (needs.get-network.outputs.network == 'matic' ) }} + if: ${{ (needs.get-network.outputs.network == 'eth' ) || (needs.get-network.outputs.network == 'matic' ) || (needs.get-network.outputs.network == 'bsc' ) }} environment: mainnet steps: - uses: actions/checkout@v2 @@ -106,6 +108,7 @@ jobs: ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }} POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }} + BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }} - name: Update release notes uses: actions/github-script@v6 with: diff --git a/hardhat.config.ts b/hardhat.config.ts index 2d9c442..070e278 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -14,7 +14,8 @@ const { ALCHEMY_ETHER_API_KEY, ETHERSCAN_API_KEY, ALCHEMY_POLYGON_API_KEY, - POLYGONSCAN_API_KEY + POLYGONSCAN_API_KEY, + BSCSCAN_API_KEY } = process.env; const config: HardhatUserConfig = { @@ -55,6 +56,14 @@ const config: HardhatUserConfig = { //https://polygon-mumbai.g.alchemy.com/ url: `https://polygon-mumbai.g.alchemyapi.io/v2/${ALCHEMY_POLYGON_API_KEY}`, accounts: [`${PRIVATE_KEY}`] + }, + bsc: { + url: `https://bsc-dataseed1.binance.org/`, + accounts: [`${PRIVATE_KEY}`] + }, + tbsc: { + url: `https://data-seed-prebsc-1-s1.binance.org:8545/`, + accounts: [`${PRIVATE_KEY}`] } }, gasReporter: { @@ -68,7 +77,9 @@ const config: HardhatUserConfig = { goerli: `${ETHERSCAN_API_KEY}`, //polygon polygon: `${POLYGONSCAN_API_KEY}`, - polygonMumbai: `${POLYGONSCAN_API_KEY}` + polygonMumbai: `${POLYGONSCAN_API_KEY}`, + bscTestnet: `${BSCSCAN_API_KEY}`, + bsc: `${BSCSCAN_API_KEY}` } }, mocha: { diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 147809f..3352856 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -12,32 +12,47 @@ async function main() { const [deployer] = await ethers.getSigners(); - let walletContractName = ''; + let walletImplementationContractName = ''; + let walletFactoryContractName = 'WalletFactory'; + const chainId = await deployer.getChainId(); switch (await deployer.getChainId()) { // https://chainlist.org/ //eth case 1: //gteth case 5: - walletContractName = 'WalletSimple'; + walletImplementationContractName = 'WalletSimple'; break; //matic case 137: //tmatic case 80001: - walletContractName = 'PolygonWalletSimple'; + walletImplementationContractName = 'PolygonWalletSimple'; + break; + // bsc + case 56: + // tbsc + case 97: + walletImplementationContractName = 'RecoveryWalletSimple'; + walletFactoryContractName = 'RecoveryWalletFactory'; break; } - console.log('Deployed wallet contract called: ' + walletContractName); + console.log( + 'Deployed wallet contract called: ' + walletImplementationContractName + ); - const WalletSimple = await ethers.getContractFactory(walletContractName); + const WalletSimple = await ethers.getContractFactory( + walletImplementationContractName + ); const walletSimple = await WalletSimple.deploy(); await walletSimple.deployed(); output.walletImplementation = walletSimple.address; console.log('WalletSimple deployed at ' + walletSimple.address); - const WalletFactory = await ethers.getContractFactory('WalletFactory'); + const WalletFactory = await ethers.getContractFactory( + walletFactoryContractName + ); const walletFactory = await WalletFactory.deploy(walletSimple.address); await walletFactory.deployed(); output.walletFactory = walletFactory.address;