Skip to content

Commit

Permalink
feat(eth-multisig-v4): add deploy batcher smart contract in workflow
Browse files Browse the repository at this point in the history
TICKET: COIN-716
  • Loading branch information
MohammedRyaan786 committed Sep 12, 2024
1 parent e35d1e1 commit 056b7d6
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 4 deletions.
208 changes: 208 additions & 0 deletions .github/workflows/deploy_batcher_contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
name: Deploy Batcher Contract and Update Release
on:
release:
types: [published]
jobs:
lint-and-test:
environment: dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: 'npm'
- run: npm install
- run: npm run lint
- run: npm run test
env:
PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT: ${{ secrets.PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT }}
QUICKNODE_ETH_MAINNET_API_KEY: ${{ secrets.QUICKNODE_ETH_MAINNET_API_KEY }}
QUICKNODE_ETH_HOLESKY_API_KEY: ${{ secrets.QUICKNODE_ETH_HOLESKY_API_KEY }}
QUICKNODE_ARBITRUM_SEPOLIA_API_KEY: ${{ secrets.QUICKNODE_ARBITRUM_SEPOLIA_API_KEY }}
QUICKNODE_ARBITRUM_ONE_API_KEY: ${{ secrets.QUICKNODE_ARBITRUM_ONE_API_KEY }}
QUICKNODE_OPTIMISM_SEPOLIA_API_KEY: ${{ secrets.QUICKNODE_OPTIMISM_SEPOLIA_API_KEY }}
QUICKNODE_OPTIMISM_API_KEY: ${{ secrets.QUICKNODE_OPTIMISM_API_KEY }}
QUICKNODE_ZKSYNC_SEPOLIA_API_KEY: ${{ secrets.QUICKNODE_ZKSYNC_SEPOLIA_API_KEY }}
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 }}
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }}
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }}
ZKSYNC_EXPLORER_API_KEY: ${{ secrets.ZKSYNC_EXPLORER_API_KEY }}
BASESCAN_API_KEY: ${{ secrets.BASESCAN_API_KEY }}
BARTIO_BERA_EXPLORER_API_KEY: ${{ secrets.BARTIO_BERA_EXPLORER_API_KEY }}
get-network:
runs-on: ubuntu-latest
needs: [lint-and-test]
outputs:
network: ${{steps.network-name.outputs.result}}
steps:
- name: GET NETWORK NAME
id: network-name
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
const tag = process.env.GITHUB_REF_NAME;
const regex = /v.*\-(eth|hteth|matic|tmatic|bsc|tbsc|arbeth|tarbeth|opeth|topeth|zketh|tzketh|baseeth|tbaseeth|bera|tbera|tavaxc|avaxc)$/;
const matchedNetwork = tag.match(regex);
if (!matchedNetwork) {
console.log("No match found for the network name, defaulting to 'hteth'.");
return "hteth";
}
return matchedNetwork[1];
deploy-batcher-contract-to-test:
runs-on: ubuntu-latest
needs: [lint-and-test, get-network]
if: ${{ (needs.get-network.outputs.network == 'hteth' ) || (needs.get-network.outputs.network == 'tmatic' ) || (needs.get-network.outputs.network == 'tbsc' ) || (needs.get-network.outputs.network == 'tarbeth' ) || (needs.get-network.outputs.network == 'topeth' ) || (needs.get-network.outputs.network == 'tzketh' ) || (needs.get-network.outputs.network == 'tbaseeth' ) || (needs.get-network.outputs.network == 'tbera' ) || (needs.get-network.outputs.network == 'tavaxc' ) }}
environment: testnet
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 16.x
cache: 'npm'
- run: npm install
- run: npm run deploy-batcher --network ${{ needs.get-network.outputs.network }}
env:
PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT: ${{ secrets.PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT }}
QUICKNODE_ETH_HOLESKY_API_KEY: ${{ secrets.QUICKNODE_ETH_HOLESKY_API_KEY }}
QUICKNODE_ARBITRUM_SEPOLIA_API_KEY: ${{ secrets.QUICKNODE_ARBITRUM_SEPOLIA_API_KEY }}
QUICKNODE_OPTIMISM_SEPOLIA_API_KEY: ${{ secrets.QUICKNODE_OPTIMISM_SEPOLIA_API_KEY }}
QUICKNODE_ZKSYNC_SEPOLIA_API_KEY: ${{ secrets.QUICKNODE_ZKSYNC_SEPOLIA_API_KEY }}
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 }}
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }}
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }}
ZKSYNC_EXPLORER_API_KEY: ${{ secrets.ZKSYNC_EXPLORER_API_KEY }}
BASESCAN_API_KEY: ${{ secrets.BASESCAN_API_KEY }}
BARTIO_BERA_EXPLORER_API_KEY: ${{ secrets.BARTIO_BERA_EXPLORER_API_KEY }}
- name: Update release notes
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const path = require('path');
let json;
let html = [];
// Read and parse the JSON file
try {
json = JSON.parse(fs.readFileSync('./output.json').toString());
for (const key in json) {
html.push(`${key}: ${json[key]}`);
}
} catch (err) {
console.error("Error reading or parsing 'output.json':", err.message);
return;
}
// Join the HTML content
html = html.join('<br>');
// Async function to fetch and update the release
async function updateRelease() {
try {
const response = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: context.payload.release.tag_name
});
// Update the release with the new notes
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: response.data.id,
body: html
});
} catch (err) {
console.error("Error fetching or updating the release:", err.message);
throw err;
}
}
updateRelease();
deploy-batcher-contract-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' ) || (needs.get-network.outputs.network == 'bsc' ) || (needs.get-network.outputs.network == 'arbeth' ) || (needs.get-network.outputs.network == 'opeth' ) || (needs.get-network.outputs.network == 'zketh' ) || (needs.get-network.outputs.network == 'baseeth' ) || (needs.get-network.outputs.network == 'bera' ) || (needs.get-network.outputs.network == 'avaxc' )}}
environment: mainnet
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 16.x
cache: 'npm'
- run: npm install
- run: npm run deploy-batcher --network ${{ needs.get-network.outputs.network }}
env:
PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT: ${{ secrets.PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT }}
QUICKNODE_ETH_MAINNET_API_KEY: ${{ secrets.QUICKNODE_ETH_MAINNET_API_KEY }}
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 }}
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }}
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }}
ZKSYNC_EXPLORER_API_KEY: ${{ secrets.ZKSYNC_EXPLORER_API_KEY }}
BARTIO_BERA_EXPLORER_API_KEY: ${{ secrets.BARTIO_BERA_EXPLORER_API_KEY }}
QUICKNODE_ARBITRUM_ONE_API_KEY: ${{ secrets.QUICKNODE_ARBITRUM_ONE_API_KEY }}
QUICKNODE_OPTIMISM_API_KEY: ${{ secrets.QUICKNODE_OPTIMISM_API_KEY }}
BASESCAN_API_KEY: ${{ secrets.BASESCAN_API_KEY }}
- name: Update release notes
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const path = require('path');
let json;
let html = [];
// Read and parse the JSON file
try {
json = JSON.parse(fs.readFileSync('./output.json').toString());
for (const key in json) {
html.push(`${key}: ${json[key]}`);
}
} catch (err) {
console.error("Error reading or parsing 'output.json':", err.message);
return;
}
// Join the HTML content
html = html.join('<br>');
// Async function to fetch and update the release
async function updateRelease() {
try {
const response = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: context.payload.release.tag_name
});
// Update the release with the new notes
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: response.data.id,
body: html
});
} catch (err) {
console.error("Error fetching or updating the release:", err.message);
throw err;
}
}
updateRelease();
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
QUICKNODE_ETH_MAINNET_API_KEY,
PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP,
PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT,
PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT,
QUICKNODE_ARBITRUM_SEPOLIA_API_KEY,
QUICKNODE_OPTIMISM_SEPOLIA_API_KEY,
QUICKNODE_ARBITRUM_ONE_API_KEY,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"scripts": {
"deploy-prod": "hardhat run scripts/deployV1FactoryContracts.ts --network",
"deploy-test": "hardhat run scripts/deploy.ts --network",
"deploy-batcher" : "hardhat run scripts/deployBatcherContract.ts --network",
"test": "hardhat test",
"coverage": "hardhat coverage",
"solhint": "./node_modules/.bin/solhint --fix 'contracts/**/*.sol'",
Expand Down
4 changes: 0 additions & 4 deletions scripts/deployBatcherContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ const fs = require('fs');

async function main() {
const output = {
walletImplementation: '',
walletFactory: '',
forwarderImplementation: '',
forwarderFactory: '',
batcher: ''
};

Expand Down

0 comments on commit 056b7d6

Please sign in to comment.