diff --git a/.github/workflows/deploy_and_release.yml b/.github/workflows/deploy_and_release.yml index 8ed74c6..910989e 100644 --- a/.github/workflows/deploy_and_release.yml +++ b/.github/workflows/deploy_and_release.yml @@ -44,6 +44,7 @@ jobs: 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 }} + WEMIX_EXPLORER_API_KEY: ${{ secrets.WEMIX_EXPLORER_API_KEY }} get-network: runs-on: ubuntu-latest needs: [lint-and-test] @@ -58,13 +59,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|txdc|xdc)$/; + 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|twemix|wemix)$/; 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' ) || (needs.get-network.outputs.network == 'txdc' ) }} + 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' ) || (needs.get-network.outputs.network == 'twemix' ) }} environment: testnet steps: - uses: actions/checkout@v2 @@ -104,6 +105,7 @@ jobs: 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 }} + WEMIX_EXPLORER_API_KEY: ${{ secrets.WEMIX_EXPLORER_API_KEY }} - name: Update release notes uses: actions/github-script@v6 with: @@ -135,7 +137,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' ) || (needs.get-network.outputs.network == 'xdc' ) }} + 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' ) || (needs.get-network.outputs.network == 'wemix' ) }} environment: mainnet steps: - uses: actions/checkout@v2 @@ -175,6 +177,7 @@ jobs: 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 }} + WEMIX_EXPLORER_API_KEY: ${{ secrets.WEMIX_EXPLORER_API_KEY }} - name: Update release notes uses: actions/github-script@v6 with: diff --git a/.github/workflows/deploy_batcher_contract.yml b/.github/workflows/deploy_batcher_contract.yml index 8f6ddb9..6c7502b 100644 --- a/.github/workflows/deploy_batcher_contract.yml +++ b/.github/workflows/deploy_batcher_contract.yml @@ -44,6 +44,7 @@ jobs: 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 }} + WEMIX_EXPLORER_API_KEY: ${{ secrets.WEMIX_EXPLORER_API_KEY }} get-network: runs-on: ubuntu-latest needs: [lint-and-test] @@ -58,7 +59,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|txdc|xdc)$/; + 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|twemix|wemix)$/; const matchedNetwork = tag.match(regex); if (!matchedNetwork) { console.log("No match found for the network name, defaulting to 'hteth'."); @@ -68,7 +69,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' ) || (needs.get-network.outputs.network == 'txdc' ) }} + 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' ) || (needs.get-network.outputs.network == 'twemix' ) }} environment: testnet steps: - uses: actions/checkout@v4 @@ -105,6 +106,7 @@ jobs: 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 }} + WEMIX_EXPLORER_API_KEY: ${{ secrets.WEMIX_EXPLORER_API_KEY }} - name: Update release notes uses: actions/github-script@v7 with: @@ -116,7 +118,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' ) || (needs.get-network.outputs.network == 'xdc' ) }} + 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' ) || (needs.get-network.outputs.network == 'wemix' ) }} environment: mainnet steps: - uses: actions/checkout@v4 @@ -153,6 +155,7 @@ jobs: 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 }} + WEMIX_EXPLORER_API_KEY: ${{ secrets.WEMIX_EXPLORER_API_KEY }} - name: Update release notes uses: actions/github-script@v7 with: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 941d98d..b3a5dd2 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -52,4 +52,5 @@ jobs: 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 }} + WEMIX_EXPLORER_API_KEY: ${{ secrets.WEMIX_EXPLORER_API_KEY }} - run: npm run lint diff --git a/hardhat.config.ts b/hardhat.config.ts index 71c411a..26ee487 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -36,7 +36,8 @@ const { CORE_DAO_MAINNET_EXPLORER_API_KEY, FLARE_EXPLORER_API_KEY, SONGBIRD_EXPLORER_API_KEY, - XDC_EXPLORER_API_KEY + XDC_EXPLORER_API_KEY, + WEMIX_EXPLORER_API_KEY } = process.env; const config: HardhatUserConfig = { @@ -172,7 +173,7 @@ const config: HardhatUserConfig = { `${PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT}` ] }, - tflare: { + tflr: { url: `https://coston2-api.flare.network/ext/C/rpc`, accounts: [ `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, @@ -180,23 +181,23 @@ const config: HardhatUserConfig = { `${PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT}` ] }, - tsongbird: { - url: `https://coston-api.flare.network/ext/C/rpc`, + flr: { + url: `https://flare-api.flare.network/ext/C/rpc`, accounts: [ `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, `${PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT}` ] }, - flare: { - url: `https://flare-api.flare.network/ext/C/rpc`, + tsgb: { + url: `https://coston-api.flare.network/ext/C/rpc`, accounts: [ `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, `${PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT}` ] }, - songbird: { + sgb: { url: `https://songbird-api.flare.network/ext/C/rpc`, accounts: [ `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, @@ -227,6 +228,22 @@ const config: HardhatUserConfig = { `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, `${PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT}` ] + }, + twemix: { + url: `https://api.test.wemix.com`, + accounts: [ + `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, + `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, + `${PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT}` + ] + }, + wemix: { + url: `https://api.wemix.com`, + accounts: [ + `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, + `${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`, + `${PRIVATE_KEY_FOR_BATCHER_CONTRACT_DEPLOYMENT}` + ] } }, gasReporter: { @@ -276,7 +293,9 @@ const config: HardhatUserConfig = { avaxcTestnet: 'sampleapikey', //XDC xdcTestnet: `${XDC_EXPLORER_API_KEY}`, - xdcMainnet: `${XDC_EXPLORER_API_KEY}` + xdcMainnet: `${XDC_EXPLORER_API_KEY}`, + wemixTestnet: `${WEMIX_EXPLORER_API_KEY}`, + wemixMainnet: `${WEMIX_EXPLORER_API_KEY}` }, customChains: [ { @@ -449,6 +468,22 @@ const config: HardhatUserConfig = { apiURL: 'https://api-xdc.blocksscan.io/api', browserURL: 'https://xdcscan.io' } + }, + { + network: 'wemixTestnet', + chainId: 1112, + urls: { + apiURL: 'https://api-testnet.wemixscan.com/api', + browserURL: 'https://testnet.wemixscan.com/' + } + }, + { + network: 'wemixMainnet', + chainId: 1111, + urls: { + apiURL: 'https://api.wemixscan.com/api', + browserURL: 'https://wemixscan.com/' + } } ] }, diff --git a/scripts/deploy.ts b/scripts/deploy.ts index aeec806..6a2ab73 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -172,6 +172,23 @@ async function main() { forwarderFactoryContractName = 'ForwarderFactoryV4'; contractPath = `contracts/${walletImplementationContractName}.sol:${walletImplementationContractName}`; break; + //wemix + case 1112: + case 1111: + if ( + eip1559GasParams.maxPriorityFeePerGas?.lt( + legacyGasParams.gasPrice as BigNumber + ) + ) { + eip1559GasParams.maxPriorityFeePerGas = legacyGasParams.gasPrice; + eip1559GasParams.maxFeePerGas = legacyGasParams.gasPrice; + } + eip1559GasParams.gasLimit = 3000000; + walletImplementationContractName = 'WalletSimple'; + forwarderContractName = 'ForwarderV4'; + forwarderFactoryContractName = 'ForwarderFactoryV4'; + contractPath = `contracts/${walletImplementationContractName}.sol:${walletImplementationContractName}`; + break; } if (deployWalletContracts) { @@ -226,7 +243,7 @@ async function main() { // If we have to deploy contracts for the older coins like eth, avax, polygon, we need to deploy Forwarder and ForwarderFactory console.log('Deploying Forwarder contracts'); const Forwarder = await ethers.getContractFactory(forwarderContractName); - const forwarder = await Forwarder.deploy(); + const forwarder = await Forwarder.deploy(gasParams); await forwarder.deployed(); output.forwarderImplementation = forwarder.address; console.log(`${forwarderContractName} deployed at ` + forwarder.address); @@ -234,7 +251,10 @@ async function main() { const ForwarderFactory = await ethers.getContractFactory( forwarderFactoryContractName ); - const forwarderFactory = await ForwarderFactory.deploy(forwarder.address); + const forwarderFactory = await ForwarderFactory.deploy( + forwarder.address, + gasParams + ); await forwarderFactory.deployed(); output.forwarderFactory = forwarderFactory.address; console.log( diff --git a/scripts/deployBatcherContract.ts b/scripts/deployBatcherContract.ts index e756e92..f687404 100644 --- a/scripts/deployBatcherContract.ts +++ b/scripts/deployBatcherContract.ts @@ -1,4 +1,7 @@ import { ethers } from 'hardhat'; +import { BigNumber } from 'ethers'; +import { Overrides } from '@ethersproject/contracts/src.ts'; +import { BigNumberish } from '@ethersproject/bignumber'; const hre = require('hardhat'); const fs = require('fs'); @@ -16,7 +19,35 @@ async function main() { contractName, batcherDeployer ); - const batcher = await Batcher.deploy(transferGasLimit); + + let gasParams: Overrides | undefined = undefined; + + const chainId = await signers[0].getChainId(); + switch (chainId) { + //WEMIX + case 1112: + case 1111: + const feeData = await ethers.provider.getFeeData(); + gasParams = { + maxFeePerGas: (feeData.maxFeePerGas?.lt(feeData.gasPrice as BigNumber) + ? feeData.gasPrice + : feeData.maxFeePerGas) as BigNumberish, + maxPriorityFeePerGas: (feeData.maxFeePerGas?.lt( + feeData.gasPrice as BigNumber + ) + ? feeData.gasPrice + : feeData.maxPriorityFeePerGas) as BigNumberish, + gasLimit: BigNumber.from('3000000') + }; + break; + } + + let batcher = null; + if (gasParams != undefined) { + batcher = await Batcher.deploy(transferGasLimit, gasParams); + } else { + batcher = await Batcher.deploy(transferGasLimit); + } await batcher.deployed(); output.batcher = batcher.address; console.log('Batcher deployed at ' + batcher.address);