diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-05-24 05:16:32 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-05-24 05:16:32 +0800 |
commit | 3fe94891d3569a4615f4aa32d47f0065b5957fe9 (patch) | |
tree | 83d4e4ccf7748d2100aa935c457de0a893eaec9c /packages/sol-compiler/src | |
parent | d0abc60176dba3116cb3986d298ab5164c1fe49c (diff) | |
parent | f6b81f588d98e09e7a5806902d94e2892d029481 (diff) | |
download | dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.gz dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.bz2 dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.lz dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.xz dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.zst dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.zip |
Merge branch 'v2-prototype' into feature/website/wallet-flex-box
* v2-prototype: (95 commits)
Add missing dep to website
Upgrade solidity parser
Fix trace test
Fix linter issues
Move contract utils
Fix prettier
Fix NameResolver
Fix prettier
Remove 0x.js as a dependency from website
Enable 0x.js tests
Fix small bug in order-utils
Address feedback
Fix Tslint error caused by "PromiseLike" value
Fix Tslint error caused by "PromiseLike" value
Update dogfood url
fix contract-wrappers version
Parse compiler.json in SolCompilerArtifactsAdapter
Fix TokenTransferProxy artifact name since it's now suffixed with _v1
Update yarn.lock
Fix signature verification test
...
Diffstat (limited to 'packages/sol-compiler/src')
-rw-r--r-- | packages/sol-compiler/src/compiler.ts | 16 | ||||
-rw-r--r-- | packages/sol-compiler/src/index.ts | 1 | ||||
-rw-r--r-- | packages/sol-compiler/src/utils/types.ts | 1 |
3 files changed, 13 insertions, 5 deletions
diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index efb30091b..2ebc5228e 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -74,6 +74,7 @@ export class Compiler { private _contractsDir: string; private _compilerSettings: solc.CompilerSettings; private _artifactsDir: string; + private _solcVersionIfExists: string | undefined; private _specifiedContracts: string[] | TYPE_ALL_FILES_IDENTIFIER; /** * Instantiates a new instance of the Compiler class. @@ -85,6 +86,7 @@ export class Compiler { ? JSON.parse(fs.readFileSync(CONFIG_FILE).toString()) : {}; this._contractsDir = opts.contractsDir || config.contractsDir || DEFAULT_CONTRACTS_DIR; + this._solcVersionIfExists = opts.solcVersion || config.solcVersion; this._compilerSettings = opts.compilerSettings || config.compilerSettings || DEFAULT_COMPILER_SETTINGS; this._artifactsDir = opts.artifactsDir || config.artifactsDir || DEFAULT_ARTIFACTS_DIR; this._specifiedContracts = opts.contracts || config.contracts || ALL_CONTRACTS_IDENTIFIER; @@ -139,9 +141,12 @@ export class Compiler { if (!shouldCompile) { return; } - const solcVersionRange = parseSolidityVersionRange(contractSource.source); - const availableCompilerVersions = _.keys(binPaths); - const solcVersion = semver.maxSatisfying(availableCompilerVersions, solcVersionRange); + let solcVersion = this._solcVersionIfExists; + if (_.isUndefined(solcVersion)) { + const solcVersionRange = parseSolidityVersionRange(contractSource.source); + const availableCompilerVersions = _.keys(binPaths); + solcVersion = semver.maxSatisfying(availableCompilerVersions, solcVersionRange); + } const fullSolcVersion = binPaths[solcVersion]; const compilerBinFilename = path.join(SOLC_BIN_DIR, fullSolcVersion); let solcjs: string; @@ -152,7 +157,8 @@ export class Compiler { logUtils.log(`Downloading ${fullSolcVersion}...`); const url = `${constants.BASE_COMPILER_URL}${fullSolcVersion}`; const response = await fetch(url); - if (response.status !== 200) { + const SUCCESS_STATUS = 200; + if (response.status !== SUCCESS_STATUS) { throw new Error(`Failed to load ${fullSolcVersion}`); } solcjs = await response.text(); @@ -228,7 +234,7 @@ export class Compiler { sourceTreeHashHex, compiler: { name: 'solc', - version: solcVersion, + version: fullSolcVersion, settings: this._compilerSettings, }, }; diff --git a/packages/sol-compiler/src/index.ts b/packages/sol-compiler/src/index.ts index 4b4c51de2..15c166992 100644 --- a/packages/sol-compiler/src/index.ts +++ b/packages/sol-compiler/src/index.ts @@ -1,2 +1,3 @@ export { Compiler } from './compiler'; +export { CompilerOptions } from './utils/types'; export { ContractArtifact, ContractNetworks } from './utils/types'; diff --git a/packages/sol-compiler/src/utils/types.ts b/packages/sol-compiler/src/utils/types.ts index b12a11b79..d43347fa6 100644 --- a/packages/sol-compiler/src/utils/types.ts +++ b/packages/sol-compiler/src/utils/types.ts @@ -55,6 +55,7 @@ export interface CompilerOptions { artifactsDir?: string; compilerSettings?: solc.CompilerSettings; contracts?: string[] | '*'; + solcVersion?: string; } export interface ContractSourceData { |