diff --git a/src/app/tabs/runTab/contractDropdown.js b/src/app/tabs/runTab/contractDropdown.js
index 18f5ad7dce..e34585f14d 100644
--- a/src/app/tabs/runTab/contractDropdown.js
+++ b/src/app/tabs/runTab/contractDropdown.js
@@ -56,12 +56,10 @@ class ContractDropdownUI {
this.createPanel = yo`
`
this.orLabel = yo`or
`
- const ipfsCheckbox = this.ipfsCheckedState ?
- yo``
- :
- yo` {
- if(!this.ipfsCheckedState){
- publishToStorage('ipfs', this.runView.fileProvider, this.runView.fileManager, this.getSelectedContract.call(this))
+ const ipfsCheckbox = this.ipfsCheckedState ? yo``
+ : yo` {
+ if (!this.ipfsCheckedState) {
+ publishToStorage('ipfs', this.runView.fileProvider, this.runView.fileManager, this.getSelectedContract.apply(this))
this.ipfsCheckedState = true
}
}}>`
diff --git a/src/publishToStorage.js b/src/publishToStorage.js
index b8997f48d8..fc9684ea12 100644
--- a/src/publishToStorage.js
+++ b/src/publishToStorage.js
@@ -4,28 +4,28 @@ const publishOnIpfs = require('./lib/publishOnIpfs')
const modalDialogCustom = require('./app/ui/modal-dialog-custom')
export default function publish (storage, fileProvider, fileManager, contract) {
- if (contract) {
- if (contract.metadata === undefined || contract.metadata.length === 0) {
- modalDialogCustom.alert('This contract may be abstract, may not implement an abstract parent\'s methods completely or not invoke an inherited contract\'s constructor correctly.')
+ if (contract) {
+ if (contract.metadata === undefined || contract.metadata.length === 0) {
+ modalDialogCustom.alert('This contract may be abstract, may not implement an abstract parent\'s methods completely or not invoke an inherited contract\'s constructor correctly.')
+ } else {
+ if (storage === 'swarm') {
+ publishOnSwarm(contract, fileManager, function (err, uploaded) {
+ if (err) {
+ try {
+ err = JSON.stringify(err)
+ } catch (e) {}
+ modalDialogCustom.alert(yo`Failed to publish metadata file to swarm, please check the Swarm gateways is available ( swarm-gateways.net ).
+ ${err}`)
+ } else {
+ var result = yo`${uploaded.map((value) => {
+ return yo`
${value.filename} :
${value.output.url}
`
+ })}
`
+ modalDialogCustom.alert(yo`Metadata published successfully.
${result}
`)
+ }
+ }, (item) => { // triggered each time there's a new verified publish (means hash correspond)
+ fileProvider.addExternal('swarm/' + item.hash, item.content)
+ })
} else {
- if (storage === 'swarm') {
- publishOnSwarm(contract, fileManager, function (err, uploaded) {
- if (err) {
- try {
- err = JSON.stringify(err)
- } catch (e) {}
- modalDialogCustom.alert(yo`Failed to publish metadata file to swarm, please check the Swarm gateways is available ( swarm-gateways.net ).
- ${err}`)
- } else {
- var result = yo`${uploaded.map((value) => {
- return yo`
${value.filename} :
${value.output.url}
`
- })}
`
- modalDialogCustom.alert(`Published ${contract.name}'s Metadata`, yo`Metadata of "${contract.name.toLowerCase()}" was published successfully.
${result}
`)
- }
- }, (item) => { // triggered each time there's a new verified publish (means hash correspond)
- fileProvider.addExternal('swarm/' + item.hash, item.content)
- })
- } else {
publishOnIpfs(contract, fileManager, function (err, uploaded) {
if (err) {
try {
@@ -45,4 +45,4 @@ export default function publish (storage, fileProvider, fileManager, contract) {
}
}
}
- }
\ No newline at end of file
+ }