Pull in console dapp as builtin (#4145)
* Copy static dapps from static (no build) * Console sources * Add console to builtins * Remove console assets * Disable eslint on console.js * Enable eslint after disable * Webpack copy
This commit is contained in:
parent
cfb6dd2ea8
commit
ee4ede915a
221
js/src/dapps/static/console.css
Executable file
221
js/src/dapps/static/console.css
Executable file
@ -0,0 +1,221 @@
|
||||
#full-screen {
|
||||
}
|
||||
|
||||
textarea:focus, input:focus{
|
||||
outline: none;
|
||||
}
|
||||
|
||||
* { padding: 0; margin: 0; }
|
||||
|
||||
html, body, #full-screen {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#full-screen {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#history-wrap {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#history {
|
||||
flex: 1 1 auto;
|
||||
|
||||
display: flex;
|
||||
min-height: min-content;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.entry, #input {
|
||||
margin: 0;
|
||||
padding: 0.25em;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.type {
|
||||
color: #ccc;
|
||||
font-weight: bold;
|
||||
font-family: "Lucida Console", Monaco, monospace;
|
||||
font-size: 11pt;
|
||||
padding: 0 0.5em 0 0.25em;
|
||||
}
|
||||
|
||||
.command .type {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.result .type {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
#input .type {
|
||||
color: #59f;
|
||||
}
|
||||
|
||||
.addwatch {
|
||||
background-color: #cfc;
|
||||
border-top: 1px solid #6e6;
|
||||
}
|
||||
.addwatch .type {
|
||||
color: #040;
|
||||
}
|
||||
.addwatch .text {
|
||||
color: #080;
|
||||
}
|
||||
|
||||
.log.logLevel .type {
|
||||
color: blue;
|
||||
}
|
||||
.log.debugLevel .text {
|
||||
color: blue;
|
||||
}
|
||||
.log.infoLevel .type {
|
||||
color: #00c;
|
||||
}
|
||||
.log.warnLevel {
|
||||
background-color: #fff8dd;
|
||||
border-top: 1px solid #fe8;
|
||||
border-bottom: 1px solid #fe8;
|
||||
}
|
||||
.log.warnLevel .text {
|
||||
color: #440;
|
||||
}
|
||||
.log.warnLevel .type {
|
||||
color: #880;
|
||||
}
|
||||
.log.errorLevel, .error {
|
||||
background-color: #fee;
|
||||
border-top: 1px solid #fbb;
|
||||
border-bottom: 1px solid #fbb;
|
||||
}
|
||||
.log.errorLevel .text, .error .text {
|
||||
color: #c00;
|
||||
}
|
||||
.log.errorLevel .type, .error .type {
|
||||
color: #800;
|
||||
}
|
||||
|
||||
|
||||
span.text {
|
||||
color: black;
|
||||
}
|
||||
.text {
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
color: black;
|
||||
font-weight: 1000;
|
||||
font-family: "Lucida Console", Monaco, monospace;
|
||||
font-size: 11pt;
|
||||
|
||||
flex-grow: 1;
|
||||
}
|
||||
div.error {
|
||||
background-color: #fee;
|
||||
border-top: 1px solid #fbb;
|
||||
color: red;
|
||||
}
|
||||
div.command {
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
div#input {
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
#status {
|
||||
background: #eee;
|
||||
padding: 0.25em;
|
||||
font-family: "Lucida Console", Monaco, monospace;
|
||||
font-size: 8pt;
|
||||
color: #888;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
#input {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
#status {
|
||||
display: flex;
|
||||
}
|
||||
.watch {
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
.watch:not(:first-child) {
|
||||
border-left: 1px solid #ccc;
|
||||
}
|
||||
.expr {
|
||||
color: #888;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
.res {
|
||||
font-weight: bold;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.stringType {
|
||||
color: #c00;
|
||||
}
|
||||
.numberType {
|
||||
color: #00f;
|
||||
}
|
||||
.eObject {
|
||||
color: #00f;
|
||||
}
|
||||
.objectType {
|
||||
font-style: italic;
|
||||
}
|
||||
.fieldType {
|
||||
color: #808;
|
||||
}
|
||||
.undefinedType {
|
||||
color: #888;
|
||||
}
|
||||
.functionType {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#autocomplete-anchor {
|
||||
position: relative;
|
||||
}
|
||||
#autocomplete {
|
||||
position: absolute;
|
||||
left: 1.5em;
|
||||
bottom: 0;
|
||||
background: #f8f8f8;
|
||||
box-shadow: 0 0.125em 0.25em rgba(0, 0, 0, 0.5);
|
||||
max-height: 20em;
|
||||
overflow: scroll;
|
||||
}
|
||||
#autocomplete div {
|
||||
font-size: small;
|
||||
font-family: "Lucida Console", Monaco, monospace;
|
||||
padding: 0.1em 1em 0.1em 0;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
.ac-already {
|
||||
font-weight: bold;
|
||||
}
|
||||
.ac-new {
|
||||
color: #666;
|
||||
}
|
||||
.ac-selected {
|
||||
background-color: #ccddff;
|
||||
}
|
20
js/src/dapps/static/console.html
Executable file
20
js/src/dapps/static/console.html
Executable file
@ -0,0 +1,20 @@
|
||||
<!doctype html>
|
||||
<html lang="us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JS Console dapp</title>
|
||||
<link href="console.css" rel='stylesheet' type='text/css'>
|
||||
<script src="/parity-utils/parity.js"></script>
|
||||
<script src="/parity-utils/web3.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="full-screen">
|
||||
<div id="eval"></div>
|
||||
<div id="history-wrap"><div id="history"></div></div>
|
||||
<div id="autocomplete-anchor"><div id="autocomplete"></div></div>
|
||||
<div id="input"><span class="type">></span><input type="text" class="text" id="command" list="input-datalist"></div>
|
||||
<div id="status"></div>
|
||||
</div>
|
||||
<script src="console.js"></script>
|
||||
</body>
|
||||
</html>
|
601
js/src/dapps/static/console.js
Executable file
601
js/src/dapps/static/console.js
Executable file
@ -0,0 +1,601 @@
|
||||
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/* eslint-disable */
|
||||
// TODO: Fix linting issues
|
||||
|
||||
if (typeof(window.parity) == 'object')
|
||||
window.parity.api.subscribe('eth_blockNumber', function (error, blockNumber) {
|
||||
if (error) {
|
||||
console.log('error', error);
|
||||
return;
|
||||
}
|
||||
refreshWatches();
|
||||
});
|
||||
|
||||
function escapeHtml(str) {
|
||||
var div = document.createElement('div');
|
||||
div.appendChild(document.createTextNode(str));
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
function getAllPropertyNames(obj) {
|
||||
var props = {};
|
||||
do {
|
||||
Object.getOwnPropertyNames(obj).forEach(n => props[n] = true);
|
||||
} while (obj = Object.getPrototypeOf(obj));
|
||||
return Object.keys(props);
|
||||
}
|
||||
|
||||
function htmlToElement(html) {
|
||||
var template = document.createElement('template');
|
||||
template.innerHTML = html;
|
||||
return template.content.firstChild;
|
||||
}
|
||||
|
||||
function evaluate(x) {
|
||||
try {
|
||||
return eval(x);
|
||||
}
|
||||
catch (err) {
|
||||
return eval('(()=>{var x = ' + x + "; return x;})()")
|
||||
}
|
||||
}
|
||||
|
||||
function displayReady(x) {
|
||||
if (x === undefined)
|
||||
return '<span class="undefinedType">undefined</span>';
|
||||
if (x === null)
|
||||
return '<span class="undefinedType">null</span>';
|
||||
if (typeof(x) == "string")
|
||||
return `"<span class="${typeof(x)}Type">${escapeHtml(x)}</span>"`;
|
||||
if (Object.prototype.toString.call(x) === '[object Array]')
|
||||
return `[${x.map(displayReady).join(', ')}]`;
|
||||
if (typeof(x) == "function")
|
||||
return `<span class="${typeof(x)}Type">function () { /* ... */ }</span>`;
|
||||
if (typeof(x) == "object") {
|
||||
if (x.toString().indexOf('[object ') != 0)
|
||||
return `<span class="${x.constructor.name}Object">${escapeHtml(x.toString())}</span>`;
|
||||
return `<span class="objectType ${x.constructor.name}Object">${x.constructor.name} {${Object.keys(x).map(f => `<span class="fieldType">${escapeHtml(f)}</span>: ${displayReady(x[f])}`).join(', ')}}</span>`;
|
||||
}
|
||||
return `<span class="${typeof(x)}Type">${escapeHtml(JSON.stringify(x))}</span>`;
|
||||
}
|
||||
|
||||
if (!localStorage.history)
|
||||
localStorage.history = "[]";
|
||||
window.historyData = JSON.parse(localStorage.history);
|
||||
window.historyIndex = window.historyData.length;
|
||||
if (!localStorage.watches)
|
||||
localStorage.watches = "[]";
|
||||
window.watches = {};
|
||||
|
||||
function watch(name, f) {
|
||||
let status = document.getElementById("status");
|
||||
let cleanName = name.replace(/[^a-zA-Z0-9]/, '');
|
||||
status.innerHTML += `<div class="watch" id="watch_${cleanName}"><span class="expr" id="expr_${cleanName}">${escapeHtml(name)}</span><span class="res" id="res_${cleanName}"></span></div>`;
|
||||
window.watches[name] = f;
|
||||
}
|
||||
|
||||
var savedWatches = JSON.parse(localStorage.watches);
|
||||
savedWatches.forEach(w => watch(w[1], () => evaluate(w[0])));
|
||||
|
||||
if (typeof(window.web3) == 'object' && window.watches.latest == undefined)
|
||||
watch('latest', () => window.web3.eth.blockNumber);
|
||||
|
||||
|
||||
function refreshWatches() {
|
||||
for (n in window.watches) {
|
||||
let r = window.watches[n]();
|
||||
let cn = n.replace(/[^a-zA-Z0-9]/, '');
|
||||
let e = document.getElementById(`res_${cn}`);
|
||||
if (typeof(r) == 'object' && r.constructor.name == "Promise")
|
||||
r.then(r => e.innerHTML = displayReady(r));
|
||||
else
|
||||
e.innerHTML = displayReady(r);
|
||||
}
|
||||
}
|
||||
|
||||
function removeWatch(name) {
|
||||
let e = document.getElementById(`watch_${name}`);
|
||||
e.parentNode.removeChild(e);
|
||||
delete window.watches[name];
|
||||
}
|
||||
|
||||
function newLog(level, text) {
|
||||
let icon = {
|
||||
debug: " ",
|
||||
log: " ",
|
||||
warn: "⚠",
|
||||
error: "✖",
|
||||
info: "ℹ"
|
||||
};
|
||||
pushLine('<div class="entry log ' + level + 'Level"><span class="type">' + icon[level] + '</span><span class="text">' + escapeHtml(text) + '</span></div>');
|
||||
}
|
||||
|
||||
function exec() {
|
||||
let command = document.getElementById("command");
|
||||
let c = command.value;
|
||||
|
||||
if (c != '') {
|
||||
command.value = "";
|
||||
window.historyData.push(c);
|
||||
while (window.historyData.length > 1000)
|
||||
window.historyData.shift;
|
||||
localStorage.history = JSON.stringify(window.historyData);
|
||||
window.historyIndex = window.historyData.length;
|
||||
|
||||
var html = '';
|
||||
if (c.indexOf("//") == 0) {
|
||||
let n = c.substr(2);
|
||||
savedWatches = savedWatches.filter(x => x[1] != n);
|
||||
localStorage.watches = JSON.stringify(savedWatches);
|
||||
removeWatch(n);
|
||||
}
|
||||
else if (c.indexOf("//") != -1) {
|
||||
x = c.split("//");
|
||||
let e = x[0];
|
||||
savedWatches.push(x);
|
||||
localStorage.watches = JSON.stringify(savedWatches);
|
||||
watch(x[1], () => evaluate(e));
|
||||
pushLine('<div class="entry command"><span class="type">></span><span class="text">' + escapeHtml(c) + '</span></div>');
|
||||
pushLine('<div class="entry addwatch"><span class="type">✓</span><span class="text">Watch added</span></div>');
|
||||
}
|
||||
else {
|
||||
pushLine('<div class="entry command"><span class="type">></span><span class="text">' + escapeHtml(c) + '</span></div>');
|
||||
let res;
|
||||
try {
|
||||
res = evaluate(c);
|
||||
if (typeof(res) == 'object' && res !== null && res.constructor.name == "Promise") {
|
||||
let id = window.historyData.length;
|
||||
pushLine('<div class="entry result"><span class="type"><</span><span class="text" id="pending' + id + '">...</span></div>');
|
||||
res.then(r => document.getElementById('pending' + id).innerHTML = displayReady(r));
|
||||
} else {
|
||||
pushLine('<div class="entry result"><span class="type"><</span><span class="text">' + displayReady(res) + '</span></div>');
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
pushLine('<div class="entry error"><span class="type">✖</span><span class="text">Unhandled exception: ' + escapeHtml(err.message) + '</span></div>');
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshWatches();
|
||||
}
|
||||
|
||||
function pushLine(l) {
|
||||
document.getElementById("history").innerHTML += l
|
||||
var h = document.getElementById("history-wrap");
|
||||
h.scrollTop = h.scrollHeight;
|
||||
}
|
||||
|
||||
var autocompletes = [];
|
||||
var currentAuto = null;
|
||||
var currentPots = [];
|
||||
var currentStem = null;
|
||||
|
||||
function updateAutocomplete() {
|
||||
let v = document.getElementById("command").value;
|
||||
if (v.length == 0) {
|
||||
cancelAutocomplete();
|
||||
return;
|
||||
}
|
||||
let t = v.split('.');
|
||||
let last = t.pop();
|
||||
let tj = t.join('.');
|
||||
let ex = t.length > 0 ? tj : 'window';
|
||||
if (currentStem != tj) {
|
||||
autocompletes = eval('getAllPropertyNames('+ex+')');
|
||||
currentStem = tj;
|
||||
}
|
||||
let dl = document.getElementById("autocomplete");
|
||||
currentPots = autocompletes.filter(n => n.startsWith(last));
|
||||
if (currentPots.length > 0) {
|
||||
if (currentPots.indexOf(currentAuto) == -1)
|
||||
currentAuto = currentPots[0];
|
||||
dl.innerHTML = currentPots
|
||||
// .map(n => `${tj != '' ? tj + '.' : ''}${n}`)
|
||||
.map((n, i) => `<div id="pot${i}" class="${currentAuto == n ? 'ac-selected' : 'ac-unselected'}"><span class="ac-already">${escapeHtml(last)}</span><span class="ac-new">${escapeHtml(n.substr(last.length))}</div>`)
|
||||
.join('');
|
||||
dl.hidden = false;
|
||||
} else {
|
||||
cancelAutocomplete();
|
||||
}
|
||||
}
|
||||
|
||||
function enactAutocomplete() {
|
||||
if (currentAuto != null) {
|
||||
document.getElementById("command").value = (currentStem != '' ? currentStem + '.' : '') + currentAuto;
|
||||
cancelAutocomplete();
|
||||
}
|
||||
}
|
||||
|
||||
function cancelAutocomplete() {
|
||||
document.getElementById("autocomplete").hidden = true;
|
||||
currentAuto = null;
|
||||
}
|
||||
|
||||
function scrollAutocomplete(positive) {
|
||||
if (currentAuto != null) {
|
||||
var i = currentPots.indexOf(currentAuto);
|
||||
document.getElementById('pot' + i).classList = ['ac-unselected'];
|
||||
if (positive && i < currentPots.length - 1)
|
||||
++i;
|
||||
else if (!positive && i > 0)
|
||||
--i;
|
||||
currentAuto = currentPots[i];
|
||||
let sel = document.getElementById('pot' + i);
|
||||
sel.classList = ['ac-selected'];
|
||||
sel.scrollIntoViewIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("command").addEventListener("paste", updateAutocomplete);
|
||||
document.getElementById("command").addEventListener("input", updateAutocomplete);
|
||||
document.getElementById("command").addEventListener("focusout", cancelAutocomplete);
|
||||
document.getElementById("command").addEventListener("blur", cancelAutocomplete);
|
||||
|
||||
document.getElementById("command").addEventListener("keydown", function(event) {
|
||||
let el = document.getElementById("command");
|
||||
if (currentAuto != null) {
|
||||
if (event.keyCode == 38 || event.keyCode == 40) {
|
||||
event.preventDefault();
|
||||
scrollAutocomplete(event.keyCode == 40);
|
||||
}
|
||||
else if ((event.keyCode == 39 || event.keyCode == 9 || event.keyCode == 13) && el.selectionStart == el.value.length) {
|
||||
event.preventDefault();
|
||||
enactAutocomplete();
|
||||
}
|
||||
else if (event.keyCode == 27) {
|
||||
event.preventDefault();
|
||||
cancelAutocomplete();
|
||||
}
|
||||
} else {
|
||||
let command = document.getElementById("command");
|
||||
if (event.keyCode == 38 && window.historyIndex > 0) {
|
||||
event.preventDefault();
|
||||
window.historyIndex--;
|
||||
command.value = window.historyData[window.historyIndex];
|
||||
}
|
||||
if (event.keyCode == 40 && window.historyIndex < window.historyData.length) {
|
||||
event.preventDefault();
|
||||
window.historyIndex++;
|
||||
command.value = window.historyIndex < window.historyData.length ? window.historyData[window.historyIndex] : "";
|
||||
}
|
||||
}
|
||||
if (event.keyCode >= 48 || event.keyCode == 8) {
|
||||
let t = document.getElementById("command").value;
|
||||
setTimeout(() => {
|
||||
if (t != document.getElementById("command").value)
|
||||
updateAutocomplete();
|
||||
}, 0);
|
||||
}
|
||||
else {
|
||||
setTimeout(() => {
|
||||
if (el.selectionStart != el.value.length)
|
||||
cancelAutocomplete();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("command").addEventListener("keyup", function(event) {
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
exec();
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof(window.parity) == 'object') {
|
||||
document.getElementById("command").focus();
|
||||
window.web3 = web3;
|
||||
window.parity = parity;
|
||||
}
|
||||
refreshWatches();
|
||||
|
||||
["debug", "error", "info", "log", "warn"].forEach(n => { let old = window.console[n]; window.console[n] = x => { old(x); newLog(n, x); }; });
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///// Home comforts.
|
||||
|
||||
|
||||
// Usage example:
|
||||
// web3.eth.traceCall({
|
||||
// to: theChicken.address,
|
||||
// data: theChicken.withdraw.getData(100000000000000000),
|
||||
// gas: 100000
|
||||
// },
|
||||
// `["trace", "vmTrace", "stateDiff"]
|
||||
// )
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'traceCall',
|
||||
call: 'trace_call',
|
||||
params: 2,
|
||||
inputFormatter: [web3._extend.formatters.inputCallFormatter, null]
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'traceSendRawTransaction',
|
||||
call: 'trace_rawTransaction',
|
||||
params: 2,
|
||||
inputFormatter: [null, null]
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'traceReplayTransaction',
|
||||
call: 'trace_replayTransaction',
|
||||
params: 2,
|
||||
inputFormatter: [null, null]
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'setMode',
|
||||
call: 'ethcore_setMode',
|
||||
params: 1,
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'mode',
|
||||
call: 'ethcore_mode',
|
||||
params: 0,
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'traceTransaction',
|
||||
call: 'trace_Transaction',
|
||||
params: 1,
|
||||
inputFormatter: [null]
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'gasPriceStatistics',
|
||||
call: 'ethcore_gasPriceStatistics',
|
||||
params: 0,
|
||||
outputFormatter: function(a) { return a.map(web3.toBigNumber); }
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'registryAddress',
|
||||
call: 'ethcore_registryAddress',
|
||||
params: 0
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'accountsInfo',
|
||||
call: 'personal_accountsInfo',
|
||||
outputFormatter: function(m) { Object.keys(m).forEach(k => {
|
||||
m[k].meta = JSON.parse(m[k].meta);
|
||||
m[k].meta.name = m[k].name;
|
||||
m[k].meta.uuid = m[k].uuid;
|
||||
m[k] = m[k].meta;
|
||||
}); return m; },
|
||||
params: 0
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'setAccountName',
|
||||
call: 'personal_setAccountName',
|
||||
params: 2,
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'setAccountMeta',
|
||||
call: 'personal_setAccountMeta',
|
||||
params: 2,
|
||||
inputFormatter: [a => a, JSON.stringify]
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'postTransaction',
|
||||
call: 'eth_postTransaction',
|
||||
params: 1,
|
||||
inputFormatter: [web3._extend.formatters.inputCallFormatter]
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'postSign',
|
||||
call: 'eth_postSign',
|
||||
params: 1
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'encryptMessage',
|
||||
call: 'ethcore_encryptMessage',
|
||||
params: 2
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'checkRequest',
|
||||
call: 'eth_checkRequest',
|
||||
params: 1
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
new web3._extend.Method({
|
||||
name: 'listAccounts',
|
||||
call: 'ethcore_listAccounts',
|
||||
params: 0
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
{
|
||||
var postTransaction = web3.eth.postTransaction.bind(web3.eth);
|
||||
var sendTransaction = web3.eth.sendTransaction.bind(web3.eth);
|
||||
web3.eth.sendTransaction = function(options, f) {
|
||||
// No callback - do sync API.
|
||||
if (typeof f != "function")
|
||||
return sendTransaction(options);
|
||||
// Callback - use async API.
|
||||
var id = postTransaction(options);
|
||||
console.log("Posted trasaction id=" + id);
|
||||
var timerId = window.setInterval(check, 500);
|
||||
function check() {
|
||||
try {
|
||||
let r = web3.eth.checkRequest(id);
|
||||
if (typeof r == 'string') {
|
||||
clearInterval(timerId);
|
||||
if (r == "0x0000000000000000000000000000000000000000000000000000000000000000")
|
||||
f("Rejected", r);
|
||||
else
|
||||
f(null, r);
|
||||
} else if (r !== null) {
|
||||
console.log("checkRequest returned: " + r);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
clearInterval(timerId);
|
||||
f("Rejected", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
web3.eth.installInterceptor = function(interceptor) {
|
||||
var oldSendTransaction = web3.eth.sendTransaction.bind(web3.eth);
|
||||
web3.eth.sendTransaction = function(options, f) {
|
||||
if (interceptor(options) == false)
|
||||
return "0x0000000000000000000000000000000000000000000000000000000000000000";
|
||||
return oldSendTransaction(options, f);
|
||||
};
|
||||
}
|
||||
|
||||
web3.eth.reporter = function(e, r) {
|
||||
if (e) {
|
||||
console.log("Error confirming transaction: " + e);
|
||||
} else {
|
||||
var addr = r;
|
||||
var confirmed = false;
|
||||
var timer_id = window.setInterval(check, 500);
|
||||
function check() {
|
||||
var receipt = web3.eth.getTransactionReceipt(addr);
|
||||
if (receipt != null) {
|
||||
if (!confirmed) {
|
||||
console.log("Transaction confirmed (" + r + "); used " + receipt.gasUsed + " gas; left " + receipt.logs.length + " logs; mining...");
|
||||
confirmed = true;
|
||||
}
|
||||
if (typeof receipt.blockHash == 'string') {
|
||||
clearInterval(timer_id);
|
||||
console.log("Mined into block " + receipt.blockNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var oldSha3 = web3.sha3
|
||||
web3.sha3 = function(data, format) {
|
||||
if (typeof format !== 'string' || (format != 'hex' && format != 'bin'))
|
||||
format = data.startsWith('0x') ? 'hex' : 'bin';
|
||||
return oldSha3(data, {encoding: format});
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var Registry = web3.eth.contract([{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setOwner","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"}],"name":"confirmReverse","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserve","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"},{"name":"_value","type":"bytes32"}],"name":"set","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"drop","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"}],"name":"getAddress","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"}],"name":"setFee","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_to","type":"address"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserved","outputs":[{"name":"reserved","type":"bool"}],"type":"function"},{"constant":false,"inputs":[],"name":"drain","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_who","type":"address"}],"name":"proposeReverse","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"}],"name":"getUint","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"}],"name":"get","outputs":[{"name":"","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[],"name":"fee","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"reverse","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"},{"name":"_value","type":"uint256"}],"name":"setUint","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":false,"inputs":[],"name":"removeReverse","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"},{"name":"_value","type":"address"}],"name":"setAddress","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"Drained","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"FeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"owner","type":"address"}],"name":"Reserved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"oldOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"Transferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"owner","type":"address"}],"name":"Dropped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"key","type":"string"},{"indexed":false,"name":"plainKey","type":"string"}],"name":"DataChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"string"},{"indexed":true,"name":"reverse","type":"address"}],"name":"ReverseProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"string"},{"indexed":true,"name":"reverse","type":"address"}],"name":"ReverseConfirmed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"string"},{"indexed":true,"name":"reverse","type":"address"}],"name":"ReverseRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"old","type":"address"},{"indexed":true,"name":"current","type":"address"}],"name":"NewOwner","type":"event"}]);
|
||||
web3.eth.registry = Registry.at(web3.eth.registryAddress());
|
||||
web3.eth.registry.lookup = (name, field) => web3.eth.registry.get(web3.sha3(name), field);
|
||||
web3.eth.registry.lookupAddress = (name, field) => web3.eth.registry.getAddress(web3.sha3(name), field);
|
||||
web3.eth.registry.lookupUint = (name, field) => web3.eth.registry.getUint(web3.sha3(name), field);
|
||||
|
||||
var TokenReg = web3.eth.contract([{"constant":true,"inputs":[{"name":"_id","type":"uint256"}],"name":"token","outputs":[{"name":"addr","type":"address"},{"name":"tla","type":"string"},{"name":"base","type":"uint256"},{"name":"name","type":"string"},{"name":"owner","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setOwner","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_addr","type":"address"},{"name":"_tla","type":"string"},{"name":"_base","type":"uint256"},{"name":"_name","type":"string"}],"name":"register","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":false,"inputs":[{"name":"_fee","type":"uint256"}],"name":"setFee","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"_id","type":"uint256"},{"name":"_key","type":"bytes32"}],"name":"meta","outputs":[{"name":"","type":"bytes32"}],"type":"function"},{"constant":false,"inputs":[{"name":"_addr","type":"address"},{"name":"_tla","type":"string"},{"name":"_base","type":"uint256"},{"name":"_name","type":"string"},{"name":"_owner","type":"address"}],"name":"registerAs","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"_tla","type":"string"}],"name":"fromTLA","outputs":[{"name":"id","type":"uint256"},{"name":"addr","type":"address"},{"name":"base","type":"uint256"},{"name":"name","type":"string"},{"name":"owner","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[],"name":"drain","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"tokenCount","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_id","type":"uint256"}],"name":"unregister","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"_addr","type":"address"}],"name":"fromAddress","outputs":[{"name":"id","type":"uint256"},{"name":"tla","type":"string"},{"name":"base","type":"uint256"},{"name":"name","type":"string"},{"name":"owner","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_id","type":"uint256"},{"name":"_key","type":"bytes32"},{"name":"_value","type":"bytes32"}],"name":"setMeta","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"fee","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tla","type":"string"},{"indexed":true,"name":"id","type":"uint256"},{"indexed":false,"name":"addr","type":"address"},{"indexed":false,"name":"name","type":"string"}],"name":"Registered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tla","type":"string"},{"indexed":true,"name":"id","type":"uint256"}],"name":"Unregistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":true,"name":"key","type":"bytes32"},{"indexed":false,"name":"value","type":"bytes32"}],"name":"MetaChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"old","type":"address"},{"indexed":true,"name":"current","type":"address"}],"name":"NewOwner","type":"event"}]);
|
||||
web3.eth.tokenReg = TokenReg.at(web3.eth.registry.lookupAddress('tokenreg', 'A'));
|
||||
}
|
||||
|
||||
/* eslint-enable */
|
@ -73,5 +73,14 @@
|
||||
"author": "Parity Team <admin@ethcore.io>",
|
||||
"version": "1.0.0",
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "0xa635a9326814bded464190eddf0bdb90ce92d40ea2359cf553ea80e3c5a4076c",
|
||||
"url": "console",
|
||||
"name": "Parity/Web3 console",
|
||||
"description": "A Javascript development console complete with web3 and parity objects.",
|
||||
"version": "0.3",
|
||||
"author": "Gav Wood <gavin@ethcore.io>",
|
||||
"visible": true
|
||||
}
|
||||
]
|
||||
|
@ -150,7 +150,11 @@ module.exports = {
|
||||
});
|
||||
|
||||
const plugins = Shared.getPlugins().concat(
|
||||
new CopyWebpackPlugin([{ from: './error_pages.css', to: 'styles.css' }], {}),
|
||||
new CopyWebpackPlugin([
|
||||
{ from: './error_pages.css', to: 'styles.css' },
|
||||
{ from: 'dapps/static' }
|
||||
], {}),
|
||||
|
||||
new WebpackErrorNotificationPlugin(),
|
||||
|
||||
new webpack.DllReferencePlugin({
|
||||
|
Loading…
Reference in New Issue
Block a user