Skip to content

Commit

Permalink
Merge pull request #104 from BitGo/BG-68541-bsc-config
Browse files Browse the repository at this point in the history
feat(bsc): add config for deployment
  • Loading branch information
mullapudipruthvik authored Feb 24, 2023
2 parents b76b031 + c69ff2b commit 47976e3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/deploy_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
15 changes: 13 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down
27 changes: 21 additions & 6 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 47976e3

Please sign in to comment.