diff --git a/package.json b/package.json index 9b0dcbff..b7600f5a 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "verify:ZkEVM:mainnet": "npx hardhat run deployment/verifyContracts.js --network mainnet", "compile": "npx hardhat compile", "lintjs": "npx eslint ./src", - "lintjs:fix": "npx eslint ./src/deployment --fix" + "lintjs:fix": "npx eslint ./src --fix" }, "dependencies": { "chai": "^4.3.7", diff --git a/src/scripts/depositForkonomicTokenIntoBridge.js b/src/scripts/depositForkonomicTokenIntoBridge.js index 283d484a..6d2b6814 100644 --- a/src/scripts/depositForkonomicTokenIntoBridge.js +++ b/src/scripts/depositForkonomicTokenIntoBridge.js @@ -4,14 +4,15 @@ const path = require('path'); const { ethers } = require('hardhat'); require('dotenv').config({ path: path.resolve(__dirname, '../.env') }); -const deployParameters = require('../../deployment/deploy_parameters.json'); -const deploymentOutput = require('../../deployment/deploy_output.json'); - async function main() { /* * Check deploy parameters * Check that every necessary parameter is fullfilled */ + const args = process.argv.slice(2); + const deploymentName = args[0]; + const deployParameters = require(`../../deployments/${deploymentName}/deploy_parameters.json`); + const deploymentOutput = require(`../../deployments/${deploymentName}/deploy_output.json`); const mandatoryDeploymentOutput = [ 'polygonZkEVMBridgeAddress', @@ -65,7 +66,7 @@ async function main() { 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); + 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); @@ -73,18 +74,22 @@ async function main() { [deployer] = (await ethers.getSigners()); } - const bridge = await hre.ethers.getContractAt( + const bridge = await ethers.getContractAt( 'ForkableBridge', polygonZkEVMBridgeAddress, ); - const forkonomicToken = await hre.ethers.getContractAt( + const forkonomicToken = await ethers.getContractAt( 'ForkonomicToken', forkonomicTokenAddress, ); const depositAmount = ethers.utils.parseEther('10'); - await forkonomicToken.connect(deployer).approve(polygonZkEVMBridgeAddress, depositAmount, { gasLimit: 500000 }); + 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); + + // sleep for 3 secs to wait until tx is mined and nonce increase is reflected + await new Promise((r) => setTimeout(r, 3000)); await bridge.connect(deployer).bridgeAsset( 1, @@ -102,4 +107,3 @@ main().catch((e) => { console.error(e); process.exit(1); }); -