fix publish on swarm

pull/3094/head
yann300 6 years ago
parent 7b66aec43f
commit 76ecb3aba4
  1. 15
      src/app/contract/publishOnSwarm.js
  2. 6
      src/app/files/basicReadOnlyExplorer.js
  3. 3
      src/app/files/file-explorer.js
  4. 7
      src/app/files/styles/file-explorer-styles.js
  5. 2
      src/app/tabs/compile-tab.js

@ -47,6 +47,11 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => {
var uploaded = []
async.eachSeries(sources, function (item, cb) {
swarmVerifiedPublish(item.content, item.hash, (error, result) => {
try {
item.hash = result.url.match('bzz-raw://(.+)')[1]
} catch (e) {
item.hash = '<Metadata inconsistency> - ' + item.fileName
}
if (!error && swarmVerifiedPublishCallBack) swarmVerifiedPublishCallBack(item)
item.output = result
uploaded.push(item)
@ -55,10 +60,16 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => {
cb(error)
})
}, () => {
swarmVerifiedPublish(JSON.stringify(metadata), '', (error, result) => {
const metadataContent = JSON.stringify(metadata)
swarmVerifiedPublish(metadataContent, '', (error, result) => {
try {
contract.metadataHash = result.url.match('bzz-raw://(.+)')[1]
} catch (e) {
contract.metadataHash = '<Metadata inconsistency> - metadata.json'
}
if (!error && swarmVerifiedPublishCallBack) {
swarmVerifiedPublishCallBack({
content: contract.metadata,
content: metadataContent,
hash: contract.metadataHash
})
}

@ -41,13 +41,13 @@ class BasicReadOnlyExplorer {
}
set (path, content, cb) {
var unprefixedPath = this.removePrefix(path)
this.addReadOnly(unprefixedPath, content)
this.addReadOnly(path, content)
if (cb) cb()
return true
}
addReadOnly (path, content, rawPath) {
path = this.removePrefix(path)
try { // lazy try to format JSON
content = JSON.stringify(JSON.parse(content), null, '\t')
} catch (e) {}
@ -67,7 +67,7 @@ class BasicReadOnlyExplorer {
this.paths[this.type][split] = { isDirectory: folder }
this.files[path] = content
this.normalizedNames[rawPath] = path
this.event.trigger('fileAdded', [path, true])
this.event.trigger('fileAdded', [this.type + '/' + path, true])
return true
}

@ -158,7 +158,8 @@ function fileExplorer (localRegistry, files, menuItems) {
return yo`
<div class="${css.items}">
<label
class=${css.label}
title="${data.path}"
class="${css.label} ${!isRoot ? css.leaf : ''}"
data-path="${data.path}"
style="${isRoot ? 'font-weight:bold;' : ''}"
onkeydown=${editModeOff}

@ -2,7 +2,12 @@ var csjs = require('csjs-inject')
var css = csjs`
.label {
margin-top : 4px
margin-top : 4px;
}
.leaf {
overflow : hidden;
text-overflow : ellipsis;
width : 90%;
}
.fileexplorer {
box-sizing : border-box;

@ -259,7 +259,7 @@ class CompileTab extends CompilerApi {
modalDialogCustom.alert(yo`<span>Metadata published successfully.<br> <pre>${result}</pre> </span>`)
}
}, (item) => { // triggered each time there's a new verified publish (means hash correspond)
this.swarmfileProvider.addReadOnly(item.hash, item.content)
this.swarmfileProvider.addReadOnly('swarm/' + item.hash, item.content)
})
}
}

Loading…
Cancel
Save