Commit d03f0c45 authored by ninabreznik's avatar ninabreznik

Add copy instance address to clipboard

parent 205fa8e7
...@@ -92,24 +92,39 @@ ...@@ -92,24 +92,39 @@
}, },
"browserify": { "browserify": {
"transform": [ "transform": [
["babelify", { [
"sourceMapsAbsolute": false, "babelify",
"sourceMaps": true, {
"plugins": [ "sourceMapsAbsolute": false,
["fast-async", { "sourceMaps": true,
"runtimePattern": null, "plugins": [
"compiler": { [
"es7": true, "fast-async",
"noRuntime": true, {
"promises": true, "runtimePattern": null,
"wrapAwait": true "compiler": {
} "es7": true,
}], "noRuntime": true,
["yo-yoify"], ["transform-object-assign"] "promises": true,
], "wrapAwait": true
"presets": ["es2015"] }
}], }
["uglifyify"] ],
[
"yo-yoify"
],
[
"transform-object-assign"
]
],
"presets": [
"es2015"
]
}
],
[
"uglifyify"
]
] ]
}, },
"scripts": { "scripts": {
...@@ -136,5 +151,8 @@ ...@@ -136,5 +151,8 @@
"test": "standard; npm run csslint; node test/index.js", "test": "standard; npm run csslint; node test/index.js",
"test-browser": "npm-run-all -lpr selenium downloadsolc make-mock-compiler serve browsertest", "test-browser": "npm-run-all -lpr selenium downloadsolc make-mock-compiler serve browsertest",
"watch": "watchify src/index.js --transform-key=development -dv -p browserify-reload -o build/app.js" "watch": "watchify src/index.js --transform-key=development -dv -p browserify-reload -o build/app.js"
},
"dependencies": {
"clipboard-copy": "^1.2.0"
} }
} }
var name = 'gas costs: ' var name = 'gas costs: '
var desc = 'warn if the gas requiremets of functions are too high.' var desc = 'warn if the gas requiremets of functions are too high'
var categories = require('./categories') var categories = require('./categories')
function gasCosts () { function gasCosts () {
......
...@@ -7,7 +7,7 @@ function styleGuide () { ...@@ -7,7 +7,7 @@ function styleGuide () {
COLORS COLORS
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
var colors = { var colors = {
blue: '#9DC1F5', // hsla(215, 81%, 79%, 1) blue: '#9393bf',
lightBlue: '#F4F6FF', lightBlue: '#F4F6FF',
greyBlue: '#102026', greyBlue: '#102026',
grey: '#666', grey: '#666',
......
...@@ -9,6 +9,10 @@ var EventManager = require('./lib/eventManager') ...@@ -9,6 +9,10 @@ var EventManager = require('./lib/eventManager')
var crypto = require('crypto') var crypto = require('crypto')
var async = require('async') var async = require('async')
var TxRunner = require('./app/txRunner') var TxRunner = require('./app/txRunner')
var yo = require('yo-yo')
// copy to copyToClipboard
const copy = require('clipboard-copy')
// -------------- styling ---------------------- // -------------- styling ----------------------
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
...@@ -49,9 +53,11 @@ var css = csjs` ...@@ -49,9 +53,11 @@ var css = csjs`
var cssInstance = csjs` var cssInstance = csjs`
.title extends ${styles.titleBox} { .title extends ${styles.titleBox} {
justify-content: center;
font-size: .95em; font-size: .95em;
cursor: pointer; cursor: pointer;
background-color: ${styles.colors.lightGrey}; background-color: ${styles.colors.violet};
border: 2px dotted ${styles.colors.blue};
} }
.title:hover { .title:hover {
opacity: .8; opacity: .8;
...@@ -71,6 +77,29 @@ var cssInstance = csjs` ...@@ -71,6 +77,29 @@ var cssInstance = csjs`
.instance.hidesub > *:not(.title) { .instance.hidesub > *:not(.title) {
display: none; display: none;
} }
.copyToClipboard extends ${styles.infoTextBox} {
margin-top: 1em;
display: flex;
flex-wrap: wrap;
justify-content: center;
cursor: pointer;
}
.copyToClipboard:hover {
background-color: ${styles.colors.green}
}
.address extends ${styles.button} {
text-align: center;
width: 100%;
padding: .1em;
}
.copy extends ${styles.button} {
text-align: center;
width: 75%;
padding: .1em;
}
.copy:hover, .address:hover {
opacity: 1;
}
` `
;[...document.querySelectorAll('#header #options li')].forEach(addCss) ;[...document.querySelectorAll('#header #options li')].forEach(addCss)
...@@ -221,7 +250,7 @@ UniversalDApp.prototype.render = function () { ...@@ -221,7 +250,7 @@ UniversalDApp.prototype.render = function () {
self.$el.append($legend) self.$el.append($legend)
for (var c in self.contracts) { for (var c in self.contracts) {
var $contractEl = $(`<div class="${css.contract}"/>`) var $contractEl = $(`<div class="contract ${css.contract}"/>`)
if (self.contracts[c].address) { if (self.contracts[c].address) {
self.getInstanceInterface(self.contracts[c], self.contracts[c].address, $contractEl) self.getInstanceInterface(self.contracts[c], self.contracts[c].address, $contractEl)
...@@ -324,7 +353,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -324,7 +353,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
var context = self.executionContext.isVM() ? 'memory' : 'blockchain' var context = self.executionContext.isVM() ? 'memory' : 'blockchain'
address = (address.slice(0, 2) === '0x' ? '' : '0x') + address.toString('hex') address = (address.slice(0, 2) === '0x' ? '' : '0x') + address.toString('hex')
var $title = $(`<span class="${cssInstance.title}"/>`).text('Contract instance for ' + contract.name + ' at ' + address + ' (' + context + ')') var $title = $(`<span class="${cssInstance.title}"/>`).text(contract.name + '' + ' at ' + address.substring(0, 10) + '...' + ' (' + context + ')')
$title.click(function () { $title.click(function () {
$instance.toggleClass(`${cssInstance.hidesub}`) $instance.toggleClass(`${cssInstance.hidesub}`)
}) })
...@@ -389,6 +418,21 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -389,6 +418,21 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
} }
$instance.append($title) $instance.append($title)
var instanceAddress = yo`
<div class="${cssInstance.copyToClipboard}" onclick=${copyToClipboard}>
<div class="${cssInstance.address}">${address}</div>
<div class="${cssInstance.copy}">
<i class="fa fa-clipboard" aria-hidden="true"></i>
Copy address to clipboard
</div>
</div>`
$instance.append(instanceAddress)
function copyToClipboard () {
var address = this.innerText.split('\n')[0]
copy(address)
}
// Add the fallback function // Add the fallback function
var fallback = self.getFallbackInterface(abi) var fallback = self.getFallbackInterface(abi)
if (fallback) { if (fallback) {
...@@ -666,7 +710,6 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -666,7 +710,6 @@ UniversalDApp.prototype.getCallButton = function (args) {
var outputObj = '0x' + result.vm.return.toString('hex') var outputObj = '0x' + result.vm.return.toString('hex')
clearOutput($result) clearOutput($result)
$result.append(getReturnOutput(outputObj)).append(getGasUsedOutput(result, result.vm)) $result.append(getReturnOutput(outputObj)).append(getGasUsedOutput(result, result.vm))
decoded = decodeResponse(result.vm.return) decoded = decodeResponse(result.vm.return)
if (decoded) { if (decoded) {
$result.append(decoded) $result.append(decoded)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment