fix publish on Swarm

pull/1/head
yann300 6 years ago
parent 6dade5bf8d
commit 8327506ec0
  1. 4
      src/app/contract/publishOnSwarm.js
  2. 8
      src/app/tabs/compile-tab.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 {

@ -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`<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)
self._api.fileProvider('swarm').addReadOnly(item.hash, item.content)
self._deps.swarmfileProvider.addReadOnly(item.hash, item.content)
})
}
}

Loading…
Cancel
Save