diff --git a/lib/modules/ipfs/embarkjs/default.js b/lib/modules/ipfs/embarkjs/default.js
index a764ca54b..1334d069f 100644
--- a/lib/modules/ipfs/embarkjs/default.js
+++ b/lib/modules/ipfs/embarkjs/default.js
@@ -4,9 +4,9 @@ let __embarkIPFS = {};
__embarkIPFS.setProvider = function (options) {
var self = this;
- var promise = new Promise(function (resolve, reject) {
+ return new Promise(function (resolve, reject) {
try {
- if (options === undefined) {
+ if (!options) {
self._config = options;
self._ipfsConnection = IpfsApi('localhost', '5001');
self._getUrl = "http://localhost:8080/ipfs/";
@@ -28,7 +28,6 @@ __embarkIPFS.setProvider = function (options) {
reject(new Error('Failed to connect to IPFS'));
}
});
- return promise;
};
__embarkIPFS.isAvailable = function () {
diff --git a/lib/modules/ipfs/index.js b/lib/modules/ipfs/index.js
index 3ecf3259a..b870ef0ea 100644
--- a/lib/modules/ipfs/index.js
+++ b/lib/modules/ipfs/index.js
@@ -19,12 +19,12 @@ class IPFS {
this.webServerConfig = embark.config.webServerConfig;
this.blockchainConfig = embark.config.blockchainConfig;
- if (this.isIpfsEnabledInTheConfig() || this.isIpnsEnabledInTheConfig()) {
+ if (this.isIpfsStorageEnabledInTheConfig() || this.isIpfsNameEnabledInTheConfig()) {
this.downloadIpfsApi();
this.addDefaultToEmbarkJS();
}
- if (this.isIpfsEnabledInTheConfig()) {
+ if (this.isIpfsStorageEnabledInTheConfig()) {
this.setServiceCheck();
this.addStorageProviderToEmbarkJS();
this.addObjectToConsole();
@@ -39,7 +39,7 @@ class IPFS {
});
}
- if (this.isIpnsEnabledInTheConfig()) {
+ if (this.isIpfsNameEnabledInTheConfig()) {
this.addNamesystemProviderToEmbarkJS();
this.setNamesystemProvider();
}
@@ -156,12 +156,12 @@ class IPFS {
});
}
- isIpfsEnabledInTheConfig() {
+ isIpfsStorageEnabledInTheConfig() {
let {enabled, available_providers, dappConnection} = this.storageConfig;
return enabled && (available_providers.indexOf('ipfs') > 0 || dappConnection.find(c => c.provider === 'ipfs'));
}
- isIpnsEnabledInTheConfig() {
+ isIpfsNameEnabledInTheConfig() {
let {enabled, available_providers} = this.namesystemConfig;
return enabled && available_providers.indexOf('ipns') > 0;
}
diff --git a/package-lock.json b/package-lock.json
index ebf345ace..36bf94570 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3917,7 +3917,7 @@
}
},
"embarkjs": {
- "version": "file:../EmbarkJS",
+ "version": "0.3.1",
"requires": {
"@babel/runtime": "^7.0.0-beta.54",
"async": "^2.0.1"
diff --git a/package.json b/package.json
index 032264298..2236901c0 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
"decompress": "^4.2.0",
"deep-equal": "^1.0.1",
"ejs": "^2.5.8",
- "embarkjs": "file:../EmbarkJS",
+ "embarkjs": "^0.3.1",
"eth-ens-namehash": "^2.0.8",
"eth-lib": "^0.2.8",
"ethereumjs-wallet": "0.6.0",
diff --git a/templates/demo/app/components/storage.js b/templates/demo/app/components/storage.js
index 6f3803b69..dbd828b77 100644
--- a/templates/demo/app/components/storage.js
+++ b/templates/demo/app/components/storage.js
@@ -18,8 +18,8 @@ class Storage extends React.Component {
url: '',
logs: [],
storageError: '',
- ipfsHash: '',
- ipnsResolveName: '',
+ valueRegister: '',
+ valueResolver: '',
};
}
@@ -101,34 +101,45 @@ class Storage extends React.Component {
ipnsRegister(e) {
e.preventDefault();
- this.setState({ ipnsRegistering: true });
- EmbarkJS.Names.register(this.state.ipfsHash, (err, name) => {
+ this.setState({ registering: true, responseRegister: false });
+ this.addToLog("EmbarkJS.Names.register(this.state.ipfsHash).then(function(hash) { })");
+ EmbarkJS.Names.register(this.state.valueRegister, (err, name) => {
+ let responseRegister;
+ let isRegisterError = false;
if (err) {
- console.log("Name Register Error => " + err.message);
+ isRegisterError = true;
+ responseRegister = "Name Register Error: " + err.message
+ } else {
+ responseRegister = name;
}
this.setState({
- ipnsResolveName: name,
- ipnsName: name,
- ipnsRegistering: false
+ responseRegister: responseRegister,
+ registering: false,
+ isRegisterError: isRegisterError
});
- this.addToLog("EmbarkJS.Names.register(this.state.ipfsHash).then(function(hash) { })");
});
}
ipnsResolve(e) {
e.preventDefault();
- this.setState({ ipnsResolving: true });
- EmbarkJS.Names.resolve(this.state.ipnsName, (err, path) => {
+ this.setState({ resolving: true, responseResolver: false });
+ this.addToLog("EmbarkJS.Names.resolve(this.state.ipnsName, function(err, path) { })");
+ EmbarkJS.Names.resolve(this.state.valueResolver, (err, path) => {
+ let responseResolver;
+ let isResolverError = false;
if (err) {
- console.log("Name Resolve Error => " + err.message);
+ isResolverError = true;
+ responseResolver = "Name Resolve Error: " + err.message
+ } else {
+ responseResolver = path;
}
this.setState({
- ipfsPath: path,
- ipnsResolving: false
+ responseResolver: responseResolver,
+ resolving: false,
+ isResolverError: isResolverError
});
- this.addToLog("EmbarkJS.Names.resolve(this.state.ipnsName, function(err, path) { })");
});
}
@@ -201,13 +212,16 @@ class Storage extends React.Component {
this.handleChange(e, 'ipfsHash')}/>
+ value={this.state.valueRegister}
+ onChange={e => this.handleChange(e, 'valueRegister')}/>
It will take around 1 minute
- registered at: {this.state.ipnsName}
+ {this.state.responseRegister &&
+
+ {this.state.responseRegister}
+ }
@@ -216,13 +230,16 @@ class Storage extends React.Component {
this.handleChange(e, 'ipnsResolveName')}/>
+ value={this.state.valueResolver}
+ onChange={e => this.handleChange(e, 'valueResolver')}/>
It will take around 1 minute
- IPFS path: {this.state.ipfsPath}
+ {this.state.responseResolver &&
+
+ {this.state.responseResolver}
+ }
diff --git a/templates/demo/app/dapp.js b/templates/demo/app/dapp.js
index 2d15567f5..c48ab0bdb 100644
--- a/templates/demo/app/dapp.js
+++ b/templates/demo/app/dapp.js
@@ -61,9 +61,9 @@ class App extends React.Component {
}
handleSelect(key) {
- if (key == 2) {
+ if (key === 2) {
EmbarkJS.Names.setProvider('ipns', {server: 'localhost', port: '5001'});
- } else if (key == 4) {
+ } else if (key === 4) {
EmbarkJS.Names.currentNameSystems = this.state.ensNameSystems
}
this.setState({ activeKey: key });