Commit c87e4c74 authored by Rajiv Patel-O'Connor's avatar Rajiv Patel-O'Connor Committed by GitHub

Use Eslint instead of Tslint (#1005)

* removed tslint

* forgot to commit files

* made .eslintrc.js consistent for all subdirs and other cleanup

* [removed] includes and files keys from tsconfig.json

* removed file level linting exceptions and added details to line level

* added changeset

* fixed newly introduced linting errors from rebase

* enable json import for batch submitter

* removed ecdsa-coder

* maybe a tsconfig issue?

* Update deploy.ts
Co-authored-by: default avatarsmartcontracts <kelvinfichter@gmail.com>
Co-authored-by: default avatarplatocrat <37757724+platocrat@users.noreply.github.com>
parent 14243701
---
'@eth-optimism/contracts': patch
---
Migrated from tslint to eslint. The preference for lint exceptions is as follows: line level, block level, file level, package level.
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": [
"prettier",
],
"ignorePatterns": ["dist/**/*.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"eslint-plugin-import",
"eslint-plugin-unicorn",
"eslint-plugin-jsdoc",
"eslint-plugin-prefer-arrow",
"eslint-plugin-react",
"@typescript-eslint",
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-shadow": [
"error",
{
"hoist": "all"
}
],
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/quotes": "off",
"@typescript-eslint/semi": [
"off",
null
],
"@typescript-eslint/triple-slash-reference": [
"error",
{
"path": "always",
"types": "prefer-import",
"lib": "always"
}
],
"@typescript-eslint/type-annotation-spacing": "off",
"@typescript-eslint/unified-signatures": "error",
"arrow-parens": [
"off",
"always"
],
"brace-style": [
"off",
"off"
],
"comma-dangle": "off",
"complexity": "off",
"constructor-super": "error",
"curly": "error",
"dot-notation": "off",
"eol-last": "off",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-blacklist": "off",
"id-match": "off",
"import/no-extraneous-dependencies": [
"error"
],
"import/no-internal-modules": "off",
"import/order": "off",
"indent": "off",
"jsdoc/check-alignment": "error",
"jsdoc/check-indentation": "error",
"jsdoc/newline-after-description": "error",
"linebreak-style": "off",
"max-classes-per-file": "off",
"max-len": "off",
"new-parens": "off",
"newline-per-chained-call": "off",
"no-bitwise": "off",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "off",
"no-debugger": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-empty": "error",
"no-eval": "error",
"no-extra-bind": "error",
"no-extra-semi": "off",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-irregular-whitespace": "off",
"no-multiple-empty-lines": "off",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-redeclare": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "off",
"no-undef-init": "error",
"no-underscore-dangle": "off",
"no-unsafe-finally": "error",
"no-unused-expressions": "off",
"no-unused-labels": "error",
"no-use-before-define": "off",
"no-var": "error",
"object-shorthand": "error",
"one-var": [
"error",
"never"
],
"padded-blocks": [
"off",
{
"blocks": "never"
},
{
"allowSingleLineBlocks": true
}
],
"prefer-arrow/prefer-arrow-functions": "error",
"prefer-const": "error",
"prefer-object-spread": "error",
"quote-props": "off",
"quotes": "off",
"radix": "error",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-tag-spacing": [
"off",
{
"afterOpening": "allow",
"closingSlash": "allow"
}
],
"react/jsx-wrap-multilines": "off",
"semi": "off",
"space-before-blocks": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"off",
"never"
],
"unicorn/prefer-ternary": "off",
"use-isnan": "error",
"valid-typeof": "off"
}
};
......@@ -211,8 +211,7 @@ contract('ERC20', (accounts) => {
const balance02 = await token.balanceOf.call(accounts[ 0 ])
assert.strictEqual(balance02.toNumber(), 9980)
})
/* eslint-disable no-underscore-dangle */
it('events: should fire Transfer event properly', async () => {
const res = await token.transfer(accounts[ 1 ], '2666', { from: accounts[ 0 ], gasPrice: 0 })
const transferLog = res.logs.find(
......
module.exports = {
"extends": "../.eslintrc.js"
}
......@@ -8,7 +8,7 @@
"scripts": {
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config ./.prettierrc.json --write 'test/**/*.ts'",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"build:integration": "./scripts/build.sh",
"build:contracts": "hardhat compile",
"build:contracts:ovm": "hardhat compile --network optimism",
......@@ -23,15 +23,25 @@
"@ethersproject/providers": "^5.0.24",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@types/chai-as-promised": "^7.1.3",
"@types/chai": "^4.2.17",
"@types/chai-as-promised": "^7.1.3",
"@types/mocha": "^8.2.2",
"@types/rimraf": "^3.0.0",
"@types/shelljs": "^0.8.8",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.3.3",
"chai-as-promised": "^7.1.1",
"docker-compose": "^0.23.8",
"envalid": "^7.1.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.0.32",
"hardhat": "^2.2.1",
......
......@@ -3,6 +3,6 @@
"compilerOptions": {
"resolveJsonModule": true
},
"include": ["./test", "sync-tests/*.ts"],
"include": ["./test", "sync-tests/*.ts", "./artifacts/**/*.json", "./artifacts-ovm/**/*.json"],
"files": ["./hardhat.config.ts"]
}
{
"extends": "../tslint.base.json",
"rules": {
"array-type": false,
"class-name": false
}
}
module.exports = {
"extends": "../../.eslintrc.js"
}
......@@ -14,7 +14,7 @@
"clean": "rimraf cache/ dist/ ./tsconfig.build.tsbuildinfo",
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config .prettierrc.json --write \"hardhat.config.ts\" \"{src,exec,test}/**/*.ts\"",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"test": "hardhat test --show-stack-traces"
},
"keywords": [
......@@ -57,7 +57,17 @@
"@types/rimraf": "^3.0.0",
"@types/sinon": "^9.0.10",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.2.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"ethereum-waffle": "3.0.0",
"ganache-core": "^2.13.2",
"hardhat": "^2.2.1",
......@@ -66,10 +76,6 @@
"rimraf": "^2.6.3",
"sinon": "^9.2.4",
"sinon-chai": "^3.5.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^4.2.3"
},
"resolutions": {
......
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true
}
"extends": "../../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true
}
}
\ No newline at end of file
{
"extends": "../../tslint.base.json"
}
module.exports = {
"extends": "../../.eslintrc.js"
}
......@@ -14,7 +14,7 @@
"clean": "rimraf dist/ ./tsconfig.build.tsbuildinfo",
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config .prettierrc.json --write '{src,test}/**/*.ts'",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"test": "ts-mocha test/*.spec.ts"
},
"devDependencies": {
......@@ -24,15 +24,21 @@
"@types/pino": "^6.3.6",
"@types/pino-multi-stream": "^5.1.1",
"@types/prettier": "^2.2.3",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.3.4",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"mocha": "^8.4.0",
"prettier": "^2.2.1",
"supertest": "^6.1.3",
"ts-mocha": "^8.0.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^4.2.3"
},
"dependencies": {
......
......@@ -109,10 +109,10 @@ export class BaseService<T> {
/**
* Combines user provided and default options.
*/
function mergeDefaultOptions<T>(
const mergeDefaultOptions = <T>(
options: T,
optionSettings: OptionSettings<T>
): T {
): T => {
for (const optionName of Object.keys(optionSettings)) {
const optionDefault = optionSettings[optionName].default
if (optionDefault === undefined) {
......@@ -132,7 +132,7 @@ function mergeDefaultOptions<T>(
/**
* Performs option validation against the option settings
*/
function validateOptions<T>(options: T, optionSettings: OptionSettings<T>) {
const validateOptions = <T>(options: T, optionSettings: OptionSettings<T>) => {
for (const optionName of Object.keys(optionSettings)) {
const optionValidationFunction = optionSettings[optionName].validate
if (optionValidationFunction === undefined) {
......
{
"extends": "../../tslint.base.json"
}
module.exports = {
"extends": "../../.eslintrc.js",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
}
}
......@@ -18,8 +18,32 @@ import hre from 'hardhat'
const sequencer = new Wallet(process.env.SEQUENCER_PRIVATE_KEY)
const deployer = new Wallet(process.env.DEPLOYER_PRIVATE_KEY)
const main = async () => {
const parseEnv = () => {
const ensure = (env, type) => {
if (typeof process.env[env] === 'undefined') {
return undefined
}
if (type === 'number') {
return parseInt(process.env[env], 10)
}
return process.env[env]
}
return {
l1BlockTimeSeconds: ensure('BLOCK_TIME_SECONDS', 'number'),
ctcForceInclusionPeriodSeconds: ensure('FORCE_INCLUSION_PERIOD_SECONDS', 'number'),
ctcMaxTransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'),
emMinTransactionGasLimit: ensure('MIN_TRANSACTION_GAS_LIMIT', 'number'),
emMaxtransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'),
emMaxGasPerQueuePerEpoch: ensure('MAX_GAS_PER_QUEUE_PER_EPOCH', 'number'),
emSecondsPerEpoch: ensure('ECONDS_PER_EPOCH', 'number'),
emOvmChainId: ensure('CHAIN_ID', 'number'),
sccFraudProofWindow: ensure('FRAUD_PROOF_WINDOW_SECONDS', 'number'),
sccSequencerPublishWindow: ensure('SEQUENCER_PUBLISH_WINDOW_SECONDS', 'number'),
}
}
const main = async () => {
const config = parseEnv()
await hre.run('deploy', {
......@@ -52,11 +76,12 @@ const main = async () => {
path.resolve(__dirname, `../deployments/custom`)
).children.filter((child) => {
return child.extension === '.json'
}).reduce((contracts, child) => {
}).reduce((contractsAccumulator, child) => {
const contractName = child.name.replace('.json', '')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const artifact = require(path.resolve(__dirname, `../deployments/custom/${child.name}`))
contracts[nicknames[contractName] || contractName] = artifact.address
return contracts
contractsAccumulator[nicknames[contractName] || contractName] = artifact.address
return contractsAccumulator
}, {})
contracts.OVM_Sequencer = await sequencer.getAddress()
......@@ -79,26 +104,3 @@ main()
)
process.exit(1)
})
function parseEnv() {
function ensure(env, type) {
if (typeof process.env[env] === 'undefined')
return undefined
if (type === 'number')
return parseInt(process.env[env], 10)
return process.env[env]
}
return {
l1BlockTimeSeconds: ensure('BLOCK_TIME_SECONDS', 'number'),
ctcForceInclusionPeriodSeconds: ensure('FORCE_INCLUSION_PERIOD_SECONDS', 'number'),
ctcMaxTransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'),
emMinTransactionGasLimit: ensure('MIN_TRANSACTION_GAS_LIMIT', 'number'),
emMaxtransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'),
emMaxGasPerQueuePerEpoch: ensure('MAX_GAS_PER_QUEUE_PER_EPOCH', 'number'),
emSecondsPerEpoch: ensure('ECONDS_PER_EPOCH', 'number'),
emOvmChainId: ensure('CHAIN_ID', 'number'),
sccFraudProofWindow: ensure('FRAUD_PROOF_WINDOW_SECONDS', 'number'),
sccSequencerPublishWindow: ensure('SEQUENCER_PUBLISH_WINDOW_SECONDS', 'number'),
}
}
......@@ -39,7 +39,7 @@
"lint:fix": "yarn run lint:fix:typescript",
"lint:fix:typescript": "prettier --config .prettierrc.json --write \"hardhat.config.ts\" \"{src,test}/**/*.ts\"",
"lint:check": "yarn run lint:typescript",
"lint:typescript": "tslint --format stylish --project .",
"lint:typescript": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"clean": "rm -rf ./dist ./artifacts ./artifacts-ovm ./cache ./cache-ovm ./tsconfig.build.tsbuildinfo",
"deploy": "ts-node \"./bin/deploy.ts\" && yarn generate-markdown",
"serve": "./bin/serve_dump.sh",
......@@ -74,11 +74,21 @@
"@types/mkdirp": "^1.0.1",
"@types/mocha": "^8.2.2",
"@types/yargs": "^16.0.1",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"buffer-xor": "^2.0.2",
"chai": "^4.3.1",
"copyfiles": "^2.3.0",
"directory-tree": "^2.2.7",
"dotenv": "^8.2.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.0.31",
"ganache-core": "^2.13.2",
......@@ -96,10 +106,6 @@
"solidity-coverage": "^0.7.16",
"ts-generator": "0.0.8",
"ts-node": "^9.1.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0",
"typechain": "2.0.0",
"yargs": "^16.2.0"
},
......
......@@ -3,9 +3,9 @@
* various useful functions.
*
* Notes:
* - 0x42...04 was the address of the OVM_ProxySequencerEntrypoint. This contract is no longer in
* use and has therefore been removed. We may place a new predeployed contract at this address
* in the future. See https://github.com/ethereum-optimism/optimism/pull/549 for more info.
* 0x42...04 was the address of the OVM_ProxySequencerEntrypoint. This contract is no longer in
* use and has therefore been removed. We may place a new predeployed contract at this address
* in the future. See https://github.com/ethereum-optimism/optimism/pull/549 for more info.
*/
export const predeploys = {
OVM_L2ToL1MessagePasser: '0x4200000000000000000000000000000000000000',
......
......@@ -12,6 +12,7 @@ import { predeploys } from '../predeploys'
/**
* Generates a storage dump for a given address.
*
* @param cStateManager Instance of the callback-based internal vm StateManager.
* @param address Address to generate a state dump for.
*/
......@@ -44,6 +45,7 @@ const getStorageDump = async (
/**
* Replaces old addresses found in a storage dump with new ones.
*
* @param storageDump Storage dump to sanitize.
* @param accounts Set of accounts to sanitize with.
* @returns Sanitized storage dump.
......
......@@ -35,8 +35,7 @@ describe('OVM_L2DepositedERC20', () => {
let finalizeWithdrawalGasLimit: number
beforeEach(async () => {
// Create a special signer which will enable us to send messages from the L2Messenger contract
let l2MessengerImpersonator: Signer
;[l2MessengerImpersonator] = await ethers.getSigners()
const [l2MessengerImpersonator] = await ethers.getSigners()
// Get a new mock L2 messenger
Mock__OVM_L2CrossDomainMessenger = await smockit(
......
/* tslint:disable:no-empty */
import { expect } from '../../../setup'
/* External Imports */
......
/* tslint:disable:no-empty */
import '../../../setup'
/* Internal Imports */
......
/* tslint:disable:no-empty */
import '../../../setup'
/* Internal Imports */
......
/* tslint:disable:no-empty */
import { expect } from '../../../setup'
/* External Imports */
......
/* tslint:disable:no-empty */
import { expect } from '../../../setup'
/* External Imports */
......@@ -300,6 +299,7 @@ describe('Lib_EthUtils', () => {
})
})
/* eslint-disable @typescript-eslint/no-empty-function */
describe('getCode(address)', () => {
describe('when the contract does not exist', () => {})
......@@ -359,4 +359,5 @@ describe('Lib_EthUtils', () => {
})
})
})
/* eslint-enable @typescript-eslint/no-empty-function */
})
......@@ -45,7 +45,7 @@ try {
len = fromHexString(
getContractDefinition('Helper_TestRunner').deployedBytecode
).byteLength
/* tslint:disable:no-empty */
// eslint-disable-next-line no-empty
} catch {}
export const Helper_TestRunner_BYTELEN = len
......
......@@ -95,10 +95,10 @@ export class ExecutionManagerTestRunner {
}
public run(test: TestDefinition) {
// tslint:disable-next-line:ban-comma-operator
;(test.preState = merge(
cloneDeep(this.defaultPreState),
cloneDeep(test.preState)
// eslint-disable-next-line no-sequences
)),
(test.postState = test.postState || {})
......
......@@ -2,7 +2,5 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true
},
"include": ["./test", "src/**/*", "deployments"],
"files": ["./hardhat.config.ts"]
}
}
{
"extends": "../../tslint.base.json",
"rules": {
"array-type": false,
"class-name": false,
"no-var-requires": false
}
}
module.exports = {
"extends": "../../.eslintrc.js"
}
......@@ -15,7 +15,7 @@
"clean": "rimraf dist/ ./tsconfig.build.tsbuildinfo",
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config .prettierrc.json --write '{src,test}/**/*.ts'",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"test": "ts-mocha test/**/*.spec.ts"
},
"devDependencies": {
......@@ -23,14 +23,20 @@
"@types/lodash": "^4.14.168",
"@types/mocha": "^8.2.2",
"@types/prettier": "^2.2.3",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.3.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"mocha": "^8.3.0",
"prettier": "^2.2.1",
"ts-mocha": "^8.0.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^4.2.3"
},
"dependencies": {
......
......@@ -3,6 +3,7 @@ import { BigNumber } from 'ethers'
/**
* Removes "0x" from start of a string if it exists.
*
* @param str String to modify.
* @returns the string without "0x".
*/
......@@ -15,6 +16,7 @@ export const remove0x = (str: string): string => {
/**
* Adds "0x" to the start of a string if necessary.
*
* @param str String to modify.
* @returns the string with "0x".
*/
......@@ -27,6 +29,7 @@ export const add0x = (str: string): string => {
/**
* Returns whether or not the provided string is a hex string.
*
* @param str The string to test.
* @returns True if the provided string is a hex string, false otherwise.
*/
......@@ -36,6 +39,7 @@ export const isHexString = (inp: any): boolean => {
/**
* Casts a hex string to a buffer.
*
* @param inp Input to cast to a buffer.
* @return Input cast as a buffer.
*/
......@@ -49,6 +53,7 @@ export const fromHexString = (inp: Buffer | string): Buffer => {
/**
* Casts an input to a hex string.
*
* @param inp Input to cast to a hex string.
* @return Input cast as a hex string.
*/
......
/**
* Basic timeout-based async sleep function.
*
* @param ms Number of milliseconds to sleep.
*/
export const sleep = async (ms: number): Promise<void> => {
......
......@@ -20,7 +20,7 @@ export interface EncodableL2GasLimit {
l2GasPrice: BigNumber | number
}
function encode(input: EncodableL2GasLimit): BigNumber {
const encode = (input: EncodableL2GasLimit): BigNumber => {
const { data } = input
let { l1GasPrice, l2GasLimit, l2GasPrice } = input
if (typeof l1GasPrice === 'number') {
......@@ -43,7 +43,7 @@ function encode(input: EncodableL2GasLimit): BigNumber {
return rounded.add(roundedScaledL2GasLimit)
}
function decode(fee: BigNumber | number): BigNumber {
const decode = (fee: BigNumber | number): BigNumber => {
if (typeof fee === 'number') {
fee = BigNumber.from(fee)
}
......@@ -56,7 +56,7 @@ export const TxGasLimit = {
decode,
}
export function ceilmod(a: BigNumber | number, b: BigNumber | number) {
export const ceilmod = (a: BigNumber | number, b: BigNumber | number) => {
if (typeof a === 'number') {
a = BigNumber.from(a)
}
......@@ -72,7 +72,7 @@ export function ceilmod(a: BigNumber | number, b: BigNumber | number) {
return rounded
}
export function calculateL1GasLimit(data: string | Buffer): BigNumber {
export const calculateL1GasLimit = (data: string | Buffer): BigNumber => {
const [zeroes, ones] = zeroesAndOnes(data)
const zeroesCost = zeroes * txDataZeroGas
const onesCost = ones * txDataNonZeroGasEIP2028
......@@ -80,7 +80,7 @@ export function calculateL1GasLimit(data: string | Buffer): BigNumber {
return BigNumber.from(gasLimit)
}
export function zeroesAndOnes(data: Buffer | string): Array<number> {
export const zeroesAndOnes = (data: Buffer | string): Array<number> => {
if (typeof data === 'string') {
data = Buffer.from(remove0x(data), 'hex')
}
......
......@@ -42,6 +42,7 @@ describe('BatchEncoder', () => {
})
it('should work with mainnet calldata', () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const data = require('../fixtures/appendSequencerBatch.json')
for (const calldata of data.calldata) {
const decoded = sequencerBatch.decode(calldata)
......
{
"extends": "../../tslint.base.json"
}
module.exports = {
"extends": "../../.eslintrc.js"
}
......@@ -14,7 +14,7 @@
"clean:db": "rimraf ./db",
"lint": "yarn run lint:fix && yarn run lint:check",
"lint:fix": "prettier --config .prettierrc.json --write \"{src,exec,test}/**/*.ts\"",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"start": "ts-node ./src/services/run.ts",
"start:local": "ts-node ./src/services/run.ts | pino-pretty",
"test": "hardhat --config test/config/hardhat.config.ts test",
......@@ -52,18 +52,24 @@
"@types/mocha": "^8.2.2",
"@types/node-fetch": "^2.5.8",
"@types/workerpool": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"hardhat": "^2.2.1",
"mocha": "^8.3.2",
"pino-pretty": "^4.7.1",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"ts-node": "^9.1.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^4.2.3"
}
}
// Only load if not in browser.
import { isNode } from 'browser-or-node'
// eslint-disable-next-line no-var
declare var window: any
/* tslint:disable-next-line:no-var-requires */
const fetch = isNode ? require('node-fetch') : window.fetch
import {
......
......@@ -402,7 +402,7 @@ export class TransportDB {
}
}
function stringify(entry) {
const stringify = (entry) => {
if (entry === null || entry === undefined) {
return entry
}
......
......@@ -321,6 +321,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
/**
* Gets the address of a contract at a particular block in the past.
*
* @param contractName Name of the contract to get an address for.
* @param blockNumber Block at which to get an address.
* @return Contract address.
......
......@@ -132,6 +132,7 @@ export class L2IngestionService extends BaseService<L2IngestionServiceOptions> {
/**
* Synchronizes unconfirmed transactions from a range of sequencer blocks.
*
* @param startBlockNumber Block to start querying from.
* @param endBlockNumber Block to query to.
*/
......
......@@ -169,6 +169,7 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> {
/**
* Registers a route on the server.
*
* @param method Http method type.
* @param route Route to register.
* @param handler Handler called and is expected to return a JSON response.
......
......@@ -2,6 +2,7 @@ import { toHexString } from '@eth-optimism/core-utils'
/**
* Basic timeout-based async sleep function.
*
* @param ms Number of milliseconds to sleep.
*/
export const sleep = async (ms: number): Promise<void> => {
......
{
"extends": "../../tslint.base.json"
}
module.exports = {
"extends": "../../.eslintrc.js"
}
......@@ -13,7 +13,7 @@
"build": "tsc -p tsconfig.build.json",
"lint": "yarn run lint:fix && yarn run lint:check",
"lint:fix": "prettier --config .prettierrc.json --write \"{src,test}/**/*.ts\"",
"lint:check": "tslint --format stylish --project ."
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish ."
},
"dependencies": {
"node-fetch": "^2.6.1"
......@@ -25,10 +25,16 @@
"devDependencies": {
"@types/mocha": "^8.2.2",
"@types/node-fetch": "^2.5.10",
"prettier": "^2.2.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0"
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"prettier": "^2.2.1"
}
}
......@@ -35,6 +35,7 @@ const OVM_POLLING_INTERVAL = 50
/**
* Find or generate an OVM soljson.js compiler file and return the path of this file.
* We pass the path to this file into hardhat.
*
* @param version Solidity compiler version to get a path for in the format `X.Y.Z`.
* @return Path to the downloaded soljson.js file.
*/
......@@ -289,7 +290,7 @@ extendEnvironment(async (hre) => {
}
;(hre as any).ethers.getSigners = () => signers
/* tslint:disable:no-empty */
// eslint-disable-next-line no-empty
} catch (e) {}
// Update the provider at the very end to avoid any weird issues.
......
{
"extends": "../../tslint.base.json"
}
module.exports = {
"extends": "../../.eslintrc.js"
}
......@@ -13,7 +13,7 @@
"clean": "rimraf dist/ ./tsconfig.build.tsbuildinfo",
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config .prettierrc.json --write \"{src,exec,test}/**/*.ts\"",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"test": "hardhat test --show-stack-traces"
},
"keywords": [
......@@ -46,16 +46,22 @@
"@types/chai": "^4.2.18",
"@types/chai-as-promised": "^7.1.4",
"@types/mocha": "^8.2.2",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"ethereum-waffle": "^3.3.0",
"hardhat": "^2.3.0",
"lodash": "^4.17.21",
"mocha": "^8.4.0",
"prettier": "^2.2.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0"
"eslint": "^7.27.0",
"prettier": "^2.2.1"
}
}
......@@ -59,6 +59,7 @@ interface StateTrieProof {
/**
* Finds all L2 => L1 messages triggered by a given L2 transaction, if the message exists.
*
* @param l2RpcProvider L2 RPC provider.
* @param l2CrossDomainMessengerAddress Address of the L2CrossDomainMessenger.
* @param l2TransactionHash Hash of the L2 transaction to find a message for.
......@@ -110,6 +111,7 @@ export const getMessagesByTransactionHash = async (
/**
* Encodes a cross domain message.
*
* @param message Message to encode.
* @returns Encoded message.
*/
......@@ -126,6 +128,7 @@ const encodeCrossDomainMessage = (message: CrossDomainMessage): string => {
/**
* Finds the StateBatchAppended event associated with a given L2 transaction.
*
* @param l1RpcProvider L1 RPC provider.
* @param l1StateCommitmentChainAddress Address of the L1StateCommitmentChain.
* @param l2TransactionIndex Index of the L2 transaction to find a StateBatchAppended event for.
......@@ -206,6 +209,7 @@ export const getStateBatchAppendedEventByTransactionIndex = async (
/**
* Finds the full state root batch associated with a given transaction index.
*
* @param l1RpcProvider L1 RPC provider.
* @param l1StateCommitmentChainAddress Address of the L1StateCommitmentChain.
* @param l2TransactionIndex Index of the L2 transaction to find a state root batch for.
......@@ -252,6 +256,7 @@ export const getStateRootBatchByTransactionIndex = async (
/**
* Generates a Merkle proof (using the particular scheme we use within Lib_MerkleTree).
*
* @param leaves Leaves of the merkle tree.
* @param index Index to generate a proof for.
* @returns Merkle proof sibling leaves, as hex strings.
......@@ -288,6 +293,7 @@ const getMerkleTreeProof = (leaves: string[], index: number): string[] => {
/**
* Generates a Merkle-Patricia trie proof for a given account and storage slot.
*
* @param l2RpcProvider L2 RPC provider.
* @param blockNumber Block number to generate the proof at.
* @param address Address to generate the proof for.
......@@ -315,6 +321,7 @@ const getStateTrieProof = async (
/**
* Finds all L2 => L1 messages sent in a given L2 transaction and generates proofs for each of
* those messages.
*
* @param l1RpcProvider L1 RPC provider.
* @param l2RpcProvider L2 RPC provider.
* @param l1StateCommitmentChainAddress Address of the StateCommitmentChain.
......
......@@ -367,6 +367,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
/**
* Returns all sent message events between some start height (inclusive) and an end height
* (exclusive).
*
* @param startHeight Start height to start finding messages from.
* @param endHeight End height to finish finding messages at.
* @returns All sent messages between start and end height, sorted by transaction index in
......
{
"extends": "../../tslint.base.json"
}
module.exports = {
"extends": "../../.eslintrc.js",
"parserOptions": {
"project": "./tsconfig.json",
"sourceType": "module"
}
}
......@@ -13,7 +13,7 @@
"test": "hardhat test --show-stack-traces",
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config ./.prettierrc.json --write \"hardhat.config.ts\" \"{src,test}/**/*.ts\"",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"clean": "rimraf ./artifacts ./cache ./dist ./tsconfig.build.tsbuildinfo"
},
"peerDependencies": {
......@@ -41,15 +41,21 @@
"@types/glob": "^7.1.3",
"@types/lodash": "^4.14.161",
"@types/prettier": "^2.2.3",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.3.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.0.31",
"hardhat": "^2.2.1",
"lodash": "^4.17.20",
"prettier": "^2.2.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0"
"prettier": "^2.2.1"
}
}
......@@ -13,6 +13,7 @@ import { fromHexString, toHexString } from '@eth-optimism/core-utils'
* This object has direct access to the node (provider._node), which in turn has direct access to
* the ethereumjs-vm instance (provider._node._vm). So it's quite useful to be able to find this
* object reliably!
*
* @param hre hardhat runtime environment to pull the base provider from.
* @return base hardhat network provider
*/
......@@ -49,6 +50,7 @@ export const findBaseHardhatProvider = (
/**
* Converts a string into the fancy new address thing that ethereumjs-vm v5 expects while also
* maintaining backwards compatibility with ethereumjs-vm v4.
*
* @param address String address to convert into the fancy new address type.
* @returns Fancified address.
*/
......@@ -67,6 +69,7 @@ export const toFancyAddress = (address: string): any => {
/**
* Same as toFancyAddress but in the opposite direction.
*
* @param fancyAddress Fancy address to turn into a string.
* @returns Way more boring address.
*/
......
......@@ -7,11 +7,11 @@ import BN from 'bn.js'
// Handle hardhat ^2.2.0
let TransactionExecutionError: any
try {
// tslint:disable-next-line
// eslint-disable-next-line @typescript-eslint/no-var-requires
TransactionExecutionError = require('hardhat/internal/hardhat-network/provider/errors')
.TransactionExecutionError
} catch (err) {
// tslint:disable-next-line
// eslint-disable-next-line @typescript-eslint/no-var-requires
TransactionExecutionError = require('hardhat/internal/core/providers/errors')
.TransactionExecutionError
}
......@@ -23,6 +23,7 @@ import { fromFancyAddress, toFancyAddress } from '../common'
/**
* Checks to see if smock has been initialized already. Basically just checking to see if we've
* attached smock state to the VM already.
*
* @param provider Base hardhat network provider to check.
* @return Whether or not the provider has already been modified to support smock.
*/
......@@ -32,6 +33,7 @@ const isSmockInitialized = (provider: HardhatNetworkProvider): boolean => {
/**
* Modifies a hardhat provider to be compatible with smock.
*
* @param provider Base hardhat network provider to modify.
*/
const initializeSmock = (provider: HardhatNetworkProvider): void => {
......@@ -156,6 +158,7 @@ const initializeSmock = (provider: HardhatNetworkProvider): void => {
/**
* Attaches a smocked contract to a hardhat network provider. Will also modify the provider to be
* compatible with smock if not done already.
*
* @param mock Smocked contract to attach to a provider.
* @param provider Hardhat network provider to attach the contract to.
*/
......
......@@ -23,6 +23,7 @@ import { findBaseHardhatProvider } from '../common'
/**
* Generates an ethers Interface instance when given a smock spec. Meant for standardizing the
* various input types we might reasonably want to support.
*
* @param spec Smock specification object. Thing you want to base the interface on.
* @param hre Hardhat runtime environment. Used so we can
* @return Interface generated from the spec.
......@@ -57,6 +58,7 @@ const makeContractInterfaceFromSpec = async (
/**
* Creates a mock contract function from a real contract function.
*
* @param contract Contract object to make a mock function for.
* @param functionName Name of the function to mock.
* @param vm Virtual machine reference, necessary for call assertions to work.
......@@ -137,6 +139,7 @@ const smockifyFunction = (
/**
* Turns a specification into a mock contract.
*
* @param spec Smock contract specification.
* @param opts Optional additional settings.
*/
......
......@@ -10,6 +10,7 @@ import { findBaseHardhatProvider, toFancyAddress } from '../common'
/**
* Creates a modifiable contract factory.
*
* @param name Name of the contract to smoddify.
* @param signer Optional signer to attach to the factory.
* @returns Smoddified contract factory.
......
......@@ -21,6 +21,7 @@ interface StorageSlot {
/**
* Reads the storage layout of a contract.
*
* @param name Name of the contract to get a storage layout for.
* @return Storage layout for the given contract name.
*/
......@@ -43,6 +44,7 @@ export const getStorageLayout = async (name: string): Promise<any> => {
/**
* Converts storage into a list of storage slots.
*
* @param storageLayout Contract storage layout.
* @param obj Storage object to convert.
* @returns List of storage slots.
......@@ -108,6 +110,7 @@ export const getStorageSlots = (
/**
* Flattens an object.
*
* @param obj Object to flatten.
* @param prefix Current object prefix (used recursively).
* @param res Current result (used recursively).
......@@ -143,6 +146,7 @@ const flattenObject = (
/**
* Gets the slot positions for a provided variable type.
*
* @param storageLayout Contract's storage layout.
* @param inputTypeName Variable type name.
* @returns Slot positions.
......
{
"extends": "../../tsconfig.json",
"files": [
"./hardhat.config.ts"
]
"extends": "../../tsconfig.json"
}
{
"extends": "../../tslint.base.json"
}
{
"extends": [
"tslint:latest",
"tslint-config-prettier",
"tslint-plugin-prettier"
],
"rulesDirectory": [
"tslint-no-focused-test"
],
"rules": {
"ban-types": false,
"comment-format": false,
"interface-name": false,
"max-classes-per-file": false,
"member-ordering": false,
"no-console": false,
"no-bitwise": false,
"no-empty-interface": false,
"no-implicit-dependencies": [true, "dev"],
"no-string-literal": false,
"no-submodule-imports": false,
"no-unused-expression": false,
"object-literal-sort-keys": false,
"prefer-conditional-expression": false,
"ordered-imports": false,
"semicolon": false,
"variable-name": false,
"no-focused-test": true,
"array-type": false,
"prettier": [true, "./.prettierrc.json"],
"curly": true
},
"linterOptions": {
"exclude": [
"**/node_modules/**/*"
]
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment