From 2817fa84d86e409fb22efa2d7b4e1931e532e87b Mon Sep 17 00:00:00 2001 From: Thomas Schoffelen Date: Wed, 13 Jun 2018 20:26:46 +0200 Subject: [PATCH 1/2] Added copy buttons for ABI and Bytecode --- src/app/tabs/compile-tab.js | 69 +++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index 9d7b71e0f5..cd0291a187 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -1,5 +1,6 @@ const yo = require('yo-yo') const csjs = require('csjs-inject') +const copy = require('clipboard-copy') const TreeView = require('../ui/TreeView') const modalDialog = require('../ui/modaldialog') @@ -8,6 +9,7 @@ const modalDialogCustom = require('../ui/modal-dialog-custom') const styleGuide = require('../ui/styles-guide/theme-chooser') const parseContracts = require('../contract/contractParser') const publishOnSwarm = require('../contract/publishOnSwarm') +const addTooltip = require('../ui/tooltip') const styles = styleGuide.chooser() @@ -153,10 +155,18 @@ module.exports = class CompileTab { self._view.contractNames = yo`` self._view.contractEl = yo`
- ${self._view.contractNames} -
+
+ ${self._view.contractNames} +
+
Details
Publish on Swarm
+
+ ABI +
+
+ Bytecode +
` self._view.el = yo` @@ -181,6 +191,36 @@ module.exports = class CompileTab { } function updateAutoCompile (event) { self._opts.config.set('autoCompile', self._view.autoCompile.checked) } function compile (event) { self._api.runCompiler() } + function getContractProperty (property) { + const select = self._view.contractNames + if (select.children.length > 0 && select.selectedIndex >= 0) { + const contractName = select.children[select.selectedIndex].innerHTML + const contractProperties = self.data.contractsDetails[contractName] + return contractProperties[property] || null + } + } + function copyContractProperty (property) { + let content = getContractProperty(property) + if (!content) { + addTooltip('No content available for ' + property) + return + } + + try { + if (typeof content !== 'string') { + content = JSON.stringify(content, null, '\t') + } + } catch (e) {} + + copy(content) + addTooltip('Copied value to clipboard') + } + function copyABI () { + copyContractProperty('abi') + } + function copyBytecode () { + copyContractProperty('bytecode') + } function details () { const select = self._view.contractNames if (select.children.length > 0 && select.selectedIndex >= 0) { @@ -314,25 +354,42 @@ const css = csjs` .container { ${styles.rightPanel.compileTab.box_CompileContainer}; margin: 0; + margin-bottom: 2%; + } + .contractContainer { display: flex; align-items: center; + margin-bottom: 2%; } .contractNames { ${styles.rightPanel.compileTab.dropdown_CompileContract}; - margin-right: 5%; } - .contractButtons { + .contractHelperButtons { display: flex; cursor: pointer; - justify-content: center; + justify-content: space-between; text-align: center; } + .copyButton { + ${styles.rightPanel.compileTab.button_Details}; + padding: 0 7px; + min-width: 50px; + width: auto; + margin-left: 5px; + } + .bytecodeButton { + min-width: 80px; + } + .copyIcon { + margin-right: 5px; + } .details { ${styles.rightPanel.compileTab.button_Details}; } .publish { ${styles.rightPanel.compileTab.button_Publish}; - margin-left: 2%; + margin-left: 5px; + margin-right: 5px; width: 120px; } .log { From 7ba1a956c37728e79ff4191c958c11ee37ed784e Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 28 Jun 2018 11:32:32 +0200 Subject: [PATCH 2/2] Update compile-tab.js --- src/app/tabs/compile-tab.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index e3872415b7..5ec641a76e 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -384,7 +384,6 @@ const css = csjs` .contractHelperButtons { display: flex; cursor: pointer; - justify-content: space-between; text-align: center; } .copyButton {