refactor: upgrade to web3 v1.2.1

Upgrade all dependencies on web3/web3-* v1.0.0-beta.37 to v1.2.1.

Make various adjustments related to the previous convention of
`"web3": "1.0.0-beta"` in `embark.json` signifying that embark's own web3
dependency should be used in dapp builds.

Fix bugs in library manager, including a switch from using the
live-plugin-manager package to using npm in a child process to install
`"versions"` dependencies specified in `embark.json` when a specified version
doesn't match up with embark's own version for that package.

Avoid race conditions when installing `"versions"` by completing all installs
prior to starting other services. If an install fails, then after all the
installs have completed or failed the embark command will exit with error.

Change various comments and update docs to reflect the new default of web3
v1.2.1.
This commit is contained in:
Michael Bradley, Jr 2019-08-06 17:07:55 -05:00 committed by Michael Bradley
parent 0c12097c17
commit ad30a98169
42 changed files with 1377 additions and 435 deletions

View File

@ -9,7 +9,7 @@
"buildDir": "dist/",
"config": "config/",
"versions": {
"web3": "1.0.0-beta",
"web3": "1.2.1",
"solc": "0.5.0",
"ipfs-api": "17.2.4"
},

View File

@ -9,7 +9,7 @@
"buildDir": "dist/",
"config": "config/",
"versions": {
"web3": "1.0.0-beta",
"web3": "1.2.1",
"solc": "0.5.0",
"ipfs-api": "17.2.4"
},

View File

@ -16,7 +16,7 @@
"config": "config/",
"versions": {
"solc": "0.4.25",
"web3": "1.0.0-beta",
"web3": "1.2.1",
"ipfs-api": "17.2.7"
},
"plugins": {

View File

@ -12,7 +12,7 @@
"namesystem": "ens.json"
},
"versions": {
"web3": "1.0.0-beta",
"web3": "1.2.1",
"solc": "0.4.24"
},
"plugins": {

View File

@ -55,7 +55,7 @@
"ethereumjs-tx": "1.3.7",
"ethereumjs-util": "6.0.0",
"ganache-cli": "6.4.3",
"web3": "1.0.0-beta.37"
"web3": "1.2.1"
},
"devDependencies": {
"@babel/cli": "7.2.3",

View File

@ -280,7 +280,7 @@ class BlockchainConnector {
next();
},
function checkVersion(next) {
// TODO: web3_clientVersion method is currently not implemented in web3.js 1.0
// TODO: web3_clientVersion method is currently not implemented in web3.js 1.x
self.web3._requestManager.send({method: 'web3_clientVersion', params: []}, (err, version) => {
if (err || !version) {
self.isWeb3Ready = false;

View File

@ -51,7 +51,7 @@
"embark-core": "^4.1.0-beta.5",
"embark-process-logs-api": "^4.1.0-beta.5",
"embark-utils": "^4.1.0-beta.5",
"web3": "1.0.0-beta.37"
"web3": "1.2.1"
},
"devDependencies": {
"@babel/cli": "7.2.3",

View File

@ -53,7 +53,7 @@
"fs-extra": "7.0.1",
"parse-json": "4.0.0",
"vm2": "3.6.4",
"web3": "1.0.0-beta.37"
"web3": "1.2.1"
},
"devDependencies": {
"@babel/cli": "7.2.3",

View File

@ -50,13 +50,15 @@
"prettier-plugin-solidity": "1.0.0-alpha.25",
"semver": "5.6.0",
"solidity-parser-antlr": "0.4.5",
"web3-eth-contract": "1.0.0-beta.37"
"web3-eth-contract": "1.2.1"
},
"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"@types/fs-extra": "7.0.0",
"@types/mocha": "5.2.0",
"@types/prettier": "1.16.4",
"@types/semver": "5.5.0",
"@types/web3": "1.0.12",
"cross-env": "5.2.0",
"eslint": "5.7.0",

View File

@ -50,7 +50,8 @@
"colors": "1.3.2",
"embark-i18n": "^4.1.0-beta.3",
"embark-utils": "^4.1.0-beta.5",
"live-plugin-manager-git-fix": "0.12.1"
"fs-extra": "7.0.1",
"rimraf": "2.6.3"
},
"devDependencies": {
"@babel/cli": "7.2.3",

View File

@ -1,6 +1,7 @@
import { __ } from 'embark-i18n';
import { dappPath, embarkPath, normalizePath, toForwardSlashes } from 'embark-utils';
var Npm = require('./npm.js');
const Npm = require('./npm.js');
const {callbackify} = require('util');
class LibraryManager {
@ -10,6 +11,7 @@ class LibraryManager {
this.contractsConfig = this.config.contractsConfig;
this.storageConfig = this.config.storageConfig;
this.useDashboard = useDashboard;
this.npm = new Npm({logger: this.embark.logger, useDashboard});
this.determineVersions();
@ -22,7 +24,7 @@ class LibraryManager {
determineVersions() {
this.versions = {};
let solcVersionInConfig = this.contractsConfig.versions.solc;
let solcVersionInConfig = this.contractsConfig.versions["solc"];
let web3VersionInConfig = this.contractsConfig.versions["web3"];
let ipfsApiVersion = this.storageConfig.versions["ipfs-api"];
@ -39,6 +41,63 @@ class LibraryManager {
});
}
installAll(callback) {
const installAll = async () => {
const useDashboard = this.npm._useDashboard;
this.npm._useDashboard = false;
const results = await Promise.all(
Object.entries(this.versions)
.filter(([packageName, version]) => {
// NOTE: will behave less than ideally if embark switches to using
// a dependency range for the various overridable packages instead
// of an exact version
if (version === this.embark.config.package.dependencies[packageName]) {
return false;
}
return true;
})
.map(
([packageName, version]) => {
return new Promise((resolve) => {
this.npm.getPackageVersion(packageName, version, (err, location) => {
resolve({packageName, version, err, location});
});
});
}
)
);
this.npm._useDashboard = useDashboard;
const errors = {};
const locations = {};
results.forEach(({packageName, version, err, location}) => {
if (err) {
errors[packageName] = {version, err};
} else {
locations[packageName] = {version, location};
}
});
if (!Object.keys(errors).length) return locations;
const packages = (Object.entries(errors).reduce((packages, [packageName, {version}]) => {
return packages.concat(`${packageName}@${version}`);
}, []));
const err = new Error(`install failed for ${packages.length} packages: ${packages.join(', ')}`);
err.results = {errors, locations};
throw err;
};
if (callback) {
return callbackify(installAll)(callback);
}
return installAll();
}
registerCommands() {
const self = this;
const matches = ['versions'];
@ -95,9 +154,8 @@ class LibraryManager {
}
listenToCommandsToGetLibrary() {
let npm = new Npm({logger: this.embark.logger, useDashboard: this.useDashboard});
this.embark.events.setCommandHandler('version:getPackageLocation', (libName, version, cb) => {
npm.getPackageVersion(libName, version, cb);
this.npm.getPackageVersion(libName, version, cb);
});
this.embark.events.setCommandHandler('version:downloadIfNeeded', (libName, cb) => {
this.downloadIfNeeded(libName, cb);

View File

@ -1,7 +1,11 @@
const fs = require('fs');
const PluginManager = require('live-plugin-manager-git-fix').PluginManager;
const path = require('path');
require('colors');
import { LongRunningProcessTimer } from 'embark-utils';
const {exec} = require('child_process');
const {existsSync, mkdirpSync, writeFileSync} = require('fs-extra');
const rimraf = require('rimraf');
const FINISHED_INSTALLING_SUCCESSFULLY = 'finished';
class Npm {
@ -9,27 +13,54 @@ class Npm {
this._logger = options.logger;
this._packageName = options.packageName;
this._version = options.version;
this._installed = {};
this._installing = {};
this._installFailed = {};
this._useDashboard = options.useDashboard;
}
static getPackagePath(packageName, version) {
return './.embark/versions/' + packageName + '/' + version + '/' + packageName;
return path.join('.embark', 'versions', packageName, version, 'node_modules', packageName);
}
_isInstallFailure(packageName, version) {
return !!this._installFailed[packageName + version];
}
_isInstalled(packageName, version) {
if (this._installed[packageName + version]) {
return true;
}
const packagePath = Npm.getPackagePath(packageName, version);
const installPath = path.dirname(path.dirname(packagePath));
if (existsSync(packagePath) &&
!this._isInstalling(packageName, version)) {
if (existsSync(path.join(installPath, FINISHED_INSTALLING_SUCCESSFULLY))) {
this._installed[packageName + version] = true;
return true;
}
rimraf.sync(installPath);
return false;
}
return false;
}
_isInstalling(packageName, version) {
return typeof this._installing[packageName + version] !== 'undefined';
return !!this._installing[packageName + version];
}
getPackageVersion(packageName, version, callback) {
const packagePath = Npm.getPackagePath(packageName, version);
// check if this package already exists in the filesystem
if (fs.existsSync(packagePath)) {
// check if this package is already installed
if (this._isInstalled(packageName, version)) {
return callback(null, packagePath);
}
const pluginManager = new PluginManager({pluginsPath: './.embark/versions/' + packageName + '/' + version + '/'});
// check if this package already failed to install
if (this._isInstallFailure(packageName, version)) {
return callback(this._installFailed[packageName + version]);
}
// check if we're already installing this package
if (this._isInstalling(packageName, version)) {
@ -41,28 +72,37 @@ class Npm {
this._logger,
packageName,
version,
'Downloading and installing {{packageName}} {{version}}...',
'Still downloading and installing {{packageName}} {{version}}... ({{duration}})',
'Finished downloading and installing {{packageName}} {{version}} in {{duration}}',
'Downloading and installing {{packageName}} {{version}}...\n',
'Still downloading and installing {{packageName}} {{version}}... ({{duration}})\n',
'Finished downloading and installing {{packageName}} {{version}} in {{duration}}\n',
{
showSpinner: !this._useDashboard,
interval: this._useDashboard ? 2000 : 1000,
longRunningThreshold: 10000
longRunningThreshold: 120000
}
);
timer.start();
// do the package download/install
pluginManager.install(packageName, version).then((result) => {
timer.end();
this._installing[packageName + version].forEach((cb) => {
cb(null, result.location);
// do the package install
const installPath = path.dirname(path.dirname(packagePath));
mkdirpSync(installPath);
exec(`npm init -y && npm install --no-package-lock --no-save ${packageName}@${version}`, {
cwd: installPath
}, (err) => {
this._installing[packageName + version].forEach(cb => {
setImmediate(() => { return err ? cb(err) : cb(null, packagePath); });
});
delete this._installing[packageName + version];
}).catch(err => {
this._installing[packageName + version].forEach((cb) => {
cb(err);
});
if (err) {
timer.abort();
this._installFailed[packageName + version] = err;
rimraf.sync(installPath);
} else {
timer.end();
this._installed[packageName + version] = true;
writeFileSync(path.join(installPath, FINISHED_INSTALLING_SUCCESSFULLY), '');
}
});
}
}

View File

@ -44,7 +44,7 @@ const buildDir = path.join(dappPath, embarkJson.buildDir);
// unexpectedly
let versions;
try {
versions = glob.sync(path.join(dappPath, '.embark/versions/*/*'));
versions = glob.sync(path.join(dappPath, '.embark/versions/*/*/*'));
} catch (e) {
versions = [];
}

View File

@ -49,7 +49,7 @@
"@babel/runtime-corejs2": "7.3.1",
"ascii-table": "0.0.9",
"async": "2.6.1",
"web3-utils": "1.0.0-beta.37"
"web3-utils": "1.2.1"
},
"devDependencies": {
"@babel/cli": "7.2.3",

View File

@ -52,7 +52,6 @@
"embark-i18n": "^4.1.0-beta.3",
"embark-utils": "^4.1.0-beta.5",
"fs-extra": "7.0.1",
"live-plugin-manager-git-fix": "0.12.1",
"semver": "5.6.0",
"solc": "0.5.0",
"uuid": "3.3.2"

View File

@ -1,8 +1,6 @@
import { ProcessWrapper } from 'embark-core';
const fs = require('fs-extra');
const semver = require('semver');
const PluginManager = require('live-plugin-manager-git-fix').PluginManager;
import { LongRunningProcessTimer } from 'embark-utils';
class SolcProcess extends ProcessWrapper {
@ -20,33 +18,6 @@ class SolcProcess extends ProcessWrapper {
return {error: 'File not found'};
}
installAndLoadCompiler(solcVersion, packagePath) {
let self = this;
return new Promise((resolve, reject) => {
let manager = new PluginManager({pluginsPath: packagePath});
let timer;
if (!fs.existsSync(packagePath)) {
timer = new LongRunningProcessTimer(
self._logger,
'solc',
solcVersion,
'Downloading and installing {{packageName}} {{version}}...',
'Still downloading and installing {{packageName}} {{version}}... ({{duration}})',
'Finished downloading and installing {{packageName}} {{version}} in {{duration}}',
{ showSpinner: self._showSpinner }
);
}
if (timer) timer.start();
manager.install('solc', solcVersion).then(() => {
self.solc = manager.require('solc');
if (timer) timer.end();
resolve();
}).catch(reject);
});
}
compile(jsonObj, cb) {
// TODO: only available in 0.4.11; need to make versions warn about this
try {
@ -60,8 +31,6 @@ class SolcProcess extends ProcessWrapper {
cb(err.message || err);
}
}
}
let solcProcess;
@ -73,16 +42,10 @@ process.on('message', (msg) => {
}
else if (msg.action === 'loadCompiler') {
solcProcess.solc = require('solc');
solcProcess.solc = require(msg.requirePath);
return process.send({result: "loadedCompiler"});
}
else if (msg.action === 'installAndLoadCompiler') {
solcProcess.installAndLoadCompiler(msg.solcVersion, msg.packagePath).then(() => {
return process.send({result: "loadedCompiler"});
});
}
else if (msg.action === 'compile') {
solcProcess.compile(msg.jsonObj, (err, output) => {
process.send({result: "compilation-" + msg.id, err: err, output: output});

View File

@ -1,6 +1,6 @@
import { __ } from 'embark-i18n';
import { ProcessLauncher } from 'embark-core';
import { dappPath, joinPath } from 'embark-utils';
import { dappPath, joinPath, toForwardSlashes } from 'embark-utils';
const uuid = require('uuid/v1');
class SolcW {
@ -36,43 +36,44 @@ class SolcW {
}
load_compiler_internally(done) {
const self = this;
if (this.compilerLoaded) {
return done();
}
this.solcProcess = new ProcessLauncher({
embark: self.embark,
embark: this.embark,
modulePath: joinPath(__dirname, 'solcP.js'),
logger: self.logger,
events: self.events,
providerUrl: self.providerUrl,
logger: this.logger,
events: this.events,
providerUrl: this.providerUrl,
silent: false
});
this.solcProcess.once("result", "initiated", () => {
this.events.request("version:get:solc", function(solcVersion) {
if (solcVersion === self.embark.config.package.dependencies.solc) {
return self.solcProcess.send({action: 'loadCompiler', requirePath: 'solc'});
this.events.request("version:get:solc", (solcVersion) => {
if (solcVersion === this.embark.config.package.dependencies.solc) {
return this.solcProcess.send({action: 'loadCompiler', requirePath: 'solc'});
}
self.events.request("version:getPackagePath", "solc", solcVersion, function(err, path) {
this.events.request("version:getPackageLocation", "solc", solcVersion, (err, location) => {
if (err) {
return done(err);
}
let requirePath = dappPath(path);
self.solcProcess.send({action: 'installAndLoadCompiler', solcVersion: solcVersion, packagePath: requirePath});
this.solcProcess.send({
action: 'loadCompiler',
requirePath: toForwardSlashes(dappPath(location))
});
});
});
});
this.solcProcess.once("result", "loadedCompiler", () => {
self.compilerLoaded = true;
this.compilerLoaded = true;
done();
});
this.solcProcess.send({action: "init", options: {showSpinner: !self.useDashboard}});
this.solcProcess.send({action: "init", options: {showSpinner: !this.useDashboard}});
if (this.ipc.isServer()) {
this.ipc.on('compile', self.compile.bind(this));
this.ipc.on('compile', this.compile.bind(this));
}
}

View File

@ -127,7 +127,7 @@
"url-loader": "1.1.1",
"uuid": "3.3.2",
"velocity-react": "^1.4.1",
"web3": "1.0.0-beta.37",
"web3": "1.2.1",
"webpack": "4.19.1",
"webpack-dev-server": "3.1.9",
"webpack-manifest-plugin": "2.0.4",

View File

@ -61,14 +61,15 @@
"ora": "2.1.0",
"pretty-ms": "4.0.0",
"shelljs": "0.8.3",
"web3": "1.0.0-beta.37",
"web3-eth": "1.0.0-beta.37",
"web3-eth-abi": "1.0.0-beta.37"
"web3": "1.2.1",
"web3-eth": "1.2.1",
"web3-eth-abi": "1.2.1"
},
"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"@types/follow-redirects": "1.5.0",
"@types/fs-extra": "7.0.0",
"@types/node": "10.11.7",
"@types/pretty-ms": "3.2.0",
"cross-env": "5.2.0",

View File

@ -119,11 +119,19 @@ export default class LongRunningProcessTimer {
}
public end() {
// stop updating console for ongoing download
// stop updating console upon success
clearInterval(this.intOngoingDownload);
performance.mark(this.endMark);
performance.measure(this.downloadComplete, this.startMark, this.endMark);
}
public abort() {
if (this.spinner) {
this.spinner.fail(`Failed to download and install ${this.packageName} ${this.version}\n`);
}
// stop updating console upon failure
clearInterval(this.intOngoingDownload);
}
}
module.exports = LongRunningProcessTimer;

View File

@ -86,16 +86,24 @@ class EmbarkWeb3 {
getWeb3Location() {
return new Promise((resolve, reject) => {
this.events.request("version:get:web3", (web3Version) => {
const embarkWeb3Version = this.embark.config.package.dependencies["web3"];
if (web3Version === "1.0.0-beta") {
web3Version = embarkWeb3Version;
this.logger.warn(`web3 version in embark.json is 1.0.0-beta, using ${embarkWeb3Version} instead, please update your project's embark.json`);
}
// NOTE: will behave less than ideally if embark switches to using a
// dependency range for the web3 package instead of an exact version
if (web3Version === embarkWeb3Version) {
const nodePath = embarkPath('node_modules');
const web3Path = require.resolve("web3", {paths: [nodePath]});
return resolve(web3Path);
}
this.events.request("version:getPackageLocation", "web3", web3Version, (err, location) => {
if (err) {
return reject(err);
}
const locationPath = embarkPath(location);
const locationPath = toForwardSlashes(dappPath(location));
resolve(locationPath);
});
});

View File

@ -158,7 +158,6 @@
"ipfs-api": "17.2.4",
"istanbul": "0.4.5",
"json-parse-better-errors": "1.0.2",
"live-plugin-manager-git-fix": "0.12.1",
"lodash.clonedeep": "4.5.0",
"mocha": "5.2.0",
"neo-blessed": "0.2.0",
@ -191,26 +190,26 @@
"url-loader": "1.1.2",
"viz.js": "1.8.2",
"vm2": "3.6.4",
"web3": "1.0.0-beta.37",
"web3-bzz": "1.0.0-beta.37",
"web3-core": "1.0.0-beta.37",
"web3-core-helpers": "1.0.0-beta.37",
"web3-core-method": "1.0.0-beta.37",
"web3-core-promievent": "1.0.0-beta.37",
"web3-core-requestmanager": "1.0.0-beta.37",
"web3-core-subscriptions": "1.0.0-beta.37",
"web3-eth": "1.0.0-beta.37",
"web3-eth-abi": "1.0.0-beta.37",
"web3-eth-accounts": "1.0.0-beta.37",
"web3-eth-contract": "1.0.0-beta.37",
"web3-eth-iban": "1.0.0-beta.37",
"web3-eth-personal": "1.0.0-beta.37",
"web3-net": "1.0.0-beta.37",
"web3-providers-http": "1.0.0-beta.37",
"web3-providers-ipc": "1.0.0-beta.37",
"web3-providers-ws": "1.0.0-beta.37",
"web3-shh": "1.0.0-beta.37",
"web3-utils": "1.0.0-beta.37",
"web3": "1.2.1",
"web3-bzz": "1.2.1",
"web3-core": "1.2.1",
"web3-core-helpers": "1.2.1",
"web3-core-method": "1.2.1",
"web3-core-promievent": "1.2.1",
"web3-core-requestmanager": "1.2.1",
"web3-core-subscriptions": "1.2.1",
"web3-eth": "1.2.1",
"web3-eth-abi": "1.2.1",
"web3-eth-accounts": "1.2.1",
"web3-eth-contract": "1.2.1",
"web3-eth-iban": "1.2.1",
"web3-eth-personal": "1.2.1",
"web3-net": "1.2.1",
"web3-providers-http": "1.2.1",
"web3-providers-ipc": "1.2.1",
"web3-providers-ws": "1.2.1",
"web3-shh": "1.2.1",
"web3-utils": "1.2.1",
"webpack": "4.29.3",
"window-size": "1.1.1",
"ws": "6.1.2"

View File

@ -122,6 +122,9 @@ class EmbarkController {
callback();
});
},
function (callback) {
engine.startService("libraryManager").installAll((err) => callback(err ? err : null));
},
function (callback) {
let pluginList = engine.plugins.listPlugins();
if (pluginList.length > 0) {
@ -133,7 +136,6 @@ class EmbarkController {
engine.startService("coreProcess");
engine.startService("blockchainListener");
engine.startService("serviceMonitor");
engine.startService("libraryManager");
engine.startService("codeRunner");
engine.startService("pipeline");
engine.startService("deployment");
@ -189,6 +191,7 @@ class EmbarkController {
if (err) {
engine.logger.error(err.message);
engine.logger.info(err.stack);
process.exit(1);
} else {
engine.events.emit('firstDeploymentDone');
}
@ -221,6 +224,9 @@ class EmbarkController {
function initEngine(callback) {
engine.init({}, callback);
},
function (callback) {
engine.startService("libraryManager").installAll((err) => callback(err ? err : null));
},
function startServices(callback) {
if (options.env === 'development') {
engine.logger.warn(__('Building using the development environment. Did you forget to add an environment? eg: `embark build testnet`'));
@ -232,7 +238,6 @@ class EmbarkController {
if (!options.onlyCompile) engine.startService("web3");
engine.startService("processManager");
engine.startService("libraryManager");
engine.startService("codeRunner");
engine.startService("pipeline");
engine.startService("codeGenerator");
@ -303,6 +308,9 @@ class EmbarkController {
function initEngine(callback) {
engine.init({}, callback);
},
function (callback) {
engine.startService("libraryManager").installAll((err) => callback(err ? err : null));
},
function startServices(callback) {
let pluginList = engine.plugins.listPlugins();
if (pluginList.length > 0) {
@ -322,7 +330,6 @@ class EmbarkController {
engine.startService("processManager");
engine.startService("coreProcess");
engine.startService("serviceMonitor");
engine.startService("libraryManager");
engine.startService("pipeline");
engine.startService("storage");
engine.startService("cockpit");
@ -367,6 +374,7 @@ class EmbarkController {
if (err) {
engine.logger.error(err.message);
engine.logger.info(err.stack);
process.exit(1);
} else {
engine.events.emit('firstDeploymentDone');
}
@ -391,6 +399,9 @@ class EmbarkController {
function (callback) {
engine.init({}, callback);
},
function (callback) {
engine.startService("libraryManager").installAll((err) => callback(err ? err : null));
},
function (callback) {
let pluginList = engine.plugins.listPlugins();
if (pluginList.length > 0) {
@ -399,7 +410,6 @@ class EmbarkController {
engine.startService("processManager");
engine.startService("serviceMonitor");
engine.startService("libraryManager");
engine.startService("compiler");
engine.startService("codeGenerator");
engine.startService("graph");
@ -411,11 +421,11 @@ class EmbarkController {
engine.logger.error(err.message);
engine.logger.info(err.stack);
} else {
engine.events.request("graph:create", options, () => {
engine.logger.info(__("Done. %s generated", options.output).underline);
});
}
process.exit(err ? 1 : 0);
});
@ -488,6 +498,9 @@ class EmbarkController {
function initEngine(callback) {
engine.init({}, callback);
},
function (callback) {
engine.startService("libraryManager").installAll((err) => callback(err ? err : null));
},
function startServices(callback) {
engine.startService("scaffolding");
callback();
@ -505,7 +518,6 @@ class EmbarkController {
}
engine.startService("web3");
engine.startService("processManager");
engine.startService("libraryManager");
engine.startService("codeRunner");
engine.startService("deployment", {onlyCompile: true});
@ -525,11 +537,11 @@ class EmbarkController {
if (err) {
engine.logger.error(__("Error generating the UI: "));
engine.logger.error(err.message || err);
process.exit(1);
}
engine.logger.info(__("finished generating the UI").underline);
engine.logger.info(__("To see the result, execute {{cmd}} and go to /{{contract}}.html", {cmd: 'embark run'.underline, contract: options.contract}));
process.exit(0);
process.exit(err ? 1 : 0);
});
}
@ -571,12 +583,14 @@ class EmbarkController {
callback();
});
},
function (callback) {
engine.startService("libraryManager").installAll((err) => callback(err ? err : null));
},
function startServices(callback) {
engine.startService("web3");
engine.startService("processManager");
engine.startService("serviceMonitor");
engine.startService("libraryManager");
engine.startService("codeRunner");
engine.startService("pipeline");
engine.startService("deployment");
@ -659,10 +673,12 @@ class EmbarkController {
function initEngine(callback) {
engine.init({}, callback);
},
function (callback) {
engine.startService("libraryManager").installAll((err) => callback(err ? err : null));
},
function startServices(callback) {
engine.startService("web3", {wait: true, node: options.node});
engine.startService("processManager");
engine.startService("libraryManager");
engine.startService("codeRunner");
engine.startService("deployment", {
trackContracts: false,

View File

@ -334,7 +334,7 @@ Config.prototype.loadBlockchainConfigFile = function() {
Config.prototype.loadContractsConfigFile = function() {
var defaultVersions = {
"web3": "1.0.0-beta",
"web3": "1.2.1",
"solc": "0.5.0"
};
var versions = recursiveMerge(defaultVersions, this.embarkConfig.versions || {});

View File

@ -58,7 +58,7 @@ class Engine {
}
registerModulePackage(moduleName, options) {
this.plugins.loadInternalPlugin(moduleName, options || {}, true);
return this.plugins.loadInternalPlugin(moduleName, options || {}, true);
}
startService(serviceName, _options) {
@ -300,7 +300,7 @@ class Engine {
}
libraryManagerService(_options) {
this.registerModulePackage('embark-library-manager', {useDashboard: this.useDashboard});
return this.registerModulePackage('embark-library-manager', {useDashboard: this.useDashboard});
}
codeCoverageService(_options) {

View File

@ -114,7 +114,7 @@ Plugin.prototype.loadInternalPlugin = function() {
this.pluginModule = this.pluginModule.default;
}
}
new this.pluginModule(this, this.pluginConfig); /*eslint no-new: "off"*/
return new this.pluginModule(this, this.pluginConfig); /*eslint no-new: "off"*/
};
Plugin.prototype.loadPluginFile = function(filename) {

View File

@ -93,8 +93,9 @@ Plugins.prototype.loadInternalPlugin = function(pluginName, pluginConfig, isPack
context: this.context,
env: this.env
});
pluginWrapper.loadInternalPlugin();
const pluginInstance = pluginWrapper.loadInternalPlugin();
this.plugins.push(pluginWrapper);
return pluginInstance;
};
Plugins.prototype.loadPlugin = function(pluginName, pluginConfig) {

View File

@ -122,7 +122,7 @@ describe('embark.Config', function () {
it('should load contract config correctly', function () {
config.loadContractsConfigFile();
let expectedConfig = {
versions: {'web3': '1.0.0-beta', solc: '0.5.0'},
versions: {'web3': '1.2.1', solc: '0.5.0'},
deployment: {host: 'localhost', port: 8545, type: 'rpc', "accounts": [{"mnemonic": "12 word mnemonic", "balance": "5000000000"}]},
dappConnection: ['$WEB3', 'localhost:8545'],
dappAutoEnable: true,
@ -145,7 +145,7 @@ describe('embark.Config', function () {
it('should replace occourences of `0x0` with full zero addresses', () => {
let expectedConfig = {
versions: {'web3': '1.0.0-beta', solc: '0.5.0'},
versions: {'web3': '1.2.1', solc: '0.5.0'},
deployment: {host: 'localhost', port: 8545, type: 'rpc'},
dappConnection: ['$WEB3', 'localhost:8545'],
dappAutoEnable: true,

View File

@ -89,7 +89,7 @@ describe('embark.Contracts', function() {
contractsConfig = {
"versions": {
"web3.js": "1.0.0-beta",
"web3": "1.2.1",
"solc": "0.4.17"
},
"deployment": {
@ -213,7 +213,7 @@ describe('embark.Contracts', function() {
contractsConfig = {
"versions": {
"web3.js": "1.0.0-beta",
"web3": "1.2.1",
"solc": "0.4.17"
},
"deployment": {

View File

@ -53,7 +53,7 @@
"@babel/runtime-corejs2": "7.3.1",
"embarkjs": "^4.1.0-beta.5",
"eth-ens-namehash": "2.0.8",
"web3": "1.0.0-beta.37"
"web3": "1.2.1"
},
"devDependencies": {
"@babel/cli": "7.2.3",

View File

@ -51,7 +51,7 @@
},
"dependencies": {
"@babel/runtime-corejs2": "7.3.1",
"web3": "1.0.0-beta.37"
"web3": "1.2.1"
},
"devDependencies": {
"@babel/cli": "7.2.3",

View File

@ -52,7 +52,7 @@
"dependencies": {
"@babel/runtime-corejs2": "7.3.1",
"rxjs": "6.4.0",
"web3": "1.0.0-beta.37"
"web3": "1.2.1"
},
"devDependencies": {
"@babel/cli": "7.2.3",

View File

@ -2,7 +2,7 @@
let Web3 = require('web3');
const {sendMessage, listenTo} = require('./communicationFunctions').default;
// for the whisper v5 and web3.js 1.0
// for the whisper v5 and web3.js 1.x
let __embarkWhisperNewWeb3 = {};
__embarkWhisperNewWeb3.real_sendMessage = sendMessage;

View File

@ -73,7 +73,7 @@
"nyc": "13.1.0",
"rimraf": "2.6.3",
"source-map-support": "0.5.9",
"web3": "1.0.0-beta.37"
"web3": "1.2.1"
},
"engines": {
"node": ">=8.12.0 <12.0.0",

View File

@ -25,7 +25,7 @@ EmbarkJS.Contract = function() {
throw new Error('EmbarkJS.Contract is deprecated: please use EmbarkJS.Blockchain.Contract instead');
};
EmbarkJS.isNewWeb3 = function() {
throw new Error('EmbarkJS.isNewWeb3 is deprecated: only Web3 1.0 is supported now');
throw new Error('EmbarkJS.isNewWeb3 is deprecated: only Web3 >=1.2.1 is supported now');
};
export default EmbarkJS;

View File

@ -1,4 +1,6 @@
/* global Web3 clearInterval setInterval */
/* global clearInterval global require setInterval */
const Web3 = global.Web3 || require('web3');
let Utils = {
fromAscii: function(str) {

View File

@ -22,7 +22,7 @@ Every application [created with Embark](create_project.html) comes with an `emba
"generationDir": "embarkArtifacts",
"config": "config/",
"versions": {
"web3": "1.0.0-beta",
"web3": "1.2.1",
"solc": "0.4.25",
"ipfs-api": "17.2.4"
},

View File

@ -90,7 +90,7 @@ This will request account access and if the user grants access to his accounts,
### Components
* [EmbarkJS.Contract](contracts_javascript.html) - To interact with smart contracts. Typically Embark automatically initializes all your deployed contracts with this. uses web3.js 1.0
* [EmbarkJS.Contract](contracts_javascript.html) - To interact with smart contracts. Typically Embark automatically initializes all your deployed contracts with this. uses web3.js 1.2.1
* [EmbarkJS.Storage](storage_javascript.html) - To interact with the configured decentralized storage. Includes bindings to save & retrieve data, upload & download files, etc..
* [EmbarkJS.Communication](messages_javascript.html) - To interact with the configured decentralized messages system. Includes bindings to listen to topics and send messages.
* [EmbarkJS.Names](naming_javascript.html) - To interact with the configured decentralized naming system such as ENS. Includes bindings to look up the address of a domain name as well as retrieve a domain name given an address.

View File

@ -62,7 +62,7 @@ By default, the value of `dappAutoEnable` is `true` which means that Embark will
If we want more control over when our application should request account access, we can set `dappAutoEnable` to false and make use of `EmbarkJS.enableEthereum()`.
This method will essentially cause our application to request account access, giving us full control over when this should happen.
This method will essentially cause our application to request account access, giving us full control over when this should happen.
```
try {
@ -77,9 +77,7 @@ try {
This guide only touched on getting started with EmbarkJS. There are many more APIs to explore, depending on what we're achieving to build. Have a look at the dedicated guides to learn more:
* [EmbarkJS.Contract](contracts_javascript.html) - To interact with smart contracts. Typically Embark automatically initializes all your deployed contracts with this. uses web3.js 1.0
* [EmbarkJS.Contract](contracts_javascript.html) - To interact with smart contracts. Typically Embark automatically initializes all your deployed contracts with this. uses web3.js 1.2.1
* [EmbarkJS.Storage](storage_javascript.html) - To interact with the configured decentralized storage. Includes bindings to save & retrieve data, upload & download files, etc..
* [EmbarkJS.Communication](messages_javascript.html) - To interact with the configured decentralized messages system. Includes bindings to listen to topics and send messages.
* [EmbarkJS.Names](naming_javascript.html) - To interact with the configured decentralized naming system such as ENS. Includes bindings to look up the address of a domain name as well as retrieve a domain name given an address.

View File

@ -36,5 +36,4 @@ SimpleStorage.methods.get().call().then(function(value) { console.log(value) });
SimpleStorage.methods.storedData().call().then(function(value) { console.log(value) });
```
The syntax used is <a href="http://web3js.readthedocs.io/en/1.0/" target="_blank">web3.js 1.0</a>
The syntax used is <a href="https://web3js.readthedocs.io/en/v1.2.1/" target="_blank">web3.js 1.2.1</a>

View File

@ -1,5 +1,4 @@
title: Web3.js Documentation
---
The documentation for Web3.js can be found [here](http://web3js.readthedocs.io/en/1.0/)
The documentation for Web3.js can be found [here](https://web3js.readthedocs.io/en/v1.2.1/)

1411
yarn.lock

File diff suppressed because it is too large Load Diff