fix on contract add

This commit is contained in:
Jonathan Rainville 2018-04-27 13:50:57 -04:00
parent 7ebaa7aaca
commit 2827deb418
7 changed files with 34 additions and 15 deletions

View File

@ -13,6 +13,6 @@
"any": "any"
},
"events": {
"contextChange": "contextChange"
"contractFilesChanged": "contractFilesChanged"
}
}

View File

@ -3,6 +3,7 @@ let async = require('async');
let Compiler = require('./compiler.js');
let utils = require('../utils/utils.js');
const constants = require('../constants');
// TODO: create a contract object
@ -16,6 +17,11 @@ class ContractsManager {
this.contractDependencies = {};
this.gasLimit = options.gasLimit;
this.deployOnlyOnConfig = false;
this.events = options.events;
this.events.on(constants.events.contractFilesChanged, (newContracts) => {
this.contractFiles = newContracts;
});
}
build(done) {

View File

@ -3,6 +3,7 @@ const File = require('./file.js');
const Plugins = require('./plugins.js');
const utils = require('../utils/utils.js');
const path = require('path');
const deepEqual = require('deep-equal');
const constants = require('../constants');
var Config = function(options) {
@ -217,8 +218,12 @@ Config.prototype.loadWebServerConfigFile = function() {
};
Config.prototype.loadEmbarkConfigFile = function() {
var contracts = this.embarkConfig.contracts;
this.contractsFiles = this.loadFiles(contracts);
const contracts = this.embarkConfig.contracts;
const newContractsFiles = this.loadFiles(contracts);
if (newContractsFiles.length !== this.contractFiles || deepEqual(newContractsFiles, this.contractFiles)) {
this.events.emit(constants.events.contractFilesChanged, newContractsFiles);
this.contractsFiles = newContractsFiles;
}
// determine contract 'root' directories
this.contractDirectories = contracts.map((dir) => {
return dir.split("**")[0];

View File

@ -197,7 +197,8 @@ class Engine {
contractsConfig: this.config.contractsConfig,
logger: this.logger,
plugins: this.plugins,
gasLimit: false
gasLimit: false,
events: this.events
});
this.deployManager = new DeployManager({
@ -211,7 +212,7 @@ class Engine {
onlyCompile: options.onlyCompile
});
this.events.on('file-event', function (fileType, _path) {
this.events.on('file-event', function (fileType) {
// TODO: for now need to deploy on asset chanes as well
// because the contractsManager config is corrupted after a deploy
if (fileType === 'contract' || fileType === 'config') {

19
package-lock.json generated
View File

@ -23,7 +23,7 @@
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.2.tgz",
"integrity": "sha512-Q3FWsbdmkQd1ib11A4XNWQvRD//5KpPoGawA8aB2DR7pWKoW9XQv3+dGxD/Z1eVFze23Okdo27ZQytVFlweKvQ==",
"requires": {
"@types/node": "9.6.6"
"@types/node": "10.0.0"
}
},
"@types/lockfile": {
@ -32,16 +32,16 @@
"integrity": "sha512-pD6JuijPmrfi84qF3/TzGQ7zi0QIX+d7ZdetD6jUA6cp+IsCzAquXZfi5viesew+pfpOTIdAVKuh1SHA7KeKzg=="
},
"@types/node": {
"version": "9.6.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.6.tgz",
"integrity": "sha512-SJe0g5cZeGNDP5sD8mIX3scb+eq8LQQZ60FXiKZHipYSeEFZ5EKml+NNMiO76F74TY4PoMWlNxF/YRY40FOvZQ=="
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.0.0.tgz",
"integrity": "sha512-kctoM36XiNZT86a7tPsUje+Q/yl+dqELjtYApi0T5eOQ90Elhu0MI10rmYk44yEP4v1jdDvtjQ9DFtpRtHf2Bw=="
},
"@types/node-fetch": {
"version": "1.6.9",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-1.6.9.tgz",
"integrity": "sha512-n2r6WLoY7+uuPT7pnEtKJCmPUGyJ+cbyBR8Avnu4+m1nzz7DwBVuyIvvlBzCZ/nrpC7rIgb3D6pNavL7rFEa9g==",
"requires": {
"@types/node": "9.6.6"
"@types/node": "10.0.0"
}
},
"@types/semver": {
@ -54,7 +54,7 @@
"resolved": "https://registry.npmjs.org/@types/tar/-/tar-4.0.0.tgz",
"integrity": "sha512-YybbEHNngcHlIWVCYsoj7Oo1JU9JqONuAlt1LlTH/lmL8BMhbzdFUgReY87a05rY1j8mfK47Del+TCkaLAXwLw==",
"requires": {
"@types/node": "9.6.6"
"@types/node": "10.0.0"
}
},
"@types/url-join": {
@ -2138,6 +2138,11 @@
}
}
},
"deep-equal": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz",
"integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU="
},
"deep-is": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
@ -6647,7 +6652,6 @@
"version": "1.0.35",
"resolved": "https://registry.npmjs.org/node-webcrypto-ossl/-/node-webcrypto-ossl-1.0.35.tgz",
"integrity": "sha1-FCJVeb0J9dY7CtbO4LqAD4xqBg0=",
"optional": true,
"requires": {
"mkdirp": "0.5.1",
"nan": "2.9.2",
@ -10897,7 +10901,6 @@
"version": "0.1.19",
"resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-0.1.19.tgz",
"integrity": "sha1-8CTjoCu8oW3tRtJpaMQlNaORJNw=",
"optional": true,
"requires": {
"tslib": "1.9.0"
}

View File

@ -34,6 +34,7 @@
"colors": "^1.1.2",
"commander": "^2.15.1",
"css-loader": "^0.28.11",
"deep-equal": "^1.0.1",
"ejs": "^2.5.8",
"ethereumjs-testrpc": "^6.0.3",
"file-loader": "^1.1.5",

View File

@ -3,6 +3,7 @@ let ContractsManager = require('../lib/contracts/contracts.js');
let Logger = require('../lib/core/logger.js');
let File = require('../lib/core/file.js');
let TestLogger = require('../lib/tests/test_logger.js');
let Events = require('../lib/core/events');
let assert = require('assert');
//let SolidityCompiler = require('../lib/modules/solidity');
@ -55,7 +56,8 @@ describe('embark.Contracts', function() {
}
}
},
logger: new Logger({})
logger: new Logger({}),
events: new Events()
});
describe('#build', function() {
@ -146,7 +148,8 @@ describe('embark.Contracts', function() {
}
}
},
logger: new Logger({})
logger: new Logger({}),
events: new Events()
});
describe('#build', function() {