Commit 8327506e authored by yann300's avatar yann300

fix publish on Swarm

parent 6dade5bf
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
var async = require('async') var async = require('async')
var swarmgw = require('swarmgw') var swarmgw = require('swarmgw')
module.exports = (contract, appAPI, cb, swarmVerifiedPublishCallBack) => { module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => {
// gather list of files to publish // gather list of files to publish
var sources = [] var sources = []
...@@ -32,7 +32,7 @@ module.exports = (contract, appAPI, cb, swarmVerifiedPublishCallBack) => { ...@@ -32,7 +32,7 @@ module.exports = (contract, appAPI, cb, swarmVerifiedPublishCallBack) => {
return cb('Metadata inconsistency') return cb('Metadata inconsistency')
} }
appAPI.fileProviderOf(fileName).get(fileName, (error, content) => { fileManager.fileProviderOf(fileName).get(fileName, (error, content) => {
if (error) { if (error) {
console.log(error) console.log(error)
} else { } else {
......
...@@ -37,7 +37,9 @@ module.exports = class CompileTab { ...@@ -37,7 +37,9 @@ module.exports = class CompileTab {
editor: self._components.registry.get('editor').api, editor: self._components.registry.get('editor').api,
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
compiler: self._components.registry.get('compiler').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 = { self.data = {
hideWarnings: self._deps.config.get('hideWarnings') || false, hideWarnings: self._deps.config.get('hideWarnings') || false,
...@@ -304,7 +306,7 @@ module.exports = class CompileTab { ...@@ -304,7 +306,7 @@ module.exports = class CompileTab {
if (contract.metadata === undefined || contract.metadata.length === 0) { if (contract.metadata === undefined || contract.metadata.length === 0) {
modalDialogCustom.alert('This contract does not implement all functions and thus cannot be published.') modalDialogCustom.alert('This contract does not implement all functions and thus cannot be published.')
} else { } else {
publishOnSwarm(contract, self._api, function (err) { publishOnSwarm(contract, self._deps.fileManager, function (err) {
if (err) { if (err) {
try { try {
err = JSON.stringify(err) err = JSON.stringify(err)
...@@ -315,7 +317,7 @@ module.exports = class CompileTab { ...@@ -315,7 +317,7 @@ module.exports = class CompileTab {
modalDialogCustom.alert(yo`<span>Metadata published successfully.<br />The Swarm address of the metadata file is available in the contract details.</span>`) modalDialogCustom.alert(yo`<span>Metadata published successfully.<br />The Swarm address of the metadata file is available in the contract details.</span>`)
} }
}, function (item) { // triggered each time there's a new verified publish (means hash correspond) }, 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)
}) })
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment