Merge branch 'develop' of https://github.com/embark-framework/embark into develop

This commit is contained in:
Santiago Gonzalez Toral 2018-09-11 12:32:07 -05:00
commit 8a43b0789e
27 changed files with 2337 additions and 1988 deletions

View File

@ -4,11 +4,32 @@ try {
eval('let __nodeTest = 123;');
} catch(e) {
if (e.name === 'SyntaxError') {
console.error("unsupported version of NodeJS. Make sure you are running nodejs 6.9.5 or above");
console.error("unsupported version of NodeJS. Make sure you are running nodejs 8.11.3 or above");
process.exit();
}
}
var Cmd = require('../cmd/cmd');
var cli = new Cmd();
cli.process(process.argv);
function launchEmbark() {
var Cmd = require('../cmd/cmd');
var cli = new Cmd();
cli.process(process.argv);
}
const path = require('path');
try {
const dappPackage = require(path.join(process.cwd(), 'package.json'));
require(path.join(process.cwd(), 'embark.json')); // Make sure we are in a Dapp
require('check-dependencies')(dappPackage, (state) => {
if (state.status) {
require('colors');
console.error('\nMissing dependencies. Please run npm install'.red);
process.exit();
}
launchEmbark();
});
} catch (_e) {
// We are not in a Dapp
launchEmbark();
}

View File

@ -26,9 +26,9 @@ if (!process.env.EMBARK_PATH) {
// as an ejected webpack.config.js), making embark's dependencies trasitive
// dependencies of a dapp without the dapp explicitly specifying embark as a
// dependency in the dapp's package.json
process.env.NODE_PATH = utils.joinPath(process.env.EMBARK_PATH, 'node_modules')
+ (process.env.NODE_PATH ? require('path').delimiter : '')
+ (process.env.NODE_PATH || '');
process.env.NODE_PATH = utils.joinPath(process.env.EMBARK_PATH, 'node_modules') +
(process.env.NODE_PATH ? require('path').delimiter : '') +
(process.env.NODE_PATH || '');
class Cmd {
constructor() {
@ -62,7 +62,7 @@ class Cmd {
newApp() {
let validateName = function (value) {
let validateName = function(value) {
try {
if (value.match(/^[a-zA-Z\s-]+$/)) return value;
} catch (e) {
@ -76,14 +76,14 @@ class Cmd {
.option('--simple', __('create a barebones project meant only for contract development'))
.option('--locale [locale]', __('language to use (default: en)'))
.option('--template [url]', __('download template'))
.action(function (name, options) {
.action(function(name, options) {
i18n.setOrDetectLocale(options.locale);
if (name === undefined) {
const promptly = require('promptly');
return promptly.prompt(__("Name your app (default is %s):", 'embarkDapp'), {
default: "embarkDApp",
validator: validateName
}, function (err, inputvalue) {
}, function(err, inputvalue) {
if (err) {
console.error(__('Invalid name') + ':', err.message);
// Manually call retry
@ -98,12 +98,11 @@ class Cmd {
}
}
});
}
if (options.simple) {
embark.generateTemplate('simple', './', name);
} else {
if (options.simple) {
embark.generateTemplate('simple', './', name);
} else {
embark.generateTemplate('boilerplate', './', name, options.template);
}
embark.generateTemplate('boilerplate', './', name, options.template);
}
});
}
@ -113,7 +112,7 @@ class Cmd {
.command('demo')
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('create a working dapp with a SimpleStorage contract'))
.action(function (options) {
.action(function(options) {
i18n.setOrDetectLocale(options.locale);
embark.generateTemplate('demo', './', 'embark_demo');
});
@ -124,12 +123,12 @@ class Cmd {
.command('build [environment]')
.option('--contracts', 'only compile contracts into Embark wrappers')
.option('--logfile [logfile]', __('filename to output logs (default: none)'))
.option('-c, --client [client]', __('Use a specific ethereum client or simulator (supported: %s)', 'geth, testrpc'))
.option('-c, --client [client]', __('Use a specific ethereum client (supported: %s)', 'geth'))
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'debug')
.option('--locale [locale]', __('language to use (default: en)'))
.option('--pipeline [pipeline]', __('webpack config to use (default: production)'))
.description(__('deploy and build dapp at ') + 'dist/ (default: development)')
.action(function (env, _options) {
.action(function(env, _options) {
i18n.setOrDetectLocale(_options.locale);
_options.env = env || 'development';
_options.logFile = _options.logfile; // fix casing
@ -145,7 +144,7 @@ class Cmd {
program
.command('run [environment]')
.option('-p, --port [port]', __('port to run the dev webserver (default: %s)', '8000'))
.option('-c, --client [client]', __('Use a specific ethereum client or simulator (supported: %s)', 'geth, testrpc'))
.option('-c, --client [client]', __('Use a specific ethereum client (supported: %s)', 'geth'))
.option('-b, --host [host]', __('host to run the dev webserver (default: %s)', 'localhost'))
.option('--noserver', __('disable the development webserver'))
.option('--nodashboard', __('simple mode, disables the dashboard'))
@ -155,7 +154,7 @@ class Cmd {
.option('--locale [locale]', __('language to use (default: en)'))
.option('--pipeline [pipeline]', __('webpack config to use (default: development)'))
.description(__('run dapp (default: %s)', 'development'))
.action(function (env, options) {
.action(function(env, options) {
i18n.setOrDetectLocale(options.locale);
embark.run({
env: env || 'development',
@ -175,13 +174,13 @@ class Cmd {
console() {
program
.command('console [environment]')
.option('-c, --client [client]', __('Use a specific ethereum client or simulator (supported: %s)', 'geth, testrpc'))
.option('-c, --client [client]', __('Use a specific ethereum client (supported: %s)', 'geth'))
.option('--logfile [logfile]', __('filename to output logs (default: %s)', 'none'))
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'debug')
.option('--locale [locale]', __('language to use (default: en)'))
.option('--pipeline [pipeline]', __('webpack config to use (default: development)'))
.description(__('Start the Embark console'))
.action(function (env, options) {
.action(function(env, options) {
i18n.setOrDetectLocale(options.locale);
embark.console({
env: env || 'development',
@ -197,10 +196,10 @@ class Cmd {
blockchain() {
program
.command('blockchain [environment]')
.option('-c, --client [client]', __('Use a specific ethereum client or simulator (supported: %s)', 'geth, testrpc'))
.option('-c, --client [client]', __('Use a specific ethereum client (supported: %s)', 'geth'))
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('run blockchain server (default: %s)', 'development'))
.action(function (env, options) {
.action(function(env, options) {
i18n.setOrDetectLocale(options.locale);
embark.initConfig(env || 'development', {
embarkConfig: 'embark.json',
@ -222,7 +221,7 @@ class Cmd {
.option('-l, --gasLimit [gasLimit]', __('custom gas limit (default: %s)', '8000000'))
.option('--locale [locale]', __('language to use (default: en)'))
.action(function (env, options) {
.action(function(env, options) {
i18n.setOrDetectLocale(options.locale);
embark.initConfig(env || 'development', {
embarkConfig: 'embark.json',
@ -246,7 +245,7 @@ class Cmd {
.option('--locale [locale]', __('language to use (default: en)'))
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'warn')
.description(__('run tests'))
.action(function (file, options) {
.action(function(file, options) {
i18n.setOrDetectLocale(options.locale);
embark.runTests({file, loglevel: options.loglevel, gasDetails: options.gasDetails, node: options.node});
});
@ -259,10 +258,10 @@ class Cmd {
.option('--logfile [logfile]', __('filename to output logs (default: %s)', 'none'))
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'debug')
.option('--locale [locale]', __('language to use (default: en)'))
.option('-c, --client [client]', __('Use a specific ethereum client or simulator (supported: %s)', 'geth, testrpc'))
.option('-c, --client [client]', __('Use a specific ethereum client (supported: %s)', 'geth'))
.option('--pipeline [pipeline]', __('webpack config to use (default: production)'))
.description(__('Upload your dapp to a decentralized storage') + '.')
.action(function (env, _options) {
.action(function(env, _options) {
i18n.setOrDetectLocale(_options.locale);
if (env === "ipfs" || env === "swarm") {
console.warn(("did you mean " + "embark upload".bold + " ?").underline);
@ -286,7 +285,7 @@ class Cmd {
.option('--skip-events', __('Graph will not include events'))
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('generates documentation based on the smart contracts configured'))
.action(function (env, options) {
.action(function(env, options) {
i18n.setOrDetectLocale(options.locale);
embark.graph({
env: env || 'development',
@ -303,7 +302,7 @@ class Cmd {
.command('reset')
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('resets embarks state on this dapp including clearing cache'))
.action(function (options) {
.action(function(options) {
i18n.setOrDetectLocale(options.locale);
embark.initConfig('development', {
embarkConfig: 'embark.json', interceptLogs: false
@ -316,38 +315,38 @@ class Cmd {
program
.command('eject-webpack')
.description(__('copy the default webpack config into your dapp for customization'))
.action(function () {
.action(function() {
embark.ejectWebpack();
});
}
versionCmd() {
program
.command('version')
.description(__('output the version number'))
.action(function () {
console.log(embark.version);
process.exit(0);
});
.command('version')
.description(__('output the version number'))
.action(function() {
console.log(embark.version);
process.exit(0);
});
}
helpCmd() {
program
.command('help')
.description(__('output usage information and help information'))
.action(function () {
console.log("Documentation can be found at: ".green + "https://embark.status.im/docs/".underline.green);
console.log("");
console.log("Have an issue? submit it here: ".green + "https://github.com/embark-framework/embark/issues/new".underline.green);
console.log("or chat with us directly at: ".green + "https://gitter.im/embark-framework/Lobby".underline.green);
program.help();
process.exit(0);
});
.command('help')
.description(__('output usage information and help information'))
.action(function() {
console.log("Documentation can be found at: ".green + "https://embark.status.im/docs/".underline.green);
console.log("");
console.log("Have an issue? submit it here: ".green + "https://github.com/embark-framework/embark/issues/new".underline.green);
console.log("or chat with us directly at: ".green + "https://gitter.im/embark-framework/Lobby".underline.green);
program.help();
process.exit(0);
});
}
otherCommands() {
program
.action(function (cmd) {
.action(function(cmd) {
console.log((__('unknown command') + ' "%s"').red, cmd);
let utils = require('../lib/utils/utils.js');
let dictionary = ['new', 'demo', 'build', 'run', 'blockchain', 'simulator', 'test', 'upload', 'version'];

View File

@ -79,18 +79,20 @@ class EmbarkController {
context: self.context,
useDashboard: options.useDashboard,
webServerConfig: webServerConfig,
webpackConfigName: options.webpackConfigName,
ipcRole: 'server'
webpackConfigName: options.webpackConfigName
});
engine.init();
if (!options.useDashboard) {
engine.logger.info('========================'.bold.green);
engine.logger.info((__('Welcome to Embark') + ' ' + this.version).yellow.bold);
engine.logger.info('========================'.bold.green);
}
async.parallel([
async.waterfall([
function initEngine(callback) {
engine.init({}, () => {
if (!options.useDashboard) {
engine.logger.info('========================'.bold.green);
engine.logger.info((__('Welcome to Embark') + ' ' + engine.version).yellow.bold);
engine.logger.info('========================'.bold.green);
}
callback();
});
},
function startDashboard(callback) {
if (!options.useDashboard) {
return callback();
@ -182,9 +184,12 @@ class EmbarkController {
context: this.context,
webpackConfigName: options.webpackConfigName
});
engine.init();
async.waterfall([
function initEngine(callback) {
engine.init({}, callback);
},
function startServices(callback) {
let pluginList = engine.plugins.listPlugins();
if (pluginList.length > 0) {
@ -250,8 +255,11 @@ class EmbarkController {
context: this.context,
webpackConfigName: options.webpackConfigName
});
engine.init();
async.waterfall([
function initEngine(callback) {
engine.init({}, callback);
},
function startServices(callback) {
let pluginList = engine.plugins.listPlugins();
if (pluginList.length > 0) {
@ -350,9 +358,12 @@ class EmbarkController {
logFile: options.logFile,
context: this.context
});
engine.init();
async.waterfall([
function (callback) {
engine.init({}, callback);
},
function (callback) {
let pluginList = engine.plugins.listPlugins();
if (pluginList.length > 0) {
@ -436,12 +447,22 @@ class EmbarkController {
context: this.context,
webpackConfigName: options.webpackConfigName
});
engine.init();
let platform = engine.config.storageConfig.upload.provider;
let platform;
async.waterfall([
function initEngine(callback) {
engine.init({}, () => {
if (engine.config.embarkConfig.config.storage === false || engine.config.storageConfig.enabled === false) {
engine.logger.error(__('Storage configuration is disabled in embark.json. Please provide a storage file before uploading'));
engine.logger.info(__('You can find an example here: %s', 'https://github.com/embark-framework/embark/blob/master/templates/demo/config/storage.js'.underline));
process.exit(1);
}
platform = engine.config.storageConfig.upload.provider;
callback();
});
},
function startServices(callback) {
engine.startService("processManager");
@ -499,7 +520,7 @@ class EmbarkController {
engine.logger.error(err.message);
return engine.logger.debug(err.stack);
}
engine.locale.error(err);
engine.logger.error(err);
} else {
engine.logger.info((__("finished building DApp and deploying to") + " " + platform).underline);
}

View File

@ -183,10 +183,11 @@ Config.prototype.loadBlockchainConfigFile = function() {
if (!configFilePath) {
this.blockchainConfig.default = true;
}
if(!this.blockchainConfig.account && !this.blockchainConfig.isDev) {
if (!this.blockchainConfig.account && !this.blockchainConfig.isDev &&
this.env !== 'development' && this.env !== 'test') {
this.logger.warn(
__('Account settings are needed for this chain.' +
' Please put a valid address and possibly a password in your blockchain config or use a dev chain.')
' Please put a valid address and possibly a password in your blockchain config or use a dev chain.')
);
}
};
@ -322,8 +323,12 @@ Config.prototype.loadWebServerConfigFile = function() {
let webServerConfig = this._mergeConfig(configFilePath, configObject, false);
if (configFilePath === false) {
this.webServerConfig = {enabled: false};
return;
}
if (this.webServerConfig) {
// cli falgs to `embark run` should override configFile and defaults (configObject)
// cli flags to `embark run` should override configFile and defaults (configObject)
this.webServerConfig = utils.recursiveMerge(webServerConfig, this.webServerConfig);
} else {
this.webServerConfig = webServerConfig;

View File

@ -17,11 +17,11 @@ class Engine {
this.context = options.context;
this.useDashboard = options.useDashboard;
this.webServerConfig = options.webServerConfig;
this.ipcRole = options.ipcRole;
this.webpackConfigName = options.webpackConfigName;
}
init(_options) {
init(_options, callback) {
callback = callback || function() {};
const Events = require('./events.js');
const Logger = require('./logger.js');
const Config = require('./config.js');
@ -38,22 +38,13 @@ class Engine {
utils.interceptLogs(console, this.logger);
}
if (this.ipcRole) {
this.ipc = new IPC({logger: this.logger, ipcRole: this.ipcRole});
if(this.ipc.isServer()) {
this.ipc.serve();
}
return;
}
this.ipc = new IPC({logger: this.logger, ipcRole: 'client'});
this.ipc.connect((err) => {
if(err) {
this.ipc = new IPC({logger: this.logger, ipcRole: 'server'});
this.ipc.serve();
}
callback();
});
}

View File

@ -6,7 +6,7 @@ class IPC {
constructor(options) {
this.logger = options.logger;
this.socketPath = options.socketPath || fs.dappPath(".embark/embark.ipc");
this.ipcRole = options.ipcRole || "server";
this.ipcRole = options.ipcRole;
ipc.config.silent = true;
this.connected = false;
}

View File

@ -12,13 +12,14 @@ class ProcessWrapper {
* Manages the log interception so that all console.* get sent back to the parent process
* Also creates an Events instance. To use it, just do `this.events.[on|request]`
*
* @param {Options} _options Nothing for now
* @param {Options} options pingParent: true by default
*/
constructor(_options) {
constructor(options = {pingParent: true}) {
this.interceptLogs();
this.events = new Events();
this.pingParent();
if(options.pingParent) {
this.pingParent();
}
}
// Ping parent to see if it is still alive. Otherwise, let's die

View File

@ -5,6 +5,7 @@ let proxy = require('./proxy');
const Ipc = require('../../core/ipc');
const constants = require('../../constants.json');
const {defaultHost, dockerHostSwap} = require('../../utils/host');
const fs = require('../../core/fs.js');
class Simulator {
constructor(options) {
@ -15,7 +16,7 @@ class Simulator {
run(options) {
let cmds = [];
const ganache_main = require.resolve('ganache-cli');
const ganache_main = require.resolve('ganache-cli', {paths: fs.embarkPath('node_modules')});
const ganache_json = pkgUp.sync(path.dirname(ganache_main));
const ganache_root = path.dirname(ganache_json);
const ganache_bin = require(ganache_json).bin;

View File

@ -289,7 +289,7 @@ class CodeGenerator {
function getWeb3Location(next) {
self.events.request("version:get:web3", function(web3Version) {
if (web3Version === "1.0.0-beta") {
return next(null, fs.embarkPath("node_modules/web3"));
return next(null, require.resolve("web3", {paths: fs.embarkPath("node_modules")}));
}
self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) {
return next(null, fs.dappPath(location));
@ -350,7 +350,7 @@ class CodeGenerator {
function getWeb3Location(next) {
self.events.request("version:get:web3", function(web3Version) {
if (web3Version === "1.0.0-beta") {
return next(null, utils.joinPath(fs.embarkPath("node_modules/web3")));
return next(null, require.resolve("web3", {paths: fs.embarkPath("node_modules")}));
}
self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) {
return next(null, fs.dappPath(location));

View File

@ -28,7 +28,7 @@ class ENS {
}
registerEvents() {
this.embark.registerActionForEvent("contracts:deploy:afterAll", this.setProviderAndRegisterDomains.bind(this));
this.events.once("contracts:deploy:afterAll", this.setProviderAndRegisterDomains.bind(this));
this.events.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this));
}

View File

@ -10,7 +10,7 @@ const NpmTimer = require('../library_manager/npmTimer');
class SolcProcess extends ProcessWrapper {
constructor(options){
super();
super({pingParent: false});
this._logger = options.logger;
this._showSpinner = options.showSpinner === true;
}

View File

@ -32,6 +32,26 @@ class WebServer {
port: this.port
});
this.events.on('webserver:config:change', () => {
this.embark.config.webServerConfig = null;
this.embark.config.loadWebServerConfigFile();
this.webServerConfig = this.embark.config.webServerConfig;
this.host = this.webServerConfig.host;
this.port = this.webServerConfig.port;
this.server.host = this.host;
this.server.port = this.port;
this.testPort(() => {
this.server.stop((_err) => {
this.server.start((_err, message, port) => {
this.logger.info(message);
this.port = port;
this.events.request('open-browser', () => {});
});
});
});
});
this.testPort(() => {
this.listenToCommands();
this.registerConsoleCommands();

View File

@ -85,11 +85,14 @@ class Pipeline {
},
function runWebpack(next) {
self.logger.info(__(`running webpack with '${self.webpackConfigName}' config...`));
Object.keys(self.assetFiles)
.filter(key => key.match(/\.js?$/))
.forEach(key => {
self.logger.info(__("writing file") + " " + (utils.joinPath(self.buildDir, key)).bold.dim);
});
const assets = Object.keys(self.assetFiles)
.filter(key => key.match(/\.js$/));
if (!assets || !assets.length) {
return next();
}
assets.forEach(key => {
self.logger.info(__("writing file") + " " + (utils.joinPath(self.buildDir, key)).bold.dim);
});
let built = false;
const webpackProcess = new ProcessLauncher({
modulePath: utils.joinPath(__dirname, 'webpackProcess.js'),
@ -117,7 +120,7 @@ class Pipeline {
async.eachOf(
// assetFileWrite should not process .js files
Object.keys(self.assetFiles)
.filter(key => !key.match(/\.js?$/))
.filter(key => !key.match(/\.js$/))
.reduce((obj, key) => {
obj[key] = self.assetFiles[key];
return obj;

View File

@ -26,8 +26,12 @@ class Watch {
self.logger.trace('ready to watch contract changes');
});
this.watchConfigs(embarkConfig, function () {
self.logger.trace('ready to watch config changes');
this.watchContractConfig(embarkConfig, function () {
self.logger.trace('ready to watch contract config changes');
});
this.watchWebserverConfig(embarkConfig, function () {
self.logger.trace('ready to watch webserver config changes');
});
this.logger.info(__("ready to watch file changes"));
@ -96,19 +100,45 @@ class Watch {
);
}
watchConfigs(embarkConfig, callback) {
watchWebserverConfig(embarkConfig, callback) {
let self = this;
let contractsConfig;
if (typeof embarkConfig.config === 'object' || embarkConfig.config.contracts) {
contractsConfig = embarkConfig.config.contracts;
let webserverConfig;
if (typeof embarkConfig.config === 'object') {
if (!embarkConfig.config.webserver) {
return;
}
webserverConfig = embarkConfig.config.webserver;
} else {
let contractsFolder = embarkConfig.config.replace(/\\/g, '/');
if (contractsFolder.charAt(contractsFolder.length - 1) !== '/') {
contractsFolder += '/';
}
contractsConfig = [`${contractsFolder}**/contracts.json`, `${contractsFolder}**/contracts.js`];
webserverConfig = [`${contractsFolder}**/webserver.json`, `${contractsFolder}**/webserver.js`];
}
this.watchFiles(contractsConfig,
this.watchFiles(webserverConfig,
function (eventName, path) {
self.logger.info(`${eventName}: ${path}`);
self.events.emit('webserver:config:change', 'config', path);
},
function () {
callback();
}
);
}
watchContractConfig(embarkConfig, callback) {
let self = this;
let contractConfig;
if (typeof embarkConfig.config === 'object' || embarkConfig.config.contracts) {
contractConfig = embarkConfig.config.contracts;
} else {
let contractsFolder = embarkConfig.config.replace(/\\/g, '/');
if (contractsFolder.charAt(contractsFolder.length - 1) !== '/') {
contractsFolder += '/';
}
contractConfig = [`${contractsFolder}**/contracts.json`, `${contractsFolder}**/contracts.js`];
}
this.watchFiles(contractConfig,
function (eventName, path) {
self.logger.info(`${eventName}: ${path}`);
self.events.emit('file-' + eventName, 'config', path);

View File

@ -36,7 +36,7 @@ try {
}
const entry = Object.keys(embarkAssets)
.filter(key => key.match(/\.js?$/))
.filter(key => key.match(/\.js$/))
.reduce((obj, key) => {
// webpack entry paths should start with './' if they're relative to the
// webpack context; embark.json "app" keys correspond to lists of .js

View File

@ -116,48 +116,52 @@ class Test {
}
init(callback) {
let self = this;
this.engine = new Engine({
env: this.options.env || 'test',
// TODO: config will need to detect if this is a obj
embarkConfig: this.options.embarkConfig || 'embark.json',
interceptLogs: false,
ipcRole: 'client'
interceptLogs: false
});
async.waterfall([
function initEngine(cb) {
self.engine.init({
logger: new TestLogger({logLevel: self.options.loglevel})
}, cb);
},
function startServices(cb) {
self.versions_default = self.engine.config.contractsConfig.versions;
// Reset contract config to nothing to make sure we deploy only what we want
self.engine.config.contractsConfig = {
contracts: {},
versions: self.versions_default
};
this.engine.init({
logger: new TestLogger({logLevel: this.options.loglevel})
});
self.engine.startService("libraryManager");
self.engine.startService("codeRunner");
self.initDeployServices();
self.engine.startService("codeGenerator");
self.engine.startService("codeCoverage");
this.versions_default = this.engine.config.contractsConfig.versions;
// Reset contract config to nothing to make sure we deploy only what we want
this.engine.config.contractsConfig = {
contracts: {},
versions: this.versions_default
};
this.engine.startService("libraryManager");
this.engine.startService("codeRunner");
this.initDeployServices();
this.engine.startService("codeGenerator");
this.engine.startService("codeCoverage");
if (this.options.node === 'embark') {
return this.engine.ipc.connect((err) => {
if (err) {
this.engine.logger.error(err.message || err);
this.engine.logger.error("Could not connect to Embark's IPC. Is embark running?");
process.exit(1);
if (self.options.node === 'embark') {
return self.engine.ipc.connect((err) => {
if (err) {
this.engine.logger.error(err.message || err);
this.engine.logger.error("Could not connect to Embark's IPC. Is embark running?");
process.exit(1);
}
self.engine.ipc.request('blockchain:node', {}, (err, node) => {
if (err) {
return self.engine.logger.error(err.message || err);
}
self.options.node = node;
cb();
});
});
}
this.engine.ipc.request('blockchain:node', {}, (err, node) => {
if (err) {
return this.engine.logger.error(err.message || err);
}
this.options.node = node;
callback();
});
});
}
callback();
cb();
}
], callback);
}
onReady(callback) {

View File

@ -75,25 +75,66 @@ class TemplateGenerator {
console.log('\n' + __('App ready at ').green + templatePath);
}
getExternalProject(uri) {
let match = uri.match(
/\.[a-z]+\/([-a-zA-Z0-9@:%_+.~#?&\/=]+)/
);
extractGithubUrlAndFolder(uri){
/* first matching group is the url, second the repoPart and third the branch with a hash in the beginning (if existing)
e.g. (["git@github.com/status-im/dappcon-workshop-dapp#master", "status-im/dappcon-workshop-dapp", "#master" ])
should work with all formats of the following:
* git@github.com/status-im/dappcon-workshop-dapp#start-here
* git@github.com/status-im/dappcon-workshop-dapp
* http://www.github.com/status-im/dappcon-workshop-dapp
* https://www.github.com/status-im/dappcon-workshop-dapp
* github.com/status-im/dappcon-workshop-dapp#start-here
sadly it doesn't extract from http(s)://github.com/status-im/dappcon-workshop-dapp/tree/start-here
thats why we have a special case later
*/
const match = uri.match(/github\.com+\/(.+?)(#.*)?$/);
const githubPart = "https://github.com/";
let repoPart = match !== null? match[1] : null;
let branchName = match !== null? match[2] : null;
if (branchName && branchName !== '#'){
branchName = branchName.substring(1);
} else {
branchName = "master";
}
let url, folder;
if (uri.includes("/tree")){
//e.g http(s)://github.com/status-im/dappcon-workshop-dapp/tree/start-here
let repoPartAndBranch = repoPart.split("/tree/");
repoPart = repoPartAndBranch[0];
branchName = repoPartAndBranch[1];
url = "https://github.com/" + repoPart + "/archive/"+ branchName +".zip";
folder = repoPart + "/" + branchName;
} else if (repoPart !== undefined) {
url = githubPart + repoPart + "/archive/" + branchName + ".zip";
folder = repoPart + "/" + branchName;
}
if (uri.startsWith('http')) {
url = uri + "/archive/master.zip";
folder = match[1];
} else if (uri.startsWith('github')) {
url = "https://" + uri + "/archive/master.zip";
folder = match[1];
} else if (uri.split('/').length === 2) {
url = "https://github.com/" + uri + "/archive/master.zip";
folder = uri;
return {
'url': url,
'folder': folder
};
}
getExternalProject(uri) {
let url, folder;
if (uri.split('/').length === 2) {
//e.g embark-framework/embark
let repoPartAndBranch = uri.split('#');
let repoPart = repoPartAndBranch[0];
let branchName = (repoPartAndBranch.length === 2)? repoPartAndBranch[1] : "master";
url = "https://github.com/" + repoPart + "/archive/"+ branchName + ".zip";
folder = repoPart + "/" + branchName;
} else if (uri.indexOf('/') === -1) {
url = "https://github.com/embark-framework/embark-" + uri + "-template/archive/master.zip";
folder = "embark-framework/embark-" + uri + "-template";
} else {
let urlAndFolder = this.extractGithubUrlAndFolder(uri);
url = urlAndFolder.url;
folder = urlAndFolder.folder;
}
return {
@ -101,7 +142,5 @@ class TemplateGenerator {
filePath: utils.joinPath(".embark/templates/", folder, "archive.zip")
};
}
}
module.exports = TemplateGenerator;

3711
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,7 @@
"babel-loader": "8.0.0-beta.4",
"babel-plugin-module-resolver": "^3.1.1",
"bip39": "^2.5.0",
"check-dependencies": "^1.1.0",
"chokidar": "^2.0.3",
"clone-deep": "^4.0.0",
"colors": "^1.1.2",
@ -40,7 +41,7 @@
"decompress": "^4.2.0",
"deep-equal": "^1.0.1",
"ejs": "^2.5.8",
"embarkjs": "^0.4.0",
"embarkjs": "^0.4.1",
"eth-ens-namehash": "^2.0.8",
"eth-lib": "^0.2.8",
"ethereumjs-wallet": "0.6.0",

View File

@ -43,6 +43,11 @@ module.exports = {
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
dappConnection: [
"ws://localhost:8546",
"http://localhost:8545",
"$WEB3" // uses pre existing web3 object if available (e.g in Mist)
]
},
// merges with the settings in default

View File

@ -43,6 +43,11 @@ module.exports = {
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
dappConnection: [
"ws://localhost:8546",
"http://localhost:8545",
"$WEB3" // uses pre existing web3 object if available (e.g in Mist)
]
},
// merges with the settings in default

View File

@ -43,6 +43,11 @@ module.exports = {
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
dappConnection: [
"ws://localhost:8546",
"http://localhost:8545",
"$WEB3" // uses pre existing web3 object if available (e.g in Mist)
]
},
// merges with the settings in default

View File

@ -44,7 +44,6 @@ let generateApiObject = function() {
}
describe('embark.Compiler', function() {
describe('#compile_solidity', function() {
this.timeout(0);
@ -54,10 +53,10 @@ describe('embark.Compiler', function() {
let expectedObject = {};
expectedObject["SimpleStorage"] = {
"code":"608060405234801561001057600080fd5b50604051602080610114833981016040525160005560e1806100336000396000f30060806040526004361060525763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632a1afcd98114605757806360fe47b114607b5780636d4ce63c146092575b600080fd5b348015606257600080fd5b50606960a4565b60408051918252519081900360200190f35b348015608657600080fd5b50609060043560aa565b005b348015609d57600080fd5b50606960af565b60005481565b600055565b600054905600a165627a7a723058200d15419363aede339114aad0374f61d748071e4d9cd677583967b8b94eeb35ed0029",
"runtimeBytecode":"60806040526004361060525763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632a1afcd98114605757806360fe47b114607b5780636d4ce63c146092575b600080fd5b348015606257600080fd5b50606960a4565b60408051918252519081900360200190f35b348015608657600080fd5b50609060043560aa565b005b348015609d57600080fd5b50606960af565b60005481565b600055565b600054905600a165627a7a723058200d15419363aede339114aad0374f61d748071e4d9cd677583967b8b94eeb35ed0029",
"code":"608060405234801561001057600080fd5b50604051602080610114833981016040525160005560e1806100336000396000f30060806040526004361060525763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632a1afcd98114605757806360fe47b114607b5780636d4ce63c146092575b600080fd5b348015606257600080fd5b50606960a4565b60408051918252519081900360200190f35b348015608657600080fd5b50609060043560aa565b005b348015609d57600080fd5b50606960af565b60005481565b600055565b600054905600a165627a7a72305820614716494f92abbcf64973073344e48071ac9a7a9f8515b7f5226e6bbd244b730029",
"runtimeBytecode":"60806040526004361060525763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632a1afcd98114605757806360fe47b114607b5780636d4ce63c146092575b600080fd5b348015606257600080fd5b50606960a4565b60408051918252519081900360200190f35b348015608657600080fd5b50609060043560aa565b005b348015609d57600080fd5b50606960af565b60005481565b600055565b600054905600a165627a7a72305820614716494f92abbcf64973073344e48071ac9a7a9f8515b7f5226e6bbd244b730029",
"realRuntimeBytecode":"60806040526004361060525763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632a1afcd98114605757806360fe47b114607b5780636d4ce63c146092575b600080fd5b348015606257600080fd5b50606960a4565b60408051918252519081900360200190f35b348015608657600080fd5b50609060043560aa565b005b348015609d57600080fd5b50606960af565b60005481565b600055565b600054905600a165627a7a72305820",
"swarmHash":"0d15419363aede339114aad0374f61d748071e4d9cd677583967b8b94eeb35ed",
"swarmHash":"614716494f92abbcf64973073344e48071ac9a7a9f8515b7f5226e6bbd244b73",
"gasEstimates":{"creation":{"codeDepositCost":"45000","executionCost":"20141","totalCost":"65141"},"external":{"get()":"428","set(uint256)":"20161","storedData()":"384"}},
"functionHashes":{"get()":"6d4ce63c","set(uint256)":"60fe47b1","storedData()":"2a1afcd9"},
"abiDefinition":[{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}],
@ -65,10 +64,10 @@ describe('embark.Compiler', function() {
};
expectedObject["Token"] = {
"code":"608060405234801561001057600080fd5b506040516020806104618339810160409081529051336000908152602081905291909120819055600255610418806100496000396000f3006080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461007c57806318160ddd146100b457806323b872dd146100db57806370a0823114610105578063a9059cbb14610126578063dd62ed3e1461014a575b600080fd5b34801561008857600080fd5b506100a0600160a060020a0360043516602435610171565b604080519115158252519081900360200190f35b3480156100c057600080fd5b506100c96101d7565b60408051918252519081900360200190f35b3480156100e757600080fd5b506100a0600160a060020a03600435811690602435166044356101dd565b34801561011157600080fd5b506100c9600160a060020a03600435166102e9565b34801561013257600080fd5b506100a0600160a060020a0360043516602435610304565b34801561015657600080fd5b506100c9600160a060020a03600435811690602435166103ba565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025490565b600160a060020a03831660009081526020819052604081205482111561020257600080fd5b600160a060020a038416600090815260016020908152604080832033845290915290205482111561023257600080fd5b600160a060020a03831660009081526020819052604090205461025590836103e5565b151561026057600080fd5b600160a060020a03808516600081815260016020908152604080832033845282528083208054889003905583835282825280832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b3360009081526020819052604081205482111561032057600080fd5b600160a060020a03831660009081526020819052604090205461034390836103e5565b151561034e57600080fd5b3360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b81011015905600a165627a7a72305820f4d3e54bdfabcdb60435da61d6a6d650b6814ec3bfa0ac2cb0e4eec3795d11a20029",
"runtimeBytecode":"6080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461007c57806318160ddd146100b457806323b872dd146100db57806370a0823114610105578063a9059cbb14610126578063dd62ed3e1461014a575b600080fd5b34801561008857600080fd5b506100a0600160a060020a0360043516602435610171565b604080519115158252519081900360200190f35b3480156100c057600080fd5b506100c96101d7565b60408051918252519081900360200190f35b3480156100e757600080fd5b506100a0600160a060020a03600435811690602435166044356101dd565b34801561011157600080fd5b506100c9600160a060020a03600435166102e9565b34801561013257600080fd5b506100a0600160a060020a0360043516602435610304565b34801561015657600080fd5b506100c9600160a060020a03600435811690602435166103ba565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025490565b600160a060020a03831660009081526020819052604081205482111561020257600080fd5b600160a060020a038416600090815260016020908152604080832033845290915290205482111561023257600080fd5b600160a060020a03831660009081526020819052604090205461025590836103e5565b151561026057600080fd5b600160a060020a03808516600081815260016020908152604080832033845282528083208054889003905583835282825280832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b3360009081526020819052604081205482111561032057600080fd5b600160a060020a03831660009081526020819052604090205461034390836103e5565b151561034e57600080fd5b3360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b81011015905600a165627a7a72305820f4d3e54bdfabcdb60435da61d6a6d650b6814ec3bfa0ac2cb0e4eec3795d11a20029",
"code":"608060405234801561001057600080fd5b506040516020806104618339810160409081529051336000908152602081905291909120819055600255610418806100496000396000f3006080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461007c57806318160ddd146100b457806323b872dd146100db57806370a0823114610105578063a9059cbb14610126578063dd62ed3e1461014a575b600080fd5b34801561008857600080fd5b506100a0600160a060020a0360043516602435610171565b604080519115158252519081900360200190f35b3480156100c057600080fd5b506100c96101d7565b60408051918252519081900360200190f35b3480156100e757600080fd5b506100a0600160a060020a03600435811690602435166044356101dd565b34801561011157600080fd5b506100c9600160a060020a03600435166102e9565b34801561013257600080fd5b506100a0600160a060020a0360043516602435610304565b34801561015657600080fd5b506100c9600160a060020a03600435811690602435166103ba565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025490565b600160a060020a03831660009081526020819052604081205482111561020257600080fd5b600160a060020a038416600090815260016020908152604080832033845290915290205482111561023257600080fd5b600160a060020a03831660009081526020819052604090205461025590836103e5565b151561026057600080fd5b600160a060020a03808516600081815260016020908152604080832033845282528083208054889003905583835282825280832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b3360009081526020819052604081205482111561032057600080fd5b600160a060020a03831660009081526020819052604090205461034390836103e5565b151561034e57600080fd5b3360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b81011015905600a165627a7a72305820607405c1f2c38630c04e36d3137c31d3ac8aff2ad5da1d0b7d4502c95f46df4b0029",
"runtimeBytecode":"6080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461007c57806318160ddd146100b457806323b872dd146100db57806370a0823114610105578063a9059cbb14610126578063dd62ed3e1461014a575b600080fd5b34801561008857600080fd5b506100a0600160a060020a0360043516602435610171565b604080519115158252519081900360200190f35b3480156100c057600080fd5b506100c96101d7565b60408051918252519081900360200190f35b3480156100e757600080fd5b506100a0600160a060020a03600435811690602435166044356101dd565b34801561011157600080fd5b506100c9600160a060020a03600435166102e9565b34801561013257600080fd5b506100a0600160a060020a0360043516602435610304565b34801561015657600080fd5b506100c9600160a060020a03600435811690602435166103ba565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025490565b600160a060020a03831660009081526020819052604081205482111561020257600080fd5b600160a060020a038416600090815260016020908152604080832033845290915290205482111561023257600080fd5b600160a060020a03831660009081526020819052604090205461025590836103e5565b151561026057600080fd5b600160a060020a03808516600081815260016020908152604080832033845282528083208054889003905583835282825280832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b3360009081526020819052604081205482111561032057600080fd5b600160a060020a03831660009081526020819052604090205461034390836103e5565b151561034e57600080fd5b3360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b81011015905600a165627a7a72305820607405c1f2c38630c04e36d3137c31d3ac8aff2ad5da1d0b7d4502c95f46df4b0029",
"realRuntimeBytecode":"6080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461007c57806318160ddd146100b457806323b872dd146100db57806370a0823114610105578063a9059cbb14610126578063dd62ed3e1461014a575b600080fd5b34801561008857600080fd5b506100a0600160a060020a0360043516602435610171565b604080519115158252519081900360200190f35b3480156100c057600080fd5b506100c96101d7565b60408051918252519081900360200190f35b3480156100e757600080fd5b506100a0600160a060020a03600435811690602435166044356101dd565b34801561011157600080fd5b506100c9600160a060020a03600435166102e9565b34801561013257600080fd5b506100a0600160a060020a0360043516602435610304565b34801561015657600080fd5b506100c9600160a060020a03600435811690602435166103ba565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025490565b600160a060020a03831660009081526020819052604081205482111561020257600080fd5b600160a060020a038416600090815260016020908152604080832033845290915290205482111561023257600080fd5b600160a060020a03831660009081526020819052604090205461025590836103e5565b151561026057600080fd5b600160a060020a03808516600081815260016020908152604080832033845282528083208054889003905583835282825280832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b3360009081526020819052604081205482111561032057600080fd5b600160a060020a03831660009081526020819052604090205461034390836103e5565b151561034e57600080fd5b3360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b81011015905600a165627a7a72305820",
"swarmHash":"f4d3e54bdfabcdb60435da61d6a6d650b6814ec3bfa0ac2cb0e4eec3795d11a2",
"swarmHash":"607405c1f2c38630c04e36d3137c31d3ac8aff2ad5da1d0b7d4502c95f46df4b",
"gasEstimates":{"creation":{"codeDepositCost":"209600","executionCost":"40385","totalCost":"249985"},"external":{"allowance(address,address)":"818","approve(address,uint256)":"22332","balanceOf(address)":"675","totalSupply()":"406","transfer(address,uint256)":"43544","transferFrom(address,address,uint256)":"64387"},"internal":{"safeToAdd(uint256,uint256)":"24"}},
"functionHashes":{"allowance(address,address)":"dd62ed3e","approve(address,uint256)":"095ea7b3","balanceOf(address)":"70a08231","totalSupply()":"18160ddd","transfer(address,uint256)":"a9059cbb","transferFrom(address,address,uint256)":"23b872dd"},
"abiDefinition":[{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"value","type":"uint256"}],"name":"approve","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"supply","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"who","type":"address"}],"name":"balanceOf","outputs":[{"name":"value","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"_allowance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"initial_balance","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}],
@ -97,10 +96,10 @@ describe('embark.Compiler', function() {
let expectedObject = {};
expectedObject["SimpleStorage"] = {
"code":"608060405234801561001057600080fd5b506040516020806101618339810180604052810190808051906020019092919050505080600081905550506101178061004a6000396000f3006080604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605857806360fe47b11460805780636d4ce63c1460aa575b600080fd5b348015606357600080fd5b50606a60d2565b6040518082815260200191505060405180910390f35b348015608b57600080fd5b5060a86004803603810190808035906020019092919050505060d8565b005b34801560b557600080fd5b5060bc60e2565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b600080549050905600a165627a7a72305820031e899b9bf6ce1eedee31ac19bb4e49a4b5b666e83ccb4342d5e608154164b60029",
"runtimeBytecode":"6080604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605857806360fe47b11460805780636d4ce63c1460aa575b600080fd5b348015606357600080fd5b50606a60d2565b6040518082815260200191505060405180910390f35b348015608b57600080fd5b5060a86004803603810190808035906020019092919050505060d8565b005b34801560b557600080fd5b5060bc60e2565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b600080549050905600a165627a7a72305820031e899b9bf6ce1eedee31ac19bb4e49a4b5b666e83ccb4342d5e608154164b60029",
"code":"608060405234801561001057600080fd5b506040516020806101618339810180604052810190808051906020019092919050505080600081905550506101178061004a6000396000f3006080604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605857806360fe47b11460805780636d4ce63c1460aa575b600080fd5b348015606357600080fd5b50606a60d2565b6040518082815260200191505060405180910390f35b348015608b57600080fd5b5060a86004803603810190808035906020019092919050505060d8565b005b34801560b557600080fd5b5060bc60e2565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b600080549050905600a165627a7a723058208767191d8e94f92eb21bca12a1c23f972a28b18f7fbb8fa67eec4b88e95715820029",
"runtimeBytecode":"6080604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605857806360fe47b11460805780636d4ce63c1460aa575b600080fd5b348015606357600080fd5b50606a60d2565b6040518082815260200191505060405180910390f35b348015608b57600080fd5b5060a86004803603810190808035906020019092919050505060d8565b005b34801560b557600080fd5b5060bc60e2565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b600080549050905600a165627a7a723058208767191d8e94f92eb21bca12a1c23f972a28b18f7fbb8fa67eec4b88e95715820029",
"realRuntimeBytecode":"6080604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605857806360fe47b11460805780636d4ce63c1460aa575b600080fd5b348015606357600080fd5b50606a60d2565b6040518082815260200191505060405180910390f35b348015608b57600080fd5b5060a86004803603810190808035906020019092919050505060d8565b005b34801560b557600080fd5b5060bc60e2565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b600080549050905600a165627a7a72305820",
"swarmHash":"031e899b9bf6ce1eedee31ac19bb4e49a4b5b666e83ccb4342d5e608154164b6",
"swarmHash":"8767191d8e94f92eb21bca12a1c23f972a28b18f7fbb8fa67eec4b88e9571582",
"gasEstimates":{"creation":{"codeDepositCost":"55800","executionCost":"20205","totalCost":"76005"},"external":{"get()":"446","set(uint256)":"20227","storedData()":"394"}},
"functionHashes":{"get()":"6d4ce63c","set(uint256)":"60fe47b1","storedData()":"2a1afcd9"},
"abiDefinition":[{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}],
@ -108,10 +107,10 @@ describe('embark.Compiler', function() {
};
expectedObject["Token"] = {
"code":"608060405234801561001057600080fd5b506040516020806109bb83398101806040528101908080519060200190929190505050806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550806002819055505061092e8061008d6000396000f300608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007d57806318160ddd146100e257806323b872dd1461010d57806370a0823114610192578063a9059cbb146101e9578063dd62ed3e1461024e575b600080fd5b34801561008957600080fd5b506100c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506102c5565b604051808215151515815260200191505060405180910390f35b3480156100ee57600080fd5b506100f76103b7565b6040518082815260200191505060405180910390f35b34801561011957600080fd5b50610178600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b34801561019e57600080fd5b506101d3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061067c565b6040518082815260200191505060405180910390f35b3480156101f557600080fd5b50610234600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c4565b604051808215151515815260200191505060405180910390f35b34801561025a57600080fd5b506102af600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061086b565b6040518082815260200191505060405180910390f35b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600254905090565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561040e57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561049757600080fd5b6104df6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b15156104ea57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561071157600080fd5b6107596000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b151561076457600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008282840110159050929150505600a165627a7a7230582001e0089d85828d4d2c0bb811fd6015f61224838cbfaaa8c7d72b01a6dcfe35ce0029",
"runtimeBytecode":"608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007d57806318160ddd146100e257806323b872dd1461010d57806370a0823114610192578063a9059cbb146101e9578063dd62ed3e1461024e575b600080fd5b34801561008957600080fd5b506100c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506102c5565b604051808215151515815260200191505060405180910390f35b3480156100ee57600080fd5b506100f76103b7565b6040518082815260200191505060405180910390f35b34801561011957600080fd5b50610178600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b34801561019e57600080fd5b506101d3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061067c565b6040518082815260200191505060405180910390f35b3480156101f557600080fd5b50610234600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c4565b604051808215151515815260200191505060405180910390f35b34801561025a57600080fd5b506102af600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061086b565b6040518082815260200191505060405180910390f35b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600254905090565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561040e57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561049757600080fd5b6104df6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b15156104ea57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561071157600080fd5b6107596000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b151561076457600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008282840110159050929150505600a165627a7a7230582001e0089d85828d4d2c0bb811fd6015f61224838cbfaaa8c7d72b01a6dcfe35ce0029",
"code":"608060405234801561001057600080fd5b506040516020806109bb83398101806040528101908080519060200190929190505050806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550806002819055505061092e8061008d6000396000f300608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007d57806318160ddd146100e257806323b872dd1461010d57806370a0823114610192578063a9059cbb146101e9578063dd62ed3e1461024e575b600080fd5b34801561008957600080fd5b506100c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506102c5565b604051808215151515815260200191505060405180910390f35b3480156100ee57600080fd5b506100f76103b7565b6040518082815260200191505060405180910390f35b34801561011957600080fd5b50610178600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b34801561019e57600080fd5b506101d3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061067c565b6040518082815260200191505060405180910390f35b3480156101f557600080fd5b50610234600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c4565b604051808215151515815260200191505060405180910390f35b34801561025a57600080fd5b506102af600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061086b565b6040518082815260200191505060405180910390f35b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600254905090565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561040e57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561049757600080fd5b6104df6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b15156104ea57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561071157600080fd5b6107596000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b151561076457600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008282840110159050929150505600a165627a7a72305820981ad128c29450c3409fdae69b63a96944d97726367b4b211308ad530e5b02800029",
"runtimeBytecode":"608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007d57806318160ddd146100e257806323b872dd1461010d57806370a0823114610192578063a9059cbb146101e9578063dd62ed3e1461024e575b600080fd5b34801561008957600080fd5b506100c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506102c5565b604051808215151515815260200191505060405180910390f35b3480156100ee57600080fd5b506100f76103b7565b6040518082815260200191505060405180910390f35b34801561011957600080fd5b50610178600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b34801561019e57600080fd5b506101d3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061067c565b6040518082815260200191505060405180910390f35b3480156101f557600080fd5b50610234600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c4565b604051808215151515815260200191505060405180910390f35b34801561025a57600080fd5b506102af600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061086b565b6040518082815260200191505060405180910390f35b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600254905090565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561040e57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561049757600080fd5b6104df6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b15156104ea57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561071157600080fd5b6107596000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b151561076457600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008282840110159050929150505600a165627a7a72305820981ad128c29450c3409fdae69b63a96944d97726367b4b211308ad530e5b02800029",
"realRuntimeBytecode":"608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007d57806318160ddd146100e257806323b872dd1461010d57806370a0823114610192578063a9059cbb146101e9578063dd62ed3e1461024e575b600080fd5b34801561008957600080fd5b506100c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506102c5565b604051808215151515815260200191505060405180910390f35b3480156100ee57600080fd5b506100f76103b7565b6040518082815260200191505060405180910390f35b34801561011957600080fd5b50610178600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b34801561019e57600080fd5b506101d3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061067c565b6040518082815260200191505060405180910390f35b3480156101f557600080fd5b50610234600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c4565b604051808215151515815260200191505060405180910390f35b34801561025a57600080fd5b506102af600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061086b565b6040518082815260200191505060405180910390f35b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600254905090565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561040e57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561049757600080fd5b6104df6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b15156104ea57600080fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561071157600080fd5b6107596000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836108f2565b151561076457600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008282840110159050929150505600a165627a7a72305820",
"swarmHash":"01e0089d85828d4d2c0bb811fd6015f61224838cbfaaa8c7d72b01a6dcfe35ce",
"swarmHash":"981ad128c29450c3409fdae69b63a96944d97726367b4b211308ad530e5b0280",
"gasEstimates":{"creation":{"codeDepositCost":"470000","executionCost":"40708","totalCost":"510708"},"external":{"allowance(address,address)":"794","approve(address,uint256)":"22331","balanceOf(address)":"625","totalSupply()":"424","transfer(address,uint256)":"43562","transferFrom(address,address,uint256)":"64373"},"internal":{"safeToAdd(uint256,uint256)":"45"}},
"functionHashes":{"allowance(address,address)":"dd62ed3e","approve(address,uint256)":"095ea7b3","balanceOf(address)":"70a08231","totalSupply()":"18160ddd","transfer(address,uint256)":"a9059cbb","transferFrom(address,address,uint256)":"23b872dd"},
"abiDefinition":[{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"value","type":"uint256"}],"name":"approve","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"supply","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"who","type":"address"}],"name":"balanceOf","outputs":[{"name":"value","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"_allowance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"initial_balance","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}],
@ -127,7 +126,5 @@ describe('embark.Compiler', function() {
done();
});
});
});
});

View File

@ -1,16 +1,17 @@
pragma solidity ^0.4.7;
contract SimpleStorage {
uint public storedData;
function SimpleStorage(uint initialValue) {
constructor(uint initialValue) public {
storedData = initialValue;
}
function set(uint x) {
function set(uint x) public {
storedData = x;
}
function get() constant returns (uint retVal) {
function get() public view returns (uint retVal) {
return storedData;
}

View File

@ -1,6 +1,7 @@
// https://github.com/nexusdev/erc20/blob/master/contracts/base.sol
pragma solidity ^0.4.7;
contract Token {
event Transfer(address indexed from, address indexed to, uint value);
@ -9,57 +10,65 @@ contract Token {
mapping( address => uint ) _balances;
mapping( address => mapping( address => uint ) ) _approvals;
uint _supply;
function Token( uint initial_balance ) {
constructor(uint initial_balance) public {
_balances[msg.sender] = initial_balance;
_supply = initial_balance;
}
function totalSupply() constant returns (uint supply) {
function totalSupply() public view returns (uint supply) {
return _supply;
}
function balanceOf( address who ) constant returns (uint value) {
function balanceOf(address who) public view returns (uint value) {
return _balances[who];
}
function transfer( address to, uint value) returns (bool ok) {
function transfer(address to, uint value) public returns (bool ok) {
if( _balances[msg.sender] < value ) {
throw;
revert();
}
if( !safeToAdd(_balances[to], value) ) {
throw;
revert();
}
_balances[msg.sender] -= value;
_balances[to] += value;
Transfer( msg.sender, to, value );
emit Transfer( msg.sender, to, value );
return true;
}
function transferFrom( address from, address to, uint value) returns (bool ok) {
function transferFrom(address from, address to, uint value) public returns (bool ok) {
// if you don't have enough balance, throw
if( _balances[from] < value ) {
throw;
revert();
}
// if you don't have approval, throw
if( _approvals[from][msg.sender] < value ) {
throw;
revert();
}
if( !safeToAdd(_balances[to], value) ) {
throw;
revert();
}
// transfer and return true
_approvals[from][msg.sender] -= value;
_balances[from] -= value;
_balances[to] += value;
Transfer( from, to, value );
emit Transfer( from, to, value );
return true;
}
function approve(address spender, uint value) returns (bool ok) {
function approve(address spender, uint value) public returns (bool ok) {
// TODO: should increase instead
_approvals[msg.sender][spender] = value;
Approval( msg.sender, spender, value );
emit Approval( msg.sender, spender, value );
return true;
}
function allowance(address owner, address spender) constant returns (uint _allowance) {
function allowance(address owner, address spender) public view returns (uint _allowance) {
return _approvals[owner][spender];
}
function safeToAdd(uint a, uint b) internal returns (bool) {
function safeToAdd(uint a, uint b) internal pure returns (bool) {
return (a + b >= a);
}
}

View File

@ -1,6 +1,7 @@
// https://github.com/nexusdev/erc20/blob/master/contracts/base.sol
pragma solidity ^0.4.7;
contract TokenStorage {
event Transfer(address indexed from, address indexed to, uint value);
@ -10,58 +11,66 @@ contract TokenStorage {
mapping( address => mapping( address => uint ) ) _approvals;
uint _supply;
address public addr;
function TokenStorage( uint initial_balance, address _addr) {
constructor( uint initial_balance, address _addr) public {
_balances[msg.sender] = initial_balance;
_supply = initial_balance;
addr = _addr;
}
function totalSupply() constant returns (uint supply) {
function totalSupply() public view returns (uint supply) {
return _supply;
}
function balanceOf( address who ) constant returns (uint value) {
function balanceOf(address who) public view returns (uint value) {
return _balances[who];
}
function transfer( address to, uint value) returns (bool ok) {
function transfer(address to, uint value) public returns (bool ok) {
if( _balances[msg.sender] < value ) {
throw;
revert();
}
if( !safeToAdd(_balances[to], value) ) {
throw;
revert();
}
_balances[msg.sender] -= value;
_balances[to] += value;
Transfer( msg.sender, to, value );
emit Transfer( msg.sender, to, value );
return true;
}
function transferFrom( address from, address to, uint value) returns (bool ok) {
function transferFrom(address from, address to, uint value) public returns (bool ok) {
// if you don't have enough balance, throw
if( _balances[from] < value ) {
throw;
revert();
}
// if you don't have approval, throw
if( _approvals[from][msg.sender] < value ) {
throw;
revert();
}
if( !safeToAdd(_balances[to], value) ) {
throw;
revert();
}
// transfer and return true
_approvals[from][msg.sender] -= value;
_balances[from] -= value;
_balances[to] += value;
Transfer( from, to, value );
emit Transfer( from, to, value );
return true;
}
function approve(address spender, uint value) returns (bool ok) {
function approve(address spender, uint value) public returns (bool ok) {
// TODO: should increase instead
_approvals[msg.sender][spender] = value;
Approval( msg.sender, spender, value );
emit Approval( msg.sender, spender, value );
return true;
}
function allowance(address owner, address spender) constant returns (uint _allowance) {
function allowance(address owner, address spender) public view returns (uint _allowance) {
return _approvals[owner][spender];
}
function safeToAdd(uint a, uint b) internal returns (bool) {
function safeToAdd(uint a, uint b) internal pure returns (bool) {
return (a + b >= a);
}
}

View File

@ -15,31 +15,49 @@ describe('TemplateGenerator', function () {
it('return correct zip filename for https link', function () {
let result = templateGenerator.getExternalProject("https://github.com/embark-framework/embark");
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/master.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/archive.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/master/archive.zip");
});
it('return correct zip filename for https link with branch specified', function () {
let result = templateGenerator.getExternalProject("https://github.com/embark-framework/embark/tree/develop");
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/develop.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/develop/archive.zip");
});
it('return correct zip filename for http link', function () {
let result = templateGenerator.getExternalProject("http://github.com/embark-framework/embark");
assert.strictEqual(result.url, "http://github.com/embark-framework/embark/archive/master.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/archive.zip");
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/master.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/master/archive.zip");
});
it('return correct zip filename for http link with branch specified', function () {
let result = templateGenerator.getExternalProject("http://github.com/embark-framework/embark/tree/develop");
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/develop.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/develop/archive.zip");
});
it('return correct zip filename without protocol specified ', function () {
let result = templateGenerator.getExternalProject("github.com/embark-framework/embark");
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/master.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/archive.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/master/archive.zip");
});
it('return correct zip filename without protocol specified ', function () {
let result = templateGenerator.getExternalProject("github.com/embark-framework/embark");
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/master.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/archive.zip");
it('return correct zip filename without protocol with branch specified', function () {
let result = templateGenerator.getExternalProject("github.com/embark-framework/embark#develop");
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/develop.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/develop/archive.zip");
});
it('return correct zip filename with just username/repo specified', function () {
let result = templateGenerator.getExternalProject("embark-framework/embark");
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/master.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/archive.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/master/archive.zip");
});
it('return correct zip filename with just username/repo and branch specified', function () {
let result = templateGenerator.getExternalProject("embark-framework/embark#develop");
assert.strictEqual(result.url, "https://github.com/embark-framework/embark/archive/develop.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark/develop/archive.zip");
});
it('return correct zip filename with just embark template specified', function () {
@ -47,7 +65,6 @@ describe('TemplateGenerator', function () {
assert.strictEqual(result.url, "https://github.com/embark-framework/embark-react-template/archive/master.zip");
assert.strictEqual(result.filePath.replace(/\\/g,'/'), ".embark/templates/embark-framework/embark-react-template/archive.zip");
});
});
});