Skip to content

Commit

Permalink
chore(eth-multisig-v4): add xdc config for contract deployment
Browse files Browse the repository at this point in the history
Ticket: WIN-4229
  • Loading branch information
parasgarg-bitgo committed Jan 21, 2025
1 parent d64bb5a commit 557cebc
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 16 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 @@ -43,6 +43,7 @@ jobs:
CORE_DAO_MAINNET_EXPLORER_API_KEY: ${{ secrets.CORE_DAO_MAINNET_EXPLORER_API_KEY }}
FLARE_EXPLORER_API_KEY: ${{ secrets.FLARE_EXPLORER_API_KEY }}
SONGBIRD_EXPLORER_API_KEY: ${{ secrets.SONGBIRD_EXPLORER_API_KEY }}
XDC_EXPLORER_API_KEY: ${{ secrets.XDC_EXPLORER_API_KEY }}
get-network:
runs-on: ubuntu-latest
needs: [lint-and-test]
Expand All @@ -57,13 +58,13 @@ jobs:
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|tbera|tavaxc|avaxc|toas|oas|tcoredao|coredao|tflr|flr|tsgb|sgb)$/;
const regex = /v.*\-(eth|hteth|matic|tmatic|bsc|tbsc|arbeth|tarbeth|opeth|topeth|zketh|tzketh|baseeth|tbaseeth|tbera|tavaxc|avaxc|toas|oas|tcoredao|coredao|tflr|flr|tsgb|sgb|txdc|xdc)$/;
const network = tag.match(regex);
return network ? network[1] : "hteth";
deploy-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' ) || (needs.get-network.outputs.network == 'toas' ) || (needs.get-network.outputs.network == 'tcoredao' ) || (needs.get-network.outputs.network == 'tflr' ) || (needs.get-network.outputs.network == 'tsgb' )}}
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' ) || (needs.get-network.outputs.network == 'toas' ) || (needs.get-network.outputs.network == 'tcoredao' ) || (needs.get-network.outputs.network == 'tflr' ) || (needs.get-network.outputs.network == 'tsgb' ) || (needs.get-network.outputs.network == 'txdc' ) }}
environment: testnet
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -102,6 +103,7 @@ jobs:
CORE_DAO_MAINNET_EXPLORER_API_KEY: ${{ secrets.CORE_DAO_MAINNET_EXPLORER_API_KEY }}
FLARE_EXPLORER_API_KEY: ${{ secrets.FLARE_EXPLORER_API_KEY }}
SONGBIRD_EXPLORER_API_KEY: ${{ secrets.SONGBIRD_EXPLORER_API_KEY }}
XDC_EXPLORER_API_KEY: ${{ secrets.XDC_EXPLORER_API_KEY }}
- name: Update release notes
uses: actions/github-script@v6
with:
Expand Down Expand Up @@ -133,7 +135,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' ) || (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' ) || (needs.get-network.outputs.network == 'coredao' ) || (needs.get-network.outputs.network == 'oas' ) || (needs.get-network.outputs.network == 'flr' ) || (needs.get-network.outputs.network == 'sgb' ) }}
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' ) || (needs.get-network.outputs.network == 'coredao' ) || (needs.get-network.outputs.network == 'oas' ) || (needs.get-network.outputs.network == 'flr' ) || (needs.get-network.outputs.network == 'sgb' ) || (needs.get-network.outputs.network == 'xdc' ) }}
environment: mainnet
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -172,6 +174,7 @@ jobs:
CORE_DAO_MAINNET_EXPLORER_API_KEY: ${{ secrets.CORE_DAO_MAINNET_EXPLORER_API_KEY }}
FLARE_EXPLORER_API_KEY: ${{ secrets.FLARE_EXPLORER_API_KEY }}
SONGBIRD_EXPLORER_API_KEY: ${{ secrets.SONGBIRD_EXPLORER_API_KEY }}
XDC_EXPLORER_API_KEY: ${{ secrets.XDC_EXPLORER_API_KEY }}
- name: Update release notes
uses: actions/github-script@v6
with:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/deploy_batcher_contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
CORE_DAO_MAINNET_EXPLORER_API_KEY: ${{ secrets.CORE_DAO_MAINNET_EXPLORER_API_KEY }}
FLARE_EXPLORER_API_KEY: ${{ secrets.FLARE_EXPLORER_API_KEY }}
SONGBIRD_EXPLORER_API_KEY: ${{ secrets.SONGBIRD_EXPLORER_API_KEY }}
XDC_EXPLORER_API_KEY: ${{ secrets.XDC_EXPLORER_API_KEY }}
get-network:
runs-on: ubuntu-latest
needs: [lint-and-test]
Expand All @@ -57,7 +58,7 @@ jobs:
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|toas|oas|tcoredao|coredao|flr|tflr|sgb|tsgb)$/;
const regex = /v.*\-(eth|hteth|matic|tmatic|bsc|tbsc|arbeth|tarbeth|opeth|topeth|zketh|tzketh|baseeth|tbaseeth|bera|tbera|tavaxc|avaxc|toas|oas|tcoredao|coredao|flr|tflr|sgb|tsgb|txdc|xdc)$/;
const matchedNetwork = tag.match(regex);
if (!matchedNetwork) {
console.log("No match found for the network name, defaulting to 'hteth'.");
Expand All @@ -67,7 +68,7 @@ jobs:
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' ) || (needs.get-network.outputs.network == 'tcoredao' ) || (needs.get-network.outputs.network == 'toas' ) || (needs.get-network.outputs.network == 'tflr' ) || (needs.get-network.outputs.network == 'tsgb' ) }}
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' ) || (needs.get-network.outputs.network == 'tcoredao' ) || (needs.get-network.outputs.network == 'toas' ) || (needs.get-network.outputs.network == 'tflr' ) || (needs.get-network.outputs.network == 'tsgb' ) || (needs.get-network.outputs.network == 'txdc' ) }}
environment: testnet
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -103,6 +104,7 @@ jobs:
CORE_DAO_MAINNET_EXPLORER_API_KEY: ${{ secrets.CORE_DAO_MAINNET_EXPLORER_API_KEY }}
FLARE_EXPLORER_API_KEY: ${{ secrets.FLARE_EXPLORER_API_KEY }}
SONGBIRD_EXPLORER_API_KEY: ${{ secrets.SONGBIRD_EXPLORER_API_KEY }}
XDC_EXPLORER_API_KEY: ${{ secrets.XDC_EXPLORER_API_KEY }}
- name: Update release notes
uses: actions/github-script@v7
with:
Expand All @@ -114,7 +116,7 @@ jobs:
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' ) || (needs.get-network.outputs.network == 'coredao' ) || (needs.get-network.outputs.network == 'oas' ) || (needs.get-network.outputs.network == 'sgb' ) || (needs.get-network.outputs.network == 'flr' ) }}
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' ) || (needs.get-network.outputs.network == 'coredao' ) || (needs.get-network.outputs.network == 'oas' ) || (needs.get-network.outputs.network == 'sgb' ) || (needs.get-network.outputs.network == 'flr' ) || (needs.get-network.outputs.network == 'xdc' ) }}
environment: mainnet
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -150,6 +152,7 @@ jobs:
CORE_DAO_MAINNET_EXPLORER_API_KEY: ${{ secrets.CORE_DAO_MAINNET_EXPLORER_API_KEY }}
FLARE_EXPLORER_API_KEY: ${{ secrets.FLARE_EXPLORER_API_KEY }}
SONGBIRD_EXPLORER_API_KEY: ${{ secrets.SONGBIRD_EXPLORER_API_KEY }}
XDC_EXPLORER_API_KEY: ${{ secrets.XDC_EXPLORER_API_KEY }}
- name: Update release notes
uses: actions/github-script@v7
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ jobs:
CORE_DAO_MAINNET_EXPLORER_API_KEY: ${{ secrets.CORE_DAO_MAINNET_EXPLORER_API_KEY }}
FLARE_EXPLORER_API_KEY: ${{ secrets.FLARE_EXPLORER_API_KEY }}
SONGBIRD_EXPLORER_API_KEY: ${{ secrets.SONGBIRD_EXPLORER_API_KEY }}
XDC_EXPLORER_API_KEY: ${{ secrets.XDC_EXPLORER_API_KEY }}
- run: npm run lint
40 changes: 38 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const {
CORE_DAO_TESTNET_EXPLORER_API_KEY,
CORE_DAO_MAINNET_EXPLORER_API_KEY,
FLARE_EXPLORER_API_KEY,
SONGBIRD_EXPLORER_API_KEY
SONGBIRD_EXPLORER_API_KEY,
XDC_EXPLORER_API_KEY
} = process.env;

const config: HardhatUserConfig = {
Expand Down Expand Up @@ -210,6 +211,22 @@ const config: HardhatUserConfig = {
avaxc: {
url: 'https://api.avax.network/ext/bc/C/rpc',
accounts: [`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`]
},
txdc: {
url: `https://rpc.apothem.network`,
accounts: [
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT}`
]
},
xdc: {
url: `https://erpc.xinfin.network`,
accounts: [
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`,
`${PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT}`
]
}
},
gasReporter: {
Expand Down Expand Up @@ -256,7 +273,10 @@ const config: HardhatUserConfig = {
//avaxc
// there is free api key for avaxc, so make use of 2 req/sec
avaxc: 'sampleapikey',
avaxcTestnet: 'sampleapikey'
avaxcTestnet: 'sampleapikey',
//XDC
xdcTestnet: `${XDC_EXPLORER_API_KEY}`,
xdcMainnet: `${XDC_EXPLORER_API_KEY}`
},
customChains: [
{
Expand Down Expand Up @@ -413,6 +433,22 @@ const config: HardhatUserConfig = {
apiURL: 'https://songbird-explorer.flare.network/api ',
browserURL: 'https://songbird.flarescan.com'
}
},
{
network: 'xdcTestnet',
chainId: 51,
urls: {
apiURL: 'https://api-apothem.xdcscan.io/api',
browserURL: 'https://apothem.xdcscan.io'
}
},
{
network: 'xdcMainnet',
chainId: 50,
urls: {
apiURL: 'https://api-xdc.blocksscan.io/api',
browserURL: 'https://xdcscan.io'
}
}
]
},
Expand Down
36 changes: 30 additions & 6 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,28 @@ async function main() {

const feeData = await ethers.provider.getFeeData();

const eip1559GasParams: {
type LegacyGasParams = {
gasPrice: BigNumber | null;
gasLimit?: number;
};

const legacyGasParams: LegacyGasParams = {
gasPrice: feeData.gasPrice
};

type Eip1559GasParams = {
maxFeePerGas: BigNumber | null;
maxPriorityFeePerGas: BigNumber | null;
gasLimit?: number;
} = {
};

const eip1559GasParams: Eip1559GasParams = {
maxFeePerGas: feeData.maxFeePerGas,
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas
};

let gasParams: Eip1559GasParams | LegacyGasParams = eip1559GasParams;

let deployWalletContracts = false,
deployForwarderContracts = false;
const [deployer] = await ethers.getSigners();
Expand Down Expand Up @@ -148,6 +162,16 @@ async function main() {
forwarderFactoryContractName = 'ForwarderFactoryV4';
contractPath = `contracts/${walletImplementationContractName}.sol:${walletImplementationContractName}`;
break;
//XDC
case 50:
case 51:
legacyGasParams.gasLimit = 3000000;
gasParams = legacyGasParams;
walletImplementationContractName = 'WalletSimple';
forwarderContractName = 'ForwarderV4';
forwarderFactoryContractName = 'ForwarderFactoryV4';
contractPath = `contracts/${walletImplementationContractName}.sol:${walletImplementationContractName}`;
break;
}

if (deployWalletContracts) {
Expand All @@ -157,7 +181,7 @@ async function main() {
const WalletSimple = await ethers.getContractFactory(
walletImplementationContractName
);
const walletSimple = await WalletSimple.deploy(eip1559GasParams);
const walletSimple = await WalletSimple.deploy(gasParams);
await walletSimple.deployed();
output.walletImplementation = walletSimple.address;
console.log('WalletSimple deployed at ' + walletSimple.address);
Expand All @@ -167,7 +191,7 @@ async function main() {
);
const walletFactory = await WalletFactory.deploy(
walletSimple.address,
eip1559GasParams
gasParams
);
await walletFactory.deployed();
output.walletFactory = walletFactory.address;
Expand Down Expand Up @@ -263,11 +287,11 @@ async function verifyContract(
} catch (e) {
// @ts-ignore
// We get a failure API response if the source code has already been uploaded, don't throw in this case.
if (!e.message.includes('Reason: Already Verified')) {
if (!e.message.toLowerCase().includes('already verified')) {
throw e;
}
}
console.log(`Verified ${contractName} on Etherscan!`);
console.log(`Verified ${contractName} on explorer!`);
}

main().catch((error) => {
Expand Down
4 changes: 2 additions & 2 deletions scripts/deployBatcherContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ async function verifyContract(
} catch (e) {
// @ts-ignore
// We get a failure API response if the source code has already been uploaded, don't throw in this case.
if (!e.message.includes('Reason: Already Verified')) {
if (!e.message.toLowerCase().includes('already verified')) {
throw e;
}
}
console.log(`Verified ${contractName} on Etherscan!`);
console.log(`Verified ${contractName} on explorer!`);
}

main().catch((error) => {
Expand Down

0 comments on commit 557cebc

Please sign in to comment.