Skip to content

Commit

Permalink
eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kovalgek committed Dec 16, 2024
1 parent 7c90056 commit 0a05265
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 29 deletions.
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* eslint-disable */
module.exports = { extends: ["@commitlint/config-conventional"] };
2 changes: 1 addition & 1 deletion src/command-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawnSync } from "child_process";
import chalk from "chalk";
import { spawnSync } from "child_process";

export function runCommand({
command,
Expand Down
8 changes: 5 additions & 3 deletions src/deploy-all-contracts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { cpSync, readFileSync } from "node:fs";
import process from "node:process";

import chalk from "chalk";
import dotenv from "dotenv";
import env from "./env";
import { ethers } from 'ethers';
import { NetworkType } from "./rpc-utils";

import { runCommand } from "./command-utils";
import chalk from "chalk";
import env from "./env";
import { NetworkType } from "./rpc-utils";

export async function burnL2DeployerNonces(l2RpcUrl: string, numNonces: number) {
const l2Provider = new ethers.JsonRpcProvider(l2RpcUrl);
Expand Down
37 changes: 25 additions & 12 deletions src/deploy-gov-executor.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { writeFileSync, readFileSync } from "node:fs";
import { readFileSync,writeFileSync } from "node:fs";

import chalk from "chalk";
import { ethers } from "ethers";

import env from "./env";

const GOV_BRIDGE_EXECUTOR_PATH = "./governance-crosschain-bridges/artifacts/contracts/bridges/OptimismBridgeExecutor.sol/OptimismBridgeExecutor.json";
const MAX_DEPLOYMENT_TRIES = 3;

type ConstructorArgs = [
string, // ovmL2Messenger
string, // ethereumGovExecutor
number, // delay
number, // gracePeriod
number, // minDelay
number, // maxDelay
string // ovmGuiardian
];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function deployGovExecutor(deploymentConfig: any, rpcUrl: string) {
const contractJson = JSON.parse(
Expand All @@ -17,7 +29,8 @@ export async function deployGovExecutor(deploymentConfig: any, rpcUrl: string) {
const { abi, bytecode } = contractJson;
const provider = new ethers.JsonRpcProvider(rpcUrl);
const wallet = new ethers.Wallet(env.string("DEPLOYER_PRIVATE_KEY"), provider);
const contractFactory = new ethers.ContractFactory(abi, bytecode, wallet);

const contractFactory = new ethers.ContractFactory<ConstructorArgs, ethers.BaseContract>(abi, bytecode, wallet);

const govBridgeExecutorConfig = deploymentConfig["l2"]["govBridgeExecutor"];
const contract = await deploy(contractFactory, govBridgeExecutorConfig, 1);
Expand All @@ -30,7 +43,7 @@ export async function deployGovExecutor(deploymentConfig: any, rpcUrl: string) {
return deployedContractAddress;
}

async function deploy(contractFactory: ethers.ContractFactory<any[], ethers.BaseContract>, govBridgeExecutorConfig: Record<string, any>, tryIndex: number) {
async function deploy(contractFactory: ethers.ContractFactory<ConstructorArgs, ethers.BaseContract>, govBridgeExecutorConfig: Record<string, string | number>, tryIndex: number) {
console.log(
chalk.bold(
chalk.yellowBright(
Expand All @@ -41,13 +54,13 @@ async function deploy(contractFactory: ethers.ContractFactory<any[], ethers.Base

try {
const contract = await contractFactory.deploy(
govBridgeExecutorConfig["ovmL2Messenger"],
govBridgeExecutorConfig["ethereumGovExecutor"],
govBridgeExecutorConfig["delay"],
govBridgeExecutorConfig["gracePeriod"],
govBridgeExecutorConfig["minDelay"],
govBridgeExecutorConfig["maxDelay"],
govBridgeExecutorConfig["ovmGuiardian"],
govBridgeExecutorConfig["ovmL2Messenger"] as string,
govBridgeExecutorConfig["ethereumGovExecutor"] as string,
govBridgeExecutorConfig["delay"] as number,
govBridgeExecutorConfig["gracePeriod"] as number,
govBridgeExecutorConfig["minDelay"] as number,
govBridgeExecutorConfig["maxDelay"] as number,
govBridgeExecutorConfig["ovmGuiardian"] as string,
);
await contract.deploymentTransaction();
return contract;
Expand Down Expand Up @@ -79,9 +92,9 @@ export function saveGovExecutorDeploymentArgs(contractAddress: string, deploymen
writeFileSync(`./artifacts/${fileName}`, JSON.stringify(content, null, 2));
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function addGovExecutorToDeploymentArtifacts(govBridgeExecutor: string, deploymentResultsFilename: string) {
let newContractsConfig = configFromArtifacts(deploymentResultsFilename);
const newContractsConfig = configFromArtifacts(deploymentResultsFilename);
newContractsConfig["optimism"]["govBridgeExecutor"] = govBridgeExecutor;
writeFileSync(`./artifacts/${deploymentResultsFilename}`, JSON.stringify(newContractsConfig, null, 2));
}
Expand Down
4 changes: 3 additions & 1 deletion src/diffyscan.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { readFileSync, writeFileSync} from "node:fs";
import process from "node:process";
import { runCommand } from "./command-utils";

import dotenv from "dotenv";

import { runCommand } from "./command-utils";
import env from "./env";

const UNICHAIN_CONFIGS_PATH = "./diffyscan/config_samples/optimism/automaton";
Expand Down
1 change: 1 addition & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function isValidUrl(envValue: string) {
try {
new URL(envValue);
return true;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (_) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions src/integration-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dotenv from "dotenv";

import { runCommand } from "./command-utils";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
15 changes: 7 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@ import * as child_process from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import process from "node:process";
import env from "./env";

import "dotenv/config";
import { program } from "commander";
import { JsonRpcProvider } from "ethers";
import { once } from "stream";
import * as YAML from "yaml";

import { runDiffyscanScript, setupDiffyscan } from "./diffyscan";
import { addGovExecutorToDeploymentArtifacts, deployGovExecutor, saveGovExecutorDeploymentArgs } from "./deploy-gov-executor";
import {
burnL2DeployerNonces,
configFromArtifacts,
copyArtifacts,
populateDeployScriptEnvs,
runDeployScript,
copyArtifacts
} from "./deploy-all-contracts";
runDeployScript} from "./deploy-all-contracts";
import { addGovExecutorToDeploymentArtifacts, deployGovExecutor, saveGovExecutorDeploymentArgs } from "./deploy-gov-executor";
import { runDiffyscanScript, setupDiffyscan } from "./diffyscan";
import env from "./env";
import { runIntegrationTestsScript,setupIntegrationTests } from "./integration-tests";
import { diffyscanRpcUrl,l1RpcUrl, l2RpcUrl, localL1RpcPort, localL2RpcPort, NetworkType } from "./rpc-utils";
import { runStateMateScript, setupStateMateConfig, setupStateMateEnvs } from "./state-mate";
import { runVerificationScript, setupGovExecutorVerification } from "./verification";
import { setupIntegrationTests, runIntegrationTestsScript } from "./integration-tests";
import { NetworkType, l1RpcUrl, l2RpcUrl, localL1RpcPort, localL2RpcPort, diffyscanRpcUrl } from "./rpc-utils";

const NUM_L1_DEPLOYED_CONTRACTS = 3;

Expand Down
7 changes: 4 additions & 3 deletions src/state-mate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import process from "node:process";
import dotenv from "dotenv";
import { ethers } from "ethers";
import * as YAML from "yaml";

import { runCommand } from "./command-utils";

export function setupStateMateEnvs(ethereumRpcUrl: string, optimismRpcUrl: string) {
Expand Down Expand Up @@ -135,7 +136,7 @@ export function setupStateMateConfig(
tokenRateOracleChecks.set("MIN_TIME_BETWEEN_TOKEN_RATE_UPDATES", Number(tokenRateOracleConfig["minTimeBetweenTokenRateUpdates"]));
tokenRateOracleChecks.set("OLDEST_RATE_ALLOWED_IN_PAUSE_TIME_SPAN", Number(tokenRateOracleConfig["oldestRateAllowedInPauseTimeSpan"]));
tokenRateOracleChecks.set("TOKEN_RATE_OUTDATED_DELAY", Number(tokenRateOracleConfig["tokenRateOutdatedDelay"]));
tokenRateOracleChecks.set("isTokenRateUpdatesPaused", !Boolean(tokenRateOracleConfig["updateEnabled"]));
tokenRateOracleChecks.set("isTokenRateUpdatesPaused", !tokenRateOracleConfig["updateEnabled"]);

// L2TokenBridge
const l2TokenBridge = l2Contracts.get("tokenBridge") as YAML.YAMLMap;
Expand All @@ -157,15 +158,15 @@ export function setupStateMateConfig(
checks.set("eip712Domain", ["0x0f",name,version,l2ChainId,address,"0x0000000000000000000000000000000000000000000000000000000000000000",[]]);
}

function domainSeparator(name: string, version: string, l2ChainId: number, addr: string) {
function domainSeparator(name: string, version: string, chainId: number, addr: string) {
const hashedName = ethers.keccak256(ethers.toUtf8Bytes(name));
const hashedVersion = ethers.keccak256(ethers.toUtf8Bytes(version));
const typeHash = ethers.keccak256(
ethers.toUtf8Bytes("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
);
const encodedParams = ethers.AbiCoder.defaultAbiCoder().encode(
["bytes32", "bytes32", "bytes32", "uint256", "address"],
[typeHash, hashedName, hashedVersion, l2ChainId, addr],
[typeHash, hashedName, hashedVersion, chainId, addr],
);
return ethers.keccak256(encodedParams);
}
Expand Down
4 changes: 3 additions & 1 deletion src/verification.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { readFileSync } from "node:fs";

import dotenv from "dotenv";

import { runCommand } from "./command-utils";
import { readFileSync } from "node:fs";
import env from "./env";

export function runVerificationScript({
Expand Down

0 comments on commit 0a05265

Please sign in to comment.