Skip to content

Commit

Permalink
Merge pull request #10 from zkLinkProtocol/issues_9
Browse files Browse the repository at this point in the history
modify log name and update config
  • Loading branch information
zkbenny committed Mar 28, 2024
2 parents a5b5c7e + d20b889 commit 7316b31
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# defaultNetwork
DEFAULT_NETWORK=zklinkGoerli

# wallet private key
WALLET_PRIVATE_KEY=0x
8 changes: 6 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import '@matterlabs/hardhat-zksync-verify';
import '@matterlabs/hardhat-zksync-upgradable';
import 'solidity-coverage';
import 'hardhat-abi-exporter';
import * as dotenv from 'dotenv';
import './script/deploy_portal';
import './script/deploy_merge_token';

dotenv.config();

/**
* @type import('hardhat/config').HardhatUserConfig
*/
Expand Down Expand Up @@ -41,6 +44,7 @@ const config: HardhatUserConfig = {
},
],
},
defaultNetwork: process.env.DEFAULT_NETWORK || 'hardhat',
networks: {
hardhat: {
zksync: false,
Expand All @@ -50,14 +54,14 @@ const config: HardhatUserConfig = {
ethNetwork: 'goerli',
verifyURL: 'https://goerli.explorer.zklink.io/contract_verification',
zksync: true,
accounts: ["0x0000000000000000000000000000000000000000000000000000000000000000"]
accounts: [process.env.WALLET_PRIVATE_KEY || ''],
},
zklinkNova: {
url: 'https://rpc.zklink.io',
ethNetwork: 'mainnet',
verifyURL: 'https://explorer.zklink.io/contract_verification',
zksync: true,
accounts: ["0x0000000000000000000000000000000000000000000000000000000000000000"]
accounts: [process.env.WALLET_PRIVATE_KEY || '']
}
},
zksolc: {
Expand Down
2 changes: 1 addition & 1 deletion script/deploy_log_name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// consumed in deploy_portal.ts
export const DEPLOY_PORTAL_LOG = 'deploy_portal';
export const DEPLOY_PORTAL_LOG_PREFIX = 'deploy_portal';
export const DEPLOY_LOG_PORTAL_TARGET = 'portalTarget';
export const DEPLOY_LOG_PORTAL_TARGET_VERIFIED = 'portalTargetVerified';
export const DEPLOY_LOG_PORTAL_PROXY = 'portalProxy';
Expand Down
4 changes: 2 additions & 2 deletions script/deploy_merge_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from './utils';
import {
DEPLOY_LOG_DEPLOYER,
DEPLOY_PORTAL_LOG,
DEPLOY_PORTAL_LOG_PREFIX,
DEPLOY_LOG_PORTAL_PROXY,
DEPLOY_MERGETOKEN_LOG_PREFIX,
DEPLOY_LOG_MERGETOKEN,
Expand Down Expand Up @@ -41,7 +41,7 @@ task('deployMergeToken', 'Deploy MergeToken')

let portal = taskArgs.portal;
if (portal === undefined) {
portal = readDeployContract(DEPLOY_PORTAL_LOG, DEPLOY_LOG_PORTAL_PROXY, hardhat.network.name);
portal = readDeployContract(DEPLOY_PORTAL_LOG_PREFIX, DEPLOY_LOG_PORTAL_PROXY, hardhat.network.name);
}
let skipVerify = taskArgs.skipVerify;
console.log('skip verify contracts?', skipVerify);
Expand Down
18 changes: 9 additions & 9 deletions script/deploy_portal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
readDeployContract,
} from './utils';
import {
DEPLOY_PORTAL_LOG,
DEPLOY_PORTAL_LOG_PREFIX,
DEPLOY_LOG_DEPLOYER,
DEPLOY_LOG_PORTAL_TARGET,
DEPLOY_LOG_PORTAL_TARGET_VERIFIED,
Expand Down Expand Up @@ -37,14 +37,14 @@ task('deployPortal', 'Deploy portal')
await contractDeployer.init();
const deployerWallet = contractDeployer.deployerWallet;

const { deployLogPath, deployLog } = createOrGetDeployLog(DEPLOY_PORTAL_LOG, hardhat.network.name);
const { deployLogPath, deployLog } = createOrGetDeployLog(DEPLOY_PORTAL_LOG_PREFIX, hardhat.network.name);
const dLog = deployLog as any;
dLog[DEPLOY_LOG_DEPLOYER] = await deployerWallet?.getAddress();
fs.writeFileSync(deployLogPath, JSON.stringify(dLog, null, 2));

// deploy portal
let portalAddr;
if (!(DEPLOY_PORTAL_LOG in dLog)) {
if (!(DEPLOY_LOG_PORTAL_PROXY in dLog)) {
console.log('deploy portal...');
const contractName = getPortalContractName();
const contract = await contractDeployer.deployProxy(contractName, [], {
Expand Down Expand Up @@ -93,7 +93,7 @@ task('upgradePortal', 'Upgrade portal')
let skipVerify = taskArgs.skipVerify;
console.log('skipVerify', skipVerify);

const { deployLogPath, deployLog } = createOrGetDeployLog(DEPLOY_PORTAL_LOG, hardhat.network.name);
const { deployLogPath, deployLog } = createOrGetDeployLog(DEPLOY_PORTAL_LOG_PREFIX, hardhat.network.name);
const dLog = deployLog as any;
const contractAddr = dLog[DEPLOY_LOG_PORTAL_PROXY];
if (contractAddr === undefined) {
Expand Down Expand Up @@ -141,7 +141,7 @@ task('deployPortalTarget', 'Deploy portal target')
await contractDeployer.init();
const deployerWallet = contractDeployer.deployerWallet;

const { deployLogPath, deployLog } = createOrGetDeployLog(DEPLOY_PORTAL_LOG, hardhat.network.name);
const { deployLogPath, deployLog } = createOrGetDeployLog(DEPLOY_PORTAL_LOG_PREFIX, hardhat.network.name);
const dLog = deployLog as any;
dLog[DEPLOY_LOG_DEPLOYER] = await deployerWallet?.getAddress();
fs.writeFileSync(deployLogPath, JSON.stringify(dLog, null, 2));
Expand Down Expand Up @@ -180,7 +180,7 @@ task('encodeAddSourceToken', 'Get the calldata of add source token for portal')
console.log('mergeToken', mergeToken);
console.log('limit', limit);
if (portal === undefined) {
portal = readDeployContract(DEPLOY_PORTAL_LOG, DEPLOY_LOG_PORTAL_PROXY, hre.network.name);
portal = readDeployContract(DEPLOY_PORTAL_LOG_PREFIX, DEPLOY_LOG_PORTAL_PROXY, hre.network.name);
}
console.log('portal address', portal);

Expand Down Expand Up @@ -208,7 +208,7 @@ task('encodeRemoveSourceToken', 'Get the calldata of remove source token for por
let portal = taskArgs.portal;
console.log('sourceToken', sourceToken);
if (portal === undefined) {
portal = readDeployContract(DEPLOY_PORTAL_LOG, DEPLOY_LOG_PORTAL_PROXY, hre.network.name);
portal = readDeployContract(DEPLOY_PORTAL_LOG_PREFIX, DEPLOY_LOG_PORTAL_PROXY, hre.network.name);
}
console.log('portal address', portal);

Expand All @@ -230,7 +230,7 @@ task('encodeUpdateDepositStatus', 'Get the calldata of update deposit status for
console.log('sourceToken', sourceToken);
console.log('lock status', lock);
if (portal === undefined) {
portal = readDeployContract(DEPLOY_PORTAL_LOG, DEPLOY_LOG_PORTAL_PROXY, hre.network.name);
portal = readDeployContract(DEPLOY_PORTAL_LOG_PREFIX, DEPLOY_LOG_PORTAL_PROXY, hre.network.name);
}
console.log('portal address', portal);

Expand All @@ -252,7 +252,7 @@ task('encodeUpdateDepositLimit', 'Get the calldata of update deposit limit for p
console.log('sourceToken', sourceToken);
console.log('limit', limit);
if (portal === undefined) {
portal = readDeployContract(DEPLOY_PORTAL_LOG, DEPLOY_LOG_PORTAL_PROXY, hre.network.name);
portal = readDeployContract(DEPLOY_PORTAL_LOG_PREFIX, DEPLOY_LOG_PORTAL_PROXY, hre.network.name);
}
console.log('portal address', portal);

Expand Down

0 comments on commit 7316b31

Please sign in to comment.