aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-compiler
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-24 03:01:38 +0800
committerGitHub <noreply@github.com>2018-05-24 03:01:38 +0800
commit513007a82ce9065d44694516bc94771ee4bc2c6f (patch)
treefe156fa4bb2dc5fecd2df4dd1fcd82e1e3007821 /packages/sol-compiler
parentaf0d9439d4f4e05fce8018665e375cf2db07184c (diff)
parentbf18a90da79d43e90901b0cd156f15398e215d91 (diff)
downloaddexon-sol-tools-513007a82ce9065d44694516bc94771ee4bc2c6f.tar
dexon-sol-tools-513007a82ce9065d44694516bc94771ee4bc2c6f.tar.gz
dexon-sol-tools-513007a82ce9065d44694516bc94771ee4bc2c6f.tar.bz2
dexon-sol-tools-513007a82ce9065d44694516bc94771ee4bc2c6f.tar.lz
dexon-sol-tools-513007a82ce9065d44694516bc94771ee4bc2c6f.tar.xz
dexon-sol-tools-513007a82ce9065d44694516bc94771ee4bc2c6f.tar.zst
dexon-sol-tools-513007a82ce9065d44694516bc94771ee4bc2c6f.zip
Merge pull request #589 from 0xProject/feature/truffle-sol-cov
Sol-cov artifact Adapters (truffle)
Diffstat (limited to 'packages/sol-compiler')
-rw-r--r--packages/sol-compiler/CHANGELOG.json4
-rw-r--r--packages/sol-compiler/src/compiler.ts13
-rw-r--r--packages/sol-compiler/src/index.ts1
-rw-r--r--packages/sol-compiler/src/utils/types.ts1
-rw-r--r--packages/sol-compiler/test/util/provider.ts3
5 files changed, 16 insertions, 6 deletions
diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json
index c558a98c5..33fd99e4f 100644
--- a/packages/sol-compiler/CHANGELOG.json
+++ b/packages/sol-compiler/CHANGELOG.json
@@ -5,6 +5,10 @@
{
"note": "Properly export the executable binary",
"pr": 588
+ },
+ {
+ "note": "Add the ability to define a specific solidity version",
+ "pr": 589
}
],
"timestamp": 1527009133
diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts
index c17616246..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;
@@ -229,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 {
diff --git a/packages/sol-compiler/test/util/provider.ts b/packages/sol-compiler/test/util/provider.ts
index e0fcb362a..2bd178129 100644
--- a/packages/sol-compiler/test/util/provider.ts
+++ b/packages/sol-compiler/test/util/provider.ts
@@ -3,7 +3,6 @@ import { Provider } from '@0xproject/types';
import * as Web3 from 'web3';
const providerConfigs = { shouldUseInProcessGanache: true };
-const web3Instance = web3Factory.create(providerConfigs);
-const provider: Provider = web3Instance.currentProvider;
+const provider: Provider = web3Factory.getRpcProvider(providerConfigs);
export { provider };