@@ -122,6 +177,7 @@ class ContractDropdownUI {
selectedContract.bytecodeObject
)
this.createPanel.appendChild(createConstructorInstance.render())
+ this.createPanel.appendChild(this.deployCheckBox)
}
getSelectedContract () {
@@ -175,6 +231,9 @@ class ContractDropdownUI {
}
this.event.trigger('newContractInstanceAdded', [contractObject, address, contractObject.name])
+ if (this.ipfsCheckedState) {
+ publishToStorage('ipfs', this.runView.fileProvider, this.runView.fileManager, selectedContract)
+ }
}
let contractMetadata
diff --git a/src/app/tabs/runTab/model/dropdownlogic.js b/src/app/tabs/runTab/model/dropdownlogic.js
index 4ce649d177..c2dc932aa1 100644
--- a/src/app/tabs/runTab/model/dropdownlogic.js
+++ b/src/app/tabs/runTab/model/dropdownlogic.js
@@ -93,7 +93,8 @@ class DropdownLogic {
isOverSizeLimit: () => {
var deployedBytecode = contract.object.evm.deployedBytecode
return (deployedBytecode && deployedBytecode.object.length / 2 > 24576)
- }
+ },
+ metadata: contract.object.metadata
}
}
diff --git a/src/app/udapp/run-tab.js b/src/app/udapp/run-tab.js
index 49ed6537d6..7834364176 100644
--- a/src/app/udapp/run-tab.js
+++ b/src/app/udapp/run-tab.js
@@ -33,7 +33,7 @@ const profile = {
export class RunTab extends LibraryPlugin {
- constructor (blockchain, pluginUDapp, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView) {
+ constructor (blockchain, pluginUDapp, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView, fileProvider) {
super(pluginUDapp, profile)
this.event = new EventManager()
this.config = config
@@ -44,6 +44,7 @@ export class RunTab extends LibraryPlugin {
this.filePanel = filePanel
this.compilersArtefacts = compilersArtefacts
this.networkModule = networkModule
+ this.fileProvider = fileProvider
}
renderContainer () {
diff --git a/src/blockchain/blockchain.js b/src/blockchain/blockchain.js
index 2104306da6..0a572aa0a7 100644
--- a/src/blockchain/blockchain.js
+++ b/src/blockchain/blockchain.js
@@ -196,17 +196,12 @@ class Blockchain {
}
updateNetwork (cb) {
- this.networkcallid++
- ((callid) => {
- this.executionContext.detectNetwork((err, { id, name } = {}) => {
- if (this.networkcallid > callid) return
- this.networkcallid++
- if (err) {
- return cb(err)
- }
- cb(null, {id, name})
- })
- })(this.networkcallid)
+ this.executionContext.detectNetwork((err, { id, name } = {}) => {
+ if (err) {
+ return cb(err)
+ }
+ cb(null, {id, name})
+ })
}
detectNetwork (cb) {
diff --git a/src/publishToStorage.js b/src/publishToStorage.js
new file mode 100644
index 0000000000..f3c1ed5b6f
--- /dev/null
+++ b/src/publishToStorage.js
@@ -0,0 +1,47 @@
+const yo = require('yo-yo')
+const publishOnSwarm = require('./lib/publishOnSwarm')
+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.')
+ } else {
+ if (storage === 'swarm') {
+ publishOnSwarm(contract, fileManager, function (err, uploaded) {
+ if (err) {
+ try {
+ err = JSON.stringify(err)
+ } catch (e) {}
+ console.log(`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 {
+ err = JSON.stringify(err)
+ } catch (e) {}
+ modalDialogCustom.alert(yo`
Failed to publish metadata file to ${storage}, please check the ${storage} gateways is available.
+ ${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('ipfs/' + item.hash, item.content)
+ })
+ }
+ }
+ }
+}
diff --git a/test-browser/commands/renameFile.js b/test-browser/commands/renameFile.js
index 7b2ab2d2c1..840b0974d6 100644
--- a/test-browser/commands/renameFile.js
+++ b/test-browser/commands/renameFile.js
@@ -40,7 +40,7 @@ function renameFile (browser, path, newFileName, renamedPath, done) {
})
})
.click('body') // blur
- .waitForElementVisible('#modal-footer-ok', 2000)
+ .waitForElementVisible('#modal-footer-ok', 10000)
.pause(2000)
.click('#modal-footer-ok')
.waitForElementNotPresent('[data-path="' + path + '"]')
diff --git a/test-browser/tests/generalSettings.js b/test-browser/tests/generalSettings.js
index 3a01519a12..7a507c26b0 100644
--- a/test-browser/tests/generalSettings.js
+++ b/test-browser/tests/generalSettings.js
@@ -97,7 +97,7 @@ module.exports = {
'Should load Cerulean theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeCerulean"]')
- .pause(2000)
+ .pause(5000)
.checkElementStyle(':root', '--primary', remixIdeThemes.curelean.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.curelean.secondary)
.checkElementStyle(':root', '--success', remixIdeThemes.curelean.success)
diff --git a/test-browser/tests/terminal.js b/test-browser/tests/terminal.js
index 20280f3e52..553370d7af 100644
--- a/test-browser/tests/terminal.js
+++ b/test-browser/tests/terminal.js
@@ -70,6 +70,7 @@ module.exports = {
.switchFile('browser/asyncAwaitWithFileManagerAccess.js')
.pause(5000)
.executeScript(`remix.execute('browser/asyncAwaitWithFileManagerAccess.js')`)
+ .pause(2000)
.journalLastChildIncludes('contract Ballot {')
.end()
},