From 207df8573540f9791f74fee9328f3661f787eccb Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 15:24:35 +0100 Subject: [PATCH 1/8] don't format json cause hash mismatch in that case ... --- src/app/contract/publishOnSwarm.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/app/contract/publishOnSwarm.js b/src/app/contract/publishOnSwarm.js index 1155a2fbb7..0c2692a801 100644 --- a/src/app/contract/publishOnSwarm.js +++ b/src/app/contract/publishOnSwarm.js @@ -7,10 +7,6 @@ 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 From 29b11b869fcd2b9b8fefae54dfd3ef3234144c87 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 15:24:57 +0100 Subject: [PATCH 2/8] fix name --- src/app/files/basicReadOnlyExplorer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/files/basicReadOnlyExplorer.js b/src/app/files/basicReadOnlyExplorer.js index 5285da3930..096b6a8eb7 100644 --- a/src/app/files/basicReadOnlyExplorer.js +++ b/src/app/files/basicReadOnlyExplorer.js @@ -1,7 +1,7 @@ 'use strict' var EventManager = require('remix-lib').EventManager -class SwarmExplorer { +class BasicReadOnlyExplorer { constructor (type) { this.event = new EventManager() this.files = {} @@ -99,4 +99,4 @@ class SwarmExplorer { } } -module.exports = SwarmExplorer +module.exports = BasicReadOnlyExplorer From 4c3846a1003f7ae44e401b47a54332ca89dcc9f2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 15:25:11 +0100 Subject: [PATCH 3/8] add readonly property --- src/app/files/basicReadOnlyExplorer.js | 1 + src/app/files/file-explorer.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/app/files/basicReadOnlyExplorer.js b/src/app/files/basicReadOnlyExplorer.js index 096b6a8eb7..f210c5ca63 100644 --- a/src/app/files/basicReadOnlyExplorer.js +++ b/src/app/files/basicReadOnlyExplorer.js @@ -6,6 +6,7 @@ class BasicReadOnlyExplorer { this.event = new EventManager() this.files = {} this.type = type + this.readonly = true } close (cb) { diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 410fe4da0a..b8dcb52d8a 100755 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -216,6 +216,7 @@ function fileExplorer (appAPI, files) { } function editModeOn (event) { + if (self.files.readonly) return var label = this var li = getLiFrom(label) var classes = li.className From 7d0ae3328fbfbf813497ac459768d4e4d6577870 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 15:35:17 +0100 Subject: [PATCH 4/8] lazy format to JSON --- src/app/files/basicReadOnlyExplorer.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/files/basicReadOnlyExplorer.js b/src/app/files/basicReadOnlyExplorer.js index f210c5ca63..f6f7d09bb6 100644 --- a/src/app/files/basicReadOnlyExplorer.js +++ b/src/app/files/basicReadOnlyExplorer.js @@ -36,6 +36,9 @@ class BasicReadOnlyExplorer { } addReadOnly (path, content) { + try { // lazy try to format JSON + content = JSON.stringify(JSON.parse(content), null, '\t') + } catch (e) {} this.files[this.type + '/' + path] = content this.event.trigger('fileAdded', [this.type + '/' + path, true]) return true From bcbe08d5f443bed807acd903351328cef3af5fc9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 16:01:36 +0100 Subject: [PATCH 5/8] update optimize --- src/app/tabs/settings-tab.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 5dabb1cce3..867802870a 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -72,6 +72,7 @@ function SettingsTab (container, appAPI, appEvents, opts) { optimize.setAttribute('checked', true) appAPI.setOptimize(true, false) } else { + queryParams.update({ optimize: false }) appAPI.setOptimize(false, false) } From 3dc9bebf9c484af5334ce51d3330734258fc03e7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 16:01:54 +0100 Subject: [PATCH 6/8] get package for gist from browser --- src/app/panels/file-panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/panels/file-panel.js b/src/app/panels/file-panel.js index 4c82a169ad..881fff2cad 100644 --- a/src/app/panels/file-panel.js +++ b/src/app/panels/file-panel.js @@ -345,7 +345,7 @@ function filepanel (appAPI, filesProvider) { } function toGist () { - packageFiles(filesProvider['gist'], (error, packaged) => { + packageFiles(filesProvider['browser'], (error, packaged) => { if (error) { console.log(error) } else { From 28bcb71ed668026d86a7d7e7236e6338d70c9966 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 16:02:17 +0100 Subject: [PATCH 7/8] load gist to gist explorer --- src/app.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app.js b/src/app.js index e1f4e521e6..3f9cfa71bb 100644 --- a/src/app.js +++ b/src/app.js @@ -409,14 +409,16 @@ function run () { }) // Add files received from remote instance (i.e. another browser-solidity) - function loadFiles (filesSet) { + function loadFiles (filesSet, fileProvider) { + if (!fileProvider) fileProvider = 'browser' + for (var f in filesSet) { - var name = helper.createNonClashingName(f, filesProviders['browser']) + var name = helper.createNonClashingName(f, filesProviders[fileProvider]) if (helper.checkSpecialChars(name)) { modalDialogCustom.alert('Special characters are not allowed') return } - filesProviders['browser'].set(name, filesSet[f].content) + filesProviders[fileProvider].set(name, filesSet[f].content) } fileManager.switchFile() } @@ -444,7 +446,7 @@ function run () { modalDialogCustom.alert('Gist load error: ' + response.data.message) return } - loadFiles(response.data.files) + loadFiles(response.data.files, 'gist') } } }) From 5f82e3040eb46344b16455446f35d3360a195028 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 16:02:32 +0100 Subject: [PATCH 8/8] fix save readonly explorer file --- src/app/files/basicReadOnlyExplorer.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/files/basicReadOnlyExplorer.js b/src/app/files/basicReadOnlyExplorer.js index f6f7d09bb6..fa8f49d81f 100644 --- a/src/app/files/basicReadOnlyExplorer.js +++ b/src/app/files/basicReadOnlyExplorer.js @@ -32,15 +32,18 @@ class BasicReadOnlyExplorer { } set (path, content, cb) { + this.addReadOnly(path, content) + if (cb) cb() return true } addReadOnly (path, content) { + var unprefixedPath = this.removePrefix(path) try { // lazy try to format JSON content = JSON.stringify(JSON.parse(content), null, '\t') } catch (e) {} - this.files[this.type + '/' + path] = content - this.event.trigger('fileAdded', [this.type + '/' + path, true]) + this.files[this.type + '/' + unprefixedPath] = content + this.event.trigger('fileAdded', [this.type + '/' + unprefixedPath, true]) return true } @@ -101,6 +104,10 @@ class BasicReadOnlyExplorer { }) return tree } + + removePrefix (path) { + return path.indexOf(this.type + '/') === 0 ? path.replace(this.type + '/', '') : path + } } module.exports = BasicReadOnlyExplorer