diff --git a/lib/zkevm-contracts b/lib/zkevm-contracts index c169730b..2f2a60aa 160000 --- a/lib/zkevm-contracts +++ b/lib/zkevm-contracts @@ -1 +1 @@ -Subproject commit c169730bc37328f52a91497dee0aba3983aff376 +Subproject commit 2f2a60aacc63cb18c9078ec9a779966eb16ebc1f diff --git a/src/scripts/depositForkonomicTokenIntoBridge.js b/src/scripts/depositForkonomicTokenIntoBridge.js index 22502cdf..c5850f71 100644 --- a/src/scripts/depositForkonomicTokenIntoBridge.js +++ b/src/scripts/depositForkonomicTokenIntoBridge.js @@ -3,6 +3,7 @@ const path = require('path'); const { ethers } = require('hardhat'); require('dotenv').config({ path: path.resolve(__dirname, '../.env') }); +const common = require('../common/common'); async function main() { /* @@ -35,45 +36,8 @@ async function main() { const forkonomicTokenAddress = maticTokenAddress; // Load provider - let currentProvider = ethers.provider; - if (deployParameters.multiplierGas || deployParameters.maxFeePerGas) { - if (process.env.HARDHAT_NETWORK !== 'hardhat') { - currentProvider = new ethers.providers.JsonRpcProvider(`https://${process.env.HARDHAT_NETWORK}.infura.io/v3/${process.env.INFURA_PROJECT_ID}`); - if (deployParameters.maxPriorityFeePerGas && deployParameters.maxFeePerGas) { - console.log(`Hardcoded gas used: MaxPriority${deployParameters.maxPriorityFeePerGas} gwei, MaxFee${deployParameters.maxFeePerGas} gwei`); - const FEE_DATA = { - maxFeePerGas: ethers.utils.parseUnits(deployParameters.maxFeePerGas, 'gwei'), - maxPriorityFeePerGas: ethers.utils.parseUnits(deployParameters.maxPriorityFeePerGas, 'gwei'), - }; - currentProvider.getFeeData = async () => FEE_DATA; - } else { - console.log('Multiplier gas used: ', deployParameters.multiplierGas); - async function overrideFeeData() { - const feedata = await ethers.provider.getFeeData(); - return { - maxFeePerGas: feedata.maxFeePerGas.mul(deployParameters.multiplierGas).div(1000), - maxPriorityFeePerGas: feedata.maxPriorityFeePerGas.mul(deployParameters.multiplierGas).div(1000), - }; - } - currentProvider.getFeeData = overrideFeeData; - } - } - } - - // Load deployer - let deployer; - if (deployParameters.deployerPvtKey) { - deployer = new ethers.Wallet(deployParameters.deployerPvtKey, currentProvider); - console.log('Using pvtKey deployer with address: ', deployer.address); - } else if (process.env.PK) { - deployer = new ethers.Wallet(process.env.PK, currentProvider); - console.log('Using PK deployer with address: ', deployer.address); - } else if (process.env.MNEMONIC) { - deployer = ethers.Wallet.fromMnemonic(process.env.MNEMONIC, 'm/44\'/60\'/0\'/0/0').connect(currentProvider); - console.log('Using MNEMONIC deployer with address: ', deployer.address); - } else { - [deployer] = (await ethers.getSigners()); - } + const currentProvider = await common.loadProvider(deployParameters, process.env); + const deployer = await common.loadDeployer(currentProvider, deployParameters); if (trustedSequencer === undefined || trustedSequencer.toLowerCase() !== deployer.address.toLowerCase()) { throw new Error('Wrong deployer address'); @@ -88,7 +52,13 @@ async function main() { 'contracts/ForkonomicToken.sol:ForkonomicToken', forkonomicTokenAddress, ); + console.log('ForkonomicToken address: ', forkonomicToken.address); + console.log('ForkonomicToken owner: ', deployer.address); const depositAmount = ethers.utils.parseEther('10'); + const tx0 = await forkonomicToken.connect(deployer).mint(polygonZkEVMBridgeAddress, ethers.utils.parseEther('100000'), { gasLimit: 500000 }); + console.log('Mint forkonomic tokens'); + console.log('by the following tx: ', tx0.hash); + const tx1 = await forkonomicToken.connect(deployer).approve(polygonZkEVMBridgeAddress, depositAmount, { gasLimit: 500000 }); console.log('Approved bridge to spend forkonomic tokens'); console.log('by the following tx: ', tx1.hash);