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 = [] var uploaded = []
async.eachSeries(sources, function (item, cb) { async.eachSeries(sources, function (item, cb) {
swarmVerifiedPublish(item.content, item.hash, (error, result) => { 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) if (!error && swarmVerifiedPublishCallBack) swarmVerifiedPublishCallBack(item)
item.output = result item.output = result
uploaded.push(item) uploaded.push(item)
@ -55,10 +60,16 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => {
cb(error) 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) { if (!error && swarmVerifiedPublishCallBack) {
swarmVerifiedPublishCallBack({ swarmVerifiedPublishCallBack({
content: contract.metadata, content: metadataContent,
hash: contract.metadataHash hash: contract.metadataHash
}) })
} }

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

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

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

@ -259,7 +259,7 @@ class CompileTab extends CompilerApi {
modalDialogCustom.alert(yo`<span>Metadata published successfully.<br> <pre>${result}</pre> </span>`) 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) }, (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