Skip to content

Commit

Permalink
zk fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kelemeno committed Jan 26, 2024
1 parent 4dfd153 commit 44f4f6a
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 35 deletions.
6 changes: 3 additions & 3 deletions l1-contracts/scripts/deploy-erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { web3Provider } from "./utils";
import * as fs from "fs";
import * as path from "path";

import { deployTokens,TokenDescription } from "../src.ts/deploy-token";
import { deployTokens, TokenDescription } from "../src.ts/deploy-token";

const testConfigPath = path.join(process.env.ZKSYNC_HOME as string, "etc/test_config/constant");
const ethTestConfig = JSON.parse(fs.readFileSync(`${testConfigPath}/eth.json`, { encoding: "utf-8" }));
Expand Down Expand Up @@ -51,8 +51,8 @@ async function main() {
const wallet = cmd.privateKey
? new Wallet(cmd.privateKey, provider)
: Wallet.fromMnemonic(ethTestConfig.mnemonic, "m/44'/60'/0'/0/1").connect(provider);
console.log(JSON.stringify((await deployTokens(tokens, wallet, ethTestConfig.mnemonic, true, false)), null, 2));

console.log(JSON.stringify(await deployTokens(tokens, wallet, ethTestConfig.mnemonic, true, false), null, 2));
});

await program.parseAsync(process.argv);
Expand Down
6 changes: 4 additions & 2 deletions l1-contracts/scripts/deploy-weth-bridges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Deployer } from "../src.ts/deploy";
import { formatUnits, parseUnits } from "ethers/lib/utils";
import * as fs from "fs";
import * as path from "path";
import { GAS_MULTIPLIER, web3Provider} from "./utils";
import { GAS_MULTIPLIER, web3Provider } from "./utils";

const provider = web3Provider();
const testConfigPath = path.join(process.env.ZKSYNC_HOME as string, "etc/test_config/constant");
Expand All @@ -29,7 +29,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ async function main() {
const ownerAddress = cmd.ownerAddress ? cmd.ownerAddress : deployWallet.address;
console.log(`Using owner address: ${ownerAddress}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

let nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/erc20-deploy-on-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/erc20-finish-deployment-on-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ async function main() {
"m/44'/60'/0'/0/0"
).connect(l2Provider);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/initialize-erc20-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/initialize-governance-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const ownerAddress = cmd.ownerAddress ? cmd.ownerAddress : deployWallet.address;
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/initialize-governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const ownerAddress = cmd.ownerAddress ? cmd.ownerAddress : deployWallet.address;
Expand Down
8 changes: 6 additions & 2 deletions l1-contracts/scripts/initialize-l2-weth-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const deployer = new Deployer({
Expand Down Expand Up @@ -148,7 +150,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/initialize-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/initialize-weth-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/migrate-governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ async function main() {
.option("--gas-price <gas-price>")
.option("--refund-recipient <refund-recipient>")
.action(async (cmd) => {
const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const refundRecipient = cmd.refundRecipient;
Expand Down
6 changes: 4 additions & 2 deletions l1-contracts/scripts/register-hyperchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { formatUnits, parseUnits } from "ethers/lib/utils";
import * as fs from "fs";
import * as path from "path";
import { Deployer } from "../src.ts/deploy";
import {GAS_MULTIPLIER, ADDRESS_ONE, getTokens, web3Provider } from "./utils";
import { GAS_MULTIPLIER, ADDRESS_ONE, getTokens, web3Provider } from "./utils";

const provider = web3Provider();
const testConfigPath = path.join(process.env.ZKSYNC_HOME as string, "etc/test_config/constant");
Expand Down Expand Up @@ -38,7 +38,9 @@ async function main() {
const ownerAddress = cmd.governorAddress || deployWallet.address;
console.log(`Using governor address: ${ownerAddress}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/weth-deploy-on-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
4 changes: 3 additions & 1 deletion l1-contracts/scripts/weth-finish-deployment-on-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ async function main() {
"m/44'/60'/0'/0/0"
).connect(l2Provider);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
Expand Down
28 changes: 16 additions & 12 deletions l1-contracts/src.ts/deploy-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ export type TokenDescription = Token & {
implementation?: string;
};

export async function deployTokens(tokens: Token[], wallet: Wallet, mnemonic: any, mintTokens: boolean=false, verbose : boolean = false): Promise<Token[]> {
const result :Token[] = [];
export async function deployTokens(
tokens: Token[],
wallet: Wallet,
mnemonic: any,
mintTokens: boolean = false,
verbose: boolean = false
): Promise<Token[]> {
const result: Token[] = [];
for (const token of tokens) {

const implementation = (token.symbol != "WETH") ? DEFAULT_ERC20 : "WETH9" ;
const implementation = token.symbol != "WETH" ? DEFAULT_ERC20 : "WETH9";
const tokenFactory = await hardhat.ethers.getContractFactory(implementation, wallet);
const args = (token.symbol != "WETH") ? [`${token.name} (${process.env.CHAIN_ETH_NETWORK})`, token.symbol, token.decimals] : [];
const args =
token.symbol != "WETH" ? [`${token.name} (${process.env.CHAIN_ETH_NETWORK})`, token.symbol, token.decimals] : [];
if (verbose) {
console.log(`Deploying testnet ${token.symbol}`, implementation);
}
Expand All @@ -34,21 +40,19 @@ export async function deployTokens(tokens: Token[], wallet: Wallet, mnemonic: an
console.log(`Token ${token.symbol} deployed at ${erc20.address}`);
}

if ((token.symbol !== "WETH") && mintTokens) {
if (token.symbol !== "WETH" && mintTokens) {
await erc20.mint(wallet.address, parseEther("3000000000"));
}
if (mintTokens) {
for (let i = 0; i < 10; ++i) {
const testWallet = Wallet.fromMnemonic(mnemonic as string, "m/44'/60'/0'/0/" + i).connect(
wallet.provider
);
if (token.symbol !== "WETH") {
const testWallet = Wallet.fromMnemonic(mnemonic as string, "m/44'/60'/0'/0/" + i).connect(wallet.provider);
if (token.symbol !== "WETH") {
await erc20.mint(testWallet.address, parseEther("3000000000"));
}
}
}

result.push(token);
}
return result;
}
}
4 changes: 3 additions & 1 deletion l1-contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ export class Deployer {
);

if (this.verbose) {
console.log(`StateTransitionManagerProxy deployed, with protocol version: ${protocolVersion}, gasUsed: ${contractAddress}`);
console.log(
`StateTransitionManagerProxy deployed, with protocol version: ${protocolVersion}, gasUsed: ${contractAddress}`
);
console.log(`CONTRACTS_STATE_TRANSITION_PROXY_ADDR=${contractAddress}`);
}

Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/test/test_config/constant/hardhat.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@
"decimals": 18,
"address": "0xCadADb33ff7F0061f96eA54567756c1F0e7DCC78"
}
]
]
2 changes: 1 addition & 1 deletion l1-contracts/test/unit_tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export async function initialDeployment(
ownerAddress: string,
gasPrice: BigNumberish,
extraFacets: FacetCut[],
baseTokenName?: string,
baseTokenName?: string
): Promise<Deployer> {
process.env.ETH_CLIENT_CHAIN_ID = (await deployWallet.getChainId()).toString();

Expand Down

0 comments on commit 44f4f6a

Please sign in to comment.