From fcb0a05880f6217f5b5942ec419fcf4df490551d Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 7 May 2018 13:49:21 +0200 Subject: Improve the readability of the check for should compile --- packages/deployer/src/compiler.ts | 10 +++++----- packages/deployer/src/utils/constants.ts | 1 + packages/deployer/src/utils/types.ts | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'packages/deployer') diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index db06ccf43..e81df3c0a 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -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: {}, diff --git a/packages/deployer/src/utils/constants.ts b/packages/deployer/src/utils/constants.ts index 6f9dfb994..df2ddb3b2 100644 --- a/packages/deployer/src/utils/constants.ts +++ b/packages/deployer/src/utils/constants.ts @@ -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', }; diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts index c4af5ac87..19c27df67 100644 --- a/packages/deployer/src/utils/types.ts +++ b/packages/deployer/src/utils/types.ts @@ -11,7 +11,7 @@ export enum AbiType { } export interface ContractArtifact extends ContractVersionData { - schemaVersion: '2.0.0'; + schemaVersion: string; contractName: string; networks: ContractNetworks; } -- cgit v1.2.3