Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundedgar committed Apr 25, 2024
1 parent 9da26f2 commit 25b6592
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 35 deletions.
2 changes: 0 additions & 2 deletions src/scripts/mintFor.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ async function main() {
}
const {
maticTokenAddress,
trustedSequencer,
deployerAddress,
} = deploymentOutput;

const forkonomicTokenAddress = maticTokenAddress;
Expand Down
41 changes: 21 additions & 20 deletions src/scripts/saveForkDeployment.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
/* eslint-disable import/no-dynamic-require, global-require */
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved, no-restricted-syntax */
/* eslint-disable no-await-in-loop, no-constant-condition, no-console, no-inner-declarations, no-undef, import/no-unresolved, no-restricted-syntax */
const path = require('path');
const fs = require('fs');
const { ethers } = require('hardhat');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
const common = require('../common/common');

const FILTER_RANGE = 1000;

async function main() {

const args = process.argv.slice(2);
const deploymentName = args[0];
const whichFork = parseInt(args[1]);
const whichFork = parseInt(args[1], 10);

if (whichFork !== 1 && whichFork !== 2) {
throw new Error("Usage: node saveForkDeployment.js <old_deployment> <1_or_2> [<fork_block_number]> [<new_name>]");
throw new Error('Usage: node saveForkDeployment.js <old_deployment> <1_or_2> [<fork_block_number]> [<new_name>]');
}

// Optionally we can specify the block number to avoid a slow log lookup
// If you pass nothing or "0" we will try to fetch it automatically
let forkBlockNumber = args.length >= 3 ? parseInt(args[2]) : 0;
/*
* Optionally we can specify the block number to avoid a slow log lookup
* If you pass nothing or "0" we will try to fetch it automatically
*/
let forkBlockNumber = args.length >= 3 ? parseInt(args[2], 10) : 0;

// Optionally you can pass in the name of the new chain, otherwise we'll add _1 or _2 to the old chain
const newDeploymentName = args.length >= 4 ? args[3] : deploymentName + "_" + whichFork;
const newDeploymentName = args.length >= 4 ? args[3] : `${deploymentName}_${whichFork}`;

const deploymentOutput = require(`../../deployments/${deploymentName}/deploy_output.json`);
const deployParameters = require(`../../deployments/${deploymentName}/deploy_parameters.json`);
Expand All @@ -31,13 +33,13 @@ async function main() {
const newDeploymentPath = path.resolve(__dirname, `../../deployments/${newDeploymentName}`);

if (fs.existsSync(newDeploymentPath)) {
throw new Error("New deployment directory already exists. Delete it to create it fresh. "+newDeploymentPath);
throw new Error(`New deployment directory already exists. Delete it to create it fresh. ${newDeploymentPath}`);
}

const currentProvider = await common.loadProvider(deployParameters, process.env);
const deployer = await common.loadDeployer(currentProvider, deployParameters);

const parentForkingManagerAddress = deploymentOutput['forkingManager'];
const parentForkingManagerAddress = deploymentOutput.forkingManager;
console.log('looking up children of', parentForkingManagerAddress);

const parentForkingManager = (await ethers.getContractAt(
Expand All @@ -52,7 +54,7 @@ async function main() {
)).connect(deployer);

const children = await parentForkingManager.getChildren();
const forkingManagerAddress = children[whichFork-1];
const forkingManagerAddress = children[whichFork - 1];

const forkingManager = (await ethers.getContractAt(
'contracts/ForkingManager.sol:ForkingManager',
Expand All @@ -79,11 +81,11 @@ async function main() {
const lastVerifiedBatch = parentZkEVM.lastVerifiedBatch();
deploymentOutput.genesisRoot = parentZkEVM.batchNumToStateRoot(lastVerifiedBatch);

let endBlock = await ethers.provider.getBlockNumber()
let endBlock = await ethers.provider.getBlockNumber();
const initializedFilter = forkingManager.filters.Initialized();
if (forkBlockNumber == 0) {
if (forkBlockNumber === 0) {
console.log('Searching back through logs for the fork block number. If this takes too long you may prefer to pass it manually.');
while(true) {
while (true) {
let startBlock = endBlock - FILTER_RANGE;
if (startBlock < 0) {
startBlock = 0;
Expand All @@ -95,7 +97,7 @@ async function main() {
console.log('Found fork block number at', forkBlockNumber);
break;
}
if (startBlock == 0) {
if (startBlock === 0) {
console.log('Fork block not found, you may be able to set it manually.');
break;
}
Expand All @@ -106,14 +108,13 @@ async function main() {
deploymentOutput.deploymentBlockNumber = forkBlockNumber;

console.log('Saving new deployment at', newDeploymentPath);
fs.cpSync(oldDeploymentPath, newDeploymentPath, {recursive: true});

fs.writeFileSync(newDeploymentPath+'/deploy_output.json', JSON.stringify(deploymentOutput, null, 1));
fs.writeFileSync(newDeploymentPath+'/deploy_parameters.json', JSON.stringify(deployParameters, null, 1));
fs.cpSync(oldDeploymentPath, newDeploymentPath, { recursive: true });

fs.writeFileSync(`${newDeploymentPath}/deploy_output.json`, JSON.stringify(deploymentOutput, null, 1));
fs.writeFileSync(`${newDeploymentPath}/deploy_parameters.json`, JSON.stringify(deployParameters, null, 1));
}

main().catch((e) => {
console.error(e);
process.exit(1);
});
});
24 changes: 11 additions & 13 deletions src/scripts/sendTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,31 @@ require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
const common = require('../common/common');

async function main() {

const args = process.argv.slice(2);
const deploymentName = args[0];
const recipient = args[1];
const amount = ethers.BigNumber.from(args[2]);

const deployParameters = require(`../../deployments/${deploymentName}/deploy_parameters.json`);
const deploymentOutput = require(`../../deployments/${deploymentName}/deploy_output.json`);

const currentProvider = await common.loadProvider(deployParameters, process.env);
const deployer = await common.loadDeployer(currentProvider, deployParameters);

const bal = await currentProvider.getBalance(deployer.address)
const gas_price = await currentProvider.getGasPrice()
const nonce = await currentProvider.getTransactionCount(deployer.address, 'latest')
const gas_limit = 21000;
// const bal = await currentProvider.getBalance(deployer.address);
const gasPrice = await currentProvider.getGasPrice();
const nonce = await currentProvider.getTransactionCount(deployer.address, 'latest');
const gasLimit = 21000;

const txdata = {
to: recipient,
value: amount,
nonce: nonce,
gasLimit: ethers.utils.hexlify(gas_limit),
gasPrice: gas_price,
}
to: recipient,
value: amount,
nonce,
gasLimit: ethers.utils.hexlify(gasLimit),
gasPrice,
};

const response = await deployer.sendTransaction(txdata);
console.log('sent tx', response.hash)
console.log('sent tx', response.hash);
}

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

0 comments on commit 25b6592

Please sign in to comment.