-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88ad11b
commit 0765c8b
Showing
127 changed files
with
314,912 additions
and
15,204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build | ||
.coverage_* | ||
coverage | ||
.circleci/src | ||
.circleci/config.template.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 125, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": false, | ||
"explicitTypes": "preserve" | ||
} | ||
}, | ||
{ | ||
"files": ["*.js", "*.md"], | ||
"options": { | ||
"printWidth": 100, | ||
"semi": true, | ||
"singleQuote": true, | ||
"bracketSpacing": true, | ||
"trailingComma": "es5" | ||
} | ||
}, | ||
{ | ||
"files": ["*.js", "*.json"], | ||
"options": { | ||
"useTabs": true | ||
} | ||
}, | ||
{ | ||
"files": "*.md", | ||
"options": { | ||
"useTabs": false | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { | ||
constants: { inflationStartTimestampInSecs }, | ||
} = require('.'); | ||
|
||
module.exports = { | ||
port: 8545, | ||
skipFiles: [ | ||
], | ||
providerOptions: { | ||
default_balance_ether: 10000000000000, // extra zero just in case (coverage consumes more gas) | ||
time: new Date(inflationStartTimestampInSecs * 1000), | ||
network_id: 55, | ||
}, | ||
mocha: { | ||
grep: '@cov-skip', // Find everything with this tag | ||
invert: true, // Run the grep's inverse set. | ||
timeout: 360e3, | ||
}, | ||
// Reduce instrumentation footprint - volume of solidity code | ||
// passed to compiler causes it to crash (See discussion PR #732) | ||
// Line and branch coverage will still be reported. | ||
measureStatementCoverage: false, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"extends": ["solhint:recommended"], | ||
"plugins": [], | ||
"rules": { | ||
"avoid-call-value": "off", | ||
"compiler-version": ["error", "^0.5.0"], | ||
"const-name-snakecase": "off", | ||
"func-order": "off", | ||
"func-param-name-mixedcase": "off", | ||
"imports-on-top": "off", | ||
"mark-callable-contracts": "off", | ||
"max-line-length": "off", | ||
"no-empty-blocks": "off", | ||
"no-inline-assembly": "off", | ||
"not-rely-on-time": "off", | ||
"no-unused-vars": "warn", | ||
"quotes": ["error", "double"], | ||
"reason-string": "off", | ||
"var-name-mixedcase": "off", | ||
"visibility-modifier-order": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { extendEnvironment } = require('hardhat/config'); | ||
const { gray } = require('chalk'); | ||
|
||
const log = (...text) => console.log(gray(...['└─> [DEBUG]'].concat(text))); | ||
|
||
extendEnvironment(hre => { | ||
hre.log = log; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// now require all extensions and tasks | ||
['extensions', 'tasks'].forEach(folder => | ||
fs | ||
.readdirSync(path.join(__dirname, folder)) | ||
.forEach(mod => require(path.join(__dirname, folder, mod))) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
const path = require('path'); | ||
|
||
const { subtask, task, internalTask } = require('hardhat/config'); | ||
const { | ||
TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD, | ||
TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS, | ||
TASK_COMPILE_SOLIDITY_GET_DEPENDENCY_GRAPH, | ||
} = require('hardhat/builtin-tasks/task-names'); | ||
const { gray, yellow, red } = require('chalk'); | ||
|
||
const optimizeIfRequired = require('../util/optimizeIfRequired'); | ||
|
||
const { collectContractBytesCodes } = require('../util/collectContractBytecodes'); | ||
const { logContractSizes } = require('../../publish/src/contract-size'); | ||
|
||
task('compile') | ||
.addFlag('showsize', 'Show size of compiled contracts') | ||
.addFlag('optimizer', 'Compile with the optimizer') | ||
.addFlag('failOversize', 'Fail if any contract is oversize') | ||
.addFlag('native', 'Compile with the native solc compiler') | ||
.setAction(async (taskArguments, hre, runSuper) => { | ||
|
||
if (taskArguments.native) { | ||
hre.config.solc.native = true; | ||
} | ||
|
||
optimizeIfRequired({ hre, taskArguments }); | ||
|
||
await runSuper(taskArguments); | ||
|
||
if (taskArguments.showsize || taskArguments.failOversize) { | ||
const contractToObjectMap = collectContractBytesCodes(); | ||
const sizes = logContractSizes({ contractToObjectMap }); | ||
|
||
if (taskArguments.failOversize) { | ||
const offenders = sizes.filter(entry => +entry.pcent.split('%')[0] > 100); | ||
if (offenders.length > 0) { | ||
const names = offenders.map(o => o.file); | ||
console.log(red('Oversized contracts:'), yellow(`[${names}]`)); | ||
throw new Error( | ||
'Compilation failed, because some contracts are too big to be deployed. See above.' | ||
); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
subtask(TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD).setAction(({ solcVersion }, hre, runSuper) => { | ||
|
||
console.log(gray('Solc version ' + solcVersion)); | ||
if (!hre.isOvm) { | ||
return runSuper(); | ||
} | ||
|
||
if (solcVersion === '0.4.25') { | ||
return runSuper(); | ||
} | ||
|
||
const compilerPath = path.resolve( | ||
__dirname, | ||
'node_modules', | ||
'@eth-optimism', | ||
'solc', | ||
'soljson.js' | ||
); | ||
|
||
console.log("Compile path is " + compilerPath); | ||
|
||
return { | ||
compilerPath, | ||
isSolcJs: true, | ||
version: solcVersion, | ||
longVersion: solcVersion, | ||
}; | ||
}); | ||
|
||
internalTask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS, async (_, { config }, runSuper) => { | ||
let filePaths = await runSuper(); | ||
|
||
return filePaths; | ||
}); | ||
|
||
// See internalTask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS) first. | ||
// Filtering the right sources should be enough. However, knowing which are the right sources can be hard. | ||
// I.e. you may mark TradingRewards to be ignored, but it ends up in the compilation anyway | ||
// because test-helpers/FakeTradingRewards uses it. | ||
// We also override this task to more easily detect when this is happening. | ||
internalTask(TASK_COMPILE_SOLIDITY_GET_DEPENDENCY_GRAPH, async (_, { config }, runSuper) => { | ||
const graph = await runSuper(); | ||
|
||
return graph; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { task } = require('hardhat/config'); | ||
const { gray, green } = require('chalk'); | ||
|
||
const describeSources = require('../util/describeSources'); | ||
|
||
task('describe').setAction(async (taskArguments, hre) => { | ||
await hre.run('compile', taskArguments); | ||
|
||
console.log(gray('Processing Solidity sources and output ASTs...')); | ||
const descriptions = await describeSources({ hre }); | ||
console.log(green(`Done describing ${Object.keys(descriptions).length} sources 💯`)); | ||
}); |
Oops, something went wrong.