mirror of https://github.com/embarklabs/embark.git
Merge branch 'develop'
This commit is contained in:
commit
3ba8c55284
|
@ -0,0 +1,19 @@
|
|||
engines:
|
||||
eslint:
|
||||
enabled: true
|
||||
checks:
|
||||
no-eval:
|
||||
enabled: false
|
||||
no-process-exit:
|
||||
enabled: false
|
||||
global-require:
|
||||
enabled: false
|
||||
ratings:
|
||||
paths:
|
||||
- "lib/**/*"
|
||||
exclude_paths:
|
||||
- "tests/"
|
||||
- "old_test/"
|
||||
- "boilerplate/"
|
||||
- "demo/"
|
||||
- "js/"
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"reporter": [
|
||||
"lcov",
|
||||
"text-summary"
|
||||
],
|
||||
"include": [
|
||||
"lib/**/*.js"
|
||||
]
|
||||
}
|
|
@ -3,3 +3,6 @@ node_js:
|
|||
- "6"
|
||||
- "5"
|
||||
- "4"
|
||||
addons:
|
||||
code_climate:
|
||||
repo_token: 7454b1a666015e244c384d19f48c34e35d1ae58c3aa428ec542f10bbcb848358
|
||||
|
|
14
README.md
14
README.md
|
@ -2,6 +2,7 @@
|
|||
[![Join the chat at https://gitter.im/iurimatias/embark-framework](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iurimatias/embark-framework?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[![Build
|
||||
Status](https://travis-ci.org/iurimatias/embark-framework.svg?branch=develop)](https://travis-ci.org/iurimatias/embark-framework)
|
||||
[![Code Climate](https://codeclimate.com/github/iurimatias/embark-framework/badges/gpa.svg)](https://codeclimate.com/github/iurimatias/embark-framework)
|
||||
|
||||
What is Embark
|
||||
======
|
||||
|
@ -23,6 +24,7 @@ Table of Contents
|
|||
* [Usage Demo](#usage---demo)
|
||||
* [Dashboard](#dashboard)
|
||||
* [Creating a new DApp](#creating-a-new-dapp)
|
||||
* [Libraries and APIs available](#libraries-and-languages-available)
|
||||
* [Using and Configuring Contracts](#dapp-structure)
|
||||
* [EmbarkJS](#embarkjs)
|
||||
* [EmbarkJS - Storage (IPFS)](#embarkjs---storage)
|
||||
|
@ -75,7 +77,7 @@ Alternatively, to use an ethereum rpc simulator simply run:
|
|||
$ embark simulator
|
||||
```
|
||||
|
||||
By default embark blockchain will mine a minimum amount of ether and will only mine when new transactions come in. This is quite usefull to keep a low CPU. The option can be configured at config/blockchain.json
|
||||
By default embark blockchain will mine a minimum amount of ether and will only mine when new transactions come in. This is quite usefull to keep a low CPU. The option can be configured at ```config/blockchain.json```. Note that running a real node requires at least 2GB of free ram, please take this into account if running it in a VM.
|
||||
|
||||
Then, in another command line:
|
||||
|
||||
|
@ -131,6 +133,16 @@ DApp Structure
|
|||
|
||||
Solidity/Serpent files in the contracts directory will automatically be deployed with embark run. Changes in any files will automatically be reflected in app, changes to contracts will result in a redeployment and update of their JS Bindings
|
||||
|
||||
Libraries and languages available
|
||||
======
|
||||
|
||||
Embark can build and deploy contracts coded in Solidity or Serpent. It will make them available on the client side using EmbarkJS and Web3.js.
|
||||
|
||||
Further documentation for these can be found below:
|
||||
|
||||
* Smart Contracts: [Solidity](https://solidity.readthedocs.io/en/develop/) and [Serpent](https://github.com/ethereum/wiki/wiki/Serpent)
|
||||
* Client Side: [Web3.js](https://github.com/ethereum/wiki/wiki/JavaScript-API) and [EmbarkJS](#embarkjs)
|
||||
|
||||
Using Contracts
|
||||
======
|
||||
Embark will automatically take care of deployment for you and set all needed JS bindings. For example, the contract below:
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"license": "ISC",
|
||||
"homepage": "",
|
||||
"devDependencies": {
|
||||
"embark": "^2.0.1",
|
||||
"embark": "^2.1.2",
|
||||
"mocha": "^2.2.5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"license": "ISC",
|
||||
"homepage": "",
|
||||
"devDependencies": {
|
||||
"embark": "^2.0.1",
|
||||
"embark": "^2.1.2",
|
||||
"mocha": "^2.2.5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ var EmbarkJS =
|
|||
var self = this;
|
||||
var contractParams;
|
||||
|
||||
contractParams = args;
|
||||
contractParams = args || [];
|
||||
|
||||
contractParams.push({
|
||||
from: this.web3.eth.accounts[0],
|
||||
|
@ -5907,83 +5907,14 @@ var EmbarkJS =
|
|||
/***/ function(module, exports) {
|
||||
|
||||
// shim for using process in browser
|
||||
|
||||
var process = module.exports = {};
|
||||
|
||||
// cached from whatever global is present so that test runners that stub it
|
||||
// don't break things. But we need to wrap it in a try catch in case it is
|
||||
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
||||
// function because try/catches deoptimize in certain engines.
|
||||
|
||||
var cachedSetTimeout;
|
||||
var cachedClearTimeout;
|
||||
|
||||
(function () {
|
||||
try {
|
||||
cachedSetTimeout = setTimeout;
|
||||
} catch (e) {
|
||||
cachedSetTimeout = function () {
|
||||
throw new Error('setTimeout is not defined');
|
||||
}
|
||||
}
|
||||
try {
|
||||
cachedClearTimeout = clearTimeout;
|
||||
} catch (e) {
|
||||
cachedClearTimeout = function () {
|
||||
throw new Error('clearTimeout is not defined');
|
||||
}
|
||||
}
|
||||
} ())
|
||||
function runTimeout(fun) {
|
||||
if (cachedSetTimeout === setTimeout) {
|
||||
//normal enviroments in sane situations
|
||||
return setTimeout(fun, 0);
|
||||
}
|
||||
try {
|
||||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||
return cachedSetTimeout(fun, 0);
|
||||
} catch(e){
|
||||
try {
|
||||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||
return cachedSetTimeout.call(null, fun, 0);
|
||||
} catch(e){
|
||||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
||||
return cachedSetTimeout.call(this, fun, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function runClearTimeout(marker) {
|
||||
if (cachedClearTimeout === clearTimeout) {
|
||||
//normal enviroments in sane situations
|
||||
return clearTimeout(marker);
|
||||
}
|
||||
try {
|
||||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||
return cachedClearTimeout(marker);
|
||||
} catch (e){
|
||||
try {
|
||||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||
return cachedClearTimeout.call(null, marker);
|
||||
} catch (e){
|
||||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
||||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
||||
return cachedClearTimeout.call(this, marker);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
var queue = [];
|
||||
var draining = false;
|
||||
var currentQueue;
|
||||
var queueIndex = -1;
|
||||
|
||||
function cleanUpNextTick() {
|
||||
if (!draining || !currentQueue) {
|
||||
return;
|
||||
}
|
||||
draining = false;
|
||||
if (currentQueue.length) {
|
||||
queue = currentQueue.concat(queue);
|
||||
|
@ -5999,7 +5930,7 @@ var EmbarkJS =
|
|||
if (draining) {
|
||||
return;
|
||||
}
|
||||
var timeout = runTimeout(cleanUpNextTick);
|
||||
var timeout = setTimeout(cleanUpNextTick);
|
||||
draining = true;
|
||||
|
||||
var len = queue.length;
|
||||
|
@ -6016,7 +5947,7 @@ var EmbarkJS =
|
|||
}
|
||||
currentQueue = null;
|
||||
draining = false;
|
||||
runClearTimeout(timeout);
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
process.nextTick = function (fun) {
|
||||
|
@ -6028,7 +5959,7 @@ var EmbarkJS =
|
|||
}
|
||||
queue.push(new Item(fun, args));
|
||||
if (queue.length === 1 && !draining) {
|
||||
runTimeout(drainQueue);
|
||||
setTimeout(drainQueue, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ EmbarkJS.Contract.prototype.deploy = function(args) {
|
|||
var self = this;
|
||||
var contractParams;
|
||||
|
||||
contractParams = args;
|
||||
contractParams = args || [];
|
||||
|
||||
contractParams.push({
|
||||
from: this.web3.eth.accounts[0],
|
||||
|
|
|
@ -3,7 +3,7 @@ var colors = require('colors');
|
|||
|
||||
var Cmd = function(Embark) {
|
||||
this.Embark = Embark;
|
||||
program.version('2.0.1');
|
||||
program.version('2.1.2');
|
||||
};
|
||||
|
||||
Cmd.prototype.process = function(args) {
|
||||
|
@ -62,12 +62,13 @@ Cmd.prototype.run = function() {
|
|||
var self = this;
|
||||
program
|
||||
.command('run [environment]')
|
||||
.option('-p, --port [port]', 'port to run the dev webserver')
|
||||
.description('run dapp (default: development)')
|
||||
.action(function(env, options) {
|
||||
self.Embark.initConfig(env || 'development', {
|
||||
embarkConfig: 'embark.json'
|
||||
});
|
||||
self.Embark.run(env || 'development');
|
||||
self.Embark.run({env: env || 'development', serverPort: options.port});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ ContractsManager.prototype.build = function() {
|
|||
};
|
||||
|
||||
ContractsManager.prototype.getContract = function(className) {
|
||||
return this.compiledContracts[className];
|
||||
return this.contracts[className];
|
||||
};
|
||||
|
||||
ContractsManager.prototype.sortContracts = function(contractList) {
|
||||
|
|
127
lib/index.js
127
lib/index.js
|
@ -53,41 +53,15 @@ var Embark = {
|
|||
self.config.reloadConfig();
|
||||
callback();
|
||||
},
|
||||
function deployAndBuildContractsManager(callback) {
|
||||
Embark.monitor.setStatus("Redeploying changed Contracts");
|
||||
Embark.buildAndDeploy(function(contractsManager) {
|
||||
callback(null, contractsManager);
|
||||
});
|
||||
},
|
||||
function generateConsoleABI(contractsManager, callback) {
|
||||
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
|
||||
var consoleABI = abiGenerator.generateABI({useEmbarkJS: false});
|
||||
Embark.console.runCode(consoleABI);
|
||||
callback(null, contractsManager);
|
||||
},
|
||||
function generateABI(contractsManager, callback) {
|
||||
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
|
||||
callback(null, abiGenerator.generateABI({useEmbarkJS: true}));
|
||||
},
|
||||
function buildPipeline(abi, callback) {
|
||||
Embark.monitor.setStatus("Building Assets");
|
||||
var pipeline = new Pipeline({
|
||||
buildDir: self.config.buildDir,
|
||||
contractsFiles: self.config.contractsFiles,
|
||||
assetFiles: self.config.assetFiles,
|
||||
logger: self.logger
|
||||
});
|
||||
pipeline.build(abi);
|
||||
callback();
|
||||
}
|
||||
self.buildDeployGenerate.bind(self)
|
||||
], function(err, result) {
|
||||
Embark.monitor.setStatus("Ready");
|
||||
self.logger.trace("finished".underline);
|
||||
});
|
||||
},
|
||||
|
||||
run: function(env) {
|
||||
run: function(options) {
|
||||
var self = this;
|
||||
var env = options.env;
|
||||
async.waterfall([
|
||||
function startConsole(callback) {
|
||||
Embark.console = new Console();
|
||||
|
@ -105,41 +79,16 @@ var Embark = {
|
|||
function monitorServices(callback) {
|
||||
Embark.servicesMonitor = new ServicesMonitor({
|
||||
logger: Embark.logger,
|
||||
config: Embark.config
|
||||
config: Embark.config,
|
||||
serverPort: options.serverPort
|
||||
});
|
||||
Embark.servicesMonitor.startMonitor();
|
||||
callback();
|
||||
},
|
||||
function deployAndBuildContractsManager(callback) {
|
||||
Embark.monitor.setStatus("Deploying Contracts");
|
||||
Embark.buildAndDeploy(function(contractsManager) {
|
||||
callback(null, contractsManager);
|
||||
});
|
||||
},
|
||||
function generateConsoleABI(contractsManager, callback) {
|
||||
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
|
||||
var consoleABI = abiGenerator.generateABI({useEmbarkJS: false});
|
||||
Embark.console.runCode(consoleABI);
|
||||
callback(null, contractsManager);
|
||||
},
|
||||
function generateABI(contractsManager, callback) {
|
||||
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
|
||||
callback(null, abiGenerator.generateABI({useEmbarkJS: true}));
|
||||
},
|
||||
function buildPipeline(abi, callback) {
|
||||
Embark.monitor.setStatus("Building Assets");
|
||||
var pipeline = new Pipeline({
|
||||
buildDir: self.config.buildDir,
|
||||
contractsFiles: self.config.contractsFiles,
|
||||
assetFiles: self.config.assetFiles,
|
||||
logger: self.logger
|
||||
});
|
||||
pipeline.build(abi);
|
||||
callback();
|
||||
},
|
||||
self.buildDeployGenerate.bind(self),
|
||||
function startAssetServer(callback) {
|
||||
Embark.monitor.setStatus("Starting Server");
|
||||
var server = new Server({logger: self.logger});
|
||||
var server = new Server({logger: self.logger, port: options.serverPort});
|
||||
server.start(callback);
|
||||
},
|
||||
function watchFilesForChanges(callback) {
|
||||
|
@ -158,7 +107,7 @@ var Embark = {
|
|||
callback();
|
||||
}
|
||||
], function(err, result) {
|
||||
Embark.monitor.setStatus("Ready");
|
||||
Embark.monitor.setStatus("Ready".green);
|
||||
self.logger.trace("finished".underline);
|
||||
});
|
||||
},
|
||||
|
@ -194,8 +143,12 @@ var Embark = {
|
|||
contractsConfig: self.config.contractsConfig,
|
||||
logger: Embark.logger
|
||||
});
|
||||
try {
|
||||
contractsManager.build();
|
||||
callback(null, contractsManager);
|
||||
} catch(err) {
|
||||
callback(new Error(err.message));
|
||||
}
|
||||
},
|
||||
function deployContracts(contractsManager, callback) {
|
||||
|
||||
|
@ -229,7 +182,11 @@ var Embark = {
|
|||
|
||||
}
|
||||
], function(err, result) {
|
||||
done(result);
|
||||
if (err) {
|
||||
done(err, null);
|
||||
} else {
|
||||
done(null, result);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -244,12 +201,60 @@ var Embark = {
|
|||
function generateABI(contractsManager, callback) {
|
||||
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
|
||||
callback(null, abiGenerator.generateABI({useEmbarkJS: true}));
|
||||
},
|
||||
}
|
||||
], function(err, result) {
|
||||
done(result);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
buildDeployGenerate: function(done) {
|
||||
var self = this;
|
||||
|
||||
Embark.monitor.setStatus("Deploying...".magenta.underline);
|
||||
async.waterfall([
|
||||
function deployAndBuildContractsManager(callback) {
|
||||
Embark.buildAndDeploy(function(err, contractsManager) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
callback(null, contractsManager);
|
||||
}
|
||||
});
|
||||
},
|
||||
function generateConsoleABI(contractsManager, callback) {
|
||||
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
|
||||
var consoleABI = abiGenerator.generateABI({useEmbarkJS: false});
|
||||
Embark.console.runCode(consoleABI);
|
||||
callback(null, contractsManager);
|
||||
},
|
||||
function generateABI(contractsManager, callback) {
|
||||
var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager);
|
||||
callback(null, abiGenerator.generateABI({useEmbarkJS: true}));
|
||||
},
|
||||
function buildPipeline(abi, callback) {
|
||||
Embark.monitor.setStatus("Building Assets");
|
||||
var pipeline = new Pipeline({
|
||||
buildDir: self.config.buildDir,
|
||||
contractsFiles: self.config.contractsFiles,
|
||||
assetFiles: self.config.assetFiles,
|
||||
logger: self.logger
|
||||
});
|
||||
pipeline.build(abi);
|
||||
callback();
|
||||
}
|
||||
], function(err, result) {
|
||||
if (err) {
|
||||
self.logger.error("error deploying");
|
||||
self.logger.error(err.message);
|
||||
Embark.monitor.setStatus("Deployment Error".red);
|
||||
} else {
|
||||
Embark.monitor.setStatus("Ready".green);
|
||||
}
|
||||
done(result);
|
||||
});
|
||||
},
|
||||
|
||||
initTests: function(options) {
|
||||
return new Test(options);
|
||||
},
|
||||
|
|
|
@ -101,14 +101,14 @@ Dashboard.prototype.layoutLog = function() {
|
|||
left: "0%",
|
||||
top: "42%",
|
||||
border: {
|
||||
type: "line",
|
||||
type: "line"
|
||||
},
|
||||
style: {
|
||||
fg: -1,
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
},
|
||||
fg: this.color
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.logText = blessed.log({
|
||||
|
@ -141,14 +141,14 @@ Dashboard.prototype.layoutModules = function() {
|
|||
left: "0%",
|
||||
top: "0",
|
||||
border: {
|
||||
type: "line",
|
||||
type: "line"
|
||||
},
|
||||
style: {
|
||||
fg: -1,
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
},
|
||||
fg: this.color
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.moduleTable = blessed.table({
|
||||
|
@ -184,14 +184,14 @@ Dashboard.prototype.layoutAssets = function() {
|
|||
left: "50%",
|
||||
top: "42%",
|
||||
border: {
|
||||
type: "line",
|
||||
type: "line"
|
||||
},
|
||||
style: {
|
||||
fg: -1,
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
},
|
||||
fg: this.color
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.assetTable = blessed.table({
|
||||
|
@ -230,20 +230,20 @@ Dashboard.prototype.layoutStatus = function() {
|
|||
label: "Environment",
|
||||
tags: true,
|
||||
padding: {
|
||||
left: 1,
|
||||
left: 1
|
||||
},
|
||||
width: "100%",
|
||||
height: "20%",
|
||||
valign: "middle",
|
||||
border: {
|
||||
type: "line",
|
||||
type: "line"
|
||||
},
|
||||
style: {
|
||||
fg: -1,
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
},
|
||||
fg: this.color
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.operations = blessed.box({
|
||||
|
@ -251,20 +251,20 @@ Dashboard.prototype.layoutStatus = function() {
|
|||
label: "Status",
|
||||
tags: true,
|
||||
padding: {
|
||||
left: 1,
|
||||
left: 1
|
||||
},
|
||||
width: "100%",
|
||||
height: "20%",
|
||||
valign: "middle",
|
||||
border: {
|
||||
type: "line",
|
||||
type: "line"
|
||||
},
|
||||
style: {
|
||||
fg: -1,
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
},
|
||||
fg: this.color
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.progress = blessed.box({
|
||||
|
@ -283,9 +283,9 @@ Dashboard.prototype.layoutStatus = function() {
|
|||
style: {
|
||||
fg: -1,
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
},
|
||||
fg: this.color
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.screen.append(this.wrapper);
|
||||
|
@ -302,14 +302,14 @@ Dashboard.prototype.layoutCmd = function() {
|
|||
left: '0%',
|
||||
top: '95%',
|
||||
border: {
|
||||
type: 'line',
|
||||
type: 'line'
|
||||
},
|
||||
style: {
|
||||
fg: 'black',
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
},
|
||||
fg: this.color
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.input = blessed.textbox({
|
||||
|
|
|
@ -6,6 +6,7 @@ var ServicesMonitor = function(options) {
|
|||
this.logger = options.logger;
|
||||
this.interval = options.interval || 5000;
|
||||
this.config = options.config;
|
||||
this.serverPort = options.serverPort || 8000;
|
||||
};
|
||||
|
||||
ServicesMonitor.prototype.startMonitor = function() {
|
||||
|
@ -27,7 +28,7 @@ ServicesMonitor.prototype.check = function() {
|
|||
},
|
||||
function addEmbarkVersion(web3, result, callback) {
|
||||
self.logger.trace('addEmbarkVersion');
|
||||
result.push('Embark 2.1.0'.green);
|
||||
result.push('Embark 2.1.2'.green);
|
||||
callback(null, web3, result);
|
||||
},
|
||||
function checkEthereum(web3, result, callback) {
|
||||
|
@ -63,7 +64,7 @@ ServicesMonitor.prototype.check = function() {
|
|||
},
|
||||
function checkDevServer(result, callback) {
|
||||
self.logger.trace('checkDevServer');
|
||||
result.push('dev server (http://localhost:8000)'.green);
|
||||
result.push(('dev server (http://localhost:' + self.serverPort + ')').green);
|
||||
callback(null, result);
|
||||
}
|
||||
], function(err, result) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "embark",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.2",
|
||||
"description": "Embark is a framework that allows you to easily develop and deploy DApps",
|
||||
"scripts": {
|
||||
"test": "grunt jshint && mocha test/ --no-timeouts"
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue