Skip to content

Commit

Permalink
update deposit script (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
josojo authored Dec 5, 2023
1 parent 51cc03e commit dbf131d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 12 additions & 8 deletions src/scripts/depositForkonomicTokenIntoBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -65,26 +66,30 @@ 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);
} else {
[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,
Expand All @@ -102,4 +107,3 @@ main().catch((e) => {
console.error(e);
process.exit(1);
});

0 comments on commit dbf131d

Please sign in to comment.