swap more var -> let
This commit is contained in:
parent
a948cecd42
commit
5bf1475ea4
|
@ -1,7 +1,7 @@
|
||||||
var async = require('async');
|
let async = require('async');
|
||||||
|
|
||||||
// TODO: make all of this async
|
// TODO: make all of this async
|
||||||
var GethCommands = function(options) {
|
let GethCommands = function(options) {
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
this.env = options.env || 'development';
|
this.env = options.env || 'development';
|
||||||
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
||||||
|
@ -9,8 +9,8 @@ var GethCommands = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GethCommands.prototype.commonOptions = function() {
|
GethCommands.prototype.commonOptions = function() {
|
||||||
var config = this.config;
|
let config = this.config;
|
||||||
var cmd = "";
|
let cmd = "";
|
||||||
|
|
||||||
cmd += this.determineNetworkType(config);
|
cmd += this.determineNetworkType(config);
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ GethCommands.prototype.commonOptions = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
GethCommands.prototype.determineNetworkType = function(config) {
|
GethCommands.prototype.determineNetworkType = function(config) {
|
||||||
var cmd = "";
|
let cmd = "";
|
||||||
if (config.networkType === 'testnet') {
|
if (config.networkType === 'testnet') {
|
||||||
cmd += "--testnet ";
|
cmd += "--testnet ";
|
||||||
} else if (config.networkType === 'olympic') {
|
} else if (config.networkType === 'olympic') {
|
||||||
|
@ -46,8 +46,8 @@ GethCommands.prototype.determineNetworkType = function(config) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GethCommands.prototype.initGenesisCommmand = function() {
|
GethCommands.prototype.initGenesisCommmand = function() {
|
||||||
var config = this.config;
|
let config = this.config;
|
||||||
var cmd = this.geth_bin + " " + this.commonOptions();
|
let cmd = this.geth_bin + " " + this.commonOptions();
|
||||||
|
|
||||||
if (config.genesisBlock) {
|
if (config.genesisBlock) {
|
||||||
cmd += "init \"" + config.genesisBlock + "\" ";
|
cmd += "init \"" + config.genesisBlock + "\" ";
|
||||||
|
@ -65,7 +65,7 @@ GethCommands.prototype.listAccountsCommand = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
GethCommands.prototype.determineRpcOptions = function(config) {
|
GethCommands.prototype.determineRpcOptions = function(config) {
|
||||||
var cmd = "";
|
let cmd = "";
|
||||||
|
|
||||||
cmd += "--port " + config.port + " ";
|
cmd += "--port " + config.port + " ";
|
||||||
cmd += "--rpc ";
|
cmd += "--rpc ";
|
||||||
|
@ -88,17 +88,17 @@ GethCommands.prototype.determineRpcOptions = function(config) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GethCommands.prototype.mainCommand = function(address, done) {
|
GethCommands.prototype.mainCommand = function(address, done) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var config = this.config;
|
let config = this.config;
|
||||||
var rpc_api = (this.config.rpcApi || ['eth', 'web3', 'net']);
|
let rpc_api = (this.config.rpcApi || ['eth', 'web3', 'net']);
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
function commonOptions(callback) {
|
function commonOptions(callback) {
|
||||||
var cmd = self.commonOptions();
|
let cmd = self.commonOptions();
|
||||||
callback(null, cmd);
|
callback(null, cmd);
|
||||||
},
|
},
|
||||||
function rpcOptions(callback) {
|
function rpcOptions(callback) {
|
||||||
var cmd = self.determineRpcOptions(self.config);
|
let cmd = self.determineRpcOptions(self.config);
|
||||||
callback(null, cmd);
|
callback(null, cmd);
|
||||||
},
|
},
|
||||||
function dontGetPeers(callback) {
|
function dontGetPeers(callback) {
|
||||||
|
@ -114,7 +114,7 @@ GethCommands.prototype.mainCommand = function(address, done) {
|
||||||
callback(null, "");
|
callback(null, "");
|
||||||
},
|
},
|
||||||
function maxPeers(callback) {
|
function maxPeers(callback) {
|
||||||
var cmd = "--maxpeers " + config.maxpeers;
|
let cmd = "--maxpeers " + config.maxpeers;
|
||||||
callback(null, cmd);
|
callback(null, cmd);
|
||||||
},
|
},
|
||||||
function mining(callback) {
|
function mining(callback) {
|
||||||
|
@ -140,7 +140,7 @@ GethCommands.prototype.mainCommand = function(address, done) {
|
||||||
callback(null, '--rpcapi "' + rpc_api.join(',') + '"');
|
callback(null, '--rpcapi "' + rpc_api.join(',') + '"');
|
||||||
},
|
},
|
||||||
function accountToUnlock(callback) {
|
function accountToUnlock(callback) {
|
||||||
var accountAddress = config.account.address || address;
|
let accountAddress = config.account.address || address;
|
||||||
if (accountAddress) {
|
if (accountAddress) {
|
||||||
return callback(null, "--unlock=" + accountAddress);
|
return callback(null, "--unlock=" + accountAddress);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
var shelljs = require('shelljs');
|
let shelljs = require('shelljs');
|
||||||
|
|
||||||
var Simulator = function(options) {
|
let Simulator = function(options) {
|
||||||
this.blockchainConfig = options.blockchainConfig;
|
this.blockchainConfig = options.blockchainConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
Simulator.prototype.run = function(options) {
|
Simulator.prototype.run = function(options) {
|
||||||
var cmds = [];
|
let cmds = [];
|
||||||
|
|
||||||
cmds.push("-p " + (this.blockchainConfig.rpcPort || options.port || 8545));
|
cmds.push("-p " + (this.blockchainConfig.rpcPort || options.port || 8545));
|
||||||
cmds.push("-h " + (this.blockchainConfig.rpcHost || options.host || 'localhost'));
|
cmds.push("-h " + (this.blockchainConfig.rpcHost || options.host || 'localhost'));
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
var fs = require('../core/fs.js');
|
let fs = require('../core/fs.js');
|
||||||
var utils = require('../utils/utils.js');
|
let utils = require('../utils/utils.js');
|
||||||
|
|
||||||
var TemplateGenerator = function(templateName) {
|
let TemplateGenerator = function(templateName) {
|
||||||
this.templateName = templateName;
|
this.templateName = templateName;
|
||||||
};
|
};
|
||||||
|
|
||||||
TemplateGenerator.prototype.generate = function(destinationFolder, name) {
|
TemplateGenerator.prototype.generate = function(destinationFolder, name) {
|
||||||
var templatePath = fs.embarkPath(this.templateName);
|
let templatePath = fs.embarkPath(this.templateName);
|
||||||
console.log('Initializing Embark Template....'.green);
|
console.log('Initializing Embark Template....'.green);
|
||||||
|
|
||||||
fs.copySync(templatePath, destinationFolder + name);
|
fs.copySync(templatePath, destinationFolder + name);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
var ABIGenerator = function(options) {
|
let ABIGenerator = function(options) {
|
||||||
this.blockchainConfig = options.blockchainConfig || {};
|
this.blockchainConfig = options.blockchainConfig || {};
|
||||||
this.storageConfig = options.storageConfig || {};
|
this.storageConfig = options.storageConfig || {};
|
||||||
this.communicationConfig = options.communicationConfig || {};
|
this.communicationConfig = options.communicationConfig || {};
|
||||||
|
@ -10,9 +10,9 @@ var ABIGenerator = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ABIGenerator.prototype.generateProvider = function() {
|
ABIGenerator.prototype.generateProvider = function() {
|
||||||
var self = this;
|
let self = this;
|
||||||
var result = "";
|
let result = "";
|
||||||
var providerPlugins;
|
let providerPlugins;
|
||||||
|
|
||||||
if (self.blockchainConfig === {} || self.blockchainConfig.enabled === false) {
|
if (self.blockchainConfig === {} || self.blockchainConfig.enabled === false) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -39,9 +39,9 @@ ABIGenerator.prototype.generateProvider = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
ABIGenerator.prototype.generateContracts = function(useEmbarkJS) {
|
ABIGenerator.prototype.generateContracts = function(useEmbarkJS) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var result = "\n";
|
let result = "\n";
|
||||||
var contractsPlugins;
|
let contractsPlugins;
|
||||||
|
|
||||||
if (self.blockchainConfig === {} || self.blockchainConfig.enabled === false) {
|
if (self.blockchainConfig === {} || self.blockchainConfig.enabled === false) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -56,11 +56,11 @@ ABIGenerator.prototype.generateContracts = function(useEmbarkJS) {
|
||||||
result += plugin.generateContracts({contracts: self.contractsManager.contracts});
|
result += plugin.generateContracts({contracts: self.contractsManager.contracts});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
for(var className in this.contractsManager.contracts) {
|
for(let className in this.contractsManager.contracts) {
|
||||||
var contract = this.contractsManager.contracts[className];
|
let contract = this.contractsManager.contracts[className];
|
||||||
|
|
||||||
var abi = JSON.stringify(contract.abiDefinition);
|
let abi = JSON.stringify(contract.abiDefinition);
|
||||||
var gasEstimates = JSON.stringify(contract.gasEstimates);
|
let gasEstimates = JSON.stringify(contract.gasEstimates);
|
||||||
|
|
||||||
if (useEmbarkJS) {
|
if (useEmbarkJS) {
|
||||||
result += "\n" + className + " = new EmbarkJS.Contract({abi: " + abi + ", address: '" + contract.deployedAddress + "', code: '" + contract.code + "', gasEstimates: " + gasEstimates + "});";
|
result += "\n" + className + " = new EmbarkJS.Contract({abi: " + abi + ", address: '" + contract.deployedAddress + "', code: '" + contract.code + "', gasEstimates: " + gasEstimates + "});";
|
||||||
|
@ -76,8 +76,8 @@ ABIGenerator.prototype.generateContracts = function(useEmbarkJS) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ABIGenerator.prototype.generateStorageInitialization = function(useEmbarkJS) {
|
ABIGenerator.prototype.generateStorageInitialization = function(useEmbarkJS) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var result = "\n";
|
let result = "\n";
|
||||||
|
|
||||||
if (!useEmbarkJS || self.storageConfig === {}) return "";
|
if (!useEmbarkJS || self.storageConfig === {}) return "";
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ ABIGenerator.prototype.generateStorageInitialization = function(useEmbarkJS) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ABIGenerator.prototype.generateCommunicationInitialization = function(useEmbarkJS) {
|
ABIGenerator.prototype.generateCommunicationInitialization = function(useEmbarkJS) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var result = "\n";
|
let result = "\n";
|
||||||
|
|
||||||
if (!useEmbarkJS || self.communicationConfig === {}) return "";
|
if (!useEmbarkJS || self.communicationConfig === {}) return "";
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ ABIGenerator.prototype.generateCommunicationInitialization = function(useEmbarkJ
|
||||||
};
|
};
|
||||||
|
|
||||||
ABIGenerator.prototype.generateABI = function(options) {
|
ABIGenerator.prototype.generateABI = function(options) {
|
||||||
var result = "";
|
let result = "";
|
||||||
|
|
||||||
result += this.generateProvider();
|
result += this.generateProvider();
|
||||||
result += this.generateContracts(options.useEmbarkJS);
|
result += this.generateContracts(options.useEmbarkJS);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
var toposort = require('toposort');
|
let toposort = require('toposort');
|
||||||
var async = require('async');
|
let async = require('async');
|
||||||
|
|
||||||
var Compiler = require('./compiler.js');
|
let Compiler = require('./compiler.js');
|
||||||
|
|
||||||
// TODO: create a contract object
|
// TODO: create a contract object
|
||||||
|
|
||||||
var adjustGas = function(contract) {
|
let adjustGas = function(contract) {
|
||||||
var maxGas, adjustedGas;
|
let maxGas, adjustedGas;
|
||||||
if (contract.gas === 'auto') {
|
if (contract.gas === 'auto') {
|
||||||
if (contract.deploy || contract.deploy === undefined) {
|
if (contract.deploy || contract.deploy === undefined) {
|
||||||
if (contract.gasEstimates.creation !== undefined) {
|
if (contract.gasEstimates.creation !== undefined) {
|
||||||
|
@ -25,7 +25,7 @@ var adjustGas = function(contract) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var ContractsManager = function(options) {
|
let ContractsManager = function(options) {
|
||||||
this.contractFiles = options.contractFiles;
|
this.contractFiles = options.contractFiles;
|
||||||
this.contractsConfig = options.contractsConfig;
|
this.contractsConfig = options.contractsConfig;
|
||||||
this.contracts = {};
|
this.contracts = {};
|
||||||
|
@ -36,17 +36,17 @@ var ContractsManager = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ContractsManager.prototype.build = function(done) {
|
ContractsManager.prototype.build = function(done) {
|
||||||
var self = this;
|
let self = this;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function compileContracts(callback) {
|
function compileContracts(callback) {
|
||||||
var compiler = new Compiler({plugins: self.plugins, logger: self.logger});
|
let compiler = new Compiler({plugins: self.plugins, logger: self.logger});
|
||||||
compiler.compile_contracts(self.contractFiles, function(err, compiledObject) {
|
compiler.compile_contracts(self.contractFiles, function(err, compiledObject) {
|
||||||
self.compiledContracts = compiledObject;
|
self.compiledContracts = compiledObject;
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function prepareContractsFromConfig(callback) {
|
function prepareContractsFromConfig(callback) {
|
||||||
var className, contract;
|
let className, contract;
|
||||||
for(className in self.contractsConfig.contracts) {
|
for(className in self.contractsConfig.contracts) {
|
||||||
contract = self.contractsConfig.contracts[className];
|
contract = self.contractsConfig.contracts[className];
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ ContractsManager.prototype.build = function(done) {
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
function setDeployIntention(callback) {
|
function setDeployIntention(callback) {
|
||||||
var className, contract;
|
let className, contract;
|
||||||
for(className in self.contracts) {
|
for(className in self.contracts) {
|
||||||
contract = self.contracts[className];
|
contract = self.contracts[className];
|
||||||
contract.deploy = (contract.deploy === undefined) || contract.deploy;
|
contract.deploy = (contract.deploy === undefined) || contract.deploy;
|
||||||
|
@ -66,7 +66,7 @@ ContractsManager.prototype.build = function(done) {
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
function prepareContractsFromCompilation(callback) {
|
function prepareContractsFromCompilation(callback) {
|
||||||
var className, compiledContract, contractConfig, contract;
|
let className, compiledContract, contractConfig, contract;
|
||||||
for(className in self.compiledContracts) {
|
for(className in self.compiledContracts) {
|
||||||
compiledContract = self.compiledContracts[className];
|
compiledContract = self.compiledContracts[className];
|
||||||
contractConfig = self.contractsConfig.contracts[className];
|
contractConfig = self.contractsConfig.contracts[className];
|
||||||
|
@ -94,7 +94,7 @@ ContractsManager.prototype.build = function(done) {
|
||||||
},
|
},
|
||||||
/*eslint complexity: ["error", 11]*/
|
/*eslint complexity: ["error", 11]*/
|
||||||
function dealWithSpecialConfigs(callback) {
|
function dealWithSpecialConfigs(callback) {
|
||||||
var className, contract, parentContractName, parentContract;
|
let className, contract, parentContractName, parentContract;
|
||||||
|
|
||||||
for(className in self.contracts) {
|
for(className in self.contracts) {
|
||||||
contract = self.contracts[className];
|
contract = self.contracts[className];
|
||||||
|
@ -136,7 +136,7 @@ ContractsManager.prototype.build = function(done) {
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
function removeContractsWithNoCode(callback) {
|
function removeContractsWithNoCode(callback) {
|
||||||
var className, contract;
|
let className, contract;
|
||||||
for(className in self.contracts) {
|
for(className in self.contracts) {
|
||||||
contract = self.contracts[className];
|
contract = self.contracts[className];
|
||||||
|
|
||||||
|
@ -149,15 +149,15 @@ ContractsManager.prototype.build = function(done) {
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
function determineDependencies(callback) {
|
function determineDependencies(callback) {
|
||||||
var className, contract;
|
let className, contract;
|
||||||
for(className in self.contracts) {
|
for(className in self.contracts) {
|
||||||
contract = self.contracts[className];
|
contract = self.contracts[className];
|
||||||
|
|
||||||
if (contract.args === []) continue;
|
if (contract.args === []) continue;
|
||||||
|
|
||||||
var ref = contract.args;
|
let ref = contract.args;
|
||||||
for (var j = 0; j < ref.length; j++) {
|
for (let j = 0; j < ref.length; j++) {
|
||||||
var arg = ref[j];
|
let arg = ref[j];
|
||||||
if (arg[0] === "$") {
|
if (arg[0] === "$") {
|
||||||
self.contractDependencies[className] = self.contractDependencies[className] || [];
|
self.contractDependencies[className] = self.contractDependencies[className] || [];
|
||||||
self.contractDependencies[className].push(arg.substr(1));
|
self.contractDependencies[className].push(arg.substr(1));
|
||||||
|
@ -180,20 +180,20 @@ ContractsManager.prototype.getContract = function(className) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ContractsManager.prototype.sortContracts = function(contractList) {
|
ContractsManager.prototype.sortContracts = function(contractList) {
|
||||||
var converted_dependencies = [], i;
|
let converted_dependencies = [], i;
|
||||||
|
|
||||||
for(var contract in this.contractDependencies) {
|
for(let contract in this.contractDependencies) {
|
||||||
var dependencies = this.contractDependencies[contract];
|
let dependencies = this.contractDependencies[contract];
|
||||||
for(i=0; i < dependencies.length; i++) {
|
for(i=0; i < dependencies.length; i++) {
|
||||||
converted_dependencies.push([contract, dependencies[i]]);
|
converted_dependencies.push([contract, dependencies[i]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var orderedDependencies = toposort(converted_dependencies).reverse();
|
let orderedDependencies = toposort(converted_dependencies).reverse();
|
||||||
|
|
||||||
var newList = contractList.sort(function(a,b) {
|
let newList = contractList.sort(function(a,b) {
|
||||||
var order_a = orderedDependencies.indexOf(a.className);
|
let order_a = orderedDependencies.indexOf(a.className);
|
||||||
var order_b = orderedDependencies.indexOf(b.className);
|
let order_b = orderedDependencies.indexOf(b.className);
|
||||||
return order_a - order_b;
|
return order_a - order_b;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -202,21 +202,21 @@ ContractsManager.prototype.sortContracts = function(contractList) {
|
||||||
|
|
||||||
// TODO: should be built contracts
|
// TODO: should be built contracts
|
||||||
ContractsManager.prototype.listContracts = function() {
|
ContractsManager.prototype.listContracts = function() {
|
||||||
var contracts = [];
|
let contracts = [];
|
||||||
for(var className in this.contracts) {
|
for(let className in this.contracts) {
|
||||||
var contract = this.contracts[className];
|
let contract = this.contracts[className];
|
||||||
contracts.push(contract);
|
contracts.push(contract);
|
||||||
}
|
}
|
||||||
return this.sortContracts(contracts);
|
return this.sortContracts(contracts);
|
||||||
};
|
};
|
||||||
|
|
||||||
ContractsManager.prototype.contractsState = function() {
|
ContractsManager.prototype.contractsState = function() {
|
||||||
var data = [];
|
let data = [];
|
||||||
|
|
||||||
for(var className in this.contracts) {
|
for(let className in this.contracts) {
|
||||||
var contract = this.contracts[className];
|
let contract = this.contracts[className];
|
||||||
|
|
||||||
var contractData;
|
let contractData;
|
||||||
|
|
||||||
if (contract.deploy === false) {
|
if (contract.deploy === false) {
|
||||||
contractData = [
|
contractData = [
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
var async = require('async');
|
let async = require('async');
|
||||||
|
|
||||||
var RunCode = require('../core/runCode.js');
|
let RunCode = require('../core/runCode.js');
|
||||||
|
|
||||||
var DeployTracker = require('./deploy_tracker.js');
|
let DeployTracker = require('./deploy_tracker.js');
|
||||||
var ABIGenerator = require('./abi.js');
|
let ABIGenerator = require('./abi.js');
|
||||||
|
|
||||||
var Deploy = function(options) {
|
let Deploy = function(options) {
|
||||||
this.web3 = options.web3;
|
this.web3 = options.web3;
|
||||||
this.contractsManager = options.contractsManager;
|
this.contractsManager = options.contractsManager;
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
|
@ -17,7 +17,7 @@ var Deploy = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Deploy.prototype.determineArguments = function(suppliedArgs) {
|
Deploy.prototype.determineArguments = function(suppliedArgs) {
|
||||||
var realArgs = [], l, arg, contractName, referedContract;
|
let realArgs = [], l, arg, contractName, referedContract;
|
||||||
|
|
||||||
for (l = 0; l < suppliedArgs.length; l++) {
|
for (l = 0; l < suppliedArgs.length; l++) {
|
||||||
arg = suppliedArgs[l];
|
arg = suppliedArgs[l];
|
||||||
|
@ -34,13 +34,13 @@ Deploy.prototype.determineArguments = function(suppliedArgs) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var suppliedArgs;
|
let suppliedArgs;
|
||||||
var realArgs;
|
let realArgs;
|
||||||
var arg;
|
let arg;
|
||||||
var l;
|
let l;
|
||||||
var contractName;
|
let contractName;
|
||||||
var referedContract;
|
let referedContract;
|
||||||
contract.error = false;
|
contract.error = false;
|
||||||
|
|
||||||
if (contract.deploy === false) {
|
if (contract.deploy === false) {
|
||||||
|
@ -59,7 +59,7 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
var trackedContract = self.deployTracker.getContract(contract.className, contract.realRuntimeBytecode, contract.args);
|
let trackedContract = self.deployTracker.getContract(contract.className, contract.realRuntimeBytecode, contract.args);
|
||||||
|
|
||||||
if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") {
|
if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") {
|
||||||
self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan);
|
self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan);
|
||||||
|
@ -80,9 +80,9 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
||||||
|
|
||||||
if (contract.onDeploy !== undefined) {
|
if (contract.onDeploy !== undefined) {
|
||||||
self.logger.info('executing onDeploy commands');
|
self.logger.info('executing onDeploy commands');
|
||||||
var abiGenerator = new ABIGenerator({contractsManager: self.contractsManager});
|
let abiGenerator = new ABIGenerator({contractsManager: self.contractsManager});
|
||||||
var abi = abiGenerator.generateContracts(false);
|
let abi = abiGenerator.generateContracts(false);
|
||||||
var cmds = contract.onDeploy.join(';\n');
|
let cmds = contract.onDeploy.join(';\n');
|
||||||
|
|
||||||
RunCode.doEval(abi + "\n" + cmds, self.web3);
|
RunCode.doEval(abi + "\n" + cmds, self.web3);
|
||||||
}
|
}
|
||||||
|
@ -94,10 +94,10 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Deploy.prototype.deployContract = function(contract, params, callback) {
|
Deploy.prototype.deployContract = function(contract, params, callback) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var contractObject = this.web3.eth.contract(contract.abiDefinition);
|
let contractObject = this.web3.eth.contract(contract.abiDefinition);
|
||||||
|
|
||||||
var contractParams = (params || contract.args).slice();
|
let contractParams = (params || contract.args).slice();
|
||||||
|
|
||||||
this.web3.eth.getAccounts(function(err, accounts) {
|
this.web3.eth.getAccounts(function(err, accounts) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -121,7 +121,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
self.logger.error("error deploying contract: " + contract.className.cyan);
|
self.logger.error("error deploying contract: " + contract.className.cyan);
|
||||||
var errMsg = err.toString();
|
let errMsg = err.toString();
|
||||||
if (errMsg === 'Error: The contract code couldn\'t be stored, please check your gas amount.') {
|
if (errMsg === 'Error: The contract code couldn\'t be stored, please check your gas amount.') {
|
||||||
errMsg = 'The contract code couldn\'t be stored, out of gas or constructor error';
|
errMsg = 'The contract code couldn\'t be stored, out of gas or constructor error';
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Deploy.prototype.deployAll = function(done) {
|
Deploy.prototype.deployAll = function(done) {
|
||||||
var self = this;
|
let self = this;
|
||||||
this.logger.info("deploying contracts");
|
this.logger.info("deploying contracts");
|
||||||
|
|
||||||
async.eachOfSeries(this.contractsManager.listContracts(),
|
async.eachOfSeries(this.contractsManager.listContracts(),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var fs = require('../core/fs.js');
|
let fs = require('../core/fs.js');
|
||||||
|
|
||||||
var DeployTracker = function(options) {
|
let DeployTracker = function(options) {
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.env = options.env;
|
this.env = options.env;
|
||||||
this.chainConfig = options.chainConfig;
|
this.chainConfig = options.chainConfig;
|
||||||
|
@ -12,8 +12,8 @@ var DeployTracker = function(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: need to make this async
|
// TODO: need to make this async
|
||||||
var block = this.web3.eth.getBlock(0);
|
let block = this.web3.eth.getBlock(0);
|
||||||
var chainId = block.hash;
|
let chainId = block.hash;
|
||||||
|
|
||||||
if (this.chainConfig[chainId] === undefined) {
|
if (this.chainConfig[chainId] === undefined) {
|
||||||
this.chainConfig[chainId] = {contracts: {}};
|
this.chainConfig[chainId] = {contracts: {}};
|
||||||
|
@ -40,7 +40,7 @@ DeployTracker.prototype.trackContract = function(contractName, code, args, addre
|
||||||
};
|
};
|
||||||
|
|
||||||
DeployTracker.prototype.getContract = function(contractName, code, args) {
|
DeployTracker.prototype.getContract = function(contractName, code, args) {
|
||||||
var contract = this.currentChain.contracts[this.web3.sha3(code + contractName + args.join(','))];
|
let contract = this.currentChain.contracts[this.web3.sha3(code + contractName + args.join(','))];
|
||||||
if (contract && contract.address === undefined) { return false; }
|
if (contract && contract.address === undefined) { return false; }
|
||||||
return contract;
|
return contract;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var solc;
|
let solc;
|
||||||
|
|
||||||
process.on('message', function(msg) {
|
process.on('message', function(msg) {
|
||||||
if (msg.action === 'loadCompiler') {
|
if (msg.action === 'loadCompiler') {
|
||||||
|
@ -7,7 +7,7 @@ process.on('message', function(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.action === 'compile') {
|
if (msg.action === 'compile') {
|
||||||
var output = solc.compile(msg.obj, msg.optimize);
|
let output = solc.compile(msg.obj, msg.optimize);
|
||||||
process.send({result: "compilation", output: output});
|
process.send({result: "compilation", output: output});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
var utils = require('../utils/utils.js');
|
let utils = require('../utils/utils.js');
|
||||||
var solcProcess;
|
let solcProcess;
|
||||||
var compilerLoaded = false;
|
let compilerLoaded = false;
|
||||||
|
|
||||||
var SolcW = function() {
|
let SolcW = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
SolcW.prototype.load_compiler = function(done) {
|
SolcW.prototype.load_compiler = function(done) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
var Core = function() {};
|
let Core = function() {};
|
||||||
|
|
||||||
module.exports = Core;
|
module.exports = Core;
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
var http = require('http');
|
let http = require('http');
|
||||||
var Web3 = require('web3');
|
let Web3 = require('web3');
|
||||||
var utils = require('../utils/utils.js');
|
let utils = require('../utils/utils.js');
|
||||||
|
|
||||||
var Events = require('./events.js');
|
let Events = require('./events.js');
|
||||||
var Logger = require('./logger.js');
|
let Logger = require('./logger.js');
|
||||||
var Config = require('./config.js');
|
let Config = require('./config.js');
|
||||||
|
|
||||||
var DeployManager = require('../contracts/deploy_manager.js');
|
let DeployManager = require('../contracts/deploy_manager.js');
|
||||||
var ABIGenerator = require('../contracts/abi.js');
|
let ABIGenerator = require('../contracts/abi.js');
|
||||||
var ServicesMonitor = require('./services_monitor.js');
|
let ServicesMonitor = require('./services_monitor.js');
|
||||||
var Pipeline = require('../pipeline/pipeline.js');
|
let Pipeline = require('../pipeline/pipeline.js');
|
||||||
var Server = require('../pipeline/server.js');
|
let Server = require('../pipeline/server.js');
|
||||||
var Watch = require('../pipeline/watch.js');
|
let Watch = require('../pipeline/watch.js');
|
||||||
var version = require('../../package.json').version;
|
let version = require('../../package.json').version;
|
||||||
|
|
||||||
var Engine = function(options) {
|
let Engine = function(options) {
|
||||||
this.env = options.env;
|
this.env = options.env;
|
||||||
this.embarkConfig = options.embarkConfig;
|
this.embarkConfig = options.embarkConfig;
|
||||||
this.interceptLogs = options.interceptLogs;
|
this.interceptLogs = options.interceptLogs;
|
||||||
|
@ -22,8 +22,8 @@ var Engine = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.init = function(_options) {
|
Engine.prototype.init = function(_options) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var options = _options || {};
|
let options = _options || {};
|
||||||
this.events = new Events();
|
this.events = new Events();
|
||||||
this.logger = options.logger || new Logger({logLevel: 'debug'});
|
this.logger = options.logger || new Logger({logLevel: 'debug'});
|
||||||
this.config = new Config({env: this.env, logger: this.logger, events: this.events});
|
this.config = new Config({env: this.env, logger: this.logger, events: this.events});
|
||||||
|
@ -37,9 +37,9 @@ Engine.prototype.init = function(_options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.startMonitor = function() {
|
Engine.prototype.startMonitor = function() {
|
||||||
var self = this;
|
let self = this;
|
||||||
if (this.plugins) {
|
if (this.plugins) {
|
||||||
var servicePlugins = this.plugins.getPluginsFor('serviceChecks');
|
let servicePlugins = this.plugins.getPluginsFor('serviceChecks');
|
||||||
servicePlugins.forEach(function(plugin) {
|
servicePlugins.forEach(function(plugin) {
|
||||||
plugin.serviceChecks.forEach(function(pluginCheck) {
|
plugin.serviceChecks.forEach(function(pluginCheck) {
|
||||||
self.servicesMonitor.addCheck(pluginCheck.checkName, pluginCheck.checkFn, pluginCheck.time);
|
self.servicesMonitor.addCheck(pluginCheck.checkName, pluginCheck.checkFn, pluginCheck.time);
|
||||||
|
@ -50,9 +50,9 @@ Engine.prototype.startMonitor = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.startService = function(serviceName, _options) {
|
Engine.prototype.startService = function(serviceName, _options) {
|
||||||
var options = _options || {};
|
let options = _options || {};
|
||||||
|
|
||||||
var services = {
|
let services = {
|
||||||
"pipeline": this.pipelineService,
|
"pipeline": this.pipelineService,
|
||||||
"abi": this.abiService,
|
"abi": this.abiService,
|
||||||
"deployment": this.deploymentService,
|
"deployment": this.deploymentService,
|
||||||
|
@ -62,7 +62,7 @@ Engine.prototype.startService = function(serviceName, _options) {
|
||||||
"web3": this.web3Service
|
"web3": this.web3Service
|
||||||
};
|
};
|
||||||
|
|
||||||
var service = services[serviceName];
|
let service = services[serviceName];
|
||||||
|
|
||||||
if (!service) {
|
if (!service) {
|
||||||
throw new Error("unknown service: " + serviceName);
|
throw new Error("unknown service: " + serviceName);
|
||||||
|
@ -74,9 +74,9 @@ Engine.prototype.startService = function(serviceName, _options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.pipelineService = function(options) {
|
Engine.prototype.pipelineService = function(options) {
|
||||||
var self = this;
|
let self = this;
|
||||||
this.logger.setStatus("Building Assets");
|
this.logger.setStatus("Building Assets");
|
||||||
var pipeline = new Pipeline({
|
let pipeline = new Pipeline({
|
||||||
buildDir: this.config.buildDir,
|
buildDir: this.config.buildDir,
|
||||||
contractsFiles: this.config.contractsFiles,
|
contractsFiles: this.config.contractsFiles,
|
||||||
assetFiles: this.config.assetFiles,
|
assetFiles: this.config.assetFiles,
|
||||||
|
@ -100,18 +100,18 @@ Engine.prototype.pipelineService = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.abiService = function(options) {
|
Engine.prototype.abiService = function(options) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var generateABICode = function(contractsManager) {
|
let generateABICode = function(contractsManager) {
|
||||||
var abiGenerator = new ABIGenerator({
|
let abiGenerator = new ABIGenerator({
|
||||||
blockchainConfig: self.config.blockchainConfig,
|
blockchainConfig: self.config.blockchainConfig,
|
||||||
contractsManager: contractsManager,
|
contractsManager: contractsManager,
|
||||||
plugins: self.plugins,
|
plugins: self.plugins,
|
||||||
storageConfig: self.config.storageConfig,
|
storageConfig: self.config.storageConfig,
|
||||||
communicationConfig: self.config.communicationConfig
|
communicationConfig: self.config.communicationConfig
|
||||||
});
|
});
|
||||||
var embarkJSABI = abiGenerator.generateABI({useEmbarkJS: true});
|
let embarkJSABI = abiGenerator.generateABI({useEmbarkJS: true});
|
||||||
var vanillaABI = abiGenerator.generateABI({useEmbarkJS: false});
|
let vanillaABI = abiGenerator.generateABI({useEmbarkJS: false});
|
||||||
var vanillaContractsABI = abiGenerator.generateContracts(false);
|
let vanillaContractsABI = abiGenerator.generateContracts(false);
|
||||||
|
|
||||||
self.events.emit('abi-contracts-vanila', vanillaContractsABI);
|
self.events.emit('abi-contracts-vanila', vanillaContractsABI);
|
||||||
self.events.emit('abi-vanila', vanillaABI);
|
self.events.emit('abi-vanila', vanillaABI);
|
||||||
|
@ -122,7 +122,7 @@ Engine.prototype.abiService = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.deploymentService = function(options) {
|
Engine.prototype.deploymentService = function(options) {
|
||||||
var self = this;
|
let self = this;
|
||||||
this.deployManager = new DeployManager({
|
this.deployManager = new DeployManager({
|
||||||
web3: options.web3 || self.web3,
|
web3: options.web3 || self.web3,
|
||||||
trackContracts: options.trackContracts,
|
trackContracts: options.trackContracts,
|
||||||
|
@ -144,27 +144,27 @@ Engine.prototype.deploymentService = function(options) {
|
||||||
|
|
||||||
Engine.prototype.fileWatchService = function(options) {
|
Engine.prototype.fileWatchService = function(options) {
|
||||||
this.logger.setStatus("Watching for changes");
|
this.logger.setStatus("Watching for changes");
|
||||||
var watch = new Watch({logger: this.logger, events: this.events});
|
let watch = new Watch({logger: this.logger, events: this.events});
|
||||||
watch.start();
|
watch.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.webServerService = function(options) {
|
Engine.prototype.webServerService = function(options) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var webServerConfig = this.config.webServerConfig;
|
let webServerConfig = this.config.webServerConfig;
|
||||||
if (!webServerConfig.enabled) { return; }
|
if (!webServerConfig.enabled) { return; }
|
||||||
|
|
||||||
var host = options.host || webServerConfig.host;
|
let host = options.host || webServerConfig.host;
|
||||||
var port = options.port || webServerConfig.port;
|
let port = options.port || webServerConfig.port;
|
||||||
|
|
||||||
this.logger.setStatus("Starting Server");
|
this.logger.setStatus("Starting Server");
|
||||||
var server = new Server({
|
let server = new Server({
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
host: host,
|
host: host,
|
||||||
port: port
|
port: port
|
||||||
});
|
});
|
||||||
|
|
||||||
self.servicesMonitor.addCheck('Webserver', function(cb) {
|
self.servicesMonitor.addCheck('Webserver', function(cb) {
|
||||||
var devServer = 'Webserver (http://' + host + ':' + port + ')';
|
let devServer = 'Webserver (http://' + host + ':' + port + ')';
|
||||||
return cb({name: devServer, status: 'green'});
|
return cb({name: devServer, status: 'green'});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ Engine.prototype.webServerService = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.ipfsService = function(options) {
|
Engine.prototype.ipfsService = function(options) {
|
||||||
var self = this;
|
let self = this;
|
||||||
self.servicesMonitor.addCheck('IPFS', function(cb) {
|
self.servicesMonitor.addCheck('IPFS', function(cb) {
|
||||||
utils.checkIsAvailable('http://localhost:5001', function(available) {
|
utils.checkIsAvailable('http://localhost:5001', function(available) {
|
||||||
if (available) {
|
if (available) {
|
||||||
|
@ -181,13 +181,13 @@ Engine.prototype.ipfsService = function(options) {
|
||||||
//The URL should also be flexible to accept non-default IPFS url
|
//The URL should also be flexible to accept non-default IPFS url
|
||||||
self.logger.trace("Checking IPFS version...");
|
self.logger.trace("Checking IPFS version...");
|
||||||
http.get('http://localhost:5001/api/v0/version', function(res) {
|
http.get('http://localhost:5001/api/v0/version', function(res) {
|
||||||
var body = '';
|
let body = '';
|
||||||
res.on('data', function(d) {
|
res.on('data', function(d) {
|
||||||
body += d;
|
body += d;
|
||||||
});
|
});
|
||||||
res.on('end', function() {
|
res.on('end', function() {
|
||||||
try{
|
try{
|
||||||
var parsed = JSON.parse(body);
|
let parsed = JSON.parse(body);
|
||||||
if(parsed.Version){
|
if(parsed.Version){
|
||||||
return cb({name: ("IPFS " + parsed.Version), status: 'green'});
|
return cb({name: ("IPFS " + parsed.Version), status: 'green'});
|
||||||
}
|
}
|
||||||
|
@ -213,11 +213,11 @@ Engine.prototype.ipfsService = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.web3Service = function(options) {
|
Engine.prototype.web3Service = function(options) {
|
||||||
var self = this;
|
let self = this;
|
||||||
this.web3 = options.web3;
|
this.web3 = options.web3;
|
||||||
if (this.web3 === undefined) {
|
if (this.web3 === undefined) {
|
||||||
this.web3 = new Web3();
|
this.web3 = new Web3();
|
||||||
var web3Endpoint = 'http://' + this.config.blockchainConfig.rpcHost + ':' + this.config.blockchainConfig.rpcPort;
|
let web3Endpoint = 'http://' + this.config.blockchainConfig.rpcHost + ':' + this.config.blockchainConfig.rpcPort;
|
||||||
this.web3.setProvider(new this.web3.providers.HttpProvider(web3Endpoint));
|
this.web3.setProvider(new this.web3.providers.HttpProvider(web3Endpoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var fs = require('fs-extra');
|
let fs = require('fs-extra');
|
||||||
var utils = require('../utils/utils.js');
|
let utils = require('../utils/utils.js');
|
||||||
|
|
||||||
function mkdirpSync() {
|
function mkdirpSync() {
|
||||||
return fs.mkdirpSync.apply(fs.mkdirpSync, arguments);
|
return fs.mkdirpSync.apply(fs.mkdirpSync, arguments);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var colors = require('colors');
|
let colors = require('colors');
|
||||||
|
|
||||||
var Logger = function(options) {
|
let Logger = function(options) {
|
||||||
this.logLevels = ['error', 'warn', 'info', 'debug', 'trace'];
|
this.logLevels = ['error', 'warn', 'info', 'debug', 'trace'];
|
||||||
this.logLevel = options.logLevel || 'info';
|
this.logLevel = options.logLevel || 'info';
|
||||||
this.logFunction = options.logFunction || console.log;
|
this.logFunction = options.logFunction || console.log;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var Web3 = require('web3');
|
let Web3 = require('web3');
|
||||||
var web3;
|
let web3;
|
||||||
|
|
||||||
// ======================
|
// ======================
|
||||||
// the eval is used for evaluating some of the contact calls for different purposes
|
// the eval is used for evaluating some of the contact calls for different purposes
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
var async = require('../utils/async_extend.js');
|
let async = require('../utils/async_extend.js');
|
||||||
|
|
||||||
// TODO: need to separate colors from states
|
// TODO: need to separate colors from states
|
||||||
// i.e use status: /on|off|warn/ not /red|green/
|
// i.e use status: /on|off|warn/ not /red|green/
|
||||||
// it's up to the logger or console to determine the color
|
// it's up to the logger or console to determine the color
|
||||||
var ServicesMonitor = function(options) {
|
let ServicesMonitor = function(options) {
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.checkList = {};
|
this.checkList = {};
|
||||||
|
@ -13,8 +13,8 @@ var ServicesMonitor = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ServicesMonitor.prototype.initCheck = function(checkName) {
|
ServicesMonitor.prototype.initCheck = function(checkName) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var check = this.checkList[checkName];
|
let check = this.checkList[checkName];
|
||||||
|
|
||||||
if (!check) { return false; }
|
if (!check) { return false; }
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ ServicesMonitor.prototype.initCheck = function(checkName) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ServicesMonitor.prototype.addCheck = function(checkName, checkFn, time) {
|
ServicesMonitor.prototype.addCheck = function(checkName, checkFn, time) {
|
||||||
var self = this;
|
let self = this;
|
||||||
this.logger.trace('add check: ' + checkName);
|
this.logger.trace('add check: ' + checkName);
|
||||||
this.checkList[checkName] = {fn: checkFn, interval: time || 5000};
|
this.checkList[checkName] = {fn: checkFn, interval: time || 5000};
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ ServicesMonitor.prototype.stopCheck = function(name) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ServicesMonitor.prototype.startMonitor = function() {
|
ServicesMonitor.prototype.startMonitor = function() {
|
||||||
var self = this;
|
let self = this;
|
||||||
this.working = true;
|
this.working = true;
|
||||||
this.logger.trace('startMonitor');
|
this.logger.trace('startMonitor');
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var getSimulator = function() {
|
let getSimulator = function() {
|
||||||
try {
|
try {
|
||||||
return require('ethereumjs-testrpc');
|
return require('ethereumjs-testrpc');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -17,18 +17,18 @@ var getSimulator = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var Test;
|
let Test;
|
||||||
Test = (function (options) {
|
Test = (function (options) {
|
||||||
var async = require('async');
|
let async = require('async');
|
||||||
var opts = options === undefined ? {} : options;
|
let opts = options === undefined ? {} : options;
|
||||||
opts.logLevel = opts.hasOwnProperty('logLevel') ? opts.logLevel : 'debug';
|
opts.logLevel = opts.hasOwnProperty('logLevel') ? opts.logLevel : 'debug';
|
||||||
opts.simulatorOptions = opts.hasOwnProperty('simulatorOptions') ? opts.simulatorOptions : {};
|
opts.simulatorOptions = opts.hasOwnProperty('simulatorOptions') ? opts.simulatorOptions : {};
|
||||||
var sim = getSimulator();
|
let sim = getSimulator();
|
||||||
|
|
||||||
function newWebThree() {
|
function newWebThree() {
|
||||||
try {
|
try {
|
||||||
var Web3 = require('web3');
|
let Web3 = require('web3');
|
||||||
var web3 = new Web3();
|
let web3 = new Web3();
|
||||||
web3.setProvider(sim.provider(opts.simulatorOptions));
|
web3.setProvider(sim.provider(opts.simulatorOptions));
|
||||||
return web3;
|
return web3;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -37,11 +37,11 @@ Test = (function (options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deployAll(contractsConfig, cb) {
|
function deployAll(contractsConfig, cb) {
|
||||||
var RunCode = require('./runCode.js');
|
let RunCode = require('./runCode.js');
|
||||||
var self = this;
|
let self = this;
|
||||||
|
|
||||||
function newEngine () {
|
function newEngine () {
|
||||||
var Engine = require('./engine.js');
|
let Engine = require('./engine.js');
|
||||||
return new Engine({
|
return new Engine({
|
||||||
env: opts.env || 'test',
|
env: opts.env || 'test',
|
||||||
// TODO: confi will need to detect if this is a obj
|
// TODO: confi will need to detect if this is a obj
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
var colors = require('colors');
|
let colors = require('colors');
|
||||||
|
|
||||||
// TODO: just logFunction changes, probably doesn't need a whole new module just
|
// TODO: just logFunction changes, probably doesn't need a whole new module just
|
||||||
// for this
|
// for this
|
||||||
var TestLogger = function(options) {
|
let TestLogger = function(options) {
|
||||||
this.logLevels = ['error', 'warn', 'info', 'debug', 'trace'];
|
this.logLevels = ['error', 'warn', 'info', 'debug', 'trace'];
|
||||||
this.logs = [];
|
this.logs = [];
|
||||||
this.logLevel = options.logLevel || 'info';
|
this.logLevel = options.logLevel || 'info';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
var CommandHistory = function() {
|
let CommandHistory = function() {
|
||||||
this.history = [];
|
this.history = [];
|
||||||
this.pointer = -1;
|
this.pointer = -1;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
var async = require('async');
|
let async = require('async');
|
||||||
|
|
||||||
var Monitor = require('./monitor.js');
|
let Monitor = require('./monitor.js');
|
||||||
var Console = require('./console.js');
|
let Console = require('./console.js');
|
||||||
|
|
||||||
var Dashboard = function(options) {
|
let Dashboard = function(options) {
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
this.version = options.version;
|
this.version = options.version;
|
||||||
|
@ -11,8 +11,8 @@ var Dashboard = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Dashboard.prototype.start = function(done) {
|
Dashboard.prototype.start = function(done) {
|
||||||
var console, monitor;
|
let console, monitor;
|
||||||
var self = this;
|
let self = this;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function startConsole(callback) {
|
function startConsole(callback) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*jshint esversion: 6 */
|
/*jshint esversion: 6 */
|
||||||
|
|
||||||
var blessed = require("blessed");
|
let blessed = require("blessed");
|
||||||
var CommandHistory = require('./command_history.js');
|
let CommandHistory = require('./command_history.js');
|
||||||
var version = require('../../package.json').version;
|
let version = require('../../package.json').version;
|
||||||
|
|
||||||
function Dashboard(options) {
|
function Dashboard(options) {
|
||||||
var title = (options && options.title) || "Embark " + version;
|
let title = (options && options.title) || "Embark " + version;
|
||||||
this.env = options.env;
|
this.env = options.env;
|
||||||
this.console = options.console;
|
this.console = options.console;
|
||||||
this.history = new CommandHistory();
|
this.history = new CommandHistory();
|
||||||
|
@ -41,8 +41,8 @@ function Dashboard(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Dashboard.prototype.availableServices = function(_services) {
|
Dashboard.prototype.availableServices = function(_services) {
|
||||||
var services = [];
|
let services = [];
|
||||||
var checkName;
|
let checkName;
|
||||||
for (checkName in _services) {
|
for (checkName in _services) {
|
||||||
services.push(_services[checkName]);
|
services.push(_services[checkName]);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ Dashboard.prototype.setStatus = function(status) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Dashboard.prototype.setContracts = function(contracts) {
|
Dashboard.prototype.setContracts = function(contracts) {
|
||||||
var data = [];
|
let data = [];
|
||||||
|
|
||||||
data.push(["Contract Name", "Address", "Status"]);
|
data.push(["Contract Name", "Address", "Status"]);
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ Dashboard.prototype.layoutCmd = function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var self = this;
|
let self = this;
|
||||||
|
|
||||||
this.input.key(["C-c"], function() {
|
this.input.key(["C-c"], function() {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
@ -326,13 +326,13 @@ Dashboard.prototype.layoutCmd = function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.input.key(["up"], function() {
|
this.input.key(["up"], function() {
|
||||||
var cmd = self.history.getPreviousCommand();
|
let cmd = self.history.getPreviousCommand();
|
||||||
self.input.setValue(cmd);
|
self.input.setValue(cmd);
|
||||||
self.input.focus();
|
self.input.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.input.key(["down"], function() {
|
this.input.key(["down"], function() {
|
||||||
var cmd = self.history.getNextCommand();
|
let cmd = self.history.getNextCommand();
|
||||||
self.input.setValue(cmd);
|
self.input.setValue(cmd);
|
||||||
self.input.focus();
|
self.input.focus();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*jshint esversion: 6, loopfunc: true */
|
/*jshint esversion: 6, loopfunc: true */
|
||||||
var fs = require('../core/fs.js');
|
let fs = require('../core/fs.js');
|
||||||
|
|
||||||
var Pipeline = function(options) {
|
let Pipeline = function(options) {
|
||||||
this.buildDir = options.buildDir;
|
this.buildDir = options.buildDir;
|
||||||
this.contractsFiles = options.contractsFiles;
|
this.contractsFiles = options.contractsFiles;
|
||||||
this.assetFiles = options.assetFiles;
|
this.assetFiles = options.assetFiles;
|
||||||
|
@ -10,13 +10,13 @@ var Pipeline = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Pipeline.prototype.build = function(abi, path) {
|
Pipeline.prototype.build = function(abi, path) {
|
||||||
var self = this;
|
let self = this;
|
||||||
for(var targetFile in this.assetFiles) {
|
for(let targetFile in this.assetFiles) {
|
||||||
|
|
||||||
var contentFiles = this.assetFiles[targetFile].map(file => {
|
let contentFiles = this.assetFiles[targetFile].map(file => {
|
||||||
self.logger.trace("reading " + file.filename);
|
self.logger.trace("reading " + file.filename);
|
||||||
|
|
||||||
var pipelinePlugins = this.plugins.getPluginsFor('pipeline');
|
let pipelinePlugins = this.plugins.getPluginsFor('pipeline');
|
||||||
|
|
||||||
if (file.filename === 'embark.js') {
|
if (file.filename === 'embark.js') {
|
||||||
return {content: file.content + "\n" + abi, filename: file.filename, path: file.path, modified: true};
|
return {content: file.content + "\n" + abi, filename: file.filename, path: file.path, modified: true};
|
||||||
|
@ -46,27 +46,27 @@ Pipeline.prototype.build = function(abi, path) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var dir = targetFile.split('/').slice(0, -1).join('/');
|
let dir = targetFile.split('/').slice(0, -1).join('/');
|
||||||
self.logger.trace("creating dir " + this.buildDir + dir);
|
self.logger.trace("creating dir " + this.buildDir + dir);
|
||||||
fs.mkdirpSync(this.buildDir + dir);
|
fs.mkdirpSync(this.buildDir + dir);
|
||||||
|
|
||||||
// if it's a directory
|
// if it's a directory
|
||||||
if (targetFile.slice(-1) === '/' || targetFile.indexOf('.') === -1) {
|
if (targetFile.slice(-1) === '/' || targetFile.indexOf('.') === -1) {
|
||||||
var targetDir = targetFile;
|
let targetDir = targetFile;
|
||||||
|
|
||||||
if (targetDir.slice(-1) !== '/') {
|
if (targetDir.slice(-1) !== '/') {
|
||||||
targetDir = targetDir + '/';
|
targetDir = targetDir + '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
contentFiles.map(function(file) {
|
contentFiles.map(function(file) {
|
||||||
var filename = file.filename.replace('app/', '');
|
let filename = file.filename.replace('app/', '');
|
||||||
filename = filename.replace(targetDir, '');
|
filename = filename.replace(targetDir, '');
|
||||||
self.logger.info("writing file " + (self.buildDir + targetDir + filename).bold.dim);
|
self.logger.info("writing file " + (self.buildDir + targetDir + filename).bold.dim);
|
||||||
|
|
||||||
fs.copySync(self.buildDir + targetDir + filename, file.path, {overwrite: true});
|
fs.copySync(self.buildDir + targetDir + filename, file.path, {overwrite: true});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var content = contentFiles.map(function(file) {
|
let content = contentFiles.map(function(file) {
|
||||||
return file.content;
|
return file.content;
|
||||||
}).join("\n");
|
}).join("\n");
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
var finalhandler = require('finalhandler');
|
let finalhandler = require('finalhandler');
|
||||||
var http = require('http');
|
let http = require('http');
|
||||||
var serveStatic = require('serve-static');
|
let serveStatic = require('serve-static');
|
||||||
|
|
||||||
var Server = function(options) {
|
let Server = function(options) {
|
||||||
this.dist = options.dist || 'dist/';
|
this.dist = options.dist || 'dist/';
|
||||||
this.port = options.port || 8000;
|
this.port = options.port || 8000;
|
||||||
this.hostname = options.host || 'localhost';
|
this.hostname = options.host || 'localhost';
|
||||||
|
@ -10,9 +10,9 @@ var Server = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype.start = function(callback) {
|
Server.prototype.start = function(callback) {
|
||||||
var serve = serveStatic(this.dist, {'index': ['index.html', 'index.htm']});
|
let serve = serveStatic(this.dist, {'index': ['index.html', 'index.htm']});
|
||||||
|
|
||||||
var server = http.createServer(function onRequest (req, res) {
|
let server = http.createServer(function onRequest (req, res) {
|
||||||
serve(req, res, finalhandler(req, res));
|
serve(req, res, finalhandler(req, res));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/*jshint esversion: 6 */
|
/*jshint esversion: 6 */
|
||||||
var chokidar = require('chokidar');
|
let chokidar = require('chokidar');
|
||||||
|
|
||||||
var fs = require('../core/fs.js');
|
let fs = require('../core/fs.js');
|
||||||
|
|
||||||
// TODO: this should be receiving the config object not re-reading the
|
// TODO: this should be receiving the config object not re-reading the
|
||||||
// embark.json file
|
// embark.json file
|
||||||
var Watch = function(options) {
|
let Watch = function(options) {
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
};
|
};
|
||||||
|
|
||||||
Watch.prototype.start = function() {
|
Watch.prototype.start = function() {
|
||||||
var self = this;
|
let self = this;
|
||||||
// TODO: should come from the config object instead of reading the file
|
// TODO: should come from the config object instead of reading the file
|
||||||
// directly
|
// directly
|
||||||
var embarkConfig = fs.readJSONSync("embark.json");
|
let embarkConfig = fs.readJSONSync("embark.json");
|
||||||
|
|
||||||
this.watchAssets(embarkConfig, function() {
|
this.watchAssets(embarkConfig, function() {
|
||||||
self.logger.trace('ready to watch asset changes');
|
self.logger.trace('ready to watch asset changes');
|
||||||
|
@ -32,11 +32,11 @@ Watch.prototype.start = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Watch.prototype.watchAssets = function(embarkConfig, callback) {
|
Watch.prototype.watchAssets = function(embarkConfig, callback) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var appConfig = embarkConfig.app;
|
let appConfig = embarkConfig.app;
|
||||||
var filesToWatch = [];
|
let filesToWatch = [];
|
||||||
|
|
||||||
for(var targetFile in appConfig) {
|
for(let targetFile in appConfig) {
|
||||||
filesToWatch.push(appConfig[targetFile]);
|
filesToWatch.push(appConfig[targetFile]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ Watch.prototype.watchAssets = function(embarkConfig, callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Watch.prototype.watchContracts = function(embarkConfig, callback) {
|
Watch.prototype.watchContracts = function(embarkConfig, callback) {
|
||||||
var self = this;
|
let self = this;
|
||||||
this.watchFiles(
|
this.watchFiles(
|
||||||
[embarkConfig.contracts],
|
[embarkConfig.contracts],
|
||||||
function(eventName, path) {
|
function(eventName, path) {
|
||||||
|
@ -69,7 +69,7 @@ Watch.prototype.watchContracts = function(embarkConfig, callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Watch.prototype.watchConfigs = function(callback) {
|
Watch.prototype.watchConfigs = function(callback) {
|
||||||
var self = this;
|
let self = this;
|
||||||
this.watchFiles(
|
this.watchFiles(
|
||||||
"config/**/contracts.json",
|
"config/**/contracts.json",
|
||||||
function(eventName, path) {
|
function(eventName, path) {
|
||||||
|
@ -87,7 +87,7 @@ Watch.prototype.watchFiles = function(files, changeCallback, doneCallback) {
|
||||||
this.logger.trace('watchFiles');
|
this.logger.trace('watchFiles');
|
||||||
this.logger.trace(files);
|
this.logger.trace(files);
|
||||||
|
|
||||||
var configWatcher = chokidar.watch(files, {
|
let configWatcher = chokidar.watch(files, {
|
||||||
ignored: /[\/\\]\./, persistent: true, ignoreInitial: true, followSymlinks: true
|
ignored: /[\/\\]\./, persistent: true, ignoreInitial: true, followSymlinks: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
var colors = require('colors');
|
let colors = require('colors');
|
||||||
var async = require('async');
|
let async = require('async');
|
||||||
var shelljs = require('shelljs');
|
let shelljs = require('shelljs');
|
||||||
|
|
||||||
var IPFS = function(options) {
|
let IPFS = function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.buildDir = options.buildDir || 'dist/';
|
this.buildDir = options.buildDir || 'dist/';
|
||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
|
@ -11,10 +11,10 @@ var IPFS = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
IPFS.prototype.deploy = function() {
|
IPFS.prototype.deploy = function() {
|
||||||
var self = this;
|
let self = this;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function findBinary(callback) {
|
function findBinary(callback) {
|
||||||
var ipfs_bin = shelljs.exec('which ' + self.configIpfsBin).output.split("\n")[0];
|
let ipfs_bin = shelljs.exec('which ' + self.configIpfsBin).output.split("\n")[0];
|
||||||
|
|
||||||
if (ipfs_bin === 'ipfs not found' || ipfs_bin === ''){
|
if (ipfs_bin === 'ipfs not found' || ipfs_bin === ''){
|
||||||
console.log(('=== WARNING: ' + self.configIpfsBin + ' not found or not in the path. Guessing ~/go/bin/ipfs for path').yellow);
|
console.log(('=== WARNING: ' + self.configIpfsBin + ' not found or not in the path. Guessing ~/go/bin/ipfs for path').yellow);
|
||||||
|
@ -24,17 +24,17 @@ IPFS.prototype.deploy = function() {
|
||||||
return callback(null, ipfs_bin);
|
return callback(null, ipfs_bin);
|
||||||
},
|
},
|
||||||
function runCommand(ipfs_bin, callback) {
|
function runCommand(ipfs_bin, callback) {
|
||||||
var cmd = ipfs_bin + " add -r " + self.buildDir;
|
let cmd = ipfs_bin + " add -r " + self.buildDir;
|
||||||
console.log(("=== adding " + self.buildDir + " to ipfs").green);
|
console.log(("=== adding " + self.buildDir + " to ipfs").green);
|
||||||
console.log(cmd.green);
|
console.log(cmd.green);
|
||||||
var result = shelljs.exec(cmd);
|
let result = shelljs.exec(cmd);
|
||||||
|
|
||||||
return callback(null, result);
|
return callback(null, result);
|
||||||
},
|
},
|
||||||
function getHashFromOutput(result, callback) {
|
function getHashFromOutput(result, callback) {
|
||||||
var rows = result.output.split("\n");
|
let rows = result.output.split("\n");
|
||||||
var dir_row = rows[rows.length - 2];
|
let dir_row = rows[rows.length - 2];
|
||||||
var dir_hash = dir_row.split(" ")[1];
|
let dir_hash = dir_row.split(" ")[1];
|
||||||
|
|
||||||
return callback(null, dir_hash);
|
return callback(null, dir_hash);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
var colors = require('colors');
|
let colors = require('colors');
|
||||||
var async = require('async');
|
let async = require('async');
|
||||||
var shelljs = require('shelljs');
|
let shelljs = require('shelljs');
|
||||||
|
|
||||||
var Swarm = function(options) {
|
let Swarm = function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.buildDir = options.buildDir || 'dist/';
|
this.buildDir = options.buildDir || 'dist/';
|
||||||
};
|
};
|
||||||
|
|
||||||
Swarm.prototype.deploy = function() {
|
Swarm.prototype.deploy = function() {
|
||||||
var self = this;
|
let self = this;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function findBinary(callback) {
|
function findBinary(callback) {
|
||||||
var swarm_bin = shelljs.exec('which swarm').output.split("\n")[0];
|
let swarm_bin = shelljs.exec('which swarm').output.split("\n")[0];
|
||||||
|
|
||||||
if (swarm_bin==='swarm not found' || swarm_bin === ''){
|
if (swarm_bin==='swarm not found' || swarm_bin === ''){
|
||||||
console.log('=== WARNING: Swarm not in an executable path. Guessing ~/go/bin/swarm for path'.yellow);
|
console.log('=== WARNING: Swarm not in an executable path. Guessing ~/go/bin/swarm for path'.yellow);
|
||||||
|
@ -21,10 +21,10 @@ Swarm.prototype.deploy = function() {
|
||||||
return callback(null, swarm_bin);
|
return callback(null, swarm_bin);
|
||||||
},
|
},
|
||||||
function runCommand(swarm_bin, callback) {
|
function runCommand(swarm_bin, callback) {
|
||||||
var cmd = swarm_bin + " --defaultpath " + self.buildDir + "index.html --recursive up " + self.buildDir;
|
let cmd = swarm_bin + " --defaultpath " + self.buildDir + "index.html --recursive up " + self.buildDir;
|
||||||
console.log(("=== adding " + self.buildDir + " to swarm").green);
|
console.log(("=== adding " + self.buildDir + " to swarm").green);
|
||||||
console.log(cmd.green);
|
console.log(cmd.green);
|
||||||
var result = shelljs.exec(cmd);
|
let result = shelljs.exec(cmd);
|
||||||
|
|
||||||
return callback(null, result);
|
return callback(null, result);
|
||||||
},
|
},
|
||||||
|
@ -33,8 +33,8 @@ Swarm.prototype.deploy = function() {
|
||||||
return callback("couldn't upload, is the swarm daemon running?");
|
return callback("couldn't upload, is the swarm daemon running?");
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows = result.output.split("\n");
|
let rows = result.output.split("\n");
|
||||||
var dir_hash = rows.reverse()[1];
|
let dir_hash = rows.reverse()[1];
|
||||||
|
|
||||||
return callback(null, dir_hash);
|
return callback(null, dir_hash);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var async = require('async');
|
let async = require('async');
|
||||||
|
|
||||||
function asyncEachObject(object, iterator, callback) {
|
function asyncEachObject(object, iterator, callback) {
|
||||||
async.each(
|
async.each(
|
||||||
|
|
|
@ -6,8 +6,8 @@ function extend(filename, async) {
|
||||||
}
|
}
|
||||||
async._waterfall = async.waterfall;
|
async._waterfall = async.waterfall;
|
||||||
async.waterfall = function(_tasks, callback) {
|
async.waterfall = function(_tasks, callback) {
|
||||||
var tasks = _tasks.map(function(t) {
|
let tasks = _tasks.map(function(t) {
|
||||||
var fn = function() {
|
let fn = function() {
|
||||||
console.log("async " + filename + ": " + t.name);
|
console.log("async " + filename + ": " + t.name);
|
||||||
t.apply(t, arguments);
|
t.apply(t, arguments);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue