From 7434a74a5d7e479fef55d4ffacd849237e52c291 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 9 May 2019 17:47:22 +0200 Subject: [PATCH 01/19] small style changes --- src/app/debugger/debuggerUI/TxBrowser.js | 1 - src/lib/panels-resize.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/debugger/debuggerUI/TxBrowser.js b/src/app/debugger/debuggerUI/TxBrowser.js index 831b185acc..6659a466f1 100644 --- a/src/app/debugger/debuggerUI/TxBrowser.js +++ b/src/app/debugger/debuggerUI/TxBrowser.js @@ -17,7 +17,6 @@ var css = csjs` justify-content: center; } .txinput { - margin: 3px; width: inherit; } .txbuttons { diff --git a/src/lib/panels-resize.js b/src/lib/panels-resize.js index 27f8679371..c041c48121 100644 --- a/src/lib/panels-resize.js +++ b/src/lib/panels-resize.js @@ -4,7 +4,7 @@ const csjs = require('csjs-inject') const css = csjs` .dragbar { position : absolute; - top : 29px; + top : 0px; width : 0.5em; right : 0; bottom : 0; From 53b119fbc5bc65dd35475baf8e426e1f0739d22f Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 16:19:43 +0200 Subject: [PATCH 02/19] Remove settings from swapPanel --- src/app/components/swap-panel.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/app/components/swap-panel.js b/src/app/components/swap-panel.js index 215805c56c..b58738f093 100644 --- a/src/app/components/swap-panel.js +++ b/src/app/components/swap-panel.js @@ -54,19 +54,13 @@ export class SwapPanel extends AbstractPanel { /** The header of the swap panel */ renderHeader () { let name = ' - ' - let hasSettings = false if (this.active) { const { profile } = this.store.getOne(this.active) name = profile.displayName ? profile.displayName : profile.name - hasSettings = profile.settings || false } return yo`
${name}
-
- ${hasSettings - ? yo`` - : yo``}
` } From 558951bcf1961ae9dfa8a40c80c327e9151b113e Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 16:19:54 +0200 Subject: [PATCH 03/19] Create a plugin manager settings --- src/app/components/plugin-manager-settings.js | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/app/components/plugin-manager-settings.js diff --git a/src/app/components/plugin-manager-settings.js b/src/app/components/plugin-manager-settings.js new file mode 100644 index 0000000000..f63ff2e9d1 --- /dev/null +++ b/src/app/components/plugin-manager-settings.js @@ -0,0 +1,95 @@ +const yo = require('yo-yo') +const csjs = require('csjs-inject') +const modalDialog = require('../ui/modaldialog') + +const css = csjs` +.permissions { + position: sticky; + bottom: 0; + display: flex; + justify-content: flex-end; + align-items: center; + padding: 5px 20px; +} +.permissions button { + padding: 2px 5px; + cursor: pointer; +} +.permissionForm h4 { + font-size: 1.3rem; +} +.permissionForm h6 { + font-size: 1.1rem; +} +.permissionForm hr { + width: 80%; +} +.checkbox { + display: flex; + align-items: center; +} +.checkbox label { + margin: 0; + font-size: 1rem; +}` + +export class PluginManagerSettings { + + openDialog () { + this.permissions = JSON.parse(window.localStorage.getItem('plugins/permissions')) + modalDialog('Plugin Manager Settings', this.settings(), + { fn: () => this.onValidation() }, + ) + } + + onValidation () { + const permissions = JSON.stringify(this.permissions) + window.localStorage.setItem('plugins/permissions', permissions) + } + + settings () { + const permissionByModule = (key, permission) => { + const permissionByPlugin = (name, plugin) => { + function updatePermission () { + plugin.allow = !plugin.allow + } + const checkbox = plugin.allow + ? yo`` + : yo`` + + return yo` +
+ ${checkbox} + +
` + } + + const byPlugin = Object + .keys(permission) + .map(name => permissionByPlugin(name, permission[name])) + + return yo` +
+
${key} :
+ ${byPlugin} +
` + } + + const permissions = Object + .keys(this.permissions) + .map(key => permissionByModule(key, this.permissions[key])) + return yo`
+

Current Permission settings

+
+ ${permissions} +
` + } + + render () { + return yo` +
+ +
` + } + +} From 6382e855c307202552b0ea8505c0768209d14ffd Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 16:20:19 +0200 Subject: [PATCH 04/19] implement settings in plugin manager --- src/app/components/plugin-manager-component.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/components/plugin-manager-component.js b/src/app/components/plugin-manager-component.js index e0bb2f3f8c..b904aa1b2e 100644 --- a/src/app/components/plugin-manager-component.js +++ b/src/app/components/plugin-manager-component.js @@ -3,6 +3,7 @@ const csjs = require('csjs-inject') const EventEmitter = require('events') const LocalPlugin = require('./local-plugin') import { Plugin, BaseApi } from 'remix-plugin' +import { PluginManagerSettings } from './plugin-manager-settings' const css = csjs` .pluginSearch { @@ -152,14 +153,16 @@ class PluginManagerComponent extends BaseApi { ` : '' + const settings = new PluginManagerSettings().render() + const rootView = yo`
-
+
-
+
${activeTile}
@@ -170,6 +173,7 @@ class PluginManagerComponent extends BaseApi { ${inactives.map(name => this.renderItem(name))}
+ ${settings}
` if (!this.views.root) this.views.root = rootView From b815dae7af61383f4c8af7614279f37c34960baf Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 16:47:19 +0200 Subject: [PATCH 05/19] Add title if no permission exist --- src/app/components/plugin-manager-settings.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/components/plugin-manager-settings.js b/src/app/components/plugin-manager-settings.js index f63ff2e9d1..017cf53cf2 100644 --- a/src/app/components/plugin-manager-settings.js +++ b/src/app/components/plugin-manager-settings.js @@ -17,6 +17,7 @@ const css = csjs` } .permissionForm h4 { font-size: 1.3rem; + text-align: center; } .permissionForm h6 { font-size: 1.1rem; @@ -36,7 +37,8 @@ const css = csjs` export class PluginManagerSettings { openDialog () { - this.permissions = JSON.parse(window.localStorage.getItem('plugins/permissions')) + const fromLocal = window.localStorage.getItem('plugins/permissions') + this.permissions = JSON.parse(fromLocal || '{}') modalDialog('Plugin Manager Settings', this.settings(), { fn: () => this.onValidation() }, ) @@ -64,22 +66,27 @@ export class PluginManagerSettings { ` } - const byPlugin = Object + const byModule = Object .keys(permission) .map(name => permissionByPlugin(name, permission[name])) return yo`
${key} :
- ${byPlugin} + ${byModule}
` } const permissions = Object .keys(this.permissions) .map(key => permissionByModule(key, this.permissions[key])) + + const title = permissions.length === 0 + ? yo`

No Permission requested yet.

` + : yo`

Current Permission settings

` + return yo`
-

Current Permission settings

+ ${title}
${permissions}
` From 4dcb7105907d2fc8e58197d516ce3470750ab79b Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 17:10:46 +0200 Subject: [PATCH 06/19] createVMAccount accept an object as parameter --- src/universal-dapp.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/universal-dapp.js b/src/universal-dapp.js index d57aaf7160..aff881d123 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -82,13 +82,18 @@ module.exports = class UniversalDApp extends UdappApi { this.transactionContextAPI = transactionContextAPI } - createVMAccount (privateKey, balance, cb) { - return new Promise((resolve, reject) => { - if (executionContext.getProvider() !== 'vm') return reject('plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed') - this._addAccount(privateKey, balance) - privateKey = Buffer.from(privateKey, 'hex') - resolve('0x' + ethJSUtil.privateToAddress(privateKey).toString('hex')) - }) + /** + * Create a VM Account + * @param {{privateKey: string, balance: string}} newAccount The new account to create + */ + createVMAccount (newAccount) { + const { privateKey, balance } = newAccount + if (executionContext.getProvider() !== 'vm') { + throw new Error('plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed') + } + this._addAccount(privateKey, balance) + privateKey = Buffer.from(privateKey, 'hex') + return '0x' + ethJSUtil.privateToAddress(privateKey).toString('hex') } newAccount (password, passwordPromptCb, cb) { From 2181a12e0de459c6e27cbaa1eb99a1d9f3ae0821 Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 17:30:05 +0200 Subject: [PATCH 07/19] update browser test --- test-browser/plugin/plugin.js | 5 ++++- test-browser/plugin/remix.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test-browser/plugin/plugin.js b/test-browser/plugin/plugin.js index 62bb971037..2d9a90c029 100644 --- a/test-browser/plugin/plugin.js +++ b/test-browser/plugin/plugin.js @@ -44,7 +44,10 @@ window.onload = function () { }) document.querySelector('input#testaccountcreation').addEventListener('click', function () { - extension.call('udapp', 'createVMAccount', ['71975fbf7fe448e004ac7ae54cad0a383c3906055a75468714156a07385e96ce', '0x56BC75E2D63100000'], + extension.call('udapp', 'createVMAccount', [{ + privateKey: '71975fbf7fe448e004ac7ae54cad0a383c3906055a75468714156a07385e96ce', + balance: '0x56BC75E2D63100000' + }], function (error, result) { console.log(error, result) }) }) diff --git a/test-browser/plugin/remix.js b/test-browser/plugin/remix.js index 415f678711..182ff97906 100644 --- a/test-browser/plugin/remix.js +++ b/test-browser/plugin/remix.js @@ -64,7 +64,10 @@ window.onload = function () { action: 'request', key: 'udapp', type: 'createVMAccount', - value: ['71975fbf7fe448e004ac7ae54cad0a383c3906055a75468714156a07385e96ce', '0x56BC75E2D63100000'], + value: [{ + privateKey: '71975fbf7fe448e004ac7ae54cad0a383c3906055a75468714156a07385e96ce', + balance: '0x56BC75E2D63100000' + }], id: 38 }), '*') }) From 4a9889a9dd26f8e2d703418f613268359108247b Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 17:30:22 +0200 Subject: [PATCH 08/19] create an intermediary variable --- src/universal-dapp.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/universal-dapp.js b/src/universal-dapp.js index aff881d123..5bf713f026 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -92,8 +92,8 @@ module.exports = class UniversalDApp extends UdappApi { throw new Error('plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed') } this._addAccount(privateKey, balance) - privateKey = Buffer.from(privateKey, 'hex') - return '0x' + ethJSUtil.privateToAddress(privateKey).toString('hex') + const privKey = Buffer.from(privateKey, 'hex') + return '0x' + ethJSUtil.privateToAddress(privKey).toString('hex') } newAccount (password, passwordPromptCb, cb) { From 6a3214993c1ff86709b2a22c6fa25474708d7e76 Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Tue, 14 May 2019 11:48:53 +0200 Subject: [PATCH 09/19] location radio set from local storage --- src/app/components/local-plugin.js | 37 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/app/components/local-plugin.js b/src/app/components/local-plugin.js index 1159413102..a5106387e2 100644 --- a/src/app/components/local-plugin.js +++ b/src/app/components/local-plugin.js @@ -34,11 +34,13 @@ module.exports = class LocalPlugin { */ create () { const profile = { - ...this.profile, icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xMjYyIDEwNzVxLTM3IDEyMS0xMzggMTk1dC0yMjggNzQtMjI4LTc0LTEzOC0xOTVxLTgtMjUgNC00OC41dDM4LTMxLjVxMjUtOCA0OC41IDR0MzEuNSAzOHEyNSA4MCA5Mi41IDEyOS41dDE1MS41IDQ5LjUgMTUxLjUtNDkuNSA5Mi41LTEyOS41cTgtMjYgMzItMzh0NDktNCAzNyAzMS41IDQgNDguNXptLTQ5NC00MzVxMCA1My0zNy41IDkwLjV0LTkwLjUgMzcuNS05MC41LTM3LjUtMzcuNS05MC41IDM3LjUtOTAuNSA5MC41LTM3LjUgOTAuNSAzNy41IDM3LjUgOTAuNXptNTEyIDBxMCA1My0zNy41IDkwLjV0LTkwLjUgMzcuNS05MC41LTM3LjUtMzcuNS05MC41IDM3LjUtOTAuNSA5MC41LTM3LjUgOTAuNSAzNy41IDM3LjUgOTAuNXptMjU2IDI1NnEwLTEzMC01MS0yNDguNXQtMTM2LjUtMjA0LTIwNC0xMzYuNS0yNDguNS01MS0yNDguNSA1MS0yMDQgMTM2LjUtMTM2LjUgMjA0LTUxIDI0OC41IDUxIDI0OC41IDEzNi41IDIwNCAyMDQgMTM2LjUgMjQ4LjUgNTEgMjQ4LjUtNTEgMjA0LTEzNi41IDEzNi41LTIwNCA1MS0yNDguNXptMTI4IDBxMCAyMDktMTAzIDM4NS41dC0yNzkuNSAyNzkuNS0zODUuNSAxMDMtMzg1LjUtMTAzLTI3OS41LTI3OS41LTEwMy0zODUuNSAxMDMtMzg1LjUgMjc5LjUtMjc5LjUgMzg1LjUtMTAzIDM4NS41IDEwMyAyNzkuNSAyNzkuNSAxMDMgMzg1LjV6Ii8+PC9zdmc+', methods: [], + location: 'swapPanel', + ...this.profile, hash: `local-${this.profile.name}` } + profile.events = profile.events || [] profile.events = profile.events.filter((item) => { return item !== '' }) if (!profile.location) throw new Error('Plugin should have a location') @@ -95,11 +97,11 @@ module.exports = class LocalPlugin { notificationCheckbox (plugin, event) { const notifications = this.profile.notifications || {} const checkbox = notifications[plugin] && notifications[plugin].includes(event) - ? yo`` - : yo`` + ? yo`` + : yo`` return yo`
${checkbox} - +
` } @@ -120,6 +122,20 @@ module.exports = class LocalPlugin { return yo`` })}` } + const radioLocations = (label, displayN) => { + const radioButton = (this.profile.location === label) + ? yo`
+ +
` + : yo`
+ +
` + return yo`
+ ${radioButton} +
` + } const eventsEl = eventsForm(this.profile.events || []) const pushEvent = () => { if (!this.profile.events) this.profile.events = [] @@ -156,16 +172,9 @@ module.exports = class LocalPlugin {
Location in remix (required)
- -
- -
-
- -
-
- -
+ ${radioLocations('swapPanel', 'Swap Panel')} + ${radioLocations('mainPanel', 'Main Panel')} + ${radioLocations('none', 'None')} ` } } From 3f3eb07df215acf5f58c47688736fa7c0ee68b61 Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Tue, 14 May 2019 16:19:18 +0200 Subject: [PATCH 10/19] check if plugin name has been used --- src/app/components/local-plugin.js | 3 +-- src/app/components/plugin-manager-component.js | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/components/local-plugin.js b/src/app/components/local-plugin.js index a5106387e2..5dc71f8e2c 100644 --- a/src/app/components/local-plugin.js +++ b/src/app/components/local-plugin.js @@ -40,8 +40,7 @@ module.exports = class LocalPlugin { ...this.profile, hash: `local-${this.profile.name}` } - profile.events = profile.events || [] - profile.events = profile.events.filter((item) => { return item !== '' }) + profile.events = (profile.events || []).filter(item => item !== '') if (!profile.location) throw new Error('Plugin should have a location') if (!profile.name) throw new Error('Plugin should have a name') diff --git a/src/app/components/plugin-manager-component.js b/src/app/components/plugin-manager-component.js index b904aa1b2e..1c56a81961 100644 --- a/src/app/components/plugin-manager-component.js +++ b/src/app/components/plugin-manager-component.js @@ -4,6 +4,7 @@ const EventEmitter = require('events') const LocalPlugin = require('./local-plugin') import { Plugin, BaseApi } from 'remix-plugin' import { PluginManagerSettings } from './plugin-manager-settings' +const addToolTip = require('../ui/tooltip') const css = csjs` .pluginSearch { @@ -109,11 +110,15 @@ class PluginManagerComponent extends BaseApi { try { const profile = await this.localPlugin.open(this.store.getAll()) if (!profile) return + if (this.store.ids.includes(profile.name)) { + throw new Error('This name has already been used') + } this.appManager.registerOne(new Plugin(profile)) this.appManager.activateOne(profile.name) } catch (err) { // TODO : Use an alert to handle this error instead of a console.log console.log(`Cannot create Plugin : ${err.message}`) + addToolTip(`Cannot create Plugin : ${err.message}`) } } From 6a7dbdb3c84f75b61f6e8ece0c7d0babeb67a4cd Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 14 May 2019 18:26:47 +0200 Subject: [PATCH 11/19] remove "compilation result for" label --- src/app/tabs/compile-tab.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index 19203ec97b..a144a1a021 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -184,10 +184,7 @@ class CompileTab extends CompilerApi { return contractList.length !== 0 ? yo`
-
- Compilation result for -
-
+