Skip to content

Commit

Permalink
update hardhat config
Browse files Browse the repository at this point in the history
  • Loading branch information
zkbenny committed Mar 28, 2024
1 parent 02ba212 commit e813696
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

9 changes: 8 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const config: HardhatUserConfig = {
},
],
},
defaultNetwork: process.env.DEFAULT_NETWORK || 'hardhat',
networks: {
hardhat: {
zksync: false,
Expand All @@ -51,7 +50,15 @@ const config: HardhatUserConfig = {
ethNetwork: 'goerli',
verifyURL: 'https://goerli.explorer.zklink.io/contract_verification',
zksync: true,
accounts: ["YOUR_KEY"]
},
zklinkNova: {
url: 'https://rpc.zklink.io',
ethNetwork: 'mainnet',
verifyURL: 'https://explorer.zklink.io/contract_verification',
zksync: true,
accounts: ["YOUR_KEY"]
}
},
zksolc: {
version: '1.3.22',
Expand Down
26 changes: 12 additions & 14 deletions script/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as fs from 'fs';
import * as path from 'path';
import { Wallet, Provider } from 'zksync-ethers';
import { Deployer } from '@matterlabs/hardhat-zksync-deploy';
import { HardhatRuntimeEnvironment, Network, HttpNetworkConfig, HardhatNetworkAccountConfig } from 'hardhat/types';
import { BaseContract, Signer, Contract, ContractTransactionResponse } from 'ethers';
import { HardhatRuntimeEnvironment, Network, HttpNetworkConfig } from 'hardhat/types';
import { BaseContract, Signer, ContractTransactionResponse } from 'ethers';
import { DeployProxyOptions, UpgradeProxyOptions } from '@openzeppelin/hardhat-upgrades/src/utils/options';
import * as dotenv from 'dotenv';
dotenv.config();
Expand Down Expand Up @@ -127,9 +127,8 @@ export class ChainContractDeployer {
// a flag to identify if chain is zksync
this.zksync = network.zksync !== undefined && network.zksync;
console.log('deploy on zksync?', this.zksync);

if (!process.env.WALLET_PRIVATE_KEY) throw "⛔️ Wallet private key wasn't found in .env file!";
const deployerKey = process.env.WALLET_PRIVATE_KEY;
// use the first account of accounts in the hardhat network config as the deployer
const deployerKey: string = (networkConfig.accounts as string[])[0];
if (this.zksync) {
this.zkSyncProvider = new Provider((networkConfig as HttpNetworkConfig).url);
this.deployerWallet = new Wallet(deployerKey, this.zkSyncProvider);
Expand Down Expand Up @@ -158,27 +157,26 @@ export class ChainContractDeployer {
}

async deployProxy(contractName: string, initArgs: any[], opts: DeployProxyOptions) {
let { initializer, constructorArgs, kind } = opts;
if (constructorArgs === undefined) {
constructorArgs = [];
if (opts.constructorArgs === undefined) {
opts.constructorArgs = [];
}
if (kind === undefined) {
kind = 'uups';
if (opts.kind === undefined) {
opts.kind = 'uups';
}
let contract;
if (this.zksync) {
const artifact = await (this.zkSyncDeployer as Deployer).loadArtifact(contractName);
contract = await this.hardhat.zkUpgrades.deployProxy(this.deployerWallet as Wallet, artifact, initArgs, {
kind: kind,
constructorArgs: constructorArgs,
kind: opts.kind,
constructorArgs: opts.constructorArgs,
unsafeAllow: opts.unsafeAllow,
initializer: opts.initializer,
});
} else {
const factory = await this.hardhat.ethers.getContractFactory(contractName, this.deployerWallet);
contract = await this.hardhat.upgrades.deployProxy(factory, initArgs, {
kind: kind,
constructorArgs: constructorArgs,
kind: opts.kind,
constructorArgs: opts.constructorArgs,
unsafeAllow: opts.unsafeAllow,
initializer: opts.initializer,
});
Expand Down

0 comments on commit e813696

Please sign in to comment.