Removed p-iteration from embark altogether.

Replaced usage in storage module (on dapp side) with async.js `detectSeries`
This commit is contained in:
emizzle 2018-06-27 10:45:46 +10:00
parent 4b693867b1
commit 9f33a05d82
10 changed files with 2999 additions and 3026 deletions

View File

@ -245,7 +245,7 @@ Config.prototype.loadExternalContractsFiles = function() {
};
Config.prototype.loadStorageConfigFile = function() {
var versions = utils.recursiveMerge({"ipfs-api": "17.2.4", "p-iteration": "1.1.7"}, this.embarkConfig.versions || {});
var versions = utils.recursiveMerge({"ipfs-api": "17.2.4"}, this.embarkConfig.versions || {});
var configObject = {
"default": {

View File

@ -90,15 +90,6 @@ class IPFS {
}
});
self.events.request("version:get:p-iteration", function(pIterationVersion) {
let currentPIterationVersion = require('../../../package.json').dependencies["p-iteration"];
if (pIterationVersion !== currentPIterationVersion) {
self.events.request("version:getPackageLocation", "p-iteration", pIterationVersion, function(err, location) {
self.embark.registerImportFile("p-iteration", fs.dappPath(location));
});
}
});
let code = "";
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkIPFS);";

View File

@ -1,21 +1,21 @@
/* global EmbarkJS */
import {findSeries} from 'p-iteration';
import {detectSeries} from 'async';
let __embarkStorage = {};
__embarkStorage.setProviders = async function (dappConnOptions) {
try {
let workingConnFound = await findSeries(dappConnOptions, async (dappConn) => {
await detectSeries(dappConnOptions, async (dappConn, callback) => {
if(dappConn === '$BZZ' || dappConn.provider === 'swarm'){
let options = dappConn;
if(dappConn === '$BZZ') options = {"useOnlyGivenProvider": true};
try{
await EmbarkJS.Storage.setProvider('swarm', options);
let isAvailable = await EmbarkJS.Storage.isAvailable();
return isAvailable;
callback(null, isAvailable);
}catch(err){
return false; // catch errors for when bzz object not initialised but config has requested it to be used
callback(null, false); // catch errors for when bzz object not initialised but config has requested it to be used
}
}
else if(dappConn.provider === 'ipfs') {
@ -23,13 +23,14 @@ __embarkStorage.setProviders = async function (dappConnOptions) {
try{
await EmbarkJS.Storage.setProvider('ipfs', dappConn);
let isAvailable = await EmbarkJS.Storage.isAvailable();
return isAvailable;
callback(null, isAvailable);
} catch(err) {
return false;
callback(null, false); // catch but keep looping by not passing err to callback
}
}
}, function(err, result){
if(!result) throw new Error('Could not connect to a storage provider using any of the dappConnections in the storage config');
});
if(!workingConnFound) throw new Error('Could not connect to a storage provider using any of the dappConnections in the storage config');
} catch (err) {
throw new Error('Failed to connect to a storage provider: ' + err.message);
}

View File

@ -76,18 +76,6 @@ class Swarm {
return;
}
this.events.request("version:get:p-iteration", function(pIterationVersion) {
let currentPIterationVersion = require('../../../package.json').dependencies["p-iteration"];
if (pIterationVersion !== currentPIterationVersion) {
self.events.request("version:getPackageLocation", "p-iteration", pIterationVersion, function(err, location) {
if(err){
return self.logger.error("Error getting package location for p-iteration: " + err);
}
self.embark.registerImportFile("p-iteration", fs.dappPath(location));
});
}
});
let code = "";
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
code += "\nEmbarkJS.Storage.registerProvider('swarm', __embarkSwarm);";

View File

@ -23,12 +23,10 @@ class LibraryManager {
let solcVersionInConfig = this.contractsConfig.versions.solc;
let web3VersionInConfig = this.contractsConfig.versions["web3"];
let ipfsApiVersion = this.storageConfig.versions["ipfs-api"];
let pIterationVersion = this.storageConfig.versions["p-iteration"];
this.versions['solc'] = solcVersionInConfig;
this.versions['web3'] = web3VersionInConfig;
this.versions['ipfs-api'] = ipfsApiVersion;
this.versions['p-iteration'] = pIterationVersion;
Object.keys(this.versions).forEach(versionKey => {
const newVersion = this.versions[versionKey].trim();

5973
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,7 @@
"css-loader": "^0.28.11",
"deep-equal": "^1.0.1",
"ejs": "^2.5.8",
"embark-web3-provider-engine": "14.0.7",
"eth-ens-namehash": "^2.0.8",
"eth-lib": "^0.2.8",
"ethereumjs-wallet": "^0.6.0",
@ -60,7 +61,6 @@
"node-ipc": "^9.1.1",
"ora": "^2.1.0",
"os-locale": "^2.1.0",
"p-iteration": "^1.1.7",
"parse-json": "^4.0.0",
"promptly": "^2.1.0",
"propose": "0.0.5",
@ -79,7 +79,6 @@
"uuid": "^3.2.1",
"viz.js": "^1.8.1",
"web3": "1.0.0-beta.34",
"embark-web3-provider-engine": "14.0.7",
"webpack": "^3.10.0",
"window-size": "^1.1.0"
},

View File

@ -11,8 +11,7 @@
"versions": {
"web3": "1.0.0-beta",
"solc": "0.4.24",
"ipfs-api": "17.2.4",
"p-iteration": "1.1.7"
"ipfs-api": "17.2.4"
},
"plugins": {}
}

View File

@ -10,8 +10,7 @@
"versions": {
"web3": "1.0.0-beta",
"solc": "0.4.24",
"ipfs-api": "17.2.4",
"p-iteration": "1.1.7"
"ipfs-api": "17.2.4"
},
"plugins": {
}

View File

@ -17,8 +17,7 @@
"versions": {
"solc": "0.4.24",
"web3": "1.0.0-beta.34",
"ipfs-api": "17.2.7",
"p-iteration": "1.1.7"
"ipfs-api": "17.2.7"
},
"plugins": {
"embark-service": {}