Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: modify deploy script #156

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions .github/workflows/deploy_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
- name: Use Node.js
uses: actions/setup-node@v3
with:
cache: 'npm'
Expand Down Expand Up @@ -38,20 +38,26 @@ jobs:
get-network:
runs-on: ubuntu-latest
needs: [lint-and-test]
outputs:
outputs:
network: ${{steps.network-name.outputs.result}}
version: ${{steps.network-name.outputs.result}}
steps:
- name: GET NETWORK NAME
id: 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)$/;
const network = tag.match(regex);
return network ? network[1] : "hteth";
const regex = (v[\d\.]+)\-(eth|hteth|matic|tmatic|bsc|tbsc|arbeth|tarbeth|opeth|topeth|zketh|tzketh)$
const tagArray = tag.match(regex);
const network = tagArray ? tagArray[2] : "hteth";
const version = tarArray ? tagArray[1] : "v1.0";
return {
network: network,
version: version
};
deploy-to-test:
runs-on: ubuntu-latest
needs: [lint-and-test, get-network]
Expand Down Expand Up @@ -82,7 +88,9 @@ jobs:
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 }}
ZKSYNC_EXPLORER_API_KEY: ${{ secrets.ZKSYNC_EXPLORER_API_KEY }},
VERSION: ${{ needs.get-network.outputs.version }},
ENV: 'TEST'
- name: Update release notes
uses: actions/github-script@v6
with:
Expand Down Expand Up @@ -140,7 +148,9 @@ jobs:
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }}
ZKSYNC_EXPLORER_API_KEY: ${{ secrets.ZKSYNC_EXPLORER_API_KEY }}
QUICKNODE_ARBITRUM_ONE_API_KEY: ${{ secrets.QUICKNODE_ARBITRUM_ONE_API_KEY }}
QUICKNODE_OPTIMISM_API_KEY: ${{ secrets.QUICKNODE_OPTIMISM_API_KEY }}
QUICKNODE_OPTIMISM_API_KEY: ${{ secrets.QUICKNODE_OPTIMISM_API_KEY }},
VERSION: ${{ needs.get-network.outputs.version }},
ENV: 'PROD'
- name: Update release notes
uses: actions/github-script@v6
with:
Expand Down
66 changes: 42 additions & 24 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,39 @@ const {
BSCSCAN_API_KEY,
ARBISCAN_API_KEY,
OPTIMISTIC_ETHERSCAN_API_KEY,
ZKSYNC_EXPLORER_API_KEY
ZKSYNC_EXPLORER_API_KEY,
VERSION,
ENV
} = process.env;

const version = VERSION ? VERSION.split('.')[0] : 'v1';
venkateshv1266 marked this conversation as resolved.
Show resolved Hide resolved

const privateKey: { [key: string]: string } = {
v4Prod: PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT ?? '',
v4Test: PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT ?? '',
v2Prod: MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT ?? '',
v2Test: TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT ?? '',
v1ProdTestWallet: PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT ?? '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
v1ProdTestWallet: PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT ?? '',
v1ProdTestWallet: PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP ?? '',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use same private key for wallet and forwarder deployment in v1?

Because I have added something like this...

v1ProdTestWallet: PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT ?? '',
v1ProdTestForwarder: PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP ?? ''

v1ProdTestForwarder: PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP ?? ''
};

function getPrivateKey(version: string): string[] {
switch (version) {
case 'v1':
return [
privateKey['v1ProdTestWallet'],
privateKey['v1ProdTestForwarder']
];
case 'v2':
return ENV === 'TEST' ? [privateKey['v2Test']] : [privateKey['v2Prod']];
case 'v4':
return ENV === 'TEST' ? [privateKey['v4Test']] : [privateKey['v4Prod']];
default:
console.error('Invalid Version Number or Tag');
process.exit(1);
}
}

const config: HardhatUserConfig = {
solidity: {
compilers: [
Expand Down Expand Up @@ -67,60 +97,48 @@ const config: HardhatUserConfig = {
},
eth: {
url: `https://ethereum-rpc.publicnode.com`,
accounts: [`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`]
accounts: getPrivateKey(version)
},
hteth: {
url: `https://rpc.holesky.ethpandaops.io/`,
accounts: [`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`]
accounts: getPrivateKey(version)
},
matic: {
url: `https://polygon-rpc.com/`,
accounts: [`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`]
accounts: getPrivateKey(version)
},
tmatic: {
// https://polygon-amoy.g.alchemy.com
url: `https://polygon-amoy-bor-rpc.publicnode.com`,
accounts: [`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`]
accounts: getPrivateKey(version)
},
bsc: {
url: `https://bsc-dataseed1.binance.org/`,
accounts: [`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`]
accounts: getPrivateKey(version)
},
tbsc: {
url: `https://data-seed-prebsc-1-s1.binance.org:8545/`,
accounts: [`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`]
accounts: getPrivateKey(version)
},
tarbeth: {
url: `${QUICKNODE_ARBITRUM_SEPOLIA_API_KEY}`,
accounts: [
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
]
accounts: getPrivateKey(version)
},
arbeth: {
url: `${QUICKNODE_ARBITRUM_ONE_API_KEY}`,
accounts: [
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
]
accounts: getPrivateKey(version)
},
topeth: {
url: `${QUICKNODE_OPTIMISM_SEPOLIA_API_KEY}`,
accounts: [
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
]
accounts: getPrivateKey(version)
},
opeth: {
url: `${QUICKNODE_OPTIMISM_API_KEY}`,
accounts: [
`${PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP}`
]
accounts: getPrivateKey(version)
},
tzketh: {
url: `${QUICKNODE_ZKSYNC_SEPOLIA_API_KEY}`,
accounts: [`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`]
accounts: getPrivateKey(version)
}
},
gasReporter: {
Expand Down
Loading
Loading