aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-29 06:33:20 +0800
committerobscuren <geffobscura@gmail.com>2015-01-29 06:33:20 +0800
commitf80fe9776335312615ce3b1a565e4f48e171ab0d (patch)
treeca65fccaa96721c5bd111cb28b679e29c2315448 /cmd
parentcbf1d07073fcb6d2859b0617f1e84c0cb512bbbb (diff)
downloadgo-tangerine-f80fe9776335312615ce3b1a565e4f48e171ab0d.tar
go-tangerine-f80fe9776335312615ce3b1a565e4f48e171ab0d.tar.gz
go-tangerine-f80fe9776335312615ce3b1a565e4f48e171ab0d.tar.bz2
go-tangerine-f80fe9776335312615ce3b1a565e4f48e171ab0d.tar.lz
go-tangerine-f80fe9776335312615ce3b1a565e4f48e171ab0d.tar.xz
go-tangerine-f80fe9776335312615ce3b1a565e4f48e171ab0d.tar.zst
go-tangerine-f80fe9776335312615ce3b1a565e4f48e171ab0d.zip
removed old js yet again
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mist/assets/ext/LICENSE14
-rw-r--r--cmd/mist/assets/ext/README.md96
-rw-r--r--cmd/mist/assets/ext/big.js397
-rw-r--r--cmd/mist/assets/ext/bower.json51
-rw-r--r--cmd/mist/assets/ext/dist/ethereum.js1198
-rw-r--r--cmd/mist/assets/ext/dist/ethereum.js.map29
-rw-r--r--cmd/mist/assets/ext/dist/ethereum.min.js1
-rw-r--r--cmd/mist/assets/ext/example/balance.html46
-rw-r--r--cmd/mist/assets/ext/example/contract.html73
-rw-r--r--cmd/mist/assets/ext/example/natspec_contract.html76
-rw-r--r--cmd/mist/assets/ext/example/node-app.js12
-rw-r--r--cmd/mist/assets/ext/filter.js66
-rw-r--r--cmd/mist/assets/ext/gulpfile.js104
-rw-r--r--cmd/mist/assets/ext/home.html22
-rw-r--r--cmd/mist/assets/ext/html_messaging.js481
-rw-r--r--cmd/mist/assets/ext/http.js30
-rw-r--r--cmd/mist/assets/ext/index.js11
-rw-r--r--cmd/mist/assets/ext/lib/abi.js410
-rw-r--r--cmd/mist/assets/ext/lib/contract.js145
-rw-r--r--cmd/mist/assets/ext/lib/filter.js73
-rw-r--r--cmd/mist/assets/ext/lib/httpsync.js70
-rw-r--r--cmd/mist/assets/ext/lib/local.js18
-rw-r--r--cmd/mist/assets/ext/lib/providermanager.js110
-rw-r--r--cmd/mist/assets/ext/lib/qtsync.js32
-rw-r--r--cmd/mist/assets/ext/lib/web3.js327
-rw-r--r--cmd/mist/assets/ext/package.json69
-rw-r--r--cmd/mist/assets/ext/q.js1909
-rw-r--r--cmd/mist/assets/ext/qml_messaging.js30
-rw-r--r--cmd/mist/assets/ext/qt_messaging_adapter.js38
-rw-r--r--cmd/mist/assets/ext/setup.js8
-rw-r--r--cmd/mist/assets/ext/string.js75
-rw-r--r--cmd/mist/assets/ext/test.html44
-rw-r--r--cmd/mist/assets/ext/test/abi.parsers.js860
-rw-r--r--cmd/mist/assets/ext/test/db.methods.js14
-rw-r--r--cmd/mist/assets/ext/test/eth.methods.js34
-rw-r--r--cmd/mist/assets/ext/test/mocha.opts2
-rw-r--r--cmd/mist/assets/ext/test/shh.methods.js14
-rw-r--r--cmd/mist/assets/ext/test/utils.js19
-rw-r--r--cmd/mist/assets/ext/test/web3.methods.js10
39 files changed, 0 insertions, 7018 deletions
diff --git a/cmd/mist/assets/ext/LICENSE b/cmd/mist/assets/ext/LICENSE
deleted file mode 100644
index 0f187b873..000000000
--- a/cmd/mist/assets/ext/LICENSE
+++ /dev/null
@@ -1,14 +0,0 @@
-This file is part of ethereum.js.
-
-ethereum.js is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-ethereum.js 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 Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with ethereum.js. If not, see <http://www.gnu.org/licenses/>. \ No newline at end of file
diff --git a/cmd/mist/assets/ext/README.md b/cmd/mist/assets/ext/README.md
deleted file mode 100644
index 02988fe73..000000000
--- a/cmd/mist/assets/ext/README.md
+++ /dev/null
@@ -1,96 +0,0 @@
-# Ethereum JavaScript API
-
-This is the Ethereum compatible [JavaScript API](https://github.com/ethereum/wiki/wiki/JavaScript-API)
-which implements the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC) spec. It's available on npm as a node module and also for bower and component as an embeddable js
-
-[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![dependency status][dep-image]][dep-url] [![dev dependency status][dep-dev-image]][dep-dev-url]
-
-<!-- [![browser support](https://ci.testling.com/ethereum/ethereum.js.png)](https://ci.testling.com/ethereum/ethereum.js) -->
-
-## Installation
-
-### Node.js
-
- npm install ethereum.js
-
-### For browser
-Bower
-
- bower install ethereum.js
-
-Component
-
- component install ethereum/ethereum.js
-
-* Include `ethereum.min.js` in your html file.
-* Include [bignumber.js](https://github.com/MikeMcl/bignumber.js/)
-
-## Usage
-Require the library:
-
- var web3 = require('web3');
-
-Set a provider (QtProvider, WebSocketProvider, HttpRpcProvider)
-
- var web3.setProvider(new web3.providers.WebSocketProvider('ws://localhost:40404/eth'));
-
-There you go, now you can use it:
-
-```
-var coinbase = web3.eth.coinbase;
-var balance = web3.eth.balanceAt(coinbase);
-```
-
-
-For another example see `example/index.html`.
-
-## Contribute!
-
-### Requirements
-
-* Node.js
-* npm
-* gulp (build)
-* mocha (tests)
-
-```bash
-sudo apt-get update
-sudo apt-get install nodejs
-sudo apt-get install npm
-sudo apt-get install nodejs-legacy
-```
-
-### Building (gulp)
-
-```bash
-npm run-script build
-```
-
-
-### Testing (mocha)
-
-```bash
-npm test
-```
-
-**Please note this repo is in it's early stage.**
-
-If you'd like to run a WebSocket ethereum node check out
-[go-ethereum](https://github.com/ethereum/go-ethereum).
-
-To install ethereum and spawn a node:
-
-```
-go get github.com/ethereum/go-ethereum/ethereum
-ethereum -ws -loglevel=4
-```
-
-[npm-image]: https://badge.fury.io/js/ethereum.js.png
-[npm-url]: https://npmjs.org/package/ethereum.js
-[travis-image]: https://travis-ci.org/ethereum/ethereum.js.svg
-[travis-url]: https://travis-ci.org/ethereum/ethereum.js
-[dep-image]: https://david-dm.org/ethereum/ethereum.js.svg
-[dep-url]: https://david-dm.org/ethereum/ethereum.js
-[dep-dev-image]: https://david-dm.org/ethereum/ethereum.js/dev-status.svg
-[dep-dev-url]: https://david-dm.org/ethereum/ethereum.js#info=devDependencies
-
diff --git a/cmd/mist/assets/ext/big.js b/cmd/mist/assets/ext/big.js
deleted file mode 100644
index 145a6aa6c..000000000
--- a/cmd/mist/assets/ext/big.js
+++ /dev/null
@@ -1,397 +0,0 @@
-// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
-//
-// This library 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 2.1 of the License, or (at your option) any later version.
-//
-// This library 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 this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-// MA 02110-1301 USA
-
-var BigNumber = (function () {
- var base = 10000000, logBase = 7;
- var sign = {
- positive: false,
- negative: true
- };
-
- var normalize = function (first, second) {
- var a = first.value, b = second.value;
- var length = a.length > b.length ? a.length : b.length;
- for (var i = 0; i < length; i++) {
- a[i] = a[i] || 0;
- b[i] = b[i] || 0;
- }
- for (var i = length - 1; i >= 0; i--) {
- if (a[i] === 0 && b[i] === 0) {
- a.pop();
- b.pop();
- } else break;
- }
- if (!a.length) a = [0], b = [0];
- first.value = a;
- second.value = b;
- };
-
- var parse = function (text, first) {
- if (typeof text === "object") return text;
- text += "";
- var s = sign.positive, value = [];
- if (text[0] === "-") {
- s = sign.negative;
- text = text.slice(1);
- }
- var base = 10;
- if (text.slice(0, 2) == "0x") {
- base = 16;
- text = text.slice(2);
- }
- else {
- var texts = text.split("e");
- if (texts.length > 2) throw new Error("Invalid integer");
- if (texts[1]) {
- var exp = texts[1];
- if (exp[0] === "+") exp = exp.slice(1);
- exp = parse(exp);
- if (exp.lesser(0)) throw new Error("Cannot include negative exponent part for integers");
- while (exp.notEquals(0)) {
- texts[0] += "0";
- exp = exp.prev();
- }
- }
- text = texts[0];
- }
- if (text === "-0") text = "0";
- text = text.toUpperCase();
- var isValid = (base == 16 ? /^[0-9A-F]*$/ : /^[0-9]+$/).test(text);
- if (!isValid) throw new Error("Invalid integer");
- if (base == 16) {
- var val = BigNumber(0);
- while (text.length) {
- v = text.charCodeAt(0) - 48;
- if (v > 9)
- v -= 7;
- text = text.slice(1);
- val = val.times(16).plus(v);
- }
- return val;
- }
- else {
- while (text.length) {
- var divider = text.length > logBase ? text.length - logBase : 0;
- value.push(+text.slice(divider));
- text = text.slice(0, divider);
- }
- var val = BigNumber(value, s);
- if (first) normalize(first, val);
- return val;
- }
- };
-
- var goesInto = function (a, b) {
- var a = BigNumber(a, sign.positive), b = BigNumber(b, sign.positive);
- if (a.equals(0)) throw new Error("Cannot divide by 0");
- var n = 0;
- do {
- var inc = 1;
- var c = BigNumber(a.value, sign.positive), t = c.times(10);
- while (t.lesser(b)) {
- c = t;
- inc *= 10;
- t = t.times(10);
- }
- while (c.lesserOrEquals(b)) {
- b = b.minus(c);
- n += inc;
- }
- } while (a.lesserOrEquals(b));
-
- return {
- remainder: b.value,
- result: n
- };
- };
-
- var BigNumber = function (value, s) {
- var self = {
- value: value,
- sign: s
- };
- var o = {
- value: value,
- sign: s,
- negate: function (m) {
- var first = m || self;
- return BigNumber(first.value, !first.sign);
- },
- abs: function (m) {
- var first = m || self;
- return BigNumber(first.value, sign.positive);
- },
- add: function (n, m) {
- var s, first = self, second;
- if (m) (first = parse(n)) && (second = parse(m));
- else second = parse(n, first);
- s = first.sign;
- if (first.sign !== second.sign) {
- first = BigNumber(first.value, sign.positive);
- second = BigNumber(second.value, sign.positive);
- return s === sign.positive ?
- o.subtract(first, second) :
- o.subtract(second, first);
- }
- normalize(first, second);
- var a = first.value, b = second.value;
- var result = [],
- carry = 0;
- for (var i = 0; i < a.length || carry > 0; i++) {
- var sum = (a[i] || 0) + (b[i] || 0) + carry;
- carry = sum >= base ? 1 : 0;
- sum -= carry * base;
- result.push(sum);
- }
- return BigNumber(result, s);
- },
- plus: function (n, m) {
- return o.add(n, m);
- },
- subtract: function (n, m) {
- var first = self, second;
- if (m) (first = parse(n)) && (second = parse(m));
- else second = parse(n, first);
- if (first.sign !== second.sign) return o.add(first, o.negate(second));
- if (first.sign === sign.negative) return o.subtract(o.negate(second), o.negate(first));
- if (o.compare(first, second) === -1) return o.negate(o.subtract(second, first));
- var a = first.value, b = second.value;
- var result = [],
- borrow = 0;
- for (var i = 0; i < a.length; i++) {
- var tmp = a[i] - borrow;
- borrow = tmp < b[i] ? 1 : 0;
- var minuend = (borrow * base) + tmp - b[i];
- result.push(minuend);
- }
- return BigNumber(result, sign.positive);
- },
- minus: function (n, m) {
- return o.subtract(n, m);
- },
- multiply: function (n, m) {
- var s, first = self, second;
- if (m) (first = parse(n)) && (second = parse(m));
- else second = parse(n, first);
- s = first.sign !== second.sign;
- var a = first.value, b = second.value;
- var resultSum = [];
- for (var i = 0; i < a.length; i++) {
- resultSum[i] = [];
- var j = i;
- while (j--) {
- resultSum[i].push(0);
- }
- }
- var carry = 0;
- for (var i = 0; i < a.length; i++) {
- var x = a[i];
- for (var j = 0; j < b.length || carry > 0; j++) {
- var y = b[j];
- var product = y ? (x * y) + carry : carry;
- carry = product > base ? Math.floor(product / base) : 0;
- product -= carry * base;
- resultSum[i].push(product);
- }
- }
- var max = -1;
- for (var i = 0; i < resultSum.length; i++) {
- var len = resultSum[i].length;
- if (len > max) max = len;
- }
- var result = [], carry = 0;
- for (var i = 0; i < max || carry > 0; i++) {
- var sum = carry;
- for (var j = 0; j < resultSum.length; j++) {
- sum += resultSum[j][i] || 0;
- }
- carry = sum > base ? Math.floor(sum / base) : 0;
- sum -= carry * base;
- result.push(sum);
- }
- return BigNumber(result, s);
- },
- times: function (n, m) {
- return o.multiply(n, m);
- },
- divmod: function (n, m) {
- var s, first = self, second;
- if (m) (first = parse(n)) && (second = parse(m));
- else second = parse(n, first);
- s = first.sign !== second.sign;
- if (BigNumber(first.value, first.sign).equals(0)) return {
- quotient: BigNumber([0], sign.positive),
- remainder: BigNumber([0], sign.positive)
- };
- if (second.equals(0)) throw new Error("Cannot divide by zero");
- var a = first.value, b = second.value;
- var result = [], remainder = [];
- for (var i = a.length - 1; i >= 0; i--) {
- var n = [a[i]].concat(remainder);
- var quotient = goesInto(b, n);
- result.push(quotient.result);
- remainder = quotient.remainder;
- }
- result.reverse();
- return {
- quotient: BigNumber(result, s),
- remainder: BigNumber(remainder, first.sign)
- };
- },
- divide: function (n, m) {
- return o.divmod(n, m).quotient;
- },
- over: function (n, m) {
- return o.divide(n, m);
- },
- mod: function (n, m) {
- return o.divmod(n, m).remainder;
- },
- pow: function (n, m) {
- var first = self, second;
- if (m) (first = parse(n)) && (second = parse(m));
- else second = parse(n, first);
- var a = first, b = second;
- if (b.lesser(0)) return ZERO;
- if (b.equals(0)) return ONE;
- var result = BigNumber(a.value, a.sign);
-
- if (b.mod(2).equals(0)) {
- var c = result.pow(b.over(2));
- return c.times(c);
- } else {
- return result.times(result.pow(b.minus(1)));
- }
- },
- next: function (m) {
- var first = m || self;
- return o.add(first, 1);
- },
- prev: function (m) {
- var first = m || self;
- return o.subtract(first, 1);
- },
- compare: function (n, m) {
- var first = self, second;
- if (m) (first = parse(n)) && (second = parse(m, first));
- else second = parse(n, first);
- normalize(first, second);
- if (first.value.length === 1 && second.value.length === 1 && first.value[0] === 0 && second.value[0] === 0) return 0;
- if (second.sign !== first.sign) return first.sign === sign.positive ? 1 : -1;
- var multiplier = first.sign === sign.positive ? 1 : -1;
- var a = first.value, b = second.value;
- for (var i = a.length - 1; i >= 0; i--) {
- if (a[i] > b[i]) return 1 * multiplier;
- if (b[i] > a[i]) return -1 * multiplier;
- }
- return 0;
- },
- compareAbs: function (n, m) {
- var first = self, second;
- if (m) (first = parse(n)) && (second = parse(m, first));
- else second = parse(n, first);
- first.sign = second.sign = sign.positive;
- return o.compare(first, second);
- },
- equals: function (n, m) {
- return o.compare(n, m) === 0;
- },
- notEquals: function (n, m) {
- return !o.equals(n, m);
- },
- lesser: function (n, m) {
- return o.compare(n, m) < 0;
- },
- greater: function (n, m) {
- return o.compare(n, m) > 0;
- },
- greaterOrEquals: function (n, m) {
- return o.compare(n, m) >= 0;
- },
- lesserOrEquals: function (n, m) {
- return o.compare(n, m) <= 0;
- },
- isPositive: function (m) {
- var first = m || self;
- return first.sign === sign.positive;
- },
- isNegative: function (m) {
- var first = m || self;
- return first.sign === sign.negative;
- },
- isEven: function (m) {
- var first = m || self;
- return first.value[0] % 2 === 0;
- },
- isOdd: function (m) {
- var first = m || self;
- return first.value[0] % 2 === 1;
- },
- toString: function (m) {
- var first = m || self;
- var str = "", len = first.value.length;
- while (len--) {
- if (first.value[len].toString().length === 8) str += first.value[len];
- else str += (base.toString() + first.value[len]).slice(-logBase);
- }
- while (str[0] === "0") {
- str = str.slice(1);
- }
- if (!str.length) str = "0";
- var s = (first.sign === sign.positive || str == "0") ? "" : "-";
- return s + str;
- },
- toHex: function (m) {
- var first = m || self;
- var str = "";
- var l = this.abs();
- while (l > 0) {
- var qr = l.divmod(256);
- var b = qr.remainder.toJSNumber();
- str = (b >> 4).toString(16) + (b & 15).toString(16) + str;
- l = qr.quotient;
- }
- return (this.isNegative() ? "-" : "") + "0x" + str;
- },
- toJSNumber: function (m) {
- return +o.toString(m);
- },
- valueOf: function (m) {
- return o.toJSNumber(m);
- }
- };
- return o;
- };
-
- var ZERO = BigNumber([0], sign.positive);
- var ONE = BigNumber([1], sign.positive);
- var MINUS_ONE = BigNumber([1], sign.negative);
-
- var fnReturn = function (a) {
- if (typeof a === "undefined") return ZERO;
- return parse(a);
- };
- fnReturn.zero = ZERO;
- fnReturn.one = ONE;
- fnReturn.minusOne = MINUS_ONE;
- return fnReturn;
-})();
-
-if (typeof module !== "undefined") {
- module.exports = BigNumber;
-}
-
diff --git a/cmd/mist/assets/ext/bower.json b/cmd/mist/assets/ext/bower.json
deleted file mode 100644
index e3a9cb3c5..000000000
--- a/cmd/mist/assets/ext/bower.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "name": "ethereum.js",
- "namespace": "ethereum",
- "version": "0.0.10",
- "description": "Ethereum Compatible JavaScript API",
- "main": ["./dist/ethereum.js", "./dist/ethereum.min.js"],
- "dependencies": {
- "bignumber.js": ">=2.0.0"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/ethereum/ethereum.js.git"
- },
- "homepage": "https://github.com/ethereum/ethereum.js",
- "bugs": {
- "url": "https://github.com/ethereum/ethereum.js/issues"
- },
- "keywords": [
- "ethereum",
- "javascript",
- "API"
- ],
- "authors": [
- {
- "name": "Marek Kotewicz",
- "email": "marek@ethdev.com",
- "homepage": "https://github.com/debris"
- },
- {
- "name": "Marian Oancea",
- "email": "marian@ethdev.com",
- "homepage": "https://github.com/cubedro"
- }
- ],
- "license": "LGPL-3.0",
- "ignore": [
- "example",
- "lib",
- "node_modules",
- "package.json",
- ".bowerrc",
- ".editorconfig",
- ".gitignore",
- ".jshintrc",
- ".npmignore",
- ".travis.yml",
- "gulpfile.js",
- "index.js",
- "**/*.txt"
- ]
-}
diff --git a/cmd/mist/assets/ext/dist/ethereum.js b/cmd/mist/assets/ext/dist/ethereum.js
deleted file mode 100644
index 6e6c5020c..000000000
--- a/cmd/mist/assets/ext/dist/ethereum.js
+++ /dev/null
@@ -1,1198 +0,0 @@
-require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file abi.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-// TODO: is these line is supposed to be here?
-if ("build" !== 'build') {/*
- var BigNumber = require('bignumber.js'); // jshint ignore:line
-*/}
-
-var web3 = require('./web3'); // jshint ignore:line
-
-BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_DOWN });
-
-var ETH_PADDING = 32;
-
-/// method signature length in bytes
-var ETH_METHOD_SIGNATURE_LENGTH = 4;
-
-/// Finds first index of array element matching pattern
-/// @param array
-/// @param callback pattern
-/// @returns index of element
-var findIndex = function (array, callback) {
- var end = false;
- var i = 0;
- for (; i < array.length && !end; i++) {
- end = callback(array[i]);
- }
- return end ? i - 1 : -1;
-};
-
-/// @returns a function that is used as a pattern for 'findIndex'
-var findMethodIndex = function (json, methodName) {
- return findIndex(json, function (method) {
- return method.name === methodName;
- });
-};
-
-/// @returns method with given method name
-var getMethodWithName = function (json, methodName) {
- var index = findMethodIndex(json, methodName);
- if (index === -1) {
- console.error('method ' + methodName + ' not found in the abi');
- return undefined;
- }
- return json[index];
-};
-
-/// @param string string to be padded
-/// @param number of characters that result string should have
-/// @param sign, by default 0
-/// @returns right aligned string
-var padLeft = function (string, chars, sign) {
- return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
-};
-
-/// @param expected type prefix (string)
-/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false
-var prefixedType = function (prefix) {
- return function (type) {
- return type.indexOf(prefix) === 0;
- };
-};
-
-/// @param expected type name (string)
-/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false
-var namedType = function (name) {
- return function (type) {
- return name === type;
- };
-};
-
-var arrayType = function (type) {
- return type.slice(-2) === '[]';
-};
-
-/// Formats input value to byte representation of int
-/// If value is negative, return it's two's complement
-/// If the value is floating point, round it down
-/// @returns right-aligned byte representation of int
-var formatInputInt = function (value) {
- var padding = ETH_PADDING * 2;
- if (value instanceof BigNumber || typeof value === 'number') {
- if (typeof value === 'number')
- value = new BigNumber(value);
- value = value.round();
-
- if (value.lessThan(0))
- value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
- value = value.toString(16);
- }
- else if (value.indexOf('0x') === 0)
- value = value.substr(2);
- else if (typeof value === 'string')
- value = formatInputInt(new BigNumber(value));
- else
- value = (+value).toString(16);
- return padLeft(value, padding);
-};
-
-/// Formats input value to byte representation of string
-/// @returns left-algined byte representation of string
-var formatInputString = function (value) {
- return web3.fromAscii(value, ETH_PADDING).substr(2);
-};
-
-/// Formats input value to byte representation of bool
-/// @returns right-aligned byte representation bool
-var formatInputBool = function (value) {
- return '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');
-};
-
-/// Formats input value to byte representation of real
-/// Values are multiplied by 2^m and encoded as integers
-/// @returns byte representation of real
-var formatInputReal = function (value) {
- return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
-};
-
-var dynamicTypeBytes = function (type, value) {
- // TODO: decide what to do with array of strings
- if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
- return formatInputInt(value.length);
- return "";
-};
-
-/// Setups input formatters for solidity types
-/// @returns an array of input formatters
-var setupInputTypes = function () {
-
- return [
- { type: prefixedType('uint'), format: formatInputInt },
- { type: prefixedType('int'), format: formatInputInt },
- { type: prefixedType('hash'), format: formatInputInt },
- { type: prefixedType('string'), format: formatInputString },
- { type: prefixedType('real'), format: formatInputReal },
- { type: prefixedType('ureal'), format: formatInputReal },
- { type: namedType('address'), format: formatInputInt },
- { type: namedType('bool'), format: formatInputBool }
- ];
-};
-
-var inputTypes = setupInputTypes();
-
-/// Formats input params to bytes
-/// @param contract json abi
-/// @param name of the method that we want to use
-/// @param array of params that will be formatted to bytes
-/// @returns bytes representation of input params
-var toAbiInput = function (json, methodName, params) {
- var bytes = "";
-
- var method = getMethodWithName(json, methodName);
- var padding = ETH_PADDING * 2;
-
- /// first we iterate in search for dynamic
- method.inputs.forEach(function (input, index) {
- bytes += dynamicTypeBytes(input.type, params[index]);
- });
-
- method.inputs.forEach(function (input, i) {
- var typeMatch = false;
- for (var j = 0; j < inputTypes.length && !typeMatch; j++) {
- typeMatch = inputTypes[j].type(method.inputs[i].type, params[i]);
- }
- if (!typeMatch) {
- console.error('input parser does not support type: ' + method.inputs[i].type);
- }
-
- var formatter = inputTypes[j - 1].format;
- var toAppend = "";
-
- if (arrayType(method.inputs[i].type))
- toAppend = params[i].reduce(function (acc, curr) {
- return acc + formatter(curr);
- }, "");
- else
- toAppend = formatter(params[i]);
-
- bytes += toAppend;
- });
- return bytes;
-};
-
-/// Check if input value is negative
-/// @param value is hex format
-/// @returns true if it is negative, otherwise false
-var signedIsNegative = function (value) {
- return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
-};
-
-/// Formats input right-aligned input bytes to int
-/// @returns right-aligned input bytes formatted to int
-var formatOutputInt = function (value) {
- value = value || "0";
- // check if it's negative number
- // it it is, return two's complement
- if (signedIsNegative(value)) {
- return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
- }
- return new BigNumber(value, 16);
-};
-
-/// Formats big right-aligned input bytes to uint
-/// @returns right-aligned input bytes formatted to uint
-var formatOutputUInt = function (value) {
- value = value || "0";
- return new BigNumber(value, 16);
-};
-
-/// @returns input bytes formatted to real
-var formatOutputReal = function (value) {
- return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128));
-};
-
-/// @returns input bytes formatted to ureal
-var formatOutputUReal = function (value) {
- return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128));
-};
-
-/// @returns right-aligned input bytes formatted to hex
-var formatOutputHash = function (value) {
- return "0x" + value;
-};
-
-/// @returns right-aligned input bytes formatted to bool
-var formatOutputBool = function (value) {
- return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
-};
-
-/// @returns left-aligned input bytes formatted to ascii string
-var formatOutputString = function (value) {
- return web3.toAscii(value);
-};
-
-/// @returns right-aligned input bytes formatted to address
-var formatOutputAddress = function (value) {
- return "0x" + value.slice(value.length - 40, value.length);
-};
-
-var dynamicBytesLength = function (type) {
- if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
- return ETH_PADDING * 2;
- return 0;
-};
-
-/// Setups output formaters for solidity types
-/// @returns an array of output formatters
-var setupOutputTypes = function () {
-
- return [
- { type: prefixedType('uint'), format: formatOutputUInt },
- { type: prefixedType('int'), format: formatOutputInt },
- { type: prefixedType('hash'), format: formatOutputHash },
- { type: prefixedType('string'), format: formatOutputString },
- { type: prefixedType('real'), format: formatOutputReal },
- { type: prefixedType('ureal'), format: formatOutputUReal },
- { type: namedType('address'), format: formatOutputAddress },
- { type: namedType('bool'), format: formatOutputBool }
- ];
-};
-
-var outputTypes = setupOutputTypes();
-
-/// Formats output bytes back to param list
-/// @param contract json abi
-/// @param name of the method that we want to use
-/// @param bytes representtion of output
-/// @returns array of output params
-var fromAbiOutput = function (json, methodName, output) {
-
- output = output.slice(2);
- var result = [];
- var method = getMethodWithName(json, methodName);
- var padding = ETH_PADDING * 2;
-
- var dynamicPartLength = method.outputs.reduce(function (acc, curr) {
- return acc + dynamicBytesLength(curr.type);
- }, 0);
-
- var dynamicPart = output.slice(0, dynamicPartLength);
- output = output.slice(dynamicPartLength);
-
- method.outputs.forEach(function (out, i) {
- var typeMatch = false;
- for (var j = 0; j < outputTypes.length && !typeMatch; j++) {
- typeMatch = outputTypes[j].type(method.outputs[i].type);
- }
-
- if (!typeMatch) {
- console.error('output parser does not support type: ' + method.outputs[i].type);
- }
-
- var formatter = outputTypes[j - 1].format;
- if (arrayType(method.outputs[i].type)) {
- var size = formatOutputUInt(dynamicPart.slice(0, padding));
- dynamicPart = dynamicPart.slice(padding);
- var array = [];
- for (var k = 0; k < size; k++) {
- array.push(formatter(output.slice(0, padding)));
- output = output.slice(padding);
- }
- result.push(array);
- }
- else if (prefixedType('string')(method.outputs[i].type)) {
- dynamicPart = dynamicPart.slice(padding);
- result.push(formatter(output.slice(0, padding)));
- output = output.slice(padding);
- } else {
- result.push(formatter(output.slice(0, padding)));
- output = output.slice(padding);
- }
- });
-
- return result;
-};
-
-/// @returns display name for method eg. multiply(uint256) -> multiply
-var methodDisplayName = function (method) {
- var length = method.indexOf('(');
- return length !== -1 ? method.substr(0, length) : method;
-};
-
-/// @returns overloaded part of method's name
-var methodTypeName = function (method) {
- /// TODO: make it not vulnerable
- var length = method.indexOf('(');
- return length !== -1 ? method.substr(length + 1, method.length - 1 - (length + 1)) : "";
-};
-
-/// @param json abi for contract
-/// @returns input parser object for given json abi
-var inputParser = function (json) {
- var parser = {};
- json.forEach(function (method) {
- var displayName = methodDisplayName(method.name);
- var typeName = methodTypeName(method.name);
-
- var impl = function () {
- var params = Array.prototype.slice.call(arguments);
- return toAbiInput(json, method.name, params);
- };
-
- if (parser[displayName] === undefined) {
- parser[displayName] = impl;
- }
-
- parser[displayName][typeName] = impl;
- });
-
- return parser;
-};
-
-/// @param json abi for contract
-/// @returns output parser for given json abi
-var outputParser = function (json) {
- var parser = {};
- json.forEach(function (method) {
-
- var displayName = methodDisplayName(method.name);
- var typeName = methodTypeName(method.name);
-
- var impl = function (output) {
- return fromAbiOutput(json, method.name, output);
- };
-
- if (parser[displayName] === undefined) {
- parser[displayName] = impl;
- }
-
- parser[displayName][typeName] = impl;
- });
-
- return parser;
-};
-
-/// @param method name for which we want to get method signature
-/// @returns (promise) contract method signature for method with given name
-var methodSignature = function (name) {
- return web3.sha3(web3.fromAscii(name)).slice(0, 2 + ETH_METHOD_SIGNATURE_LENGTH * 2);
-};
-
-module.exports = {
- inputParser: inputParser,
- outputParser: outputParser,
- methodSignature: methodSignature,
- methodDisplayName: methodDisplayName,
- methodTypeName: methodTypeName,
- getMethodWithName: getMethodWithName
-};
-
-
-},{"./web3":7}],2:[function(require,module,exports){
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file contract.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3'); // jshint ignore:line
-var abi = require('./abi');
-
-/**
- * This method should be called when we want to call / transact some solidity method from javascript
- * it returns an object which has same methods available as solidity contract description
- * usage example:
- *
- * var abi = [{
- * name: 'myMethod',
- * inputs: [{ name: 'a', type: 'string' }],
- * outputs: [{name: 'd', type: 'string' }]
- * }]; // contract abi
- *
- * var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object
- *
- * myContract.myMethod('this is test string param for call'); // myMethod call (implicit, default)
- * myContract.call().myMethod('this is test string param for call'); // myMethod call (explicit)
- * myContract.transact().myMethod('this is test string param for transact'); // myMethod transact
- *
- * @param address - address of the contract, which should be called
- * @param desc - abi json description of the contract, which is being created
- * @returns contract object
- */
-
-var contract = function (address, desc) {
-
- desc.forEach(function (method) {
- // workaround for invalid assumption that method.name is the full anonymous prototype of the method.
- // it's not. it's just the name. the rest of the code assumes it's actually the anonymous
- // prototype, so we make it so as a workaround.
- if (method.name.indexOf('(') === -1) {
- var displayName = method.name;
- var typeName = method.inputs.map(function(i){return i.type; }).join();
- method.name = displayName + '(' + typeName + ')';
- }
- });
-
- var inputParser = abi.inputParser(desc);
- var outputParser = abi.outputParser(desc);
-
- var result = {};
-
- result.call = function (options) {
- result._isTransact = false;
- result._options = options;
- return result;
- };
-
- result.transact = function (options) {
- result._isTransact = true;
- result._options = options;
- return result;
- };
-
- result._options = {};
- ['gas', 'gasPrice', 'value', 'from'].forEach(function(p) {
- result[p] = function (v) {
- result._options[p] = v;
- return result;
- };
- });
-
-
- desc.forEach(function (method) {
-
- var displayName = abi.methodDisplayName(method.name);
- var typeName = abi.methodTypeName(method.name);
-
- var impl = function () {
- var params = Array.prototype.slice.call(arguments);
- var signature = abi.methodSignature(method.name);
- var parsed = inputParser[displayName][typeName].apply(null, params);
-
- var options = result._options || {};
- options.to = address;
- options.data = signature + parsed;
-
- var isTransact = result._isTransact === true || (result._isTransact !== false && !method.constant);
- var collapse = options.collapse !== false;
-
- // reset
- result._options = {};
- result._isTransact = null;
-
- if (isTransact) {
- // it's used byt natspec.js
- // TODO: figure out better way to solve this
- web3._currentContractAbi = desc;
- web3._currentContractAddress = address;
- web3._currentContractMethodName = method.name;
- web3._currentContractMethodParams = params;
-
- // transactions do not have any output, cause we do not know, when they will be processed
- web3.eth.transact(options);
- return;
- }
-
- var output = web3.eth.call(options);
- var ret = outputParser[displayName][typeName](output);
- if (collapse)
- {
- if (ret.length === 1)
- ret = ret[0];
- else if (ret.length === 0)
- ret = null;
- }
- return ret;
- };
-
- if (result[displayName] === undefined) {
- result[displayName] = impl;
- }
-
- result[displayName][typeName] = impl;
-
- });
-
- return result;
-};
-
-module.exports = contract;
-
-
-},{"./abi":1,"./web3":7}],3:[function(require,module,exports){
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file filter.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3'); // jshint ignore:line
-
-/// should be used when we want to watch something
-/// it's using inner polling mechanism and is notified about changes
-var Filter = function(options, impl) {
- this.impl = impl;
- this.callbacks = [];
-
- this.id = impl.newFilter(options);
- web3.provider.startPolling({call: impl.changed, args: [this.id]}, this.id, this.trigger.bind(this));
-};
-
-/// alias for changed*
-Filter.prototype.arrived = function(callback) {
- this.changed(callback);
-};
-
-/// gets called when there is new eth/shh message
-Filter.prototype.changed = function(callback) {
- this.callbacks.push(callback);
-};
-
-/// trigger calling new message from people
-Filter.prototype.trigger = function(messages) {
- for (var i = 0; i < this.callbacks.length; i++) {
- for (var j = 0; j < messages.length; j++) {
- this.callbacks[i].call(this, messages[j]);
- }
- }
-};
-
-/// should be called to uninstall current filter
-Filter.prototype.uninstall = function() {
- this.impl.uninstallFilter(this.id);
- web3.provider.stopPolling(this.id);
-};
-
-/// should be called to manually trigger getting latest messages from the client
-Filter.prototype.messages = function() {
- return this.impl.getMessages(this.id);
-};
-
-/// alias for messages
-Filter.prototype.logs = function () {
- return this.messages();
-};
-
-module.exports = Filter;
-
-},{"./web3":7}],4:[function(require,module,exports){
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file httpsync.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * @date 2014
- */
-
-if ("build" !== 'build') {/*
- var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
-*/}
-
-var HttpSyncProvider = function (host) {
- this.handlers = [];
- this.host = host || 'http://localhost:8080';
-};
-
-/// Transforms inner message to proper jsonrpc object
-/// @param inner message object
-/// @returns jsonrpc object
-function formatJsonRpcObject(object) {
- return {
- jsonrpc: '2.0',
- method: object.call,
- params: object.args,
- id: object._id
- };
-}
-
-/// Transforms jsonrpc object to inner message
-/// @param incoming jsonrpc message
-/// @returns inner message object
-function formatJsonRpcMessage(message) {
- var object = JSON.parse(message);
-
- return {
- _id: object.id,
- data: object.result,
- error: object.error
- };
-}
-
-HttpSyncProvider.prototype.send = function (payload) {
- var data = formatJsonRpcObject(payload);
-
- var request = new XMLHttpRequest();
- request.open('POST', this.host, false);
- request.send(JSON.stringify(data));
-
- // check request.status
- return request.responseText;
-};
-
-module.exports = HttpSyncProvider;
-
-
-},{}],5:[function(require,module,exports){
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file providermanager.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3'); // jshint ignore:line
-
-/**
- * Provider manager object prototype
- * It's responsible for passing messages to providers
- * If no provider is set it's responsible for queuing requests
- * It's also responsible for polling the ethereum node for incoming messages
- * Default poll timeout is 12 seconds
- * If we are running ethereum.js inside ethereum browser, there are backend based tools responsible for polling,
- * and provider manager polling mechanism is not used
- */
-var ProviderManager = function() {
- this.polls = [];
- this.provider = undefined;
- this.id = 1;
-
- var self = this;
- var poll = function () {
- if (self.provider) {
- self.polls.forEach(function (data) {
- data.data._id = self.id;
- self.id++;
- var result = self.provider.send(data.data);
-
- result = JSON.parse(result);
-
- // dont call the callback if result is not an array, or empty one
- if (result.error || !(result.result instanceof Array) || result.result.length === 0) {
- return;
- }
-
- data.callback(result.result);
- });
- }
- setTimeout(poll, 1000);
- };
- poll();
-};
-
-/// sends outgoing requests
-ProviderManager.prototype.send = function(data) {
-
- data.args = data.args || [];
- data._id = this.id++;
-
- if (this.provider === undefined) {
- console.error('provider is not set');
- return null;
- }
-
- //TODO: handle error here?
- var result = this.provider.send(data);
- result = JSON.parse(result);
-
- if (result.error) {
- console.log(result.error);
- return null;
- }
-
- return result.result;
-};
-
-/// setups provider, which will be used for sending messages
-ProviderManager.prototype.set = function(provider) {
- this.provider = provider;
-};
-
-/// this method is only used, when we do not have native qt bindings and have to do polling on our own
-/// should be callled, on start watching for eth/shh changes
-ProviderManager.prototype.startPolling = function (data, pollId, callback) {
- this.polls.push({data: data, id: pollId, callback: callback});
-};
-
-/// should be called to stop polling for certain watch changes
-ProviderManager.prototype.stopPolling = function (pollId) {
- for (var i = this.polls.length; i--;) {
- var poll = this.polls[i];
- if (poll.id === pollId) {
- this.polls.splice(i, 1);
- }
- }
-};
-
-module.exports = ProviderManager;
-
-
-},{"./web3":7}],6:[function(require,module,exports){
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file qtsync.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * @date 2014
- */
-
-var QtSyncProvider = function () {
-};
-
-QtSyncProvider.prototype.send = function (payload) {
- return navigator.qt.callMethod(JSON.stringify(payload));
-};
-
-module.exports = QtSyncProvider;
-
-
-},{}],7:[function(require,module,exports){
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file web3.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-if ("build" !== 'build') {/*
- var BigNumber = require('bignumber.js');
-*/}
-
-var ETH_UNITS = [
- 'wei',
- 'Kwei',
- 'Mwei',
- 'Gwei',
- 'szabo',
- 'finney',
- 'ether',
- 'grand',
- 'Mether',
- 'Gether',
- 'Tether',
- 'Pether',
- 'Eether',
- 'Zether',
- 'Yether',
- 'Nether',
- 'Dether',
- 'Vether',
- 'Uether'
-];
-
-/// @returns an array of objects describing web3 api methods
-var web3Methods = function () {
- return [
- { name: 'sha3', call: 'web3_sha3' }
- ];
-};
-
-/// @returns an array of objects describing web3.eth api methods
-var ethMethods = function () {
- var blockCall = function (args) {
- return typeof args[0] === "string" ? "eth_blockByHash" : "eth_blockByNumber";
- };
-
- var transactionCall = function (args) {
- return typeof args[0] === "string" ? 'eth_transactionByHash' : 'eth_transactionByNumber';
- };
-
- var uncleCall = function (args) {
- return typeof args[0] === "string" ? 'eth_uncleByHash' : 'eth_uncleByNumber';
- };
-
- var methods = [
- { name: 'balanceAt', call: 'eth_balanceAt' },
- { name: 'stateAt', call: 'eth_stateAt' },
- { name: 'storageAt', call: 'eth_storageAt' },
- { name: 'countAt', call: 'eth_countAt'},
- { name: 'codeAt', call: 'eth_codeAt' },
- { name: 'transact', call: 'eth_transact' },
- { name: 'call', call: 'eth_call' },
- { name: 'block', call: blockCall },
- { name: 'transaction', call: transactionCall },
- { name: 'uncle', call: uncleCall },
- { name: 'compilers', call: 'eth_compilers' },
- { name: 'flush', call: 'eth_flush' },
- { name: 'lll', call: 'eth_lll' },
- { name: 'solidity', call: 'eth_solidity' },
- { name: 'serpent', call: 'eth_serpent' },
- { name: 'logs', call: 'eth_logs' }
- ];
- return methods;
-};
-
-/// @returns an array of objects describing web3.eth api properties
-var ethProperties = function () {
- return [
- { name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' },
- { name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' },
- { name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' },
- { name: 'gasPrice', getter: 'eth_gasPrice' },
- { name: 'accounts', getter: 'eth_accounts' },
- { name: 'peerCount', getter: 'eth_peerCount' },
- { name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' },
- { name: 'number', getter: 'eth_number'}
- ];
-};
-
-/// @returns an array of objects describing web3.db api methods
-var dbMethods = function () {
- return [
- { name: 'put', call: 'db_put' },
- { name: 'get', call: 'db_get' },
- { name: 'putString', call: 'db_putString' },
- { name: 'getString', call: 'db_getString' }
- ];
-};
-
-/// @returns an array of objects describing web3.shh api methods
-var shhMethods = function () {
- return [
- { name: 'post', call: 'shh_post' },
- { name: 'newIdentity', call: 'shh_newIdentity' },
- { name: 'haveIdentity', call: 'shh_haveIdentity' },
- { name: 'newGroup', call: 'shh_newGroup' },
- { name: 'addToGroup', call: 'shh_addToGroup' }
- ];
-};
-
-/// @returns an array of objects describing web3.eth.watch api methods
-var ethWatchMethods = function () {
- var newFilter = function (args) {
- return typeof args[0] === 'string' ? 'eth_newFilterString' : 'eth_newFilter';
- };
-
- return [
- { name: 'newFilter', call: newFilter },
- { name: 'uninstallFilter', call: 'eth_uninstallFilter' },
- { name: 'getMessages', call: 'eth_filterLogs' }
- ];
-};
-
-/// @returns an array of objects describing web3.shh.watch api methods
-var shhWatchMethods = function () {
- return [
- { name: 'newFilter', call: 'shh_newFilter' },
- { name: 'uninstallFilter', call: 'shh_uninstallFilter' },
- { name: 'getMessages', call: 'shh_getMessages' }
- ];
-};
-
-/// creates methods in a given object based on method description on input
-/// setups api calls for these methods
-var setupMethods = function (obj, methods) {
- methods.forEach(function (method) {
- obj[method.name] = function () {
- var args = Array.prototype.slice.call(arguments);
- var call = typeof method.call === 'function' ? method.call(args) : method.call;
- return web3.provider.send({
- call: call,
- args: args
- });
- };
- });
-};
-
-/// creates properties in a given object based on properties description on input
-/// setups api calls for these properties
-var setupProperties = function (obj, properties) {
- properties.forEach(function (property) {
- var proto = {};
- proto.get = function () {
- return web3.provider.send({
- call: property.getter
- });
- };
-
- if (property.setter) {
- proto.set = function (val) {
- return web3.provider.send({
- call: property.setter,
- args: [val]
- });
- };
- }
- Object.defineProperty(obj, property.name, proto);
- });
-};
-
-/// setups web3 object, and it's in-browser executed methods
-var web3 = {
- _callbacks: {},
- _events: {},
- providers: {},
-
- toHex: function(str) {
- var hex = "";
- for(var i = 0; i < str.length; i++) {
- var n = str.charCodeAt(i).toString(16);
- hex += n.length < 2 ? '0' + n : n;
- }
-
- return hex;
- },
-
- /// @returns ascii string representation of hex value prefixed with 0x
- toAscii: function(hex) {
- // Find termination
- var str = "";
- var i = 0, l = hex.length;
- if (hex.substring(0, 2) === '0x')
- i = 2;
- for(; i < l; i+=2) {
- var code = parseInt(hex.substr(i, 2), 16);
- if(code === 0) {
- break;
- }
-
- str += String.fromCharCode(code);
- }
-
- return str;
- },
-
- /// @returns hex representation (prefixed by 0x) of ascii string
- fromAscii: function(str, pad) {
- pad = pad === undefined ? 0 : pad;
- var hex = this.toHex(str);
- while(hex.length < pad*2)
- hex += "00";
- return "0x" + hex;
- },
-
- /// @returns decimal representaton of hex value prefixed by 0x
- toDecimal: function (val) {
- // remove 0x and place 0, if it's required
- val = val.length > 2 ? val.substring(2) : "0";
- return (new BigNumber(val, 16).toString(10));
- },
-
- /// @returns hex representation (prefixed by 0x) of decimal value
- fromDecimal: function (val) {
- return "0x" + (new BigNumber(val).toString(16));
- },
-
- /// used to transform value/string to eth string
- /// TODO: use BigNumber.js to parse int
- toEth: function(str) {
- var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
- var unit = 0;
- var units = ETH_UNITS;
- while (val > 3000 && unit < units.length - 1)
- {
- val /= 1000;
- unit++;
- }
- var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2);
- var replaceFunction = function($0, $1, $2) {
- return $1 + ',' + $2;
- };
-
- while (true) {
- var o = s;
- s = s.replace(/(\d)(\d\d\d[\.\,])/, replaceFunction);
- if (o === s)
- break;
- }
- return s + ' ' + units[unit];
- },
-
- /// eth object prototype
- eth: {
- contractFromAbi: function (abi) {
- return function(addr) {
- // Default to address of Config. TODO: rremove prior to genesis.
- addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
- var ret = web3.eth.contract(addr, abi);
- ret.address = addr;
- return ret;
- };
- },
- watch: function (params) {
- return new web3.filter(params, ethWatch);
- }
- },
-
- /// db object prototype
- db: {},
-
- /// shh object prototype
- shh: {
- watch: function (params) {
- return new web3.filter(params, shhWatch);
- }
- },
-
- /// @returns true if provider is installed
- haveProvider: function() {
- return !!web3.provider.provider;
- }
-};
-
-/// setups all api methods
-setupMethods(web3, web3Methods());
-setupMethods(web3.eth, ethMethods());
-setupProperties(web3.eth, ethProperties());
-setupMethods(web3.db, dbMethods());
-setupMethods(web3.shh, shhMethods());
-
-var ethWatch = {
- changed: 'eth_changed'
-};
-
-setupMethods(ethWatch, ethWatchMethods());
-
-var shhWatch = {
- changed: 'shh_changed'
-};
-
-setupMethods(shhWatch, shhWatchMethods());
-
-web3.setProvider = function(provider) {
- //provider.onmessage = messageHandler; // there will be no async calls, to remove
- web3.provider.set(provider);
-};
-
-module.exports = web3;
-
-
-},{}],"web3":[function(require,module,exports){
-var web3 = require('./lib/web3');
-var ProviderManager = require('./lib/providermanager');
-web3.provider = new ProviderManager();
-web3.filter = require('./lib/filter');
-web3.providers.HttpSyncProvider = require('./lib/httpsync');
-web3.providers.QtSyncProvider = require('./lib/qtsync');
-web3.eth.contract = require('./lib/contract');
-web3.abi = require('./lib/abi');
-
-
-module.exports = web3;
-
-},{"./lib/abi":1,"./lib/contract":2,"./lib/filter":3,"./lib/httpsync":4,"./lib/providermanager":5,"./lib/qtsync":6,"./lib/web3":7}]},{},["web3"])
-
-
-//# sourceMappingURL=ethereum.js.map
diff --git a/cmd/mist/assets/ext/dist/ethereum.js.map b/cmd/mist/assets/ext/dist/ethereum.js.map
deleted file mode 100644
index 5017119bc..000000000
--- a/cmd/mist/assets/ext/dist/ethereum.js.map
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "version": 3,
- "sources": [
- "node_modules/browserify/node_modules/browser-pack/_prelude.js",
- "lib/abi.js",
- "lib/contract.js",
- "lib/filter.js",
- "lib/httpsync.js",
- "lib/providermanager.js",
- "lib/qtsync.js",
- "lib/web3.js",
- "index.js"
- ],
- "names": [],
- "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1ZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA",
- "file": "generated.js",
- "sourceRoot": "",
- "sourcesContent": [
- "(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file abi.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * Gav Wood <g@ethdev.com>\n * @date 2014\n */\n\n// TODO: is these line is supposed to be here? \nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js'); // jshint ignore:line\n*/}\n\nvar web3 = require('./web3'); // jshint ignore:line\n\nBigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_DOWN });\n\nvar ETH_PADDING = 32;\n\n/// method signature length in bytes\nvar ETH_METHOD_SIGNATURE_LENGTH = 4;\n\n/// Finds first index of array element matching pattern\n/// @param array\n/// @param callback pattern\n/// @returns index of element\nvar findIndex = function (array, callback) {\n var end = false;\n var i = 0;\n for (; i < array.length && !end; i++) {\n end = callback(array[i]);\n }\n return end ? i - 1 : -1;\n};\n\n/// @returns a function that is used as a pattern for 'findIndex'\nvar findMethodIndex = function (json, methodName) {\n return findIndex(json, function (method) {\n return method.name === methodName;\n });\n};\n\n/// @returns method with given method name\nvar getMethodWithName = function (json, methodName) {\n var index = findMethodIndex(json, methodName);\n if (index === -1) {\n console.error('method ' + methodName + ' not found in the abi');\n return undefined;\n }\n return json[index];\n};\n\n/// @param string string to be padded\n/// @param number of characters that result string should have\n/// @param sign, by default 0\n/// @returns right aligned string\nvar padLeft = function (string, chars, sign) {\n return new Array(chars - string.length + 1).join(sign ? sign : \"0\") + string;\n};\n\n/// @param expected type prefix (string)\n/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false\nvar prefixedType = function (prefix) {\n return function (type) {\n return type.indexOf(prefix) === 0;\n };\n};\n\n/// @param expected type name (string)\n/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false\nvar namedType = function (name) {\n return function (type) {\n return name === type;\n };\n};\n\nvar arrayType = function (type) {\n return type.slice(-2) === '[]';\n};\n\n/// Formats input value to byte representation of int\n/// If value is negative, return it's two's complement\n/// If the value is floating point, round it down\n/// @returns right-aligned byte representation of int\nvar formatInputInt = function (value) {\n var padding = ETH_PADDING * 2;\n if (value instanceof BigNumber || typeof value === 'number') {\n if (typeof value === 'number')\n value = new BigNumber(value);\n value = value.round();\n\n if (value.lessThan(0)) \n value = new BigNumber(\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\", 16).plus(value).plus(1);\n value = value.toString(16);\n }\n else if (value.indexOf('0x') === 0)\n value = value.substr(2);\n else if (typeof value === 'string')\n value = formatInputInt(new BigNumber(value));\n else\n value = (+value).toString(16);\n return padLeft(value, padding);\n};\n\n/// Formats input value to byte representation of string\n/// @returns left-algined byte representation of string\nvar formatInputString = function (value) {\n return web3.fromAscii(value, ETH_PADDING).substr(2);\n};\n\n/// Formats input value to byte representation of bool\n/// @returns right-aligned byte representation bool\nvar formatInputBool = function (value) {\n return '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');\n};\n\n/// Formats input value to byte representation of real\n/// Values are multiplied by 2^m and encoded as integers\n/// @returns byte representation of real\nvar formatInputReal = function (value) {\n return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128))); \n};\n\nvar dynamicTypeBytes = function (type, value) {\n // TODO: decide what to do with array of strings\n if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.\n return formatInputInt(value.length); \n return \"\";\n};\n\n/// Setups input formatters for solidity types\n/// @returns an array of input formatters \nvar setupInputTypes = function () {\n \n return [\n { type: prefixedType('uint'), format: formatInputInt },\n { type: prefixedType('int'), format: formatInputInt },\n { type: prefixedType('hash'), format: formatInputInt },\n { type: prefixedType('string'), format: formatInputString }, \n { type: prefixedType('real'), format: formatInputReal },\n { type: prefixedType('ureal'), format: formatInputReal },\n { type: namedType('address'), format: formatInputInt },\n { type: namedType('bool'), format: formatInputBool }\n ];\n};\n\nvar inputTypes = setupInputTypes();\n\n/// Formats input params to bytes\n/// @param contract json abi\n/// @param name of the method that we want to use\n/// @param array of params that will be formatted to bytes\n/// @returns bytes representation of input params\nvar toAbiInput = function (json, methodName, params) {\n var bytes = \"\";\n\n var method = getMethodWithName(json, methodName);\n var padding = ETH_PADDING * 2;\n\n /// first we iterate in search for dynamic \n method.inputs.forEach(function (input, index) {\n bytes += dynamicTypeBytes(input.type, params[index]);\n });\n\n method.inputs.forEach(function (input, i) {\n var typeMatch = false;\n for (var j = 0; j < inputTypes.length && !typeMatch; j++) {\n typeMatch = inputTypes[j].type(method.inputs[i].type, params[i]);\n }\n if (!typeMatch) {\n console.error('input parser does not support type: ' + method.inputs[i].type);\n }\n\n var formatter = inputTypes[j - 1].format;\n var toAppend = \"\";\n\n if (arrayType(method.inputs[i].type))\n toAppend = params[i].reduce(function (acc, curr) {\n return acc + formatter(curr);\n }, \"\");\n else\n toAppend = formatter(params[i]);\n\n bytes += toAppend; \n });\n return bytes;\n};\n\n/// Check if input value is negative\n/// @param value is hex format\n/// @returns true if it is negative, otherwise false\nvar signedIsNegative = function (value) {\n return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';\n};\n\n/// Formats input right-aligned input bytes to int\n/// @returns right-aligned input bytes formatted to int\nvar formatOutputInt = function (value) {\n value = value || \"0\";\n // check if it's negative number\n // it it is, return two's complement\n if (signedIsNegative(value)) {\n return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);\n }\n return new BigNumber(value, 16);\n};\n\n/// Formats big right-aligned input bytes to uint\n/// @returns right-aligned input bytes formatted to uint\nvar formatOutputUInt = function (value) {\n value = value || \"0\";\n return new BigNumber(value, 16);\n};\n\n/// @returns input bytes formatted to real\nvar formatOutputReal = function (value) {\n return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/// @returns input bytes formatted to ureal\nvar formatOutputUReal = function (value) {\n return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/// @returns right-aligned input bytes formatted to hex\nvar formatOutputHash = function (value) {\n return \"0x\" + value;\n};\n\n/// @returns right-aligned input bytes formatted to bool\nvar formatOutputBool = function (value) {\n return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;\n};\n\n/// @returns left-aligned input bytes formatted to ascii string\nvar formatOutputString = function (value) {\n return web3.toAscii(value);\n};\n\n/// @returns right-aligned input bytes formatted to address\nvar formatOutputAddress = function (value) {\n return \"0x\" + value.slice(value.length - 40, value.length);\n};\n\nvar dynamicBytesLength = function (type) {\n if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.\n return ETH_PADDING * 2;\n return 0;\n};\n\n/// Setups output formaters for solidity types\n/// @returns an array of output formatters\nvar setupOutputTypes = function () {\n\n return [\n { type: prefixedType('uint'), format: formatOutputUInt },\n { type: prefixedType('int'), format: formatOutputInt },\n { type: prefixedType('hash'), format: formatOutputHash },\n { type: prefixedType('string'), format: formatOutputString },\n { type: prefixedType('real'), format: formatOutputReal },\n { type: prefixedType('ureal'), format: formatOutputUReal },\n { type: namedType('address'), format: formatOutputAddress },\n { type: namedType('bool'), format: formatOutputBool }\n ];\n};\n\nvar outputTypes = setupOutputTypes();\n\n/// Formats output bytes back to param list\n/// @param contract json abi\n/// @param name of the method that we want to use\n/// @param bytes representtion of output \n/// @returns array of output params \nvar fromAbiOutput = function (json, methodName, output) {\n \n output = output.slice(2);\n var result = [];\n var method = getMethodWithName(json, methodName);\n var padding = ETH_PADDING * 2;\n\n var dynamicPartLength = method.outputs.reduce(function (acc, curr) {\n return acc + dynamicBytesLength(curr.type);\n }, 0);\n \n var dynamicPart = output.slice(0, dynamicPartLength);\n output = output.slice(dynamicPartLength);\n\n method.outputs.forEach(function (out, i) {\n var typeMatch = false;\n for (var j = 0; j < outputTypes.length && !typeMatch; j++) {\n typeMatch = outputTypes[j].type(method.outputs[i].type);\n }\n\n if (!typeMatch) {\n console.error('output parser does not support type: ' + method.outputs[i].type);\n }\n\n var formatter = outputTypes[j - 1].format;\n if (arrayType(method.outputs[i].type)) {\n var size = formatOutputUInt(dynamicPart.slice(0, padding));\n dynamicPart = dynamicPart.slice(padding);\n var array = [];\n for (var k = 0; k < size; k++) {\n array.push(formatter(output.slice(0, padding))); \n output = output.slice(padding);\n }\n result.push(array);\n }\n else if (prefixedType('string')(method.outputs[i].type)) {\n dynamicPart = dynamicPart.slice(padding); \n result.push(formatter(output.slice(0, padding)));\n output = output.slice(padding);\n } else {\n result.push(formatter(output.slice(0, padding)));\n output = output.slice(padding);\n }\n });\n\n return result;\n};\n\n/// @returns display name for method eg. multiply(uint256) -> multiply\nvar methodDisplayName = function (method) {\n var length = method.indexOf('('); \n return length !== -1 ? method.substr(0, length) : method;\n};\n\n/// @returns overloaded part of method's name\nvar methodTypeName = function (method) {\n /// TODO: make it not vulnerable\n var length = method.indexOf('(');\n return length !== -1 ? method.substr(length + 1, method.length - 1 - (length + 1)) : \"\";\n};\n\n/// @param json abi for contract\n/// @returns input parser object for given json abi\nvar inputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n var displayName = methodDisplayName(method.name); \n var typeName = methodTypeName(method.name);\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n return toAbiInput(json, method.name, params);\n };\n \n if (parser[displayName] === undefined) {\n parser[displayName] = impl;\n }\n\n parser[displayName][typeName] = impl;\n });\n\n return parser;\n};\n\n/// @param json abi for contract\n/// @returns output parser for given json abi\nvar outputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n\n var displayName = methodDisplayName(method.name); \n var typeName = methodTypeName(method.name);\n\n var impl = function (output) {\n return fromAbiOutput(json, method.name, output);\n };\n\n if (parser[displayName] === undefined) {\n parser[displayName] = impl;\n }\n\n parser[displayName][typeName] = impl;\n });\n\n return parser;\n};\n\n/// @param method name for which we want to get method signature\n/// @returns (promise) contract method signature for method with given name\nvar methodSignature = function (name) {\n return web3.sha3(web3.fromAscii(name)).slice(0, 2 + ETH_METHOD_SIGNATURE_LENGTH * 2);\n};\n\nmodule.exports = {\n inputParser: inputParser,\n outputParser: outputParser,\n methodSignature: methodSignature,\n methodDisplayName: methodDisplayName,\n methodTypeName: methodTypeName,\n getMethodWithName: getMethodWithName\n};\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file contract.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * @date 2014\n */\n\nvar web3 = require('./web3'); // jshint ignore:line\nvar abi = require('./abi');\n\n/**\n * This method should be called when we want to call / transact some solidity method from javascript\n * it returns an object which has same methods available as solidity contract description\n * usage example: \n *\n * var abi = [{\n * name: 'myMethod',\n * inputs: [{ name: 'a', type: 'string' }],\n * outputs: [{name: 'd', type: 'string' }]\n * }]; // contract abi\n *\n * var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object\n *\n * myContract.myMethod('this is test string param for call'); // myMethod call (implicit, default)\n * myContract.call().myMethod('this is test string param for call'); // myMethod call (explicit)\n * myContract.transact().myMethod('this is test string param for transact'); // myMethod transact\n *\n * @param address - address of the contract, which should be called\n * @param desc - abi json description of the contract, which is being created\n * @returns contract object\n */\n\nvar contract = function (address, desc) {\n\n desc.forEach(function (method) {\n // workaround for invalid assumption that method.name is the full anonymous prototype of the method.\n // it's not. it's just the name. the rest of the code assumes it's actually the anonymous\n // prototype, so we make it so as a workaround.\n if (method.name.indexOf('(') === -1) {\n var displayName = method.name;\n var typeName = method.inputs.map(function(i){return i.type; }).join();\n method.name = displayName + '(' + typeName + ')';\n }\n });\n\n var inputParser = abi.inputParser(desc);\n var outputParser = abi.outputParser(desc);\n\n var result = {};\n\n result.call = function (options) {\n result._isTransact = false;\n result._options = options;\n return result;\n };\n\n result.transact = function (options) {\n result._isTransact = true;\n result._options = options;\n return result;\n };\n\n result._options = {};\n ['gas', 'gasPrice', 'value', 'from'].forEach(function(p) {\n result[p] = function (v) {\n result._options[p] = v;\n return result;\n };\n });\n\n\n desc.forEach(function (method) {\n\n var displayName = abi.methodDisplayName(method.name);\n var typeName = abi.methodTypeName(method.name);\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n var signature = abi.methodSignature(method.name);\n var parsed = inputParser[displayName][typeName].apply(null, params);\n\n var options = result._options || {};\n options.to = address;\n options.data = signature + parsed;\n \n var isTransact = result._isTransact === true || (result._isTransact !== false && !method.constant);\n var collapse = options.collapse !== false;\n \n // reset\n result._options = {};\n result._isTransact = null;\n\n if (isTransact) {\n // it's used byt natspec.js\n // TODO: figure out better way to solve this\n web3._currentContractAbi = desc;\n web3._currentContractAddress = address;\n web3._currentContractMethodName = method.name;\n web3._currentContractMethodParams = params;\n\n // transactions do not have any output, cause we do not know, when they will be processed\n web3.eth.transact(options);\n return;\n }\n \n var output = web3.eth.call(options);\n var ret = outputParser[displayName][typeName](output);\n if (collapse)\n {\n if (ret.length === 1)\n ret = ret[0];\n else if (ret.length === 0)\n ret = null;\n }\n return ret;\n };\n\n if (result[displayName] === undefined) {\n result[displayName] = impl;\n }\n\n result[displayName][typeName] = impl;\n\n });\n\n return result;\n};\n\nmodule.exports = contract;\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file filter.js\n * @authors:\n * Jeffrey Wilcke <jeff@ethdev.com>\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * Gav Wood <g@ethdev.com>\n * @date 2014\n */\n\nvar web3 = require('./web3'); // jshint ignore:line\n\n/// should be used when we want to watch something\n/// it's using inner polling mechanism and is notified about changes\nvar Filter = function(options, impl) {\n this.impl = impl;\n this.callbacks = [];\n\n this.id = impl.newFilter(options);\n web3.provider.startPolling({call: impl.changed, args: [this.id]}, this.id, this.trigger.bind(this));\n};\n\n/// alias for changed*\nFilter.prototype.arrived = function(callback) {\n this.changed(callback);\n};\n\n/// gets called when there is new eth/shh message\nFilter.prototype.changed = function(callback) {\n this.callbacks.push(callback);\n};\n\n/// trigger calling new message from people\nFilter.prototype.trigger = function(messages) {\n for (var i = 0; i < this.callbacks.length; i++) {\n for (var j = 0; j < messages.length; j++) {\n this.callbacks[i].call(this, messages[j]);\n }\n }\n};\n\n/// should be called to uninstall current filter\nFilter.prototype.uninstall = function() {\n this.impl.uninstallFilter(this.id);\n web3.provider.stopPolling(this.id);\n};\n\n/// should be called to manually trigger getting latest messages from the client\nFilter.prototype.messages = function() {\n return this.impl.getMessages(this.id);\n};\n\n/// alias for messages\nFilter.prototype.logs = function () {\n return this.messages();\n};\n\nmodule.exports = Filter;\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file httpsync.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * @date 2014\n */\n\nif (\"build\" !== 'build') {/*\n var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line\n*/}\n\nvar HttpSyncProvider = function (host) {\n this.handlers = [];\n this.host = host || 'http://localhost:8080';\n};\n\n/// Transforms inner message to proper jsonrpc object\n/// @param inner message object\n/// @returns jsonrpc object\nfunction formatJsonRpcObject(object) {\n return {\n jsonrpc: '2.0',\n method: object.call,\n params: object.args,\n id: object._id\n };\n}\n\n/// Transforms jsonrpc object to inner message\n/// @param incoming jsonrpc message \n/// @returns inner message object\nfunction formatJsonRpcMessage(message) {\n var object = JSON.parse(message);\n\n return {\n _id: object.id,\n data: object.result,\n error: object.error\n };\n}\n\nHttpSyncProvider.prototype.send = function (payload) {\n var data = formatJsonRpcObject(payload);\n \n var request = new XMLHttpRequest();\n request.open('POST', this.host, false);\n request.send(JSON.stringify(data));\n \n // check request.status\n return request.responseText;\n};\n\nmodule.exports = HttpSyncProvider;\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file providermanager.js\n * @authors:\n * Jeffrey Wilcke <jeff@ethdev.com>\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * Gav Wood <g@ethdev.com>\n * @date 2014\n */\n\nvar web3 = require('./web3'); // jshint ignore:line\n\n/**\n * Provider manager object prototype\n * It's responsible for passing messages to providers\n * If no provider is set it's responsible for queuing requests\n * It's also responsible for polling the ethereum node for incoming messages\n * Default poll timeout is 12 seconds\n * If we are running ethereum.js inside ethereum browser, there are backend based tools responsible for polling,\n * and provider manager polling mechanism is not used\n */\nvar ProviderManager = function() {\n this.polls = [];\n this.provider = undefined;\n this.id = 1;\n\n var self = this;\n var poll = function () {\n if (self.provider) {\n self.polls.forEach(function (data) {\n data.data._id = self.id;\n self.id++;\n var result = self.provider.send(data.data);\n \n result = JSON.parse(result);\n \n // dont call the callback if result is not an array, or empty one\n if (result.error || !(result.result instanceof Array) || result.result.length === 0) {\n return;\n }\n\n data.callback(result.result);\n });\n }\n setTimeout(poll, 1000);\n };\n poll();\n};\n\n/// sends outgoing requests\nProviderManager.prototype.send = function(data) {\n\n data.args = data.args || [];\n data._id = this.id++;\n\n if (this.provider === undefined) {\n console.error('provider is not set');\n return null; \n }\n\n //TODO: handle error here? \n var result = this.provider.send(data);\n result = JSON.parse(result);\n\n if (result.error) {\n console.log(result.error);\n return null;\n }\n\n return result.result;\n};\n\n/// setups provider, which will be used for sending messages\nProviderManager.prototype.set = function(provider) {\n this.provider = provider;\n};\n\n/// this method is only used, when we do not have native qt bindings and have to do polling on our own\n/// should be callled, on start watching for eth/shh changes\nProviderManager.prototype.startPolling = function (data, pollId, callback) {\n this.polls.push({data: data, id: pollId, callback: callback});\n};\n\n/// should be called to stop polling for certain watch changes\nProviderManager.prototype.stopPolling = function (pollId) {\n for (var i = this.polls.length; i--;) {\n var poll = this.polls[i];\n if (poll.id === pollId) {\n this.polls.splice(i, 1);\n }\n }\n};\n\nmodule.exports = ProviderManager;\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file qtsync.js\n * @authors:\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * @date 2014\n */\n\nvar QtSyncProvider = function () {\n};\n\nQtSyncProvider.prototype.send = function (payload) {\n return navigator.qt.callMethod(JSON.stringify(payload));\n};\n\nmodule.exports = QtSyncProvider;\n\n",
- "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/** @file web3.js\n * @authors:\n * Jeffrey Wilcke <jeff@ethdev.com>\n * Marek Kotewicz <marek@ethdev.com>\n * Marian Oancea <marian@ethdev.com>\n * Gav Wood <g@ethdev.com>\n * @date 2014\n */\n\nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js');\n*/}\n\nvar ETH_UNITS = [ \n 'wei', \n 'Kwei', \n 'Mwei', \n 'Gwei', \n 'szabo', \n 'finney', \n 'ether', \n 'grand', \n 'Mether', \n 'Gether', \n 'Tether', \n 'Pether', \n 'Eether', \n 'Zether', \n 'Yether', \n 'Nether', \n 'Dether', \n 'Vether', \n 'Uether' \n];\n\n/// @returns an array of objects describing web3 api methods\nvar web3Methods = function () {\n return [\n { name: 'sha3', call: 'web3_sha3' }\n ];\n};\n\n/// @returns an array of objects describing web3.eth api methods\nvar ethMethods = function () {\n var blockCall = function (args) {\n return typeof args[0] === \"string\" ? \"eth_blockByHash\" : \"eth_blockByNumber\";\n };\n\n var transactionCall = function (args) {\n return typeof args[0] === \"string\" ? 'eth_transactionByHash' : 'eth_transactionByNumber';\n };\n\n var uncleCall = function (args) {\n return typeof args[0] === \"string\" ? 'eth_uncleByHash' : 'eth_uncleByNumber';\n };\n\n var methods = [\n { name: 'balanceAt', call: 'eth_balanceAt' },\n { name: 'stateAt', call: 'eth_stateAt' },\n { name: 'storageAt', call: 'eth_storageAt' },\n { name: 'countAt', call: 'eth_countAt'},\n { name: 'codeAt', call: 'eth_codeAt' },\n { name: 'transact', call: 'eth_transact' },\n { name: 'call', call: 'eth_call' },\n { name: 'block', call: blockCall },\n { name: 'transaction', call: transactionCall },\n { name: 'uncle', call: uncleCall },\n { name: 'compilers', call: 'eth_compilers' },\n { name: 'flush', call: 'eth_flush' },\n { name: 'lll', call: 'eth_lll' },\n { name: 'solidity', call: 'eth_solidity' },\n { name: 'serpent', call: 'eth_serpent' },\n { name: 'logs', call: 'eth_logs' }\n ];\n return methods;\n};\n\n/// @returns an array of objects describing web3.eth api properties\nvar ethProperties = function () {\n return [\n { name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' },\n { name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' },\n { name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' },\n { name: 'gasPrice', getter: 'eth_gasPrice' },\n { name: 'accounts', getter: 'eth_accounts' },\n { name: 'peerCount', getter: 'eth_peerCount' },\n { name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' },\n { name: 'number', getter: 'eth_number'}\n ];\n};\n\n/// @returns an array of objects describing web3.db api methods\nvar dbMethods = function () {\n return [\n { name: 'put', call: 'db_put' },\n { name: 'get', call: 'db_get' },\n { name: 'putString', call: 'db_putString' },\n { name: 'getString', call: 'db_getString' }\n ];\n};\n\n/// @returns an array of objects describing web3.shh api methods\nvar shhMethods = function () {\n return [\n { name: 'post', call: 'shh_post' },\n { name: 'newIdentity', call: 'shh_newIdentity' },\n { name: 'haveIdentity', call: 'shh_haveIdentity' },\n { name: 'newGroup', call: 'shh_newGroup' },\n { name: 'addToGroup', call: 'shh_addToGroup' }\n ];\n};\n\n/// @returns an array of objects describing web3.eth.watch api methods\nvar ethWatchMethods = function () {\n var newFilter = function (args) {\n return typeof args[0] === 'string' ? 'eth_newFilterString' : 'eth_newFilter';\n };\n\n return [\n { name: 'newFilter', call: newFilter },\n { name: 'uninstallFilter', call: 'eth_uninstallFilter' },\n { name: 'getMessages', call: 'eth_filterLogs' }\n ];\n};\n\n/// @returns an array of objects describing web3.shh.watch api methods\nvar shhWatchMethods = function () {\n return [\n { name: 'newFilter', call: 'shh_newFilter' },\n { name: 'uninstallFilter', call: 'shh_uninstallFilter' },\n { name: 'getMessages', call: 'shh_getMessages' }\n ];\n};\n\n/// creates methods in a given object based on method description on input\n/// setups api calls for these methods\nvar setupMethods = function (obj, methods) {\n methods.forEach(function (method) {\n obj[method.name] = function () {\n var args = Array.prototype.slice.call(arguments);\n var call = typeof method.call === 'function' ? method.call(args) : method.call;\n return web3.provider.send({\n call: call,\n args: args\n });\n };\n });\n};\n\n/// creates properties in a given object based on properties description on input\n/// setups api calls for these properties\nvar setupProperties = function (obj, properties) {\n properties.forEach(function (property) {\n var proto = {};\n proto.get = function () {\n return web3.provider.send({\n call: property.getter\n });\n };\n\n if (property.setter) {\n proto.set = function (val) {\n return web3.provider.send({\n call: property.setter,\n args: [val]\n });\n };\n }\n Object.defineProperty(obj, property.name, proto);\n });\n};\n\n/// setups web3 object, and it's in-browser executed methods\nvar web3 = {\n _callbacks: {},\n _events: {},\n providers: {},\n\n toHex: function(str) {\n var hex = \"\";\n for(var i = 0; i < str.length; i++) {\n var n = str.charCodeAt(i).toString(16);\n hex += n.length < 2 ? '0' + n : n;\n }\n\n return hex;\n },\n\n /// @returns ascii string representation of hex value prefixed with 0x\n toAscii: function(hex) {\n // Find termination\n var str = \"\";\n var i = 0, l = hex.length;\n if (hex.substring(0, 2) === '0x')\n i = 2;\n for(; i < l; i+=2) {\n var code = parseInt(hex.substr(i, 2), 16);\n if(code === 0) {\n break;\n }\n\n str += String.fromCharCode(code);\n }\n\n return str;\n },\n\n /// @returns hex representation (prefixed by 0x) of ascii string\n fromAscii: function(str, pad) {\n pad = pad === undefined ? 0 : pad;\n var hex = this.toHex(str);\n while(hex.length < pad*2)\n hex += \"00\";\n return \"0x\" + hex;\n },\n\n /// @returns decimal representaton of hex value prefixed by 0x\n toDecimal: function (val) {\n // remove 0x and place 0, if it's required\n val = val.length > 2 ? val.substring(2) : \"0\";\n return (new BigNumber(val, 16).toString(10));\n },\n\n /// @returns hex representation (prefixed by 0x) of decimal value\n fromDecimal: function (val) {\n return \"0x\" + (new BigNumber(val).toString(16));\n },\n\n /// used to transform value/string to eth string\n /// TODO: use BigNumber.js to parse int\n toEth: function(str) {\n var val = typeof str === \"string\" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;\n var unit = 0;\n var units = ETH_UNITS;\n while (val > 3000 && unit < units.length - 1)\n {\n val /= 1000;\n unit++;\n }\n var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2);\n var replaceFunction = function($0, $1, $2) {\n return $1 + ',' + $2;\n };\n\n while (true) {\n var o = s;\n s = s.replace(/(\\d)(\\d\\d\\d[\\.\\,])/, replaceFunction);\n if (o === s)\n break;\n }\n return s + ' ' + units[unit];\n },\n\n /// eth object prototype\n eth: {\n contractFromAbi: function (abi) {\n return function(addr) {\n // Default to address of Config. TODO: rremove prior to genesis.\n addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';\n var ret = web3.eth.contract(addr, abi);\n ret.address = addr;\n return ret;\n };\n },\n watch: function (params) {\n return new web3.filter(params, ethWatch);\n }\n },\n\n /// db object prototype\n db: {},\n\n /// shh object prototype\n shh: {\n watch: function (params) {\n return new web3.filter(params, shhWatch);\n }\n },\n\n /// @returns true if provider is installed\n haveProvider: function() {\n return !!web3.provider.provider;\n }\n};\n\n/// setups all api methods\nsetupMethods(web3, web3Methods());\nsetupMethods(web3.eth, ethMethods());\nsetupProperties(web3.eth, ethProperties());\nsetupMethods(web3.db, dbMethods());\nsetupMethods(web3.shh, shhMethods());\n\nvar ethWatch = {\n changed: 'eth_changed'\n};\n\nsetupMethods(ethWatch, ethWatchMethods());\n\nvar shhWatch = {\n changed: 'shh_changed'\n};\n\nsetupMethods(shhWatch, shhWatchMethods());\n\nweb3.setProvider = function(provider) {\n //provider.onmessage = messageHandler; // there will be no async calls, to remove\n web3.provider.set(provider);\n};\n\nmodule.exports = web3;\n\n",
- "var web3 = require('./lib/web3');\nvar ProviderManager = require('./lib/providermanager');\nweb3.provider = new ProviderManager();\nweb3.filter = require('./lib/filter');\nweb3.providers.HttpSyncProvider = require('./lib/httpsync');\nweb3.providers.QtSyncProvider = require('./lib/qtsync');\nweb3.eth.contract = require('./lib/contract');\nweb3.abi = require('./lib/abi');\n\n\nmodule.exports = web3;\n"
- ]
-} \ No newline at end of file
diff --git a/cmd/mist/assets/ext/dist/ethereum.min.js b/cmd/mist/assets/ext/dist/ethereum.min.js
deleted file mode 100644
index b5b0fb547..000000000
--- a/cmd/mist/assets/ext/dist/ethereum.min.js
+++ /dev/null
@@ -1 +0,0 @@
-require=function t(e,n,r){function i(a,f){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!f&&u)return u(a,!0);if(o)return o(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e){var n=t("./web3");BigNumber.config({ROUNDING_MODE:BigNumber.ROUND_DOWN});var r=32,i=4,o=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},a=function(t,e){return o(t,function(t){return t.name===e})},f=function(t,e){var n=a(t,e);return-1===n?void console.error("method "+e+" not found in the abi"):t[n]},u=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},s=function(t){return function(e){return 0===e.indexOf(t)}},c=function(t){return function(e){return t===e}},l=function(t){return"[]"===t.slice(-2)},h=function(t){var e=2*r;return t instanceof BigNumber||"number"==typeof t?("number"==typeof t&&(t=new BigNumber(t)),t=t.round(),t.lessThan(0)&&(t=new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(t).plus(1)),t=t.toString(16)):t=0===t.indexOf("0x")?t.substr(2):"string"==typeof t?h(new BigNumber(t)):(+t).toString(16),u(t,e)},p=function(t){return n.fromAscii(t,r).substr(2)},d=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},m=function(t){return h(new BigNumber(t).times(new BigNumber(2).pow(128)))},g=function(t,e){return l(t)||"string"===t?h(e.length):""},v=function(){return[{type:s("uint"),format:h},{type:s("int"),format:h},{type:s("hash"),format:h},{type:s("string"),format:p},{type:s("real"),format:m},{type:s("ureal"),format:m},{type:c("address"),format:h},{type:c("bool"),format:d}]},b=v(),y=function(t,e,n){var r="",i=f(t,e);return i.inputs.forEach(function(t,e){r+=g(t.type,n[e])}),i.inputs.forEach(function(t,e){for(var o=!1,a=0;a<b.length&&!o;a++)o=b[a].type(i.inputs[e].type,n[e]);o||console.error("input parser does not support type: "+i.inputs[e].type);var f=b[a-1].format,u="";u=l(i.inputs[e].type)?n[e].reduce(function(t,e){return t+f(e)},""):f(n[e]),r+=u}),r},_=function(t){return"1"===new BigNumber(t.substr(0,1),16).toString(2).substr(0,1)},w=function(t){return t=t||"0",_(t)?new BigNumber(t,16).minus(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new BigNumber(t,16)},N=function(t){return t=t||"0",new BigNumber(t,16)},x=function(t){return w(t).dividedBy(new BigNumber(2).pow(128))},B=function(t){return N(t).dividedBy(new BigNumber(2).pow(128))},A=function(t){return"0x"+t},S=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},O=function(t){return n.toAscii(t)},P=function(t){return"0x"+t.slice(t.length-40,t.length)},E=function(t){return l(t)||"string"===t?2*r:0},k=function(){return[{type:s("uint"),format:N},{type:s("int"),format:w},{type:s("hash"),format:A},{type:s("string"),format:O},{type:s("real"),format:x},{type:s("ureal"),format:B},{type:c("address"),format:P},{type:c("bool"),format:S}]},F=k(),T=function(t,e,n){n=n.slice(2);var i=[],o=f(t,e),a=2*r,u=o.outputs.reduce(function(t,e){return t+E(e.type)},0),c=n.slice(0,u);return n=n.slice(u),o.outputs.forEach(function(t,e){for(var r=!1,f=0;f<F.length&&!r;f++)r=F[f].type(o.outputs[e].type);r||console.error("output parser does not support type: "+o.outputs[e].type);var u=F[f-1].format;if(l(o.outputs[e].type)){var h=N(c.slice(0,a));c=c.slice(a);for(var p=[],d=0;h>d;d++)p.push(u(n.slice(0,a))),n=n.slice(a);i.push(p)}else s("string")(o.outputs[e].type)?(c=c.slice(a),i.push(u(n.slice(0,a))),n=n.slice(a)):(i.push(u(n.slice(0,a))),n=n.slice(a))}),i},M=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},D=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)):""},C=function(t){var e={};return t.forEach(function(n){var r=M(n.name),i=D(n.name),o=function(){var e=Array.prototype.slice.call(arguments);return y(t,n.name,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e},q=function(t){var e={};return t.forEach(function(n){var r=M(n.name),i=D(n.name),o=function(e){return T(t,n.name,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e},I=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*i)};e.exports={inputParser:C,outputParser:q,methodSignature:I,methodDisplayName:M,methodTypeName:D,getMethodWithName:f}},{"./web3":7}],2:[function(t,e){var n=t("./web3"),r=t("./abi"),i=function(t,e){e.forEach(function(t){if(-1===t.name.indexOf("(")){var e=t.name,n=t.inputs.map(function(t){return t.type}).join();t.name=e+"("+n+")"}});var i=r.inputParser(e),o=r.outputParser(e),a={};return a.call=function(t){return a._isTransact=!1,a._options=t,a},a.transact=function(t){return a._isTransact=!0,a._options=t,a},a._options={},["gas","gasPrice","value","from"].forEach(function(t){a[t]=function(e){return a._options[t]=e,a}}),e.forEach(function(f){var u=r.methodDisplayName(f.name),s=r.methodTypeName(f.name),c=function(){var c=Array.prototype.slice.call(arguments),l=r.methodSignature(f.name),h=i[u][s].apply(null,c),p=a._options||{};p.to=t,p.data=l+h;var d=a._isTransact===!0||a._isTransact!==!1&&!f.constant,m=p.collapse!==!1;if(a._options={},a._isTransact=null,d)return n._currentContractAbi=e,n._currentContractAddress=t,n._currentContractMethodName=f.name,n._currentContractMethodParams=c,void n.eth.transact(p);var g=n.eth.call(p),v=o[u][s](g);return m&&(1===v.length?v=v[0]:0===v.length&&(v=null)),v};void 0===a[u]&&(a[u]=c),a[u][s]=c}),a};e.exports=i},{"./abi":1,"./web3":7}],3:[function(t,e){var n=t("./web3"),r=function(t,e){this.impl=e,this.callbacks=[],this.id=e.newFilter(t),n.provider.startPolling({call:e.changed,args:[this.id]},this.id,this.trigger.bind(this))};r.prototype.arrived=function(t){this.changed(t)},r.prototype.changed=function(t){this.callbacks.push(t)},r.prototype.trigger=function(t){for(var e=0;e<this.callbacks.length;e++)for(var n=0;n<t.length;n++)this.callbacks[e].call(this,t[n])},r.prototype.uninstall=function(){this.impl.uninstallFilter(this.id),n.provider.stopPolling(this.id)},r.prototype.messages=function(){return this.impl.getMessages(this.id)},r.prototype.logs=function(){return this.messages()},e.exports=r},{"./web3":7}],4:[function(t,e){function n(t){return{jsonrpc:"2.0",method:t.call,params:t.args,id:t._id}}var r=function(t){this.handlers=[],this.host=t||"http://localhost:8080"};r.prototype.send=function(t){var e=n(t),r=new XMLHttpRequest;return r.open("POST",this.host,!1),r.send(JSON.stringify(e)),r.responseText},e.exports=r},{}],5:[function(t,e){var n=(t("./web3"),function(){this.polls=[],this.provider=void 0,this.id=1;var t=this,e=function(){t.provider&&t.polls.forEach(function(e){e.data._id=t.id,t.id++;var n=t.provider.send(e.data);n=JSON.parse(n),!n.error&&n.result instanceof Array&&0!==n.result.length&&e.callback(n.result)}),setTimeout(e,1e3)};e()});n.prototype.send=function(t){if(t.args=t.args||[],t._id=this.id++,void 0===this.provider)return console.error("provider is not set"),null;var e=this.provider.send(t);return e=JSON.parse(e),e.error?(console.log(e.error),null):e.result},n.prototype.set=function(t){this.provider=t},n.prototype.startPolling=function(t,e,n){this.polls.push({data:t,id:e,callback:n})},n.prototype.stopPolling=function(t){for(var e=this.polls.length;e--;){var n=this.polls[e];n.id===t&&this.polls.splice(e,1)}},e.exports=n},{"./web3":7}],6:[function(t,e){var n=function(){};n.prototype.send=function(t){return navigator.qt.callMethod(JSON.stringify(t))},e.exports=n},{}],7:[function(t,e){var n=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"],r=function(){return[{name:"sha3",call:"web3_sha3"}]},i=function(){var t=function(t){return"string"==typeof t[0]?"eth_blockByHash":"eth_blockByNumber"},e=function(t){return"string"==typeof t[0]?"eth_transactionByHash":"eth_transactionByNumber"},n=function(t){return"string"==typeof t[0]?"eth_uncleByHash":"eth_uncleByNumber"},r=[{name:"balanceAt",call:"eth_balanceAt"},{name:"stateAt",call:"eth_stateAt"},{name:"storageAt",call:"eth_storageAt"},{name:"countAt",call:"eth_countAt"},{name:"codeAt",call:"eth_codeAt"},{name:"transact",call:"eth_transact"},{name:"call",call:"eth_call"},{name:"block",call:t},{name:"transaction",call:e},{name:"uncle",call:n},{name:"compilers",call:"eth_compilers"},{name:"flush",call:"eth_flush"},{name:"lll",call:"eth_lll"},{name:"solidity",call:"eth_solidity"},{name:"serpent",call:"eth_serpent"},{name:"logs",call:"eth_logs"}];return r},o=function(){return[{name:"coinbase",getter:"eth_coinbase",setter:"eth_setCoinbase"},{name:"listening",getter:"eth_listening",setter:"eth_setListening"},{name:"mining",getter:"eth_mining",setter:"eth_setMining"},{name:"gasPrice",getter:"eth_gasPrice"},{name:"accounts",getter:"eth_accounts"},{name:"peerCount",getter:"eth_peerCount"},{name:"defaultBlock",getter:"eth_defaultBlock",setter:"eth_setDefaultBlock"},{name:"number",getter:"eth_number"}]},a=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},f=function(){return[{name:"post",call:"shh_post"},{name:"newIdentity",call:"shh_newIdentity"},{name:"haveIdentity",call:"shh_haveIdentity"},{name:"newGroup",call:"shh_newGroup"},{name:"addToGroup",call:"shh_addToGroup"}]},u=function(){var t=function(t){return"string"==typeof t[0]?"eth_newFilterString":"eth_newFilter"};return[{name:"newFilter",call:t},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getMessages",call:"eth_filterLogs"}]},s=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessages",call:"shh_getMessages"}]},c=function(t,e){e.forEach(function(e){t[e.name]=function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof e.call?e.call(t):e.call;return h.provider.send({call:n,args:t})}})},l=function(t,e){e.forEach(function(e){var n={};n.get=function(){return h.provider.send({call:e.getter})},e.setter&&(n.set=function(t){return h.provider.send({call:e.setter,args:[t]})}),Object.defineProperty(t,e.name,n)})},h={_callbacks:{},_events:{},providers:{},toHex:function(t){for(var e="",n=0;n<t.length;n++){var r=t.charCodeAt(n).toString(16);e+=r.length<2?"0"+r:r}return e},toAscii:function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);r>n;n+=2){var i=parseInt(t.substr(n,2),16);if(0===i)break;e+=String.fromCharCode(i)}return e},fromAscii:function(t,e){e=void 0===e?0:e;for(var n=this.toHex(t);n.length<2*e;)n+="00";return"0x"+n},toDecimal:function(t){return t=t.length>2?t.substring(2):"0",new BigNumber(t,16).toString(10)},fromDecimal:function(t){return"0x"+new BigNumber(t).toString(16)},toEth:function(t){for(var e="string"==typeof t?0===t.indexOf("0x")?parseInt(t.substr(2),16):parseInt(t):t,r=0,i=n;e>3e3&&r<i.length-1;)e/=1e3,r++;for(var o=e.toString().length<e.toFixed(2).length?e.toString():e.toFixed(2),a=function(t,e,n){return e+","+n};;){var f=o;if(o=o.replace(/(\d)(\d\d\d[\.\,])/,a),f===o)break}return o+" "+i[r]},eth:{contractFromAbi:function(t){return function(e){e=e||"0xc6d9d2cd449a754c494264e1809c50e34d64562b";var n=h.eth.contract(e,t);return n.address=e,n}},watch:function(t){return new h.filter(t,p)}},db:{},shh:{watch:function(t){return new h.filter(t,d)}},haveProvider:function(){return!!h.provider.provider}};c(h,r()),c(h.eth,i()),l(h.eth,o()),c(h.db,a()),c(h.shh,f());var p={changed:"eth_changed"};c(p,u());var d={changed:"shh_changed"};c(d,s()),h.setProvider=function(t){h.provider.set(t)},e.exports=h},{}],web3:[function(t,e){var n=t("./lib/web3"),r=t("./lib/providermanager");n.provider=new r,n.filter=t("./lib/filter"),n.providers.HttpSyncProvider=t("./lib/httpsync"),n.providers.QtSyncProvider=t("./lib/qtsync"),n.eth.contract=t("./lib/contract"),n.abi=t("./lib/abi"),e.exports=n},{"./lib/abi":1,"./lib/contract":2,"./lib/filter":3,"./lib/httpsync":4,"./lib/providermanager":5,"./lib/qtsync":6,"./lib/web3":7}]},{},["web3"]); \ No newline at end of file
diff --git a/cmd/mist/assets/ext/example/balance.html b/cmd/mist/assets/ext/example/balance.html
deleted file mode 100644
index 75c41dc8e..000000000
--- a/cmd/mist/assets/ext/example/balance.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!doctype>
-<html>
-
-<head>
-<script type="text/javascript" src="../bignumber.min.js"></script>
-<script type="text/javascript" src="../dist/ethereum.js"></script>
-<script type="text/javascript">
-
-console.log("hello world");
- var web3 = require('web3');
-console.log(web3)
- web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
-
- function watchBalance() {
- var coinbase = web3.eth.coinbase;
- var originalBalance = 0;
-
- var balance = web3.eth.balanceAt(coinbase);
- var originalBalance = web3.toDecimal(balance);
- document.getElementById('original').innerText = 'original balance: ' + originalBalance + ' watching...';
-
- web3.eth.watch({altered: coinbase}).changed(function() {
- balance = web3.eth.balanceAt(coinbase)
- var currentBalance = web3.toDecimal(balance);
- document.getElementById("current").innerText = 'current: ' + currentBalance;
- document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance);
- });
- }
-
-var request = new XMLHttpRequest();
-request.open('POST', "http://localhost:8080", false);
-request.send({});
-
-
-</script>
-</head>
-<body>
- <h1>coinbase balance</h1>
- <button type="button" onClick="watchBalance();">watch balance</button>
- <div></div>
- <div id="original"></div>
- <div id="current"></div>
- <div id="diff"></div>
-</body>
-</html>
-
diff --git a/cmd/mist/assets/ext/example/contract.html b/cmd/mist/assets/ext/example/contract.html
deleted file mode 100644
index dccd1a64f..000000000
--- a/cmd/mist/assets/ext/example/contract.html
+++ /dev/null
@@ -1,73 +0,0 @@
-<!doctype>
-<html>
-
-<head>
-<script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
-<script type="text/javascript" src="../dist/ethereum.js"></script>
-<script type="text/javascript">
-
- var web3 = require('web3');
- web3.setProvider(new web3.providers.HttpSyncProvider());
-
- // solidity source code
- var source = "" +
- "contract test {\n" +
- " function multiply(uint a) returns(uint d) {\n" +
- " return a * 7;\n" +
- " }\n" +
- "}\n";
-
- // contract description, this will be autogenerated somehow
- var desc = [{
- "name": "multiply(uint256)",
- "inputs": [
- {
- "name": "a",
- "type": "uint256"
- }
- ],
- "outputs": [
- {
- "name": "d",
- "type": "uint256"
- }
- ]
- }];
-
- var contract;
-
- function createExampleContract() {
- // hide create button
- document.getElementById('create').style.visibility = 'hidden';
- document.getElementById('source').innerText = source;
-
- // create contract
- var address = web3.eth.transact({code: web3.eth.solidity(source)});
- contract = web3.eth.contract(address, desc);
- document.getElementById('call').style.visibility = 'visible';
- }
-
- function callExampleContract() {
- // this should be generated by ethereum
- var param = parseInt(document.getElementById('value').value);
-
- // call the contract
- var res = contract.call().multiply(param);
- document.getElementById('result').innerText = res.toString(10);
- }
-
-</script>
-</head>
-<body>
- <h1>contract</h1>
- <div id="source"></div>
- <div id='create'>
- <button type="button" onClick="createExampleContract();">create example contract</button>
- </div>
- <div id='call' style='visibility: hidden;'>
- <input type="number" id="value" onkeyup='callExampleContract()'></input>
- </div>
- <div id="result"></div>
-</body>
-</html>
-
diff --git a/cmd/mist/assets/ext/example/natspec_contract.html b/cmd/mist/assets/ext/example/natspec_contract.html
deleted file mode 100644
index 40561a27c..000000000
--- a/cmd/mist/assets/ext/example/natspec_contract.html
+++ /dev/null
@@ -1,76 +0,0 @@
-<!doctype>
-<html>
-
-<head>
-<script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
-<script type="text/javascript" src="../dist/ethereum.js"></script>
-<script type="text/javascript">
-
- var web3 = require('web3');
- web3.setProvider(new web3.providers.QtSyncProvider());
-
- // solidity source code
- var source = "" +
- "contract test {\n" +
- " /// @notice Will multiply `a` by 7. \n" +
- " function multiply(uint a) returns(uint d) {\n" +
- " return a * 7;\n" +
- " }\n" +
- "}\n";
-
- // contract description, this will be autogenerated somehow
- var desc = [{
- "name": "multiply(uint256)",
- "inputs": [
- {
- "name": "a",
- "type": "uint256"
- }
- ],
- "outputs": [
- {
- "name": "d",
- "type": "uint256"
- }
- ]
- }];
-
- var contract;
-
- function createExampleContract() {
- // hide create button
- document.getElementById('create').style.visibility = 'hidden';
- document.getElementById('source').innerText = source;
-
- // create contract
- var address = web3.eth.transact({code: web3.eth.solidity(source)});
- contract = web3.eth.contract(address, desc);
- document.getElementById('call').style.visibility = 'visible';
- }
-
- function callExampleContract() {
- // this should be generated by ethereum
- var param = parseInt(document.getElementById('value').value);
-
- // transaction does not return any result, cause it's not synchronous and we don't know,
- // when it will be processed
- contract.transact().multiply(param);
- document.getElementById('result').innerText = 'transaction made';
- }
-
-</script>
-</head>
-<body>
- <h1>contract</h1>
- <div id="source"></div>
- <div id='create'>
- <button type="button" onClick="createExampleContract();">create example contract</button>
- </div>
- <div id='call' style='visibility: hidden;'>
- <input type="number" id="value"></input>
- <button type="button" onClick="callExampleContract()">Call Contract</button>
- </div>
- <div id="result"></div>
-</body>
-</html>
-
diff --git a/cmd/mist/assets/ext/example/node-app.js b/cmd/mist/assets/ext/example/node-app.js
deleted file mode 100644
index 8c2fc0ba3..000000000
--- a/cmd/mist/assets/ext/example/node-app.js
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env node
-
-var web3 = require("../index.js");
-
-web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
-
-var coinbase = web3.eth.coinbase;
-console.log(coinbase);
-
-var balance = web3.eth.balanceAt(coinbase);
-console.log(balance);
-
diff --git a/cmd/mist/assets/ext/filter.js b/cmd/mist/assets/ext/filter.js
deleted file mode 100644
index f8529c54b..000000000
--- a/cmd/mist/assets/ext/filter.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
-//
-// This library 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 2.1 of the License, or (at your option) any later version.
-//
-// This library 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 this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-// MA 02110-1301 USA
-
-var ethx = {
- prototype: Object,
-
- watch: function(options) {
- return new Filter(options);
- },
-
- note: function() {
- var args = Array.prototype.slice.call(arguments, 0);
- var o = []
- for(var i = 0; i < args.length; i++) {
- o.push(args[i].toString())
- }
-
- eth.notef(o);
- },
-};
-
-var Filter = function(options) {
- this.callbacks = [];
- this.options = options;
-
- if(options === "chain") {
- this.id = eth.newFilterString(options);
- } else if(typeof options === "object") {
- this.id = eth.newFilter(options);
- }
-};
-
-Filter.prototype.changed = function(callback) {
- this.callbacks.push(callback);
-
- var self = this;
- messages.connect(function(messages, id) {
- if(id == self.id) {
- for(var i = 0; i < self.callbacks.length; i++) {
- self.callbacks[i].call(self, messages);
- }
- }
- });
-};
-
-Filter.prototype.uninstall = function() {
- eth.uninstallFilter(this.id)
-}
-
-Filter.prototype.messages = function() {
- return eth.messages(this.id)
-}
diff --git a/cmd/mist/assets/ext/gulpfile.js b/cmd/mist/assets/ext/gulpfile.js
deleted file mode 100644
index f8f6c96ce..000000000
--- a/cmd/mist/assets/ext/gulpfile.js
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env node
-
-'use strict';
-
-var path = require('path');
-
-var del = require('del');
-var gulp = require('gulp');
-var browserify = require('browserify');
-var jshint = require('gulp-jshint');
-var uglify = require('gulp-uglify');
-var rename = require('gulp-rename');
-var envify = require('envify/custom');
-var unreach = require('unreachable-branch-transform');
-var source = require('vinyl-source-stream');
-var exorcist = require('exorcist');
-var bower = require('bower');
-
-var DEST = './dist/';
-
-var build = function(src, dst, ugly) {
- var result = browserify({
- debug: true,
- insert_global_vars: false,
- detectGlobals: false,
- bundleExternal: false
- })
- .require('./' + src + '.js', {expose: 'web3'})
- .add('./' + src + '.js')
- .transform('envify', {
- NODE_ENV: 'build'
- })
- .transform('unreachable-branch-transform');
-
- if (ugly) {
- result = result.transform('uglifyify', {
- mangle: false,
- compress: {
- dead_code: false,
- conditionals: true,
- unused: false,
- hoist_funs: true,
- hoist_vars: true,
- negate_iife: false
- },
- beautify: true,
- warnings: true
- });
- }
-
- return result.bundle()
- .pipe(exorcist(path.join( DEST, dst + '.js.map')))
- .pipe(source(dst + '.js'))
- .pipe(gulp.dest( DEST ));
-};
-
-var uglifyFile = function(file) {
- return gulp.src( DEST + file + '.js')
- .pipe(uglify())
- .pipe(rename(file + '.min.js'))
- .pipe(gulp.dest( DEST ));
-};
-
-gulp.task('bower', function(cb){
- bower.commands.install().on('end', function (installed){
- console.log(installed);
- cb();
- });
-});
-
-gulp.task('clean', ['lint'], function(cb) {
- del([ DEST ], cb);
-});
-
-gulp.task('lint', function(){
- return gulp.src(['./*.js', './lib/*.js'])
- .pipe(jshint())
- .pipe(jshint.reporter('default'));
-});
-
-gulp.task('build', ['clean'], function () {
- return build('index', 'ethereum', true);
-});
-
-gulp.task('buildDev', ['clean'], function () {
- return build('index', 'ethereum', false);
-});
-
-gulp.task('uglify', ['build'], function(){
- return uglifyFile('ethereum');
-});
-
-gulp.task('uglifyDev', ['buildDev'], function(){
- return uglifyFile('ethereum');
-});
-
-gulp.task('watch', function() {
- gulp.watch(['./lib/*.js'], ['lint', 'prepare', 'build']);
-});
-
-gulp.task('release', ['bower', 'lint', 'build', 'uglify']);
-gulp.task('dev', ['bower', 'lint', 'buildDev', 'uglifyDev']);
-gulp.task('default', ['dev']);
-
diff --git a/cmd/mist/assets/ext/home.html b/cmd/mist/assets/ext/home.html
deleted file mode 100644
index a524e8403..000000000
--- a/cmd/mist/assets/ext/home.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!doctype>
-<html>
-<head>
-<title>Ethereum</title>
-
-<style type="text/css">
-h1 {
- text-align: center;
- font-family: Courier;
- font-size: 50pt;
-}
-</style>
-</head>
-
-<body>
-<h1>... Ethereum ...</h1>
-<ul>
- <li><a href="http://std.eth">std::Service</a></li>
-</ul>
-</body>
-</html>
-
diff --git a/cmd/mist/assets/ext/html_messaging.js b/cmd/mist/assets/ext/html_messaging.js
deleted file mode 100644
index f58eb7c29..000000000
--- a/cmd/mist/assets/ext/html_messaging.js
+++ /dev/null
@@ -1,481 +0,0 @@
-// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
-//
-// This library 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 2.1 of the License, or (at your option) any later version.
-//
-// This library 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 this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-// MA 02110-1301 USA
-
-// The magic return variable. The magic return variable will be set during the execution of the QML call.
-(function(window) {
- var Promise = window.Promise;
- if(typeof(Promise) === "undefined") {
- var Promise = Q.Promise;
- }
-
- function isPromise(o) {
- return typeof o === "object" && o.then
- }
-
- window.eth = {
- _callbacks: {},
- _events: {},
- prototype: Object(),
-
- toHex: function(str) {
- var hex = "";
- for(var i = 0; i < str.length; i++) {
- var n = str.charCodeAt(i).toString(16);
- hex += n.length < 2 ? '0' + n : n;
- }
-
- return hex;
- },
-
- toAscii: function(hex) {
- // Find termination
- var str = "";
- var i = 0, l = hex.length;
- for(; i < l; i+=2) {
- var code = hex.charCodeAt(i)
- if(code == 0) {
- break;
- }
-
- str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
- }
-
- return str;
- },
-
- fromAscii: function(str, pad) {
- if(pad === undefined) {
- pad = 32
- }
-
- var hex = this.toHex(str);
-
- while(hex.length < pad*2)
- hex += "00";
-
- return hex
- },
-
- block: function(numberOrHash) {
- return new Promise(function(resolve, reject) {
- var func;
- if(typeof numberOrHash == "string") {
- func = "getBlockByHash";
- } else {
- func = "getBlockByNumber";
- }
-
- postData({call: func, args: [numberOrHash]}, function(block) {
- if(block)
- resolve(block);
- else
- reject("not found");
-
- });
- });
- },
-
- transact: function(params) {
- if(params === undefined) {
- params = {};
- }
-
- if(params.endowment !== undefined)
- params.value = params.endowment;
- if(params.code !== undefined)
- params.data = params.code;
-
-
- var promises = []
- if(isPromise(params.to)) {
- promises.push(params.to.then(function(_to) { params.to = _to; }));
- }
- if(isPromise(params.from)) {
- promises.push(params.from.then(function(_from) { params.from = _from; }));
- }
-
- if(typeof params.data !== "object" || isPromise(params.data)) {
- params.data = [params.data]
- }
-
- var data = params.data;
- for(var i = 0; i < params.data.length; i++) {
- if(isPromise(params.data[i])) {
- var promise = params.data[i];
- var _i = i;
- promises.push(promise.then(function(_arg) { params.data[_i] = _arg; }));
- }
- }
-
- // Make sure everything is string
- var fields = ["value", "gas", "gasPrice"];
- for(var i = 0; i < fields.length; i++) {
- if(params[fields[i]] === undefined) {
- params[fields[i]] = "";
- }
- params[fields[i]] = params[fields[i]].toString();
- }
-
- // Load promises then call the last "transact".
- return Q.all(promises).then(function() {
- return new Promise(function(resolve, reject) {
- params.data = params.data.join("");
- postData({call: "transact", args: params}, function(data) {
- if(data[1])
- reject(data[0]);
- else
- resolve(data[0]);
- });
- });
- })
- },
-
- compile: function(code) {
- return new Promise(function(resolve, reject) {
- postData({call: "compile", args: [code]}, function(data) {
- if(data[1])
- reject(data[0]);
- else
- resolve(data[0]);
- });
- });
- },
-
- balanceAt: function(address) {
- var promises = [];
-
- if(isPromise(address)) {
- promises.push(address.then(function(_address) { address = _address; }));
- }
-
- return Q.all(promises).then(function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getBalanceAt", args: [address]}, function(balance) {
- resolve(balance);
- });
- });
- });
- },
-
- countAt: function(address) {
- var promises = [];
-
- if(isPromise(address)) {
- promises.push(address.then(function(_address) { address = _address; }));
- }
-
- return Q.all(promises).then(function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getCountAt", args: [address]}, function(count) {
- resolve(count);
- });
- });
- });
- },
-
- codeAt: function(address) {
- var promises = [];
-
- if(isPromise(address)) {
- promises.push(address.then(function(_address) { address = _address; }));
- }
-
- return Q.all(promises).then(function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getCodeAt", args: [address]}, function(code) {
- resolve(code);
- });
- });
- });
- },
-
- storageAt: function(address, storageAddress) {
- var promises = [];
-
- if(isPromise(address)) {
- promises.push(address.then(function(_address) { address = _address; }));
- }
-
- if(isPromise(storageAddress)) {
- promises.push(storageAddress.then(function(_sa) { storageAddress = _sa; }));
- }
-
- return Q.all(promises).then(function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getStorageAt", args: [address, storageAddress]}, function(entry) {
- resolve(entry);
- });
- });
- });
- },
-
- stateAt: function(address, storageAddress) {
- return this.storageAt(address, storageAddress);
- },
-
- call: function(params) {
- if(params === undefined) {
- params = {};
- }
-
- if(params.endowment !== undefined)
- params.value = params.endowment;
- if(params.code !== undefined)
- params.data = params.code;
-
-
- var promises = []
- if(isPromise(params.to)) {
- promises.push(params.to.then(function(_to) { params.to = _to; }));
- }
- if(isPromise(params.from)) {
- promises.push(params.from.then(function(_from) { params.from = _from; }));
- }
-
- if(isPromise(params.data)) {
- promises.push(params.data.then(function(_code) { params.data = _code; }));
- } else {
- if(typeof params.data === "object") {
- data = "";
- for(var i = 0; i < params.data.length; i++) {
- data += params.data[i]
- }
- } else {
- data = params.data;
- }
- }
-
- // Make sure everything is string
- var fields = ["value", "gas", "gasPrice"];
- for(var i = 0; i < fields.length; i++) {
- if(params[fields[i]] === undefined) {
- params[fields[i]] = "";
- }
- params[fields[i]] = params[fields[i]].toString();
- }
-
- // Load promises then call the last "transact".
- return Q.all(promises).then(function() {
- return new Promise(function(resolve, reject) {
- postData({call: "call", args: params}, function(data) {
- if(data[1])
- reject(data[0]);
- else
- resolve(data[0]);
- });
- });
- })
- },
-
- watch: function(params) {
- return new Filter(params);
- },
-
- secretToAddress: function(key) {
- var promises = [];
- if(isPromise(key)) {
- promises.push(key.then(function(_key) { key = _key; }));
- }
-
- return Q.all(promises).then(function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getSecretToAddress", args: [key]}, function(address) {
- resolve(address);
- });
- });
- });
- },
-
- on: function(event, cb) {
- if(eth._events[event] === undefined) {
- eth._events[event] = [];
- }
-
- eth._events[event].push(cb);
-
- return this
- },
-
- off: function(event, cb) {
- if(eth._events[event] !== undefined) {
- var callbacks = eth._events[event];
- for(var i = 0; i < callbacks.length; i++) {
- if(callbacks[i] === cb) {
- delete callbacks[i];
- }
- }
- }
-
- return this
- },
-
- trigger: function(event, data) {
- var callbacks = eth._events[event];
- if(callbacks !== undefined) {
- for(var i = 0; i < callbacks.length; i++) {
- // Figure out whether the returned data was an array
- // array means multiple return arguments (multiple params)
- if(data instanceof Array) {
- callbacks[i].apply(this, data);
- } else {
- callbacks[i].call(this, data);
- }
- }
- }
- },
- };
-
- // Eth object properties
- Object.defineProperty(eth, "key", {
- get: function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getKey"}, function(k) {
- resolve(k);
- });
- });
- },
- });
-
- Object.defineProperty(eth, "gasPrice", {
- get: function() {
- return "10000000000000"
- }
- });
-
- Object.defineProperty(eth, "coinbase", {
- get: function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getCoinBase"}, function(coinbase) {
- resolve(coinbase);
- });
- });
- },
- });
-
- Object.defineProperty(eth, "listening", {
- get: function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getIsListening"}, function(listening) {
- resolve(listening);
- });
- });
- },
- });
-
-
- Object.defineProperty(eth, "mining", {
- get: function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getIsMining"}, function(mining) {
- resolve(mining);
- });
- });
- },
- });
-
- Object.defineProperty(eth, "peerCount", {
- get: function() {
- return new Promise(function(resolve, reject) {
- postData({call: "getPeerCount"}, function(peerCount) {
- resolve(peerCount);
- });
- });
- },
- });
-
- var filters = [];
- var Filter = function(options) {
- filters.push(this);
-
- this.callbacks = [];
- this.options = options;
-
- var call;
- if(options === "chain") {
- call = "newFilterString"
- } else if(typeof options === "object") {
- call = "newFilter"
- }
-
- var self = this; // Cheaper than binding
- this.promise = new Promise(function(resolve, reject) {
- postData({call: call, args: [options]}, function(id) {
- self.id = id;
-
- resolve(id);
- });
- });
- };
-
- Filter.prototype.changed = function(callback) {
- var self = this;
- this.promise.then(function(id) {
- self.callbacks.push(callback);
- });
- };
-
- Filter.prototype.trigger = function(messages, id) {
- if(id == this.id) {
- for(var i = 0; i < this.callbacks.length; i++) {
- this.callbacks[i].call(this, messages);
- }
- }
- };
-
- Filter.prototype.uninstall = function() {
- this.promise.then(function(id) {
- postData({call: "uninstallFilter", args:[id]});
- });
- };
-
- Filter.prototype.messages = function() {
- var self=this;
- return Q.all([this.promise]).then(function() {
- var id = self.id
- return new Promise(function(resolve, reject) {
- postData({call: "getMessages", args: [id]}, function(messages) {
- resolve(messages);
- });
- });
- });
- };
-
- // Register to the messages callback. "messages" will be emitted when new messages
- // from the client have been created.
- eth.on("messages", function(messages, id) {
- for(var i = 0; i < filters.length; i++) {
- filters[i].trigger(messages, id);
- }
- });
-
-
- var g_seed = 1;
- function postData(data, cb) {
- data._seed = g_seed;
- if(cb) {
- eth._callbacks[data._seed] = cb;
- }
-
- if(data.args === undefined) {
- data.args = [];
- }
-
- g_seed++;
-
- window._messagingAdapter.call(this, JSON.stringify(data))
- }
-})(this);
diff --git a/cmd/mist/assets/ext/http.js b/cmd/mist/assets/ext/http.js
deleted file mode 100644
index 81908266f..000000000
--- a/cmd/mist/assets/ext/http.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
-//
-// This library 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 2.1 of the License, or (at your option) any later version.
-//
-// This library 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 this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-// MA 02110-1301 USA
-
-// this function is included locally, but you can also include separately via a header definition
-function request(url, callback) {
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = (function(req) {
- return function() {
- if(req.readyState === 4) {
- callback(req);
- }
- }
- })(xhr);
- xhr.open('GET', url, true);
- xhr.send('');
-}
diff --git a/cmd/mist/assets/ext/index.js b/cmd/mist/assets/ext/index.js
deleted file mode 100644
index 76c923722..000000000
--- a/cmd/mist/assets/ext/index.js
+++ /dev/null
@@ -1,11 +0,0 @@
-var web3 = require('./lib/web3');
-var ProviderManager = require('./lib/providermanager');
-web3.provider = new ProviderManager();
-web3.filter = require('./lib/filter');
-web3.providers.HttpSyncProvider = require('./lib/httpsync');
-web3.providers.QtSyncProvider = require('./lib/qtsync');
-web3.eth.contract = require('./lib/contract');
-web3.abi = require('./lib/abi');
-
-
-module.exports = web3;
diff --git a/cmd/mist/assets/ext/lib/abi.js b/cmd/mist/assets/ext/lib/abi.js
deleted file mode 100644
index ba47dca73..000000000
--- a/cmd/mist/assets/ext/lib/abi.js
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file abi.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-// TODO: is these line is supposed to be here?
-if (process.env.NODE_ENV !== 'build') {
- var BigNumber = require('bignumber.js'); // jshint ignore:line
-}
-
-var web3 = require('./web3'); // jshint ignore:line
-
-BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_DOWN });
-
-var ETH_PADDING = 32;
-
-/// method signature length in bytes
-var ETH_METHOD_SIGNATURE_LENGTH = 4;
-
-/// Finds first index of array element matching pattern
-/// @param array
-/// @param callback pattern
-/// @returns index of element
-var findIndex = function (array, callback) {
- var end = false;
- var i = 0;
- for (; i < array.length && !end; i++) {
- end = callback(array[i]);
- }
- return end ? i - 1 : -1;
-};
-
-/// @returns a function that is used as a pattern for 'findIndex'
-var findMethodIndex = function (json, methodName) {
- return findIndex(json, function (method) {
- return method.name === methodName;
- });
-};
-
-/// @returns method with given method name
-var getMethodWithName = function (json, methodName) {
- var index = findMethodIndex(json, methodName);
- if (index === -1) {
- console.error('method ' + methodName + ' not found in the abi');
- return undefined;
- }
- return json[index];
-};
-
-/// @param string string to be padded
-/// @param number of characters that result string should have
-/// @param sign, by default 0
-/// @returns right aligned string
-var padLeft = function (string, chars, sign) {
- return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
-};
-
-/// @param expected type prefix (string)
-/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false
-var prefixedType = function (prefix) {
- return function (type) {
- return type.indexOf(prefix) === 0;
- };
-};
-
-/// @param expected type name (string)
-/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false
-var namedType = function (name) {
- return function (type) {
- return name === type;
- };
-};
-
-var arrayType = function (type) {
- return type.slice(-2) === '[]';
-};
-
-/// Formats input value to byte representation of int
-/// If value is negative, return it's two's complement
-/// If the value is floating point, round it down
-/// @returns right-aligned byte representation of int
-var formatInputInt = function (value) {
- var padding = ETH_PADDING * 2;
- if (value instanceof BigNumber || typeof value === 'number') {
- if (typeof value === 'number')
- value = new BigNumber(value);
- value = value.round();
-
- if (value.lessThan(0))
- value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
- value = value.toString(16);
- }
- else if (value.indexOf('0x') === 0)
- value = value.substr(2);
- else if (typeof value === 'string')
- value = formatInputInt(new BigNumber(value));
- else
- value = (+value).toString(16);
- return padLeft(value, padding);
-};
-
-/// Formats input value to byte representation of string
-/// @returns left-algined byte representation of string
-var formatInputString = function (value) {
- return web3.fromAscii(value, ETH_PADDING).substr(2);
-};
-
-/// Formats input value to byte representation of bool
-/// @returns right-aligned byte representation bool
-var formatInputBool = function (value) {
- return '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');
-};
-
-/// Formats input value to byte representation of real
-/// Values are multiplied by 2^m and encoded as integers
-/// @returns byte representation of real
-var formatInputReal = function (value) {
- return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
-};
-
-var dynamicTypeBytes = function (type, value) {
- // TODO: decide what to do with array of strings
- if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
- return formatInputInt(value.length);
- return "";
-};
-
-/// Setups input formatters for solidity types
-/// @returns an array of input formatters
-var setupInputTypes = function () {
-
- return [
- { type: prefixedType('uint'), format: formatInputInt },
- { type: prefixedType('int'), format: formatInputInt },
- { type: prefixedType('hash'), format: formatInputInt },
- { type: prefixedType('string'), format: formatInputString },
- { type: prefixedType('real'), format: formatInputReal },
- { type: prefixedType('ureal'), format: formatInputReal },
- { type: namedType('address'), format: formatInputInt },
- { type: namedType('bool'), format: formatInputBool }
- ];
-};
-
-var inputTypes = setupInputTypes();
-
-/// Formats input params to bytes
-/// @param contract json abi
-/// @param name of the method that we want to use
-/// @param array of params that will be formatted to bytes
-/// @returns bytes representation of input params
-var toAbiInput = function (json, methodName, params) {
- var bytes = "";
-
- var method = getMethodWithName(json, methodName);
- var padding = ETH_PADDING * 2;
-
- /// first we iterate in search for dynamic
- method.inputs.forEach(function (input, index) {
- bytes += dynamicTypeBytes(input.type, params[index]);
- });
-
- method.inputs.forEach(function (input, i) {
- var typeMatch = false;
- for (var j = 0; j < inputTypes.length && !typeMatch; j++) {
- typeMatch = inputTypes[j].type(method.inputs[i].type, params[i]);
- }
- if (!typeMatch) {
- console.error('input parser does not support type: ' + method.inputs[i].type);
- }
-
- var formatter = inputTypes[j - 1].format;
- var toAppend = "";
-
- if (arrayType(method.inputs[i].type))
- toAppend = params[i].reduce(function (acc, curr) {
- return acc + formatter(curr);
- }, "");
- else
- toAppend = formatter(params[i]);
-
- bytes += toAppend;
- });
- return bytes;
-};
-
-/// Check if input value is negative
-/// @param value is hex format
-/// @returns true if it is negative, otherwise false
-var signedIsNegative = function (value) {
- return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
-};
-
-/// Formats input right-aligned input bytes to int
-/// @returns right-aligned input bytes formatted to int
-var formatOutputInt = function (value) {
- value = value || "0";
- // check if it's negative number
- // it it is, return two's complement
- if (signedIsNegative(value)) {
- return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
- }
- return new BigNumber(value, 16);
-};
-
-/// Formats big right-aligned input bytes to uint
-/// @returns right-aligned input bytes formatted to uint
-var formatOutputUInt = function (value) {
- value = value || "0";
- return new BigNumber(value, 16);
-};
-
-/// @returns input bytes formatted to real
-var formatOutputReal = function (value) {
- return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128));
-};
-
-/// @returns input bytes formatted to ureal
-var formatOutputUReal = function (value) {
- return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128));
-};
-
-/// @returns right-aligned input bytes formatted to hex
-var formatOutputHash = function (value) {
- return "0x" + value;
-};
-
-/// @returns right-aligned input bytes formatted to bool
-var formatOutputBool = function (value) {
- return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
-};
-
-/// @returns left-aligned input bytes formatted to ascii string
-var formatOutputString = function (value) {
- return web3.toAscii(value);
-};
-
-/// @returns right-aligned input bytes formatted to address
-var formatOutputAddress = function (value) {
- return "0x" + value.slice(value.length - 40, value.length);
-};
-
-var dynamicBytesLength = function (type) {
- if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
- return ETH_PADDING * 2;
- return 0;
-};
-
-/// Setups output formaters for solidity types
-/// @returns an array of output formatters
-var setupOutputTypes = function () {
-
- return [
- { type: prefixedType('uint'), format: formatOutputUInt },
- { type: prefixedType('int'), format: formatOutputInt },
- { type: prefixedType('hash'), format: formatOutputHash },
- { type: prefixedType('string'), format: formatOutputString },
- { type: prefixedType('real'), format: formatOutputReal },
- { type: prefixedType('ureal'), format: formatOutputUReal },
- { type: namedType('address'), format: formatOutputAddress },
- { type: namedType('bool'), format: formatOutputBool }
- ];
-};
-
-var outputTypes = setupOutputTypes();
-
-/// Formats output bytes back to param list
-/// @param contract json abi
-/// @param name of the method that we want to use
-/// @param bytes representtion of output
-/// @returns array of output params
-var fromAbiOutput = function (json, methodName, output) {
-
- output = output.slice(2);
- var result = [];
- var method = getMethodWithName(json, methodName);
- var padding = ETH_PADDING * 2;
-
- var dynamicPartLength = method.outputs.reduce(function (acc, curr) {
- return acc + dynamicBytesLength(curr.type);
- }, 0);
-
- var dynamicPart = output.slice(0, dynamicPartLength);
- output = output.slice(dynamicPartLength);
-
- method.outputs.forEach(function (out, i) {
- var typeMatch = false;
- for (var j = 0; j < outputTypes.length && !typeMatch; j++) {
- typeMatch = outputTypes[j].type(method.outputs[i].type);
- }
-
- if (!typeMatch) {
- console.error('output parser does not support type: ' + method.outputs[i].type);
- }
-
- var formatter = outputTypes[j - 1].format;
- if (arrayType(method.outputs[i].type)) {
- var size = formatOutputUInt(dynamicPart.slice(0, padding));
- dynamicPart = dynamicPart.slice(padding);
- var array = [];
- for (var k = 0; k < size; k++) {
- array.push(formatter(output.slice(0, padding)));
- output = output.slice(padding);
- }
- result.push(array);
- }
- else if (prefixedType('string')(method.outputs[i].type)) {
- dynamicPart = dynamicPart.slice(padding);
- result.push(formatter(output.slice(0, padding)));
- output = output.slice(padding);
- } else {
- result.push(formatter(output.slice(0, padding)));
- output = output.slice(padding);
- }
- });
-
- return result;
-};
-
-/// @returns display name for method eg. multiply(uint256) -> multiply
-var methodDisplayName = function (method) {
- var length = method.indexOf('(');
- return length !== -1 ? method.substr(0, length) : method;
-};
-
-/// @returns overloaded part of method's name
-var methodTypeName = function (method) {
- /// TODO: make it not vulnerable
- var length = method.indexOf('(');
- return length !== -1 ? method.substr(length + 1, method.length - 1 - (length + 1)) : "";
-};
-
-/// @param json abi for contract
-/// @returns input parser object for given json abi
-var inputParser = function (json) {
- var parser = {};
- json.forEach(function (method) {
- var displayName = methodDisplayName(method.name);
- var typeName = methodTypeName(method.name);
-
- var impl = function () {
- var params = Array.prototype.slice.call(arguments);
- return toAbiInput(json, method.name, params);
- };
-
- if (parser[displayName] === undefined) {
- parser[displayName] = impl;
- }
-
- parser[displayName][typeName] = impl;
- });
-
- return parser;
-};
-
-/// @param json abi for contract
-/// @returns output parser for given json abi
-var outputParser = function (json) {
- var parser = {};
- json.forEach(function (method) {
-
- var displayName = methodDisplayName(method.name);
- var typeName = methodTypeName(method.name);
-
- var impl = function (output) {
- return fromAbiOutput(json, method.name, output);
- };
-
- if (parser[displayName] === undefined) {
- parser[displayName] = impl;
- }
-
- parser[displayName][typeName] = impl;
- });
-
- return parser;
-};
-
-/// @param method name for which we want to get method signature
-/// @returns (promise) contract method signature for method with given name
-var methodSignature = function (name) {
- return web3.sha3(web3.fromAscii(name)).slice(0, 2 + ETH_METHOD_SIGNATURE_LENGTH * 2);
-};
-
-module.exports = {
- inputParser: inputParser,
- outputParser: outputParser,
- methodSignature: methodSignature,
- methodDisplayName: methodDisplayName,
- methodTypeName: methodTypeName,
- getMethodWithName: getMethodWithName
-};
-
diff --git a/cmd/mist/assets/ext/lib/contract.js b/cmd/mist/assets/ext/lib/contract.js
deleted file mode 100644
index e71734d0b..000000000
--- a/cmd/mist/assets/ext/lib/contract.js
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file contract.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3'); // jshint ignore:line
-var abi = require('./abi');
-
-/**
- * This method should be called when we want to call / transact some solidity method from javascript
- * it returns an object which has same methods available as solidity contract description
- * usage example:
- *
- * var abi = [{
- * name: 'myMethod',
- * inputs: [{ name: 'a', type: 'string' }],
- * outputs: [{name: 'd', type: 'string' }]
- * }]; // contract abi
- *
- * var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object
- *
- * myContract.myMethod('this is test string param for call'); // myMethod call (implicit, default)
- * myContract.call().myMethod('this is test string param for call'); // myMethod call (explicit)
- * myContract.transact().myMethod('this is test string param for transact'); // myMethod transact
- *
- * @param address - address of the contract, which should be called
- * @param desc - abi json description of the contract, which is being created
- * @returns contract object
- */
-
-var contract = function (address, desc) {
-
- desc.forEach(function (method) {
- // workaround for invalid assumption that method.name is the full anonymous prototype of the method.
- // it's not. it's just the name. the rest of the code assumes it's actually the anonymous
- // prototype, so we make it so as a workaround.
- if (method.name.indexOf('(') === -1) {
- var displayName = method.name;
- var typeName = method.inputs.map(function(i){return i.type; }).join();
- method.name = displayName + '(' + typeName + ')';
- }
- });
-
- var inputParser = abi.inputParser(desc);
- var outputParser = abi.outputParser(desc);
-
- var result = {};
-
- result.call = function (options) {
- result._isTransact = false;
- result._options = options;
- return result;
- };
-
- result.transact = function (options) {
- result._isTransact = true;
- result._options = options;
- return result;
- };
-
- result._options = {};
- ['gas', 'gasPrice', 'value', 'from'].forEach(function(p) {
- result[p] = function (v) {
- result._options[p] = v;
- return result;
- };
- });
-
-
- desc.forEach(function (method) {
-
- var displayName = abi.methodDisplayName(method.name);
- var typeName = abi.methodTypeName(method.name);
-
- var impl = function () {
- var params = Array.prototype.slice.call(arguments);
- var signature = abi.methodSignature(method.name);
- var parsed = inputParser[displayName][typeName].apply(null, params);
-
- var options = result._options || {};
- options.to = address;
- options.data = signature + parsed;
-
- var isTransact = result._isTransact === true || (result._isTransact !== false && !method.constant);
- var collapse = options.collapse !== false;
-
- // reset
- result._options = {};
- result._isTransact = null;
-
- if (isTransact) {
- // it's used byt natspec.js
- // TODO: figure out better way to solve this
- web3._currentContractAbi = desc;
- web3._currentContractAddress = address;
- web3._currentContractMethodName = method.name;
- web3._currentContractMethodParams = params;
-
- // transactions do not have any output, cause we do not know, when they will be processed
- web3.eth.transact(options);
- return;
- }
-
- var output = web3.eth.call(options);
- var ret = outputParser[displayName][typeName](output);
- if (collapse)
- {
- if (ret.length === 1)
- ret = ret[0];
- else if (ret.length === 0)
- ret = null;
- }
- return ret;
- };
-
- if (result[displayName] === undefined) {
- result[displayName] = impl;
- }
-
- result[displayName][typeName] = impl;
-
- });
-
- return result;
-};
-
-module.exports = contract;
-
diff --git a/cmd/mist/assets/ext/lib/filter.js b/cmd/mist/assets/ext/lib/filter.js
deleted file mode 100644
index d93064b58..000000000
--- a/cmd/mist/assets/ext/lib/filter.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file filter.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3'); // jshint ignore:line
-
-/// should be used when we want to watch something
-/// it's using inner polling mechanism and is notified about changes
-var Filter = function(options, impl) {
- this.impl = impl;
- this.callbacks = [];
-
- this.id = impl.newFilter(options);
- web3.provider.startPolling({call: impl.changed, args: [this.id]}, this.id, this.trigger.bind(this));
-};
-
-/// alias for changed*
-Filter.prototype.arrived = function(callback) {
- this.changed(callback);
-};
-
-/// gets called when there is new eth/shh message
-Filter.prototype.changed = function(callback) {
- this.callbacks.push(callback);
-};
-
-/// trigger calling new message from people
-Filter.prototype.trigger = function(messages) {
- for (var i = 0; i < this.callbacks.length; i++) {
- for (var j = 0; j < messages.length; j++) {
- this.callbacks[i].call(this, messages[j]);
- }
- }
-};
-
-/// should be called to uninstall current filter
-Filter.prototype.uninstall = function() {
- this.impl.uninstallFilter(this.id);
- web3.provider.stopPolling(this.id);
-};
-
-/// should be called to manually trigger getting latest messages from the client
-Filter.prototype.messages = function() {
- return this.impl.getMessages(this.id);
-};
-
-/// alias for messages
-Filter.prototype.logs = function () {
- return this.messages();
-};
-
-module.exports = Filter;
diff --git a/cmd/mist/assets/ext/lib/httpsync.js b/cmd/mist/assets/ext/lib/httpsync.js
deleted file mode 100644
index a638cfe94..000000000
--- a/cmd/mist/assets/ext/lib/httpsync.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file httpsync.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * @date 2014
- */
-
-if (process.env.NODE_ENV !== 'build') {
- var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
-}
-
-var HttpSyncProvider = function (host) {
- this.handlers = [];
- this.host = host || 'http://localhost:8080';
-};
-
-/// Transforms inner message to proper jsonrpc object
-/// @param inner message object
-/// @returns jsonrpc object
-function formatJsonRpcObject(object) {
- return {
- jsonrpc: '2.0',
- method: object.call,
- params: object.args,
- id: object._id
- };
-}
-
-/// Transforms jsonrpc object to inner message
-/// @param incoming jsonrpc message
-/// @returns inner message object
-function formatJsonRpcMessage(message) {
- var object = JSON.parse(message);
-
- return {
- _id: object.id,
- data: object.result,
- error: object.error
- };
-}
-
-HttpSyncProvider.prototype.send = function (payload) {
- var data = formatJsonRpcObject(payload);
-
- var request = new XMLHttpRequest();
- request.open('POST', this.host, false);
- request.send(JSON.stringify(data));
-
- // check request.status
- return request.responseText;
-};
-
-module.exports = HttpSyncProvider;
-
diff --git a/cmd/mist/assets/ext/lib/local.js b/cmd/mist/assets/ext/lib/local.js
deleted file mode 100644
index 30cd14df2..000000000
--- a/cmd/mist/assets/ext/lib/local.js
+++ /dev/null
@@ -1,18 +0,0 @@
-var addressName = {"0x12378912345789": "Gav", "0x57835893478594739854": "Jeff"};
-var nameAddress = {};
-
-for (var prop in addressName) {
- if (addressName.hasOwnProperty(prop)) {
- nameAddress[addressName[prop]] = prop;
- }
-}
-
-var local = {
- addressBook:{
- byName: addressName,
- byAddress: nameAddress
- }
-};
-
-if (typeof(module) !== "undefined")
- module.exports = local;
diff --git a/cmd/mist/assets/ext/lib/providermanager.js b/cmd/mist/assets/ext/lib/providermanager.js
deleted file mode 100644
index 25cd14288..000000000
--- a/cmd/mist/assets/ext/lib/providermanager.js
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file providermanager.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-var web3 = require('./web3'); // jshint ignore:line
-
-/**
- * Provider manager object prototype
- * It's responsible for passing messages to providers
- * If no provider is set it's responsible for queuing requests
- * It's also responsible for polling the ethereum node for incoming messages
- * Default poll timeout is 12 seconds
- * If we are running ethereum.js inside ethereum browser, there are backend based tools responsible for polling,
- * and provider manager polling mechanism is not used
- */
-var ProviderManager = function() {
- this.polls = [];
- this.provider = undefined;
- this.id = 1;
-
- var self = this;
- var poll = function () {
- if (self.provider) {
- self.polls.forEach(function (data) {
- data.data._id = self.id;
- self.id++;
- var result = self.provider.send(data.data);
-
- result = JSON.parse(result);
-
- // dont call the callback if result is not an array, or empty one
- if (result.error || !(result.result instanceof Array) || result.result.length === 0) {
- return;
- }
-
- data.callback(result.result);
- });
- }
- setTimeout(poll, 1000);
- };
- poll();
-};
-
-/// sends outgoing requests
-ProviderManager.prototype.send = function(data) {
-
- data.args = data.args || [];
- data._id = this.id++;
-
- if (this.provider === undefined) {
- console.error('provider is not set');
- return null;
- }
-
- //TODO: handle error here?
- var result = this.provider.send(data);
- result = JSON.parse(result);
-
- if (result.error) {
- console.log(result.error);
- return null;
- }
-
- return result.result;
-};
-
-/// setups provider, which will be used for sending messages
-ProviderManager.prototype.set = function(provider) {
- this.provider = provider;
-};
-
-/// this method is only used, when we do not have native qt bindings and have to do polling on our own
-/// should be callled, on start watching for eth/shh changes
-ProviderManager.prototype.startPolling = function (data, pollId, callback) {
- this.polls.push({data: data, id: pollId, callback: callback});
-};
-
-/// should be called to stop polling for certain watch changes
-ProviderManager.prototype.stopPolling = function (pollId) {
- for (var i = this.polls.length; i--;) {
- var poll = this.polls[i];
- if (poll.id === pollId) {
- this.polls.splice(i, 1);
- }
- }
-};
-
-module.exports = ProviderManager;
-
diff --git a/cmd/mist/assets/ext/lib/qtsync.js b/cmd/mist/assets/ext/lib/qtsync.js
deleted file mode 100644
index a287a7172..000000000
--- a/cmd/mist/assets/ext/lib/qtsync.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file qtsync.js
- * @authors:
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * @date 2014
- */
-
-var QtSyncProvider = function () {
-};
-
-QtSyncProvider.prototype.send = function (payload) {
- return navigator.qt.callMethod(JSON.stringify(payload));
-};
-
-module.exports = QtSyncProvider;
-
diff --git a/cmd/mist/assets/ext/lib/web3.js b/cmd/mist/assets/ext/lib/web3.js
deleted file mode 100644
index 7b8bbd28a..000000000
--- a/cmd/mist/assets/ext/lib/web3.js
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- This file is part of ethereum.js.
-
- ethereum.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- ethereum.js 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
-*/
-/** @file web3.js
- * @authors:
- * Jeffrey Wilcke <jeff@ethdev.com>
- * Marek Kotewicz <marek@ethdev.com>
- * Marian Oancea <marian@ethdev.com>
- * Gav Wood <g@ethdev.com>
- * @date 2014
- */
-
-if (process.env.NODE_ENV !== 'build') {
- var BigNumber = require('bignumber.js');
-}
-
-var ETH_UNITS = [
- 'wei',
- 'Kwei',
- 'Mwei',
- 'Gwei',
- 'szabo',
- 'finney',
- 'ether',
- 'grand',
- 'Mether',
- 'Gether',
- 'Tether',
- 'Pether',
- 'Eether',
- 'Zether',
- 'Yether',
- 'Nether',
- 'Dether',
- 'Vether',
- 'Uether'
-];
-
-/// @returns an array of objects describing web3 api methods
-var web3Methods = function () {
- return [
- { name: 'sha3', call: 'web3_sha3' }
- ];
-};
-
-/// @returns an array of objects describing web3.eth api methods
-var ethMethods = function () {
- var blockCall = function (args) {
- return typeof args[0] === "string" ? "eth_blockByHash" : "eth_blockByNumber";
- };
-
- var transactionCall = function (args) {
- return typeof args[0] === "string" ? 'eth_transactionByHash' : 'eth_transactionByNumber';
- };
-
- var uncleCall = function (args) {
- return typeof args[0] === "string" ? 'eth_uncleByHash' : 'eth_uncleByNumber';
- };
-
- var methods = [
- { name: 'balanceAt', call: 'eth_balanceAt' },
- { name: 'stateAt', call: 'eth_stateAt' },
- { name: 'storageAt', call: 'eth_storageAt' },
- { name: 'countAt', call: 'eth_countAt'},
- { name: 'codeAt', call: 'eth_codeAt' },
- { name: 'transact', call: 'eth_transact' },
- { name: 'call', call: 'eth_call' },
- { name: 'block', call: blockCall },
- { name: 'transaction', call: transactionCall },
- { name: 'uncle', call: uncleCall },
- { name: 'compilers', call: 'eth_compilers' },
- { name: 'flush', call: 'eth_flush' },
- { name: 'lll', call: 'eth_lll' },
- { name: 'solidity', call: 'eth_solidity' },
- { name: 'serpent', call: 'eth_serpent' },
- { name: 'logs', call: 'eth_logs' }
- ];
- return methods;
-};
-
-/// @returns an array of objects describing web3.eth api properties
-var ethProperties = function () {
- return [
- { name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' },
- { name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' },
- { name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' },
- { name: 'gasPrice', getter: 'eth_gasPrice' },
- { name: 'accounts', getter: 'eth_accounts' },
- { name: 'peerCount', getter: 'eth_peerCount' },
- { name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' },
- { name: 'number', getter: 'eth_number'}
- ];
-};
-
-/// @returns an array of objects describing web3.db api methods
-var dbMethods = function () {
- return [
- { name: 'put', call: 'db_put' },
- { name: 'get', call: 'db_get' },
- { name: 'putString', call: 'db_putString' },
- { name: 'getString', call: 'db_getString' }
- ];
-};
-
-/// @returns an array of objects describing web3.shh api methods
-var shhMethods = function () {
- return [
- { name: 'post', call: 'shh_post' },
- { name: 'newIdentity', call: 'shh_newIdentity' },
- { name: 'haveIdentity', call: 'shh_haveIdentity' },
- { name: 'newGroup', call: 'shh_newGroup' },
- { name: 'addToGroup', call: 'shh_addToGroup' }
- ];
-};
-
-/// @returns an array of objects describing web3.eth.watch api methods
-var ethWatchMethods = function () {
- var newFilter = function (args) {
- return typeof args[0] === 'string' ? 'eth_newFilterString' : 'eth_newFilter';
- };
-
- return [
- { name: 'newFilter', call: newFilter },
- { name: 'uninstallFilter', call: 'eth_uninstallFilter' },
- { name: 'getMessages', call: 'eth_filterLogs' }
- ];
-};
-
-/// @returns an array of objects describing web3.shh.watch api methods
-var shhWatchMethods = function () {
- return [
- { name: 'newFilter', call: 'shh_newFilter' },
- { name: 'uninstallFilter', call: 'shh_uninstallFilter' },
- { name: 'getMessages', call: 'shh_getMessages' }
- ];
-};
-
-/// creates methods in a given object based on method description on input
-/// setups api calls for these methods
-var setupMethods = function (obj, methods) {
- methods.forEach(function (method) {
- obj[method.name] = function () {
- var args = Array.prototype.slice.call(arguments);
- var call = typeof method.call === 'function' ? method.call(args) : method.call;
- return web3.provider.send({
- call: call,
- args: args
- });
- };
- });
-};
-
-/// creates properties in a given object based on properties description on input
-/// setups api calls for these properties
-var setupProperties = function (obj, properties) {
- properties.forEach(function (property) {
- var proto = {};
- proto.get = function () {
- return web3.provider.send({
- call: property.getter
- });
- };
-
- if (property.setter) {
- proto.set = function (val) {
- return web3.provider.send({
- call: property.setter,
- args: [val]
- });
- };
- }
- Object.defineProperty(obj, property.name, proto);
- });
-};
-
-/// setups web3 object, and it's in-browser executed methods
-var web3 = {
- _callbacks: {},
- _events: {},
- providers: {},
-
- toHex: function(str) {
- var hex = "";
- for(var i = 0; i < str.length; i++) {
- var n = str.charCodeAt(i).toString(16);
- hex += n.length < 2 ? '0' + n : n;
- }
-
- return hex;
- },
-
- /// @returns ascii string representation of hex value prefixed with 0x
- toAscii: function(hex) {
- // Find termination
- var str = "";
- var i = 0, l = hex.length;
- if (hex.substring(0, 2) === '0x')
- i = 2;
- for(; i < l; i+=2) {
- var code = parseInt(hex.substr(i, 2), 16);
- if(code === 0) {
- break;
- }
-
- str += String.fromCharCode(code);
- }
-
- return str;
- },
-
- /// @returns hex representation (prefixed by 0x) of ascii string
- fromAscii: function(str, pad) {
- pad = pad === undefined ? 0 : pad;
- var hex = this.toHex(str);
- while(hex.length < pad*2)
- hex += "00";
- return "0x" + hex;
- },
-
- /// @returns decimal representaton of hex value prefixed by 0x
- toDecimal: function (val) {
- // remove 0x and place 0, if it's required
- val = val.length > 2 ? val.substring(2) : "0";
- return (new BigNumber(val, 16).toString(10));
- },
-
- /// @returns hex representation (prefixed by 0x) of decimal value
- fromDecimal: function (val) {
- return "0x" + (new BigNumber(val).toString(16));
- },
-
- /// used to transform value/string to eth string
- /// TODO: use BigNumber.js to parse int
- toEth: function(str) {
- var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
- var unit = 0;
- var units = ETH_UNITS;
- while (val > 3000 && unit < units.length - 1)
- {
- val /= 1000;
- unit++;
- }
- var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2);
- var replaceFunction = function($0, $1, $2) {
- return $1 + ',' + $2;
- };
-
- while (true) {
- var o = s;
- s = s.replace(/(\d)(\d\d\d[\.\,])/, replaceFunction);
- if (o === s)
- break;
- }
- return s + ' ' + units[unit];
- },
-
- /// eth object prototype
- eth: {
- contractFromAbi: function (abi) {
- return function(addr) {
- // Default to address of Config. TODO: rremove prior to genesis.
- addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
- var ret = web3.eth.contract(addr, abi);
- ret.address = addr;
- return ret;
- };
- },
- watch: function (params) {
- return new web3.filter(params, ethWatch);
- }
- },
-
- /// db object prototype
- db: {},
-
- /// shh object prototype
- shh: {
- watch: function (params) {
- return new web3.filter(params, shhWatch);
- }
- },
-
- /// @returns true if provider is installed
- haveProvider: function() {
- return !!web3.provider.provider;
- }
-};
-
-/// setups all api methods
-setupMethods(web3, web3Methods());
-setupMethods(web3.eth, ethMethods());
-setupProperties(web3.eth, ethProperties());
-setupMethods(web3.db, dbMethods());
-setupMethods(web3.shh, shhMethods());
-
-var ethWatch = {
- changed: 'eth_changed'
-};
-
-setupMethods(ethWatch, ethWatchMethods());
-
-var shhWatch = {
- changed: 'shh_changed'
-};
-
-setupMethods(shhWatch, shhWatchMethods());
-
-web3.setProvider = function(provider) {
- //provider.onmessage = messageHandler; // there will be no async calls, to remove
- web3.provider.set(provider);
-};
-
-module.exports = web3;
-
diff --git a/cmd/mist/assets/ext/package.json b/cmd/mist/assets/ext/package.json
deleted file mode 100644
index 7fc20a667..000000000
--- a/cmd/mist/assets/ext/package.json
+++ /dev/null
@@ -1,69 +0,0 @@
-{
- "name": "ethereum.js",
- "namespace": "ethereum",
- "version": "0.0.10",
- "description": "Ethereum Compatible JavaScript API",
- "main": "./index.js",
- "directories": {
- "lib": "./lib"
- },
- "dependencies": {
- "ws": "*",
- "xmlhttprequest": "*",
- "bignumber.js": ">=2.0.0"
- },
- "devDependencies": {
- "bower": ">=1.3.0",
- "browserify": ">=6.0",
- "del": ">=0.1.1",
- "envify": "^3.0.0",
- "exorcist": "^0.1.6",
- "gulp": ">=3.4.0",
- "gulp-jshint": ">=1.5.0",
- "gulp-rename": ">=1.2.0",
- "gulp-uglify": ">=1.0.0",
- "jshint": ">=2.5.0",
- "uglifyify": "^2.6.0",
- "unreachable-branch-transform": "^0.1.0",
- "vinyl-source-stream": "^1.0.0",
- "mocha": ">=2.1.0"
- },
- "scripts": {
- "build": "gulp",
- "watch": "gulp watch",
- "lint": "gulp lint",
- "test": "mocha"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/ethereum/ethereum.js.git"
- },
- "homepage": "https://github.com/ethereum/ethereum.js",
- "bugs": {
- "url": "https://github.com/ethereum/ethereum.js/issues"
- },
- "keywords": [
- "ethereum",
- "javascript",
- "API"
- ],
- "author": "ethdev.com",
- "authors": [
- {
- "name": "Jeffery Wilcke",
- "email": "jeff@ethdev.com",
- "url": "https://github.com/obscuren"
- },
- {
- "name": "Marek Kotewicz",
- "email": "marek@ethdev.com",
- "url": "https://github.com/debris"
- },
- {
- "name": "Marian Oancea",
- "email": "marian@ethdev.com",
- "url": "https://github.com/cubedro"
- }
- ],
- "license": "LGPL-3.0"
-}
diff --git a/cmd/mist/assets/ext/q.js b/cmd/mist/assets/ext/q.js
deleted file mode 100644
index 23c4245ee..000000000
--- a/cmd/mist/assets/ext/q.js
+++ /dev/null
@@ -1,1909 +0,0 @@
-// vim:ts=4:sts=4:sw=4:
-/*!
- *
- * Copyright 2009-2012 Kris Kowal under the terms of the MIT
- * license found at http://github.com/kriskowal/q/raw/master/LICENSE
- *
- * With parts by Tyler Close
- * Copyright 2007-2009 Tyler Close under the terms of the MIT X license found
- * at http://www.opensource.org/licenses/mit-license.html
- * Forked at ref_send.js version: 2009-05-11
- *
- * With parts by Mark Miller
- * Copyright (C) 2011 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-(function (definition) {
- // Turn off strict mode for this function so we can assign to global.Q
- /* jshint strict: false */
-
- // This file will function properly as a <script> tag, or a module
- // using CommonJS and NodeJS or RequireJS module formats. In
- // Common/Node/RequireJS, the module exports the Q API and when
- // executed as a simple <script>, it creates a Q global instead.
-
- // Montage Require
- if (typeof bootstrap === "function") {
- bootstrap("promise", definition);
-
- // CommonJS
- } else if (typeof exports === "object" && typeof module === "object") {
- module.exports = definition();
-
- // RequireJS
- } else if (typeof define === "function" && define.amd) {
- define(definition);
-
- // SES (Secure EcmaScript)
- } else if (typeof ses !== "undefined") {
- if (!ses.ok()) {
- return;
- } else {
- ses.makeQ = definition;
- }
-
- // <script>
- } else {
- Q = definition();
- }
-
-})(function () {
-"use strict";
-
-var hasStacks = false;
-try {
- throw new Error();
-} catch (e) {
- hasStacks = !!e.stack;
-}
-
-// All code after this point will be filtered from stack traces reported
-// by Q.
-var qStartingLine = captureLine();
-var qFileName;
-
-// shims
-
-// used for fallback in "allResolved"
-var noop = function () {};
-
-// Use the fastest possible means to execute a task in a future turn
-// of the event loop.
-var nextTick =(function () {
- // linked list of tasks (single, with head node)
- var head = {task: void 0, next: null};
- var tail = head;
- var flushing = false;
- var requestTick = void 0;
- var isNodeJS = false;
-
- function flush() {
- /* jshint loopfunc: true */
-
- while (head.next) {
- head = head.next;
- var task = head.task;
- head.task = void 0;
- var domain = head.domain;
-
- if (domain) {
- head.domain = void 0;
- domain.enter();
- }
-
- try {
- task();
-
- } catch (e) {
- if (isNodeJS) {
- // In node, uncaught exceptions are considered fatal errors.
- // Re-throw them synchronously to interrupt flushing!
-
- // Ensure continuation if the uncaught exception is suppressed
- // listening "uncaughtException" events (as domains does).
- // Continue in next event to avoid tick recursion.
- if (domain) {
- domain.exit();
- }
- setTimeout(flush, 0);
- if (domain) {
- domain.enter();
- }
-
- throw e;
-
- } else {
- // In browsers, uncaught exceptions are not fatal.
- // Re-throw them asynchronously to avoid slow-downs.
- setTimeout(function() {
- throw e;
- }, 0);
- }
- }
-
- if (domain) {
- domain.exit();
- }
- }
-
- flushing = false;
- }
-
- nextTick = function (task) {
- tail = tail.next = {
- task: task,
- domain: isNodeJS && process.domain,
- next: null
- };
-
- if (!flushing) {
- flushing = true;
- requestTick();
- }
- };
-
- if (typeof process !== "undefined" && process.nextTick) {
- // Node.js before 0.9. Note that some fake-Node environments, like the
- // Mocha test runner, introduce a `process` global without a `nextTick`.
- isNodeJS = true;
-
- requestTick = function () {
- process.nextTick(flush);
- };
-
- } else if (typeof setImmediate === "function") {
- // In IE10, Node.js 0.9+, or https://github.com/NobleJS/setImmediate
- if (typeof window !== "undefined") {
- requestTick = setImmediate.bind(window, flush);
- } else {
- requestTick = function () {
- setImmediate(flush);
- };
- }
-
- } else if (typeof MessageChannel !== "undefined") {
- // modern browsers
- // http://www.nonblocking.io/2011/06/windownexttick.html
- var channel = new MessageChannel();
- // At least Safari Version 6.0.5 (8536.30.1) intermittently cannot create
- // working message ports the first time a page loads.
- channel.port1.onmessage = function () {
- requestTick = requestPortTick;
- channel.port1.onmessage = flush;
- flush();
- };
- var requestPortTick = function () {
- // Opera requires us to provide a message payload, regardless of
- // whether we use it.
- channel.port2.postMessage(0);
- };
- requestTick = function () {
- setTimeout(flush, 0);
- requestPortTick();
- };
-
- } else {
- // old browsers
- requestTick = function () {
- setTimeout(flush, 0);
- };
- }
-
- return nextTick;
-})();
-
-// Attempt to make generics safe in the face of downstream
-// modifications.
-// There is no situation where this is necessary.
-// If you need a security guarantee, these primordials need to be
-// deeply frozen anyway, and if you don’t need a security guarantee,
-// this is just plain paranoid.
-// However, this **might** have the nice side-effect of reducing the size of
-// the minified code by reducing x.call() to merely x()
-// See Mark Miller’s explanation of what this does.
-// http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
-var call = Function.call;
-function uncurryThis(f) {
- return function () {
- return call.apply(f, arguments);
- };
-}
-// This is equivalent, but slower:
-// uncurryThis = Function_bind.bind(Function_bind.call);
-// http://jsperf.com/uncurrythis
-
-var array_slice = uncurryThis(Array.prototype.slice);
-
-var array_reduce = uncurryThis(
- Array.prototype.reduce || function (callback, basis) {
- var index = 0,
- length = this.length;
- // concerning the initial value, if one is not provided
- if (arguments.length === 1) {
- // seek to the first value in the array, accounting
- // for the possibility that is is a sparse array
- do {
- if (index in this) {
- basis = this[index++];
- break;
- }
- if (++index >= length) {
- throw new TypeError();
- }
- } while (1);
- }
- // reduce
- for (; index < length; index++) {
- // account for the possibility that the array is sparse
- if (index in this) {
- basis = callback(basis, this[index], index);
- }
- }
- return basis;
- }
-);
-
-var array_indexOf = uncurryThis(
- Array.prototype.indexOf || function (value) {
- // not a very good shim, but good enough for our one use of it
- for (var i = 0; i < this.length; i++) {
- if (this[i] === value) {
- return i;
- }
- }
- return -1;
- }
-);
-
-var array_map = uncurryThis(
- Array.prototype.map || function (callback, thisp) {
- var self = this;
- var collect = [];
- array_reduce(self, function (undefined, value, index) {
- collect.push(callback.call(thisp, value, index, self));
- }, void 0);
- return collect;
- }
-);
-
-var object_create = Object.create || function (prototype) {
- function Type() { }
- Type.prototype = prototype;
- return new Type();
-};
-
-var object_hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);
-
-var object_keys = Object.keys || function (object) {
- var keys = [];
- for (var key in object) {
- if (object_hasOwnProperty(object, key)) {
- keys.push(key);
- }
- }
- return keys;
-};
-
-var object_toString = uncurryThis(Object.prototype.toString);
-
-function isObject(value) {
- return value === Object(value);
-}
-
-// generator related shims
-
-// FIXME: Remove this function once ES6 generators are in SpiderMonkey.
-function isStopIteration(exception) {
- return (
- object_toString(exception) === "[object StopIteration]" ||
- exception instanceof QReturnValue
- );
-}
-
-// FIXME: Remove this helper and Q.return once ES6 generators are in
-// SpiderMonkey.
-var QReturnValue;
-if (typeof ReturnValue !== "undefined") {
- QReturnValue = ReturnValue;
-} else {
- QReturnValue = function (value) {
- this.value = value;
- };
-}
-
-// long stack traces
-
-var STACK_JUMP_SEPARATOR = "From previous event:";
-
-function makeStackTraceLong(error, promise) {
- // If possible, transform the error stack trace by removing Node and Q
- // cruft, then concatenating with the stack trace of `promise`. See #57.
- if (hasStacks &&
- promise.stack &&
- typeof error === "object" &&
- error !== null &&
- error.stack &&
- error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1
- ) {
- var stacks = [];
- for (var p = promise; !!p; p = p.source) {
- if (p.stack) {
- stacks.unshift(p.stack);
- }
- }
- stacks.unshift(error.stack);
-
- var concatedStacks = stacks.join("\n" + STACK_JUMP_SEPARATOR + "\n");
- error.stack = filterStackString(concatedStacks);
- }
-}
-
-function filterStackString(stackString) {
- var lines = stackString.split("\n");
- var desiredLines = [];
- for (var i = 0; i < lines.length; ++i) {
- var line = lines[i];
-
- if (!isInternalFrame(line) && !isNodeFrame(line) && line) {
- desiredLines.push(line);
- }
- }
- return desiredLines.join("\n");
-}
-
-function isNodeFrame(stackLine) {
- return stackLine.indexOf("(module.js:") !== -1 ||
- stackLine.indexOf("(node.js:") !== -1;
-}
-
-function getFileNameAndLineNumber(stackLine) {
- // Named functions: "at functionName (filename:lineNumber:columnNumber)"
- // In IE10 function name can have spaces ("Anonymous function") O_o
- var attempt1 = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine);
- if (attempt1) {
- return [attempt1[1], Number(attempt1[2])];
- }
-
- // Anonymous functions: "at filename:lineNumber:columnNumber"
- var attempt2 = /at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine);
- if (attempt2) {
- return [attempt2[1], Number(attempt2[2])];
- }
-
- // Firefox style: "function@filename:lineNumber or @filename:lineNumber"
- var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine);
- if (attempt3) {
- return [attempt3[1], Number(attempt3[2])];
- }
-}
-
-function isInternalFrame(stackLine) {
- var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);
-
- if (!fileNameAndLineNumber) {
- return false;
- }
-
- var fileName = fileNameAndLineNumber[0];
- var lineNumber = fileNameAndLineNumber[1];
-
- return fileName === qFileName &&
- lineNumber >= qStartingLine &&
- lineNumber <= qEndingLine;
-}
-
-// discover own file name and line number range for filtering stack
-// traces
-function captureLine() {
- if (!hasStacks) {
- return;
- }
-
- try {
- throw new Error();
- } catch (e) {
- var lines = e.stack.split("\n");
- var firstLine = lines[0].indexOf("@") > 0 ? lines[1] : lines[2];
- var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);
- if (!fileNameAndLineNumber) {
- return;
- }
-
- qFileName = fileNameAndLineNumber[0];
- return fileNameAndLineNumber[1];
- }
-}
-
-function deprecate(callback, name, alternative) {
- return function () {
- if (typeof console !== "undefined" &&
- typeof console.warn === "function") {
- console.warn(name + " is deprecated, use " + alternative +
- " instead.", new Error("").stack);
- }
- return callback.apply(callback, arguments);
- };
-}
-
-// end of shims
-// beginning of real work
-
-/**
- * Constructs a promise for an immediate reference, passes promises through, or
- * coerces promises from different systems.
- * @param value immediate reference or promise
- */
-function Q(value) {
- // If the object is already a Promise, return it directly. This enables
- // the resolve function to both be used to created references from objects,
- // but to tolerably coerce non-promises to promises.
- if (value instanceof Promise) {
- return value;
- }
-
- // assimilate thenables
- if (isPromiseAlike(value)) {
- return coerce(value);
- } else {
- return fulfill(value);
- }
-}
-Q.resolve = Q;
-
-/**
- * Performs a task in a future turn of the event loop.
- * @param {Function} task
- */
-Q.nextTick = nextTick;
-
-/**
- * Controls whether or not long stack traces will be on
- */
-Q.longStackSupport = false;
-
-/**
- * Constructs a {promise, resolve, reject} object.
- *
- * `resolve` is a callback to invoke with a more resolved value for the
- * promise. To fulfill the promise, invoke `resolve` with any value that is
- * not a thenable. To reject the promise, invoke `resolve` with a rejected
- * thenable, or invoke `reject` with the reason directly. To resolve the
- * promise to another thenable, thus putting it in the same state, invoke
- * `resolve` with that other thenable.
- */
-Q.defer = defer;
-function defer() {
- // if "messages" is an "Array", that indicates that the promise has not yet
- // been resolved. If it is "undefined", it has been resolved. Each
- // element of the messages array is itself an array of complete arguments to
- // forward to the resolved promise. We coerce the resolution value to a
- // promise using the `resolve` function because it handles both fully
- // non-thenable values and other thenables gracefully.
- var messages = [], progressListeners = [], resolvedPromise;
-
- var deferred = object_create(defer.prototype);
- var promise = object_create(Promise.prototype);
-
- promise.promiseDispatch = function (resolve, op, operands) {
- var args = array_slice(arguments);
- if (messages) {
- messages.push(args);
- if (op === "when" && operands[1]) { // progress operand
- progressListeners.push(operands[1]);
- }
- } else {
- nextTick(function () {
- resolvedPromise.promiseDispatch.apply(resolvedPromise, args);
- });
- }
- };
-
- // XXX deprecated
- promise.valueOf = function () {
- if (messages) {
- return promise;
- }
- var nearerValue = nearer(resolvedPromise);
- if (isPromise(nearerValue)) {
- resolvedPromise = nearerValue; // shorten chain
- }
- return nearerValue;
- };
-
- promise.inspect = function () {
- if (!resolvedPromise) {
- return { state: "pending" };
- }
- return resolvedPromise.inspect();
- };
-
- if (Q.longStackSupport && hasStacks) {
- try {
- throw new Error();
- } catch (e) {
- // NOTE: don't try to use `Error.captureStackTrace` or transfer the
- // accessor around; that causes memory leaks as per GH-111. Just
- // reify the stack trace as a string ASAP.
- //
- // At the same time, cut off the first line; it's always just
- // "[object Promise]\n", as per the `toString`.
- promise.stack = e.stack.substring(e.stack.indexOf("\n") + 1);
- }
- }
-
- // NOTE: we do the checks for `resolvedPromise` in each method, instead of
- // consolidating them into `become`, since otherwise we'd create new
- // promises with the lines `become(whatever(value))`. See e.g. GH-252.
-
- function become(newPromise) {
- resolvedPromise = newPromise;
- promise.source = newPromise;
-
- array_reduce(messages, function (undefined, message) {
- nextTick(function () {
- newPromise.promiseDispatch.apply(newPromise, message);
- });
- }, void 0);
-
- messages = void 0;
- progressListeners = void 0;
- }
-
- deferred.promise = promise;
- deferred.resolve = function (value) {
- if (resolvedPromise) {
- return;
- }
-
- become(Q(value));
- };
-
- deferred.fulfill = function (value) {
- if (resolvedPromise) {
- return;
- }
-
- become(fulfill(value));
- };
- deferred.reject = function (reason) {
- if (resolvedPromise) {
- return;
- }
-
- become(reject(reason));
- };
- deferred.notify = function (progress) {
- if (resolvedPromise) {
- return;
- }
-
- array_reduce(progressListeners, function (undefined, progressListener) {
- nextTick(function () {
- progressListener(progress);
- });
- }, void 0);
- };
-
- return deferred;
-}
-
-/**
- * Creates a Node-style callback that will resolve or reject the deferred
- * promise.
- * @returns a nodeback
- */
-defer.prototype.makeNodeResolver = function () {
- var self = this;
- return function (error, value) {
- if (error) {
- self.reject(error);
- } else if (arguments.length > 2) {
- self.resolve(array_slice(arguments, 1));
- } else {
- self.resolve(value);
- }
- };
-};
-
-/**
- * @param resolver {Function} a function that returns nothing and accepts
- * the resolve, reject, and notify functions for a deferred.
- * @returns a promise that may be resolved with the given resolve and reject
- * functions, or rejected by a thrown exception in resolver
- */
-Q.Promise = promise; // ES6
-Q.promise = promise;
-function promise(resolver) {
- if (typeof resolver !== "function") {
- throw new TypeError("resolver must be a function.");
- }
- var deferred = defer();
- try {
- resolver(deferred.resolve, deferred.reject, deferred.notify);
- } catch (reason) {
- deferred.reject(reason);
- }
- return deferred.promise;
-}
-
-promise.race = race; // ES6
-promise.all = all; // ES6
-promise.reject = reject; // ES6
-promise.resolve = Q; // ES6
-
-// XXX experimental. This method is a way to denote that a local value is
-// serializable and should be immediately dispatched to a remote upon request,
-// instead of passing a reference.
-Q.passByCopy = function (object) {
- //freeze(object);
- //passByCopies.set(object, true);
- return object;
-};
-
-Promise.prototype.passByCopy = function () {
- //freeze(object);
- //passByCopies.set(object, true);
- return this;
-};
-
-/**
- * If two promises eventually fulfill to the same value, promises that value,
- * but otherwise rejects.
- * @param x {Any*}
- * @param y {Any*}
- * @returns {Any*} a promise for x and y if they are the same, but a rejection
- * otherwise.
- *
- */
-Q.join = function (x, y) {
- return Q(x).join(y);
-};
-
-Promise.prototype.join = function (that) {
- return Q([this, that]).spread(function (x, y) {
- if (x === y) {
- // TODO: "===" should be Object.is or equiv
- return x;
- } else {
- throw new Error("Can't join: not the same: " + x + " " + y);
- }
- });
-};
-
-/**
- * Returns a promise for the first of an array of promises to become fulfilled.
- * @param answers {Array[Any*]} promises to race
- * @returns {Any*} the first promise to be fulfilled
- */
-Q.race = race;
-function race(answerPs) {
- return promise(function(resolve, reject) {
- // Switch to this once we can assume at least ES5
- // answerPs.forEach(function(answerP) {
- // Q(answerP).then(resolve, reject);
- // });
- // Use this in the meantime
- for (var i = 0, len = answerPs.length; i < len; i++) {
- Q(answerPs[i]).then(resolve, reject);
- }
- });
-}
-
-Promise.prototype.race = function () {
- return this.then(Q.race);
-};
-
-/**
- * Constructs a Promise with a promise descriptor object and optional fallback
- * function. The descriptor contains methods like when(rejected), get(name),
- * set(name, value), post(name, args), and delete(name), which all
- * return either a value, a promise for a value, or a rejection. The fallback
- * accepts the operation name, a resolver, and any further arguments that would
- * have been forwarded to the appropriate method above had a method been
- * provided with the proper name. The API makes no guarantees about the nature
- * of the returned object, apart from that it is usable whereever promises are
- * bought and sold.
- */
-Q.makePromise = Promise;
-function Promise(descriptor, fallback, inspect) {
- if (fallback === void 0) {
- fallback = function (op) {
- return reject(new Error(
- "Promise does not support operation: " + op
- ));
- };
- }
- if (inspect === void 0) {
- inspect = function () {
- return {state: "unknown"};
- };
- }
-
- var promise = object_create(Promise.prototype);
-
- promise.promiseDispatch = function (resolve, op, args) {
- var result;
- try {
- if (descriptor[op]) {
- result = descriptor[op].apply(promise, args);
- } else {
- result = fallback.call(promise, op, args);
- }
- } catch (exception) {
- result = reject(exception);
- }
- if (resolve) {
- resolve(result);
- }
- };
-
- promise.inspect = inspect;
-
- // XXX deprecated `valueOf` and `exception` support
- if (inspect) {
- var inspected = inspect();
- if (inspected.state === "rejected") {
- promise.exception = inspected.reason;
- }
-
- promise.valueOf = function () {
- var inspected = inspect();
- if (inspected.state === "pending" ||
- inspected.state === "rejected") {
- return promise;
- }
- return inspected.value;
- };
- }
-
- return promise;
-}
-
-Promise.prototype.toString = function () {
- return "[object Promise]";
-};
-
-Promise.prototype.then = function (fulfilled, rejected, progressed) {
- var self = this;
- var deferred = defer();
- var done = false; // ensure the untrusted promise makes at most a
- // single call to one of the callbacks
-
- function _fulfilled(value) {
- try {
- return typeof fulfilled === "function" ? fulfilled(value) : value;
- } catch (exception) {
- return reject(exception);
- }
- }
-
- function _rejected(exception) {
- if (typeof rejected === "function") {
- makeStackTraceLong(exception, self);
- try {
- return rejected(exception);
- } catch (newException) {
- return reject(newException);
- }
- }
- return reject(exception);
- }
-
- function _progressed(value) {
- return typeof progressed === "function" ? progressed(value) : value;
- }
-
- nextTick(function () {
- self.promiseDispatch(function (value) {
- if (done) {
- return;
- }
- done = true;
-
- deferred.resolve(_fulfilled(value));
- }, "when", [function (exception) {
- if (done) {
- return;
- }
- done = true;
-
- deferred.resolve(_rejected(exception));
- }]);
- });
-
- // Progress propagator need to be attached in the current tick.
- self.promiseDispatch(void 0, "when", [void 0, function (value) {
- var newValue;
- var threw = false;
- try {
- newValue = _progressed(value);
- } catch (e) {
- threw = true;
- if (Q.onerror) {
- Q.onerror(e);
- } else {
- throw e;
- }
- }
-
- if (!threw) {
- deferred.notify(newValue);
- }
- }]);
-
- return deferred.promise;
-};
-
-/**
- * Registers an observer on a promise.
- *
- * Guarantees:
- *
- * 1. that fulfilled and rejected will be called only once.
- * 2. that either the fulfilled callback or the rejected callback will be
- * called, but not both.
- * 3. that fulfilled and rejected will not be called in this turn.
- *
- * @param value promise or immediate reference to observe
- * @param fulfilled function to be called with the fulfilled value
- * @param rejected function to be called with the rejection exception
- * @param progressed function to be called on any progress notifications
- * @return promise for the return value from the invoked callback
- */
-Q.when = when;
-function when(value, fulfilled, rejected, progressed) {
- return Q(value).then(fulfilled, rejected, progressed);
-}
-
-Promise.prototype.thenResolve = function (value) {
- return this.then(function () { return value; });
-};
-
-Q.thenResolve = function (promise, value) {
- return Q(promise).thenResolve(value);
-};
-
-Promise.prototype.thenReject = function (reason) {
- return this.then(function () { throw reason; });
-};
-
-Q.thenReject = function (promise, reason) {
- return Q(promise).thenReject(reason);
-};
-
-/**
- * If an object is not a promise, it is as "near" as possible.
- * If a promise is rejected, it is as "near" as possible too.
- * If it’s a fulfilled promise, the fulfillment value is nearer.
- * If it’s a deferred promise and the deferred has been resolved, the
- * resolution is "nearer".
- * @param object
- * @returns most resolved (nearest) form of the object
- */
-
-// XXX should we re-do this?
-Q.nearer = nearer;
-function nearer(value) {
- if (isPromise(value)) {
- var inspected = value.inspect();
- if (inspected.state === "fulfilled") {
- return inspected.value;
- }
- }
- return value;
-}
-
-/**
- * @returns whether the given object is a promise.
- * Otherwise it is a fulfilled value.
- */
-Q.isPromise = isPromise;
-function isPromise(object) {
- return isObject(object) &&
- typeof object.promiseDispatch === "function" &&
- typeof object.inspect === "function";
-}
-
-Q.isPromiseAlike = isPromiseAlike;
-function isPromiseAlike(object) {
- return isObject(object) && typeof object.then === "function";
-}
-
-/**
- * @returns whether the given object is a pending promise, meaning not
- * fulfilled or rejected.
- */
-Q.isPending = isPending;
-function isPending(object) {
- return isPromise(object) && object.inspect().state === "pending";
-}
-
-Promise.prototype.isPending = function () {
- return this.inspect().state === "pending";
-};
-
-/**
- * @returns whether the given object is a value or fulfilled
- * promise.
- */
-Q.isFulfilled = isFulfilled;
-function isFulfilled(object) {
- return !isPromise(object) || object.inspect().state === "fulfilled";
-}
-
-Promise.prototype.isFulfilled = function () {
- return this.inspect().state === "fulfilled";
-};
-
-/**
- * @returns whether the given object is a rejected promise.
- */
-Q.isRejected = isRejected;
-function isRejected(object) {
- return isPromise(object) && object.inspect().state === "rejected";
-}
-
-Promise.prototype.isRejected = function () {
- return this.inspect().state === "rejected";
-};
-
-//// BEGIN UNHANDLED REJECTION TRACKING
-
-// This promise library consumes exceptions thrown in handlers so they can be
-// handled by a subsequent promise. The exceptions get added to this array when
-// they are created, and removed when they are handled. Note that in ES6 or
-// shimmed environments, this would naturally be a `Set`.
-var unhandledReasons = [];
-var unhandledRejections = [];
-var trackUnhandledRejections = true;
-
-function resetUnhandledRejections() {
- unhandledReasons.length = 0;
- unhandledRejections.length = 0;
-
- if (!trackUnhandledRejections) {
- trackUnhandledRejections = true;
- }
-}
-
-function trackRejection(promise, reason) {
- if (!trackUnhandledRejections) {
- return;
- }
-
- unhandledRejections.push(promise);
- if (reason && typeof reason.stack !== "undefined") {
- unhandledReasons.push(reason.stack);
- } else {
- unhandledReasons.push("(no stack) " + reason);
- }
-}
-
-function untrackRejection(promise) {
- if (!trackUnhandledRejections) {
- return;
- }
-
- var at = array_indexOf(unhandledRejections, promise);
- if (at !== -1) {
- unhandledRejections.splice(at, 1);
- unhandledReasons.splice(at, 1);
- }
-}
-
-Q.resetUnhandledRejections = resetUnhandledRejections;
-
-Q.getUnhandledReasons = function () {
- // Make a copy so that consumers can't interfere with our internal state.
- return unhandledReasons.slice();
-};
-
-Q.stopUnhandledRejectionTracking = function () {
- resetUnhandledRejections();
- trackUnhandledRejections = false;
-};
-
-resetUnhandledRejections();
-
-//// END UNHANDLED REJECTION TRACKING
-
-/**
- * Constructs a rejected promise.
- * @param reason value describing the failure
- */
-Q.reject = reject;
-function reject(reason) {
- var rejection = Promise({
- "when": function (rejected) {
- // note that the error has been handled
- if (rejected) {
- untrackRejection(this);
- }
- return rejected ? rejected(reason) : this;
- }
- }, function fallback() {
- return this;
- }, function inspect() {
- return { state: "rejected", reason: reason };
- });
-
- // Note that the reason has not been handled.
- trackRejection(rejection, reason);
-
- return rejection;
-}
-
-/**
- * Constructs a fulfilled promise for an immediate reference.
- * @param value immediate reference
- */
-Q.fulfill = fulfill;
-function fulfill(value) {
- return Promise({
- "when": function () {
- return value;
- },
- "get": function (name) {
- return value[name];
- },
- "set": function (name, rhs) {
- value[name] = rhs;
- },
- "delete": function (name) {
- delete value[name];
- },
- "post": function (name, args) {
- // Mark Miller proposes that post with no name should apply a
- // promised function.
- if (name === null || name === void 0) {
- return value.apply(void 0, args);
- } else {
- return value[name].apply(value, args);
- }
- },
- "apply": function (thisp, args) {
- return value.apply(thisp, args);
- },
- "keys": function () {
- return object_keys(value);
- }
- }, void 0, function inspect() {
- return { state: "fulfilled", value: value };
- });
-}
-
-/**
- * Converts thenables to Q promises.
- * @param promise thenable promise
- * @returns a Q promise
- */
-function coerce(promise) {
- var deferred = defer();
- nextTick(function () {
- try {
- promise.then(deferred.resolve, deferred.reject, deferred.notify);
- } catch (exception) {
- deferred.reject(exception);
- }
- });
- return deferred.promise;
-}
-
-/**
- * Annotates an object such that it will never be
- * transferred away from this process over any promise
- * communication channel.
- * @param object
- * @returns promise a wrapping of that object that
- * additionally responds to the "isDef" message
- * without a rejection.
- */
-Q.master = master;
-function master(object) {
- return Promise({
- "isDef": function () {}
- }, function fallback(op, args) {
- return dispatch(object, op, args);
- }, function () {
- return Q(object).inspect();
- });
-}
-
-/**
- * Spreads the values of a promised array of arguments into the
- * fulfillment callback.
- * @param fulfilled callback that receives variadic arguments from the
- * promised array
- * @param rejected callback that receives the exception if the promise
- * is rejected.
- * @returns a promise for the return value or thrown exception of
- * either callback.
- */
-Q.spread = spread;
-function spread(value, fulfilled, rejected) {
- return Q(value).spread(fulfilled, rejected);
-}
-
-Promise.prototype.spread = function (fulfilled, rejected) {
- return this.all().then(function (array) {
- return fulfilled.apply(void 0, array);
- }, rejected);
-};
-
-/**
- * The async function is a decorator for generator functions, turning
- * them into asynchronous generators. Although generators are only part
- * of the newest ECMAScript 6 drafts, this code does not cause syntax
- * errors in older engines. This code should continue to work and will
- * in fact improve over time as the language improves.
- *
- * ES6 generators are currently part of V8 version 3.19 with the
- * --harmony-generators runtime flag enabled. SpiderMonkey has had them
- * for longer, but under an older Python-inspired form. This function
- * works on both kinds of generators.
- *
- * Decorates a generator function such that:
- * - it may yield promises
- * - execution will continue when that promise is fulfilled
- * - the value of the yield expression will be the fulfilled value
- * - it returns a promise for the return value (when the generator
- * stops iterating)
- * - the decorated function returns a promise for the return value
- * of the generator or the first rejected promise among those
- * yielded.
- * - if an error is thrown in the generator, it propagates through
- * every following yield until it is caught, or until it escapes
- * the generator function altogether, and is translated into a
- * rejection for the promise returned by the decorated generator.
- */
-Q.async = async;
-function async(makeGenerator) {
- return function () {
- // when verb is "send", arg is a value
- // when verb is "throw", arg is an exception
- function continuer(verb, arg) {
- var result;
-
- // Until V8 3.19 / Chromium 29 is released, SpiderMonkey is the only
- // engine that has a deployed base of browsers that support generators.
- // However, SM's generators use the Python-inspired semantics of
- // outdated ES6 drafts. We would like to support ES6, but we'd also
- // like to make it possible to use generators in deployed browsers, so
- // we also support Python-style generators. At some point we can remove
- // this block.
-
- if (typeof StopIteration === "undefined") {
- // ES6 Generators
- try {
- result = generator[verb](arg);
- } catch (exception) {
- return reject(exception);
- }
- if (result.done) {
- return Q(result.value);
- } else {
- return when(result.value, callback, errback);
- }
- } else {
- // SpiderMonkey Generators
- // FIXME: Remove this case when SM does ES6 generators.
- try {
- result = generator[verb](arg);
- } catch (exception) {
- if (isStopIteration(exception)) {
- return Q(exception.value);
- } else {
- return reject(exception);
- }
- }
- return when(result, callback, errback);
- }
- }
- var generator = makeGenerator.apply(this, arguments);
- var callback = continuer.bind(continuer, "next");
- var errback = continuer.bind(continuer, "throw");
- return callback();
- };
-}
-
-/**
- * The spawn function is a small wrapper around async that immediately
- * calls the generator and also ends the promise chain, so that any
- * unhandled errors are thrown instead of forwarded to the error
- * handler. This is useful because it's extremely common to run
- * generators at the top-level to work with libraries.
- */
-Q.spawn = spawn;
-function spawn(makeGenerator) {
- Q.done(Q.async(makeGenerator)());
-}
-
-// FIXME: Remove this interface once ES6 generators are in SpiderMonkey.
-/**
- * Throws a ReturnValue exception to stop an asynchronous generator.
- *
- * This interface is a stop-gap measure to support generator return
- * values in older Firefox/SpiderMonkey. In browsers that support ES6
- * generators like Chromium 29, just use "return" in your generator
- * functions.
- *
- * @param value the return value for the surrounding generator
- * @throws ReturnValue exception with the value.
- * @example
- * // ES6 style
- * Q.async(function* () {
- * var foo = yield getFooPromise();
- * var bar = yield getBarPromise();
- * return foo + bar;
- * })
- * // Older SpiderMonkey style
- * Q.async(function () {
- * var foo = yield getFooPromise();
- * var bar = yield getBarPromise();
- * Q.return(foo + bar);
- * })
- */
-Q["return"] = _return;
-function _return(value) {
- throw new QReturnValue(value);
-}
-
-/**
- * The promised function decorator ensures that any promise arguments
- * are settled and passed as values (`this` is also settled and passed
- * as a value). It will also ensure that the result of a function is
- * always a promise.
- *
- * @example
- * var add = Q.promised(function (a, b) {
- * return a + b;
- * });
- * add(Q(a), Q(B));
- *
- * @param {function} callback The function to decorate
- * @returns {function} a function that has been decorated.
- */
-Q.promised = promised;
-function promised(callback) {
- return function () {
- return spread([this, all(arguments)], function (self, args) {
- return callback.apply(self, args);
- });
- };
-}
-
-/**
- * sends a message to a value in a future turn
- * @param object* the recipient
- * @param op the name of the message operation, e.g., "when",
- * @param args further arguments to be forwarded to the operation
- * @returns result {Promise} a promise for the result of the operation
- */
-Q.dispatch = dispatch;
-function dispatch(object, op, args) {
- return Q(object).dispatch(op, args);
-}
-
-Promise.prototype.dispatch = function (op, args) {
- var self = this;
- var deferred = defer();
- nextTick(function () {
- self.promiseDispatch(deferred.resolve, op, args);
- });
- return deferred.promise;
-};
-
-/**
- * Gets the value of a property in a future turn.
- * @param object promise or immediate reference for target object
- * @param name name of property to get
- * @return promise for the property value
- */
-Q.get = function (object, key) {
- return Q(object).dispatch("get", [key]);
-};
-
-Promise.prototype.get = function (key) {
- return this.dispatch("get", [key]);
-};
-
-/**
- * Sets the value of a property in a future turn.
- * @param object promise or immediate reference for object object
- * @param name name of property to set
- * @param value new value of property
- * @return promise for the return value
- */
-Q.set = function (object, key, value) {
- return Q(object).dispatch("set", [key, value]);
-};
-
-Promise.prototype.set = function (key, value) {
- return this.dispatch("set", [key, value]);
-};
-
-/**
- * Deletes a property in a future turn.
- * @param object promise or immediate reference for target object
- * @param name name of property to delete
- * @return promise for the return value
- */
-Q.del = // XXX legacy
-Q["delete"] = function (object, key) {
- return Q(object).dispatch("delete", [key]);
-};
-
-Promise.prototype.del = // XXX legacy
-Promise.prototype["delete"] = function (key) {
- return this.dispatch("delete", [key]);
-};
-
-/**
- * Invokes a method in a future turn.
- * @param object promise or immediate reference for target object
- * @param name name of method to invoke
- * @param value a value to post, typically an array of
- * invocation arguments for promises that
- * are ultimately backed with `resolve` values,
- * as opposed to those backed with URLs
- * wherein the posted value can be any
- * JSON serializable object.
- * @return promise for the return value
- */
-// bound locally because it is used by other methods
-Q.mapply = // XXX As proposed by "Redsandro"
-Q.post = function (object, name, args) {
- return Q(object).dispatch("post", [name, args]);
-};
-
-Promise.prototype.mapply = // XXX As proposed by "Redsandro"
-Promise.prototype.post = function (name, args) {
- return this.dispatch("post", [name, args]);
-};
-
-/**
- * Invokes a method in a future turn.
- * @param object promise or immediate reference for target object
- * @param name name of method to invoke
- * @param ...args array of invocation arguments
- * @return promise for the return value
- */
-Q.send = // XXX Mark Miller's proposed parlance
-Q.mcall = // XXX As proposed by "Redsandro"
-Q.invoke = function (object, name /*...args*/) {
- return Q(object).dispatch("post", [name, array_slice(arguments, 2)]);
-};
-
-Promise.prototype.send = // XXX Mark Miller's proposed parlance
-Promise.prototype.mcall = // XXX As proposed by "Redsandro"
-Promise.prototype.invoke = function (name /*...args*/) {
- return this.dispatch("post", [name, array_slice(arguments, 1)]);
-};
-
-/**
- * Applies the promised function in a future turn.
- * @param object promise or immediate reference for target function
- * @param args array of application arguments
- */
-Q.fapply = function (object, args) {
- return Q(object).dispatch("apply", [void 0, args]);
-};
-
-Promise.prototype.fapply = function (args) {
- return this.dispatch("apply", [void 0, args]);
-};
-
-/**
- * Calls the promised function in a future turn.
- * @param object promise or immediate reference for target function
- * @param ...args array of application arguments
- */
-Q["try"] =
-Q.fcall = function (object /* ...args*/) {
- return Q(object).dispatch("apply", [void 0, array_slice(arguments, 1)]);
-};
-
-Promise.prototype.fcall = function (/*...args*/) {
- return this.dispatch("apply", [void 0, array_slice(arguments)]);
-};
-
-/**
- * Binds the promised function, transforming return values into a fulfilled
- * promise and thrown errors into a rejected one.
- * @param object promise or immediate reference for target function
- * @param ...args array of application arguments
- */
-Q.fbind = function (object /*...args*/) {
- var promise = Q(object);
- var args = array_slice(arguments, 1);
- return function fbound() {
- return promise.dispatch("apply", [
- this,
- args.concat(array_slice(arguments))
- ]);
- };
-};
-Promise.prototype.fbind = function (/*...args*/) {
- var promise = this;
- var args = array_slice(arguments);
- return function fbound() {
- return promise.dispatch("apply", [
- this,
- args.concat(array_slice(arguments))
- ]);
- };
-};
-
-/**
- * Requests the names of the owned properties of a promised
- * object in a future turn.
- * @param object promise or immediate reference for target object
- * @return promise for the keys of the eventually settled object
- */
-Q.keys = function (object) {
- return Q(object).dispatch("keys", []);
-};
-
-Promise.prototype.keys = function () {
- return this.dispatch("keys", []);
-};
-
-/**
- * Turns an array of promises into a promise for an array. If any of
- * the promises gets rejected, the whole array is rejected immediately.
- * @param {Array*} an array (or promise for an array) of values (or
- * promises for values)
- * @returns a promise for an array of the corresponding values
- */
-// By Mark Miller
-// http://wiki.ecmascript.org/doku.php?id=strawman:concurrency&rev=1308776521#allfulfilled
-Q.all = all;
-function all(promises) {
- return when(promises, function (promises) {
- var countDown = 0;
- var deferred = defer();
- array_reduce(promises, function (undefined, promise, index) {
- var snapshot;
- if (
- isPromise(promise) &&
- (snapshot = promise.inspect()).state === "fulfilled"
- ) {
- promises[index] = snapshot.value;
- } else {
- ++countDown;
- when(
- promise,
- function (value) {
- promises[index] = value;
- if (--countDown === 0) {
- deferred.resolve(promises);
- }
- },
- deferred.reject,
- function (progress) {
- deferred.notify({ index: index, value: progress });
- }
- );
- }
- }, void 0);
- if (countDown === 0) {
- deferred.resolve(promises);
- }
- return deferred.promise;
- });
-}
-
-Promise.prototype.all = function () {
- return all(this);
-};
-
-/**
- * Waits for all promises to be settled, either fulfilled or
- * rejected. This is distinct from `all` since that would stop
- * waiting at the first rejection. The promise returned by
- * `allResolved` will never be rejected.
- * @param promises a promise for an array (or an array) of promises
- * (or values)
- * @return a promise for an array of promises
- */
-Q.allResolved = deprecate(allResolved, "allResolved", "allSettled");
-function allResolved(promises) {
- return when(promises, function (promises) {
- promises = array_map(promises, Q);
- return when(all(array_map(promises, function (promise) {
- return when(promise, noop, noop);
- })), function () {
- return promises;
- });
- });
-}
-
-Promise.prototype.allResolved = function () {
- return allResolved(this);
-};
-
-/**
- * @see Promise#allSettled
- */
-Q.allSettled = allSettled;
-function allSettled(promises) {
- return Q(promises).allSettled();
-}
-
-/**
- * Turns an array of promises into a promise for an array of their states (as
- * returned by `inspect`) when they have all settled.
- * @param {Array[Any*]} values an array (or promise for an array) of values (or
- * promises for values)
- * @returns {Array[State]} an array of states for the respective values.
- */
-Promise.prototype.allSettled = function () {
- return this.then(function (promises) {
- return all(array_map(promises, function (promise) {
- promise = Q(promise);
- function regardless() {
- return promise.inspect();
- }
- return promise.then(regardless, regardless);
- }));
- });
-};
-
-/**
- * Captures the failure of a promise, giving an oportunity to recover
- * with a callback. If the given promise is fulfilled, the returned
- * promise is fulfilled.
- * @param {Any*} promise for something
- * @param {Function} callback to fulfill the returned promise if the
- * given promise is rejected
- * @returns a promise for the return value of the callback
- */
-Q.fail = // XXX legacy
-Q["catch"] = function (object, rejected) {
- return Q(object).then(void 0, rejected);
-};
-
-Promise.prototype.fail = // XXX legacy
-Promise.prototype["catch"] = function (rejected) {
- return this.then(void 0, rejected);
-};
-
-/**
- * Attaches a listener that can respond to progress notifications from a
- * promise's originating deferred. This listener receives the exact arguments
- * passed to ``deferred.notify``.
- * @param {Any*} promise for something
- * @param {Function} callback to receive any progress notifications
- * @returns the given promise, unchanged
- */
-Q.progress = progress;
-function progress(object, progressed) {
- return Q(object).then(void 0, void 0, progressed);
-}
-
-Promise.prototype.progress = function (progressed) {
- return this.then(void 0, void 0, progressed);
-};
-
-/**
- * Provides an opportunity to observe the settling of a promise,
- * regardless of whether the promise is fulfilled or rejected. Forwards
- * the resolution to the returned promise when the callback is done.
- * The callback can return a promise to defer completion.
- * @param {Any*} promise
- * @param {Function} callback to observe the resolution of the given
- * promise, takes no arguments.
- * @returns a promise for the resolution of the given promise when
- * ``fin`` is done.
- */
-Q.fin = // XXX legacy
-Q["finally"] = function (object, callback) {
- return Q(object)["finally"](callback);
-};
-
-Promise.prototype.fin = // XXX legacy
-Promise.prototype["finally"] = function (callback) {
- callback = Q(callback);
- return this.then(function (value) {
- return callback.fcall().then(function () {
- return value;
- });
- }, function (reason) {
- // TODO attempt to recycle the rejection with "this".
- return callback.fcall().then(function () {
- throw reason;
- });
- });
-};
-
-/**
- * Terminates a chain of promises, forcing rejections to be
- * thrown as exceptions.
- * @param {Any*} promise at the end of a chain of promises
- * @returns nothing
- */
-Q.done = function (object, fulfilled, rejected, progress) {
- return Q(object).done(fulfilled, rejected, progress);
-};
-
-Promise.prototype.done = function (fulfilled, rejected, progress) {
- var onUnhandledError = function (error) {
- // forward to a future turn so that ``when``
- // does not catch it and turn it into a rejection.
- nextTick(function () {
- makeStackTraceLong(error, promise);
- if (Q.onerror) {
- Q.onerror(error);
- } else {
- throw error;
- }
- });
- };
-
- // Avoid unnecessary `nextTick`ing via an unnecessary `when`.
- var promise = fulfilled || rejected || progress ?
- this.then(fulfilled, rejected, progress) :
- this;
-
- if (typeof process === "object" && process && process.domain) {
- onUnhandledError = process.domain.bind(onUnhandledError);
- }
-
- promise.then(void 0, onUnhandledError);
-};
-
-/**
- * Causes a promise to be rejected if it does not get fulfilled before
- * some milliseconds time out.
- * @param {Any*} promise
- * @param {Number} milliseconds timeout
- * @param {Any*} custom error message or Error object (optional)
- * @returns a promise for the resolution of the given promise if it is
- * fulfilled before the timeout, otherwise rejected.
- */
-Q.timeout = function (object, ms, error) {
- return Q(object).timeout(ms, error);
-};
-
-Promise.prototype.timeout = function (ms, error) {
- var deferred = defer();
- var timeoutId = setTimeout(function () {
- if (!error || "string" === typeof error) {
- error = new Error(error || "Timed out after " + ms + " ms");
- error.code = "ETIMEDOUT";
- }
- deferred.reject(error);
- }, ms);
-
- this.then(function (value) {
- clearTimeout(timeoutId);
- deferred.resolve(value);
- }, function (exception) {
- clearTimeout(timeoutId);
- deferred.reject(exception);
- }, deferred.notify);
-
- return deferred.promise;
-};
-
-/**
- * Returns a promise for the given value (or promised value), some
- * milliseconds after it resolved. Passes rejections immediately.
- * @param {Any*} promise
- * @param {Number} milliseconds
- * @returns a promise for the resolution of the given promise after milliseconds
- * time has elapsed since the resolution of the given promise.
- * If the given promise rejects, that is passed immediately.
- */
-Q.delay = function (object, timeout) {
- if (timeout === void 0) {
- timeout = object;
- object = void 0;
- }
- return Q(object).delay(timeout);
-};
-
-Promise.prototype.delay = function (timeout) {
- return this.then(function (value) {
- var deferred = defer();
- setTimeout(function () {
- deferred.resolve(value);
- }, timeout);
- return deferred.promise;
- });
-};
-
-/**
- * Passes a continuation to a Node function, which is called with the given
- * arguments provided as an array, and returns a promise.
- *
- * Q.nfapply(FS.readFile, [__filename])
- * .then(function (content) {
- * })
- *
- */
-Q.nfapply = function (callback, args) {
- return Q(callback).nfapply(args);
-};
-
-Promise.prototype.nfapply = function (args) {
- var deferred = defer();
- var nodeArgs = array_slice(args);
- nodeArgs.push(deferred.makeNodeResolver());
- this.fapply(nodeArgs).fail(deferred.reject);
- return deferred.promise;
-};
-
-/**
- * Passes a continuation to a Node function, which is called with the given
- * arguments provided individually, and returns a promise.
- * @example
- * Q.nfcall(FS.readFile, __filename)
- * .then(function (content) {
- * })
- *
- */
-Q.nfcall = function (callback /*...args*/) {
- var args = array_slice(arguments, 1);
- return Q(callback).nfapply(args);
-};
-
-Promise.prototype.nfcall = function (/*...args*/) {
- var nodeArgs = array_slice(arguments);
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- this.fapply(nodeArgs).fail(deferred.reject);
- return deferred.promise;
-};
-
-/**
- * Wraps a NodeJS continuation passing function and returns an equivalent
- * version that returns a promise.
- * @example
- * Q.nfbind(FS.readFile, __filename)("utf-8")
- * .then(console.log)
- * .done()
- */
-Q.nfbind =
-Q.denodeify = function (callback /*...args*/) {
- var baseArgs = array_slice(arguments, 1);
- return function () {
- var nodeArgs = baseArgs.concat(array_slice(arguments));
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- Q(callback).fapply(nodeArgs).fail(deferred.reject);
- return deferred.promise;
- };
-};
-
-Promise.prototype.nfbind =
-Promise.prototype.denodeify = function (/*...args*/) {
- var args = array_slice(arguments);
- args.unshift(this);
- return Q.denodeify.apply(void 0, args);
-};
-
-Q.nbind = function (callback, thisp /*...args*/) {
- var baseArgs = array_slice(arguments, 2);
- return function () {
- var nodeArgs = baseArgs.concat(array_slice(arguments));
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- function bound() {
- return callback.apply(thisp, arguments);
- }
- Q(bound).fapply(nodeArgs).fail(deferred.reject);
- return deferred.promise;
- };
-};
-
-Promise.prototype.nbind = function (/*thisp, ...args*/) {
- var args = array_slice(arguments, 0);
- args.unshift(this);
- return Q.nbind.apply(void 0, args);
-};
-
-/**
- * Calls a method of a Node-style object that accepts a Node-style
- * callback with a given array of arguments, plus a provided callback.
- * @param object an object that has the named method
- * @param {String} name name of the method of object
- * @param {Array} args arguments to pass to the method; the callback
- * will be provided by Q and appended to these arguments.
- * @returns a promise for the value or error
- */
-Q.nmapply = // XXX As proposed by "Redsandro"
-Q.npost = function (object, name, args) {
- return Q(object).npost(name, args);
-};
-
-Promise.prototype.nmapply = // XXX As proposed by "Redsandro"
-Promise.prototype.npost = function (name, args) {
- var nodeArgs = array_slice(args || []);
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- this.dispatch("post", [name, nodeArgs]).fail(deferred.reject);
- return deferred.promise;
-};
-
-/**
- * Calls a method of a Node-style object that accepts a Node-style
- * callback, forwarding the given variadic arguments, plus a provided
- * callback argument.
- * @param object an object that has the named method
- * @param {String} name name of the method of object
- * @param ...args arguments to pass to the method; the callback will
- * be provided by Q and appended to these arguments.
- * @returns a promise for the value or error
- */
-Q.nsend = // XXX Based on Mark Miller's proposed "send"
-Q.nmcall = // XXX Based on "Redsandro's" proposal
-Q.ninvoke = function (object, name /*...args*/) {
- var nodeArgs = array_slice(arguments, 2);
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- Q(object).dispatch("post", [name, nodeArgs]).fail(deferred.reject);
- return deferred.promise;
-};
-
-Promise.prototype.nsend = // XXX Based on Mark Miller's proposed "send"
-Promise.prototype.nmcall = // XXX Based on "Redsandro's" proposal
-Promise.prototype.ninvoke = function (name /*...args*/) {
- var nodeArgs = array_slice(arguments, 1);
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- this.dispatch("post", [name, nodeArgs]).fail(deferred.reject);
- return deferred.promise;
-};
-
-/**
- * If a function would like to support both Node continuation-passing-style and
- * promise-returning-style, it can end its internal promise chain with
- * `nodeify(nodeback)`, forwarding the optional nodeback argument. If the user
- * elects to use a nodeback, the result will be sent there. If they do not
- * pass a nodeback, they will receive the result promise.
- * @param object a result (or a promise for a result)
- * @param {Function} nodeback a Node.js-style callback
- * @returns either the promise or nothing
- */
-Q.nodeify = nodeify;
-function nodeify(object, nodeback) {
- return Q(object).nodeify(nodeback);
-}
-
-Promise.prototype.nodeify = function (nodeback) {
- if (nodeback) {
- this.then(function (value) {
- nextTick(function () {
- nodeback(null, value);
- });
- }, function (error) {
- nextTick(function () {
- nodeback(error);
- });
- });
- } else {
- return this;
- }
-};
-
-// All code before this point will be filtered from stack traces.
-var qEndingLine = captureLine();
-
-return Q;
-
-});
-
diff --git a/cmd/mist/assets/ext/qml_messaging.js b/cmd/mist/assets/ext/qml_messaging.js
deleted file mode 100644
index 031c5efd1..000000000
--- a/cmd/mist/assets/ext/qml_messaging.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
-//
-// This library 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 2.1 of the License, or (at your option) any later version.
-//
-// This library 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 this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-// MA 02110-1301 USA
-
-function HandleMessage(data) {
- var message;
- try { message = JSON.parse(data) } catch(e) {};
-
- if(message) {
- switch(message.type) {
- case "coinbase":
- return eth.coinBase();
- case "block":
- return eth.blockByNumber(0);
- }
- }
-}
diff --git a/cmd/mist/assets/ext/qt_messaging_adapter.js b/cmd/mist/assets/ext/qt_messaging_adapter.js
deleted file mode 100644
index 04f8e034a..000000000
--- a/cmd/mist/assets/ext/qt_messaging_adapter.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
-//
-// This library 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 2.1 of the License, or (at your option) any later version.
-//
-// This library 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 this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-// MA 02110-1301 USA
-
-window._messagingAdapter = function(data) {
- navigator.qt.postMessage(data);
-};
-
-navigator.qt.onmessage = function(ev) {
- var data = JSON.parse(ev.data)
-
- if(data._event !== undefined) {
- eth.trigger(data._event, data.data);
- } else {
- if(data._seed) {
- var cb = eth._callbacks[data._seed];
- if(cb) {
- cb.call(this, data.data)
-
- // Remove the "trigger" callback
- delete eth._callbacks[ev._seed];
- }
- }
- }
-}
diff --git a/cmd/mist/assets/ext/setup.js b/cmd/mist/assets/ext/setup.js
deleted file mode 100644
index 8317937b3..000000000
--- a/cmd/mist/assets/ext/setup.js
+++ /dev/null
@@ -1,8 +0,0 @@
-(function() {
- if (typeof(Promise) === "undefined")
- window.Promise = Q.Promise;
-
- var eth = web3.eth;
-
- web3.setProvider(new web3.providers.QtProvider());
-})()
diff --git a/cmd/mist/assets/ext/string.js b/cmd/mist/assets/ext/string.js
deleted file mode 100644
index e8dbd14d4..000000000
--- a/cmd/mist/assets/ext/string.js
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
-//
-// This library 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 2.1 of the License, or (at your option) any later version.
-//
-// This library 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 this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-// MA 02110-1301 USA
-
-String.prototype.pad = function(l, r) {
- if (r === undefined) {
- r = l
- if (!(this.substr(0, 2) == "0x" || /^\d+$/.test(this)))
- l = 0
- }
- var ret = this.bin();
- while (ret.length < l)
- ret = "\0" + ret
- while (ret.length < r)
- ret = ret + "\0"
- return ret;
-}
-
-String.prototype.unpad = function() {
- var i = this.length;
- while (i && this[i - 1] == "\0")
- --i
- return this.substr(0, i)
-}
-
-String.prototype.bin = function() {
- if (this.substr(0, 2) == "0x") {
- bytes = []
- var i = 2;
-
- // Check if it's odd - pad with a zero if so.
- if (this.length % 2)
- bytes.push(parseInt(this.substr(i++, 1), 16))
-
- for (; i < this.length - 1; i += 2)
- bytes.push(parseInt(this.substr(i, 2), 16));
-
- return String.fromCharCode.apply(String, bytes);
- } else if (/^\d+$/.test(this))
- return bigInt(this.substr(0)).toHex().bin()
-
- // Otherwise we'll return the "String" object instead of an actual string
- return this.substr(0, this.length)
-}
-
-String.prototype.unbin = function() {
- var i, l, o = '';
- for(i = 0, l = this.length; i < l; i++) {
- var n = this.charCodeAt(i).toString(16);
- o += n.length < 2 ? '0' + n : n;
- }
-
- return "0x" + o;
-}
-
-String.prototype.dec = function() {
- return bigInt(this.substr(0)).toString()
-}
-
-String.prototype.hex = function() {
- return bigInt(this.substr(0)).toHex()
-}
diff --git a/cmd/mist/assets/ext/test.html b/cmd/mist/assets/ext/test.html
deleted file mode 100644
index 4bac7d36f..000000000
--- a/cmd/mist/assets/ext/test.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!doctype>
-<html>
-<head>
-<title>Tests</title>
-</head>
-
-<body>
-<button onclick="test();">Test me</button>
-
-<script type="text/javascript">
-function test() {
- var filter = eth.watch({
- latest: -1,
- from: "e6716f9544a56c530d868e4bfbacb172315bdead",
- altered: ["aabb", {id: "eeff", "at": "aabb"}],
- });
-
- filter.changed(function(messages) {
- console.log("messages", messages)
- })
-
- filter.getMessages(function(messages) {
- console.log("getMessages", messages)
- });
-
- eth.getEachStorageAt("9ef0f0d81e040012600b0c1abdef7c48f720f88a", function(entries) {
- for(var i = 0; i < entries.length; i++) {
- console.log(entries[i].key, " : ", entries[i].value)
- }
- })
-
- eth.getBlock("f70097659f329a09642a27f11338d9269de64f1d4485786e36bfc410832148cd", function(block) {
- console.log(block)
- })
-
- eth.mutan("var a = 10", function(code) {
- console.log("code", code)
- });
-}
-</script>
-
-</body>
-
-</html>
diff --git a/cmd/mist/assets/ext/test/abi.parsers.js b/cmd/mist/assets/ext/test/abi.parsers.js
deleted file mode 100644
index b7a05cea3..000000000
--- a/cmd/mist/assets/ext/test/abi.parsers.js
+++ /dev/null
@@ -1,860 +0,0 @@
-var assert = require('assert');
-var BigNumber = require('bignumber.js');
-var abi = require('../lib/abi.js');
-var clone = function (object) { return JSON.parse(JSON.stringify(object)); };
-
-var description = [{
- "name": "test",
- "inputs": [{
- "name": "a",
- "type": "uint256"
- }
- ],
- "outputs": [
- {
- "name": "d",
- "type": "uint256"
- }
- ]
-}];
-
-describe('abi', function() {
- describe('inputParser', function() {
- it('should parse input uint', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "uint" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input uint128', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "uint128" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input uint256', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "uint256" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input int', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "int" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
- assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
- });
-
- it('should parse input int128', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "int128" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
- assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input int256', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "int256" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
- assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
- assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(
- parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
- "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
- );
- assert.equal(parser.test(0.1), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
- assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
- assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
-
- });
-
- it('should parse input bool', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: 'bool' }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test(true), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.test(false), "0000000000000000000000000000000000000000000000000000000000000000");
-
- });
-
- it('should parse input hash', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "hash" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
-
- });
-
- it('should parse input hash256', function() {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "hash256" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
-
- });
-
-
- it('should parse input hash160', function() {
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "hash160" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
- });
-
- it('should parse input address', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "address" }
- ];
-
- // when
- var parser = abi.inputParser(d)
-
- // then
- assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
-
- });
-
- it('should parse input string', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "string" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(
- parser.test('hello'),
- "000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"
- );
- assert.equal(
- parser.test('world'),
- "0000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000"
- );
- });
-
- it('should use proper method name', function () {
-
- // given
- var d = clone(description);
- d[0].name = 'helloworld(int)';
- d[0].inputs = [
- { type: "int" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.helloworld(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(parser.helloworld['int'](1), "0000000000000000000000000000000000000000000000000000000000000001");
-
- });
-
- it('should parse multiple methods', function () {
-
- // given
- var d = [{
- name: "test",
- inputs: [{ type: "int" }],
- outputs: [{ type: "int" }]
- },{
- name: "test2",
- inputs: [{ type: "string" }],
- outputs: [{ type: "string" }]
- }];
-
- // when
- var parser = abi.inputParser(d);
-
- //then
- assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
- assert.equal(
- parser.test2('hello'),
- "000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"
- );
-
- });
-
- it('should parse input array of ints', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: "int[]" }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(
- parser.test([5, 6]),
- "0000000000000000000000000000000000000000000000000000000000000002" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000006"
- );
- });
-
- it('should parse input real', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: 'real' }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test([1]), "0000000000000000000000000000000100000000000000000000000000000000");
- assert.equal(parser.test([2.125]), "0000000000000000000000000000000220000000000000000000000000000000");
- assert.equal(parser.test([8.5]), "0000000000000000000000000000000880000000000000000000000000000000");
- assert.equal(parser.test([-1]), "ffffffffffffffffffffffffffffffff00000000000000000000000000000000");
-
- });
-
- it('should parse input ureal', function () {
-
- // given
- var d = clone(description);
-
- d[0].inputs = [
- { type: 'ureal' }
- ];
-
- // when
- var parser = abi.inputParser(d);
-
- // then
- assert.equal(parser.test([1]), "0000000000000000000000000000000100000000000000000000000000000000");
- assert.equal(parser.test([2.125]), "0000000000000000000000000000000220000000000000000000000000000000");
- assert.equal(parser.test([8.5]), "0000000000000000000000000000000880000000000000000000000000000000");
-
- });
-
- });
-
- describe('outputParser', function() {
- it('should parse output string', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: "string" }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "68656c6c6f000000000000000000000000000000000000000000000000000000")[0],
- 'hello'
- );
- assert.equal(
- parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "776f726c64000000000000000000000000000000000000000000000000000000")[0],
- 'world'
- );
-
- });
-
- it('should parse output uint', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'uint' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10),
- new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).toString(10)
- );
- assert.equal(
- parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10),
- new BigNumber("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0", 16).toString(10)
- );
- });
-
- it('should parse output uint256', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'uint256' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10),
- new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).toString(10)
- );
- assert.equal(
- parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10),
- new BigNumber("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0", 16).toString(10)
- );
- });
-
- it('should parse output uint128', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'uint128' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(
- parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10),
- new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).toString(10)
- );
- assert.equal(
- parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10),
- new BigNumber("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0", 16).toString(10)
- );
- });
-
- it('should parse output int', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'int' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1);
- assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16);
- });
-
- it('should parse output int256', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'int256' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1);
- assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16);
- });
-
- it('should parse output int128', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'int128' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10);
- assert.equal(parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1);
- assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16);
- });
-
- it('should parse output hash', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'hash' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
- "0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
- );
- });
-
- it('should parse output hash256', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'hash256' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
- "0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
- );
- });
-
- it('should parse output hash160', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'hash160' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
- "0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
- );
- // TODO shouldnt' the expected hash be shorter?
- });
-
- it('should parse output address', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'address' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
- "0x407d73d8a49eeb85d32cf465507dd71d507100c1"
- );
- });
-
- it('should parse output bool', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'bool' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], true);
- assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000000")[0], false);
-
-
- });
-
- it('should parse output real', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'real' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000100000000000000000000000000000000")[0], 1);
- assert.equal(parser.test("0x0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125);
- assert.equal(parser.test("0x0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5);
- assert.equal(parser.test("0xffffffffffffffffffffffffffffffff00000000000000000000000000000000")[0], -1);
-
- });
-
- it('should parse output ureal', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: 'ureal' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x0000000000000000000000000000000100000000000000000000000000000000")[0], 1);
- assert.equal(parser.test("0x0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125);
- assert.equal(parser.test("0x0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5);
-
- });
-
-
- it('should parse multiple output strings', function() {
-
- // given
- var d = clone(description);
-
- d[0].outputs = [
- { type: "string" },
- { type: "string" }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(
- parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "68656c6c6f000000000000000000000000000000000000000000000000000000" +
- "776f726c64000000000000000000000000000000000000000000000000000000")[0],
- 'hello'
- );
- assert.equal(
- parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "68656c6c6f000000000000000000000000000000000000000000000000000000" +
- "776f726c64000000000000000000000000000000000000000000000000000000")[1],
- 'world'
- );
-
- });
-
- it('should use proper method name', function () {
-
- // given
- var d = clone(description);
- d[0].name = 'helloworld(int)';
- d[0].outputs = [
- { type: "int" }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.helloworld("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.helloworld['int']("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
-
- });
-
-
- it('should parse multiple methods', function () {
-
- // given
- var d = [{
- name: "test",
- inputs: [{ type: "int" }],
- outputs: [{ type: "int" }]
- },{
- name: "test2",
- inputs: [{ type: "string" }],
- outputs: [{ type: "string" }]
- }];
-
- // when
- var parser = abi.outputParser(d);
-
- //then
- assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
- assert.equal(parser.test2("0x" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "68656c6c6f000000000000000000000000000000000000000000000000000000")[0],
- "hello"
- );
-
- });
-
- it('should parse output array', function () {
-
- // given
- var d = clone(description);
- d[0].outputs = [
- { type: 'int[]' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000002" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000006")[0][0],
- 5
- );
- assert.equal(parser.test("0x" +
- "0000000000000000000000000000000000000000000000000000000000000002" +
- "0000000000000000000000000000000000000000000000000000000000000005" +
- "0000000000000000000000000000000000000000000000000000000000000006")[0][1],
- 6
- );
-
- });
-
- it('should parse 0x value', function () {
-
- // given
- var d = clone(description);
- d[0].outputs = [
- { type: 'int' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x")[0], 0);
-
- });
-
- it('should parse 0x value', function () {
-
- // given
- var d = clone(description);
- d[0].outputs = [
- { type: 'uint' }
- ];
-
- // when
- var parser = abi.outputParser(d);
-
- // then
- assert.equal(parser.test("0x")[0], 0);
-
- });
-
- });
-});
-
diff --git a/cmd/mist/assets/ext/test/db.methods.js b/cmd/mist/assets/ext/test/db.methods.js
deleted file mode 100644
index 8f8f5409f..000000000
--- a/cmd/mist/assets/ext/test/db.methods.js
+++ /dev/null
@@ -1,14 +0,0 @@
-
-var assert = require('assert');
-var web3 = require('../index.js');
-var u = require('./utils.js');
-
-describe('web3', function() {
- describe('db', function() {
- u.methodExists(web3.db, 'put');
- u.methodExists(web3.db, 'get');
- u.methodExists(web3.db, 'putString');
- u.methodExists(web3.db, 'getString');
- });
-});
-
diff --git a/cmd/mist/assets/ext/test/eth.methods.js b/cmd/mist/assets/ext/test/eth.methods.js
deleted file mode 100644
index 7a031c4c8..000000000
--- a/cmd/mist/assets/ext/test/eth.methods.js
+++ /dev/null
@@ -1,34 +0,0 @@
-var assert = require('assert');
-var web3 = require('../index.js');
-var u = require('./utils.js');
-
-describe('web3', function() {
- describe('eth', function() {
- u.methodExists(web3.eth, 'balanceAt');
- u.methodExists(web3.eth, 'stateAt');
- u.methodExists(web3.eth, 'storageAt');
- u.methodExists(web3.eth, 'countAt');
- u.methodExists(web3.eth, 'codeAt');
- u.methodExists(web3.eth, 'transact');
- u.methodExists(web3.eth, 'call');
- u.methodExists(web3.eth, 'block');
- u.methodExists(web3.eth, 'transaction');
- u.methodExists(web3.eth, 'uncle');
- u.methodExists(web3.eth, 'compilers');
- u.methodExists(web3.eth, 'lll');
- u.methodExists(web3.eth, 'solidity');
- u.methodExists(web3.eth, 'serpent');
- u.methodExists(web3.eth, 'logs');
-
- u.propertyExists(web3.eth, 'coinbase');
- u.propertyExists(web3.eth, 'listening');
- u.propertyExists(web3.eth, 'mining');
- u.propertyExists(web3.eth, 'gasPrice');
- u.propertyExists(web3.eth, 'accounts');
- u.propertyExists(web3.eth, 'peerCount');
- u.propertyExists(web3.eth, 'defaultBlock');
- u.propertyExists(web3.eth, 'number');
- });
-});
-
-
diff --git a/cmd/mist/assets/ext/test/mocha.opts b/cmd/mist/assets/ext/test/mocha.opts
deleted file mode 100644
index c4a633d64..000000000
--- a/cmd/mist/assets/ext/test/mocha.opts
+++ /dev/null
@@ -1,2 +0,0 @@
---reporter spec
-
diff --git a/cmd/mist/assets/ext/test/shh.methods.js b/cmd/mist/assets/ext/test/shh.methods.js
deleted file mode 100644
index fe2dae71d..000000000
--- a/cmd/mist/assets/ext/test/shh.methods.js
+++ /dev/null
@@ -1,14 +0,0 @@
-var assert = require('assert');
-var web3 = require('../index.js');
-var u = require('./utils.js');
-
-describe('web3', function() {
- describe('shh', function() {
- u.methodExists(web3.shh, 'post');
- u.methodExists(web3.shh, 'newIdentity');
- u.methodExists(web3.shh, 'haveIdentity');
- u.methodExists(web3.shh, 'newGroup');
- u.methodExists(web3.shh, 'addToGroup');
- });
-});
-
diff --git a/cmd/mist/assets/ext/test/utils.js b/cmd/mist/assets/ext/test/utils.js
deleted file mode 100644
index 8a1e9a0b6..000000000
--- a/cmd/mist/assets/ext/test/utils.js
+++ /dev/null
@@ -1,19 +0,0 @@
-var assert = require('assert');
-
-var methodExists = function (object, method) {
- it('should have method ' + method + ' implemented', function() {
- assert.equal('function', typeof object[method], 'method ' + method + ' is not implemented');
- });
-};
-
-var propertyExists = function (object, property) {
- it('should have property ' + property + ' implemented', function() {
- assert.notEqual('undefined', typeof object[property], 'property ' + property + ' is not implemented');
- });
-};
-
-module.exports = {
- methodExists: methodExists,
- propertyExists: propertyExists
-};
-
diff --git a/cmd/mist/assets/ext/test/web3.methods.js b/cmd/mist/assets/ext/test/web3.methods.js
deleted file mode 100644
index d08495dd9..000000000
--- a/cmd/mist/assets/ext/test/web3.methods.js
+++ /dev/null
@@ -1,10 +0,0 @@
-var assert = require('assert');
-var web3 = require('../index.js');
-var u = require('./utils.js');
-
-describe('web3', function() {
- u.methodExists(web3, 'sha3');
- u.methodExists(web3, 'toAscii');
- u.methodExists(web3, 'fromAscii');
-});
-