From 103f14455914e0d883212a3ec19f105d718be464 Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Fri, 25 May 2018 15:20:06 +0200 Subject: [PATCH 1/7] adding copy to clipboard without much instructions --- src/multiParamManager.js | 8 ++++++++ src/universal-dapp-styles.js | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/multiParamManager.js b/src/multiParamManager.js index 75ffc1f9fa..fe91f5d978 100644 --- a/src/multiParamManager.js +++ b/src/multiParamManager.js @@ -2,6 +2,9 @@ var yo = require('yo-yo') var css = require('./universal-dapp-styles') +var copyToClipboard = require('./app/ui/copy-to-clipboard') +var remixLib = require('remix-lib') +var txFormat = remixLib.execution.txFormat class MultiParamManager { @@ -147,6 +150,11 @@ class MultiParamManager { ${this.multiFields}
${button} + ${copyToClipboard(() => { + var multiString = this.getMultiValsString() + var multiJSON = JSON.parse('[' + multiString + ']') + return txFormat.encodeData(this.funABI, multiJSON) + })}
` diff --git a/src/universal-dapp-styles.js b/src/universal-dapp-styles.js index 924f579d1c..3ccca94d34 100644 --- a/src/universal-dapp-styles.js +++ b/src/universal-dapp-styles.js @@ -237,6 +237,11 @@ var css = csjs` border-bottom-right-radius: 0; border-right: 0; } + .contractActionsContainerMultiInner .multiArg i { + padding-right: 26px; + padding-top: 5px; + float: right; + } ` module.exports = css From 534c9e3e91d0f44339d7b20c63dd11200ec7c73d Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Fri, 25 May 2018 16:16:16 +0200 Subject: [PATCH 2/7] add params w/ default vals for cp-to-clipboard & updated styles --- src/app/ui/copy-to-clipboard.js | 6 +++--- src/multiParamManager.js | 2 +- src/universal-dapp-styles.js | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/ui/copy-to-clipboard.js b/src/app/ui/copy-to-clipboard.js index 146c1ebc32..2398b62e1a 100644 --- a/src/app/ui/copy-to-clipboard.js +++ b/src/app/ui/copy-to-clipboard.js @@ -14,8 +14,8 @@ var css = csjs` } ` -module.exports = function copyToClipboard (getContent) { - var copyIcon = yo`` +module.exports = function copyToClipboard (getContent, tip = 'Copy value to to clipboard', icon = 'fa-clipboard') { + var copyIcon = yo`` copyIcon.style.color = styles.remix.icon_Color_CopyToClipboard copyIcon.onmouseenter = function (event) { copyIcon.style.color = styles.remix.icon_HoverColor_CopyToClipboard } copyIcon.onmouseleave = function (event) { copyIcon.style.color = styles.remix.icon_Color_CopyToClipboard } @@ -29,7 +29,7 @@ module.exports = function copyToClipboard (getContent) { } } catch (e) {} copy(copiableContent) - addTooltip('Successfully copied!') + addTooltip(tip) } } return copyIcon diff --git a/src/multiParamManager.js b/src/multiParamManager.js index fe91f5d978..6659c22b8f 100644 --- a/src/multiParamManager.js +++ b/src/multiParamManager.js @@ -154,7 +154,7 @@ class MultiParamManager { var multiString = this.getMultiValsString() var multiJSON = JSON.parse('[' + multiString + ']') return txFormat.encodeData(this.funABI, multiJSON) - })} + }, 'Encode values of input fields & copy to clipboard', 'fa-briefcase')} ` diff --git a/src/universal-dapp-styles.js b/src/universal-dapp-styles.js index 3ccca94d34..7deda5b3dc 100644 --- a/src/universal-dapp-styles.js +++ b/src/universal-dapp-styles.js @@ -241,6 +241,7 @@ var css = csjs` padding-right: 26px; padding-top: 5px; float: right; + font-size: 16px; } ` From c554d87fcdec30c7cbe72be6531f7364809eb7a0 Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Fri, 25 May 2018 17:16:57 +0200 Subject: [PATCH 3/7] update to return .data or .error --- src/multiParamManager.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/multiParamManager.js b/src/multiParamManager.js index 6659c22b8f..922ed8fdea 100644 --- a/src/multiParamManager.js +++ b/src/multiParamManager.js @@ -150,11 +150,17 @@ class MultiParamManager { ${this.multiFields}
${button} - ${copyToClipboard(() => { - var multiString = this.getMultiValsString() - var multiJSON = JSON.parse('[' + multiString + ']') - return txFormat.encodeData(this.funABI, multiJSON) - }, 'Encode values of input fields & copy to clipboard', 'fa-briefcase')} + ${copyToClipboard( + () => { + var multiString = this.getMultiValsString() + var multiJSON = JSON.parse('[' + multiString + ']') + var encodeObj = txFormat.encodeData(this.funABI, multiJSON) + if (encodeObj.error) { + return encodeObj.error + } else { + return encodeObj.data + } + }, 'Encode values of input fields & copy to clipboard', 'fa-briefcase')}
` From 93958b4d0f0e1a1112c8b7d0c03917e22f5486f6 Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Tue, 29 May 2018 15:32:20 +0200 Subject: [PATCH 4/7] update for constructor encode --- src/app/tabs/run-tab.js | 3 ++- src/multiParamManager.js | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 87600a1306..9fb17f8fcf 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -329,9 +329,10 @@ function contractDropdown (events, appAPI, appEvents, opts, self) { createPanel.innerHTML = '' if (opts.compiler.getContract && selectContractNames.selectedIndex >= 0 && selectContractNames.children.length > 0) { var ctrabi = txHelper.getConstructorInterface(getSelectedContract().contract.object.abi) + var ctrEVMbc = getSelectedContract().contract.object.evm.bytecode.object var createConstructorInstance = new MultiParamManager(0, ctrabi, (valArray, inputsValues) => { createInstance(inputsValues) - }, txHelper.inputParametersDeclarationToString(ctrabi.inputs), 'Deploy') + }, txHelper.inputParametersDeclarationToString(ctrabi.inputs), 'Deploy', ctrEVMbc) createPanel.appendChild(createConstructorInstance.render()) return } else { diff --git a/src/multiParamManager.js b/src/multiParamManager.js index 922ed8fdea..093515d6ab 100644 --- a/src/multiParamManager.js +++ b/src/multiParamManager.js @@ -15,14 +15,16 @@ class MultiParamManager { * @param {Function} clickMultiCallBack * @param {string} inputs * @param {string} title + * @param {string} evmBC * */ - constructor (lookupOnly, funABI, clickCallBack, inputs, title) { + constructor (lookupOnly, funABI, clickCallBack, inputs, title, evmBC) { this.lookupOnly = lookupOnly this.funABI = funABI this.clickCallBack = clickCallBack this.inputs = inputs this.title = title + this.evmBC = evmBC this.basicInputField this.multiFields } @@ -154,7 +156,13 @@ class MultiParamManager { () => { var multiString = this.getMultiValsString() var multiJSON = JSON.parse('[' + multiString + ']') - var encodeObj = txFormat.encodeData(this.funABI, multiJSON) + var encodeObj + if (this.evmBC) { + console.log(this.evmBC) + encodeObj = txFormat.encodeData(this.funABI, multiJSON, this.evmBC) + } else { + encodeObj = txFormat.encodeData(this.funABI, multiJSON) + } if (encodeObj.error) { return encodeObj.error } else { From e19c9a3cc2f92163237df4525f69a47657f506ad Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Tue, 29 May 2018 16:27:18 +0200 Subject: [PATCH 5/7] update copy to clipboard for error & decrease icon size --- src/app/ui/copy-to-clipboard.js | 6 +++++- src/multiParamManager.js | 1 - src/universal-dapp-styles.js | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/ui/copy-to-clipboard.js b/src/app/ui/copy-to-clipboard.js index 2398b62e1a..a533e0ac1a 100644 --- a/src/app/ui/copy-to-clipboard.js +++ b/src/app/ui/copy-to-clipboard.js @@ -29,7 +29,11 @@ module.exports = function copyToClipboard (getContent, tip = 'Copy value to to c } } catch (e) {} copy(copiableContent) - addTooltip(tip) + if (copiableContent === 'cannot encode arguments') { + addTooltip(copiableContent) + } else { + addTooltip(tip) + } } } return copyIcon diff --git a/src/multiParamManager.js b/src/multiParamManager.js index 093515d6ab..f1bd6200a7 100644 --- a/src/multiParamManager.js +++ b/src/multiParamManager.js @@ -158,7 +158,6 @@ class MultiParamManager { var multiJSON = JSON.parse('[' + multiString + ']') var encodeObj if (this.evmBC) { - console.log(this.evmBC) encodeObj = txFormat.encodeData(this.funABI, multiJSON, this.evmBC) } else { encodeObj = txFormat.encodeData(this.funABI, multiJSON) diff --git a/src/universal-dapp-styles.js b/src/universal-dapp-styles.js index 7deda5b3dc..3ccca94d34 100644 --- a/src/universal-dapp-styles.js +++ b/src/universal-dapp-styles.js @@ -241,7 +241,6 @@ var css = csjs` padding-right: 26px; padding-top: 5px; float: right; - font-size: 16px; } ` From 291114ab7d9a6d3133d3b709e6dcc4a051563fe9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 29 May 2018 17:35:13 +0200 Subject: [PATCH 6/7] throw in getContext --- src/app/ui/copy-to-clipboard.js | 14 ++++++++------ src/multiParamManager.js | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/ui/copy-to-clipboard.js b/src/app/ui/copy-to-clipboard.js index a533e0ac1a..23e80df201 100644 --- a/src/app/ui/copy-to-clipboard.js +++ b/src/app/ui/copy-to-clipboard.js @@ -21,7 +21,13 @@ module.exports = function copyToClipboard (getContent, tip = 'Copy value to to c copyIcon.onmouseleave = function (event) { copyIcon.style.color = styles.remix.icon_Color_CopyToClipboard } copyIcon.onclick = (event) => { event.stopPropagation() - var copiableContent = getContent() + var copiableContent + try { + copiableContent = getContent() + } catch (e) { + addTooltip(e.message) + return + } if (copiableContent) { // module `copy` keeps last copied thing in the memory, so don't show tooltip if nothing is copied, because nothing was added to memory try { if (typeof copiableContent !== 'string') { @@ -29,11 +35,7 @@ module.exports = function copyToClipboard (getContent, tip = 'Copy value to to c } } catch (e) {} copy(copiableContent) - if (copiableContent === 'cannot encode arguments') { - addTooltip(copiableContent) - } else { - addTooltip(tip) - } + addTooltip(tip) } } return copyIcon diff --git a/src/multiParamManager.js b/src/multiParamManager.js index f1bd6200a7..6e62253c08 100644 --- a/src/multiParamManager.js +++ b/src/multiParamManager.js @@ -163,7 +163,7 @@ class MultiParamManager { encodeObj = txFormat.encodeData(this.funABI, multiJSON) } if (encodeObj.error) { - return encodeObj.error + throw new Error(encodeObj.error) } else { return encodeObj.data } From 6b6bba18bd7678131fe1b412b97705a56f368694 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 29 May 2018 17:40:39 +0200 Subject: [PATCH 7/7] Update copy-to-clipboard.js --- src/app/ui/copy-to-clipboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/ui/copy-to-clipboard.js b/src/app/ui/copy-to-clipboard.js index 23e80df201..c1875a62e3 100644 --- a/src/app/ui/copy-to-clipboard.js +++ b/src/app/ui/copy-to-clipboard.js @@ -14,7 +14,7 @@ var css = csjs` } ` -module.exports = function copyToClipboard (getContent, tip = 'Copy value to to clipboard', icon = 'fa-clipboard') { +module.exports = function copyToClipboard (getContent, tip = 'Copy value to clipboard', icon = 'fa-clipboard') { var copyIcon = yo`` copyIcon.style.color = styles.remix.icon_Color_CopyToClipboard copyIcon.onmouseenter = function (event) { copyIcon.style.color = styles.remix.icon_HoverColor_CopyToClipboard }