Improve the readability of the check for should compile

This commit is contained in:
Leonid Logvinov
2018-05-07 13:49:21 +02:00
parent fad7dc9f04
commit fcb0a05880
3 changed files with 7 additions and 6 deletions

View File

@@ -131,10 +131,10 @@ export class Compiler {
shouldCompile = true;
} else {
const currentArtifact = currentArtifactIfExists as ContractArtifact;
shouldCompile =
currentArtifact.schemaVersion !== '2.0.0' ||
!_.isEqual(currentArtifact.compiler.settings, this._compilerSettings) ||
currentArtifact.sourceTreeHashHex !== sourceTreeHashHex;
const isUserOnLatestVersion = currentArtifact.schemaVersion === constants.LATEST_ARTIFACT_VERSION;
const didCompilerSettingsChange = !_.isEqual(currentArtifact.compiler.settings, this._compilerSettings);
const didSourceChange = currentArtifact.sourceTreeHashHex !== sourceTreeHashHex;
shouldCompile = isUserOnLatestVersion || didCompilerSettingsChange || didSourceChange;
}
if (!shouldCompile) {
return;
@@ -228,7 +228,7 @@ export class Compiler {
};
} else {
newArtifact = {
schemaVersion: '2.0.0',
schemaVersion: constants.LATEST_ARTIFACT_VERSION,
contractName,
...contractVersion,
networks: {},

View File

@@ -1,4 +1,5 @@
export const constants = {
SOLIDITY_FILE_EXTENSION: '.sol',
BASE_COMPILER_URL: 'https://ethereum.github.io/solc-bin/bin/',
LATEST_ARTIFACT_VERSION: '2.0.0',
};

View File

@@ -11,7 +11,7 @@ export enum AbiType {
}
export interface ContractArtifact extends ContractVersionData {
schemaVersion: '2.0.0';
schemaVersion: string;
contractName: string;
networks: ContractNetworks;
}