add published doc to swarm to the swarm explorer

pull/3094/head
yann300 7 years ago
parent eaa0626cd7
commit a12248399e
  1. 3
      src/app.js
  2. 11
      src/app/contract/publishOnSwarm.js
  3. 3
      src/app/tabs/compile-tab.js

@ -553,6 +553,9 @@ function run () {
fileProviderOf: (path) => {
return fileManager.fileProviderOf(path)
},
fileProvider: (name) => {
return self._api.filesProviders[name]
},
getBalance: (address, callback) => {
udapp.getBalance(address, (error, balance) => {
if (error) {

@ -3,10 +3,14 @@
var async = require('async')
var swarmgw = require('swarmgw')
module.exports = (contract, appAPI, cb) => {
module.exports = (contract, appAPI, cb, swarmVerifiedPublishCallBack) => {
// gather list of files to publish
var sources = []
try {
contract.metadata = JSON.stringify(JSON.parse(contract.metadata), null, '\t')
} catch (e) {}
sources.push({
content: contract.metadata,
hash: contract.metadataHash
@ -49,7 +53,10 @@ module.exports = (contract, appAPI, cb) => {
} else {
// publish the list of sources in order, fail if any failed
async.eachSeries(sources, function (item, cb) {
swarmVerifiedPublish(item.content, item.hash, cb)
swarmVerifiedPublish(item.content, item.hash, (error) => {
if (!error && swarmVerifiedPublishCallBack) swarmVerifiedPublishCallBack(item)
cb(error)
})
}, cb)
}
})

@ -436,6 +436,9 @@ function compileTab (container, appAPI, appEvents, opts) {
} else {
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)
appAPI.fileProvider('swarm').addReadOnly(item.hash, item.content)
})
}
}

Loading…
Cancel
Save