Skip to content

Commit

Permalink
update ci to add lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zkbenny committed Feb 4, 2024
1 parent 2b5eabd commit b0de775
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 38 deletions.
5 changes: 0 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@
"mocha": true
},
"globals" : {
"artifacts": "readonly",
"contract": "readonly",
"web3": "readonly",
"extendEnvironment": "readonly",
"expect": "readonly"
}
}
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Lint check
run: npm lint
- name: Compile contracts
run: npm run compile
- name: Test contracts
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
},
"scripts": {
"compile": "npx hardhat compile",
"test": "npx hardhat test"
"test": "npx hardhat test",
"lint": "npm run lint:js && npm run lint:sol",
"lint:fix": "npm run lint:js:fix && npm run lint:sol:fix",
"lint:js": "prettier --log-level warn --ignore-path .gitignore '**/*.{js,ts}' --check && eslint --ignore-path .gitignore .",
"lint:js:fix": "prettier --log-level warn --ignore-path .gitignore '**/*.{js,ts}' --write && eslint --ignore-path .gitignore . --fix",
"lint:sol": "prettier --log-level warn --ignore-path .gitignore 'contracts/**/*.sol' --check && solhint 'contracts/**/*.sol'",
"lint:sol:fix": "prettier --log-level warn --ignore-path .gitignore 'contracts/**/*.sol' --write"
},
"dependencies": {
"@arbitrum/nitro-contracts": "^1.1.0",
Expand Down
1 change: 1 addition & 0 deletions script/deploy_arbitrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs');
const { getImplementationAddress } = require('@openzeppelin/upgrades-core');
const { verifyContractCode, createOrGetDeployLog, ChainContractDeployer, getDeployTx } = require('./utils');
const logName = require('./deploy_log_name');
const { task, types } = require('hardhat/config');

function getArbitratorContractName(dummy) {
return dummy ? 'DummyArbitrator' : 'Arbitrator';
Expand Down
1 change: 1 addition & 0 deletions script/deploy_eth_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
readDeployLogField,
} = require('./utils');
const logName = require('./deploy_log_name');
const { task, types } = require('hardhat/config');

task('deployETHGateway', 'Deploy ETH Gateway')
.addParam(
Expand Down
1 change: 1 addition & 0 deletions script/deploy_l1_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
} = require('./utils');
const logName = require('./deploy_log_name');
const { zkLinkConfig } = require('./zklink_config');
const { task, types } = require('hardhat/config');

task('deployL1Gateway', 'Deploy L1 Gateway')
.addParam(
Expand Down
1 change: 1 addition & 0 deletions script/deploy_l2_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
} = require('./utils');
const logName = require('./deploy_log_name');
const { zkLinkConfig } = require('./zklink_config');
const { task, types } = require('hardhat/config');

task('deployL2Gateway', 'Deploy L2 Gateway')
.addParam('zklink', 'The zklink address (default get from zkLink deploy log)', undefined, types.string, true)
Expand Down
1 change: 1 addition & 0 deletions script/deploy_zklink.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
readDeployContract,
} = require('./utils');
const logName = require('./deploy_log_name');
const { task, types } = require('hardhat/config');

function getZkLinkContractName(dummy) {
return dummy ? 'DummyZkLink' : 'ZkLink';
Expand Down
2 changes: 2 additions & 0 deletions script/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ async function verifyContractCode(hardhat, address, constructorArguments) {
// contract code may be not exist after tx send to chain
// try every one minutes if verify failed
console.log('verify %s code...', address);

/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
while (true) {
try {
await hardhat.run('verify:verify', {
Expand Down
32 changes: 0 additions & 32 deletions script/zklink_config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
// zkLink chain info
const zkLinkConfig = require('./ChainConfig.json');

function getChainConfig(zkLinkConfig, chainIdOrNet, mainnet) {
for (let [net, chainConfig] of Object.entries(zkLinkConfig)) {
if ((chainConfig.zkLinkChainId === chainIdOrNet || net === chainIdOrNet) && chainConfig.mainnet === mainnet) {
return {
net: net,
chainConfig: chainConfig,
};
}
}
return {
net: undefined,
chainConfig: undefined,
};
}

function getEthChainConfig(zkLinkConfig, mainnet) {
for (let [net, chainConfig] of Object.entries(zkLinkConfig)) {
if (chainConfig.mainnet === mainnet && chainConfig.l1Gateway !== undefined) {
return {
net: net,
chainConfig: chainConfig,
};
}
}
return {
net: undefined,
chainConfig: undefined,
};
}

module.exports = {
zkLinkConfig,
getChainConfig,
getEthChainConfig,
};

0 comments on commit b0de775

Please sign in to comment.