From 8327506ec0296f72e76446eb5929083ea4f7548b Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 4 Jul 2018 17:29:30 +0200 Subject: [PATCH] fix publish on Swarm --- src/app/contract/publishOnSwarm.js | 4 ++-- src/app/tabs/compile-tab.js | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/app/contract/publishOnSwarm.js b/src/app/contract/publishOnSwarm.js index 0c2692a801..239d4344ff 100644 --- a/src/app/contract/publishOnSwarm.js +++ b/src/app/contract/publishOnSwarm.js @@ -3,7 +3,7 @@ var async = require('async') var swarmgw = require('swarmgw') -module.exports = (contract, appAPI, cb, swarmVerifiedPublishCallBack) => { +module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => { // gather list of files to publish var sources = [] @@ -32,7 +32,7 @@ module.exports = (contract, appAPI, cb, swarmVerifiedPublishCallBack) => { return cb('Metadata inconsistency') } - appAPI.fileProviderOf(fileName).get(fileName, (error, content) => { + fileManager.fileProviderOf(fileName).get(fileName, (error, content) => { if (error) { console.log(error) } else { diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index 756ff3421a..4de77bfd16 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -37,7 +37,9 @@ module.exports = class CompileTab { editor: self._components.registry.get('editor').api, config: self._components.registry.get('config').api, compiler: self._components.registry.get('compiler').api, - renderer: self._components.registry.get('renderer').api + renderer: self._components.registry.get('renderer').api, + swarmfileProvider: self._components.registry.get('fileproviders/swarm').api, + fileManager: self._components.registry.get('filemanager').api } self.data = { hideWarnings: self._deps.config.get('hideWarnings') || false, @@ -304,7 +306,7 @@ module.exports = class CompileTab { if (contract.metadata === undefined || contract.metadata.length === 0) { modalDialogCustom.alert('This contract does not implement all functions and thus cannot be published.') } else { - publishOnSwarm(contract, self._api, function (err) { + publishOnSwarm(contract, self._deps.fileManager, function (err) { if (err) { try { err = JSON.stringify(err) @@ -315,7 +317,7 @@ module.exports = class CompileTab { modalDialogCustom.alert(yo`Metadata published successfully.
The Swarm address of the metadata file is available in the contract details.
`) } }, function (item) { // triggered each time there's a new verified publish (means hash correspond) - self._api.fileProvider('swarm').addReadOnly(item.hash, item.content) + self._deps.swarmfileProvider.addReadOnly(item.hash, item.content) }) } }