diff --git a/packages/embark/src/lib/modules/ipfs/index.js b/packages/embark/src/lib/modules/ipfs/index.js index 642f89265..523b908c7 100644 --- a/packages/embark/src/lib/modules/ipfs/index.js +++ b/packages/embark/src/lib/modules/ipfs/index.js @@ -195,8 +195,13 @@ class IPFS { } isIpfsStorageEnabledInTheConfig() { - let {enabled, available_providers, dappConnection} = this.storageConfig; - return enabled && (available_providers.indexOf('ipfs') > 0 || dappConnection.find(c => c.provider === 'ipfs')); + let {enabled, available_providers, dappConnection, upload} = this.storageConfig; + return enabled && + available_providers.includes('ipfs') && + ( + dappConnection.some(c => c.provider === 'ipfs') || + upload.provider === 'ipfs' + ); } } diff --git a/packages/embark/src/lib/modules/swarm/index.js b/packages/embark/src/lib/modules/swarm/index.js index a03f439e0..3e1743425 100644 --- a/packages/embark/src/lib/modules/swarm/index.js +++ b/packages/embark/src/lib/modules/swarm/index.js @@ -26,7 +26,9 @@ class Swarm { if(this.isSwarmEnabledInTheConfig() && cantDetermineUrl){ console.warn('\n===== Swarm module will not be loaded ====='); console.warn(`Swarm is enabled in the config, however the config is not setup to provide a URL for swarm and therefore the Swarm module will not be loaded. Please either change the ${'config/storage > upload'.bold} setting to Swarm or add the Swarm config to the ${'config/storage > dappConnection'.bold} array. Please see ${'https://embark.status.im/docs/storage_configuration.html'.underline} for more information.\n`); - } else { + return; + } + if (!this.isSwarmEnabledInTheConfig()) { this.embark.registerConsoleCommand({ matches: cmd => cmd === "swarm" || cmd.indexOf('swarm ') === 0, process: (_cmd, cb) => { @@ -34,7 +36,6 @@ class Swarm { cb(); } }); - return; } @@ -42,7 +43,6 @@ class Swarm { this.getUrl = this.storageConfig.upload.getUrl || this.providerUrl + '/bzz:/'; - this.swarm = new SwarmAPI({gateway: this.providerUrl}); this.setServiceCheck(); @@ -163,8 +163,13 @@ class Swarm { } isSwarmEnabledInTheConfig() { - let {enabled, available_providers, dappConnection} = this.storageConfig; - return enabled && (available_providers.indexOf('swarm') > 0 || dappConnection.find(c => c.provider === 'swarm')); + let {enabled, available_providers, dappConnection, upload} = this.storageConfig; + return enabled && + available_providers.includes('swarm') && + ( + dappConnection.some(c => c.provider === 'swarm') || + upload.provider === "swarm" + ); } }