move contracts manager to its own module
This commit is contained in:
parent
16aae66756
commit
53d944e801
|
@ -168,18 +168,7 @@ class Engine {
|
||||||
this.registerModule('deploytracker');
|
this.registerModule('deploytracker');
|
||||||
this.registerModule('specialconfigs');
|
this.registerModule('specialconfigs');
|
||||||
this.registerModule('console_listener', {ipc: this.ipc});
|
this.registerModule('console_listener', {ipc: this.ipc});
|
||||||
|
this.registerModule('contracts');
|
||||||
// TODO: need to refactor dependencies before moving into a module
|
|
||||||
const ContractsManager = require('../contracts/contracts.js');
|
|
||||||
this.contractsManager = new ContractsManager({
|
|
||||||
contractFiles: this.config.contractsFiles,
|
|
||||||
contractsConfig: this.config.contractsConfig,
|
|
||||||
logger: this.logger,
|
|
||||||
plugins: this.plugins,
|
|
||||||
gasLimit: false,
|
|
||||||
events: this.events
|
|
||||||
});
|
|
||||||
|
|
||||||
this.registerModule('deployment', {plugins: this.plugins, onlyCompile: options.onlyCompile});
|
this.registerModule('deployment', {plugins: this.plugins, onlyCompile: options.onlyCompile});
|
||||||
|
|
||||||
this.events.on('file-event', function (fileType) {
|
this.events.on('file-event', function (fileType) {
|
||||||
|
|
|
@ -2,22 +2,19 @@ let toposort = require('toposort');
|
||||||
let async = require('async');
|
let async = require('async');
|
||||||
const cloneDeep = require('clone-deep');
|
const cloneDeep = require('clone-deep');
|
||||||
|
|
||||||
let utils = require('../utils/utils.js');
|
let utils = require('../../utils/utils.js');
|
||||||
|
|
||||||
// TODO: create a contract object
|
// TODO: create a contract object
|
||||||
|
|
||||||
class ContractsManager {
|
class ContractsManager {
|
||||||
constructor(options) {
|
constructor(embark) {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.contractFiles = options.contractFiles;
|
this.logger = embark.logger;
|
||||||
this.contractsConfig = cloneDeep(options.contractsConfig || {});
|
this.events = embark.events;
|
||||||
|
|
||||||
this.contracts = {};
|
this.contracts = {};
|
||||||
this.logger = options.logger;
|
|
||||||
this.plugins = options.plugins;
|
|
||||||
this.contractDependencies = {};
|
this.contractDependencies = {};
|
||||||
this.gasLimit = options.gasLimit;
|
|
||||||
this.deployOnlyOnConfig = false;
|
this.deployOnlyOnConfig = false;
|
||||||
this.events = options.events;
|
|
||||||
this.compileError = false;
|
this.compileError = false;
|
||||||
|
|
||||||
self.events.setCommandHandler('contracts:list', (cb) => {
|
self.events.setCommandHandler('contracts:list', (cb) => {
|
||||||
|
@ -87,7 +84,7 @@ class ContractsManager {
|
||||||
// Only compile once for tests
|
// Only compile once for tests
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
self.events.request("compiler:contracts", self.contractFiles, function (err, compiledObject) {
|
self.events.request("compiler:contracts", self.contractsFiles, function (err, compiledObject) {
|
||||||
self.compiledContracts = compiledObject;
|
self.compiledContracts = compiledObject;
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
|
@ -1,5 +1,5 @@
|
||||||
/*globals describe, it*/
|
/*globals describe, it*/
|
||||||
let ContractsManager = require('../lib/contracts/contracts.js');
|
let ContractsManager = require('../lib/modules/contracts/index.js');
|
||||||
let Compiler = require('../lib/modules/compiler/');
|
let Compiler = require('../lib/modules/compiler/');
|
||||||
let Logger = require('../lib/core/logger.js');
|
let Logger = require('../lib/core/logger.js');
|
||||||
let File = require('../lib/core/file.js');
|
let File = require('../lib/core/file.js');
|
||||||
|
@ -45,7 +45,10 @@ describe('embark.Contracts', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
events.setCommandHandler("config:contractsFiles", (cb) => {
|
events.setCommandHandler("config:contractsFiles", (cb) => {
|
||||||
cb([]);
|
cb([
|
||||||
|
readFile('test/contracts/simple_storage.sol'),
|
||||||
|
readFile('test/contracts/token.sol')
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
events.setCommandHandler("blockchain:gasPrice", (cb) => {
|
events.setCommandHandler("blockchain:gasPrice", (cb) => {
|
||||||
|
@ -81,16 +84,13 @@ describe('embark.Contracts', function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let contractsManager = new ContractsManager({
|
let embarkObj = {
|
||||||
plugins: plugins,
|
|
||||||
contractFiles: [
|
|
||||||
readFile('test/contracts/simple_storage.sol'),
|
|
||||||
readFile('test/contracts/token.sol')
|
|
||||||
],
|
|
||||||
contractDirectories: ['app/contracts'],
|
|
||||||
contractsConfig: contractsConfig,
|
|
||||||
logger: new Logger({}),
|
logger: new Logger({}),
|
||||||
events: events
|
events: events
|
||||||
|
};
|
||||||
|
|
||||||
|
let contractsManager = new ContractsManager(embarkObj, {
|
||||||
|
contractDirectories: ['app/contracts']
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#build', function() {
|
describe('#build', function() {
|
||||||
|
@ -151,7 +151,10 @@ describe('embark.Contracts', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
events.setCommandHandler("config:contractsFiles", (cb) => {
|
events.setCommandHandler("config:contractsFiles", (cb) => {
|
||||||
cb([]);
|
cb([
|
||||||
|
readFile('test/contracts/simple_storage.sol'),
|
||||||
|
readFile('test/contracts/token_storage.sol')
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
events.setCommandHandler("blockchain:gasPrice", (cb) => {
|
events.setCommandHandler("blockchain:gasPrice", (cb) => {
|
||||||
|
@ -197,16 +200,13 @@ describe('embark.Contracts', function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let contractsManager = new ContractsManager({
|
let embarkObj = {
|
||||||
plugins: plugins,
|
|
||||||
contractFiles: [
|
|
||||||
readFile('test/contracts/simple_storage.sol'),
|
|
||||||
readFile('test/contracts/token_storage.sol')
|
|
||||||
],
|
|
||||||
contractDirectories: ['app/contracts'],
|
|
||||||
contractsConfig: contractsConfig,
|
|
||||||
logger: new Logger({}),
|
logger: new Logger({}),
|
||||||
events: events
|
events: events
|
||||||
|
}
|
||||||
|
|
||||||
|
let contractsManager = new ContractsManager(embarkObj, {
|
||||||
|
contractDirectories: ['app/contracts']
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#build', function() {
|
describe('#build', function() {
|
||||||
|
|
Loading…
Reference in New Issue